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


PHP AJXP_Utils::safeBasename方法代码示例

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


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

示例1: rawList

 protected function rawList($link, $serverPath, $target = 'd', $retry = true)
 {
     if ($target == 'f') {
         $parentDir = AJXP_Utils::safeDirname($serverPath);
         $fileName = AJXP_Utils::safeBasename($serverPath);
         ftp_chdir($link, $parentDir);
         $rl_dirlist = @ftp_rawlist($link, "-a .");
         //AJXP_Logger::debug(__CLASS__,__FUNCTION__,"FILE RAWLIST FROM ".$parentDir);
         if (is_array($rl_dirlist)) {
             $escaped = preg_quote($fileName);
             foreach ($rl_dirlist as $rl_index => $rl_entry) {
                 if (preg_match("/ {$escaped}\$/", $rl_entry)) {
                     $contents = array($rl_dirlist[$rl_index]);
                 }
             }
         }
     } else {
         ftp_chdir($link, $serverPath);
         $contents = ftp_rawlist($link, "-a .");
         //AJXP_Logger::debug(__CLASS__,__FUNCTION__,"RAW LIST RESULT ".print_r($contents, true));
     }
     if (!is_array($contents) && !$this->ftpActive) {
         if ($retry == false) {
             return array();
         }
         // We might have timed out, so let's go passive if not done yet
         global $_SESSION;
         if ($_SESSION["ftpPasv"] == "true") {
             return array();
         }
         @ftp_pasv($link, TRUE);
         $_SESSION["ftpPasv"] = "true";
         // RETRY!
         return $this->rawList($link, $serverPath, $target, FALSE);
     }
     if (!is_array($contents)) {
         return array();
     }
     return $contents;
 }
开发者ID:thermalpaste,项目名称:pydio-core,代码行数:40,代码来源:class.ftpAccessWrapper.php

示例2: hideExtension

 /**
  * @param AJXP_Node $ajxpNode
  */
 public function hideExtension(&$ajxpNode)
 {
     if ($ajxpNode->hasExtension("pad")) {
         $baseName = AJXP_Utils::safeBasename($ajxpNode->getPath());
         $ajxpNode->setLabel(str_replace(".pad", "", $baseName));
     }
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:10,代码来源:class.EtherpadClient.php

示例3: getUniquePath

 function getUniquePath()
 {
     return AJXP_Utils::safeBasename(array_keys($this->filters)[0]);
 }
开发者ID:Nanomani,项目名称:pydio-core,代码行数:4,代码来源:class.ContentFilter.php

示例4: switchAction


//.........这里部分代码省略.........
         case "rename":
             $file = AJXP_Utils::decodeSecureMagic($httpVars["file"]);
             $filename_new = AJXP_Utils::decodeSecureMagic($httpVars["filename_new"]);
             $dest = null;
             if (isset($httpVars["dest"])) {
                 $dest = AJXP_Utils::decodeSecureMagic($httpVars["dest"]);
                 $filename_new = "";
             }
             $this->filterUserSelectionToHidden(array($filename_new));
             $this->rename($file, $filename_new, $dest);
             $logMessage = SystemTextEncoding::toUTF8($file) . " {$mess['41']} " . SystemTextEncoding::toUTF8($filename_new);
             //$reloadContextNode = true;
             //$pendingSelection = $filename_new;
             if (!isset($nodesDiffs)) {
                 $nodesDiffs = $this->getNodesDiffArray();
             }
             if ($dest == null) {
                 $dest = AJXP_Utils::safeDirname($file);
             }
             $nodesDiffs["UPDATE"][$file] = new AJXP_Node($this->urlBase . $dest . "/" . $filename_new);
             $this->logInfo("Rename", array("original" => $this->addSlugToPath($file), "new" => $filename_new));
             break;
             //------------------------------------
             //	CREER UN REPERTOIRE / CREATE DIR
             //------------------------------------
         //------------------------------------
         //	CREER UN REPERTOIRE / CREATE DIR
         //------------------------------------
         case "mkdir":
             $messtmp = "";
             if (!isset($httpVars["dirname"])) {
                 $uniq = $selection->getUniqueFile();
                 $dir = AJXP_Utils::safeDirname($uniq);
                 $dirname = AJXP_Utils::safeBasename($uniq);
             } else {
                 $dirname = AJXP_Utils::decodeSecureMagic($httpVars["dirname"], AJXP_SANITIZE_FILENAME);
             }
             $dirname = substr($dirname, 0, ConfService::getCoreConf("NODENAME_MAX_LENGTH"));
             $this->filterUserSelectionToHidden(array($dirname));
             AJXP_Controller::applyHook("node.before_create", array(new AJXP_Node($dir . "/" . $dirname), -2));
             $error = $this->mkDir($dir, $dirname, isset($httpVars["ignore_exists"]) ? true : false);
             if (isset($error)) {
                 throw new AJXP_Exception($error);
             }
             $messtmp .= "{$mess['38']} " . SystemTextEncoding::toUTF8($dirname) . " {$mess['39']} ";
             if ($dir == "") {
                 $messtmp .= "/";
             } else {
                 $messtmp .= SystemTextEncoding::toUTF8($dir);
             }
             $logMessage = $messtmp;
             //$pendingSelection = $dirname;
             //$reloadContextNode = true;
             $newNode = new AJXP_Node($this->urlBase . $dir . "/" . $dirname);
             if (!isset($nodesDiffs)) {
                 $nodesDiffs = $this->getNodesDiffArray();
             }
             array_push($nodesDiffs["ADD"], $newNode);
             $this->logInfo("Create Dir", array("dir" => $this->addSlugToPath($dir) . "/" . $dirname));
             break;
             //------------------------------------
             //	CREER UN FICHIER / CREATE FILE
             //------------------------------------
         //------------------------------------
         //	CREER UN FICHIER / CREATE FILE
         //------------------------------------
开发者ID:biggtfish,项目名称:cms,代码行数:67,代码来源:class.fsAccessDriver.php

示例5: processQuery

 public function processQuery($actionName, &$httpVars, &$fileVars)
 {
     $query_name = AJXP_Utils::sanitize($httpVars["query_name"], AJXP_SANITIZE_ALPHANUM);
     $query = $this->getQuery($query_name);
     if ($query === false) {
         throw new Exception("Cannot find query " . $query_name);
     }
     $pg = $this->sqlDriver["driver"] == "postgre";
     $start = 0;
     $count = 30;
     if (isset($httpVars["start"])) {
         $start = intval($httpVars["start"]);
     }
     if (isset($httpVars["count"])) {
         $count = intval($httpVars["count"]);
     }
     $mess = ConfService::getMessages();
     $format = 'Y-m-d 00:00:00';
     $endFormat = 'Y-m-d 23:59:59';
     $dKeyFormat = $mess["date_relative_date_format"];
     $ref = time();
     $last = $start + $count;
     $startDate = date($format, strtotime("-{$last} day", $ref));
     $endDate = date($endFormat, strtotime("-{$start} day", $ref));
     $dateCursor = "logdate > '{$startDate}' AND logdate <= '{$endDate}'";
     $q = $query["SQL"];
     $q = str_replace("AJXP_CURSOR_DATE", $dateCursor, $q);
     if ($pg) {
         $q = str_replace("ORDER BY logdate DESC", "ORDER BY DATE(logdate) DESC", $q);
     }
     //$q .= " LIMIT $start, $count";
     $res = dibi::query($q);
     $all = $res->fetchAll();
     $allDates = array();
     foreach ($all as $row => &$data) {
         // PG: Recapitalize keys
         if ($pg) {
             foreach ($data as $k => $v) {
                 $data[ucfirst($k)] = $v;
             }
         }
         if (isset($data["Date"])) {
             if (is_a($data["Date"], "DibiDateTime")) {
                 $tStamp = $data["Date"]->getTimestamp();
             } else {
                 $tStamp = strtotime($data["Date"]);
             }
             $key = date($dKeyFormat, $tStamp);
             $data["Date_sortable"] = $tStamp;
             $data["Date"] = $key;
             $allDates[$key] = true;
         }
         if (isset($data["File"])) {
             $data["File"] = AJXP_Utils::safeBasename($data["File"]);
         }
     }
     if (isset($query["AXIS"]) && $query["AXIS"]["x"] == "Date") {
         for ($i = 0; $i < $count; $i++) {
             $dateCurs = $start + $i;
             $timeDate = strtotime("-{$dateCurs} day", $ref);
             $dateK = date($dKeyFormat, $timeDate);
             if (!isset($dKeyFormat[$dateK])) {
                 array_push($all, array("Date" => $dateK, "Date_sortable" => $timeDate));
             }
         }
     }
     if (isset($query["FIGURE"]) && isset($all[0][$query["FIGURE"]])) {
         $f = $all[0][$query["FIGURE"]];
         if ($f > 1000) {
             $f = number_format($f / 1000, 1, ".", " ") . 'K';
         }
         $all[0] = array($query["FIGURE"] => $f);
     }
     //$qry = "SELECT FOUND_ROWS() AS NbRows";
     //$res = dibi::query($qry);
     $total_count = 1000;
     //$res->fetchSingle();
     header('Content-type: application/json');
     $links = array();
     if ($start > $count) {
         $links[] = array('rel' => 'first', 'cursor' => 0, 'count' => $count);
     }
     if ($start > 0) {
         $prev = max(0, $start - $count);
         $links[] = array('rel' => 'previous', 'cursor' => $prev, 'count' => $count);
     }
     if ($start < $total_count) {
         $next = $start + $count;
         $links[] = array('rel' => 'next', 'cursor' => $next, 'count' => $count);
     }
     if ($start < $total_count - $count) {
         $last = $total_count - $total_count % $count;
         //$links[] = array('rel' => 'last', 'cursor' => $last, 'count' => $count);
     }
     $hLinks = array();
     foreach ($links as $link) {
         $hLinks[] = '<http://localhost/api/ajxp_conf/analytic_query/' . $query_name . '/' . $link["cursor"] . '/' . $link["cursor"] . '>; rel="' . $link["rel"] . '"';
     }
     header('Link: ' . implode(",", $hLinks));
     $envelope = array("links" => $links, "data" => $all);
//.........这里部分代码省略.........
开发者ID:projectesIF,项目名称:Ateneu,代码行数:101,代码来源:class.sqlLogDriver.php

示例6: switchAction

 public function switchAction($action, $httpVars, $filesVars)
 {
     $repository = ConfService::getRepository();
     if (!$repository->detectStreamWrapper(true)) {
         return false;
     }
     $selection = new UserSelection($repository, $httpVars);
     $node = $selection->getUniqueNode();
     if ($action == "read_video_data") {
         if (!file_exists($node->getUrl()) || !is_readable($node->getUrl())) {
             throw new Exception("Cannot find file!");
         }
         $this->logDebug("Reading video");
         session_write_close();
         $filesize = filesize($node->getUrl());
         $filename = $node->getUrl();
         $basename = AJXP_Utils::safeBasename($filename);
         //$fp = fopen($destStreamURL.$file, "r");
         if (preg_match("/\\.ogv\$/", $basename)) {
             header("Content-Type: video/ogg; name=\"" . $basename . "\"");
         } else {
             if (preg_match("/\\.mp4\$/", $basename)) {
                 header("Content-Type: video/mp4; name=\"" . $basename . "\"");
             } else {
                 if (preg_match("/\\.m4v\$/", $basename)) {
                     header("Content-Type: video/x-m4v; name=\"" . $basename . "\"");
                 } else {
                     if (preg_match("/\\.webm\$/", $basename)) {
                         header("Content-Type: video/webm; name=\"" . $basename . "\"");
                     }
                 }
             }
         }
         if (isset($_SERVER['HTTP_RANGE']) && $filesize != 0) {
             $this->logDebug("Http range", array($_SERVER['HTTP_RANGE']));
             // multiple ranges, which can become pretty complex, so ignore it for now
             $ranges = explode('=', $_SERVER['HTTP_RANGE']);
             $offsets = explode('-', $ranges[1]);
             $offset = floatval($offsets[0]);
             if ($offset == 0) {
                 $this->logInfo('Preview', 'Streaming content of ' . $filename, array("files" => $filename));
             }
             $length = floatval($offsets[1]) - $offset + 1;
             if (!$length) {
                 $length = $filesize - $offset;
             }
             if ($length + $offset > $filesize || $length < 0) {
                 $length = $filesize - $offset;
             }
             header('HTTP/1.1 206 Partial Content');
             header('Content-Range: bytes ' . $offset . '-' . ($offset + $length - 1) . '/' . $filesize);
             header('Accept-Ranges:bytes');
             header("Content-Length: " . $length);
             $file = fopen($filename, 'rb');
             if (!is_resource($file)) {
                 throw new Exception("Cannot open file {$file}!");
             }
             fseek($file, 0);
             $relOffset = $offset;
             while ($relOffset > 2000000000.0) {
                 // seek to the requested offset, this is 0 if it's not a partial content request
                 fseek($file, 2000000000, SEEK_CUR);
                 $relOffset -= 2000000000;
                 // This works because we never overcome the PHP 32 bit limit
             }
             fseek($file, $relOffset, SEEK_CUR);
             while (ob_get_level()) {
                 ob_end_flush();
             }
             $readSize = 0.0;
             while (!feof($file) && $readSize < $length && connection_status() == 0) {
                 if ($length < 2048) {
                     echo fread($file, $length);
                 } else {
                     echo fread($file, 2048);
                 }
                 $readSize += 2048.0;
                 flush();
             }
             fclose($file);
         } else {
             $this->logInfo('Preview', 'Streaming content of ' . $filename, array("files" => $filename));
             header("Content-Length: " . $filesize);
             header("Content-Range: bytes 0-" . ($filesize - 1) . "/" . $filesize . ";");
             header('Cache-Control: public');
             $stream = fopen("php://output", "a");
             AJXP_MetaStreamWrapper::copyFileInStream($node->getUrl(), $stream);
             fflush($stream);
             fclose($stream);
         }
         AJXP_Controller::applyHook("node.read", array($node));
     } else {
         if ($action == "get_sess_id") {
             HTMLWriter::charsetHeader("text/plain");
             print session_id();
         }
     }
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:98,代码来源:class.VideoReader.php

示例7: processOneQuery

 protected function processOneQuery($queryName, $start, $count, $frequency = "auto", $additionalFilters = array())
 {
     $query = $this->getQuery($queryName);
     if ($query === false) {
         throw new Exception("Cannot find query " . $queryName);
     }
     $pg = $this->sqlDriver["driver"] == "postgre";
     $mess = ConfService::getMessages();
     $format = 'Y-m-d 00:00:00';
     $endFormat = 'Y-m-d 23:59:59';
     $dKeyFormat = $mess["date_relative_date_format"];
     $ref = time();
     $last = $start + $count;
     $startDate = date($format, strtotime("-{$last} day", $ref));
     $endDate = date($endFormat, strtotime("-{$start} day", $ref));
     $dateCursor = "logdate > '{$startDate}' AND logdate <= '{$endDate}'";
     foreach ($additionalFilters as $filterField => $filterValue) {
         $comparator = strpos($filterValue, "%") !== false ? "LIKE" : "=";
         $dateCursor .= " AND [" . AJXP_Utils::sanitize($filterField, AJXP_SANITIZE_ALPHANUM) . "] {$comparator} '" . AJXP_Utils::sanitize($filterValue, AJXP_SANITIZE_EMAILCHARS) . "'";
     }
     $q = $query["SQL"];
     $q = str_replace("AJXP_CURSOR_DATE", $dateCursor, $q);
     if ($pg) {
         $q = str_replace("ORDER BY logdate DESC", "ORDER BY DATE(logdate) DESC", $q);
     }
     //$q .= " LIMIT $start, $count";
     $res = dibi::query($q);
     $all = $res->fetchAll();
     $allDates = array();
     if (isset($query["AXIS"]) && $query["AXIS"]["x"] == "Date") {
         if ($frequency == "auto") {
             if ($count > 70) {
                 $frequency = "month";
             } else {
                 if ($count > 21) {
                     $frequency = "week";
                 }
             }
         }
         $groupedSums = array();
         if ($frequency == "week") {
             $groupByFormat = "W";
         } else {
             if ($frequency == "month") {
                 $groupByFormat = "n";
             }
         }
     }
     foreach ($all as $row => &$data) {
         // PG: Recapitalize keys
         if ($pg) {
             $newData = array();
             foreach ($data as $k => $v) {
                 $newData[ucfirst($k)] = $v;
             }
             $data = $newData;
         }
         if (isset($data["File"])) {
             $data["File"] = AJXP_Utils::safeBasename($data["File"]);
         }
         if (isset($data["Date"])) {
             if (is_a($data["Date"], "DibiDateTime")) {
                 $tStamp = $data["Date"]->getTimestamp();
             } else {
                 $tStamp = strtotime($data["Date"]);
             }
             $key = date($dKeyFormat, $tStamp);
             $data["Date_sortable"] = $tStamp;
             $data["Date"] = $key;
             $allDates[$key] = true;
             if (isset($groupByFormat)) {
                 $newKey = date($groupByFormat, $tStamp);
                 if (!isset($groupedSums[$newKey])) {
                     $groupedSums[$newKey] = $data;
                 } else {
                     $valueKey = $query["AXIS"]["y"];
                     $groupedSums[$newKey][$valueKey] += $data[$valueKey];
                 }
             }
         }
     }
     if (isset($query["AXIS"]) && $query["AXIS"]["x"] == "Date") {
         for ($i = 0; $i < $count; $i++) {
             $dateCurs = $start + $i;
             $timeDate = strtotime("-{$dateCurs} day", $ref);
             $dateK = date($dKeyFormat, $timeDate);
             if (isset($groupByFormat)) {
                 $newKey = date($groupByFormat, $timeDate);
                 if (!isset($groupedSums[$newKey])) {
                     array_push($all, array("Date" => $dateK, "Date_sortable" => $timeDate));
                 }
             } else {
                 if (!isset($allDates[$dateK])) {
                     array_push($all, array("Date" => $dateK, "Date_sortable" => $timeDate));
                 }
             }
         }
     }
     if (isset($query["FIGURE"]) && isset($all[0][$query["FIGURE"]])) {
         $f = $all[0][$query["FIGURE"]];
//.........这里部分代码省略.........
开发者ID:floffel03,项目名称:pydio-core,代码行数:101,代码来源:class.sqlLogDriver.php


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