Purging thumbnails cache -> Permission denied

Discussion in 'General Support' started by david62311, Dec 7, 2018.

  1. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    New error for the latest github Webid script

    Here's the errors reported in my Webid Admin Panel:


    The code around there is this:

    PHP:
    // Purging thumbnails cache
        
    if (!file_exists(UPLOAD_PATH 'cache')) {
            
    mkdir(UPLOAD_PATH 'cache'0777);
        }

        if (!
    file_exists(UPLOAD_PATH 'cache/purge')) {
            
    touch(UPLOAD_PATH 'cache/purge');
        }

        
    $purgecachetime filectime(UPLOAD_PATH 'cache/purge');
        if ((
    time() - $purgecachetime) > 86400) {
            
    $dir UPLOAD_PATH 'cache';
            if (
    $dh opendir($dir)) {
                while ((
    $file readdir($dh)) !== false) {
                    if (
    $file != 'purge' && !is_dir($dir '/' $file) && (time() - filectime($dir '/' $file)) > 86400) {
                        
    unlink($dir '/' $file);
                    }
                }
                
    closedir($dh);
            }
            
    touch(UPLOAD_PATH 'cache/purge');
        }
    I am going to show a picture of the code just for reference of what each line number is showing. I put a blip next to the error lines. You can see the cache is set for 777 permission.

    capture-20181206-204538.png

    The problem could have something to do with the lock feature that is wrapped around most of the cron.php page. The errors that have been reported have repeated "Permission denied" 4 times. All I did was refresh the index.php page which has include to the cron.php page. The lock has never worked right. The lock feature has had about 3 updates to it but, I do not believe it has been tested.

    None of my images are coming up. I had added the lock to my older site and it was wiping out my auctions table completely when I visited or refreshed the index.php page. I have since gutted my Webid site and reinstalled the latest Webid Github script recently so, I could help out with the testing.

    It someone can figure out what the permission issue is and help us fix it then that would be greatly appreciated.

    Here's a good example how the flock code works:
    https://www.w3schools.com/php/func_filesystem_flock.asp
     
    Last edited: Dec 7, 2018
  2. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    It doesn't appear to be the lock. I used an older cron.php code that doesn't have the lock on it and it still gave the same errors.

    For the record, I cleared out all of my .htaccess code just in case there wasn't something there in the htaccess blocking something there and there was still issues.
     
    Last edited: Dec 7, 2018
  3. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    I don't know if this is related but, when I click on the item, it spits out this error:

    This is for the includes/date.php file. Line 86 is the 4th line down:

    PHP:
        public function formatDate($raw_date$format false$UTC_input true)
        {
            if (
    $UTC_input) {
                
    $datetime = new DateTime($raw_date$this->UTCtimezone);
                
    $datetime->setTimezone($this->timezone);
            } else {
                
    $datetime = new DateTime($raw_date$this->timezone);
            }
            if (!
    $format) {
                return 
    $datetime->format($this->defaultformat);
            } else {
                return 
    $datetime->format($format);
            }
        }
    The main error reported is this:

    Could this be the problem? I am noticing the the single quotes are showing in part in the error that I posted at the top but, the single quotes are not showing on this: (1375794060)
     
    Last edited: Dec 7, 2018
  4. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    PHP:
        public function formatDate($raw_date$format false$UTC_input true)
        {
            if (
    $UTC_input) {
                
    $datetime = new DateTime($raw_date$this->UTCtimezone);
                
    $datetime->setTimezone($this->timezone);
            } else {
                
    $datetime = new DateTime($raw_date$this->timezone);
            }
            if (!
    $format) {
                return 
    $datetime->format($this->defaultformat);
            } else {
                return 
    $datetime->format($format);
            }
        }
    To this:

    PHP:
        public function formatDate($raw_date$format false$UTC_input true)
        {
            if (
    $UTC_input) {
                
    $datetime = new DateTime(strtotime($raw_date), $this->UTCtimezone);
                
    $datetime->setTimezone($this->timezone);
            } else {
                
    $datetime = new DateTime($raw_date$this->timezone);
            }
            if (!
    $format) {
                return 
    $datetime->format($this->defaultformat);
            } else {
                return 
    $datetime->format($format);
            }
        }
    This did fix this getthumb error:
     
    Last edited: Dec 7, 2018
  5. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    That update fixed the issue on the item.php page but, caused the same error for the same line to report on the sell.php page. We got to take a look at the item.php page and see what is related to this line of code:

    PHP:
    $datetime = new DateTime(strtotime($raw_date), $this->UTCtimezone);
    ...and to see how it connects to the sell.php page.
     
  6. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    Error fix for posts #3,4,5. This part is solved now.

    Get rid of the $raw_date for that section of code around line 86 and line 89 and make it 'now'.

    Make the code like this on the includes/Date.php page:
    PHP:
        public function formatDate($raw_date$format false$UTC_input true)
        {
            if (
    $UTC_input) {
                
    $datetime = new DateTime('now'$this->UTCtimezone);
                
    $datetime->setTimezone($this->timezone);
            } else {
                
    $datetime = new DateTime('now'$this->timezone);
            }
            if (!
    $format) {
                return 
    $datetime->format($this->defaultformat);
            } else {
                return 
    $datetime->format($format);
            }
        }
     
  7. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    I know most of the time I am hard to understand. I come back and I sometimes have to figure out what the heck I was talking about...LOL.

    I mentioned it reported "Permission denied" 4 times.

    For some reason my uploaded folder permission was at 644 when the permission on the uploaded folder could be set at 755 to fix the issue.

    I thought I tested it at 777 yesterday but, I most likely did not. It must of been another folder like perhaps the includes folder.

    Problem solved on the "Permission denied" too!
     

Share This Page