Repository: Mintimate/OneindexM Branch: master Commit: ee9c63a9681d Files: 87 Total size: 471.0 KB Directory structure: gitextract_zkw3fajl/ ├── .gitignore ├── README.md ├── cache/ │ └── abc ├── config/ │ └── README.md ├── controller/ │ ├── AdminController.php │ ├── CommonController.php │ ├── ImagesController.php │ ├── IndexController.php │ └── UploadController.php ├── index.php ├── init.php ├── lib/ │ ├── Parsedown.php │ ├── cache/ │ │ ├── filecache_.php │ │ ├── memcache_.php │ │ ├── redis_.php │ │ └── secache_.php │ ├── cache.php │ ├── fetch.php │ ├── onedrive.php │ ├── oneindex.php │ ├── route.php │ ├── sqlite.php │ └── view.php ├── one.php ├── statics/ │ ├── common/ │ │ ├── offline/ │ │ │ ├── css/ │ │ │ │ └── main.css │ │ │ └── js/ │ │ │ ├── aria2.js │ │ │ ├── jquery.Storage.js │ │ │ ├── jquery.jsonrpc.js │ │ │ ├── mustache.js │ │ │ ├── peerid.js │ │ │ └── yaaw-1.1.js │ │ └── search/ │ │ └── js/ │ │ └── search.js │ └── themes/ │ └── nexmoe/ │ ├── css/ │ │ └── forkGh.css │ └── js/ │ ├── nexmoe.js │ └── personjs.js ├── view/ │ ├── admin/ │ │ ├── cache.php │ │ ├── images.php │ │ ├── install/ │ │ │ ├── install_0.php │ │ │ ├── install_1.php │ │ │ ├── install_2.php │ │ │ ├── install_3.php │ │ │ └── layout.php │ │ ├── layout.php │ │ ├── login.php │ │ ├── offline.php │ │ ├── setpass.php │ │ ├── settings.php │ │ ├── show.php │ │ └── upload.php │ ├── common/ │ │ ├── offline.php │ │ ├── search.php │ │ └── tips.php │ └── themes/ │ ├── classic/ │ │ ├── 404.php │ │ ├── layout.php │ │ └── list.php │ ├── material/ │ │ ├── 404.php │ │ ├── images/ │ │ │ ├── index.php │ │ │ └── layout.php │ │ ├── layout.php │ │ ├── list.php │ │ ├── password.php │ │ └── show/ │ │ ├── audio.php │ │ ├── code.php │ │ ├── doc.php │ │ ├── image.php │ │ ├── pdf.php │ │ ├── stream.php │ │ ├── video.php │ │ ├── video2.php │ │ └── video5.php │ └── nexmoe/ │ ├── 404.php │ ├── images/ │ │ ├── index.php │ │ └── layout.php │ ├── layout.php │ ├── list.php │ ├── password.php │ ├── readme.html │ └── show/ │ ├── audio.php │ ├── code.php │ ├── doc.php │ ├── image.php │ ├── pdf.php │ ├── stream.php │ ├── video.php │ ├── video2.php │ └── video5.php └── 使用及免责协议.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ **/.DS_Store ================================================ FILE: README.md ================================================ ## 简介 本项目是基于: - Oneindex - OneindexN项目地址:https://github.com/xieqifei/OneindexN 详细安装教程: - [基于Onedrive和Server搭建下载站/网盘](https://www.mintimate.cn/2020/09/22/oneindex) 教程视频: - [8分钟利用OneDrive搭建不限速的OneIndex分享网盘](https://www.bilibili.com/video/BV1ph41197aa) 打赏 - 爱发电:[Mintimate的电圈](https://www.afdian.net/@mintimate/plan)  ### 特别注意 OneindexM的默认密码为:**MintimateBlog** ## 修改功能: ### 后台: - 选择安装世纪互联/国际版(如需修改版本,需要删除config文件夹里的文件后重新进入安装程序) - 指定文件夹/全部文件夹,关闭Readme.md、index.html、head.md渲染(如果开启游客离线上传,可以关闭此路径的渲染,避免游客上传会被渲染的文件。) ### 前台 以下功能仅支持nexmoe主题 - 搜索功能:全局搜索/当前页过滤 - 文件操作:删除/新建/重命名/剪切/复制/分享等。仅管理员可用 - 文件上传:4M以下的文件在线上传。url远程上传,仅onedrive个人版支持。aria2离线上传,需自行安装在vps上安装aria2并完成相关配置。 - 外部视频播放器播放接口。需要安装对应播放器。 - 管理员登陆后,查看加密文件夹无需密码。 ## 更新日志 - 2021.12.03:修复PHP7.x查询函数警告问题;修复文件过滤、查询出错问题;修复排序不可用问题;移除Jq、Bootstrap;调整部分UI - 2021.08.03:修复Cookies循环问题、修复世纪互联版本部分情况不可用问题。 - 2021.07.01:修复因为Onedrive接口更换,而导致的无法部署。 - 2021.06.25:更换重写URL服务器。 ## 部署网站 网站环境尽量使用Nginx或Apache,配合PHP5.7+版本。 建议参考文章: 
') { $markup = $trimmedMarkup; $markup = substr($markup, 3); $position = strpos($markup, "
"); $markup = substr_replace($markup, '', $position, 4); } return $markup; } # # Deprecated Methods # function parse($text) { $markup = $this->text($text); return $markup; } protected function sanitiseElement(array $Element) { static $goodAttribute = '/^[a-zA-Z0-9][a-zA-Z0-9-_]*+$/'; static $safeUrlNameToAtt = array( 'a' => 'href', 'img' => 'src', ); if (isset($safeUrlNameToAtt[$Element['name']])) { $Element = $this->filterUnsafeUrlInAttribute($Element, $safeUrlNameToAtt[$Element['name']]); } if ( ! empty($Element['attributes'])) { foreach ($Element['attributes'] as $att => $val) { # filter out badly parsed attribute if ( ! preg_match($goodAttribute, $att)) { unset($Element['attributes'][$att]); } # dump onevent attribute elseif (self::striAtStart($att, 'on')) { unset($Element['attributes'][$att]); } } } return $Element; } protected function filterUnsafeUrlInAttribute(array $Element, $attribute) { foreach ($this->safeLinksWhitelist as $scheme) { if (self::striAtStart($Element['attributes'][$attribute], $scheme)) { return $Element; } } $Element['attributes'][$attribute] = str_replace(':', '%3A', $Element['attributes'][$attribute]); return $Element; } # # Static Methods # protected static function escape($text, $allowQuotes = false) { return htmlspecialchars($text, $allowQuotes ? ENT_NOQUOTES : ENT_QUOTES, 'UTF-8'); } protected static function striAtStart($string, $needle) { $len = strlen($needle); if ($len > strlen($string)) { return false; } else { return strtolower(substr($string, 0, $len)) === strtolower($needle); } } static function instance($name = 'default') { if (isset(self::$instances[$name])) { return self::$instances[$name]; } $instance = new static(); self::$instances[$name] = $instance; return $instance; } private static $instances = array(); # # Fields # protected $DefinitionData; # # Read-Only protected $specialCharacters = array( '\\', '`', '*', '_', '{', '}', '[', ']', '(', ')', '>', '#', '+', '-', '.', '!', '|', ); protected $StrongRegex = array( '*' => '/^[*]{2}((?:\\\\\*|[^*]|[*][^*]*[*])+?)[*]{2}(?![*])/s', '_' => '/^__((?:\\\\_|[^_]|_[^_]*_)+?)__(?!_)/us', ); protected $EmRegex = array( '*' => '/^[*]((?:\\\\\*|[^*]|[*][*][^*]+?[*][*])+?)[*](?![*])/s', '_' => '/^_((?:\\\\_|[^_]|__[^_]*__)+?)_(?!_)\b/us', ); protected $regexHtmlAttribute = '[a-zA-Z_:][\w:.-]*(?:\s*=\s*(?:[^"\'=<>`\s]+|"[^"]*"|\'[^\']*\'))?'; protected $voidElements = array( 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', ); protected $textLevelElements = array( 'a', 'br', 'bdo', 'abbr', 'blink', 'nextid', 'acronym', 'basefont', 'b', 'em', 'big', 'cite', 'small', 'spacer', 'listing', 'i', 'rp', 'del', 'code', 'strike', 'marquee', 'q', 'rt', 'ins', 'font', 'strong', 's', 'tt', 'kbd', 'mark', 'u', 'xm', 'sub', 'nobr', 'sup', 'ruby', 'var', 'span', 'wbr', 'time', ); } ================================================ FILE: lib/cache/filecache_.php ================================================ cache_path = $cache_path; } function get($key){ $file = $this->cache_path . md5($key) . '.php'; $data = @include $file; if( is_array($data) && $data['expire'] > time() && !is_null($data['data']) ){ return $data['data']; }else{ return null; } } function set($key, $value=null, $expire=99999999){ $file = $this->cache_path . md5($key) . '.php'; $data['expire'] = time() + $expire; $data['data'] = $value; return @file_put_contents($file, "cache_path.'*.php')); } } ================================================ FILE: lib/cache/memcache_.php ================================================ m = new Memcache(); if(empty($config)){ $config = 'localhost:11211'; } list($host, $port) = explode(':', $config, 2); $this->m->addServer($host, $port); } function get($key){ $data = $this->m->get($key); if( is_array($data) && $data['expire'] > time() && !is_null($data['data']) ){ return $data['data']; }else{ return null; } } function set($key, $value=null, $expire=99999999){ $data['expire'] = time() + $expire; $data['data'] = $value; return $this->m->set($key, $data); } function clear(){ $this->m->flush(10); } } ================================================ FILE: lib/cache/redis_.php ================================================ redis = new Redis(); if(empty($config)){ $config = 'localhost:6379'; } list($host, $port) = explode(':', $config, 2); $this->redis->pconnect($host, $port); } function get($key){ $gRefreshTime = $this->redis->get("OneIndex_gRefreshTime"); $key = "OneIndex_$gRefreshTime\_" . $key; $data = $this->redis->get($key); return unserialize($data) ?: null; } function set($key, $value=null, $expire=600){ $gRefreshTime = $this->redis->get("OneIndex_gRefreshTime"); if (empty($gRefreshTime)) { $gRefreshTime = time(); $this->redis->set("OneIndex_gRefreshTime", $gRefreshTime); } $key = "OneIndex_$gRefreshTime\_" . $key; return $this->redis->set($key, serialize($value), $expire); } function clear(){ $this->redis->set("OneIndex_gRefreshTime", $gRefreshTime); } } ================================================ FILE: lib/cache/secache_.php ================================================ cachefile = $cachefile; $this->c = new secache(); $this->c->workat($this->cachefile); } function get($key){ $this->c->fetch(md5($key),$data); if( is_array($data) && $data['expire'] > time() && !is_null($data['data']) ){ return $data['data']; }else{ return null; } } function set($key, $value=null, $expire=99999999){ $data['expire'] = time() + $expire; $data['data'] = $value; return $this->c->store(md5($key),$data); } function clear(){ return $this->c->clear(); } } class secache{ var $idx_node_size = 40; var $idx_node_base = 0; var $data_base_pos = 262588; //40+20+24*16+16*16*16*16*4; var $schema_item_size = 24; var $header_padding = 20; //保留空间 放置php标记防止下载 var $info_size = 20; //保留空间 4+16 maxsize|ver //40起 添加20字节保留区域 var $idx_seq_pos = 40; //id 计数器节点地址 var $dfile_cur_pos = 44; //id 计数器节点地址 var $idx_free_pos = 48; //id 空闲链表入口地址 var $idx_base_pos = 444; //40+20+24*16 var $min_size = 10240; //10M最小值 var $schema_struct = array('size','free','lru_head','lru_tail','hits','miss'); var $ver = '$Rev$'; var $name = '系统默认缓存(文件型)'; function workat($file){ $this->_file = $file.'.php'; $this->_bsize_list = array( 512=>10, 3<<10=>10, 8<<10=>10, 20<<10=>4, 30<<10=>2, 50<<10=>2, 80<<10=>2, 96<<10=>2, 128<<10=>2, 224<<10=>2, 256<<10=>2, 512<<10=>1, 1024<<10=>1, ); $this->_node_struct = array( 'next'=>array(0,'V'), 'prev'=>array(4,'V'), 'data'=>array(8,'V'), 'size'=>array(12,'V'), 'lru_right'=>array(16,'V'), 'lru_left'=>array(20,'V'), 'key'=>array(24,'H*'), ); if(!file_exists($this->_file)){ $this->create(); }else{ $this->_rs = fopen($this->_file,'rb+') or $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR); $this->_seek($this->header_padding); $info = unpack('V1max_size/a*ver',fread($this->_rs,$this->info_size)); $info['ver'] = trim($info['ver']); if($info['ver']!=$this->ver){ $this->_format(true); }else{ $this->max_size = $info['max_size']; } } $this->idx_node_base = $this->data_base_pos+$this->max_size; $this->_block_size_list = array_keys($this->_bsize_list); sort($this->_block_size_list); return true; } function create(){ $this->_rs = fopen($this->_file,'wb+') or $this->trigger_error('Can\'t open the cachefile: '.realpath($this->_file),E_USER_ERROR);; fseek($this->_rs,0); fputs($this->_rs,'<'.'?php exit()?'.'>'); return $this->_format(); } function _puts($offset,$data){ if($offset < $this->max_size*1.5){ $this->_seek($offset); return fputs($this->_rs,$data); }else{ $this->trigger_error('Offset over quota:'.$offset,E_USER_ERROR); } } function _seek($offset){ return fseek($this->_rs,$offset); } function clear(){ return $this->_format(true); } function fetch($key,&$return){ if($this->lock(false)){ $locked = true; } if($this->search($key,$offset)){ $info = $this->_get_node($offset); $schema_id = $this->_get_size_schema_id($info['size']); if($schema_id===false){ if($locked) $this->unlock(); return false; } $this->_seek($info['data']); $data = fread($this->_rs,$info['size']); $return = unserialize($data); if($return===false){ if($locked) $this->unlock(); return false; } if($locked){ $this->_lru_push($schema_id,$info['offset']); $this->_set_schema($schema_id,'hits',$this->_get_schema($schema_id,'hits')+1); return $this->unlock(); }else{ return true; } }else{ if($locked) $this->unlock(); return false; } } /** * lock * 如果flock不管用,请继承本类,并重载此方法 * * @param mixed $is_block 是否阻塞 * @access public * @return void */ function lock($is_block,$whatever=false){ ignore_user_abort(1); return flock($this->_rs, $is_block?LOCK_EX:LOCK_EX+LOCK_NB); } /** * unlock * 如果flock不管用,请继承本类,并重载此方法 * * @access public * @return void */ function unlock(){ ignore_user_abort(0); return flock($this->_rs, LOCK_UN); } function delete($key,$pos=false){ if($pos || $this->search($key,$pos)){ if($info = $this->_get_node($pos)){ //删除data区域 if($info['prev']){ $this->_set_node($info['prev'],'next',$info['next']); $this->_set_node($info['next'],'prev',$info['prev']); }else{ //改入口位置 $this->_set_node($info['next'],'prev',0); $this->_set_node_root($key,$info['next']); } $this->_free_dspace($info['size'],$info['data']); $this->_lru_delete($info); $this->_free_node($pos); return $info['prev']; } } return false; } function store($key,$value){ if($this->lock(true)){ //save data $data = serialize($value); $size = strlen($data); //get list_idx $has_key = $this->search($key,$list_idx_offset); $schema_id = $this->_get_size_schema_id($size); if($schema_id===false){ $this->unlock(); return false; } if($has_key){ $hdseq = $list_idx_offset; $info = $this->_get_node($hdseq); if($schema_id == $this->_get_size_schema_id($info['size'])){ $dataoffset = $info['data']; }else{ //破掉原有lru $this->_lru_delete($info); if(!($dataoffset = $this->_dalloc($schema_id))){ $this->unlock(); return false; } $this->_free_dspace($info['size'],$info['data']); $this->_set_node($hdseq,'lru_left',0); $this->_set_node($hdseq,'lru_right',0); } $this->_set_node($hdseq,'size',$size); $this->_set_node($hdseq,'data',$dataoffset); }else{ if(!($dataoffset = $this->_dalloc($schema_id))){ $this->unlock(); return false; } $hdseq = $this->_alloc_idx(array( 'next'=>0, 'prev'=>$list_idx_offset, 'data'=>$dataoffset, 'size'=>$size, 'lru_right'=>0, 'lru_left'=>0, 'key'=>$key, )); if($list_idx_offset>0){ $this->_set_node($list_idx_offset,'next',$hdseq); }else{ $this->_set_node_root($key,$hdseq); } } if($dataoffset>$this->max_size){ $this->trigger_error('alloc datasize:'.$dataoffset,E_USER_WARNING); return false; } $this->_puts($dataoffset,$data); $this->_set_schema($schema_id,'miss',$this->_get_schema($schema_id,'miss')+1); $this->_lru_push($schema_id,$hdseq); $this->unlock(); return true; }else{ $this->trigger_error("Couldn't lock the file !",E_USER_WARNING); return false; } } /** * search * 查找指定的key * 如果找到节点则$pos=节点本身 返回true * 否则 $pos=树的末端 返回false * * @param mixed $key * @access public * @return void */ function search($key,&$pos){ return $this->_get_pos_by_key($this->_get_node_root($key),$key,$pos); } function _get_size_schema_id($size){ foreach($this->_block_size_list as $k=>$block_size){ if($size <= $block_size){ return $k; } } return false; } function _parse_str_size($str_size,$default){ if(preg_match('/^([0-9]+)\s*([gmk]|)$/i',$str_size,$match)){ switch(strtolower($match[2])){ case 'g': if($match[1]>1){ $this->trigger_error('Max cache size 1G',E_USER_ERROR); } $size = $match[1]<<30; break; case 'm': $size = $match[1]<<20; break; case 'k': $size = $match[1]<<10; break; default: $size = $match[1]; } if($size<=0){ $this->trigger_error('Error cache size '.$this->max_size,E_USER_ERROR); return false; }elseif($size<10485760){ return 10485760; }else{ return $size; } }else{ return $default; } } function _format($truncate=false){ if($this->lock(true,true)){ if($truncate){ $this->_seek(0); ftruncate($this->_rs,$this->idx_node_base); } $this->max_size = $this->_parse_str_size(SECACHE_SIZE,15728640); //default:15m $this->_puts($this->header_padding,pack('V1a*',$this->max_size,$this->ver)); ksort($this->_bsize_list); $ds_offset = $this->data_base_pos; $i=0; foreach($this->_bsize_list as $size=>$count){ //将预分配的空间注册到free链表里 $count *= min(3,floor($this->max_size/10485760)); $next_free_node = 0; for($j=0;$j<$count;$j++){ $this->_puts($ds_offset,pack('V',$next_free_node)); $next_free_node = $ds_offset; $ds_offset+=intval($size); } $code = pack(str_repeat('V1',count($this->schema_struct)),$size,$next_free_node,0,0,0,0); $this->_puts(60+$i*$this->schema_item_size,$code); $i++; } $this->_set_dcur_pos($ds_offset); $this->_puts($this->idx_base_pos,str_repeat("\0",262144)); $this->_puts($this->idx_seq_pos,pack('V',1)); $this->unlock(); return true; }else{ $this->trigger_error("Couldn't lock the file !",E_USER_ERROR); return false; } } function _get_node_root($key){ $this->_seek(hexdec(substr($key,0,4))*4+$this->idx_base_pos); $a= fread($this->_rs,4); list(,$offset) = unpack('V',$a); return $offset; } function _set_node_root($key,$value){ return $this->_puts(hexdec(substr($key,0,4))*4+$this->idx_base_pos,pack('V',$value)); } function _set_node($pos,$key,$value){ if(!$pos){ return false; } if(isset($this->_node_struct[$key])){ return $this->_puts($pos*$this->idx_node_size+$this->idx_node_base+$this->_node_struct[$key][0],pack($this->_node_struct[$key][1],$value)); }else{ return false; } } function _get_pos_by_key($offset,$key,&$pos){ if(!$offset){ $pos = 0; return false; } $info = $this->_get_node($offset); if($info['key']==$key){ $pos = $info['offset']; return true; }elseif($info['next'] && $info['next']!=$offset){ return $this->_get_pos_by_key($info['next'],$key,$pos); }else{ $pos = $offset; return false; } } function _lru_delete($info){ if($info['lru_right']){ $this->_set_node($info['lru_right'],'lru_left',$info['lru_left']); }else{ $this->_set_schema($this->_get_size_schema_id($info['size']),'lru_tail',$info['lru_left']); } if($info['lru_left']){ $this->_set_node($info['lru_left'],'lru_right',$info['lru_right']); }else{ $this->_set_schema($this->_get_size_schema_id($info['size']),'lru_head',$info['lru_right']); } return true; } function _lru_push($schema_id,$offset){ $lru_head = $this->_get_schema($schema_id,'lru_head'); $lru_tail = $this->_get_schema($schema_id,'lru_tail'); if((!$offset) || ($lru_head==$offset))return; $info = $this->_get_node($offset); $this->_set_node($info['lru_right'],'lru_left',$info['lru_left']); $this->_set_node($info['lru_left'],'lru_right',$info['lru_right']); $this->_set_node($offset,'lru_right',$lru_head); $this->_set_node($offset,'lru_left',0); $this->_set_node($lru_head,'lru_left',$offset); $this->_set_schema($schema_id,'lru_head',$offset); if($lru_tail==0){ $this->_set_schema($schema_id,'lru_tail',$offset); }elseif($lru_tail==$offset && $info['lru_left']){ $this->_set_schema($schema_id,'lru_tail',$info['lru_left']); } return true; } function _get_node($offset){ $this->_seek($offset*$this->idx_node_size + $this->idx_node_base); $info = unpack('V1next/V1prev/V1data/V1size/V1lru_right/V1lru_left/H*key',fread($this->_rs,$this->idx_node_size)); $info['offset'] = $offset; return $info; } function _lru_pop($schema_id){ if($node = $this->_get_schema($schema_id,'lru_tail')){ $info = $this->_get_node($node); if(!$info['data']){ return false; } $this->delete($info['key'],$info['offset']); if(!$this->_get_schema($schema_id,'free')){ $this->trigger_error('pop lru,But nothing free...',E_USER_ERROR); } return $info; }else{ return false; } } function _dalloc($schema_id,$lru_freed=false){ if($free = $this->_get_schema($schema_id,'free')){ //如果lru里有链表 $this->_seek($free); list(,$next) = unpack('V',fread($this->_rs,4)); $this->_set_schema($schema_id,'free',$next); return $free; }elseif($lru_freed){ $this->trigger_error('Bat lru poped freesize',E_USER_ERROR); return false; }else{ $ds_offset = $this->_get_dcur_pos(); $size = $this->_get_schema($schema_id,'size'); if($size+$ds_offset > $this->max_size){ if($info = $this->_lru_pop($schema_id)){ return $this->_dalloc($schema_id,$info); }else{ $this->trigger_error('Can\'t alloc dataspace',E_USER_ERROR); return false; } }else{ $this->_set_dcur_pos($ds_offset+$size); return $ds_offset; } } } function _get_dcur_pos(){ $this->_seek($this->dfile_cur_pos); list(,$ds_offset) = unpack('V',fread($this->_rs,4)); return $ds_offset; } function _set_dcur_pos($pos){ return $this->_puts($this->dfile_cur_pos,pack('V',$pos)); } function _free_dspace($size,$pos){ if($pos>$this->max_size){ $this->trigger_error('free dspace over quota:'.$pos,E_USER_ERROR); return false; } $schema_id = $this->_get_size_schema_id($size); if($free = $this->_get_schema($schema_id,'free')){ $this->_puts($free,pack('V1',$pos)); }else{ $this->_set_schema($schema_id,'free',$pos); } $this->_puts($pos,pack('V1',0)); } function _dfollow($pos,&$c){ $c++; $this->_seek($pos); list(,$next) = unpack('V1',fread($this->_rs,4)); if($next){ return $this->_dfollow($next,$c); }else{ return $pos; } } function _free_node($pos){ $this->_seek($this->idx_free_pos); list(,$prev_free_node) = unpack('V',fread($this->_rs,4)); $this->_puts($pos*$this->idx_node_size+$this->idx_node_base,pack('V',$prev_free_node).str_repeat("\0",$this->idx_node_size-4)); return $this->_puts($this->idx_free_pos,pack('V',$pos)); } function _alloc_idx($data){ $this->_seek($this->idx_free_pos); list(,$list_pos) = unpack('V',fread($this->_rs,4)); if($list_pos){ $this->_seek($list_pos*$this->idx_node_size+$this->idx_node_base); list(,$prev_free_node) = unpack('V',fread($this->_rs,4)); $this->_puts($this->idx_free_pos,pack('V',$prev_free_node)); }else{ $this->_seek($this->idx_seq_pos); list(,$list_pos) = unpack('V',fread($this->_rs,4)); $this->_puts($this->idx_seq_pos,pack('V',$list_pos+1)); } return $this->_create_node($list_pos,$data); } function _create_node($pos,$data){ $this->_puts($pos*$this->idx_node_size + $this->idx_node_base ,pack('V1V1V1V1V1V1H*',$data['next'],$data['prev'],$data['data'],$data['size'],$data['lru_right'],$data['lru_left'],$data['key'])); return $pos; } function _set_schema($schema_id,$key,$value){ $info = array_flip($this->schema_struct); return $this->_puts(60+$schema_id*$this->schema_item_size + $info[$key]*4,pack('V',$value)); } function _get_schema($id,$key){ $info = array_flip($this->schema_struct); $this->_seek(60+$id*$this->schema_item_size); unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size)); $this->_seek(60+$id*$this->schema_item_size + $info[$key]*4); list(,$value) =unpack('V',fread($this->_rs,4)); return $value; } function _all_schemas(){ $schema = array(); for($i=0;$i<16;$i++){ $this->_seek(60+$i*$this->schema_item_size); $info = unpack('V1'.implode('/V1',$this->schema_struct),fread($this->_rs,$this->schema_item_size)); if($info['size']){ $info['id'] = $i; $schema[$i] = $info; }else{ return $schema; } } } function schemaStatus(){ $return = array(); foreach($this->_all_schemas() as $k=>$schemaItem){ if($schemaItem['free']){ $this->_dfollow($schemaItem['free'],$schemaItem['freecount']); } $return[] = $schemaItem; } return $return; } function status(&$curBytes,&$totalBytes){ $totalBytes = $curBytes = 0; $hits = $miss = 0; $schemaStatus = $this->schemaStatus(); $totalBytes = $this->max_size; $freeBytes = $this->max_size - $this->_get_dcur_pos(); foreach($schemaStatus as $schema){ $freeBytes+=$schema['freecount']*$schema['size']; $miss += $schema['miss']; $hits += $schema['hits']; } $curBytes = $totalBytes-$freeBytes; $return[] = array('name'=>'缓存命中','value'=>$hits); $return[] = array('name'=>'缓存未命中','value'=>$miss); return $return; } function trigger_error($errstr,$errno){ trigger_error($errstr,$errno); } } ?> ================================================ FILE: lib/cache.php ================================================ get($key); if(!is_null($value)){ return $value; }elseif(is_callable($default)){ $value = $default(); self::set($key, $value, $expire); return $value; }elseif(!is_null($default)){ self::set($key, $default, $expire); return $default; } } // 设置缓存 static function set($key, $value, $expire=99999999){ return self::c()->set($key, $value, $expire); } // 清空缓存 static function clear(){ return self::c()->clear(); } // 删除缓存 static function del($key){ return self::set($key, null); } // 判断缓存是否设置 static function has($key){ if(is_null(self::get($key))){ return false; }else{ return true; } } // 读取并删除缓存 static function pull($key){ $value = self::get($key); self::del($key); return $value; } } ================================================ FILE: lib/fetch.php ================================================ 1, //true, $head 有请求的返回值 CURLOPT_BINARYTRANSFER => true, //返回原生的Raw输出 CURLOPT_HEADER => true, //启用时会将头文件的信息作为数据流输出。 CURLOPT_FAILONERROR => true, //显示HTTP状态码,默认行为是忽略编号小于等于400的HTTP信息。 CURLOPT_AUTOREFERER => true, //当根据Location:重定向时,自动设置header中的Referer:信息。 CURLOPT_FOLLOWLOCATION => false, //跳转 CURLOPT_CONNECTTIMEOUT => 3, //在发起连接前等待的时间,如果设置为0,则无限等待。 CURLOPT_TIMEOUT => 5, //设置cURL允许执行的最长秒数。 CURLOPT_ENCODING => 'gzip,deflate', CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false, ); foreach ($opt as $k => $v) { self::$curl_opt[$k] = $v; } } /** * fetch::get('http://www.google.com/'); * fetch::post('http://www.google.com/', array('name'=>'foo')); */ public static function __callstatic($method, $args) { if (is_null(self::$curl_opt)) { self::init(); } @list($request, $post_data, $callback) = $args; if (is_callable($post_data)) { $callback = $post_data; $post_data = null; } //single_curl if (is_string($request) || !empty($request['url'])) { $request = self::bulid_request($request, $method, $post_data, $callback); return self::single_curl($request); } elseif (is_array($request)) { //rolling_curl foreach ($request as $k => $r) { $requests[$k] = self::bulid_request($r, $method, $post_data, $callback); } return self::rolling_curl($requests); } } private static function bulid_request($request, $method = 'GET', $post_data = null, $callback = null) { //url if (is_string($request)) { $request = array('url' => $request); } empty($request['method']) && $request['method'] = $method; empty($request['post_data']) && $request['post_data'] = $post_data; empty($request['callback']) && $request['callback'] = $callback; return $request; } private static function bulid_ch(&$request) { // url $ch = curl_init($request['url']); // curl_opt $curl_opt = empty($request['curl_opt']) ? array() : $request['curl_opt']; $curl_opt = $curl_opt + (array) self::$curl_opt; // method $curl_opt[CURLOPT_CUSTOMREQUEST] = strtoupper($request['method']); // post_data if (!empty($request['post_data'])) { $curl_opt[CURLOPT_POST] = true; $curl_opt[CURLOPT_POSTFIELDS] = $request['post_data']; } // header $headers = @self::bulid_request_header($request['headers'], $cookies); $curl_opt[CURLOPT_HTTPHEADER] = $headers; // cookies $request['cookies'] = empty($request['cookies']) ? fetch::$cookies : $request['cookies']; $cookies = empty($request['cookies']) ? $cookies : self::cookies_arr2str($request['cookies']); if (!empty($cookies)) { $curl_opt[CURLOPT_COOKIE] = $cookies; } //proxy $proxy = empty($request['proxy']) ? self::$proxy : $request['proxy']; if (!empty($proxy)) { $curl_opt[CURLOPT_PROXY] = $proxy; } //setopt curl_setopt_array($ch, $curl_opt); $request['curl_opt'] = $curl_opt; $request['ch'] = $ch; return $ch; } private static function response($raw, $ch) { $response = (object) curl_getinfo($ch); $response->raw = $raw; //$raw = fetch::iconv($raw, $response->content_type); $response->headers = substr($raw, 0, $response->header_size); $response->cookies = fetch::get_respone_cookies($response->headers); fetch::$cookies = array_merge((array) fetch::$cookies, $response->cookies); $response->content = substr($raw, $response->header_size); return $response; } private static function single_curl($request) { $ch = self::bulid_ch($request); $raw = curl_exec($ch); $response = self::response($raw, $ch); curl_close($ch); if (is_callable($request['callback'])) { call_user_func($request['callback'], $response, $request); } return $response; } private static function rolling_curl($requests) { $master = curl_multi_init(); $map = array(); // start the first batch of requests do { $k = key($requests); $request = current($requests); next($requests); $ch = self::bulid_ch($request); curl_multi_add_handle($master, $ch); $key = (string) $ch; $map[$key] = array($k, $request['callback']); } while (count($map) < self::$max_connect && count($map) < count($requests)); do { while (($execrun = curl_multi_exec($master, $running)) == CURLM_CALL_MULTI_PERFORM); if ($execrun != CURLM_OK) { break; } // a request was just completed -- find out which one while ($done = curl_multi_info_read($master)) { $key = (string) $done['handle']; list($k, $callback) = $map[$key]; // get the info and content returned on the request $raw = curl_multi_getcontent($done['handle']); $response = self::response($raw, $done['handle']); $responses[$k] = $response; // send the return values to the callback function. if (is_callable($callback)) { $key = (string) $done['handle']; unset($map[$key]); call_user_func($callback, $response, $requests[$k], $k); } // start a new request (it's important to do this before removing the old one) $k = key($requests); if (!empty($k)) { $k = key($requests); $request = current($requests); next($requests); $ch = self::bulid_ch($request); curl_multi_add_handle($master, $ch); $key = (string) $ch; $map[$key] = array($k, $request['callback']); curl_multi_exec($master, $running); } // remove the curl handle that just completed curl_multi_remove_handle($master, $done['handle']); } // Block for data in / output; error handling is done by curl_multi_exec if ($running) { curl_multi_select($master, 10); } } while ($running); return $responses; } private static function bulid_request_header($headers, &$cookies) { if (is_array($headers)) { $headers = join(PHP_EOL, $headers); } if (is_array(self::$headers)) { self::$headers = join(PHP_EOL, self::$headers); } $headers = self::$headers.PHP_EOL .$headers; foreach (explode(PHP_EOL, $headers) as $k => $v) { @list($k, $v) = explode(':', $v, 2); if (empty($k) || empty($v)) { continue; } $k = implode('-', array_map('ucfirst', explode('-', $k))); $tmp[$k] = $v; } foreach ((array) $tmp as $k => $v) { if ($k == 'Cookie') { $cookies = $v; } else { $return[] = $k . ':' . $v; } } return (array) $return; } public static function iconv(&$raw, $content_type) { @list($tmp, $charset) = explode('CHARSET=', strtoupper($content_type)); if (empty($charset) && stripos($content_type, 'html') > 0) { preg_match('@\if ($.Storage) will tell you if the plugin is loaded.
* $.Storage.set("name", "value") - Stores a named value in the data store.
* $.Storage.set({"name1":"value1", "name2":"value2", etc}) - Stores multiple name/value pairs in the data store.
* $.Storage.get("name") - Retrieves the value of the given name from the data store.
* $.Storage.remove("name") - Permanently deletes the name/value pair from the data store.
*
* @author Dave Schindler
*
* Distributed under the MIT License
*
* Copyright (c) 2010 Dave Schindler
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
(function($) {
// Private data
var isLS=typeof window.localStorage!=='undefined';
// Private functions
function wls(n,v){var c;if(typeof n==="string"&&typeof v==="string"){localStorage[n]=v;return true;}else if(typeof n==="object"&&typeof v==="undefined"){for(c in n){if(n.hasOwnProperty(c)){localStorage[c]=n[c];}}return true;}return false;}
function wc(n,v){var dt,e,c;dt=new Date();dt.setTime(dt.getTime()+31536000000);e="; expires="+dt.toGMTString();if(typeof n==="string"&&typeof v==="string"){document.cookie=n+"="+v+e+"; path=/";return true;}else if(typeof n==="object"&&typeof v==="undefined"){for(c in n) {if(n.hasOwnProperty(c)){document.cookie=c+"="+n[c]+e+"; path=/";}}return true;}return false;}
function rls(n){return localStorage[n];}
function rc(n){var nn, ca, i, c;nn=n+"=";ca=document.cookie.split(';');for(i=0;i
添加以下命令到crontab
*/10 * * * *
| # | 环境需求 | 当前环境 | |
|---|---|---|---|
| 1 | PHP > 5.5 | | |
| 2 | curl 支持 | | |
| 3 | config/ 目录可读可写 | | |
| 4 | cache/ 目录可读可写 | | |
| Tips | 建议配合Mintimate's Blog文章和视频操作:博客文章、 视频教程 |
client_id和client_secret,
根据你的Onedrive供应商选择:
| 远程路径 | 上传速度 | 进度 | 状态 | 操作 |
|---|
| 远程路径 | 状态 |
|---|---|
| Name | Size | Date Created | Date Modified |
|---|---|---|---|
| .. | |||
| / | |||