コード例 #1
0
 public function get_wp_version($version_file)
 {
     // Checking the current site version
     if (!file_exists($version_file)) {
         // couldn't find version file
         return false;
     }
     //parse version file for version information
     $version = preg_find("#\\\$wp_version\\s*=\\s*['\"]([^'\"]+)['\"];#ms", file_get_contents($version_file));
     return $version;
 }
コード例 #2
0
ファイル: logs.php プロジェクト: pradyumnasagar/pratechsha
 // Credit for this goes to Ciprian Murariu <*****@*****.**>.
 $yu = './logs';
 #define which year you want to read
 $yrsu = preg_find('/./', $yu, PREG_FIND_DIRONLY | PREG_FIND_SORTKEYS | PREG_FIND_SORTDESC);
 rsort($yrsu);
 foreach ($yrsu as $yru) {
     $yeardiru = str_replace($yu . "/", '', $yru);
     if ($yeardiru > date('Y')) {
         continue;
     }
     echo "<table BORDER=1 CELLSPACING=0 CELLPADDING=0 class=table><tr>";
     echo "<td valign=top align=center nowrap=\"nowrap\" colspan=6><font size=4 color=red><b>{$yeardiru}</b></font></td>";
     #print name of each file found
     $mu = $yu . "/" . $yeardiru;
     #define which month you want to read
     $mtsu = preg_find('/./', $mu, PREG_FIND_DIRONLY | PREG_FIND_RETURNASSOC | PREG_FIND_SORTMODIFIED | PREG_FIND_SORTKEYS | PREG_FIND_SORTDESC);
     $dateu1 = mktime(0, 0, 0, date('m'), 1, date('Y'));
     foreach ($mtsu as $mtu => $stats) {
         $monthdiru = str_replace($mu . "/", '', $mtu);
         $dateu2 = strtotime("01 " . $monthdiru . " " . $yeardiru);
         if ($dateu1 < $dateu2) {
             continue;
         }
         switch ($monthdiru) {
             case 'Jan':
                 $MONTHU = L_JAN;
                 break;
             case 'Feb':
                 $MONTHU = L_FEB;
                 break;
             case 'Mar':
コード例 #3
0
ファイル: preg_find.php プロジェクト: epleterte/OsmAnd-misc
function preg_find($pattern, $start_dir = '.', $args = NULL)
{
    static $depth = -1;
    ++$depth;
    $files_matched = array();
    $fh = opendir($start_dir);
    while (($file = readdir($fh)) !== false) {
        if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0) {
            continue;
        }
        $filepath = $start_dir . '/' . $file;
        if (preg_match($pattern, $args & PREG_FIND_FULLPATH ? $filepath : $file)) {
            $doadd = is_file($filepath) || is_dir($filepath) && $args & PREG_FIND_DIRMATCH || is_dir($filepath) && $args & PREG_FIND_DIRONLY;
            if ($args & PREG_FIND_DIRONLY && $doadd && !is_dir($filepath)) {
                $doadd = false;
            }
            if ($args & PREG_FIND_NEGATE) {
                $doadd = !$doadd;
            }
            if ($doadd) {
                if ($args & PREG_FIND_RETURNASSOC) {
                    // return more than just the filenames
                    $fileres = array();
                    if (function_exists('stat')) {
                        $fileres['stat'] = stat($filepath);
                        $fileres['du'] = $fileres['stat']['blocks'] * 512;
                    }
                    if (function_exists('fileowner')) {
                        $fileres['uid'] = fileowner($filepath);
                    }
                    if (function_exists('filegroup')) {
                        $fileres['gid'] = filegroup($filepath);
                    }
                    if (function_exists('filetype')) {
                        $fileres['filetype'] = filetype($filepath);
                    }
                    if (function_exists('mime_content_type')) {
                        $fileres['mimetype'] = mime_content_type($filepath);
                    }
                    if (function_exists('dirname')) {
                        $fileres['dirname'] = dirname($filepath);
                    }
                    if (function_exists('basename')) {
                        $fileres['basename'] = basename($filepath);
                    }
                    if (($i = strrpos($fileres['basename'], '.')) !== false) {
                        $fileres['ext'] = substr($fileres['basename'], $i + 1);
                    } else {
                        $fileres['ext'] = '';
                    }
                    if (isset($fileres['uid']) && function_exists('posix_getpwuid')) {
                        $fileres['owner'] = posix_getpwuid($fileres['uid']);
                    }
                    $files_matched[$filepath] = $fileres;
                } else {
                    array_push($files_matched, $filepath);
                }
            }
        }
        if (is_dir($filepath) && $args & PREG_FIND_RECURSIVE) {
            if (!is_link($filepath) || $args & PREG_FIND_FOLLOWSYMLINKS) {
                $files_matched = array_merge($files_matched, preg_find($pattern, $filepath, $args));
            }
        }
    }
    closedir($fh);
    // Before returning check if we need to sort the results.
    if ($depth == 0 && $args & (PREG_FIND_SORTKEYS | PREG_FIND_SORTBASENAME | PREG_FIND_SORTMODIFIED | PREG_FIND_SORTFILESIZE | PREG_FIND_SORTDISKUSAGE)) {
        $order = $args & PREG_FIND_SORTDESC ? 1 : -1;
        $sortby = '';
        if ($args & PREG_FIND_RETURNASSOC) {
            if ($args & PREG_FIND_SORTMODIFIED) {
                $sortby = "['stat']['mtime']";
            }
            if ($args & PREG_FIND_SORTBASENAME) {
                $sortby = "['basename']";
            }
            if ($args & PREG_FIND_SORTFILESIZE) {
                $sortby = "['stat']['size']";
            }
            if ($args & PREG_FIND_SORTDISKUSAGE) {
                $sortby = "['du']";
            }
            if ($args & PREG_FIND_SORTEXTENSION) {
                $sortby = "['ext']";
            }
        }
        $filesort = create_function('$a,$b', "\$a1=\$a{$sortby};\$b1=\$b{$sortby}; if (\$a1==\$b1) return 0; else return (\$a1<\$b1) ? {$order} : 0- {$order};");
        uasort($files_matched, $filesort);
    }
    --$depth;
    return $files_matched;
}
コード例 #4
0
ファイル: convert.php プロジェクト: jphpsf/gregarius
function preg_find($pattern, $start_dir = '.', $args = NULL)
{
    $files_matched = array();
    $fh = opendir($start_dir);
    while (($file = readdir($fh)) !== false) {
        if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0) {
            continue;
        }
        $filepath = $start_dir . '/' . $file;
        if (preg_match($pattern, $args & PREG_FIND_FULLPATH ? $filepath : $file)) {
            $doadd = is_file($filepath) || is_dir($filepath) && $args & PREG_FIND_DIRMATCH || is_dir($filepath) && $args & PREG_FIND_DIRONLY;
            if ($args & PREG_FIND_DIRONLY && $doadd && !is_dir($filepath)) {
                $doadd = false;
            }
            if ($args & PREG_FIND_NEGATE) {
                $doadd = !$doadd;
            }
            if ($doadd) {
                if ($args & PREG_FIND_RETURNASSOC) {
                    // return more than just the filenames
                    $fileres = array();
                    if (function_exists('stat')) {
                        $fileres['stat'] = stat($filepath);
                        $fileres['du'] = $fileres['stat']['blocks'] * 512;
                    }
                    if (function_exists('fileowner')) {
                        $fileres['uid'] = fileowner($filepath);
                    }
                    if (function_exists('filegroup')) {
                        $fileres['gid'] = filegroup($filepath);
                    }
                    if (function_exists('filetype')) {
                        $fileres['filetype'] = filetype($filepath);
                    }
                    if (function_exists('mime_content_type')) {
                        $fileres['mimetype'] = mime_content_type($filepath);
                    }
                    if (function_exists('dirname')) {
                        $fileres['dirname'] = dirname($filepath);
                    }
                    if (function_exists('basename')) {
                        $fileres['basename'] = basename($filepath);
                    }
                    if (isset($fileres['uid']) && function_exists('posix_getpwuid ')) {
                        $fileres['owner'] = posix_getpwuid($fileres['uid']);
                    }
                    $files_matched[$filepath] = $fileres;
                } else {
                    array_push($files_matched, $filepath);
                }
            }
        }
        if (is_dir($filepath) && $args & PREG_FIND_RECURSIVE) {
            $files_matched = array_merge($files_matched, preg_find($pattern, $filepath, $args));
        }
    }
    closedir($fh);
    return $files_matched;
}
コード例 #5
0
ファイル: builds.php プロジェクト: epleterte/OsmAnd-misc
            $type = "OsmAnd";
        } else {
            continue;
        }
        if (stripos($fname, "-nb-") !== false) {
            $tag = preg_replace("/[^-]*-(.*)-nb.*/i", "\$1", $fname);
        } else {
            $tag = preg_replace("/[^-]*-([^\\.]*).*/i", "\$1", $fname);
        }
        $size = round(filesize($file) / 1048576, 1);
        $date = date("d.m.Y", filemtime($file));
        $timestamp = filemtime($file);
        $build = $output->createElement("build");
        $outputIndexes->appendChild($build);
        $build->setAttribute("size", $size);
        $build->setAttribute("date", $date);
        $build->setAttribute("timestamp", $timestamp * 1000);
        $build->setAttribute("tag", $tag . $tag_suffix);
        $build->setAttribute("type", $type);
        $build->setAttribute("path", $file);
    }
}
$output = new DOMDocument();
$output->formatOutput = true;
$outputIndexes = $output->createElement("builds");
$output->appendChild($outputIndexes);
$files = preg_find('/./', 'latest-night-build', PREG_FIND_RETURNASSOC | PREG_FIND_SORTDESC | PREG_FIND_SORTMODIFIED);
addBuilds($files, $output, $outputIndexes);
$files = preg_find('/./', 'night-builds', PREG_FIND_RETURNASSOC | PREG_FIND_SORTDESC | PREG_FIND_SORTMODIFIED);
addBuilds($files, $output, $outputIndexes, "-night-build");
echo $output->saveXML();
コード例 #6
0
ファイル: index.php プロジェクト: pipwilson/epubserver
$scriptpath[count($scriptpath) - 1] = "";
$scriptpath = implode("/", $scriptpath);
$url = "http://" . $_SERVER["SERVER_NAME"] . $scriptpath;
$scripturl = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
header('Content-type: application/xml');
//define channel
$atom = new UniversalFeedCreator();
$atom->useCached();
$atom->title = "Books in {$epubdir}";
// todo: replace with a $catalogname field
$atom->description = "epub files on my server";
$atom->link = "http://mydomain.net/";
$atom->syndicationURL = $scripturl;
// sort the files by date so the most recent is first in the feed
// preg_find(pattern, starting dir, args)
$files = preg_find('/\\.epub$/', $epubdir, PREG_FIND_RECURSIVE | PREG_FIND_RETURNASSOC | PREG_FIND_SORTBASENAME | PREG_FIND_SORTDESC);
$files = array_keys($files);
// add the files to the feed
foreach ($files as $file) {
    if (is_file($file)) {
        $ebook = new ebookRead($file);
        // entries
        $item = new FeedItem();
        $item->title = $ebook->getDcTitle();
        $item->linktype = "application/epub+zip";
        $item->link = $file;
        // <link rel="x-stanza-cover-image" type="image/jpeg" href="cover.php?filename=$file"/>
        $coverLink = new LinkItem();
        $coverLink->rel = "x-stanza-cover-image";
        $coverLink->type = "image/jpeg";
        $coverLink->href = "cover.php?filename={$file}";