示例#1
0
文件: load.php 项目: jonesxv/csf
function checkcsv($csv, $delimiter)
{
    global $shapefiles;
    $fname = $csv;
    $fhandle = fopen($fname, "r");
    #Skip amount of rows
    for ($i = 0; $i < $_SESSION["skip"]; $i++) {
        $content = fgets($fhandle);
    }
    #get head
    $contenth = fgetcsv($fhandle, 0, $_SESSION["delimiter"], $_SESSION["quote"], $_SESSION["escape"]);
    echo "<br><table border='1'>";
    #find the amount of columns
    $k = count($contenth);
    dropline($contenth, $k);
    for ($i = 1; $i < 100000; $i++) {
        $content = fgetcsv($fhandle, 0, $_SESSION["delimiter"], $_SESSION["quote"], $_SESSION["escape"]);
        if ($content !== false) {
            for ($j = 0; $j < $k; $j++) {
                $check[$j] = checktype($check[$j], $content[$j]);
            }
        } else {
            $i = 100000;
        }
    }
    $elementsh = $contenth;
    $content = '';
    for ($j = 0; $j < $k; $j++) {
        $datareturn[$j]["type"] = $check[$j];
        $datareturn[$j]["name"] = trim($elementsh[$j]);
        $content[$j] = $check[$j];
    }
    dropline($content, $k);
    fclose($fhandle);
    $fhandle = fopen($fname, "r");
    for ($i = 0; $i < $_SESSION["skip"]; $i++) {
        $content = fgets($fhandle);
    }
    $content = fgets($fhandle);
    for ($i = 1; $i < 20; $i++) {
        $content = fgetcsv($fhandle, 0, $_SESSION["delimiter"], $_SESSION["quote"], $_SESSION["escape"]);
        dropline($content, $k);
    }
    echo "</table>";
    fclose($fhandle);
    return $datareturn;
}
示例#2
0
文件: do.php 项目: TopGrd/newxb
         }
     }
     echo "parent.save_suc('{$out}');</script>";
     die;
 } else {
     if ($action == "savefromurl" && $user["savefromurl"]) {
         if (!$path || !$url) {
             exitme("notice(lang.var_error)", "eval");
         }
         if (!$filename) {
             $filename = basename1($url);
         }
         if ($filename != checkfilename($filename)) {
             exitme("notice(lang.download+lang.fail)", "eval");
         }
         checktype($filename);
         if (!is_writeable($path)) {
             exitme("notice(lang.cannot_write)", "eval");
         }
         if (file_exists($path . $filename)) {
             exitme("notice(lang.alreadyExist+':{$filename}')", "eval");
         }
         $filename = dealpath($path . $filename);
         if (@copy($url, $filename)) {
             exitme("notice(lang.download+lang.success+': {$filename} ');reloaddata();", "eval");
         } else {
             exitme("notice(lang.download+lang.fail);", "eval");
         }
     } else {
         if ($action == "paste") {
             if ($action1 != "cut" && $action1 != "copy") {
示例#3
0
function listfiles($dir = ".")
{
    //遍厉目录并替换
    $hAndle = opendir($dir);
    //打开目录
    while (fAlse != ($file = reAddir($hAndle))) {
        //阅读目录
        if ($file != '.' && $file != '..') {
            //列出所有文件并去掉'.'和'..
            if (is_dir("{$dir}/{$file}")) {
                //列出文件和目录
                echo "<font color=\"yellow\">{$dir}/{$file}</font><br />";
                //输出目录名[黄色]
                listfiles("{$dir}/{$file}");
                //递归调用
            } else {
                if ("{$dir}/{$file}" != selfname()) {
                    //判断自身
                    echo "{$dir}/{$file}";
                    //输出文件名
                    //读取文件内容
                    if (checktype(selftype("{$dir}/{$file}"), types($_POST['type'])) and $_POST['type'] != "") {
                        if (filesize("{$dir}/{$file}") > 0) {
                            if (is_writable("{$dir}/{$file}")) {
                                $fp = fopen("{$dir}/{$file}", "r");
                                $con = addslashes(freAd($fp, filesize("{$dir}/{$file}")));
                                //==========================替换内容
                                $con = replace($_POST['a'], $_POST['b'], $con);
                                fclose($fp);
                                //关闭文件连接
                                $fd = fopen("{$dir}/{$file}", "w");
                                //打开文件
                                $A = fputs($fd, stripslashes($con));
                                //写入替换后的内容
                                fclose($fd);
                                //关闭文件连接
                                echo "<br />";
                            } else {
                                echo "<font color=\"red\">&nbsp;不可写</font><br />";
                            }
                        }
                    } else {
                        if ($_POST['type'] == "") {
                            if (filesize("{$dir}/{$file}") > 0) {
                                if (is_writable("{$dir}/{$file}")) {
                                    $fp = fopen("{$dir}/{$file}", "r");
                                    $con = addslashes(freAd($fp, filesize("{$dir}/{$file}")));
                                    //==========================替换内容
                                    $con = replace($_POST['a'], $_POST['b'], $con);
                                    fclose($fp);
                                    //关闭文件连接
                                    $fd = fopen("{$dir}/{$file}", "w");
                                    //打开文件
                                    $A = fputs($fd, stripslashes($con));
                                    //写入替换后的内容
                                    fclose($fd);
                                    //关闭文件连接}
                                    echo "<br />";
                                } else {
                                    echo "<font color=\"red\">&nbsp;不可写</font><br />";
                                }
                            }
                        } else {
                            echo "<font color=\"red\">&nbsp;类型不匹配</font><br />";
                        }
                    }
                }
            }
        }
    }
}