function getSongListing() { $trackNo = 0; $contents = getDirContents('/public/media/music'); $musicPath = "/public/media/music"; $songListing = array(); foreach (getDirContents($musicPath) as $contents) { $urlStart = strlen($musicPath) + 1; $rawurl = rawurlencode($contents); if (isFile($rawurl)) { // Artist $path = substr($contents, $urlStart); $artist = substr($path, 0, strpos($path, "/")); // Album $path = substr($path, strpos($path, "/") + 1, strlen($path)); $album = substr($path, 0, strpos($path, "/")); // Title $path = substr($path, strpos($path, "/") + 1, strlen($path)); $title = substr($path, 0, strpos($path, ".mp3")); //echo "Artist: " . $artist . "<br>"; //echo "Album: " . $album . "<br>"; //echo "Title: " . $title . "<br>"; // Url $url = str_replace("%2F", "/", $rawurl); //echo "<a href=\"..$url\">$url</a>" . "<br><br>"; $song = array("trackNo" => $trackNo, "artist" => $artist, "album" => $album, "title" => $title, "url" => $url); $trackNo++; //add song to song listing array_push($songListing, $song); } } return $songListing; }
public function testFilesystem() { isFileEq(__FILE__, __FILE__); is(openFile(__FILE__), openFile(__FILE__)); isFile(__FILE__); isDir(__DIR__); isNotFile(__DIR__); isNotFile(__FILE__ . '.qwerty'); isNotDir(__FILE__); isNotDir(__DIR__ . '/qwerty'); }
function nm_get_languages() { $languages = array(); $files = getFiles(NMLANGPATH); foreach ($files as $file) { if (isFile($file, NMLANGPATH, 'php')) { $lang = basename($file, '.php'); $languages[$lang] = NMLANGPATH . $file; } } ksort($languages); return $languages; }
public static function generateSitemapWithoutPing() { global $SITEURL; $filenames = getFiles(GSDATAPAGESPATH); if (count($filenames)) { foreach ($filenames as $file) { if (isFile($file, GSDATAPAGESPATH, 'xml')) { $data = getXML(GSDATAPAGESPATH . $file); if ($data->url != '404' && $data->private != 'Y') { $pagesArray[] = array('url' => (string) $data->url, 'parent' => (string) $data->parent, 'date' => (string) $data->pubDate, 'menuStatus' => (string) $data->menuStatus); } } } } $pagesSorted = subval_sort($pagesArray, 'menuStatus'); $languages = return_i18n_available_languages(); $deflang = return_i18n_default_language(); $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>'); $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance'); $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); if (count($pagesSorted)) { foreach ($pagesSorted as $page) { // set <loc> if (count($languages) > 1) { $pos = strrpos($page['url'], '_'); if ($pos !== false) { $pageLoc = find_i18n_url(substr($page['url'], 0, $pos), $page['parent'], substr($page['url'], $pos + 1)); } else { $pageLoc = find_i18n_url($page['url'], $page['parent'], $deflang); } } else { $pageLoc = find_i18n_url($page['url'], $page['parent']); } // set <lastmod> $pageLastMod = makeIso8601TimeStamp(date("Y-m-d H:i:s", strtotime($page['date']))); // set <changefreq> $pageChangeFreq = 'weekly'; // set <priority> $pagePriority = $page['menuStatus'] == 'Y' ? '1.0' : '0.5'; //add to sitemap $url_item = $xml->addChild('url'); $url_item->addChild('loc', htmlspecialchars($pageLoc)); $url_item->addChild('lastmod', $pageLastMod); $url_item->addChild('changefreq', $pageChangeFreq); $url_item->addChild('priority', $pagePriority); } } //create xml file $file = GSROOTPATH . 'sitemap.xml'; XMLsave($xml, $file); }
function bm_get_cache_data() { $books = array(); $files = getFiles(BMBOOKPATH); # collect all book data foreach ($files as $file) { if (isFile($file, BMBOOKPATH, 'xml')) { $data = getXML(BMBOOKPATH . $file); $time = strtotime($data->date); while (array_key_exists($time, $books)) { $time++; } $books[$time]['slug'] = basename($file, '.xml'); $books[$time]['title'] = strval($data->title); $books[$time]['date'] = strval($data->date); $books[$time]['tags'] = strval($data->tags); $books[$time]['private'] = strval($data->private); } } krsort($books); return $books; }
function nm_get_cache_data() { $posts = array(); $files = getFiles(NMPOSTPATH); # collect all post data foreach ($files as $file) { if (isFile($file, NMPOSTPATH, 'xml')) { $data = getXML(NMPOSTPATH . $file); $time = strtotime($data->date); while (array_key_exists($time, $posts)) { $time++; } $posts[$time]['slug'] = basename($file, '.xml'); $posts[$time]['title'] = strval($data->title); $posts[$time]['date'] = strval($data->date); $posts[$time]['tags'] = strval($data->tags); $posts[$time]['private'] = strval($data->private); $posts[$time]['image'] = strval($data->image); $posts[$time]['author'] = strval($data->author); } } krsort($posts); return $posts; }
/** * Creates Sitemap * * Creates sitemap.xml in the site's root. * Pending: read the content path (xml's) */ function generate_sitemap() { // Variable settings global $SITEURL; $path = GSDATAPAGESPATH; $count = "0"; $filenames = getFiles($path); if (count($filenames) != 0) { foreach ($filenames as $file) { if (isFile($file, $path, 'xml')) { $data = getXML($path . $file); if ($data->url != '404') { $status = $data->menuStatus; $pagesArray[$count]['url'] = $data->url; $pagesArray[$count]['parent'] = $data->parent; $pagesArray[$count]['date'] = $data->pubDate; $pagesArray[$count]['private'] = $data->private; $pagesArray[$count]['menuStatus'] = $data->menuStatus; $count++; } } } } $pagesSorted = subval_sort($pagesArray, 'menuStatus'); if (count($pagesSorted) != 0) { $xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>'); $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance'); $xml->addAttribute('xmlns', 'http://www.sitemaps.org/schemas/sitemap/0.9'); foreach ($pagesSorted as $page) { if ($page['private'] != 'Y') { // set <loc> $pageLoc = find_url($page['url'], $page['parent']); // set <lastmod> $tmpDate = date("Y-m-d H:i:s", strtotime($page['date'])); $pageLastMod = makeIso8601TimeStamp($tmpDate); // set <changefreq> $pageChangeFreq = 'weekly'; // set <priority> if ($page['menuStatus'] == 'Y') { $pagePriority = '1.0'; } else { $pagePriority = '0.5'; } //add to sitemap $url_item = $xml->addChild('url'); $url_item->addChild('loc', $pageLoc); $url_item->addChild('lastmod', $pageLastMod); $url_item->addChild('changefreq', $pageChangeFreq); $url_item->addChild('priority', $pagePriority); exec_action('sitemap-additem'); } } //create xml file $file = GSROOTPATH . 'sitemap.xml'; exec_action('save-sitemap'); XMLsave($xml, $file); } if (!defined('GSDONOTPING')) { if (file_exists(GSROOTPATH . 'sitemap.xml')) { if (200 === ($status = pingGoogleSitemaps($SITEURL . 'sitemap.xml'))) { #sitemap successfully created & pinged return true; } else { error_log(i18n_r('SITEMAP_ERRORPING')); return i18n_r('SITEMAP_ERRORPING'); } } else { error_log(i18n_r('SITEMAP_ERROR')); return i18n_r('SITEMAP_ERROR'); } } else { #sitemap successfully created - did not ping return true; } }
echo '<tr><td>/data/other/' . $file . '</td><td>' . valid_xml($path . $file) . '</td></tr>'; } } $path = GSDATAOTHERPATH . 'logs/'; $data = getFiles($path); sort($data); foreach ($data as $file) { if (isFile($file, $path, '.log')) { echo '<tr><td>/data/other/logs/' . $file . '</td><td>' . valid_xml($path . $file) . '</td></tr>'; } } $path = GSUSERSPATH; $data = getFiles($path); sort($data); foreach ($data as $file) { if (isFile($file, $path)) { echo '<tr><td>/backups/users/' . $file . '</td><td>' . valid_xml($path . $file) . '</td></tr>'; } } ?> </table> <h3><?php i18n('DIR_PERMISSIONS'); ?> </h3> <table class="highlight healthcheck"> <?php $me = check_perms(GSDATAOTHERPATH . 'plugins.xml'); ?> <tr><td><?php
$template = isset($_GET['template']) ? var_out($_GET['template']) : ''; $parent = isset($_GET['parent']) ? var_out($_GET['parent']) : ''; $menu = isset($_GET['menu']) ? var_out($_GET['menu']) : ''; $private = isset($_GET['private']) ? var_out($_GET['private']) : ''; $menuStatus = isset($_GET['menuStatus']) ? var_out($_GET['menuStatus']) : ''; $menuOrder = isset($_GET['menuOrder']) ? var_out($_GET['menuOrder']) : ''; $buttonname = i18n_r('BTN_SAVEPAGE'); } // MAKE SELECT BOX OF AVAILABLE TEMPLATES if ($template == '') { $template = 'template.php'; } $themes_path = GSTHEMESPATH . $TEMPLATE; $themes_handle = opendir($themes_path) or die("Unable to open " . GSTHEMESPATH); while ($file = readdir($themes_handle)) { if (isFile($file, $themes_path, 'php')) { if ($file != 'functions.php' && substr(strtolower($file), -8) != '.inc.php' && substr($file, 0, 1) !== '.') { $templates[] = $file; } } } sort($templates); foreach ($templates as $file) { if ($template == $file) { $sel = "selected"; } else { $sel = ""; } if ($file == 'template.php') { $templatename = i18n_r('DEFAULT_TEMPLATE'); } else {
/** * SFV Check hack * * @param $dirName * @return */ function findSFV($dirName) { $sfv = false; $d = dir($dirName); while (false !== ($entry = $d->read())) { if ($entry != '.' && $entry != '..' && !empty($entry)) { if (isFile($dirName . '/' . $entry) && strtolower(substr($entry, -4, 4)) == '.sfv') { $sfv['dir'] = $dirName; $sfv['sfv'] = $dirName . '/' . $entry; } } } $d->close(); return $sfv; }
function validateFile($the_file) { $msg = "<img src=\"images/red.gif\" align=\"absmiddle\" title=\"Path is not Valid\"><br><font color=\"#ff0000\">Path is not Valid</font>"; if (isFile($the_file)) { $msg = "<img src=\"images/green.gif\" align=\"absmiddle\" title=\"Valid\">"; } return $msg; }
*****************************************************/ // Setup inclusions $load['plugin'] = true; // Relative $relative = '../'; // Include common.php include 'inc/common.php'; // check validity of request if ($_REQUEST['s'] === $SESSIONHASH) { // Variable settings $path = $relative . 'data/pages/'; $count = "0"; $filenames = getFiles($path); if (count($filenames) != 0) { foreach ($filenames as $file) { if (isFile($file, $path, 'xml')) { $data = getXML($path . $file); $status = $data->menuStatus; $pagesArray[$count]['url'] = $data->url; $pagesArray[$count]['parent'] = $data->parent; $pagesArray[$count]['date'] = $data->pubDate; $pagesArray[$count]['private'] = $data->private; $pagesArray[$count]['menuStatus'] = $data->menuStatus; $count++; } } } $pagesSorted = subval_sort($pagesArray, 'menuStatus'); if (count($pagesSorted) != 0) { $xml = @new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><urlset></urlset>'); $xml->addAttribute('xsi:schemaLocation', 'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd', 'http://www.w3.org/2001/XMLSchema-instance');
function getFilesList() { $files = array(); $files_dir = getDirList(); foreach ($files_dir as $key => $value) { if (isFile($value)) { $files[$key] = $value; } } return $files; }
/** * 获取文件列表 * * @param string $dir 欲读取的目录路径 * @param boolean $mode 0:读取全部;1:仅读取文件;2:仅读取目录 * @return array */ function ReadFolder($dir, $mode = 0) { //如果打开目录句柄失败,则输出空数组 if (!($handle = @opendir($dir))) { return array(); } //定义文件列表数组 $files = array(); //遍历目录句柄中的条目 while (false !== ($file = @readdir($handle))) { //跳过本目录以及上级目录 if ('.' === $file || '..' === $file) { continue; } //是否仅读取目录 if ($mode === 2) { if (isDir($dir . '/' . $file)) { $files[] = $file; } //是否仅读取文件 } elseif ($mode === 1) { if (isFile($dir . '/' . $file)) { $files[] = $file; } //读取全部 } else { $files[] = $file; } } //关闭打开的目录句柄 @closedir($handle); //输出文件列表数组 return $files; }
/** * Validates existence + exec + valid version of transmissioncli and returns the status image * * @param $the_file * @return string */ function validateTransmissionCli($the_file) { global $cfg; if (!isFile($the_file)) { return validationMsg(false, 'Path is not valid'); } if (!is_executable($the_file)) { return validationMsg(false, 'File exists but is not executable'); } $transmissionHelp = strtolower(shell_exec("HOME=" . tfb_shellencode($cfg["path"]) . "; export HOME; " . $the_file . ' --help')); return strpos($transmissionHelp, 'transmission') === false || strpos($transmissionHelp, 'tfcli') === false && strpos($transmissionHelp, 'torrentflux') === false ? validationMsg(false, 'Executable is not TorrentFlux-bundled transmissioncli') : validationMsg(true); }
/** * List Pages Json * * This is used by the CKEditor link-local plguin function: ckeditor_add_page_link() * * @author Joshas: mailto:joshas@gmail.com * * @since 3.0 * @uses subval_sort * @uses GSDATAPAGESPATH * @uses getXML * * @returns array */ function list_pages_json() { // get local pages list for ckeditor local page link selector $path = GSDATAPAGESPATH; $filenames = getFiles($path); $count = "0"; $pagesArray = array(); if (count($filenames) != 0) { foreach ($filenames as $file) { if (isFile($file, $path, 'xml')) { $data = getXML($path . $file); $pagesArray[$count]['title'] = html_entity_decode($data->title, ENT_QUOTES, 'UTF-8'); $pagesArray[$count]['parent'] = $data->parent; if ($data->parent != '') { $parentdata = getXML($path . $data->parent . '.xml'); $parentTitle = $parentdata->title; $pagesArray[$count]['sort'] = $parentTitle . ' ' . $data->title; } else { $pagesArray[$count]['sort'] = $data->title; } $pagesArray[$count]['url'] = $data->url; $parentTitle = ''; $count++; } } } $pagesSorted = subval_sort($pagesArray, 'sort'); $pageList = array(); if (count($pagesSorted) != 0) { foreach ($pagesSorted as $page) { if ($page['parent'] != '') { $page['parent'] = $page['parent'] . "/"; $dash = '- '; } else { $dash = ""; } if ($page['title'] == '') { $page['title'] = '[No Title] ' . $page['url']; } array_push($pageList, array($dash . $page['title'], find_url($page['url'], $page['parent']))); } } return json_encode($pageList); }
/** * Safely unpack a BZIP archive to avoid memory errors. * * @param string $src The path to the BZIP archive to unpack. * @param string $dst The path to unpack the BZIP archive to, defaults to source directory * @return boolean True if unpacking was successfule, false if an error occurs. */ public static function bzip_unpack($src, $dst) { # Unpack a BZIP archive if (!isFile($src)) { echo 'Source file ' . $src . 'could not be found.'; return 0; } if (!static::check_dir($dst)) { } return 0; $sfp = bzopen($src, "rb"); $fp = fopen($dst, "w"); while ($string = gzread($sfp, 4096)) { fwrite($fp, $string, strlen($string)); } bzclose($sfp); fclose($fp); return 1; }
function simplecache_pagelist() { $path = GSDATAPAGESPATH; $data = ''; $filenames = getFiles($path); $count = "0"; $pagesArray = array(); if (count($filenames) != 0) { foreach ($filenames as $file) { if (isFile($file, $path, 'xml')) { $data = getXML($path . $file); $pagesArray[$count]['title'] = (string) html_entity_decode($data->title, ENT_QUOTES, 'UTF-8'); $pagesArray[$count]['parent'] = (string) $data->parent; $pagesArray[$count]['sort'] = (string) $data->title; $parent = (string) $data->parent; while ($parent != '') { $parentdata = getXML($path . $parent . '.xml'); $parentTitle = (string) $parentdata->title; $pagesArray[$count]['sort'] = $parentTitle . '^' . $pagesArray[$count]['sort']; $parent = (string) $parentdata->parent; } $pagesArray[$count]['slug'] = (string) $data->url; $pagesArray[$count]['hash'] = md5((string) $data->url); $parentTitle = ''; $count++; } } } return subval_sort($pagesArray, 'sort'); }
color: burlywood; } </style> </head> <body> <?php echo "<h1>PHP Index</h1>"; $contents; if (!isset($_GET['mov_index'])) { $contents = scandir("."); } else { $contents = scandir($_GET['mov_index']); } foreach ($contents as $item) { if (isFile($item) && basename($item) != '.' && basename($item) != '..') { if (isset($_GET['mov_index'])) { echo "<form action='" . $_GET['mov_index'] . "/{$item}' method='get'>"; } else { echo "<form action='{$item}' method='get'>"; } echo "<input id='file' type='submit' value='{$item}'>"; echo "</form>"; } else { if (basename($item) == '.' || basename($item) == '..') { continue; } else { echo "<form action='index.php' method='get'>"; if (isset($_GET['mov_index'])) { echo "<input id='directory' type='submit' value='" . $_GET['mov_index'] . "/{$item}' name='mov_index'>"; } else {
if ($user_count == 0) { // This user is first in DB. Make them super admin. // this is The Super USER, add them to the user table $record = array('user_id' => $user, 'password' => md5($iamhim), 'hits' => 1, 'last_visit' => $create_time, 'time_created' => $create_time, 'user_level' => 2, 'hide_offline' => 0, 'theme' => $cfg["default_theme"], 'language_file' => $cfg["default_language"]); $sTable = 'tf_users'; $sql = $db->GetInsertSql($sTable, $record); $result = $db->Execute($sql); showError($db, $sql); // Test and setup some paths for the TF settings $pythonCmd = $cfg["pythonCmd"]; $btphpbin = getcwd() . "/TF_BitTornado/btphptornado.py"; $tfQManager = getcwd() . "/TF_BitTornado/tfQManager.py"; $maketorrent = getcwd() . "/TF_BitTornado/btmakemetafile.py"; $btshowmetainfo = getcwd() . "/TF_BitTornado/btshowmetainfo.py"; $tfPath = getcwd() . "/downloads/"; if (!isFile($cfg["pythonCmd"])) { $pythonCmd = trim(shell_exec("which python")); if ($pythonCmd == "") { $pythonCmd = $cfg["pythonCmd"]; } } $settings = array("pythonCmd" => $pythonCmd, "btphpbin" => $btphpbin, "tfQManager" => $tfQManager, "btmakemetafile" => $maketorrent, "btshowmetainfo" => $btshowmetainfo, "path" => $tfPath, "btclient_tornado_bin" => $btphpbin); saveSettings($settings); AuditAction($cfg["constants"]["update"], "Initial Settings Updated for first login."); $next_loc = "admin.php?op=configSettings"; } $sql = "SELECT uid, hits, hide_offline, theme, language_file FROM tf_users WHERE user_id=" . $db->qstr($user) . " AND password="******"hide_offline"], $cfg["theme"], $cfg["language_file"]) = $result->FetchRow(); if (!array_key_exists("shutdown", $cfg)) {
if (file_exists($path . $file)) { if (isFile($file, $path, 'bak')) { unlink($path . $file); } } } $success = i18n_r('ER_FILE_DEL_SUC'); } //display all page backups $filenames = getFiles($path); $count = "0"; $pagesArray_tmp = array(); $pagesSorted = array(); if (count($filenames) != 0) { foreach ($filenames as $file) { if (isFile($file, $path, 'bak')) { $data = getXML($path . $file); $status = $data->menuStatus; $pagesArray_tmp[$count]['title'] = html_entity_decode($data->title, ENT_QUOTES, 'UTF-8'); $pagesArray_tmp[$count]['url'] = $data->url; $pagesArray_tmp[$count]['date'] = $data->pubDate; $count++; } } $pagesSorted = subval_sort($pagesArray_tmp, 'title'); } if (count($pagesSorted) != 0) { foreach ($pagesSorted as $page) { $counter++; $table .= '<tr id="tr-' . $page['url'] . '" >'; if ($page['title'] == '') {
/** * getLoadAverageString * * @return string with load-average */ function getLoadAverageString() { global $cfg; switch (_OS) { case 1: // linux if (isFile($cfg["loadavg_path"])) { $loadavg_array = explode(" ", exec($cfg['bin_cat'] . " " . $cfg["loadavg_path"])); return $loadavg_array[2]; } else { return 'n/a'; } break; case 2: // bsd $loadavg = preg_replace("/.*load averages:(.*)/", "\$1", exec("uptime")); return $loadavg; break; default: return 'n/a'; } return 'n/a'; }
echo _FREESPACE; ?> :</td> <td class="tiny"><strong><?php echo formatFreeSpace($cfg["free_space"]); ?> </strong></td> </tr> <tr> <td class="tiny" align="right"><?php echo _SERVERLOAD; ?> :</td> <td class="tiny"> <?php if ($cfg["show_server_load"] && @isFile($cfg["loadavg_path"])) { //$loadavg_array = explode(" ", exec("cat ".escapeshellarg($cfg["loadavg_path"]))); $loadavg = $loadavg_array[1]; //$loadavg = $loadavg_array[2]; echo "<strong>" . $loadavg . "</strong>"; } else { echo "<strong>n/a</strong>"; } ?> </td> </tr> </table> </td> </tr> </table>