public function install($filename)
 {
     $src = ROOT . '/sys/tmp/' . $filename;
     $dest = ROOT . '/sys/tmp/install_plugin/';
     Zip::extractZip($src, $dest);
     if (!file_exists($dest)) {
         $this->errors = __('Some error occurred');
         return false;
     }
     $tmp_plugin_path = glob($dest . '*', GLOB_ONLYDIR);
     $tmp_plugin_path = $tmp_plugin_path[0];
     $plugin_basename = substr(strrchr($tmp_plugin_path, '/'), 1);
     $plugin_path = ROOT . '/sys/plugins/' . $plugin_basename;
     copyr($dest, ROOT . '/sys/plugins/', 0755);
     $this->files = getDirFiles($plugin_path);
     if (file_exists($plugin_path . '/config.dat')) {
         $config = json_decode(file_get_contents($plugin_path . '/config.dat'), true);
         include_once $plugin_path . '/index.php';
         $className = $config['className'];
         $obj = new $className(null);
         if (method_exists($obj, 'install')) {
             $obj->install();
         }
     }
     _unlink($src);
     _unlink($dest);
     return true;
 }
function displaydir($dir)
{
    $tab_files = getDirFiles($dir);
    if (sizeof($tab_files) > 0) {
        echo "<ul>";
        $nb_group = sizeof($tab_files);
        $count_group = 0;
        foreach ($tab_files as $group) {
            echo "<li>";
            $count = 0;
            $taille = sizeof($group);
            if (sizeof($group) > 1) {
                echo "<button class=\"selection btn\" type=\"button\" onClick=\"doSimpleinSection(this.parentNode,true);\" value=\"tous\">tous</button>";
                echo "<button class=\"selection btn\" type=\"button\" onClick=\"doSimpleinSection(this.parentNode,false);\" value=\"aucun\">aucun</button>";
                $count_group++;
                if ($count_group == $nb_group) {
                    echo "<ul class=\"last\">";
                } else {
                    echo "<ul>";
                }
                foreach ($group as $tab_file) {
                    $count++;
                    echo "<li>";
                    if ($count == $taille) {
                        echo "<img src=\"img/joinbottom.gif\"/>";
                    } else {
                        echo "<img src=\"img/join.gif\"/>";
                    }
                    if ($tab_file != null && $tab_file["file"] != null) {
                        showFileFromDescription($tab_file);
                    }
                    echo "</li>";
                }
                echo "</ul>";
            } else {
                foreach ($group as $tab_file) {
                    $count++;
                    if ($count == $taille) {
                        echo "<img src=\"img/joinbottom.gif\"/>";
                    } else {
                        echo "<img src=\"img/join.gif\"/>";
                    }
                    if ($tab_file != null && $tab_file["file"] != null) {
                        showFileFromDescription($tab_file);
                    }
                }
            }
            echo "</li>";
        }
        echo "</ul>";
    }
}
Example #3
0
function getDirFiles($pathName, $exts, &$count)
{
    foreach (glob($pathName) as $fileName) {
        if (is_dir($fileName)) {
            getDirFiles($fileName . DIRECTORY_SEPARATOR . '*', $exts, $count);
        } else {
            if (in_array(pathinfo($fileName, PATHINFO_EXTENSION), $exts)) {
                $count++;
            }
        }
    }
    return 'Completed! Count:' . $count;
}
/**
 *
 * 生成项目的源代码WORD文档
 *
 * @author soft456@gmail.com
 * @date 2013-08-02
 * @varsion 1.0
 *
 * @copyright  Copyright (c) 2014 Wuhan Bo Sheng Education Information Co., Ltd.
 */
function getDirFiles($pathName, $exts, $outFp)
{
    foreach (glob($pathName) as $fileName) {
        if (is_dir($fileName)) {
            getDirFiles($fileName . DIRECTORY_SEPARATOR . '*', $exts, $outFp);
        } else {
            if (in_array(pathinfo($fileName, PATHINFO_EXTENSION), $exts)) {
                $data = file($fileName);
                array_unshift($data, chr(10), $fileName, chr(10), '---------------------', chr(10));
                //文件名插入数据数组开头
                echo $fileName . ':' . file_put_contents($outFp, $data, FILE_APPEND) . '<br>';
            }
        }
    }
    return 'Completed!';
}
Example #5
0
function getDirFiles($pathName, $exts, $ignoreRs = array())
{
    foreach (glob($pathName) as $fileName) {
        //忽略的目录
        $fileNameInfo = pathinfo($fileName);
        if (in_array(strtolower($fileNameInfo['basename']), $ignoreRs)) {
            continue;
        }
        //目录
        if (is_dir($fileName)) {
            echo '<br>Dir :' . $fileName . '<br>';
            getDirFiles($fileName . DIRECTORY_SEPARATOR . '*', $exts, $ignoreRs);
            continue;
        }
        //文件
        if (in_array(pathinfo($fileName, PATHINFO_EXTENSION), $exts)) {
            $commentTitle = getFileCommentTitle($fileName, 1, 10);
            echo 'File:<a href="makeClassDoc.php?btn=1&fn=' . $fileName . '" target="_blank">' . $fileName . '</a>  —— ' . $commentTitle;
            echo '<br>';
        }
    }
    return 'Completed!';
}
Example #6
0
/**
 * 取得输入目录所包含的所有文件,包括子目录
 * @var $dir
 * @return Array 文件路径
 */
function getDirFiles($dir)
{
    if (is_file($dir)) {
        return [$dir];
    }
    $files = array();
    if (is_dir($dir) && ($dir_p = opendir($dir))) {
        $ds = DIRECTORY_SEPARATOR;
        while (($filename = readdir($dir_p)) !== false) {
            if ($filename == '.' || $filename == '..') {
                continue;
            }
            $filetype = filetype($dir . $ds . $filename);
            if ($filetype == 'dir') {
                $files = array_merge($files, getDirFiles($dir . $ds . $filename));
            } elseif ($filetype == 'file') {
                $files[] = $dir . $ds . $filename;
            }
        }
        closedir($dir_p);
    }
    return $files;
}
Example #7
0
$extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname;
// load extension
if (!extension_loaded($extension)) {
    dl($extension_soname) or die("Can't load extension {$extension_fullname}\n");
}
if (php_sapi_name() != 'cli') {
    echo '<pre>';
}
printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
printf("ffmpeg-php build date string: %s\n", FFMPEG_PHP_BUILD_DATE_STRING);
printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
print_class_methods("ffmpeg_movie");
print_class_methods("ffmpeg_frame");
// get an array for movies from the test media directory
$movies = getDirFiles(dirname(__FILE__) . '/tests/test_media');
echo "--------------------\n\n";
foreach ($movies as $movie) {
    $mov = new ffmpeg_movie($movie);
    printf("file name = %s\n", $mov->getFileName());
    printf("duration = %s seconds\n", $mov->getDuration());
    printf("frame count = %s\n", $mov->getFrameCount());
    printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
    printf("comment = %s\n", $mov->getComment());
    printf("title = %s\n", $mov->getTitle());
    printf("author = %s\n", $mov->getAuthor());
    printf("copyright = %s\n", $mov->getCopyright());
    printf("get bit rate = %d\n", $mov->getBitRate());
    printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
    if ($mov->hasAudio()) {
        printf("get audio stream id= %s\n", $mov->getAudioStreamId());
Example #8
0
function main()
{
    global $argc;
    global $argv;
    if ($argc == 1) {
        help();
        exit;
    }
    $command = $argv[1];
    $commandParam = $argc > 2 ? $argv[2] : '';
    switch ($command) {
        case 'g':
        case 'generate':
            if (0 == strlen($commandParam)) {
                die('should provide the migration name');
            }
            @mkdir(dirName);
            $fileName = dirName . date('Y_m_d_H_i_s') . '_' . $commandParam . '.sql';
            $file = fopen($fileName, 'w+');
            // Now UTF-8 - Add byte order mark
            fwrite($file, pack('CCC', 0xef, 0xbb, 0xbf));
            fclose($file);
            print 'generate  ' . $fileName . '  done , add your sql statement please' . PHP_EOL;
            break;
        case 'm':
        case 'migrate':
            $configs = getDirFiles(configDir);
            if (count($configs) > 1) {
                if (empty($commandParam)) {
                    print 'choose the config to use ' . PHP_EOL;
                    print_r($configs);
                    print PHP_EOL;
                    die('multi config file found ,must specify one with the config file name ,for example: php -f msmt.php m default.php');
                }
                include configDir . '/' . $commandParam;
            } else {
                include configDir . '/' . $configs[0];
            }
            global $useMysqli;
            checkDBParam($dbHost, '$dbHost');
            checkDBParam($dbUser, '$dbUser');
            checkDBParam($dbPwd, '$dbPwd');
            checkDBParam($dbName, '$dbName');
            // read all the schema migrations sql files
            $migrations = getDirFiles(dirName);
            sort($migrations);
            // connect ,may be create the database
            if ($useMysqli) {
                $conn = mysqli_init();
                if (!mysqli_real_connect($conn, $dbHost, $dbUser, $dbPwd)) {
                    die('connect to db failed,check your db configuration');
                }
            } else {
                $conn = mysql_connect($dbHost, $dbUser, $dbPwd);
            }
            if (!$conn) {
                die('connect to db failed,check your db configuration');
            }
            $res = select_db($conn, $dbName);
            if (!$res) {
                print 'can not find database [' . $dbName . '] ,create it for you' . PHP_EOL;
                $query = 'create database ' . $dbName;
                $res = query($query, $conn);
                if (!$res) {
                    die('create database [' . $dbName . '] failed ' . error($conn));
                }
                $res = select_db($conn, $dbName);
            }
            // read the logs,may be create the schema__migrations table
            $query = 'show tables like "' . schemaMigrationTable . '"';
            $res = query($query, $conn);
            $hasTable = false;
            if ($res) {
                while ($row = $useMysqli ? mysqli_fetch_row($res) : mysql_fetch_row($res)) {
                    if ($row[0] == schemaMigrationTable) {
                        $hasTable = true;
                        break;
                    }
                }
            }
            if (!$hasTable) {
                $res = query('create table ' . schemaMigrationTable . ' (version varchar(50) not null,created_at datetime not null);', $conn);
                if (!$res) {
                    die(' fail to create the ' . schemaMigrationTable . ' table,' . error($conn));
                }
                print 'create ' . schemaMigrationTable . ' done' . PHP_EOL;
            }
            $res = query('select version from ' . schemaMigrationTable, $conn);
            if (debug) {
                print 'all migrate sql file list as below:' . PHP_EOL;
                print_r($migrations);
            }
            // filter to find the never executed migrations
            while ($row = $useMysqli ? mysqli_fetch_row($res) : mysql_fetch_row($res)) {
                $version = $row[0];
                if (debug) {
                    print 'exists version:' . $version . PHP_EOL;
                }
                kickout($migrations, $version);
            }
            if (debug) {
                print 'after kick out , migrate list as below:' . PHP_EOL;
                print_r($migrations);
            }
            // apply the migrations
            foreach ($migrations as $migrate) {
                print 'apply migrate ' . $migrate . PHP_EOL;
                $sql_arr = file(dirName . $migrate);
                $isMulti = count($sql_arr) > 1;
                if (empty($sql_arr)) {
                    print $migrate . ' is empty ,pass it ' . PHP_EOL;
                    continue;
                } else {
                    if ($isMulti) {
                        if (!function_exists('mysqli_multi_query')) {
                            die('need mysqli extension to support multi query');
                        }
                    }
                }
                $sql_all = file_get_contents(dirName . $migrate);
                // Remove UTF-8 BOM if present
                if (substr($sql_all, 0, 3) == pack('CCC', 0xef, 0xbb, 0xbf)) {
                    $sql_all = substr($sql_all, 3);
                }
                $queryRes = $isMulti ? mysqli_multi_query($conn, $sql_all) : query($sql_all, $conn);
                if ($isMulti) {
                    do {
                        // Store first result set
                        if ($result = mysqli_store_result($conn)) {
                            while ($row = mysqli_fetch_row($result)) {
                                printf('%sn', $row[0]);
                            }
                            mysqli_free_result($conn);
                        }
                    } while (mysqli_next_result($conn));
                }
                if (!$queryRes) {
                    die('apply migrate ' . $migrate . ' failed, error sql statement .' . $sql_all . ',error info: ' . error($conn));
                }
                // add the version record when executed success
                print 'apply migrate ' . $migrate . ' success ' . PHP_EOL;
                $sql_version = 'insert into ' . schemaMigrationTable . ' values ("' . $migrate . '",now());';
                print $sql_version . PHP_EOL;
                $queryRes = query($sql_version, $conn);
                if (!$queryRes) {
                    die('fail to insert the migration version,error:' . error($conn));
                }
            }
            print 'migrate finished successfully!';
            $useMysqli ? mysqli_close($conn) : mysql_close($conn);
            break;
        default:
            print 'unsupport command ' . PHP_EOL;
            help();
            exit;
    }
}
$ignore_demo_files = true;
$dir = dirname(dirname(dirname(dirname(__FILE__))));
require_once $dir . '/examples/example-config.php';
$tmp_dir = PHPVIDEOTOOLKIT_EXAMPLE_ABSOLUTE_BATH . 'tmp/';
// printf("ffmpeg-php version string: %s\n", FFMPEG_PHP_VERSION_STRING);
// printf("libavcodec build number: %d\n", LIBAVCODEC_BUILD_NUMBER);
// printf("libavcodec version number: %d\n", LIBAVCODEC_VERSION_NUMBER);
echo "--------------------";
print_class_methods("ffmpeg_movie");
echo "\n\n--------------------";
print_class_methods("ffmpeg_frame");
echo "\n\n--------------------";
print_class_methods("ffmpeg_animated_gif");
echo "\n\n--------------------\n";
// get an array for movies from the test media directory
$movies = getDirFiles($dir . '/examples/to-be-processed');
// print_r($movies);
foreach ($movies as $movie) {
    $mov = new PHPVideoToolkit_movie($movie, false, $tmp_dir);
    printf("file name = %s\n", $mov->getFileName());
    printf("duration = %s seconds\n", $mov->getDuration());
    printf("frame count = %s\n", $mov->getFrameCount());
    printf("frame rate = %0.3f fps\n", $mov->getFrameRate());
    printf("comment = %s\n", $mov->getComment());
    printf("title = %s\n", $mov->getTitle());
    printf("author = %s\n", $mov->getAuthor());
    printf("copyright = %s\n", $mov->getCopyright());
    printf("get bit rate = %d\n", $mov->getBitRate());
    printf("has audio = %s\n", $mov->hasAudio() == 0 ? 'No' : 'Yes');
    if ($mov->hasAudio()) {
        printf("get audio codec = %s\n", $mov->getAudioCodec());
Example #10
0
			<h3>Files <small><a href="javascript:;" onclick="refreshPage();"><span class="glyphicon glyphicon-refresh text-success"></span></a></small></h3>

			<table class="footable table">
				<thead>
					<tr>
						<th>File</th>
						<th data-hide="phone">Size</th>
						<th>Type</th>
						<th data-hide="phone,tablet">Date</th>
						<th>Action</th>
					</tr>
				</thead>
				<tbody>
<?php 
$ignored_childs = array('expimp');
$dir_files = getDirFiles(LEUPLOAD_STORE, 1, 2, $ignored_childs);
$records_per_page = $LEUPLOAD_PERPAGE_LIST;
$pagination = new Zebra_Pagination();
$pagination->records(count($dir_files));
$pagination->records_per_page($records_per_page);
$pagination->labels('<span class="glyphicon glyphicon-chevron-left"></span>', '<span class="glyphicon glyphicon-chevron-right"></span>');
$dir_files = array_slice($dir_files, ($pagination->get_page() - 1) * $records_per_page, $records_per_page);
foreach ($dir_files as $k => $v) {
    ?>
					<tr>
						<td><a href="javascript:;" class="leupload_link" data-leupload-form="<?php 
    echo $pf;
    ?>
" data-leupload-link-model="<?php 
    echo $pm;
    ?>
Example #11
0
$result = array_diff($currJobs, $remJobs);
# Add Jobs
foreach ($addJobs as $k => $v) {
    $result[] = $v;
}
# Get Backup ?
# Save Jobs
exec("crontab -r");
$letChr->saveJobs($result);
$debugs[] = '* Cron Tab Updated';
/* Clear Resource Caches */
$fileCounts = 0;
$opOrgs = $myconn->query("SELECT * FROM " . db_table_pref . "organizations") or die(mysqli_error($myconn));
while ($opOrgsRs = $opOrgs->fetch_assoc()) {
    $orgFold = LETHE_RESOURCE . DIRECTORY_SEPARATOR . $opOrgsRs['orgTag'] . '/expimp';
    $fileList = getDirFiles($orgFold);
    $now = time();
    $days = 1;
    foreach ($fileList as $k => $v) {
        if ($v['file_date'] < $now - 60 * 60 * 24 * $days) {
            if (unlink($orgFold . DIRECTORY_SEPARATOR . $v['file_name'])) {
                $fileCounts++;
            }
        }
    }
}
$opOrgs->free();
$debugs[] = '* ' . $fileCounts . ' Cache File Removed';
if (lethe_debug_mode) {
    echo implode(PHP_EOL, $debugs);
}
Example #12
0
  
  <h1><?php 
echo gettext("Rule viewer");
?>
</h1>

<?php 
require_once 'ossim_conf.inc';
require_once 'dir.php';
$ossim_conf = $GLOBALS["CONF"];
$snort_rules_path = $ossim_conf->get_conf("snort_rules_path");
?>

  <table align="center">
<?php 
$files = getDirFiles($snort_rules_path);
/* local snort rule directory */
if ($files == NULL) {
    require_once "ossim_error.inc";
    $error = new OssimError();
    $error->display("RULES_NOT_FOUND", array($snort_rules_path));
}
foreach ($files as $file) {
    /* only show .rules files */
    $f = split("\\.", $file);
    if ($f[1] == 'rules') {
        ?>
    <tr><td>
    <a href="rule.php?name=<?php 
        echo $file;
        ?>
Example #13
0
 private function getFileNames()
 {
     return getDirFiles($this->extractTo, 'tcx');
 }
/**
* Delete a language
* also called on Langupdate
*/
function AdmCenterLangDelete($langId)
{
    global $smcFunc, $settings, $pmxCacheFunc;
    $failed = false;
    $removeSet = getInstalledLanguages($langId);
    // do not remove files an a manually installed language
    if (empty($removeSet['manually'])) {
        $removeSet = array_merge($removeSet, array('subdir' => '/Blocks'));
        $themePaths = array($settings['default_theme_dir'] . '/languages/PortaMx');
        foreach ($themePaths as $themePath) {
            if (is_dir($themePath)) {
                $files = array();
                getDirFiles($files, $themePath, $removeSet['langext'] . '.php');
                // now remove found files
                foreach ($files as $file) {
                    if (file_exists($file)) {
                        if (!is_writable($file)) {
                            @chmod($file, 0644);
                            if (!is_writable($file)) {
                                @chmod($file, 0777);
                            }
                        }
                        if (!unlink($file)) {
                            $failed = true;
                            break;
                        }
                    }
                }
            } else {
                $failed = true;
            }
        }
    }
    if (empty($failed)) {
        sleep(1);
        // remove the language from installed if not baselang
        if ($langId != 'lang.english') {
            // remove the language from installed
            $smcFunc['db_query']('', '
					DELETE FROM {db_prefix}portamx_settings
					WHERE varname = {string:id}', array('id' => $langId));
        }
        // clear the filecache and redirect exit
        $pmxCacheFunc['clean']();
    }
    return $failed;
}
Example #15
0
        $vfd->saveAs( $files[$i] . '.gpx', $url );
        echo 'Saved: ' . $files[$i] . '.gpx';
    }else{
        echo $url;
    }
    echo '</td></tr>';
    flush();
}
echo '</tbody></table><br/>';
*/
echo 'Done!';
flush();
$aGPXFiles = getDirFiles($paths['trackDir'], 'gpx');
$aTCXFiles = getDirFiles($paths['trackDir'], 'tcx');
$aTCXFiles = array_merge($aTCXFiles, getDirFiles($paths['dataDir'], 'tcx'));
$aZipFiles = getDirFiles($paths['dataDir'], 'zip');
$allTempFiles = array_merge($aGPXFiles, $aTCXFiles, $aZipFiles);
echo 'Compressing converted files.<br/>';
$zipFileName = $ffGPXFileName . '.zip';
$zipFile = $paths['convertedDir'] . $zipFileName;
$tmpArray = array();
for ($i = 0, $l = count($aGPXFiles), $dir = $paths['trackDir']; $i < $l; $i++) {
    $tmpArray[] = $dir . $aGPXFiles[$i];
}
$suc = create_zip($tmpArray, $zipFile, true, false);
if ($suc) {
    echo 'Your file is ready to <a href="data/converted/' . $zipFileName . '">download</a>.<br/>';
} else {
    echo 'Error zipping.<pre>';
    var_dump($tmpArray);
    var_dump($zipFile);
Example #16
0
 logToFile('Converting located in - ' . $trackDir);
 for ($i = 0, $l = count($aFiles); $i < $l; $i++) {
     logToFile("\tConverting file - " . $aFiles[$i] . "\n");
     $url = $cvtr->convert($trackDir . $aFiles[$i]);
     if ($url) {
         $vfd->saveAs($aFiles[$i] . '.gpx', $url);
         logToFile("\t\tSaving file - " . $aFiles[$i] . "\n");
     }
 }
 //cur2:
 $aGPXFiles = getDirFiles($trackDir, 'gpx');
 $aTCXFiles = getDirFiles($trackDir, 'tcx');
 $aTCXFiles = array_merge($aTCXFiles, getDirFiles($dataDir, 'tcx'));
 $aZipFiles = getDirFiles($dataDir, 'zip');
 $aDTCXFiles = getDirFiles($dataDir, 'tcx');
 $aTrackFiles = getDirFiles($trackDir, 'zip');
 $allTempFiles = array_merge($aGPXFiles, $aTCXFiles, $aZipFiles);
 $zipFileName = basename($tmpFileName) . '.zip';
 $zipFile = $convertedDir . $zipFileName;
 $tmpArray = array();
 for ($i = 0, $l = count($aGPXFiles), $dir = $trackDir; $i < $l; $i++) {
     $tmpArray[] = $dir . $aGPXFiles[$i];
 }
 $suc = create_zip($tmpArray, $zipFile, true, false);
 if ($suc) {
     $response['convertedFile'] = 'data/converted/' . $user->user_id . '/' . $zipFileName;
 } else {
     logToFile('Error zipping.');
     array_push($response['errors'], 'Error zipping.');
     array_push($response['errors'], $zipFile);
     array_push($response['errors'], implode(',', $tmpArray));