Exemplo n.º 1
0
<?php

require_once "../lib/config.php";
require_once "../lib/dbclass.php";
require_once "../lib/JSON.php";
$json = new Services_JSON();
$dir = isset($_POST['dir']) && $_POST['dir'] != 0 ? $_POST['dir'] : 0;
$start = $_POST['start'];
$limit = $_POST['limit'];
$search = $_POST['search'];
if (empty($search)) {
    $count_sql = "select * from file_data\n\t\t\t\t  WHERE file_dir = " . $dir;
    $sql = "SELECT file . * , user.user_name\n\t\t\tFROM `file_data` file , `user_data` user\n\t\t\tWHERE file.file_dir = " . $dir . "\n\t\t\tand file.file_owner_id = user.user_id\n\t\t\torder by file.file_id DESC\n\t\t\tLIMIT " . $start . " , " . $limit;
} else {
    $count_sql = "select * from file_data\n\t\t\t\t  WHERE `file_name` LIKE '%" . $search . "%'";
    $sql = "SELECT file . * , user.user_name\n\t\t\tFROM `file_data` file , `user_data` user\n\t\t\tWHERE file.file_owner_id = user.user_id\n\t\t\tAND `file_name` LIKE '%" . $search . "%'\n\t\t\torder by file.file_id DESC\n\t\t\tLIMIT " . $start . " , " . $limit;
}
$db = new dbClass($db_username, $db_password, $db_database, $db_hostname);
$db->start();
$count = $db->getcount($count_sql);
$result = $db->query($sql);
while ($arr = $db->getarray($result)) {
    $array[] = $arr;
}
if ($count) {
    echo $_GET['callback'] . '({"totalCount":"' . $count . '","data":' . $json->encode($array) . '})';
} else {
    echo $_GET['callback'] . '({"totalCount":"' . $count . '","data":""})';
}
Exemplo n.º 2
0
<?php

require_once "../../lib/config.php";
require_once "../../lib/dbclass.php";
$dirID = $_GET['dirId'];
//判斷該資料夾下有無檔案
$sql = "SELECT *\n\t\tFROM `file_data`\n\t\tWHERE `file_dir` = " . $dirID;
$db = new dbClass($db_username, $db_password, $db_database, $db_hostname);
$db->start();
if ($db->getcount($sql)) {
    echo "haveItem";
    exit;
}
//判斷該資料夾下有無子資料夾
$sql = "SELECT *\n\t\tFROM `dir_data`\n\t\tWHERE `dir_parent` = " . $dirID;
if ($db->getcount($sql)) {
    echo "haveItem";
    exit;
}
echo "ok";
$db->close();