function searchdir ( $path , $maxdepth = -1 , $mode = "FULL" , $d = 0 ) { if ( substr ( $path , strlen ( $path ) - 1 ) != '/' ) { $path .= '/' ; } $dirlist = array () ; if ( $mode != "FILES" ) { $dirlist[] = $path ; } if ( $handle = opendir ( $path ) ) { while ( false !== ( $file = readdir ( $handle ) ) ) { if ( $file != '.' && $file != '..' ) { $file = $path . $file ; if ( ! is_dir ( $file ) ) { if ( $mode != "DIRS" ) { $dirlist[] = $file ; } } elseif ( $d >=0 && ($d < $maxdepth || $maxdepth < 0) ) { $result = searchdir ( $file . '/' , $maxdepth , $mode , $d + 1 ) ; $dirlist = array_merge ( $dirlist , $result ) ; } } } closedir ( $handle ) ; } if ( $d == 0 ) { natcasesort ( $dirlist ) ; } return ( $dirlist ) ; }
function searchdir($dir_path, $maxdepth = -1, $mode = "FULL", $d = 0) { // $dir_path : path to browse // $maxdepth : how deep to browse (-1=unlimited) // $mode : "FULL"|"DIRS"|"FILES" // $d : must not be defined if (substr($dir_path, strlen($dir_path) - 1) != '/') { $dir_path .= '/'; } $selected_entries = array(); if ($mode != "FILES") { $selected_entries[] = $dir_path; } if ($handle = opendir($dir_path)) { while (false !== ($item_name = readdir($handle))) { if ($item_name != '.' && $item_name != '..') { $item_path = $dir_path . $item_name; if (!is_dir($item_path)) { if ($mode != "DIRS") { $selected_entries[] = $item_path; } } elseif ($d >= 0 && ($d < $maxdepth || $maxdepth < 0)) { $result = searchdir($item_path . '/', $maxdepth, $mode, $d + 1); $selected_entries = array_merge($selected_entries, $result); } } } closedir($handle); } if ($d == 0) { natcasesort($selected_entries); } return $selected_entries; }
do { ++$intCount; $strLine = $arrText[$intCount]; } while ($strLine == ''); // adding the notation to the next command line // $arrNotations[trim($arrText[$intCount])] = $arrNotation; $intCount--; } } } return $arrNotations; } // // scan directory and load our services up // $files = searchdir($dir, -1, "FILES"); foreach ($files as $i => $value) { $right = strrpos($value, '.'); $left = strlen($dir) + 1; $name = substr($value, $left, $right - $left); if (stristr($name, 'Service')) { $tokens = split('_', $name); $str = ''; foreach ($tokens as $t => $token) { $str = $str . strtoupper(substr($token, 0, 1)) . substr($token, 1); } if ($str != '') { $annotations = getFileNotations($value); require_once $value; $instance = new $str(); $methods = get_class_methods($instance);
function rmdirs($dirname) { $dirlist = searchdir($dirname, true); foreach ($dirlist as $d) { $dir = $dirname . DIRECTORY_SEPARATOR . $d; is_dir($dir) ? m_rmdir($dir, true) : unlink($dir); } return true; }
} redirect('?rand=' . rand()); } $page_title = 'Upload'; $content = ' You can upload files up to ' . ini_get('upload_max_filesize') . '. This will be saved en <em>upload</em> folder. To link to your upload file you need to refer as <em>\'upload/filename.ext\'</em>. If you upload an image, it will create two files: <em>\'filename_orig.ext\'</em> and <em>\'filename_thumb.ext\'</em>. <form name="frm" id="frm" action="" method="post" enctype="multipart/form-data"> <label for="file">Upload file</label><input type="file" name="file" id="file" /><br /> <div align="center"><a href="javascript:send();">upload</a> <a href="?rand=' . rand() . '">back</a></div> </form>'; break; case 'manageuploads': $uploads = searchdir('../upload/', '0', 'FILES'); foreach ($uploads as $key => $value) { $rows .= ' <tr style="height: 35px;"> <td><a href="' . $value . '">' . substr($value, strpos($value, '/', 3) + 1) . '</a></td> <td>' . mime_content_type($value) . '</td> <td>' . filesize($value) . '</td> <td>' . date($preferences['date_format'], filemtime($value)) . '</td> <td><a href="?action=deleteupload&file=' . substr($value, strpos($value, '/', 3) + 1) . '">delete</a></td> </tr>'; } $page_title = 'Manage Uploads'; $content = ' <table width="100%" cellpadding="3" cellspacing="3"> <tr style="height: 35px;"> <th scope="col">File</th>
$config['seomode'] = addslashes(trim($_POST['seomode'])); $config['close'] = addslashes(trim($_POST['close'])); $config['template'] = addslashes(trim($_POST['template'])); $config['weektop1'] = trim($weektop1); $config['weektop2'] = trim($weektop2); foreach ($config as $key => $value) { $db->query("REPLACE INTO `{$tablepre}config` (name,value) VALUES('{$key}','{$value}')"); } updatecachefile('config'); refer('更新完成'); } $result = $db->query("SELECT * FROM `{$tablepre}config`"); while ($row = $db->fetch_array($result)) { $config[$row['name']] = $row['value']; } $dir = searchdir(ROOT_PATH . 'templates/'); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <link rel="stylesheet" href="admin.css" type="text/css" media="all" /> </head> <body topmargin="10" leftmargin="10" > <form method="post" name="setting" action="setting.php?edit=yes"> <table class="tableborder2" cellspacing="1" cellpadding="4" width="95%" align="center" > <tr class="head"> <td colspan="2" align="center">基本参数设置</td> </tr> <tr class="b"> <td width="40%"><b>网站名称:</b></td>
function media_transfer() { global $root_dir; global $debug; // directories di origine e destinazione media file $dir_from = realpath(UPLOAD_PATH . $this->set_ha['id_author'] . "/media"); $slash = strrchr($this->set_ha['media_path'], "/"); if (strlen($slash) > 1) { $m_path = $this->set_ha['media_path'] . "/"; } else { $m_path = $this->set_ha['media_path']; } $dir_to = $m_path; if ($debug) { echo "DIRFROM {$dir_from}<br>"; echo "DIRTO {$dir_to}<br>"; } // controlla i file presenti nella directory di destinazione $files_to = searchdir($dir_to); // if (empty($files_to)) die "Directory non esistente<br>"; // intersezione array e rinomina file dell'intersezione $intersect_ar = array_intersect($files_to, $this->dati_media_ar); while (list($key, $val) = each($intersect_ar)) { //$info = stat($dir_to.'/'.$val); rename($dir_to . $val, $dir_to . date("Y_m_d_H_i_s_") . $val); } // copia file nella directory di destinazione for ($i = 0; $i < count($this->dati_media_ar); $i++) { $file_to = $dir_to . $this->dati_media_ar[$i]; $file_from = $dir_from . '/' . $this->dati_media_ar[$i]; if (!stristr($this->dati_media_ar[$i], "http:")) { //echo "Va copiato: $file_from $file_to <br>"; if (!file_exists($file_from) or !copy($file_from, $file_to)) { $this->file_no_copy[] = $this->dati_media_ar[$i]; } } else { //echo "NON va copiato: ".$this->dati_media_ar[$i]."<br>"; } } return "true"; }