Esempio n. 1
0
function dirList()
{
    $list = array();
    $files = glob(DATA_PATH . '/*.php');
    arsort($files);
    foreach ($files as $file) {
        $filename = basename($file, ".php");
        $info = loadInfo($filename);
        $isChange = false;
        //如果没有设置location,就查询qqwry.dat判断location
        if (!isset($info['location'])) {
            $info['location'] = convertip($info['user_IP'], IPDATA_PATH);
            $isChange = true;
        }
        if ($isChange) {
            saveInfo(json_encode($info), $filename);
        }
        $list[] = $info;
    }
    return $list;
}
//Windows平台最好别设成0,因为windows上lock没法实现非阻塞
set_time_limit(0);
require_once "config.php";
require_once "functions.php";
require_once "dio.php";
if (KEEP_SESSION) {
    //利用非阻塞的flock实现单例运行
    $pid = fopen(DATA_PATH . '/check.pid', "w");
    if (!$pid) {
        exit;
    }
    if (flock($pid, LOCK_EX | LOCK_NB)) {
        $files = glob(DATA_PATH . '/*.php');
        foreach ($files as $file) {
            $filename = basename($file, ".php");
            $info = loadInfo($filename);
            if ($info['keepsession'] === true) {
                $url = getLocation($info);
                $cookie = getCookie($info);
                $useragent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2535.0 Safari/537.36";
                if (isset($info['headers_data']['User-Agent'])) {
                    $useragent = $info['headers_data']['User-Agent'];
                }
                $ip = $info['user_IP'];
                if ($url != "" && $cookie != "") {
                    $ch = curl_init();
                    $header[] = 'User-Agent: ' . $useragent;
                    $header[] = 'Cookie: ' . $cookie;
                    $header[] = 'X-Forwarded-For: ' . $ip;
                    curl_setopt($ch, CURLOPT_URL, $url);
                    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
function activ_pack($fileid, $https_server, $file_serv)
{
    global $l;
    //checking if corresponding available exists
    $reqVerif = "SELECT * FROM download_available WHERE fileid=%s";
    $argVerif = $fileid;
    if (!mysqli_num_rows(mysql2_query_secure($reqVerif, $_SESSION['OCS']["readServer"], $argVerif))) {
        $infoTab = loadInfo($https_server, $file_serv);
        if ($infoTab == '') {
            $infoTab = array("PRI" => '10', "FRAGS" => '0');
        }
        $req1 = "INSERT INTO download_available(FILEID, NAME, PRIORITY, FRAGMENTS, OSNAME ) VALUES\n\t\t\t( '%s', 'Manual_%s',%s,%s, 'N/A' )";
        $arg1 = array($fileid, $fileid, $infoTab["PRI"], $infoTab["FRAGS"]);
        mysql2_query_secure($req1, $_SESSION['OCS']["writeServer"], $arg1);
    }
    $req = "INSERT INTO download_enable(FILEID, INFO_LOC, PACK_LOC, CERT_FILE, CERT_PATH ) VALUES\n\t\t( '%s', '%s', '%s', 'INSTALL_PATH/cacert.pem','INSTALL_PATH')";
    $arg = array($fileid, $https_server, $file_serv);
    $lbl_log = $l->g(514) . " " . $fileid;
    mysql2_query_secure($req, $_SESSION['OCS']["writeServer"], $arg, $l->g(512));
}
Esempio n. 4
0
function showInfo($classname, $id = false, $el = false)
{
    return loadInfo($classname, $id, $el);
}