Ejemplo n.º 1
0
 public function getPageList()
 {
     $tmpl = $_REQUEST['tmpl'];
     $arr = getAllFiles(FANWE_ROOT . "/tpl/" . $tmpl . "/");
     foreach ($arr as $item) {
         if (substr($item, -4) == ".htm") {
             $item = preg_replace("/.htm/", "", $item);
             $item = explode("/" . $tmpl . "/", $item);
             $item = $item[1];
             $files[] = $item;
         }
     }
     $xml = simplexml_load_file(FANWE_ROOT . "/tpl/" . $tmpl . "/pages.xml");
     $pages = array();
     if ($xml) {
         $xml = (array) $xml;
         foreach ($xml['page'] as $item) {
             $item = (array) $item;
             if (count($item['file']) == 0) {
                 $item['file'] = '';
             }
             $pages[] = $item;
         }
     }
     $res['files'] = $files;
     $res['pages'] = $pages;
     echo json_encode($res);
 }
function deleteOldLocalFiles()
{
    $intBackupsToKeep = 2;
    //keep 2 weekly backups locally.  Locally is really just a staging area.  the real backups are kept on rackspace cloud files
    $arrAllFiles = getAllFiles();
    $arrDistinctPrefixes = filterDistinctPrefixes($arrAllFiles);
    if (count($arrDistinctPrefixes) > $intBackupsToKeep) {
        //if we have more backups than we want to keep, build a deletion list
        //rsort the array so we keep the 0-1 array positions, and chop off the rest.
        rsort($arrDistinctPrefixes);
        $arrPrefixesToKeep = array_slice($arrDistinctPrefixes, 0, $intBackupsToKeep);
        $arrFilesToDelete = array();
        foreach ($arrAllFiles as $value) {
            $dateVal = getDatePrefix($value);
            if ($dateVal != '') {
                if (!in_array($dateVal, $arrPrefixesToKeep)) {
                    //if the file has a prefix which isn't in the list of prefixes to keep, add it to the delete list
                    array_push($arrFilesToDelete, $value);
                }
            }
        }
        echo "Deleting older LOCAL backups.  There are currently " . count($arrDistinctPrefixes) . " weeks worth of an allowed " . $intBackupsToKeep . ".  Deleting " . (count($arrDistinctPrefixes) - $intBackupsToKeep) . " weeks worth.\n";
        $intDelete = 1;
        $intTotalDeletes = count($arrFilesToDelete);
        foreach ($arrFilesToDelete as $value) {
            echo "Deleting Object: " . $value . " (" . $intDelete . " of " . $intTotalDeletes . ")\n";
            unlink('data/' . $value);
            $intDelete++;
        }
    }
}
Ejemplo n.º 3
0
function getFilesTimestamp($directory, $recursive = true)
{
    $allFiles = getAllFiles($directory, $recursive);
    $fileArray = array();
    foreach ($allFiles as $val) {
        $timeResult['file'] = $val;
        $timeResult['timestamp'] = filemtime($val);
        $fileArray[] = $timeResult;
    }
    return $fileArray;
}
Ejemplo n.º 4
0
function getAllFiles($filedir, $fileType, $exclude)
{
    $allfiles = array();
    //文件名数组
    if (is_dir($filedir)) {
        //判断要遍历的是否是目录
        if ($dh = opendir($filedir)) {
            //打开目录并赋值一个目录句柄(directory handle)
            while (FALSE !== ($filestring = readdir($dh))) {
                //读取目录中的文件名
                if ($filestring != '.' && $filestring != '..' && !preg_match("/\\.svn\$/", $filestring) && !preg_match("/data\$/", $filestring) && !preg_match("/tools\$/", $filestring) && !preg_match("/ipad\$/", $filestring) && !preg_match("/import\\.js\$/", $filestring)) {
                    //如果不是.和..(每个目录下都默认有.和..)
                    if (is_dir($filedir . $filestring)) {
                        //该文件名是一个目录时
                        if (!$exclude || $exclude && !preg_match("/{$exclude}/", $filedir . $filestring)) {
                            $tempArr = getAllFiles($filedir . $filestring . '/', $fileType, $exclude);
                            //继续遍历该子目录
                            $allfiles = array_merge($allfiles, $tempArr);
                            //把临时文件名和临时文件名组合
                        }
                    } else {
                        if (is_file($filedir . $filestring)) {
                            //如果该文件名是一个文件不是目录,直接赋值给文件名数组
                            if (preg_match("/{$fileType}/", $filedir . $filestring)) {
                                $allfiles[] = $filedir . $filestring;
                                //                                                                }
                            }
                        }
                    }
                }
            }
        } else {
            //打开目录失败
            exit('Open the directory failed');
        }
        closedir($dh);
        //关闭目录句柄
        return $allfiles;
        //返回文件名数组
    } else {
        //目录不存在
        echo "{$filedir}";
        exit('The directory does not exist');
    }
}
Ejemplo n.º 5
0
/**
 * 获取指定目录下的所有文件,返回一个数组,数组元素为文件的实际路径
 * @param $dir
 * @return array
 */
function getAllFiles($dir, $extension = 'php')
{
    $files = array();
    if (is_file($dir)) {
        if (pathinfo($dir, PATHINFO_EXTENSION) == $extension) {
            array_push($files, $dir);
        }
        return $files;
    }
    $folder = new DirectoryIterator($dir);
    foreach ($folder as $file) {
        if ($file->isFile()) {
            if (pathinfo($file, PATHINFO_EXTENSION) == $extension) {
                array_push($files, $file->getRealPath());
            }
            continue;
        }
        if (!$file->isDot()) {
            $sub_files = getAllFiles($file->getRealPath(), $extension);
            $files = array_merge($files, $sub_files);
        }
    }
    return $files;
}
Ejemplo n.º 6
0
$page = "renameImages";
require '../../variables.php';
require '../../variablesdb.php';
require_once '../functions.php';
require_once './../../functions.php';
require_once '../../files/functions.php';
require '../../top.php';
echo getOuterBoxTop($leaguename . " <span class='grey-small'>&raquo;</span> Rename Videos", "");
?>
<?


$imagesDir = "./../../files/images/";
$thumbsDir = "./../../files/images/thumbnails/";

$filesList = getAllFiles($imagesDir);

$filesListRev = array ();
foreach ($filesList as $fileArray) {
	$modified = $fileArray[1];
	$filesListRev[] = array (
		$fileArray[1],
		$fileArray[0]
	);
}

$fullList = $filesListRev;

asort($fullList);
$i = 0;
Ejemplo n.º 7
0
function getAllFiles($path)
{
    $list = array();
    foreach (glob($path . '/*') as $item) {
        if (is_dir($item)) {
            $list = array_merge($list, getAllFiles($item));
        } else {
            $list[] = $item;
        }
    }
    return $list;
}
Ejemplo n.º 8
0
<?php

require_once "config.inc.php";
$limit = intval($_GET['limit']);
$filetypes = array('jpg', 'jpeg', 'tif', 'tiff', 'raw', 'ai', 'pdf', 'eps', 'svg');
$ignore_extensions = array('db', 'dmg', 'xls', 'exe');
$ignore_filenames = array('DS_Store');
$existings = $db->query("SELECT * FROM `photos`");
$existing_files = array();
while ($existing = $existings->fetch_assoc()) {
    $existing_files[] = $existing['fullpath'];
}
$files = getAllFiles("./content/");
$starttime = time();
echo "<pre>Started at: " . date("Y-m-d H:i:s", $starttime) . ' ' . count($files) . " files</pre>";
$i = 0;
foreach ($files as $key => $file) {
    $f_info = pathinfo($file);
    $f_ext = trim(strtolower($f_info['extension']));
    if (!in_array($file, $existing_files) && substr($f_info['basename'], 0, 1) !== '.' && in_array($f_ext, $filetypes) && !in_array($f_info['basename'], $ignore_filenames)) {
        try {
            $imagesize = imgetimagesize($file);
        } catch (Exception $e) {
            echo "<pre>Error with file: {$file}\nSize:" . filesize($file) . "\nCaught exception: " . $e->getMessage() . "</pre>";
        }
        if (isset($imagesize['properties']['tiff:timestamp'])) {
            $filedate = strtotime($imagesize['properties']['tiff:timestamp']);
        } elseif (isset($imagesize['properties']['xap:CreateDate'])) {
            $filedate = strtotime($imagesize['properties']['xap:CreateDate']);
        } elseif (isset($imagesize['properties']['xmp:CreateDate'])) {
            $filedate = strtotime($imagesize['properties']['xmp:CreateDate']);
Ejemplo n.º 9
0
$content = preg_replace($remove, '', $content);
$content = preg_replace($replace, '', $content);
$content = strip_tags($content);
$content = htmlspecialchars_decode($content);
preg_match_all('/./us', $content, $match);
$match[0] = array_unique($match[0]);
$unicode = array();
foreach ($match[0] as $char) {
    $unicode[] = nochaoscode("utf8", $char);
}
print_r($unicode);
exec("./generate_font.pe -font " . FONT_FILE . " " . implode(" ", $unicode));
//generate css files
$fontface = "";
$class = "";
getAllFiles("chars/", $files);
foreach ($files as $file) {
    $content = base64_encode(file_get_contents("chars/{$file}.ttf"));
    $fontface .= <<<FONT
@font-face {
    font-family: "{$file}";
    src: url("data:font/opentype;base64,{$content}");
}
FONT;
    $class .= <<<STYLE
.{$file} {
    font-family: {$file};
}
STYLE;
}
file_put_contents("font-face.css", $fontface);
Ejemplo n.º 10
0
     $keys = array_keys($query);
     $total = count($keys);
     if ($total > 0) {
         for ($i = 0; $i < $total; $i++) {
             $key = $keys[$i];
             $pattern = $query[$key];
             if (is_string($pattern)) {
                 $patterns[$key] = patternToRegExp($pattern);
             }
         }
         $files = matchFiles($query, $patterns, $ignoreCase, ".", $rootDir, $deep, $dirsOnly, $expand, $showHiddenFiles);
     } else {
         $files = getAllFiles(".", $rootDir, $deep, $dirsOnly, $expand, $showHiddenFiles);
     }
 } else {
     $files = getAllFiles(".", $rootDir, $deep, $dirsOnly, $expand, $showHiddenFiles);
 }
 $total = count($files);
 //Handle the sorting and paging.
 $sortSpec = false;
 if (array_key_exists("sort", $_GET)) {
     $sortSpec = $_GET['sort'];
     $sortSpec = str_replace("\\\"", "\"", $sortSpec);
     $sortSpec = json_decode($sortSpec);
 }
 if ($sortSpec != null) {
     $comparator = createComparator($sortSpec);
     usort($files, array($comparator, "compare"));
 }
 //Page, if necessary.
 if (array_key_exists("start", $_GET)) {
Ejemplo n.º 11
0
$page = "populateGoals";
require '../../variables.php';
require '../../variablesdb.php';
require_once '../functions.php';
require_once './../../functions.php';
require_once './../../files/functions.php';
require '../../top.php';
echo getOuterBoxTop($leaguename . " <span class='grey-small'>&raquo;</span> Populate New", "");
?>
<?


$goalsDir = "./../../files/goals/";
$thumbsDir = "./../../files/goals/thumbnails/";

$filesList = getAllFiles($goalsDir);

$filesListRev = array ();

foreach ($filesList as $fileArray) {
	if (!is_dir($fileArray[0])) {
		$filesListRev[] = array (
			$fileArray[1],
			$fileArray[0]
		);
	}
}

$fullList = $filesListRev;

asort($fullList);
Ejemplo n.º 12
0
/**
 *
 * @param DOMDocument $xml puvodni XML
 * @param array|string $styles seznam xsl stylu
 * @return string
 */
function applyTransformation(DOMDocument $xml, $styles)
{
    if (!is_array($styles)) {
        $styles = array($styles);
    }
    if (empty($styles)) {
        $GLOBALS['xmlerrmsg'] .= "No styles found with given rule. Add some xslt files into plugin configuration after the rule\n";
    }
    $GLOBALS['xmlinfomsg'] .= "Applying transformation with following styles: " . implode(", ", $styles) . "\n";
    $backendOptions = array('cache_dir' => CACHE_DIR);
    $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => null, 'automatic_serialization' => true), $backendOptions, false, false, true);
    if (isset($_GET['nocache'])) {
        $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
    }
    // ulozime datum posledni zmeny vsech souboru v xml adresari jako asociativni pole nazev_souboru => cas_zmeny
    $timestamp_cache_id = 'xml_timestamps';
    if (!($created = $cache->load($timestamp_cache_id))) {
        // smazeme radsi celou cache
        $cache->clean(Zend_Cache::CLEANING_MODE_ALL);
        $created = array();
        $files = getAllFiles($GLOBALS['xml_path']);
        foreach ($files as $file) {
            $created[basename($file)] = filectime($file);
        }
        $cache->save($created, $timestamp_cache_id);
    }
    // projdeme datum posledni zmeny u prirazenych xslt sablon a pokud nesouhlasi, smazeme cache obsahujici tuto sablonu
    foreach ($styles as $style) {
        $ctime = filectime($GLOBALS['xml_path'] . $style);
        if ($ctime != $created[$style]) {
            // smazeme cache obsahujici tuto sablonu
            $cache->clean(Zend_Cache::CLEANING_MODE_MATCHING_TAG, array(getMyTag($style)));
            // aktualizujeme datum
            $created[$style] = $ctime;
        }
        // ulozime cache obsahujici nove datum posledni zmeny xml
        $cache->save($created, $timestamp_cache_id);
    }
    // cacheId vytvoreno jako hash xml obsahu a jazyk
    // @todo zde se nekontroluje uzivatelsky vstup lang, zda je povolen
    $lang = isset($_REQUEST['lang']) ? $_REQUEST['lang'] : '';
    if (!empty($lang)) {
        $GLOBALS['xmlinfomsg'] .= "Language from URL {$lang}\n";
    }
    if (empty($lang)) {
        $user = JFactory::getUser();
        $language = $user->getParam('language');
        $lang = substr($language, 0, 2);
        if (!empty($lang)) {
            $GLOBALS['xmlinfomsg'] .= "Setting user language {$lang}\n";
        }
    }
    // default transformation language is set in the xslt transformation
    $xml_params = array();
    foreach ($_GET as $key => $val) {
        if (substr($key, 0, 5) == "xslt_") {
            $mykey = substr($key, 5);
            $xml_params[$mykey] = $val;
        }
    }
    $cache_id = md5($xml->saveXML() . $lang . implode("_", $xml_params));
    if (!($result = $cache->load($cache_id))) {
        $tags = array();
        foreach ($styles as $style) {
            // otaguj cache pouzitou sablonou
            $tags[] = getMyTag($style);
            $xsl = new DOMDocument();
            $xsl->load($GLOBALS['xml_path'] . $style);
            $processor = new XSLTProcessor();
            $processor->importStyleSheet($xsl);
            if (!empty($lang)) {
                $processor->setParameter('', 'reportLang', $lang);
            }
            foreach ($xml_params as $key => $val) {
                $processor->setParameter('', $key, $val);
            }
            $xml = $processor->transformToDOC($xml);
        }
        // timto zpusobem vypustime uvodni xml deklaraci
        $result = '';
        foreach ($xml->childNodes as $node) {
            $result .= $xml->saveXML($node) . "\n";
        }
        $cache->save($result, $cache_id, $tags);
    }
    return $result;
}
Ejemplo n.º 13
0
    //is file exist
    if (file_exists($file_path)) {
        if ($fp = fopen($file_path, "a+")) {
            //read file
            $conn = fread($fp, filesize($file_path));
            return $conn;
        } else {
            die("file open fail.\n");
        }
    } else {
        die("no file exist.\n");
    }
    fclose($fp);
    return null;
}
$res_files = getAllFiles($res_dir);
for ($i = 0; $i < count($res_files); $i++) {
    $file_content = readAllFile($res_dir . "/" . $res_files[$i]);
    $now_content[substr($res_files[$i], 1)] = md5($file_content);
}
foreach ($now_content as $key => $value) {
    $file_name = $key;
    if (!array_key_exists($file_name, $version_content)) {
        $new_content[] = ["file" => $key, "md5" => $value, "operate" => "new"];
        continue;
    } else {
        if ($version_content[$key] != $value) {
            $new_content[] = ["file" => $key, "md5" => $value, "operate" => "update"];
        }
    }
}
Ejemplo n.º 14
0
        <legend>Upload your image</legend>
        <form action="<?php 
echo $_SERVER['PHP_SELF'];
?>
" method="POST" enctype="multipart/form-data" >
            <input type="file" name="image[]" multiple>
            <input type="submit"  value="Upload images" name="submit">
            <p><?php 
echo $message ?? '';
?>
</p>
        </form>
    </fieldset>
    <div id="content">
        <?php 
if ($allFiles = getAllFiles($targetPath)) {
    ?>
            <?php 
    foreach ($allFiles as $num => $file) {
        ?>
                <img src="<?php 
        echo $targetPath . '/' . $file;
        ?>
" alt="изображение-<?php 
        echo $num + 1;
        ?>
">
            <?php 
    }
    ?>
        <?php 
Ejemplo n.º 15
0
 public static function listcase($matcher = "*")
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . "../../conf/config.php";
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'filehelper.php';
     $testdir = ConfigTest::$testdir;
     $caselist = array();
     $caselist = array_merge($caselist, getAllFiles($testdir, "\\.js\$", "fet"));
     foreach ($caselist as $caseitem) {
         if (!preg_match("/import\\.js/", $caseitem)) {
             /*将文件名替换为域名方式,替换/为.,移除.js*/
             $caseitem = str_replace($testdir, "", $caseitem);
             //$name = str_replace( '/' , '.' , substr( $caseitem , 0 , -3 ) );
             $name = substr($caseitem, 0, -3);
             //为了支持xx.xx.js类型的文件名而修改 田丽丽
             $c = new Testcase($name);
             if ($c->empty) {
                 continue;
             }
             $c->case_id = "id_case_" . str_replace('.', '__', $name);
             /* jiangshuguang 支持批量过滤,例如filter=webapp只保留webapp的所有的case*/
             //                    if(!strpos($matcher,"/") && $matcher!="*"){
             //                        $mod=explode("/",$name);
             //                        if($mod[0]==$matcher){
             //                              print( "<a href=\"run.php?case=$name\" id=\"$c->case_id\" class=\"jsframe_qunit\" target=\"_blank\" title=\"$name\" onclick=\"run('$name');\$J('#id_rerun').html('$name');return false;\">"
             //                                  . $name . "</a>\n" );
             //                          }
             //                    }else{
             if ($c->match($matcher)) {
                 print "<a href=\"run.php?case={$name}\" id=\"{$c->case_id}\" class=\"jsframe_qunit\" target=\"_blank\" title=\"{$name}\" onclick=\"run('{$name}');\$J('#id_rerun').html('{$name}');return false;\">" . $name . "</a>\n";
             }
             //                    }
         }
     }
 }
Ejemplo n.º 16
0
 private function getAllFiles($directory, $recursive = true)
 {
     $result = array();
     if (is_dir($directory)) {
         $handle = opendir($directory);
         while ($datei = readdir($handle)) {
             if ($datei != '.' && $datei != '..') {
                 $file = $directory . $datei;
                 if (is_dir($file)) {
                     if ($recursive) {
                         $result = array_merge($result, getAllFiles($file . '/'));
                     }
                 } else {
                     $result[] = $file;
                 }
             }
         }
         closedir($handle);
     }
     return $result;
 }
Ejemplo n.º 17
0
function getAllFiles($path)
{
    $list = array();
    foreach (glob($path . '/*') as $item) {
        if (is_dir($item)) {
            $list = array_merge($list, getAllFiles($item));
        } else {
            //if(eregi(".php",$item)){}//这里可以增加判断文件名或其他。changed by:edlongren
            $list[] = $item;
        }
    }
    return $list;
}
Ejemplo n.º 18
0
<?php

function getAllFiles($path)
{
    $dataArr = scandir($path);
    foreach ($dataArr as $data) {
        if (is_dir($data)) {
            continue;
        }
        $files[] = $data;
    }
    return sizeof($files) ? $files : false;
}
$allFiles = getAllFiles('.');
foreach ($allFiles as $file) {
    echo $file . '<br>';
}