Beispiel #1
0
 /**
  * Tries to initialise from WordPress options.
  * @return bool true on success
  */
 private function load_from_wp()
 {
     if (function_exists('get_option')) {
         $savedSettings = (array) get_option('wpu-settings');
         $defaults = $this->get_defaults();
         $this->settings = array_merge($defaults, (array) $savedSettings);
         $this->wpPath = ABSPATH;
         $this->pluginPath = plugin_dir_path(__FILE__);
         $this->pluginUrl = plugins_url('wp-united') . '/';
         $this->wpHomeUrl = home_url('/');
         $this->wpBaseUrl = site_url('/');
         $this->wpDocRoot = wpu_get_doc_root();
         return true;
     }
     return false;
 }
function wpu_filetree()
{
    if (stristr($_POST['filetree'], '..')) {
        die;
    }
    $docRoot = wpu_get_doc_root();
    $fileLoc = str_replace('\\', '/', urldecode($_POST['filetree']));
    if (stristr($fileLoc, $docRoot) === false) {
        $fileLoc = $docRoot . $fileLoc;
        $fileLoc = str_replace('//', '/', $fileLoc);
    }
    if (@file_exists($fileLoc)) {
        $files = scandir($fileLoc);
        natcasesort($files);
        if (count($files) > 2) {
            /* The 2 accounts for . and .. */
            echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">";
            // All dirs
            foreach ($files as $file) {
                if (@file_exists($fileLoc . $file) && $file != '.' && $file != '..' && is_dir($fileLoc . $file)) {
                    echo "<li class=\"directory collapsed\"><a href=\"#\" rel=\"" . htmlentities($fileLoc . $file) . "/\">" . htmlentities($file) . "</a></li>";
                }
            }
            // All files
            foreach ($files as $file) {
                if (@file_exists($fileLoc . $file) && $file != '.' && $file != '..' && !is_dir($fileLoc . $file)) {
                    $ext = preg_replace('/^.*\\./', '', $file);
                    echo "<li class=\"file ext_{$ext}\"><a href=\"#\" rel=\"" . htmlentities($fileLoc . $file) . "\">" . htmlentities($file) . "</a></li>";
                }
            }
            echo "</ul>";
        }
    }
    die;
}