Пример #1
0
 public function actionImageManager()
 {
     $path = "data/editor/image/" . Ibos::app()->user->uid;
     $action = EnvUtil::getRequest("action");
     if ($action == "get") {
         if (!defined("SAE_TMP_PATH")) {
             $files = $this->getfiles($path);
             if (!$files) {
                 return null;
             }
             rsort($files, SORT_STRING);
             $str = "";
             foreach ($files as $file) {
                 $str .= "../../../../../../" . $file . "ue_separate_ue";
             }
             echo $str;
         } else {
             $st = new SaeStorage();
             $num = 0;
             while ($ret = $st->getList("data", $path, 100, $num)) {
                 foreach ($ret as $file) {
                     if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) {
                         echo $st->getUrl("data", $file) . "ue_separate_ue";
                     }
                     $num++;
                 }
             }
         }
     }
 }
Пример #2
0
function printTestCases($pid, $OJ_DATA)
{
    if (strstr($OJ_DATA, "saestor:")) {
        // echo "<debug>$pid</debug>";
        $store = new SaeStorage();
        $ret = $store->getList("data", "{$pid}", 100, 0);
        foreach ($ret as $file) {
            //          echo "<debug>$file</debug>";
            if (!strstr($file, "sae-dir-tag")) {
                $pinfo = pathinfo($file);
                if (isset($pinfo['extension']) && $pinfo['extension'] == "in" && $pinfo['basename'] != "sample.in") {
                    $f = basename($pinfo['basename'], "." . $pinfo['extension']);
                    $outfile = "{$pid}/" . $f . ".out";
                    $infile = "{$pid}/" . $f . ".in";
                    if ($store->fileExists("data", $infile)) {
                        echo "<test_input><![CDATA[" . $store->read("data", $infile) . "]]></test_input>\n";
                    }
                    if ($store->fileExists("data", $outfile)) {
                        echo "<test_output><![CDATA[" . $store->read("data", $outfile) . "]]></test_output>\n";
                    }
                    //			break;
                }
            }
        }
    } else {
        $ret = "";
        $pdir = opendir("{$OJ_DATA}/{$pid}/");
        while ($file = readdir($pdir)) {
            $pinfo = pathinfo($file);
            if (isset($pinfo['extension']) && $pinfo['extension'] == "in" && $pinfo['basename'] != "sample.in") {
                $ret = basename($pinfo['basename'], "." . $pinfo['extension']);
                $outfile = "{$OJ_DATA}/{$pid}/" . $ret . ".out";
                $infile = "{$OJ_DATA}/{$pid}/" . $ret . ".in";
                if (file_exists($infile)) {
                    echo "<test_input><![CDATA[" . file_get_contents($infile) . "]]></test_input>\n";
                }
                if (file_exists($outfile)) {
                    echo "<test_output><![CDATA[" . file_get_contents($outfile) . "]]></test_output>\n";
                }
                //			break;
            }
        }
        closedir($pdir);
        return $ret;
    }
}
Пример #3
0
 /**
  * @function imageManager
  */
 public function imageManager()
 {
     header("Content-Type: text/html; charset=utf-8");
     //需要遍历的目录列表,最好使用缩略图地址,否则当网速慢时可能会造成严重的延时
     $paths = array(Upload_PATH, 'upload1/');
     //  $action = htmlspecialchars($_POST["action"]);
     $action = htmlspecialchars($_REQUEST["action"]);
     if ($action == "get") {
         if (!defined('SAE_TMP_PATH')) {
             $files = array();
             foreach ($paths as $path) {
                 //$dir = new Dir();
                 //$tmp = $dir->getfiles($path);
                 $tmp = File::getFiles($path);
                 if ($tmp) {
                     $files = array_merge($files, $tmp);
                 }
             }
             if (!count($files)) {
                 return;
             }
             rsort($files, SORT_STRING);
             $str = "";
             foreach ($files as $file) {
                 $str .= __ROOT__ . '/' . $file . "ue_separate_ue";
             }
             echo $str;
         } else {
             // SAE环境下
             $st = new \SaeStorage();
             // 实例化
             /*
              *  getList:获取指定domain下的文件名列表
              *  return: 执行成功时返回文件列表数组,否则返回false
              *  参数:存储域,路径前缀,返回条数,起始条数
              */
             $num = 0;
             while ($ret = $st->getList(get_opinion('SaeStorage'), null, 100, $num)) {
                 foreach ($ret as $file) {
                     if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) {
                         echo $st->getUrl('upload', $file) . "ue_separate_ue";
                     }
                     $num++;
                 }
             }
         }
     }
 }
Пример #4
0
     $sql = "UPDATE `problem` SET `accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`={$pid} AND `result`=4) WHERE `problem_id`={$pid}";
     //echo $sql;
     mysqli_query($mysqli, $sql);
     $sql = "UPDATE `problem` SET `submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`={$pid}) WHERE `problem_id`={$pid}";
     //echo $sql;
     mysqli_query($mysqli, $sql);
 } else {
     if (isset($_POST['checklogin'])) {
         echo "1";
     } else {
         if (isset($_POST['gettestdatalist'])) {
             $pid = intval($_POST['pid']);
             if ($OJ_SAE) {
                 //echo $OJ_DATA."$pid";
                 $store = new SaeStorage();
                 $ret = $store->getList("data", "{$pid}", 100, 0);
                 foreach ($ret as $file) {
                     if (!strstr($file, "sae-dir-tag")) {
                         $file = pathinfo($file);
                         $file = $file['basename'];
                         echo $file . "\n";
                     }
                 }
             } else {
                 $dir = opendir($OJ_DATA . "/{$pid}");
                 while (($file = readdir($dir)) != "") {
                     if (!is_dir($file)) {
                         $file = pathinfo($file);
                         $file = $file['basename'];
                         echo "{$file}\n";
                     }
Пример #5
0
<?php

header("Content-Type:text/html;charset='utf-8'");
$storage = new SaeStorage();
$glInfo = array('domain' => 'test', 'prefix' => '', 'limit' => '100', 'offset' => 0);
$ret = $storage->getList($glInfo['domain'], $glInfo['prefix'], $glInfo['limit'], $glInfo['offset']);
$allow_ext = array('image' => array('gif', 'jpg', 'jpeg', 'png', 'bmp', 'psd'), 'flash' => array('swf', 'flv'), 'media' => array('mp3', 'wav', 'wma', 'wmv', 'mid', 'avi', 'mpg', 'asf', 'rm', 'rmvb'), 'file' => array('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'htm', 'html', 'txt', 'zip', 'rar', 'gz', 'bz2'));
//容许的文件扩展名
$fileInfo = null;
for ($i = 0; $i < count($ret); $i++) {
    if (substr($ret[$i], "-" . strlen('/.placeholder')) != '/.placeholder') {
        $file_ext = strtolower(trim(array_pop(explode(".", $ret[$i]))));
        if (in_array($file_ext, $allow_ext['image']) === true) {
            $format = 'image';
        } else {
            if (in_array($file_ext, $allow_ext['flash']) === true) {
                $format = 'flash';
            } else {
                if (in_array($file_ext, $allow_ext['media']) === true) {
                    $format = 'media';
                } else {
                    if (in_array($file_ext, $allow_ext['file']) === true) {
                        $format = 'file';
                    } else {
                        $format = 'unknown';
                    }
                }
            }
        }
        $baseInfo = $storage->getAttr($glInfo['domain'], $ret[$i]);
        $fileInfo[$i]['file_ext'] = $file_ext;
Пример #6
0
<?php

include_once 'saestorage.class.php';
$stor = new SaeStorage();
$file_url = $stor->getUrl("darkblue", "100.jpg");
echo $file_url;
//http://darkblueacgstandby-darkblue.stor.sinaapp.com/images/loli/100.jpg
$pic_url = "http://darkblueacgstandby-darkblue.stor.sinaapp.com/images/loli/" . $random_id . ".jpg";
$domain = "darkblue";
$path = "darkblue/images/loli";
$pic_num = getFilesNum($domain, $path);
echo $pic_num;
// 列出 Domain 下所有路径以photo开头的文件
$stor = new SaeStorage();
$num = 0;
//string $domain, [string $prefix = NULL], [int $limit = 10], [int $offset = 0]
while ($ret = $stor->getList("darkblue", NULL, 100, $num)) {
    foreach ($ret as $file) {
        // echo "{$file}\n";
        $num++;
    }
}
// echo "\nTOTAL: {$num} files\n";
Пример #7
0
 public function ue_mgimg()
 {
     $setting = C('EDITOR_UPLOAD');
     $files = array();
     if (!defined('SAE_TMP_PATH')) {
         $imgRootPath = $setting['rootPath'];
         $paths = array('');
         $files = $this->getfiles($imgRootPath);
     } else {
         // SAE环境下
         $st = new \SaeStorage();
         // 实例化
         $driverConf = C("UPLOAD_SAE_CONFIG");
         /*
          *  getList:获取指定domain下的文件名列表
          *  return: 执行成功时返回文件列表数组,否则返回false
          *  参数:存储域,路径前缀,返回条数,起始条数
          */
         $num = 0;
         while ($ret = $st->getList($driverConf['domain'], NULL, 100, $num)) {
             foreach ($ret as $file) {
                 if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) {
                     $files[$num] = $st->getUrl($driverConf['domain'], $file);
                 }
                 $num++;
             }
         }
     }
     if (!count($files)) {
         return;
     }
     rsort($files, SORT_STRING);
     $str = implode('|', $files);
     echo $str;
 }
Пример #8
0
<?php

require_once 'saestorage.class.php';
#your app accesskey
$accesskey = 'enter_your_app_accesskey';
#your app secretkey
$secretkey = 'enter_your_app_secretkey';
#your doamin name
$domain = 'enter_your_doamin_name';
$storage = new SaeStorage($accesskey, $secretkey);
$filesNum = $storage->getFilesNum($domain);
$fileList = $storage->getList($domain);
//print_r($fileList);
foreach ($fileList as $oneFile) {
    $fileName = $oneFile['fileName'];
    //var_dump($fileName);
    echo $fileName;
    $fileNameNoDir = explode("/", $fileName)[1];
    if (!file_exists($fileNameNoDir)) {
        $fileUrl = $storage->getUrl($domain, $fileName);
        $cmd = 'wget ' . $fileUrl;
        shell_exec($cmd);
    }
}
Пример #9
0
<?php

//遍历Domain下所有文件
$stor = new SaeStorage();
$num = 0;
while ($ret = $stor->getList("box", "*", 100, $num)) {
    foreach ($ret as $file) {
        echo "{$file}\n";
        $num++;
    }
}
echo "\nTOTAL: {$num} files\n";
?>
 
 <?php 
$domain = "box";
$filename = "SAE_SDK_Windows_1.0.5.Build1105301821.zip";
$url = $stor->getUrl($domain, $filename);
echo $url;
Пример #10
0
if ($action == "get") {
    if (!defined('SAE_TMP_PATH')) {
        $files = getfiles($path);
        if (!$files) {
            return;
        }
        rsort($files, SORT_STRING);
        $str = "";
        foreach ($files as $file) {
            $str .= $file . "ue_separate_ue";
        }
        echo $str;
    } else {
        $st = new SaeStorage();
        $num = 0;
        while ($ret = $st->getList("upload", NULL, 100, $num)) {
            foreach ($ret as $file) {
                if (preg_match("/\\.(gif|jpeg|jpg|png|bmp)\$/i", $file)) {
                    echo $st->getUrl('upload', $file) . "ue_separate_ue";
                }
                $num++;
            }
        }
    }
}
/**
 * 遍历获取目录下的指定类型的文件
 * @param $path
 * @param array $files
 * @return array
 */
Пример #11
0
function SaeStorageList($Prefix)
{
    $storage = new SaeStorage();
    $domain = Sae_Storage_Domain_Name;
    $result = array();
    //默认空数组
    $limit = 100;
    //列表数量
    $offset = 0;
    //偏移量
    while ($temp = $storage->getList($domain, $Prefix, $limit, $offset)) {
        foreach ($temp as $file) {
            $result[] = $file;
            $num++;
        }
    }
    return $result;
    //注意:最大只能列出10000条数据。
}
Пример #12
0
     $sql = "UPDATE `problem` SET `accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`={$pid} AND `result`=4) WHERE `problem_id`={$pid}";
     //echo $sql;
     mysql_query($sql);
     $sql = "UPDATE `problem` SET `submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`={$pid}) WHERE `problem_id`={$pid}";
     //echo $sql;
     mysql_query($sql);
 } else {
     if (isset($_POST['checklogin'])) {
         echo "1";
     } else {
         if (isset($_POST['gettestdatalist'])) {
             $pid = intval($_POST['pid']);
             if ($OJ_SAE) {
                 //echo $OJ_DATA."$pid";
                 $store = new SaeStorage();
                 $ret = $store->getList("data", "{$pid}");
                 foreach ($ret as $file) {
                     if (!strstr($file, "sae-dir-tag")) {
                         $file = pathinfo($file);
                         $file = $file['basename'];
                         echo $file . "\n";
                     }
                 }
             } else {
                 $dir = opendir($OJ_DATA . "/{$pid}");
                 while (($file = readdir($dir)) != "") {
                     if (!is_dir($file)) {
                         $file = pathinfo($file);
                         $file = $file['basename'];
                         echo "{$file}\n";
                     }
Пример #13
0
 /**
  * Delete all existing cache files
  *
  * @access	public
  * @return	bool
  */
 function delete_all()
 {
     //---change---//
     //delete_files($this->db->cachedir, TRUE);
     if ($this->db->cache_method == "storage") {
         $storage = new SaeStorage();
         $file_list = $storage->getList($this->db->cachedir);
         for ($i = 0; $i < count($file_list); $i++) {
             $storage->delete($this->db->cachedir, $file_list[$i]);
         }
         if (count($file_list) == 100) {
             delete_all();
         }
     } else {
         $mmc = memcache_init();
         if ($mmc) {
             $catalog_data = memcache_get($mmc, $this->db->cachedir);
             $catalog;
             if ($catalog_data == false) {
                 return false;
             } else {
                 $catalog = unserialize($catalog_data);
             }
             foreach ($catalog as $key => $value) {
                 memcache_delete($mmc, $key);
             }
             $catalog = array();
             memcache_set($mmc, $this->db->cachedir, serialize($catalog));
         }
     }
 }