function chown()
 {
     $pages = $this->get_pages();
     foreach ($pages as $page) {
         $file = get_filename($page);
         // this func was created after I suggested, now I can be lazy
         if (pkwk_chown($file, true) === FALSE) {
             return "<p><b>Failed to chown {$page}. </b></p>";
         }
     }
     return '<p><b>Chown was done. </b></p>';
 }
 /**
  * Dump the PukiWiki output of a page into a html file
  *
  * @param string $page Pagename
  * @param string $file Filename to be dumped. Default is computed from $page. 
  * @param boolean $overwrite Force to overwrite. Default overwrites if $page is newer than $file
  * @param boolean $notimestamp Do not change timestamp for dumped file
  * @return mixed
  *   TRUE : Success
  *   FALSE: Failure
  *   -1   : It is already up2date
  *   -2   : Exit by read-restriction
  *   -3   : Exit because statichtml USER_AGENT called statichtml again (infinite loop)
  */
 function dump_page($page, $file = null, $overwrite = FALSE, $notimestamp = FALSE)
 {
     // statichtml USER_AGENT should not call statichtml again (avoid infinite loop)
     if (isset($GLOBALS['vars'][$this->plugin])) {
         return -3;
     }
     // Initialization
     if (!isset($file)) {
         $file = $this->get_dump_filename($page);
     }
     if (!is_page($page)) {
         if (file_exists($file)) {
             pkwk_chown($file);
             @unlink($file);
         }
         return TRUE;
     }
     // Up2date?
     if (!$overwrite && !is_page_newer($page, $file)) {
         return -1;
     }
     // Try to create dir
     $dir = dirname($file);
     if (isset($GLOBALS['PLUGIN_STATICHTML_MKDIR_CGI'])) {
         $error = file_get_contents($GLOBALS['PLUGIN_STATICHTML_MKDIR_CGI'] . '&mode=0777&dir=' . $dir);
         if ($error != '1') {
             $this->error = 'Failed to create ' . $dir . ' directory.';
             return FALSE;
         }
     } else {
         if (r_mkdir($dir) === FALSE) {
             $this->error = 'Failed to create ' . $dir . ' directory.';
             return FALSE;
         }
     }
     // Get contents
     if (is_read_auth($page) && !$this->CONF['readauth']) {
         return -2;
         // Do not read read-restriction pages
     }
     if (($contents = $this->http_pkwk_output($page)) === FALSE) {
         return -2;
         // HTTP GET failure (mostly because of read-restriction)
     }
     // Write
     $filemtime = file_exists($file) && $notimestamp ? filemtime($file) : FALSE;
     if (!file_put_contents($file, $contents)) {
         $this->error = 'Failed to create ' . $file;
         return FALSE;
     }
     if ($notimestamp) {
         pkwk_touch_file($file, $filemtime, $filemtime);
     }
     return TRUE;
 }
Example #3
0
function pkwk_touch_file($filename, $time = FALSE, $atime = FALSE)
{
    // Is the owner incorrected and unable to correct?
    if (!file_exists($filename) || pkwk_chown($filename)) {
        if ($time === FALSE) {
            $result = touch($filename);
        } else {
            if ($atime === FALSE) {
                $result = touch($filename, $time);
            } else {
                $result = touch($filename, $time, $atime);
            }
        }
        return $result;
    } else {
        die('pkwk_touch_file(): Invalid UID and (not writable for the directory or not a flie): ' . htmlspecialchars(basename($filename)));
    }
}
Example #4
0
File: file.php Project: big2men/qhm
function pkwk_touch_file($filename, $time = FALSE, $atime = FALSE)
{
    $qm = get_qm();
    // Is the owner incorrected and unable to correct?
    if (!file_exists($filename) || pkwk_chown($filename)) {
        if ($time === FALSE) {
            $result = touch($filename);
        } else {
            if ($atime === FALSE) {
                $result = touch($filename, $time);
            } else {
                $result = touch($filename, $time, $atime);
            }
        }
        return $result;
    } else {
        die($qm->replace('file.err_pkwk_touch_invalid_uid', h(basename($filename))));
    }
}