当前位置: 首页>>代码示例>>PHP>>正文


PHP dropbox::delta方法代码示例

本文整理汇总了PHP中dropbox::delta方法的典型用法代码示例。如果您正苦于以下问题:PHP dropbox::delta方法的具体用法?PHP dropbox::delta怎么用?PHP dropbox::delta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dropbox的用法示例。


在下文中一共展示了dropbox::delta方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: deltaCheck

 protected function deltaCheck()
 {
     $cache = $this->metaCacheArr;
     $cursor = '';
     if (!$cache) {
         $cache = array('cursor' => '', 'data' => array());
         $cache['data']['/'] = array('path' => '/', 'is_dir' => 1, 'mime_type' => '', 'bytes' => 0);
     } else {
         if (isset($cache['cursor'])) {
             $cursor = $cache['cursor'];
         }
     }
     try {
         $more = true;
         $info = array('cursor' => $cursor, 'entries' => array());
         do {
             $_info = $this->dropbox->delta($cursor);
             $info['entries'] += $_info['entries'];
             $cursor = $_info['cursor'];
         } while (!empty($_info['has_more']));
     } catch (Dropbox_Exception $e) {
         $info = $e->getMessage();
     }
     $info['cursor'] = $cursor;
     $entries = $info['entries'];
     $cache['cursor'] = $info['cursor'];
     foreach ($entries as $entry) {
         $key = strtolower($entry[0]);
         $pkey = strtolower(dirname($key));
         if (empty($entry[1])) {
             if (isset($cache['data'][$key]) && !empty($cache['data'][$key]['is_dir'])) {
                 $cache['data'][$pkey]['dirs']--;
             }
             unset($cache['data'][$pkey]['contents'][$key], $cache['data'][$key]);
             continue;
         }
         if (!isset($cache['data'][$pkey])) {
             $cache['data'][$pkey] = array();
         } else {
             unset($cache['data'][$key]['width'], $cache['data'][$key]['height']);
         }
         if (!empty($entry[1]['is_dir'])) {
             if (!isset($cache['data'][$pkey]['dirs'])) {
                 $cache['data'][$pkey]['dirs'] = 1;
             } else {
                 $cache['data'][$pkey]['dirs']++;
             }
         }
         $cache['data'][$pkey]['contents'][$key] = true;
         $cache['data'][$key] = $entry[1];
     }
     $cache['mtime'] = $_SERVER['REQUEST_TIME'];
     $this->metaCacheArr = $cache;
     $this->mataCacheSave();
 }
开发者ID:basdog22,项目名称:Qool,代码行数:55,代码来源:elFinderVolumeDropbox.class.php

示例2: deltaCheck

 /**
  * Get delta data and DB update
  * 
  * @param boolean $refresh force refresh
  * @return true|string error message
  */
 protected function deltaCheck($refresh = true)
 {
     $chk = false;
     if (!$refresh && ($chk = $this->query('select dat from ' . $this->DB_TableName . ' where path=\'\' and fname=\'\' limit 1'))) {
         $chk = unserialize($chk[0]);
     }
     if ($chk && $chk['mtime'] + $this->options['metaCacheTime'] > $_SERVER['REQUEST_TIME']) {
         return true;
     }
     try {
         $more = true;
         $this->DB->beginTransaction();
         if ($res = $this->query('select dat from ' . $this->DB_TableName . ' where path=\'\' and fname=\'\' limit 1')) {
             $res = unserialize($res[0]);
             $cursor = $res['cursor'];
         } else {
             $cursor = '';
         }
         $delete = false;
         $reset = false;
         $ptimes = array();
         $now = time();
         do {
             ini_set('max_execution_time', 120);
             $_info = $this->dropbox->delta($cursor);
             if (!empty($_info['reset'])) {
                 $this->DB->exec('TRUNCATE table ' . $this->DB_TableName);
                 $this->DB->exec('insert into ' . $this->DB_TableName . ' values(\'\', \'\', \'' . serialize(array('cursor' => '', 'mtime' => 0)) . '\', 0);');
                 $this->DB->exec('insert into ' . $this->DB_TableName . ' values(\'/\', \'\', \'' . serialize(array('path' => '/', 'is_dir' => 1, 'mime_type' => '', 'bytes' => 0)) . '\', 0);');
                 $reset = true;
             }
             $cursor = $_info['cursor'];
             foreach ($_info['entries'] as $entry) {
                 $key = strtolower($entry[0]);
                 $pkey = strtolower($this->_dirname($key));
                 $path = $this->DB->quote($pkey);
                 $fname = $this->DB->quote(strtolower($this->_basename($key)));
                 $where = 'where path=' . $path . ' and fname=' . $fname;
                 if (empty($entry[1])) {
                     $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($now, $ptimes[$pkey])) : $now;
                     $this->DB->exec('delete from ' . $this->DB_TableName . ' ' . $where);
                     !$delete && ($delete = true);
                     continue;
                 }
                 $_itemTime = strtotime(isset($entry[1]['client_mtime']) ? $entry[1]['client_mtime'] : $entry[1]['modified']);
                 $ptimes[$pkey] = isset($ptimes[$pkey]) ? max(array($_itemTime, $ptimes[$pkey])) : $_itemTime;
                 $sql = 'select path from ' . $this->DB_TableName . ' ' . $where . ' limit 1';
                 if (!$reset && $this->query($sql)) {
                     $this->DB->exec('update ' . $this->DB_TableName . ' set dat=' . $this->DB->quote(serialize($entry[1])) . ', isdir=' . ($entry[1]['is_dir'] ? 1 : 0) . ' ' . $where);
                 } else {
                     $this->DB->exec('insert into ' . $this->DB_TableName . ' values (' . $path . ', ' . $fname . ', ' . $this->DB->quote(serialize($entry[1])) . ', ' . (int) $entry[1]['is_dir'] . ')');
                 }
             }
         } while (!empty($_info['has_more']));
         // update time stamp of parent holder
         foreach ($ptimes as $_p => $_t) {
             if ($praw = $this->getDBdat($_p)) {
                 $_update = false;
                 if (isset($praw['client_mtime']) && $_t > strtotime($praw['client_mtime'])) {
                     $praw['client_mtime'] = date('r', $_t);
                     $_update = true;
                 }
                 if (isset($praw['modified']) && $_t > strtotime($praw['modified'])) {
                     $praw['modified'] = date('r', $_t);
                     $_update = true;
                 }
                 if ($_update) {
                     $pwhere = 'where path=' . $this->DB->quote(strtolower($this->_dirname($_p))) . ' and fname=' . $this->DB->quote(strtolower($this->_basename($_p)));
                     $this->DB->exec('update ' . $this->DB_TableName . ' set dat=' . $this->DB->quote(serialize($praw)) . ' ' . $pwhere);
                 }
             }
         }
         $this->DB->exec('update ' . $this->DB_TableName . ' set dat=' . $this->DB->quote(serialize(array('cursor' => $cursor, 'mtime' => $_SERVER['REQUEST_TIME']))) . ' where path=\'\' and fname=\'\'');
         if (!$this->DB->commit()) {
             $e = $this->DB->errorInfo();
             return $e[2];
         }
         if ($delete) {
             $this->DB->exec('vacuum');
         }
     } catch (Dropbox_Exception $e) {
         return $e->getMessage();
     }
     return true;
 }
开发者ID:studio-42,项目名称:elfinder,代码行数:91,代码来源:elFinderVolumeDropbox.class.php


注:本文中的dropbox::delta方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。