Ejemplo n.º 1
0
function make_directory_if_missing($path)
{
    if (is_dir($path)) {
        return;
    }
    make_directory($path);
}
Ejemplo n.º 2
0
 function make_directory($ftp_stream, $dir)
 {
     if (ftp_is_dir($ftp_stream, $dir) || @ftp_mkdir($ftp_stream, $dir)) {
         return true;
     }
     if (!make_directory($ftp_stream, dirname($dir))) {
         return false;
     }
     return ftp_mkdir($ftp_stream, $dir);
 }
Ejemplo n.º 3
0
            }
            break;
        default:
            die("Invalid action specified");
            break;
    }
}
switch ($event) {
    case 'view':
        draw_header();
        draw_location();
        draw_tree();
        draw_files();
        draw_footer();
        break;
    case 'upload':
        upload_file();
        break;
    case 'mkdir':
        make_directory();
        break;
    case 'download':
        download_file();
        break;
    case 'passwd':
        change_passwd();
        break;
    default:
        die('Invalid event');
        break;
}
Ejemplo n.º 4
0
    if ('mul' !== $code) {
        return true;
    }
    return false;
};
$languages = get_data('Languages', $langDir, $defaultLocale, $languagesConstraint);
// Display locales
$displayLocales = get_data('Locales', $namesDir, $defaultLocale);
// Create the stubs datafiles
$stubDir = $target . DIRECTORY_SEPARATOR . 'stub';
$stubCurrDir = $stubDir . DIRECTORY_SEPARATOR . 'curr';
$stubLangDir = $stubDir . DIRECTORY_SEPARATOR . 'lang';
$stubNamesDir = $stubDir . DIRECTORY_SEPARATOR . 'names';
$stubRegionDir = $stubDir . DIRECTORY_SEPARATOR . 'region';
// Create the directories
make_directory($stubDir);
make_directory($stubCurrDir);
make_directory($stubLangDir);
make_directory($stubNamesDir);
make_directory($stubRegionDir);
clear_directory($stubCurrDir);
clear_directory($stubLangDir);
clear_directory($stubNamesDir);
clear_directory($stubRegionDir);
create_stub_datafile($defaultLocale, $stubCurrDir, $currencies);
create_stub_datafile($defaultLocale, $stubLangDir, $languages);
create_stub_datafile($defaultLocale, $stubNamesDir, $displayLocales);
create_stub_datafile($defaultLocale, $stubRegionDir, $countries);
// Clean up
clear_directory($currDir);
rmdir($currDir);
Ejemplo n.º 5
0
$localesDir = $target . DIRECTORY_SEPARATOR . 'locales';
$namesDir = $target . DIRECTORY_SEPARATOR . 'names';
$namesGeneratedDir = $namesDir . DIRECTORY_SEPARATOR . 'generated';
$regionDir = $target . DIRECTORY_SEPARATOR . 'region';
make_directory($langDir);
clear_directory($langDir);
genrb($source . DIRECTORY_SEPARATOR . 'lang', $langDir);
make_directory($localesDir);
clear_directory($localesDir);
genrb($source . DIRECTORY_SEPARATOR . 'locales', $localesDir);
make_directory($regionDir);
clear_directory($regionDir);
genrb($source . DIRECTORY_SEPARATOR . 'region', $regionDir);
make_directory($namesDir);
clear_directory($namesDir);
make_directory($namesGeneratedDir);
clear_directory($namesGeneratedDir);
// Discover the list of supported locales, which are the names of the resource
// bundles in the "locales" directory
$supportedLocales = list_files($localesDir, '.res');
sort($supportedLocales);
// Delete unneeded locales
foreach ($supportedLocales as $key => $supportedLocale) {
    // Delete all aliases from the list
    // i.e., "az_AZ" is an alias for "az_Latn_AZ"
    $localeBundleOrig = file_get_contents($source . DIRECTORY_SEPARATOR . 'locales' . DIRECTORY_SEPARATOR . $supportedLocale . '.txt');
    // The key "%%ALIAS" is not accessible through the \ResourceBundle class
    if (strpos($localeBundleOrig, '%%ALIAS') !== false) {
        unset($supportedLocales[$key]);
    }
    // Delete locales that have no content (i.e. only "Version" key)
function make_directory($dir, $mode = 0777)
{
    $parent_dir = dirname($dir);
    if (!file_exists($parent_dir)) {
        make_directory($parent_dir, $mode);
    }
    mkdir($dir);
    chmod($dir, $mode);
}
Ejemplo n.º 7
0
function addUpdateFile($repo_owner, $repo_name, $branch, $path, $username, $password)
{
    $url = 'https://raw.githubusercontent.com/' . $repo_owner . '/' . $repo_name . '/' . $branch . '/' . $path;
    //strip "upload/" for dev server only
    if (substr($path, 0, 7) == "upload/") {
        $path = substr($path, 7, strlen($path) - 7);
    } else {
        //this is outside upload/ then, skip.
        echo "[skipped] Outside: " . $path . "<br>";
        continue;
    }
    //-----------------------------------------
    $dirname = dirname($path);
    $chdir = is_dir($dirname);
    if ($chdir == false) {
        if (make_directory($dirname)) {
            //$logmsg .= "[".date('d-m-Y h:i:s')."] - Created new directory '$dirname'\n";
        } else {
            //$logmsg .= "[".date('d-m-Y h:i:s')."] - Failed to create directory '$dirname'\n";
        }
    }
    if (file_exists($path)) {
        unlink($path);
    }
    $fp = fopen($path, 'w');
    $ch = curl_init($url);
    $User_Agent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31';
    $cookies = 'CookieName1=Value;CookieName2=$password';
    curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
    curl_setopt($ch, CURLOPT_USERAGENT, $User_Agent);
    curl_setopt($ch, CURLOPT_COOKIE, $cookies);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
    curl_setopt($ch, CURLOPT_FILE, $fp);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_exec($ch);
    curl_close($ch);
}
 public function process($filename)
 {
     global $s_runconf;
     if (DEBUG) {
         $sql_t = $s_runconf->get('time.sql.parse') + $s_runconf->get('time.sql.query');
         $st = get_microtime();
         $nested = $s_runconf->get('tpl.nested', array());
         $nested[] = 0;
         $s_runconf->set('tpl.nested', $nested);
     }
     $funcname = $this->generate_funcname($filename);
     if (!function_exists($funcname)) {
         if (!file_exists($filename)) {
             throw new Exception("Template \"{$filename}\" doesn't exists");
         }
         $dir = substr(dirname($filename), strlen(BASE));
         $rdir = conf('cache.path') . 'templates/' . $dir;
         if ($rdir != '' && !is_dir($rdir)) {
             make_directory($rdir);
         }
         if (substr($rdir, -1) != '/') {
             $rdir .= '/';
         }
         $rname = $rdir . basename($filename) . '.php';
         $mt = filemtime($filename);
         $mk = true;
         if (!file_exists($rname) || filemtime($rname) < $mt) {
             dwrite('Parsing template "' . $rname . '"', S_ACCENT);
             $parsed = $this->parse(file_get_contents($filename), $funcname);
             if ($fp = @fopen($rname, 'wb')) {
                 fwrite($fp, '<' . '?' . 'php' . "\n" . $parsed);
                 // closing php tag is not necessary
                 fclose($fp);
                 chmod($rname, 0555 + 0111);
             } else {
                 dwrite("Can't write template to \"{$rname}\"", S_ERROR);
             }
             eval($parsed);
         } else {
             dwrite('Loading template "' . $rname . '"', S_ACCENT);
             require $rname;
         }
     }
     if (DEBUG) {
         $res = call_user_func($funcname, $this, $this->vars);
         $dt = get_microtime() - $st - ($s_runconf->get('time.sql.parse') + $s_runconf->get('time.sql.query') - $sql_t);
         $nested = $s_runconf->get('tpl.nested');
         $curr = array_splice($nested, count($nested) - 1);
         $rdt = $dt - $curr[0];
         if (count($nested)) {
             $nested[count($nested) - 1] += $dt;
         }
         $s_runconf->set('tpl.nested', $nested);
         $s_runconf->set('time.template', $s_runconf->get('time.template') + $rdt);
         return $res;
     } else {
         return call_user_func($funcname, $this, $this->vars);
     }
 }