/**
  * Return the filesystem absolute path for the relative or absolute URI path.
  *
  * Takes the ['Aliases'] mapping array into account; it is processed from top to bottom a la mod_alias.
  *
  * Note: as it uses normalize(), any illegal path will throw an FileManagerException
  *
  * Returns a fully normalized filesystem absolute path.
  */
 public function url_path2file_path($url_path)
 {
     $url_path = $this->rel2abs_url_path($url_path);
     $replaced_some = false;
     if (is_array($this->options['Aliases'])) {
         $alias_arr = $this->options['Aliases'];
         foreach ($alias_arr as $a_url => $a_path) {
             // if the uri path matches us (or at least our start), then apply the mapping.
             // Make sure to only match entire path elements:
             if (FileManagerUtility::startsWith($url_path . '/', $a_url . '/')) {
                 $url_path = $a_path . substr($url_path, strlen($a_url));
                 $replaced_some = true;
             }
         }
     }
     if (!$replaced_some) {
         $url_path = parent::url_path2file_path($url_path);
     }
     return $url_path;
 }
示例#2
0
 protected function getAllowedMimeTypes()
 {
     $filter = $this->options['filter'];
     if (!$filter) {
         return null;
     }
     if (!FileManagerUtility::endsWith($filter, '/')) {
         return array($filter);
     }
     static $mimes;
     if (!$mimes) {
         $mimes = parse_ini_file($this->options['mimeTypesPath']);
     }
     foreach ($mimes as $mime) {
         if (FileManagerUtility::startsWith($mime, $filter)) {
             $mimeTypes[] = strtolower($mime);
         }
     }
     return $mimeTypes;
 }
$trim_extra = '-_,~@+#&';
?>
<h3>pagetitle(str, NULL, '<?php 
echo $re_extra;
?>
', '<?php 
echo $trim_extra;
?>
')</h3>

<?php 
$test = array(array('src' => '.htaccess', 'expect' => 'htaccess'), array('src' => 'regular.jpg', 'expect' => 'regular.jpg'), array('src' => 'Umgebung Altstadt Østgat', 'expect' => 'Umgebung Altstadt Ostgat'), array('src' => '  Sed ut perspiciatis unde omnis iste natus error ', 'expect' => 'Sed ut perspiciatis unde omnis iste natus error'), array('src' => '  advantage from it? But who has any right  ', 'expect' => 'advantage from it_ But who has any right'), array('src' => 'welche aus geistiger Schwäche, d.h.', 'expect' => 'welche aus geistiger Schwaeche, d.h'), array('src' => 'München - Ausrüstung - Spaß - Viele Grüße!', 'expect' => 'Muenchen - Ausruestung - Spass - Viele Gruesse!'), array('src' => 'C:\\Windows\\TEMP\\', 'expect' => 'C_Windows_TEMP'), array('src' => '/etc/passwd', 'expect' => 'etc_passwd'), array('src' => 'Let\'s see what " quotes do?', 'expect' => 'Let_s see what _ quotes do'), array('src' => '中国出售的软件必须使用编码 新 和 湖南北部 父母通常都会对子女说地方方言 现在香港的日常使用中出现了越来越多的简体汉字 华语, 走 贵州 看不懂 清浊声', 'expect' => ''), array('src' => 'également appelé lorem ipsum', 'expect' => 'egalement appele lorem ipsum'), array('src' => 'łaciński tekst pochodzący ze starożytności, zaczerpnięty', 'expect' => 'aci_ski tekst pochodz_cy ze staro_ytno_ci, zaczerpni_ty'), array('src' => 'Ipsum текст Lorem, которые, как правило, бессмысленный список полу-латинские слова', 'expect' => 'Ipsum _ Lorem'), array('src' => 'اول دو واژه از رشته ای از متن لاتین مورد استفاده در طراحی وب سایت و چاپ به جای انگلیسی به استرس و با تکیه تلفظ کردن اهمیت', 'expect' => ''), array('src' => '설명하는 그래픽 등의 요소의 시각적 프레 젠 테이션, 문서 또는 글꼴 , 활판 인쇄술 , 그리고 레이아웃 . 의 세미 라틴어', 'expect' => ''), array('src' => 'פילער טעקסט) צו באַווייַזן די גראַפיק עלעמענטן פון אַ דאָקומענט אָדער וויסואַל פּרעזענטירונג, אַזאַ ווי שריפֿט , טאַפּאַגראַפי', 'expect' => ')'), array('src' => 'χρησιμοποιούνται κείμενο κράτησης θέσης (κείμενο πλήρωσης), για να αποδειχθεί η γραφικά στοιχεία', 'expect' => '(_ _)'), array('src' => 'ルダテキスト (フィラーテキスト)示すために、グラフィックなどの要素を指定するの視覚的なプレゼンテーション、', 'expect' => ''), array('src' => 'SQL: \'\'; DROP TABLE; \'', 'expect' => 'SQL_ _ DROP TABLE'), array('src' => '<script>alert(\'boom!\');</script>', 'expect' => 'script_alert(_boom!_)_script'), array('src' => '%20%2F%41%39 &amp; X?', 'expect' => '20_2F_41_39 _amp_ X'), array('src' => 'https://127893215784/xyz', 'expect' => 'https_127893215784_xyz'));
foreach ($test as $tc) {
    $t = $tc['src'];
    $e = $tc['expect'];
    $r = FileManagerUtility::pagetitle($t, null, $re_extra, $trim_extra);
    echo "\n<pre>ORIG: [" . htmlentities($t, ENT_NOQUOTES, 'UTF-8') . "]\nRES:  [" . htmlentities($r, ENT_NOQUOTES, 'UTF-8') . "]</pre>\n";
    if (strcmp($e, $r) != 0) {
        echo "<p><strong>FAILED!</strong></p>\n";
    }
    echo "\n<hr />\n";
}
?>


<h3>getSiteRoot</h3>

<p>$_SERVER['DOCUMENT_ROOT'] = '<?php 
echo $_SERVER['DOCUMENT_ROOT'];
?>
'</p>
示例#4
0
 public static function table_var_dump(&$variable, $wrap_in_td = false, $show_types = false, $level = 0)
 {
     $returnstring = '';
     if (is_array($variable)) {
         $returnstring .= $wrap_in_td ? '' : '';
         $returnstring .= '<ul class="dump_array dump_level_' . sprintf('%02u', $level) . '">';
         foreach ($variable as $key => &$value) {
             // Assign an extra class representing the (rounded) width in number of characters 'or more':
             // You can use this as a width approximation in pixels to style (very) wide items. It saves
             // a long run through all the nodes in JS, just to measure the actual width and correct any
             // overlap occurring in there.
             $keylen = strlen($key);
             $threshold = 10;
             $overlarge_key_class = '';
             while ($keylen >= $threshold) {
                 $overlarge_key_class .= ' overlarger' . sprintf('%04d', $threshold);
                 $threshold *= 1.6;
             }
             $returnstring .= '<li><span class="key' . $overlarge_key_class . '">' . $key . '</span>';
             $tstring = '';
             if ($show_types) {
                 $tstring = '<span class="type">' . gettype($value);
                 if (is_array($value)) {
                     $tstring .= '&nbsp;(' . count($value) . ')';
                 } elseif (is_string($value)) {
                     $tstring .= '&nbsp;(' . strlen($value) . ')';
                 }
                 $tstring = '</span>';
             }
             switch ((string) $key) {
                 case 'filesize':
                     $returnstring .= '<span class="dump_seconds">' . $tstring . self::fmt_bytecount($value) . ($value >= 1024 ? ' (' . $value . ' bytes)' : '') . '</span></li>';
                     continue 2;
                 case 'playtime seconds':
                     $returnstring .= '<span class="dump_seconds">' . $tstring . number_format($value, 1) . ' s</span></li>';
                     continue 2;
                 case 'compression ratio':
                     $returnstring .= '<span class="dump_compression_ratio">' . $tstring . number_format($value * 100, 1) . '%</span></li>';
                     continue 2;
                 case 'bitrate':
                 case 'bit rate':
                 case 'avg bit rate':
                 case 'max bit rate':
                 case 'max bitrate':
                 case 'sample rate':
                 case 'sample rate2':
                 case 'samples per sec':
                 case 'avg bytes per sec':
                     $returnstring .= '<span class="dump_rate">' . $tstring . self::fmt_bytecount($value) . '/s</span></li>';
                     continue 2;
                 case 'bytes per minute':
                     $returnstring .= '<span class="dump_rate">' . $tstring . self::fmt_bytecount($value) . '/min</span></li>';
                     continue 2;
             }
             $returnstring .= FileManagerUtility::table_var_dump($value, true, $show_types, $level + 1) . '</li>';
         }
         $returnstring .= '</ul>';
         $returnstring .= $wrap_in_td ? '' : '';
     } else {
         if (is_bool($variable)) {
             $returnstring .= ($wrap_in_td ? '<span class="dump_boolean">' : '') . ($variable ? 'TRUE' : 'FALSE') . ($wrap_in_td ? '</span>' : '');
         } else {
             if (is_int($variable)) {
                 $returnstring .= ($wrap_in_td ? '<span class="dump_integer">' : '') . $variable . ($wrap_in_td ? '</span>' : '');
             } else {
                 if (is_float($variable)) {
                     $returnstring .= ($wrap_in_td ? '<span class="dump_double">' : '') . $variable . ($wrap_in_td ? '</span>' : '');
                 } else {
                     if (is_object($variable) && isset($variable->id3_procsupport_obj)) {
                         if (isset($variable->metadata) && isset($variable->imagedata)) {
                             // an embedded image (MP3 et al)
                             $returnstring .= $wrap_in_td ? '<div class="dump_embedded_image">' : '';
                             $returnstring .= '<table class="dump_image">';
                             $returnstring .= '<tr><td><b>type</b></td><td>' . getid3_lib::ImageTypesLookup($variable->metadata[2]) . '</td></tr>';
                             $returnstring .= '<tr><td><b>width</b></td><td>' . number_format($variable->metadata[0]) . ' px</td></tr>';
                             $returnstring .= '<tr><td><b>height</b></td><td>' . number_format($variable->metadata[1]) . ' px</td></tr>';
                             $returnstring .= '<tr><td><b>size</b></td><td>' . number_format(strlen($variable->imagedata)) . ' bytes</td></tr></table>';
                             $returnstring .= '<img src="data:' . $variable->metadata['mime'] . ';base64,' . base64_encode($variable->imagedata) . '" width="' . $variable->metadata[0] . '" height="' . $variable->metadata[1] . '">';
                             $returnstring .= $wrap_in_td ? '</div>' : '';
                         } else {
                             if (isset($variable->binarydata_mode)) {
                                 $returnstring .= $wrap_in_td ? '<span class="dump_binary_data">' : '';
                                 if ($variable->binarydata_mode == 'procd') {
                                     $returnstring .= '<i>' . self::table_var_dump($variable->binarydata, false, false, $level + 1) . '</i>';
                                 } else {
                                     $temp = unpack('H*', $variable->binarydata);
                                     $temp = str_split($temp[1], 8);
                                     $returnstring .= '<i>' . self::table_var_dump(implode(' ', $temp), false, false, $level + 1) . '</i>';
                                 }
                                 $returnstring .= $wrap_in_td ? '</span>' : '';
                             } else {
                                 $returnstring .= ($wrap_in_td ? '<span class="dump_object">' : '') . print_r($variable, true) . ($wrap_in_td ? '</span>' : '');
                             }
                         }
                     } else {
                         if (is_object($variable)) {
                             $returnstring .= ($wrap_in_td ? '<span class="dump_object">' : '') . print_r($variable, true) . ($wrap_in_td ? '</span>' : '');
                         } else {
                             if (is_null($variable)) {
                                 $returnstring .= ($wrap_in_td ? '<span class="dump_null">' : '') . '(null)' . ($wrap_in_td ? '</span>' : '');
                             } else {
                                 if (is_string($variable)) {
                                     $variable = strtr($variable, "", ' ');
                                     $varlen = strlen($variable);
                                     for ($i = 0; $i < $varlen; $i++) {
                                         $returnstring .= htmlentities($variable[$i], ENT_QUOTES, 'UTF-8');
                                     }
                                     $returnstring = ($wrap_in_td ? '<span class="dump_string">' : '') . nl2br($returnstring) . ($wrap_in_td ? '</span>' : '');
                                 } else {
                                     $returnstring .= ($wrap_in_td ? '<span class="dump_other">' : '') . nl2br(htmlspecialchars(strtr($variable, "", ' '))) . ($wrap_in_td ? '</span>' : '');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $returnstring;
 }
示例#5
0
 public static function getRealPath($path)
 {
     $path = str_replace('\\', '/', $path);
     $path = preg_replace('#/+#', '/', $path);
     $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $path);
     $path = FileManagerUtility::startsWith($path, '/') ? $_SERVER['DOCUMENT_ROOT'] . $path : $path;
     $path = FileManagerUtility::startsWith($path, '../') || !FileManagerUtility::startsWith($path, '/') ? realPath($path) : $path;
     $path = str_replace('\\', '/', $path);
     $path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $path);
     $path = FileManagerUtility::endsWith($path, '/') ? $path : $path . '/';
     return $path;
 }
示例#6
0
 public function getAllowedMimeTypes($mime_filter = null)
 {
     $mimeTypes = array();
     if (empty($mime_filter)) {
         return null;
     }
     $mset = explode(',', $mime_filter);
     for ($i = count($mset) - 1; $i >= 0; $i--) {
         if (strpos($mset[$i], '/') === false) {
             $mset[$i] .= '/';
         }
     }
     $mimes = $this->getMimeTypeDefinitions();
     foreach ($mimes as $mime) {
         foreach ($mset as $filter) {
             if (FileManagerUtility::startsWith($mime, $filter)) {
                 $mimeTypes[] = $mime;
             }
         }
     }
     return $mimeTypes;
 }