public function backupAction() { //数据备份 $total = ceil(dircount() / $this->config->pageNum); // $GLOBALS['config']['pageNum']); $this->view->total = $total; if ($this->request->isPost()) { $this->view->disable(); $post = json_decode(file_get_contents("php://input"), true); if (isset($post['back'])) { databackup(); if (dircount() % $this->config->pageNum == 1) { $total++; } $p = $total; $this->common->syslog("手动备份数据库"); } else { $p = $post['p']; } $file = fileList($p); $i = 0; $filelist = array(); foreach ($file as $v) { if ($i++ < $this->config->pageNum) { $info['filename'] = $v; $info['path'] = $this->config->dataDir . $v; $info['mtime'] = date("Y-m-d H:i:s", filemtime(getcwd() . $info['path'])); array_push($filelist, $info); } } $info = array('total' => $total, 'info' => $filelist); echo json_encode($info); } }
protected function onPrepareThemeAssets() { $src = TH_BASE_DIR . $this->assets->getPathTheme('css/'); $themeCss = TH_BASE_DIR . 'core/ui/themes/' . Service::get(Service::THEME_NAME) . '/assets/css'; $compare = fileList($themeCss); unlinkDifferent($src, $compare); $list = fileList($src); foreach ($list as $file) { $this->assets->requireCss($this->assets->getPathTheme('css/' . $file)); } $src = TH_BASE_DIR . $this->assets->getPathTheme('js/'); $themeJs = TH_BASE_DIR . 'core/ui/themes/' . Service::get(Service::THEME_NAME) . '/assets/js'; $compare = fileList($themeJs); unlinkDifferent($src, $compare); $list = fileList($src); foreach ($list as $file) { $this->assets->requireJs($this->assets->getPathTheme('js/' . $file)); } $themeImg = TH_BASE_DIR . 'core/ui/themes/' . Service::get(Service::THEME_NAME) . '/assets/img'; $compare = fileList($themeImg); unlinkDifferent($src, $compare); }
/** * Clear expired cache files * @return array */ public function clearCache() { $removed = array(); // Get cache files of the VIEW object $view_cache_dir = Exido::config('view.cache_folder'); // Get the cache life time $view_cache_lifetime = Exido::config('view.cache_lifetime'); // Get files list $files = fileList(rtrim($view_cache_dir, '/') . '/e-view', false); // Check each file foreach ($files as $file) { // Get information of the file if ($stat = stat($file)) { // Check if the difference between the current server time and the cache life time // is less then time of last access if (time() - $view_cache_lifetime > $stat['atime']) { @unlink($file); $removed[] = $file; } } } return true; }
<?php $title = '彩虹共享资源列表'; $iswap = true; include "../includes/common.php"; pageTop(); $act = $_GET['act']; if (!$act) { fileList(); } elseif ($act == 'view') { view(); } function fileList() { global $DB; $n = $DB->count("SELECT count(*) from udisk WHERE 1"); echo "<div class='title'>文件列表(共有{$n}个文件)</div>"; global $pagesize; $numrows = $n; $pages = intval($numrows / $pagesize); if ($numrows % $pagesize) { $pages++; } if (isset($_GET['page'])) { $page = intval($_GET['page']); } else { $page = 1; } $offset = $pagesize * ($page - 1); $rs = $DB->query("select * from udisk where hide=0 order by datetime desc limit {$offset},{$pagesize}"); $i = 0;
/** * Returns all the files and directories in a resource path. * @param bool $path * @param bool $recursive * @return array */ function fileList($path = false, $recursive = false) { $files = array(); if ($path === false) { $paths = array_reverse(Exido::getIncludePaths()); foreach ($paths as $path) { // Recursively get and merge all files $files = array_merge($files, fileList($path, $recursive)); } } else { $path = exido_fix_path($path); if (is_readable($path)) { $items = (array) glob($path . '*'); if (!empty($items)) { foreach ($items as $index => $item) { $files[] = $item = exido_fix_path($item); // Handle recursion if (is_dir($item) and $recursive == true) { // Filename should only be the basename $item = pathinfo($item, PATHINFO_BASENAME); // Append sub-directory search $files = array_merge($files, fileList($path . $item, true)); } } } } } return $files; }
function myfilesDispatch($op) { require_once _base_ . '/lib/lib.urlmanager.php'; $url =& UrlManager::getInstance('myfiles'); $url->setStdQuery('modname=myfiles&op=myfiles'); if (isset($_POST['undo'])) { $op = 'myfiles'; } switch ($op) { case "myfiles": fileList($url); break; case "modfiles": modfiles($url); break; case "savefiles": savefiles($url); break; case "delfiles": delfiles($url); break; } }
} else { echo "{$gpio_index}</p></td>"; } } else { $analogLocationResult = $analogLocation . $i; $analogSetting = fopen($analogLocationResult, "r"); $test = fread($analogSetting, 255); echo "{$gpio_index} {$test}</p></td>"; } echo "<td bgcolor=white>"; // 출력일 경우 if ($config_index == 1) { // GPIO 상태가 HIGH 인 경우 if ($gpio_index == 1) { echo "<p align = center><a href = 'control.php?power=off&number={$i}'>OFF</a></p>"; } else { echo "<p align = center><a href = 'control.php?power=on&number={$i}'>ON</a></p>"; } } else { if ($config_index == 4) { echo "<p align = center><a href = 'modify_pwm.php?condition=sub&number={$i}'>Decrease</a> <a href = 'modify_pwm.php?condition=plus&number={$i}'>Increase</a></p>"; } } echo "</td></tr>"; $i++; } echo "</table>"; echo "<p align = center>"; fileList("/usr/local/apache/htdocs/project_os/DB/web_variable", 330); echo "</body>"; echo "<meta http-equiv = 'Refresh' content=5; URL=test.php'>";
<!DOCTYPE html> <html> <head><title>Task 5</title></head> <body> <form action="" method="post"> <p>Название директории</p> <input type="text" required name="dirName"><br> <p>Искомое слово</p> <input type="text" required name="word"> <input type="submit" name="submit"> </form> <?php if (isset($_POST['submit'])) { fileList($_POST['dirName'], $_POST['word']); } ?> </body> </html> <?php function fileList($dirName, $word) { $dirPath = __DIR__ . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR; $word = mb_strtolower($word); if (is_dir($dirPath)) { $dirArr = scandir($dirPath); foreach ($dirArr as $k => $v) { if (is_file($dirPath . $dirArr[$k])) { $text = mb_strtolower(file_get_contents($dirPath . $dirArr[$k])); if (mb_substr_count($text, $word)) { echo $v . "<br>"; }
function collectGarbage($db) { //$msg = ""; //Pids abschiessen, welche nicht laufen dürfen $sql = "SELECT pid FROM snipe WHERE status = 0"; $snipePids = $db->get_col($sql); $pids = getPids(); if (!empty($pids)) { foreach ($pids as $pid) { if (!in_Array($pid, $snipePids)) { $msg = $msg . "Prozess " . $pid . " wurde beendet"; exec("kill -15 " . getEsniperPid($pid)); } } } //Logs löschen, von Snipes, welche nicht in der Datenbank sind $dateien = fileList(TMP_FOLDER); if (!empty($dateien)) { foreach ($dateien as $datei) { $artnrDatei = explode(".", $datei); $sql = "SELECT artnr FROM snipe WHERE artnr = \"" . $artnrDatei[0] . "\""; $snipeArtnr = $db->get_var($sql); if (empty($snipeArtnr)) { exec("rm \"" . TMP_FOLDER . "/" . $artnrDatei . "\""); } } } $sql = "SELECT artnr FROM snipe"; $snipeArtnr = $db->get_col($sql); if (!empty($snipeArtnr)) { foreach ($snipeArtnr as $artnr) { statusPruefen($artnr, $db); } } return $msg; }
echo "{$gpio_index}</p></td>"; } } else { $analogLocationResult = $analogLocation . $i; $analogSetting = fopen($analogLocationResult, "r"); $test = fread($analogSetting, 255); echo "{$gpio_index} {$test}</p></td>"; } echo "<td bgcolor=white>"; // 출력일 경우 if ($config_index == 1) { // GPIO 상태가 HIGH 인 경우 if ($gpio_index == 1) { echo "<p align = center><a href = 'control.php?power=off&number={$i}'>OFF</a></p>"; } else { echo "<p align = center><a href = 'control.php?power=on&number={$i}'>ON</a></p>"; } } else { if ($config_index == 4) { echo "<p align = center><a href = 'modify_pwm.php?condition=sub&number={$i}'>Decrease</a> <a href = 'modify_pwm.php?condition=plus&number={$i}'>Increase</a></p>"; } } echo "</td></tr>"; $i++; } echo "</table>"; echo "<p align = center>"; // GroupControl 표를 읽어온다. fileList("/var/www/project_os/DB/web_variable", 800); echo "</body>"; echo "<meta http-equiv = 'Refresh' content={$refreshTimeResult}; URL=test.php'>";
<!DOCTYPE html> <html> <head><title>Task 4</title></head> <body> <form action="" method="post"> <input type="text" required name="dirName"> <input type="submit" name="submit"> </form> <?php if (isset($_POST['submit'])) { fileList($_POST['dirName']); } ?> </body> </html> <?php function fileList($dirName) { $dirPath = __DIR__ . DIRECTORY_SEPARATOR . $dirName . DIRECTORY_SEPARATOR; if (is_dir($dirPath)) { $dirArr = scandir($dirPath); foreach ($dirArr as $k => $v) { if (is_file($dirPath . $dirArr[$k])) { echo $v . "<br>"; } } } }
require_once 'die.php'; exit(0); } $start = 0; if (isset($_POST['start'])) { $start = $_POST['start']; } require_once 'functions.php'; ?> <!DOCTYPE HTML> <html> <?php require_once 'header.php'; ?> <body> <div class="file-container" id="file-container"> <?php operateHtml($path); ?> <?php crumbHtml($path); ?> <?php fileList($path, $start, $pageLimit); ?> </div> <!-- <input type="file" id="file_upload" name="file_upload" /> --> <script type="text/javascript" src="js/fm.js"></script> </body> </html>
// and augment the breadcrumb trail and other template variables: $preview_checkcode = $ccms['preview'] == 'Y' ? GenerateNewPreviewCode(null, $pageID) : false; $ccms['previewcode'] = $preview_checkcode; $preview_qry = $preview_checkcode ? '?preview=' . $preview_checkcode : ''; $ccms['breadcrumb'][] = '<a href="' . $cfg['rootdir'] . $ccms['page_name'] . '/' . $album . '.html' . $preview_qry . '" title="' . $ccms['lang']['album']['album'] . ' ' . ucfirst($album) . '">' . $ccms['lang']['album']['album'] . ' ' . ucfirst($album) . '</a>'; $ccms['urlpage'] = $ccms['page_name'] . '/' . $album; $ccms['complete_page_url'] = $ccms['urlpage'] . '.html'; $ccms['pagetitle'] .= ' : ' . $ccms['lang']['album']['album'] . ' ' . ucfirst($album); //$ccms['subheader'] = $row->subheader; $ccms['desc'] = $desc; //$ccms['keywords'] = $row->keywords; $ccms['title'] = ucfirst($ccms['pagetitle']) . " - " . $ccms['sitename'] . " | " . $ccms['subheader']; } echo '<div class="lightbox-description">' . $desc . "</div>\n"; // Get the images in an album $images = fileList($album_path . '/' . $album); // If album is not empty and thumbnail is found if (count($images) > 0) { foreach ($images as $content) { $caption = substr($content, 0, strrpos($content, '.')); $caption = ucfirst(str_replace('_', ' ', $caption)); // If album is not empty and thumbnail is found $show_thumb = 0; $thumb_path = $album_path . '/' . $album . '/_thumbs/' . $content; $img_path = $album_path . '/' . $album . '/' . $content; $imginfo = calc_thumb_padding($img_path, $thumb_path); if (is_array($imginfo)) { $show_thumb = $imginfo['show']; } switch ($show_thumb) { case 1:
function main1() { global $key0; $act = $_REQUEST['act']; $key = $_REQUEST['key']; if ($key == $key0) { if ($act == '查看列表') { fileList(); } elseif ($act == 'read') { read(); } elseif ($act == 'del1') { delete1(); } elseif ($act == 'del2') { delete2(); } } else { echo '管理密码错误!'; } }
<tr> <td align="right"><span onMouseOver="document.getElementById('save_info').style.display='block'" onMouseOut="document.getElementById('save_info').style.display='none'" style="cursor:help">Save Info</span> : </td><td><input type="checkbox" id="mtn_N" name="mtn_N" value="true" />On</td> </tr> <tr> <td align="right">Video Info : </td><td><input name="mtn_i" type="checkbox" id="mtn_i" value="true" />On <select id="mtn_Ts" name="mtn_Ts"><option value="8">8</option> <option value="9">9</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</option></select> Size <input class="color" id="mtn_Tc" name="mtn_Tc" size="7" /> Color <?php $exts = array('.ttf', '.otf'); $fonts = array(); $fonts = fileList('mtn/font/'); echo '<select id="mtn_f" name="mtn_f">'; reset($fonts); while (key($fonts) !== NULL) { echo '<option value="' . current($fonts) . '"' . '>' . substr(current($fonts), 0, -4) . '</option>'; next($fonts); } echo '</select>'; ?> Font</td> </tr> <tr> <td align="right">Time : </td><td><input type="checkbox" id="mtn_t" name="mtn_t" value="true" />On <input class="color" id="mtn_tc" name="mtn_tc" size="7" /> Color <input class="color" id="mtn_ts" name="mtn_ts" size="7" /> Shadow</td> </tr>
<hr /> <?php if ($perm->is_level_okay('manageModLightbox', $_SESSION['ccms_userLevel']) && count($albums) > 0) { ?> <button type="submit" onclick="return confirmation_delete();" name="deleteAlbum"><span class="ss_sprite_16 ss_bin_empty"> </span><?php echo $ccms['lang']['backend']['delete']; ?> </button> <?php } ?> </form> <?php } else { // Load all images $images = fileList($album_path); $imagethumbs = array(); $imginfo = array(); if (count($images) > 0) { foreach ($images as $index => $file) { $imagethumbs[$index] = '../../../media/albums/' . $album . '/_thumbs/' . $file; $thumb_path = $album_path . '/_thumbs/' . $file; $img_path = $album_path . '/' . $file; $imginfo[$index] = calc_thumb_padding($img_path, $thumb_path); } } ?> <h2><?php echo $ccms['lang']['album']['manage']; ?> </h2>
function fileList($dir = NULL, $ext = '*', $exc = NULL) { static $allfiles; $filemask = "*.{$ext}"; $files = glob($dir . $filemask); if (count($files) > 0) { foreach ($files as $file) { $ext_file = explode('.', basename($file)); if ($ext_file[1] != $exc) { $allfiles[] = $file; } } } $dirs = glob($dir . '*', GLOB_ONLYDIR); if (count($dirs) > 0) { foreach ($dirs as $dirname) { fileList($dirname . '/', $ext, $exc); } } return $allfiles; }