/** * @param $upload */ function Storage_Del(&$upload) { global $zbp, $domainname; $s = new SaeStorage(); $url = $s->delete($domainname, $upload->Metas->Storage_URL); $GLOBALS['Filter_Plugin_Upload_DelFile']['Storage_Del'] = PLUGIN_EXITSIGNAL_RETURN; }
function is_storage_ok() { $s = new SaeStorage(); $status = $s->write('public', '.dilicms_install_test', ''); $status and $s->delete('public', '.dilicms_install_test'); return $status; }
function SaeStorageDelete($FilePath) { $storage = new SaeStorage(); $domain = Sae_Storage_Domain_Name; $result = $storage->delete($domain, $FilePath); return $result; }
function s_delete($filepath) { $_s = new SaeStorage(); //初始化Storage对象 $_f = _s_get_path($filepath); return $_s->delete($_f['domain'], $_f['filename']); }
function delete_mp3($fileName) { $stor = new SaeStorage(); $stor->delete(SAE_DOMAIN, $fileName); if ($errmsg == 0) { $result['success'] = 1; } else { $result['success'] = -1; } return $result; }
public function Delete($fileName) { $res = array('result' => false, 'reason' => ''); $file_path = SAE_MODULES . '/' . $fileName; $s = new SaeStorage(); if ($s->fileExists(SAE_STORAGE_DOMAIN, $file_path)) { if ($s->delete(SAE_STORAGE_DOMAIN, $file_path)) { $res['result'] = true; $res['reason'] = $fileName; } else { $res['reason'] = $this->messages['6']; } } else { $res['reason'] = $this->messages['4']; } }
function delete() { if (!$this->has_privilege()) { $this->json->output(array('success' => false, 'm' => '您没有使用该功能的权限')); } $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); if ($s->delete('upload', $file[0]->filename)) { // remove from upload table $this->Proj_model->delete_upload($fileid); $this->json->output(array('success' => true)); } } $this->json->output(array('success' => false)); }
/** * 文件删除 * @param string $filename 文件名 * @return boolean */ function file_delete($filename, $type = '') { switch (STORAGE_TYPE) { case 'Sae': $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->delete($domain, $filePath); break; default: return \Think\Storage::unlink($filename, $type); } }
echo '保存错误,请确保每项都不为空'; } else { $config = "<?php\n\$key0='{$adminpass}';//管理员密码\n\n\$pagesize='15';//文件列表每页显示多少个文件,必须为整数\n\n\$Storage = 'udisk';//Storage名称\n\n\$openapi = 1;//是否开启API上传\n\n/*数据库信息*/\n\$host = '{$hosti}'; //数据库服务器\n\$port = {$porti}; //数据库端口\n\$user = '******'; //数据库用户名\n\$pwd = '{$pwdi}'; //数据库密码\n\$dbname = '{$dbi}'; //数据库名称\n\n?>"; file_put_contents('config.php', $config); echo "保存成功!<br><a href='{$_SERVER['PHP_SELF']}?do=4'>下一步</a>"; } } } if ($do == '4') { require 'config.php'; if (defined("SAE_ACCESSKEY")) { require 'includes/sae.php'; //SaeStorage 文件存储检测 $storage = new SaeStorage(); $storage->write($Storage, 'test.txt', 'ceshi') or die('开启SaeStorage失败,请检查SaeStorage设置状态以及config.php里的Storage参数'); $storage->delete($Storage, 'test.txt'); } if (!defined("SAE_ACCESSKEY") && (!$user || !$pwd || !$dbname)) { echo "请先填写好数据库并保存后再安装"; } else { $sql = "CREATE TABLE udisk (\n" . " `id` int(11) NOT NULL auto_increment,\n" . " `filename` varchar(255) NOT NULL,\n" . " `size` varchar(14) NOT NULL,\n" . " `datetime` datetime NOT NULL,\n" . " `type` varchar(255) NOT NULL,\n" . " `fileurl` varchar(255) NOT NULL,\n" . " `ip` varchar(15) NOT NULL,\n" . " `hide` int(1) NOT NULL DEFAULT 0,\n" . " `pwd` varchar(255) NULL,\n" . " PRIMARY KEY (`id`)\n" . ") ENGINE=MyISAM DEFAULT CHARSET=utf8;"; $cn = mysql_connect($host, $user, $pwd); if (!$cn) { die('err:' . mysql_error()); } mysql_select_db($dbname, $cn) or die('err:' . mysql_error()); mysql_query("set names utf8", $cn); if (mysql_query($sql)) { @file_put_contents("install.lock", 'install'); echo '<font color="green">安装成功!</font><br/><a href="./">>>网站首页</a><br/><br/><font color="#FF0033">如果你的空间不支持本地文件读写,请自行建立 install.lock 文件!</font>'; } else {
/** * 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)); } } }
private function UploadToSae($func, $thumbImage) { //在新浪sae下 $S = new \SaeStorage(); $S->delete('lxpfigo', str_replace('http://atrs-lxpfigo.stor.sinaapp.com', '', $this->oldFile)); ob_start(); $func($thumbImage); $imageStr = ob_get_contents(); $url = $S->write('lxpfigo', '/operate/' . date(Ymd) . '/' . time() . '.' . $this->imageType, $imageStr); ob_end_clean(); if ($url) { $this->url = $url; return true; } else { $this->status = $this->error[5]; return false; } }
static function delete_topic($pics, $ext = 'jpg', $storage = 'temp') { define('TEMP', $storage); //缓存storage if (is_array($pics) == true) { $file_name = $pics['pic_name'][0]; $ext = $pics['pic_name'][1]; } else { $file_name = $pics; } $pic_big = $file_name . '_big.jpg'; $pic_midde = $file_name . '_midde.jpg'; $pic_small = $file_name . '_small.jpg'; $pic_y = $file_name . "." . $ext; $s = new SaeStorage(); $s->delete(TEMP, $pic_big); $s->delete(TEMP, $pic_midde); $s->delete(TEMP, $pic_small); if ($s->delete(TEMP, $pic_y) == false) { $s->delete(TEMP, $file_name . ".png"); $s->delete(TEMP, $file_name . ".gif"); } return 1; }
} public function upload($dir, $newfile, $upload) { return file_exists($upload) && is_uploaded_file($upload) && @move_uploaded_file($upload, KC_LOCALDIR . $dir . '/' . $newfile); } } } if ($is_ok) { $cache = file_exists($cachefile) ? @json_decode(file_get_contents($cachefile), true) : array(); if (empty($cache) && !is_array($cache)) { $cache = array(); } $s = new SaeStorage(); if (!empty($_REQUEST['del'])) { // 删除文件 if ($s->delete($dir, $_REQUEST['del'])) { $msg = '删除成功'; unset($cache[$_REQUEST['del']]); file_put_contents($cachefile, json_encode($cache)); } } // 上传文件 if (!empty($_POST['upload'])) { $time = time(); $upload = !empty($_FILES['file']) ? $_FILES['file'] : array(); $ext = !empty($upload['type']) ? file_ext($upload['type']) : ''; $newfile = date('YmdHis', $time) . '-' . rand(1000, 9999) . '.' . $ext; $desc = !empty($_POST['desc']) ? $_POST['desc'] : ''; $upload_errors = array(0 => '上传成功', 1 => '文件大小超过服务器限制', 2 => '文件大小超出浏览器限制', 3 => '文件上传不完整', 4 => '没有找到要上传的文件', 5 => '服务器临时文件夹丢失', 6 => '文件写入到临时文件夹出错', 7 => '上传目录不可写'); if (empty($upload)) { $msg = "上传失败,请重新上传";
/** * 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; }
$giftpicname = implode(".", $filename); $tmp_name = $_FILES['file']['tmp_name']; $q = new SaeStorage(); $giftpicname = $_GET['uid'] . "_" . $_GET['taskid'] . "_" . $giftpicname; $result = $q->upload("bzlm", $giftpicname, $tmp_name); $giftpicurl = $q->getUrl("bzlm", $giftpicname); $newtask = "no"; if (!$result) { echo "<script>alert('很抱歉,上传失败,请重新尝试!如重试多次仍无法上传,请在页面最下方联系我们。');location.href='my.php';</script>"; } if ($_POST['submit'] == "上传图片") { $newtask = "yes"; echo "<script>alert('恭喜您,上传成功!完成了任务" . $_GET['taskid'] . ",获得了" . $_GET['addmoney'] . "枚金币!');location.href='my.php';</script>"; } else { $oldfilename = $_GET['oldname']; $r = $q->delete("bzlm", $oldfilename); $newtask = "no"; echo "<script>alert('恭喜您,重新上传成功!完成了任务" . $_GET['taskid'] . ",由于非首次完成,故金币数无变化!');location.href='my.php';</script>"; } //添加数据库图片地址 include 'info.php'; $con = mysql_connect($mysql_host . ':' . $mysql_port, $mysql_user, $mysql_password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_query("SET NAMES 'UTF8'"); mysql_select_db($mysql_database, $con); $sql = "UPDATE `app_bzlmxb`.`user` SET `task" . $_GET['taskid'] . "` = '" . $giftpicname . "' WHERE `user`.`uid` =" . $_GET['uid'] . ";"; $result = mysql_query($sql); //加金币 if ($newtask == "yes") {
/** * 上传头像 */ function upload($_FILES) { $username = $_GET['username']; $files = $_FILES['file']; $filename = $files['name']; //获取图片名字 $fileResource = $files['tmp_name']; $storage = new SaeStorage(); $domain = "userinfo"; if ($storage->fileExists($domain, $filename)) { $storage->delete($domain, $filename); } if ($storage->upload($domain, $filename, $fileResource)) { $imgUrl = $storage->getCDNUrl($domain, $filename); //获取图片地址 //执行修改语句,将图片URl地址及图片名字写入数据库 $update = "update `user` set `imgName`='{$filename}', `imgUrl`='{$imgUrl}' where `username`='{$username}'"; $result = mysql_query($update); //if(mysql_affected_rows()!=0){ echo "上传成功"; //} } else { echo "上传失败,错误信息:" . $storage->errmsg(); } }
/** * 删除文件 * * @access public * @param array $content 文件相关信息 * @return string */ public static function deleteHandle(array $content) { $stor = new SaeStorage(); $options = Typecho_Widget::widget('Widget_Options'); $SaeStorageDomain = $options->plugin('SaeUpload')->saestoragedomain; return $stor->delete($SaeStorageDomain, $content['attachment']->path); }
/** * * {@inheritDoc} * @see \Illuminate\Contracts\Filesystem\Filesystem::deleteDirectory() */ public function deleteDirectory($directory) { list($domain, $path) = $this->parser($directory); return $this->storage->delete($domain, $path); }
/** * 文件删除 * @param string $filename 文件名 * @param string $type 其他参数 * @return bool */ function file_delete($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->delete($domain, $filePath); break; case 'FTP': $storage = new \Common\Plugin\Ftp(); return $storage->unlink($filename); break; default: return \Think\Storage::unlink($filename, $type); } }
function delfile($f) { $s = new SaeStorage(); $domain = 'o'; $result = $s->delete($domain, '/uploads/' . $f); }
/* * 用户上传头像 */ require_once "connect.php"; $username = $_GET['username']; //获取用户姓名 $storage = new SaeStorage(); $domain = "userinfo"; if (!empty($_FILES)) { $files = $_FILES['file']; $filename = $files['name']; //获取图片名字 $fileResource = $files['tmp_name']; if ($storage->fileExists($domain, $filename)) { $storage->delete($domain, $filename); } if ($storage->upload($domain, $filename, $fileResource)) { $imgUrl = $storage->getCDNUrl($domain, $filename); //获取图片地址 //执行修改语句,将图片URl地址及图片名字写入数据库 $update = "update `user` set `imgName`='{$filename}', `imgUrl`='{$imgUrl}' where `username`='{$username}'"; $result = mysql_query($update); if (mysql_affected_rows() != 0) { echo "上传成功"; } } else { echo "上传失败,错误信息:" . $storage->errmsg(); } } else { echo "文件未找到";
/** * All rights reserved. * 环境检测 * @author wangxin <*****@*****.**> * @time 2011/3/9 17:24 * @version Id: 0.9 */ define('DAGGER_PATH_ROOT', rtrim(dirname(__FILE__), '/') . '/../'); include DAGGER_PATH_ROOT . "config/SysInitConfig.php"; include DAGGER_PATH_ROOT . "libs/DaggerSysInitConfig.php"; include DAGGER_PATH_CONFIG . "DBConfig.php"; if (DAGGER_PLATFORM == 'sae') { $s = new SaeStorage(); if ($s->write('data', '_test.test', 'test!')) { $str .= '<div class="text_green">storage-domian检测成功</div>'; $s->delete('data', '_test.test'); } else { $str .= '<div class="text_red">需要创建一个storage-domian:data</div>'; } if (@file_put_contents('saemc://_test.test', 'test!')) { $str .= '<div class="text_green">Memcache检测成功</div>'; } else { $str .= '<div class="text_red">需要开启SAE的Memcache</div>'; } } else { $str = '<div>基本环境检测:</div>'; //PHP版本检测 if (substr(phpversion(), 0, 1) < 5) { $str .= '<div class="text_red">PHP版本检测失败,PHP版本必须 >= 5...</div>'; } else { $str .= '<div class="text_green">PHP版本检测成功,当前版本:' . phpversion() . '...</div>';
<?php define("CONSUMER_KEY", 'vPZ6aL6A6rSjXXb9'); define("CONSUMER_SECRET", 'JKO1d2btX8UjGehUX3pFOWdorWmVE1eU'); define("ACCESS_TOKEN", '74dd94519b1d410278283098b1c0baf0'); define("ACCESS_TOKEN_SECRET", 'a6e7d72f1b0f3db8f41a18c1d66f5063'); include_once 'api/tblog.class.php'; if ($_POST['submit'] == '上传') { $tblog = new TBlog(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET); if (isset($_FILES['element_1'])) { $target_path = 'saestor://images/temp_' . $_FILES['element_1']['name']; move_uploaded_file($_FILES['element_1']['tmp_name'], $target_path); $url = $tblog->upload($_REQUEST['text'], $target_path); $s = new SaeStorage(); $s->delete('images', 'temp_' . $_FILES['element_1']['name']); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>图床</title> <link rel="stylesheet" type="text/css" href="view.css" media="all"> <script type="text/javascript" src="view.js"></script> </head> <body id="main_body" > <img id="top" src="top.png" alt=""> <div id="form_container">
function file_delete($filename) { if (IS_SAE) { $arr = explode('/', ltrim($filename, './')); $domain = array_shift($arr); $filePath = implode('/', $arr); $s = new SaeStorage(); return $s->delete($domain, $filePath); } else { return unlink($filename); } }
<?php /*数据库备份*/ define('DOMAIN', 'dbback'); //define('', ''); $stor = new SaeStorage(SAE_ACCESSKEY, SAE_SECRETKEY); /*当天数据备份*/ $date = date('Y-m-d'); $filename = $date . '.sql.zip'; if (!$stor->fileExists(DOMAIN, $filename)) { $dj = new SaeDeferredJob(); $taskID = $dj->addTask('export', 'mysql', DOMAIN, $filename, SAE_MYSQL_DB, '', ''); if ($taskID === false) { var_dump($dj->errno(), $dj->errmsg()); } else { echo $taskID; } } /*旧备份清理*/ /*保留最近7天和每周1和每月1日的数据备份*/ $week_ago = date('Y-m-d', strtotime('-1 week')); $ninety_days_ago = date('Y-m-d', strtotime('-90 day')); if (date('N', time()) != '1' && date('d') != '8' && $stor->fileExists(DOMAIN, $week_ago . '.sql.zip')) { //if ( today != monday && today != 8.th), delete 7 days ago backup $stor->delete(DOMAIN, $week_ago . '.sql.zip'); } if (date('d', strtotime('-90 day')) != '1' && $stor->fileExists(DOMAIN, $ninety_days_ago . '.sql.zip')) { //if ( $90daysago != 1.st ), delete 3 months ago backup $stor->delete(DOMAIN, $ninety_days_ago . '.sql.zip'); }