Esempio n. 1
0
 public function theme($file_path, $data = 0, $output = true)
 {
     try {
         if (wt_is_writable(WT_PLUGIN_PATH . "dwoo/compiled/")) {
             global $_wt_options;
             $theme_path = wt_get_theme_path();
             $this->tpl = new Dwoo();
             if ($data) {
                 if ($this->file) {
                     $path = realpath($this->file);
                     $this->remove_file_path();
                 } else {
                     $path = realpath($this->path . '/' . $file_path);
                 }
                 if (file_exists($path)) {
                     if ($output) {
                         $this->tpl->output($path, $data);
                     } else {
                         return $this->tpl->get($path, $data);
                     }
                 } else {
                     echo "File Path <i>{$file_path}</i> doesnt exist, please add it to your theme library";
                 }
             }
         } else {
             throw new Exception("In order to display results, WordTour is using DWOO framework that requires write permission on folder <i>'" . WT_PLUGIN_PATH . "dwoo/compiled'</i>\n\t\t\t\t\tPlease set your permission level to read/write. contact your server administrator if WordPress is being hosted on a Windows server For Unix and Linux <a href='http://codex.wordpress.org/Changing_File_Permissions'>click here</a>");
         }
     } catch (Exception $e) {
         if (!wt_is_writable(WT_PLUGIN_PATH . "dwoo/compiled/")) {
             echo "<div class='error' style='background-color:#FFCCBF;padding:5px;border:1px solid #FF9980;'>An Error has Occurred<br/><i>" . $e->getMessage() . "</i></div>";
         }
     }
 }
Esempio n. 2
0
function wt_is_writable($path)
{
    if ($path[strlen($path) - 1] == '/') {
        return wt_is_writable($path . uniqid(mt_rand()) . '.tmp');
    }
    if (file_exists($path)) {
        if (!($f = @fopen($path, 'r+'))) {
            return false;
        }
        fclose($f);
        return true;
    }
    if (!($f = @fopen($path, 'w'))) {
        return false;
    }
    fclose($f);
    unlink($path);
    return true;
}
Esempio n. 3
0
function plugin_theme_backup_recover()
{
    try {
        $from = dirname(__FILE__) . "/../wordtour_theme_backup/";
        $to = dirname(__FILE__) . "/theme/";
        if (wt_is_writable($to) && wt_is_writable($from)) {
            plugin_theme_backup_copyr($from, $to);
            if (is_dir($from)) {
                plugin_theme_backup_rmdirr($from);
                #http://putraworks.wordpress.com/2006/02/27/php-delete-a-file-or-a-folder-and-its-contents/
            }
        }
    } catch (Exception $e) {
        //echo "Error backup theme folders, probably a permission isn't assigned to wordtour/theme folder";
        //return 0;
    }
}