Example #1
0
function dir_walk($path = '', $depth = 0)
{
    if ($path == '') {
        $apath = './';
    } else {
        if (substr($path, -1, 1) != '/') {
            $path .= '/';
        }
        $apath = $path;
    }
    $out = array();
    $ds = utf8_encode(str_repeat("� � ", $depth));
    foreach (scandir($apath) as $v) {
        if (substr($v, 0, 1) == '.') {
            continue;
        }
        if (is_dir($apath . $v)) {
            printf("%s+ <b>%s</b><br/>\n", $ds, xml_escape($path . $v));
            dir_walk($path . $v, $depth + 1);
            print "<br/>\n";
        } else {
            if (ext($v) == 'pyc' || $path == '' && $v == 'index.php') {
                continue;
            }
            $out[] = $v;
        }
    }
    foreach ($out as $file) {
        printf("%s<a href=\"?sauce=%s\">%s</a><br/>\n", $ds, urlencode($path . $file), xml_escape($file));
    }
}
function snmpget_smallp($ip, $oid)
{
    $command = "C:\\usr\\bin\\snmpget -Ov -v 1 -c public " . $ip . " " . $oid . " 2>&1";
    $result = shell_exec($command);
    $result = ext($result);
    $result = removeQuotation($result);
    return $result;
}
Example #3
0
    function showdir($df)
    {
        $df = str_replace("//", "/", $df);
        $dirs = array();
        $files = array();
        if ($dir = opendir($df)) {
            while (($file = readdir($dir)) !== false) {
                if ($file == "." || $file == "..") {
                    continue;
                }
                if (is_dir("{$df}/{$file}")) {
                    $dirs[] = $file;
                } else {
                    $files[] = $file;
                }
            }
        }
        closedir($dir);
        sort($dirs);
        sort($files);
        echo <<<EOF
<table width="505" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
EOF;
        for ($i = 0; $i < count($dirs); $i++) {
            $perm = perms("{$df}/{$dirs[$i]}");
            echo <<<EOF
  <tr height="1">
    <td width="1" height="1" align="center" bordercolor="#ECE9D8" bgcolor="#FFFFFF"><span class="style2"><a href="{$PHP_SELF}?d={$df}/{$dirs[$i]}&show"><img HSPACE=3 border=0 src={$PHP_SELF}?imgname=dir></a></span></td>
    <td width="241" bgcolor="#FFFFF0"><a href="{$PHP_SELF}?d={$df}/{$dirs[$i]}&show">{$dirs[$i]}</a></td>
    <td width="100" align="center" bgcolor="#FFFFFF"><a href="{$PHP_SELF}?deldir={$df}/{$dirs[$i]}/">Удалить</a></td>
    <td width="51" align="center" bgcolor="#EFFFFF"><span class="style8"><center>Каталог</center></span></td>
    <td width="113" align="center" bgcolor="#FFFFF0">{$perm}</td>
  </tr>
EOF;
        }
        for ($i = 0; $i < count($files); $i++) {
            $attr = "";
            if (!($fi = @fopen("{$df}/{$files[$i]}", "r+"))) {
                $attr = " ONLY_READ ";
                $read = " href=\"{$PHP_SELF}?edit={$df}/{$files[$i]}&readonly\"";
                $write = " href=\"{$PHP_SELF}?delfile={$df}/{$files[$i]}\"";
            } else {
                fclose($fi);
            }
            if (!($fi = @fopen("{$df}/{$files[$i]}", "r"))) {
                $attr = " Can't_READ ";
                $read = "";
                $write = " href=\"{$PHP_SELF}?delfile={$df}/{$files[$i]}\"";
            } else {
                fclose($fi);
            }
            if ($attr == "") {
                $attr = " READ/WRITE ";
                $read = " href=\"{$PHP_SELF}?edit={$df}/{$files[$i]}\"";
                $write = " href=\"{$PHP_SELF}?delfile={$df}/{$files[$i]}\"";
            }
            $perm = perms("{$df}/{$files[$i]}");
            $it = "file";
            switch (ext($files[$i])) {
                case ".txt":
                    $it = "txt";
                    break;
                case ".php":
                    $it = "txt";
                    break;
                case ".htm":
                    $it = "txt";
                    break;
                case ".log":
                    $it = "txt";
                    break;
                case ".pl":
                    $it = "txt";
                    break;
                case ".asm":
                    $it = "txt";
                    break;
                case ".bat":
                    $it = "txt";
                    break;
                case ".bash_profile":
                    $it = "txt";
                    break;
                case ".bash_history":
                    $it = "txt";
                    break;
                case ".ini":
                    $it = "txt";
                    break;
                case ".php3":
                    $it = "txt";
                    break;
                case ".html":
                    $it = "txt";
                    break;
                case ".cgi":
                    $it = "txt";
                    break;
                case ".inc":
                    $it = "txt";
                    break;
                case ".c":
                    $it = "txt";
                    break;
                case ".cpp":
                    $it = "txt";
                    break;
            }
            $fsize = fsize("{$df}/{$files[$i]}");
            echo <<<EOF
  <tr height="1">
    <td width="1" height="1" align="center" bordercolor="#ECE9D8" bgcolor="#FFFFFF"><span class="style2"><a href="{$PHP_SELF}?downloadfile={$df}/{$files[$i]}"><img HSPACE=3 border=0 src={$PHP_SELF}?imgname={$it}></a></span></td>
    <td width="241" bgcolor="#00FFFF"><a{$read}>{$files[$i]} </a> ({$fsize})</td>
    <td width="100" align="center" bgcolor="#FFFFFF"><a href="{$PHP_SELF}?rename=1&filetorename={$files[$i]}&d={$df}&diz">ren</a>/<a{$write}>del</a>/<a href="{$PHP_SELF}?downloadfile={$df}/{$files[$i]}">get</a>/<a href="{$PHP_SELF}?mailfile={$df}/{$files[$i]}">mail</a></td>
    <td width="51" align="center" bgcolor="#FFEFEF"><span class="style8"><center>{$attr}</center></span></td>
    <td width="113" align="center" bgcolor="#FFFFF9">{$perm}</td>
  </tr>
EOF;
        }
        echo "</table>";
        if (count($dirs) == 0 && count($files) == 0) {
            echo <<<EOF
<table width="505" height="24" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
  <tr>
    <td align="center" bordercolor="#ECE9D8" bgcolor="#FFFFFF">Папка пуста</td>
  </tr>
</table>
EOF;
        }
    }
Example #4
0
 public function path(string $name = null, string $path = null, string $ext = null)
 {
     $result = false;
     if (empty($name) || $name === 'root') {
         $result = $this->root;
     } elseif (isset($this->dirs[$name])) {
         $result = $this->dirs[$name];
     } else {
         $this->dirs[$name] = $result = $this->root . DS . (empty($this->aliases[$name]) ? $name : $this->aliases[$name]);
     }
     if (!empty($path)) {
         if (!empty($ext)) {
             $path = ext($path, $ext);
         }
         $result .= DS . $path;
     }
     if (!KE_IS_WIN) {
         $result = str_replace('\\', '/', $result);
     }
     return $result;
 }
 private function _transfer_file($file, $old_directory, $new_directory, $random_name = false)
 {
     //проверка существования файла
     if (!file_exists($old_directory . DS . $file)) {
         $this->Error->setError('ERROR_103');
     }
     //проверка существования новой директории и ее создание
     if (!file_exists($new_directory)) {
         if (!mkdir($new_directory, 0777)) {
             $this->Error->setError('ERROR_114');
         }
     }
     //перенос файла
     $old_file = $old_directory . DS . $file;
     //переименование файла
     if ($random_name) {
         $filename = substr(md5(time()), 0, 8);
         $ext = ext($file);
         $file = $filename . "." . $ext;
     }
     $new_file = $new_directory . DS . $file;
     if (!copy($old_file, $new_file)) {
         $this->Error->setError('ERROR_113');
         return false;
     } else {
         $this->new_filename = $file;
         unlink($old_file);
         return true;
     }
 }
Example #6
0
							//filename
							$fileOriginalName=0;
							$fileOriginalName=$_FILES['userfile']['name'];
							$fileOriginalName=addslashes($fileOriginalName);
							//temp name
							$tmpName=0;
							$tmpName=$_FILES['userfile']['tmp_name'];
							//size
							$fileSize=0;
							$fileSize=$_FILES['userfile']['size'];
							//type
							$fileType=0;
							$fileType=$_FILES['userfile']['type'];
							//extension
							$extension=0;
							$extension=ext($fileOriginalName);
							//check to ensure this is xls
							if($extension!="jpg" && $extension!="jpeg" && $extension!="gif" && $extension!="png") {
								$error.="<br>Incorrect file extension '.$extension'. Only JPG, JPEG, PNG and GIF images are acceptable";
							}
							if($_FILES['userfile']['size']>$default_maxUploadSize) {
								$error.="<br>File size is greater than the accepted ".number_format((float)$default_maxUploadSize/1000)." KB. Please reduce the size of the file then attempt to upload it again.";
							}
							if(!$error) {
								$system_default_path.="images/signatures/";
								$server_url.="/images/signatures/";
								if(move_uploaded_file($_FILES['userfile']['tmp_name'],$system_default_path."signature.$id.$extension")) {
									//update vl_users
									mysqlquery("update vl_users set 
													signaturePATH='$system_default_path"."signature.$id.$extension',
													signatureURL='$server_url"."signature.$id.$extension' 
Example #7
0
 public function getAssetData(string $name)
 {
     $library = $this->getLibrary($name);
     if (empty($library['version'])) {
         $path = ext("vendor/{$name}", $library['type']);
     } else {
         $path = ext("vendor/{$name}-{$library['version']}", $library['type']);
     }
     return [$path, $library['type']];
 }
Example #8
0
 public function getFileName()
 {
     return ext($this->name, 'phar');
 }
Example #9
0
 /**
  * 基于范围搜索相关的文件,返回这个文件的完整路径,如果搜索不到,则范围false
  *
  * @param string|null $scope
  * @param string      $file
  * @param bool        $isAll
  * @return array|bool|string
  */
 public function seek(string $scope = null, string $file, bool $isAll = false)
 {
     if (empty($file)) {
         return false;
     }
     $scope = $this->filterScope($scope);
     if (!empty($this->extension)) {
         $file = ext($file, $this->extension);
     }
     if (!KE_IS_WIN && strpos($file, KE_DS_CLS) !== false) {
         $file = str_replace(KE_DS_CLS, KE_DS_UNIX, $file);
     }
     $dir = DIRECTORY_SEPARATOR;
     if (!empty($this->scopeRewrites[$scope])) {
         $dir .= $this->scopeRewrites[$scope] . DIRECTORY_SEPARATOR;
     }
     $result = null;
     foreach ($this->getScopeDirs($scope) as $name => $base) {
         if (($base = real_dir($base)) === false) {
             continue;
         }
         if (($path = real_file($base . $dir . $file)) === false) {
             continue;
         }
         if (!$isAll) {
             return $path;
         }
         $result[] = $path;
     }
     return empty($result) ? false : $result;
 }
Example #10
0
 public function makeReferenceTag(string $src, string $type, array $props = null)
 {
     if (!isset($props['buildUri']) || !empty($props['buildUri'])) {
         $src = $this->getBaseUri()->newUri(ext($src, $type));
     }
     $tag = '';
     $attr = '';
     if (!empty($props)) {
         $attr = $this->makeProps($props);
     }
     switch ($type) {
         case 'js':
             $tag = '<script type="text/javascript" src="%s"%s></script>';
             break;
         case 'css':
             if (!isset($props['media']) || $props['media'] === 'screen') {
                 $tag = '<link rel="stylesheet" type="text/css" href="%s" media="screen"%s/>';
             } else {
                 $tag = '<link rel="stylesheet" type="text/css" href="%s"%s/>';
             }
             break;
     }
     return sprintf($tag, $src, $attr);
 }
Example #11
0
 public function loadWikiContent(string $relative)
 {
     $basePath = $this->getWikiDir();
     $exts = ['html', 'markdown', 'md', ''];
     $fileName = pathinfo($relative, PATHINFO_FILENAME);
     if (empty($fileName)) {
         return '';
     }
     foreach ($exts as $ext) {
         $fullPath = $basePath . DS . ext($fileName, $ext);
         if (is_file($fullPath)) {
             return file_get_contents($fullPath);
             break;
         }
     }
     return '';
 }
Example #12
0
function recurse($path, $action)
{
    global $output_ext;
    if (!in_array($action, array('compare', 'generate', 'clean'))) {
        echo "Unknown action: {$action}\n";
        exit(1);
    }
    $files = array();
    if (is_dir($path)) {
        $files = scandir($path);
    } elseif (is_file($path)) {
        $files[] = basename($path);
        $path = dirname($path);
    }
    foreach ($files as $f) {
        if (empty($f) || $f[0] == '.' || preg_match('/~$/', $f)) {
            continue;
        }
        $f = preg_replace('%//+%', '/', $path . '/' . $f);
        if (is_dir($f)) {
            recurse($f, $action);
        } else {
            if ($action === 'clean') {
                clean($f);
                continue;
            }
            $ext = ext($f);
            if (!empty($ext) && $ext !== '.luminous') {
                echo "{$f} ...\n";
                if ($action == 'compare') {
                    compare($f);
                } elseif ($action == 'generate') {
                    generate($f);
                }
            }
        }
    }
}