Ejemplo n.º 1
0
function main($subDir, $class, $cookieURL, $indexURL, $totalClass, $curClass, $code)
{
    $isSleep = true;
    makeDir("./html/{$subDir}/{$class}/");
    $dataFileName = "data/{$subDir}/{$class}.log";
    $httpClient = new HttpClient("epub.cnki.net");
    $content = "";
    $indexFname = "./html/{$subDir}/{$class}/index.html";
    $tf = iconv("utf-8", "gb2312", $indexFname);
    $cookies = "";
    if (file_exists($tf)) {
        $isSleep = false;
        $content = file_get_contents($tf);
        echo "From cache get index.....\n";
    } else {
        /*获取并设置cookie*/
        $httpClient->get($cookieURL);
        $cookies = $httpClient->getCookies();
        $httpClient->setCookies($cookies);
        if (!$cookies) {
            die("cookie error");
        }
        $isSleep = true;
        $httpClient->get($indexURL);
        $content = $httpClient->getContent();
        save($indexFname, $content);
        //保存
        echo "save index file...\n";
    }
    /* 解析出一共有多少页面 */
    $pageCount = parsePageCount($content);
    echo "Page is {$pageCount} ****\n";
    $articleCount = ARTICLE_PRE_PAGE * $pageCount;
    //计算一共有多少篇文章,大于等于实际文章数目,不影响结果
    echo "total article is {$articleCount}\n";
    $pageCount = $articleCount / ARTICLE_PRE_PAGE;
    $pageCount = ceil($pageCount);
    //向上取整,不放过任何数据
    if ($pageCount == 0) {
        $pageCount = 1;
    }
    if ($pageCount > 50) {
        echo "page count is big than 50\n";
    }
    echo "total page of {$class} is : {$pageCount}...............{$curClass} of {$totalClass}\n";
    if ($isSleep) {
        fakeSleep();
    }
    /* 抓取每一个页面并且保存下来,保存的同时进行解析 */
    for ($i = 1; $i <= $pageCount; $i++) {
        $content = NULL;
        $pageI = getPageI($indexURL, $i);
        //第i页的地址
        $htmlI = "./html/{$subDir}/{$class}/{$i}.html";
        if (!file_exists(iconv("utf-8", "gb2312", $htmlI))) {
            $isSleep = true;
            $httpClient->setCookies($cookies);
            $httpClient->get($pageI);
            $content = $httpClient->getContent();
            save($htmlI, $content);
            echo "From newwork & save {$i}.html..........[{$i} of {$pageCount}]\n";
        } else {
            $tmpf2 = iconv("utf-8", "gb2312", $htmlI);
            $content = file_get_contents($tmpf2);
            $ok = validatePageContent($content);
            //是否出现了验证码
            if (!$ok) {
                $i = $i - 1;
                delFile($htmlI);
            } else {
                $isSleep = false;
                echo "Find local file {$htmlI} & skip\n";
            }
            //continue;
        }
        $logName = "./data/{$subDir}/{$class}.log";
        if (!validatePageContent($content)) {
            $i = $i - 1;
            delFile($htmlI);
            dosleep(60);
            $httpClient = new HttpClient("epub.cnki.net");
            $httpClient->get($cookieURL);
            $cookies = $httpClient->getCookies();
            $httpClient->setCookies($cookies);
            continue;
        }
        parseContent($content, $logName, $code);
        if ($i != $pageCount && $isSleep) {
            fakeSleep();
        } else {
            echo "+\n";
            echo "+\n";
            echo "+ {$class} done\n";
            echo "+\n";
            echo "+\n";
        }
    }
}
Ejemplo n.º 2
0
<?php

header("Content-Type:text/html;charset=gb2312");
require_once 'dir.func.php';
require_once 'file.func.php';
require_once 'common.func.php';
//$path="../../files/files";
$path = $fileroot;
$path = $_REQUEST['path'] ? $_REQUEST['path'] : $path;
$folderp = $_REQUEST['folderp'];
$filep = $_REQUEST['filep'];
$folderp1 = explode(",", $folderp);
$filep1 = explode(",", $filep);
for ($i = 0; $i < count($folderp1); $i++) {
    delFolder($folderp1[$i]);
}
for ($i1 = 0; $i1 < count($filep1); $i1++) {
    delFile($filep1[$i1]);
}
$mes = "¸üгɹ¦";
echo "<script>location.href='file_gl.php?path=" . $path . "&info=" . $mes . "'</script>";
Ejemplo n.º 3
0
EOF;
    echo $str;
} elseif ($action == "doRename") {
    /*
     * 实现重命名操作
     * 2014-12-03 11:10:53
     */
    $newname = $_REQUEST['newname'];
    $message = renameFile($filename, $newname);
    alertMessage($message, $redirect);
} elseif ($action == "delFile") {
    /*
     * 删除文件
     * 2014-12-03 11:28:46
     */
    $message = delFile($filename);
    alertMessage($message, $redirect);
} elseif ($action == "downFile") {
    /**
     * 下载文件
     * 2014-12-03 13:34:28
     */
    $message = downFile($filename);
} elseif ($action == "copyFile") {
    /**
     * 复制文件
     * 2014-12-03 18:49:36
     */
    $str = <<<EOF
    <form action="index.php?action=doCopyFile" method = "post">
        将文件复制到:<input type="text"  name="dstname" placeholder="将文件复制到"/>
Ejemplo n.º 4
0
    //完成重命名
    $str = <<<EOF
\t<form action="index.php?act=doRename" method="post"> 
\t请填写新文件名:<input type="text" name="newname" placeholder="重命名"/>
\t<input type='hidden' name='filename' value='{$filename}' />
\t<input type="submit" value="重命名"/>
\t</form>
EOF;
    echo $str;
} elseif ($act == "doRename") {
    //实现重命名的操做
    $newname = $_REQUEST['newname'];
    $mes = renameFile($filename, $newname);
    alertMes($mes, $redirect);
} elseif ($act == "delFile") {
    $mes = delFile($filename);
    alertMes($mes, $redirect);
} elseif ($act == "downFile") {
    //完成下载的操作
    $mes = downFile($filename);
} elseif ($act == "创建文件夹") {
    $mes = createFolder($path . "/" . $dirname);
    alertMes($mes, $redirect);
} elseif ($act == "renameFolder") {
    $str = <<<EOF
\t\t\t<form action="index.php?act=doRenameFolder" method="post"> 
\t请填写新文件夹名称:<input type="text" name="newname" placeholder="重命名"/>
\t<input type="hidden" name="path" value="{$path}" />
\t<input type='hidden' name='dirname' value='{$dirname}' />
\t<input type="submit" value="重命名"/>
\t</form>
Ejemplo n.º 5
0
 $icount = 1;
 while ($line = readLine($fp)) {
     $arr = explode("\t", $line);
     $u = $arr[6];
     $paperName = $arr[0];
     $paperName = win_dir_format($paperName);
     //echo $paperName . "\n";
     $htmlFileName = $indexSavePath . "/" . $paperName . ".html";
     $tmpFile = iconv("utf-8", "gb2312//IGNORE", $htmlFileName);
     $dbCode = get_db_code($u);
     $fileName = get_file_name($u);
     $tableName = get_table_name($u);
     $realUrl = get_real_url($dbCode, $fileName, $tableName);
     if (file_exists($tmpFile)) {
         if (filesize($tmpFile) < 100) {
             delFile($htmlFileName);
         } else {
             echo "Cache hit! continue -> {$htmlFileName}\n";
             $mapContent = "{$paperName}\t{$realUrl}\n";
             save($mapFile, $mapContent, "a+");
             continue;
         }
     }
     $indexContent = @file_get_contents($realUrl);
     if (strlen($indexContent) == 0) {
         die("{$realUrl}");
         continue;
     }
     $indexContent = resourceReplace($indexContent);
     save($htmlFileName, $indexContent);
     $mapContent = "{$paperName}\t{$realUrl}\n";
Ejemplo n.º 6
0
         $attach_table = "disc_forum_attachment_" . $tableid;
         //附件表
         $attachment_data = array("tid" => 0, "pid" => 0, "uid" => $uid, "tableid" => $tableid, "downloads" => 0, "bid" => $bid, "hid" => 0);
         $db->AutoExecute("disc_forum_attachment", $attachment_data, "INSERT");
         $attach2_add = array();
         foreach ($message as $k => $file) {
             $attach2_add[$k] = array("tid" => 0, "pid" => 0, "uid" => $uid, "dateline" => $now, "filename" => "", "filesize" => "", "attachment" => $file, "remote" => 0, "description" => "no", "readperm" => 0, "price" => 0, "isimage" => 1, "width" => 0, "thumb" => 0, "picid" => 0, "bid" => $bid, "hid" => 0);
         }
         $db->AutoExecute($attach_table, $attach2_add, "INSERT");
         $data = array("status" => "ok", "msg" => "图片上传成功");
         $db->Execute("update disc_home_blog set picflag=1 where blogid={$bid}");
         //更新有图片的标志
     } else {
         //如果图片上传有失败的,则依次删除.
         foreach ($message as $file) {
             delFile($file);
         }
         $data = array("status" => "error", "msg" => "图片上传失败", "blog_file" => $_FILES, "message" => $message, "newPath" => $newPath);
     }
 } else {
     if ($act == "del") {
         //删除动态
         $uid = form_input($_POST['fromuid']);
         //uid
         if ($uid == "" || $uid == null) {
             $result = array("status" => "error", "msg" => "fromuid field requird");
             throwJSON($result);
             exit;
         }
         $bid = form_input($_POST['bid']);
         //bid
Ejemplo n.º 7
0
Archivo: ws.php Proyecto: alexlqi/sdk
        break;
    case 'addFile':
        if (!empty($_FILES)) {
            //move_uploaded_file($_FILES["tmp_name"], destination)
            $archivo = $_FILES["file"];
            $files["uuid"] = strtoupper(UUID::v4());
            $files["name"] = $archivo["name"];
            $files["mime"] = $archivo["type"];
            $files["tmp_name"] = $archivo["tmp_name"];
            $r = addFile($files);
            $r["uuid"] = $files["uuid"];
            echo json_encode($r);
        }
        break;
    case 'delFile':
        $r = delFile($_POST["uuid"]);
        echo json_encode($r);
        break;
    default:
        # code...
        break;
}
function addFile($archivo)
{
    global $modelo;
    $uuid = $archivo["uuid"];
    $name = $archivo["name"];
    $mime = $archivo["mime"];
    $data = base64_encode(file_get_contents($archivo["tmp_name"]));
    $sql = "call sp_addFile('{$uuid}','{$name}','{$mime}','{$data}');";
    $r = $modelo->query2array($sql);
Ejemplo n.º 8
0
                save($mapFile, $saveContent, "a+");
                //echo "save $saveContent\n";
                /*抓取论文摘要内容*/
                $content = $httpClient->quickGet($contentUrl);
                $contentSize = strlen($content);
                if ($contentSize > 300) {
                    save($cachedHtml, $content);
                } else {
                    fakeSleep();
                }
            } while ($contentSize < 300);
        } else {
            $sleep = false;
            echo "Hit\n";
            $content = file_get_contents($localedCachedHtml);
            if (strlen($content) < 300) {
                delFile($cachedHtml);
                echo "Empty abstract file \n";
            }
            continue;
        }
        $keyWords = get_key_words($content);
        $keyWords .= "#" . get_mentor($content) . "#" . get_major($content);
        $abs = get_paper_abs($content);
        save("{$absPath}", $keyWords . "\n" . $abs);
        if ($sleep && false) {
            fastSleep();
        }
    }
    fclose($fp);
}
Ejemplo n.º 9
0
function lightrepoDispatch($op)
{
    require_once _base_ . '/lib/lib.urlmanager.php';
    $url =& UrlManager::getInstance('light_repo');
    $url->setStdQuery('modname=light_repo&op=repolist');
    if (isset($_POST['undo'])) {
        $op = 'repolist';
    }
    switch ($op) {
        case "repolist":
            repoList($url);
            break;
        case "mod_repo":
            modRepo($url);
            break;
        case "del_repo":
            delRepo($url);
            break;
        case "repo_my_details":
            repoMyDetails($url);
            break;
        case "mod_file":
            modFile($url);
            break;
        case "del_file":
            delFile($url);
            break;
        case "repo_manager_details":
            repoManagerDetails($url);
            break;
        case "repo_user_details":
            repoUserDetails($url);
            break;
        case "download_file":
            downloadFile($url);
            break;
    }
}
Ejemplo n.º 10
0
        break;
    case 'getCustomTermin':
        getCustomTermin($_GET['id'], $_GET['tab'], $_GET['day'], $_GET['month'], $_GET['year']);
        break;
    case 'showDir':
        showDir($_GET['id'], $_GET['dir']);
        break;
    case 'showFile':
        showFile($_GET['pfad'], $_GET['file']);
        break;
    case 'lockFile':
        lockFile($_GET['file'], $_GET['pfad'], $_GET['id']);
        break;
    case 'moveFile':
        moveFile($_GET['file'], $_GET['pfadleft']);
        break;
    case 'saveAttribut':
        saveAttribut($_GET['name'], $_GET['oldname'], $_GET['pfad'], $_GET['komment'], $_GET['id']);
        break;
    case 'newDir':
        newDir($_GET['pfad'], $_GET['newdir']);
        break;
    case 'delFile':
        delFile($_GET['id'], $_GET['pfad'], $_GET['file']);
        break;
    case 'usermail':
        getUsermail($_GET['uid']);
        break;
    default:
        echo "nicht erlaubt";
}
Ejemplo n.º 11
0
							));
						}
					break;

					case 'siswa':
						// delete file/image
						$photosiswa=null;
						if(empty($_POST['idformTB'])){// add 
							 $photosiswa = isset($_POST['photosiswaTB'])?$_POST['photosiswaTB']:null; // ada upload 
							$ss='masuk add';
						}else{ // edit
							$ss='masuk dit';
							if(isset($_POST['photosiswaTB'])){// ada upload 
								$aa='ada upload';
								$photosiswa = $_POST['photosiswaTB'];
								if(isset($_POST['photosiswa2TB']) && !empty($_POST['photosiswa2TB'])) delFile($imageDir.$_POST['photosiswa2TB']); // foto lama = ada 
							} 
						} 

						// biodata siswa -----------------------------------------------------------------------------------------
						$siswaF = array(
							'photosiswa'=>$photosiswa,
							'alamatsiswa',	
							'agamasiswa',	
							'bahasasiswa1',	
							'bahasasiswa2',	
							'beratsiswa',	
							'catatankesehatansiswa',	
							'darahsiswa',	
							'diasuh',
							'emailsiswa',	
Ejemplo n.º 12
0
function deleteFile($file)
{
    return delFile($file);
}
Ejemplo n.º 13
0
            @unlink($cfg["torrent_file_path"] . $element);
            @unlink($cfg["torrent_file_path"] . $alias);
            @unlink($cfg["torrent_file_path"] . getAliasName($element) . ".prio");
            AuditAction($cfg["constants"]["delete_torrent"], $element);
        } else {
            AuditAction($cfg["constants"]["error"], $cfg["user"] . " attempted to delete " . $element);
        }
    }
} else {
    if ($action == "fileDelete") {
        $file = getRequestVar("file");
        // Lets delete some files
        if (is_array($file)) {
            foreach ($file as $key => $element) {
                $element = urldecode($element);
                delFile($element);
            }
        }
    }
}
if (isset($_SERVER["HTTP_REFERER"])) {
    header("location: " . $_SERVER["HTTP_REFERER"]);
} else {
    header("location: index.php");
}
function delFile($del)
{
    global $cfg;
    if (IsAdmin($cfg["user"]) || preg_match("/^" . $cfg["user"] . "/", $del)) {
        // Yes, then delete it
        // we need to strip slashes twice in some circumstances