function getFileList($path)
{
    global $list;
    global $i;
    $directory = dir($path);
    while ($entry = $directory->read()) {
        if ($entry != "." && $entry != "..") {
            if (Is_Dir($path . "/" . $entry) && !eregi("__zbSessionTMP", $path . "/" . $entry)) {
                getFileList($path . "/" . $entry);
            } else {
                if (!eregi("now_connect.php", $path . "/" . $entry) && !eregi("now_member_connect.php", $path . "/" . $entry) && !eregi("__zbSessionTMP", $path . "/" . $entry)) {
                    $list[] = str_replace("../", "", $path . "/" . $entry);
                    echo ".";
                    $i++;
                    if ($i > 100) {
                        $i = 0;
                        echo "\n\t\t";
                    }
                }
                flush();
            }
        }
    }
    $directory->close();
}
Esempio n. 2
0
/**
 * Return array of filenames to convert
 * @param string $dirName
 * @return mixed
 */
function getFileList($dirName = null)
{
    if (!is_string($dirName)) {
        return false;
    }
    if (!is_dir($dirName)) {
        return false;
    }
    if (!is_readable($dirName)) {
        return false;
    }
    clearstatcache();
    $ret_ar = array();
    if (!($dh = opendir($dirName))) {
        return false;
    }
    while (false !== ($file = readdir($dh))) {
        if ($file == '..' or $file == '.') {
            continue;
        }
        $cur_file = $dirName . '/' . $file;
        if (is_dir($cur_file)) {
            $tmp_ar = getFileList($cur_file);
            if (is_array($tmp_ar)) {
                $ret_ar = array_merge($ret_ar, $tmp_ar);
            }
        }
        $ret_ar[] = $cur_file;
    }
    closedir($dh);
    natcasesort($ret_ar);
    return $ret_ar;
}
/**
 * getFileList
 *
 * @param string $dir_path
 */
function getFileList($dir_path)
{
    $file_list = array();
    $dir = opendir($dir_path);
    if ($dir == false) {
        return false;
    }
    while ($file_path = readdir($dir)) {
        $full_path = $dir_path . '/' . $file_path;
        if (is_file($full_path)) {
            // テストケースのファイルのみ読み込む
            if (preg_match('/^(Ethna_)(.*)(_Test.php)$/', $file_path, $matches)) {
                $file_list[] = $full_path;
            }
            // サブディレクトリがある場合は,再帰的に読み込む.
            // "."で始まるディレクトリは読み込まない.
        } else {
            if (is_dir($full_path) && !preg_match('/^\\./', $file_path, $matches)) {
                $file_list = array_merge($file_list, getFileList($full_path));
            }
        }
    }
    closedir($dir);
    return $file_list;
}
Esempio n. 4
0
function runProducer()
{
    //读取FTP的下载的xml源文件列表
    $kmlPath = '/home/webdata/xml';
    $xml_file = getFileList($kmlPath);
    if (empty($xml_file)) {
        echo date('Y-m-d h:i:m') . "XML source files downloaded from the FTP is empty.", PHP_EOF;
        exit;
    }
    sort($xml_file);
    $startTime = explode(' ', microtime());
    $totalNum = 0;
    $i = $n = 1;
    foreach ($xml_file as $f) {
        //解析文件生成数组
        $data = paseXml($f);
        //XML格式检查
        $res = isFormat($data, $f);
        if ($res === false) {
            continue;
        }
        //格式化
        $kmldata = formatKmlData($data, $f);
        $i++;
        $fNum = count($kmldata);
        $totalNum += $fNum;
        //入队列
        $kafkaTime = explode(' ', microtime());
        echo $i . '>>>' . $f . ',file count:' . $fNum . ',total:' . $totalNum . "/n";
        //备份文件:
        //        backFile($f);
    }
    echo 'Total time:' . getTime($startTime) . '/n';
}
Esempio n. 5
0
/**
 * 得到编辑图片素材
 *
 * @param string;
 * return array;
 */
function get_imgedit_cache($cache_file, $path)
{
    if (!file_exists($cache_file)) {
        $data = getFileList($path);
        file_put_contents($cache_file, "<?php\n\$data=" . var_export($data, true) . ";\n?>");
        //echo 'creat<br>';
        return $data;
    }
    require $cache_file;
    return $data;
}
Esempio n. 6
0
function getFilelist($dir)
{
    global $rFiles;
    $files = glob($dir . '/*');
    foreach ($files as $f) {
        if (is_dir($f)) {
            getFileList($f);
            continue;
        }
        $rFiles[] = $f;
    }
}
Esempio n. 7
0
function getIndexFile($dir)
{
    $files = getFileList($dir);
    $indexFile;
    foreach ($files as $file) {
        if ($file['type'] == "text/html") {
            $indexFile = $file['name'];
            continue;
        }
    }
    return $indexFile;
}
Esempio n. 8
0
function getFileList($dir)
{
    $files = glob(rtrim($dir, '/') . '/*');
    $list = array();
    foreach ($files as $file) {
        if (is_file($file)) {
            $list[] = $file;
        }
        if (is_dir($file)) {
            $list = array_merge($list, getFileList($file));
        }
    }
    return $list;
}
Esempio n. 9
0
function runConsumer($topic)
{
    $lockfile = '/tmp/mytest.lock';
    $startTime = explode(' ', microtime());
    $kmlCachePath = getconfig('kmlCachePath');
    //本地缓存里存在数据则优先执行
    $cacheFiles = getFileList('./cache/' . $topic);
    if (!empty($cacheFiles)) {
        sort($cacheFiles);
        foreach ($cacheFiles as $f) {
            $kmls = json_decode(file_get_contents($f));
            $items = array_chunk($kmls, 25);
            foreach ($items as $item) {
                updataKml($item, $startTime, $f, 2, $topic);
            }
        }
    }
    //  $i = 1;
    $f = '';
    logs(date('h:i:s', time()) . $topic . ' start ...', 1, 'consumer', $topic);
    while ($da = kafka::getInstance()->get($topic)) {
        $starttime = explode(' ', microtime());
        if (!empty($da->messageList)) {
            foreach ($da->messageList as $d) {
                $kmls[] = json_decode($d->message);
            }
            //$i++;
            //if($i > 10){
            updataKml($kmls, $starttime, $f, 1, $topic);
            usleep(10);
            logs(date('H:i:s') . 'sleep 10', 1, 'consumer', $topic);
            $kmls = [];
            /*    $i = 1;
                      }
                  }else{
                      if(!empty($kmls)){
                         updataKml($kmls,$starttime,$f,1, $topic);
                      }
                      break;*/
        } else {
            unlink($lockfile);
            logs('success total time:' . getTime($startTime), 1, 'consumer', $topic);
            echo 'aa';
            exit;
        }
    }
    logs('success total time:' . getTime($startTime), 1, 'consumer', $topic);
    unlink($lockfile);
}
Esempio n. 10
0
function getFileList($dir)
{
    $files = glob(rtrim($dir, '/') . '/*html');
    $list = array();
    foreach ($files as $file) {
        if (is_file($file)) {
            $list[] = $file;
        }
    }
    $dirs = glob(rtrim($dir, '/') . '/*', GLOB_ONLYDIR);
    foreach ($dirs as $d) {
        $list = array_merge($list, getFileList($d));
    }
    return $list;
}
Esempio n. 11
0
/**
 * 
 * @param type $oFile
 * @param type $sDir
 * @param type $sRootPath
 */
function writePhpList($oFile, $sDir, $sRootPath)
{
    $aFile = getFileList($sDir);
    for ($i = 0; $i < count($aFile); $i++) {
        $sTemp = str_replace($sRootPath, ".", $aFile[$i]);
        $sTemp = str_replace("\\", "/", $sTemp);
        fwrite($oFile, $sTemp . "\n");
    }
    $aSubDir = getSubDir($sDir);
    if ($aSubDir != false) {
        for ($i = 0; $i < count($aSubDir); $i++) {
            writePhpList($oFile, $aSubDir[$i], $sRootPath);
        }
    }
}
Esempio n. 12
0
function writeList($dir)
{
    $list = getFileList($dir);
    if (count($list !== 0)) {
        echo "<ol>";
        foreach ($list as $value) {
            //ファイル名
            $fileName = pathinfo($value)["basename"];
            // echo $fileName;
            if ($fileName === "index.html" || $fileName === "index.php") {
                echo "<li><a href='" . $value . "'>" . pathinfo($value)["dirname"] . "</a></li>";
            }
        }
        echo "</ol>";
    }
}
Esempio n. 13
0
function runProducer()
{
    $kmlPath = getconfig('kmlPath');
    $xml_file = getFileList($kmlPath);
    $lockfile = '/tmp/producer.lock';
    if (empty($xml_file)) {
        logs(date('Y-m-d h:i:m') . "XML source files downloaded from the FTP is empty.");
        unlink($lockfile);
        exit;
    }
    sort($xml_file);
    $startTime = explode(' ', microtime());
    $totalNum = 0;
    $i = $n = 1;
    foreach ($xml_file as $f) {
        //解析文件生成数组
        $data = paseXml($f);
        //XML格式检查
        $res = isFormat($data, $f);
        if ($res === false) {
            continue;
        }
        //格式化
        $kmldata = formatKmlData($data, $f);
        $i++;
        $fNum = count($kmldata);
        $totalNum += $fNum;
        //入队列
        $kafkaTime = explode(' ', microtime());
        $fileName = basename($f);
        insertKafka($kmldata, $fileName);
        logs($i . '>>>' . basename($f) . ',file count:' . $fNum . ',total:' . $totalNum . ',into kafka time:' . getTime($kafkaTime));
        if ($n > 100) {
            usleep(200);
            $n = 1;
        }
        //备份文件:
        backFile($f);
    }
    logs('Total time:' . getTime($startTime));
    //unlock();
    //$lockfile = '/tmp/producer.lock';
    unlink($lockfile);
    exit;
}
Esempio n. 14
0
function getFileList($dir)
{
    $files = scandir($dir);
    $files = array_filter($files, function ($file) {
        return !in_array($file, array('.', '..'));
    });
    $list = array();
    foreach ($files as $file) {
        $fullpath = rtrim($dir, '/') . '/' . $file;
        if (is_file($fullpath)) {
            $list[] = $fullpath;
        }
        if (is_dir($fullpath)) {
            $list = array_merge($list, getFileList($fullpath));
        }
    }
    return $list;
}
Esempio n. 15
0
function getFileList($root, $basePath = '')
{
    $files = [];
    $handle = opendir($root);
    while (($path = readdir($handle)) !== false) {
        if ($path === '.svn' || $path === '.' || $path === '..') {
            continue;
        }
        $fullPath = "{$root}/{$path}";
        $relativePath = $basePath === '' ? $path : "{$basePath}/{$path}";
        if (is_dir($fullPath)) {
            $files = array_merge($files, getFileList($fullPath, $relativePath));
        } else {
            $files[] = $relativePath;
        }
    }
    closedir($handle);
    return $files;
}
Esempio n. 16
0
function getLocationURL($mode)
{
    $fileList = getFileList();
    $baseURL = $mode == "goto_pc" ? $fileList[0][0] : $fileList[0][1];
    foreach ($fileList as $line) {
        list($pcURL, $spURL) = $line;
        if ($mode == "goto_pc") {
            $csvData[trim($spURL)] = trim($pcURL);
        } else {
            $csvData[trim($pcURL)] = trim($spURL);
        }
    }
    if ($_SERVER['HTTP_REFERER']) {
        $refURL = str_replace("index.html", "", $_SERVER['HTTP_REFERER']);
        $refURL = str_replace("index.php", "", $refURL);
        $refDirName = dirname($_SERVER['HTTP_REFERER']);
        if (isset($csvData[$refURL]) && $csvData[$refURL]) {
            $url = $csvData[$refURL];
            if (!strstr($_SERVER['SERVER_NAME'], 'doc2root.net') && !strstr($_SERVER['SERVER_NAME'], 'biyo-ad.com') && !strstr($_SERVER['SERVER_NAME'], 'test.')) {
                $urlcheck = @file_get_contents($url);
                if (!$urlcheck) {
                    $url = $baseURL;
                }
            }
        } else {
            if (isset($csvData[$refDirName . '/*']) && $csvData[$refDirName . '/*']) {
                $url = !strstr($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST'] . '/sp') ? str_replace($_SERVER['HTTP_HOST'], $_SERVER['HTTP_HOST'] . '/sp', $_SERVER['HTTP_REFERER']) : str_replace($_SERVER['HTTP_HOST'] . '/sp', $_SERVER['HTTP_HOST'], $_SERVER['HTTP_REFERER']);
                if (!strstr($_SERVER['SERVER_NAME'], 'doc2root.net') && !strstr($_SERVER['SERVER_NAME'], 'biyo-ad.com') && !strstr($_SERVER['SERVER_NAME'], 'test.')) {
                    $urlcheck = @file_get_contents($url);
                    if (!$urlcheck) {
                        $url = $baseURL;
                    }
                }
            } else {
                $url = $baseURL;
            }
        }
    } else {
        $url = $baseURL;
    }
    return $url;
}
Esempio n. 17
0
/**
 * @param       $dir
 * @param null  $filter
 * @param array $results
 * @return array
 */
function getFileList($dir, $filter = null, &$results = array())
{
    $files = scandir($dir);
    global $config;
    foreach ($files as $key => $value) {
        $path = $dir . DIRECTORY_SEPARATOR . $value;
        if (!is_dir($path) && !in_array($value, $config['exclude'], true)) {
            if ($filter) {
                if (preg_match('#' . $filter . '#iu', $path)) {
                    $results[] = realpath($path);
                }
            } else {
                $results[] = realpath($path);
            }
        } elseif (is_dir($path) && !in_array($value, $config['exclude'], true)) {
            getFileList($path, $filter, $results);
        }
    }
    return $results;
}
Esempio n. 18
0
function getFileList($dir)
{
    $files = scandir($dir);
    $files = array_filter($files, function ($file) {
        return !in_array($file, array('.', '..'));
    });
    $list = array();
    foreach ($files as $file) {
        $path = rtrim($dir, '/') . '/' . $file;
        $htmlExtIndex = strpos($path, 'index.html');
        if (is_file($path) && $htmlExtIndex) {
            $fullpath = substr($path, 2, $htmlExtIndex - 2);
            $dirs = explode('/', $fullpath);
            $data = array('name' => "jquery.{$dirs['2']}.js", 'href' => $fullpath, 'dirs' => $dirs[1]);
            if ($dirs[2] != '') {
                $list[] = $data;
            }
        }
        if (is_dir($path)) {
            $list = array_merge($list, getFileList($path));
        }
    }
    return $list;
}
Esempio n. 19
0
function getFileList($dir)
{
    $retorno = '';
    if (substr($dir, -1) != "/") {
        $dir .= "";
    }
    $d = @dir($dir) or die("ERROR 404");
    // Directorio no encontrado
    while (false !== ($entry = $d->read())) {
        if ($entry[0] == ".") {
            continue;
        }
        // Saltear archivos ocultos (inician con ".")
        if (is_dir("{$dir}{$entry}")) {
            $retorno .= getFileList("{$dir}{$entry}/");
            // Ingresamos al subdirectorio
        } elseif (is_readable("{$dir}{$entry}")) {
            $retorno .= remove_up_dir("{$dir}{$entry}") . "|" . filesize("{$dir}{$entry}") . "|" . strtoupper(md5_file("{$dir}{$entry}")) . chr(10);
            // Archivo
        }
    }
    $d->close();
    return $retorno;
}
Esempio n. 20
0
function getFileList($dir)
{
    //$files = glob(rtrim($dir, '/') . '/*');
    $dir = rtrim($dir, '/') . '/*';
    $files = glob($dir . '{*.pdf,*.PDF}', GLOB_BRACE);
    $list = array();
    foreach ($files as $file) {
        if (is_file($file)) {
            $list[] = $file;
        }
        if (is_dir($file)) {
            $list = array_merge($list, getFileList($file));
        }
    }
    return $list;
}
Esempio n. 21
0
<!DOCTYPE html>
<html class="no-js">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title>ePub Viewer</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width">
        <meta name="apple-mobile-web-app-capable" content="yes">
    </head>

	<?php 
$dir = "../books/epub";
$keyword = $_GET["keyword"];
$filelist = getFileList($dir);
echo "FILE LIST : <br>";
$i = 1;
foreach ($filelist as $val) {
    $name = stringcut($val, $dir . "/", ".");
    echo "[{$i}] : {$name}<br>";
    $i++;
}
unset($val);
//return file list
function getFileList($dir)
{
    $files = scandir($dir);
    $files = array_filter($files, function ($file) {
        return !in_array($file, array('.', '..'));
    });
    $list = array();
Esempio n. 22
0
require ROOT_PATH . "/source/class/myfso.class.php";
date_default_timezone_set($setting['gen']['timezone']);
$plugin_path = ROOT_PATH . "/plugin/";
$p = $_GET['p'];
$l = $_GET['l'];
$cs = $_GET['cs'];
if ($cs == $setting['gen']['charset']) {
    $cs = "";
}
if (!empty($l)) {
    $setting['gen']['language'] = $l;
}
if (!empty($p)) {
    $the_file = $plugin_path . $p . "/update.php";
    if (!file_exists($the_file)) {
        $file_list = getFileList($plugin_path . $p, "update.php,config.php,cache");
        $content = '<?php
include("info.php");
$sql_list = array();
$file_list = ' . var_export($file_list, true) . ';
?>';
        WriteFile($the_file, $content, "wb");
    }
    include $the_file;
}
if (!empty($_SERVER["HTTP_REFERER"]) && isset($file_list)) {
    $cache_file = ROOT_PATH . "/" . $setting['path']['cache'] . "/update/" . md5($p . $cs . $info['ver']);
    if (file_exists($cache_file)) {
        $update = GetFile($cache_file);
    } else {
        if (!empty($cs)) {
Esempio n. 23
0
    function changePage(newLoc) {
    	nextPage = newLoc.options[newLoc.selectedIndex].value;
    	if (nextPage != '') {
    		document.location.href = nextPage;
    	}
    }

    //]]>
    </script>
</head>
  <body style="margin: 6px 6px 6px 6px; background-image: none;" onload="self.focus()">
    <table border="0" cellspacing="0" cellpadding="2">
<?php 
$show = 17;
list($fileArray, $thumbArray) = getFileList();
$count = count($fileArray);
$loop = 0;
do {
    $mystart = substr(strtolower(urldecode($fileArray[$loop]['name'])), 0, 18);
    if (isset($fileArray[$loop + $show - 1])) {
        $mystop = substr(strtolower(urldecode($fileArray[$loop + $show - 1]['name'])), 0, 18);
    } else {
        $mystop = "zzz";
    }
    $url = "pick.php?session=" . $Pivot_Vars['session'] . "&slice={$loop}";
    $slice_arr[] = "<option value=\"{$url}\">{$mystart} - {$mystop}</option>";
    $loop = $loop + $show;
} while ($loop < $count);
if (count($slice_arr) > 1) {
    echo "<form name='form1' action=''>";
Esempio n. 24
0
<?php

//--------------------------------------------------------------------
// スマートフォン振り分け
// ver 2.0 2012/12/03
// エスエス・ファシリティーズ http://www.ss-facilities.co.jp
//--------------------------------------------------------------------
//**********************************
// Go to SP
//**********************************
include "config.php";
include "function.php";
setcookie("viewSelect", "SP", time() + 60 * 60 * 24, "/");
if ($_SERVER['HTTP_REFERER']) {
    $fileList = getFileList();
    foreach ($fileList as $line) {
        list($spURL, $pcURL) = $line;
        $csvData[trim($pcURL)] = trim($spURL);
    }
    $refURL = str_replace("index.html", "", $_SERVER['HTTP_REFERER']);
    if (isset($csvData[$refURL]) && $csvData[$refURL]) {
        //除外文字列
        $url = str_replace($domain, str_replace("www.", "", str_replace("/", "", $_SERVER['HTTP_HOST'])), $csvData[$refURL]);
    } else {
        $url = $baseurlSP;
    }
} else {
    $url = $baseurlSP;
}
header('Location: ' . $url);
Esempio n. 25
0
function makeBody()
{
    // The main body, contains either a file list or an edit form.
    $str = "";
    if (empty($_REQUEST['act'])) {
        // No action set - we show a list of files.
        $files = getFileList(getDir());
        if (!is_array($files)) {
            // List couldn't be fetched. Throw error.
            redirect("status=dirfail");
        } else {
            // Show list of files in a table.
            $str .= "<table id='filelist'>";
            $str .= "<thead><tr><th colspan=\"3\">File list</th>";
            $str .= "</tr></thead>";
            $str .= "<tbody>";
            if (count($files) <= 0) {
                $str .= "<tr><td colspan='3' class='error'>Directory is empty.</td></tr>";
            } else {
                $i = 0;
                $previous = $files[0]['type'];
                foreach ($files as $c) {
                    if ($c['writeable']) {
                        $class = "show writeable ";
                    } else {
                        $class = "";
                    }
                    if ($c['edit']) {
                        $class .= " edit ";
                    } else {
                        $class .= "";
                    }
                    if ($i % 2 != 0) {
                        $odd = "odd";
                    } else {
                        $odd = "";
                    }
                    if ($previous != $c['type']) {
                        // Insert seperator.
                        $odd .= " seperator ";
                    }
                    $previous = $c['type'];
                    $str .= "<tr class='{$c['type']} {$odd}'>";
                    if ($c['writeable'] && DISABLEFILEACTIONS == FALSE) {
                        $str .= "<td class='details'><span class='{$class}'>&loz;</span><span class='hide' style='display:none;'>&loz;</span></td>";
                    } else {
                        $str .= "<td class='details'>&nbsp;</td>";
                    }
                    if ($c['type'] == "file") {
                        $str .= "<td class='name'><a href=\"" . getDir() . "/{$c['name']}\">{$c['name']}</a></td><td class='size'>" . niceFileSize($c['size']);
                    } else {
                        $str .= "<td class='name'>" . makeLink($c['name'], "dir={$_REQUEST['dir']}/{$c['name']}", "Show files in this directory") . "</td><td class='size'>{$c['size']} files";
                    }
                    // $str .= "</td><td>".date(DATEFORMAT, $c['modified'])."</td></tr>";
                    $str .= "</td></tr>";
                    $i++;
                }
            }
            $str .= "</tbody><tfoot><tr><td colspan=\"3\">" . count($files) . " files and folders</td></tr></tfoot>";
            $str .= "</table>";
        }
    } elseif ($_REQUEST['act'] == "edit") {
        $_REQUEST['file'] = trim(stripslashes($_REQUEST['file']));
        $str = "<h2>Edit file: {$_REQUEST['file']}</h2>";
        // Check that file exists and that it's writeable.
        if (is_writeable(getDir() . "/" . $_REQUEST['file'])) {
            // Check that filetype is editable.
            if (checkforedit($_REQUEST['file'])) {
                // Get file contents.
                $filecontent = implode("", file(getDir() . "/{$_REQUEST["file"]}"));
                $filecontent = htmlentities($filecontent);
                if (CONVERTTABS == TRUE) {
                    $filecontent = str_replace("\t", "    ", $filecontent);
                }
                // Make form.
                $str .= '<form id="edit" action="' . getSelf() . '" method="post">
					<div>
						<textarea cols="76" rows="20" name="filecontent">' . $filecontent . '</textarea>
					</div>
					<div>
						<input type="hidden" name="file" value="' . $_REQUEST['file'] . '" />
						<input type="hidden" name="dir" value="' . $_REQUEST['dir'] . '" />
						<input type="hidden" name="act" value="savefile" />
						<input type="submit" value="Save file" name="submit" />
						<input type="submit" value="Cancel" name="submit" />
						<input type="checkbox" name="convertspaces" id="convertspaces" checked="checked" /> <label for="convertspaces">Convert spaces to tabs</label>
					</div>
				</form>';
            } else {
                $str .= '<p class="error">Cannot edit file. This file type is not editable.</p>';
            }
        } else {
            $str .= '<p class="error">Cannot edit file. It either does not exist or is not writeable.</p>';
        }
    }
    return $str;
}
Esempio n. 26
0
<?php

/**
	The restore function will display all restore points for the current class.
	The path for restore points is $_CONF['configPath'].$center."/".$teacher."/".$course."/"
	The restore files are in the form 2010-11-12_Term 1_

**/
if ($_SESSION[$_CONF['sess_name'] . '_isTeacher']) {
    /** Get class info for current class **/
    $sql = "SELECT ed_centers.short_name, users.u_name, courses.course_name, classes.class_id, terms.term_name\n\t\tFROM ed_centers, users, courses, classes, terms\n\t\tWHERE classes.class_id=" . $_SESSION[$_CONF['sess_name'] . '_selected_class'] . "\n\t\tAND courses.course_id = classes.course_id\n\t\tAND terms.term_id = classes.term_id\n\t\tAND users.user_id=courses.teacher_id\n\t\tAND ed_centers.center_id=" . $_SESSION[$_CONF['sess_name'] . '_myCenter'];
    $result = $db->query($sql);
    $row = $result->fetch_assoc();
    $center = $row['short_name'];
    $teacher = $row['u_name'];
    $course = preg_replace('/ /i', '\\ ', $row['course_name']);
    $term = $row['term_name'];
    /** Get list of available restore points for this class **/
    $restorePath = $_CONF['configPath'] . "teacher_backups/" . $center . "/" . $teacher . "/" . $course . "/";
    $files = getFileList($restorePath);
    foreach ($files as $id => $path) {
        $files[$id] = preg_replace('/\\/usr\\/local\\/q3ait\\/teacher_backups\\/' . $center . '\\/' . $teacher . '\\/' . $course . '\\//i', '', $files[$id]);
    }
} else {
    $main .= login_error();
}
Esempio n. 27
0
 /**
  * Get file list in directory
  * @param       $dir
  * @param null  $filter
  * @param array $results
  * @return array
  * @deprecated See getFileList()
  */
 public function getFileList($dir, $filter = null, &$results = array())
 {
     return getFileList($dir, $filter, $results);
     // @codeCoverageIgnore
 }
Esempio n. 28
0
function listPosts($request, $filter)
{
    $match;
    $offset;
    $postNumber;
    //Navigating back and forth.
    if (preg_match("/.+offset\\/(\\d+)(\\/display\\/\\d+)?[\\/]?\$/", $request, $match)) {
        $offset = $match[1];
    }
    if (preg_match("/(.+offset\\/\\d+)?\\/display\\/(\\d+)[\\/]?\$/", $request, $match)) {
        $postNumber = $match[2];
    }
    $dir = BASE_PATH . BLOG_DIR;
    $allFiles = getFileList(BASE_PATH . BLOG_DIR, $filter);
    rsort($allFiles);
    if (!isset($offset)) {
        $offset = 0;
    }
    if (!isset($postNumber)) {
        $postNumber = BLOG_POST_NUMBER;
    }
    $printCount = 0;
    $itemCount = 0;
    $usedToMatch = false;
    //$html= printBlogNav($offset,$offset+$postNumber,count($allFiles),"left");
    $html .= "<br/>";
    foreach ($allFiles as $file) {
        if ($itemCount >= $offset && $printCount < $postNumber) {
            $html .= printFile($dir, $file, $uri);
            $printCount++;
            $usedToMatch = true;
        } else {
            if ($usedToMatch == true) {
                break;
            }
        }
        $itemCount++;
    }
    $html .= "<br/></div>";
    #end id=blog div
    $html .= printBlogNav($offset, $offset + $postNumber, count($allFiles), "right");
    return $html;
}
 protected function getFileList($dir, $recurse = false)
 {
     # array to hold return value
     $retval = array();
     # add trailing slash if missing
     if (substr($dir, -1) != "/") {
         $dir .= "/";
     }
     # open pointer to directory and read list of files
     $d = @dir($dir) or die("getFileList: Failed opening directory {$dir} for reading");
     while (false !== ($entry = $d->read())) {
         # skip hidden files
         if ($entry[0] == "." || strpos($entry[0], 'thumbnails')) {
             continue;
         }
         if (is_dir("{$dir}{$entry}")) {
             $retval[] = array("name" => "{$entry}/", "type" => filetype("{$dir}{$entry}"), "size" => 0, "lastmod" => filemtime("{$dir}{$entry}"));
             if ($recurse && is_readable("{$dir}{$entry}/")) {
                 $retval = array_merge($retval, getFileList("{$dir}{$entry}/", true));
             }
         } elseif (is_readable("{$dir}{$entry}")) {
             $retval[] = array("name" => "{$entry}", "type" => mime_content_type("{$dir}{$entry}"), "size" => filesize("{$dir}{$entry}"), "lastmod" => filemtime("{$dir}{$entry}"));
         }
     }
     $d->close();
     return $retval;
 }
<?php

// Development settings -- comment out the next three lines in production
header('Access-Control-Allow-Origin: *');
// CORS All-Access
error_reporting(E_ALL);
ini_set('display_errors', 'on');
/////////////////////////////////////////////////////////////////////////////////
// Entry point for getting JSON
// action=books
// action=toc&comic=file.cbz
// action=image&comic=file.cbz&page=image.jpg
// Returns a list of comic books as json format
if ($_GET["action"] == "books") {
    header('Content-type: application/json');
    print json_encode(getFileList(dirname(__FILE__)));
}
// Returns the table of contents as a JSON string
if ($_GET["action"] == "toc") {
    header('Content-type: application/json');
    print json_encode(getToC(basename(realpath($_GET["comic"]))));
}
// Get an image out of an archive file by name
if ($_GET["action"] == "image") {
    passImage(basename(realpath($_GET["comic"])), $_GET["page"]);
}
/////////////////////////////////////////////////////////////////////////////////
// Return an array of files in $path that are archive files
function getFileList($path)
{
    $files = scandir($path);