Jump to content

Matt Cohen

Members
  • Posts

    7
  • Joined

  • Last visited

Posts posted by Matt Cohen

  1. Hi there, I have an issue with my code where when it goes to save the page - it saves it using an ugly unix time stamp.

    Example: /lost-property/2016-05-25-13-40-16/

    What I am wanting to do is instead of saving as timestamp, I'd like to use the id of the page.  

    /lost-property/42854

    
    

    My code is

    <? if ($input->post->lp_date) {
    
    // Save in the ProcessWire page tree; map submission to the template fields
    $np = new Page(); // create new page object
    $np->template = $templates->get("lost-property");
    $np->parent = $pages->get("/lost-property/");
    
    // Send all form submissions through ProcessWire sanitization
    $lp_date = $sanitizer->text($input->post->lp_date);
    $lp_type = $sanitizer->text ($input->post->lp_type);
    $lp_city = $sanitizer->text($input->post->lp_city);
    $lp_row = $sanitizer->text($input->post->lp_row);
    $lp_item = $sanitizer->text($input->post->lp_item);
    $lp_description = $sanitizer->text($input->post->lp_description);
    $lp_contactname = $sanitizer->text($input->post->lp_contactname);
    $lp_contact = $sanitizer->text($input->post->lp_contact);
    $lp_ro = $sanitizer->text($input->post->lp_ro);
    $lp_status = $sanitizer->text($input->post->lp_status);
    
    // Match up the sanitized inputs we just got with the template fields
    $np->of(false);
    $np->title = $title;
    $np->lp_type = $lp_type;
    $np->lp_date = $lp_date;
    $np->lp_city = $lp_city;
    $np->lp_row = $lp_row;
    $np->lp_item = $lp_item;
    $np->lp_description = $lp_description;
    $np->lp_contactname = $lp_contactname;
    $np->lp_contact = $lp_contact;
    $np->lp_ro = $lp_ro;
    $np->lp_status = 'open'; // Set the status to 1 (confrimed )
    
    // Save/create the page
    $np->save(); ?>
  2. Hi there, I am having a trouble with my selector. I'm wanting to return a list of pages that belong to a template and a particular user. However not returning any results.

     Here is my code

    <?$lostproperty = $pages->find("user=matt, template=lost-property");
    
                          foreach ($lostproperty as $items) {
    
                            echo "<td><a href='$items->url'>$items->id </a></td>";
                            echo "</td>";
                           
                            echo "<td>";
                            echo $items->modifiedUser->name;
                            echo "</td>";
    
                            echo "<td>";
                            echo date("d/m/y H:i", $items->created);                     echo "</td>";
                            echo "</td>";
                            echo "<td>";
                            echo "$items->lp_city";
                            echo "</td>";
                            echo "<td>$items->lp_row";
                            echo "</td>";
                            echo "<td> $items->lp_item";
                            echo "</td>";
                             echo "<td > $items->lp_description";
                            echo "</td>";
                             echo "<td style='text-transform:capitalize'> $items->lp_contactname";
                            echo "</td>";
                             echo "<td style='text-transform:capitalize'> $items->lp_contact";
                            echo "</td>";
                             echo "<td> $items->lp_ro";
                            echo "</td>";
                             echo "<td> $items->lp_status";
                            echo "</td>";
    
                            echo "</tr>";
                          }
                          ?>
  3. Hi there, I am getting server 500 errors when trying to display images on my site.

    Here is my web.config file

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <configSections>
            <sectionGroup name="system.webServer">
                <sectionGroup name="rewrite">
                    <section name="rewriteMaps" overrideModeDefault="Allow" />
                    <section name="rules" overrideModeDefault="Allow" />
                </sectionGroup>
            </sectionGroup>
        </configSections>
        <system.webServer>
            <security>
                <requestFiltering>
                        <denyUrlSequences>
                        <add sequence=".inc" />
                        <add sequence=".info" />
                        <add sequence=".sh" />
                        <add sequence=".sql" />
                        <add sequence="\..*" />
                    </denyUrlSequences>
                    <fileExtensions>
                        <add fileExtension=".sql" allowed="false" />
                    </fileExtensions>
                </requestFiltering>
            </security>
            <directoryBrowse enabled="false" />
            <rewrite>
                <rules>
                    <rule name="Handle request for missing favicon.ico" stopProcessing="true">
                        <match url="favicon\.ico" />
                        <action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="The requested file favicon.ico was not found" statusDescription="The requested file favicon.ico was not found" />
                    </rule>
                    <rule name="Handle request for missing robots.txt" stopProcessing="true">
                        <match url="robots\.txt" />
                        <action type="CustomResponse" statusCode="404" subStatusCode="1" statusReason="The requested file robots.txt was not found" statusDescription="The requested file robots.txt was not found" />
                    </rule>
                    <rule name="Access Restrictions: Keep web users out of directories">
                        <match url="(^|/)\." ignoreCase="false" />
                        <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                    </rule>
                    <rule name="Access Restrictions: Protect ProcessWire system files" stopProcessing="true">
                      <match url="^.*$" ignoreCase="false" />
                      <conditions logicalGrouping="MatchAny">
                            <add input="{URL}" pattern="(^|/)site/assets/(cache|logs|backups|sessions|config|install)($|/.*$)" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)site/install($|/.*$)" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)site/config\.php$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)(wire|site)/templates-admin($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)site/templates($|/|/.*\.(php|html?|tpl|inc))$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)site/assets($|/|/.*\.php)$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)wire/(core|modules)/.*\.(php|inc|tpl|module)$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)site/modules/.*\.(php|inc|tpl|module)$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)processwire/module/.*\.(php|inc|tpl|module)$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)processwire/.*\.(php|inc|tpl|module)$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)(COPYRIGHT|INSTALL|README|htaccess)\.txt$" ignoreCase="false" />
                            <add input="{URL}" pattern="(^|/)site-default/" ignoreCase="false" />
                      </conditions>
                      <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
                    </rule>
                    <rule name="ProcessWire Rewrite" stopProcessing="true">
                        <match url="^(.*)$" ignoreCase="false" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{URL}" pattern="^/~?[-_.a-zA-Z0-9/]*$" ignoreCase="false" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" pattern="(favicon\.ico|robots\.txt)" ignoreCase="false" negate="true" />
                            <add input="{URL}" pattern="\.(gif|jpg|png|ico)$" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="index.php?it={R:1}" appendQueryString="true" />
                    </rule>
                </rules>
            </rewrite>
            <caching>
                <profiles>
                    <remove extension=".php" />
                </profiles>
            </caching>
        </system.webServer>
    </configuration>

    When I remove this section I get the imagees to display but all the sub directories on the site don't display?

          <add input="{URL}" pattern="^/~?[-_.a-zA-Z0-9/]*$" ignoreCase="false" />
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
                            <add input="{REQUEST_FILENAME}" pattern="(favicon\.ico|robots\.txt)" ignoreCase="false" negate="true" />
                            <add input="{URL}" pattern="\.(gif|jpg|png|ico)$" negate="true" />
     

    Any ideas. Running PW on IIS 7 on Windows Server 2008 r2. 

  4. Hi everybody, So it turns out PW works on IIS pretty well. Had very little issues in getting it to run and not many issues in getting it setup.... in a localhost environment. 

    I've been given a Windows Hyper-V server for the uses of my intranet that I've been building with PW. The only problem is now, I seem to be having issues whenever trying to log in. It doesn't recognize the admin user I created during installation, it simply redirects back to the /login/ page, with no error message. 

    Debugging shows the following message on the frontend login screen (not the backend). Localhost does not show this 

    Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[22003]: Numeric value out of range: 1264 Out of range value for column 'ip' at row 1' in C:\inetpub\wwwroot\wire\modules\Session\SessionHandlerDB\SessionHandlerDB.module:109 Stack trace: #0 C:\inetpub\wwwroot\wire\modules\Session\SessionHandlerDB\SessionHandlerDB.module(109): PDOStatement->execute() #1 [internal function]: SessionHandlerDB->write('j398has5jatl2lb...', 'Session|a:1:{s:...') #2 [internal function]: session_write_close() #3 {main} thrown inC:\inetpub\wwwroot\wire\modules\Session\SessionHandlerDB\SessionHandlerDB.module on line 109

    When moving the dev machine to production, here are the steps I followed:

    • Copied wwwroot from development machine to the production server
    • Exported by site's database using SQL Front and importing on the production server
    • Allowed access on the production server
    • Edited site/config and wire/config to add in the hosts - appname.domainname.co.nz, localhost, 192.1.90.1

    Now this is the real kicker:  I can goto http://localhost on the production machine, and get full access and it works fine... However when I try using appname.domainname.co.nz, I keep getting this weird "blank" redirect.

    I would really appreciate any help anyone would be able to give me. I have looked all thru the PW forums for something similar around this to no avail.

  5. Good morning everybody :)

    I am wondering if anyone has a short guide in setting up PW Microsoft IIS Version 10 or if anyone has been able to successfully deploy it on IIS.

    Currently building an intranet system with PW for my work, and currently all of their server technology is IIS and are unwilling to deploy a Linux machine

    Any assistance or help with this would be absolutely fantastic :)

×
×
  • Create New...