本文整理汇总了PHP中checkDirectory函数的典型用法代码示例。如果您正苦于以下问题:PHP checkDirectory函数的具体用法?PHP checkDirectory怎么用?PHP checkDirectory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了checkDirectory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkDirectory
function checkDirectory(&$dir)
{
if (substr($dir, -1) !== '/') {
//append slash
$dir .= '/';
}
$dirHandle = opendir($dir);
if ($dirHandle !== false) {
while (($file = readdir($dirHandle)) !== false) {
if ($file !== '..' && $file !== '.') {
$fullfilename = $dir . $file;
if (is_dir($fullfilename) === false) {
//check file for BOM
echo $fullfilename;
if (isUTF8BOM($fullfilename) !== false) {
echo ' contains BOM';
} else {
echo ' does not contain BOM';
}
echo PHP_EOL;
} else {
//check next directory
checkDirectory($fullfilename);
}
}
}
closedir($dirHandle);
}
}
示例2: checkIncomingPath
/**
* Checks for the location of the incoming directory
* If it does not exist, then it creates it.
*/
function checkIncomingPath()
{
global $cfg;
switch ($cfg["enable_home_dirs"]) {
case 1:
default:
// is there a user dir?
checkDirectory($cfg["path"] . $cfg["user"], 0777);
break;
case 0:
// is there a incoming dir?
checkDirectory($cfg["path"] . $cfg["path_incoming"], 0777);
break;
}
}
示例3: backupCreate
/**
* backup of flux-installation
*
* @param $talk: boolean if function should talk
* @param $compression: 0 = none | 1 = gzip | 2 = bzip2
* @return string with name of backup-archive, string with "" in error-case.
*/
function backupCreate($talk = false, $compression = 0)
{
global $cfg, $error;
// backup-dir
$dirBackup = $cfg["path"] . _DIR_BACKUP;
if (!checkDirectory($dirBackup)) {
$error = "Errors when checking/creating backup-dir: " . tfb_htmlencodekeepspaces($dirBackup);
return "";
}
// files and more strings
$backupName = "backup_" . _VERSION . "_" . date("YmdHis");
$fileArchiveName = $backupName . ".tar";
$tarSwitch = "-cf";
switch ($compression) {
case 1:
$fileArchiveName .= ".gz";
$tarSwitch = "-zcf";
break;
case 2:
$fileArchiveName .= ".bz2";
$tarSwitch = "-jcf";
break;
}
// files
$files = array();
$files['archive'] = $dirBackup . '/' . $fileArchiveName;
$files['db'] = $dirBackup . '/database.sql';
$files['docroot'] = $dirBackup . '/docroot.tar';
$files['transfers'] = $dirBackup . '/transfers.tar';
$files['fluxd'] = $dirBackup . '/fluxd.tar';
$files['mrtg'] = $dirBackup . '/mrtg.tar';
// exec
$exec = array();
$exec['transfers'] = @is_dir($cfg["transfer_file_path"]) === true;
$exec['fluxd'] = @is_dir($cfg["path"] . '.fluxd') === true;
$exec['mrtg'] = @is_dir($cfg["path"] . '.mrtg') === true;
// commands
$commands = array();
$commands['archive'] = "cd " . tfb_shellencode($dirBackup) . "; tar " . $tarSwitch . " " . $fileArchiveName . " ";
$commands['db'] = "";
switch ($cfg["db_type"]) {
case "mysql":
$commands['db'] = "mysqldump -h " . tfb_shellencode($cfg["db_host"]) . " -u " . tfb_shellencode($cfg["db_user"]) . " --password=" . tfb_shellencode($cfg["db_pass"]) . " --all -f " . tfb_shellencode($cfg["db_name"]) . " > " . tfb_shellencode($files['db']);
$commands['archive'] .= 'database.sql ';
break;
case "sqlite":
$commands['db'] = "sqlite " . tfb_shellencode($cfg["db_host"]) . " .dump > " . tfb_shellencode($files['db']);
$commands['archive'] .= 'database.sql ';
break;
case "postgres":
$commands['db'] = "pg_dump -h " . tfb_shellencode($cfg["db_host"]) . " -D " . tfb_shellencode($cfg["db_name"]) . " -U " . tfb_shellencode($cfg["db_user"]) . " -f " . tfb_shellencode($files['db']);
$commands['archive'] .= 'database.sql ';
break;
}
$commands['archive'] .= 'docroot.tar';
if ($exec['transfers'] === true) {
$commands['archive'] .= ' transfers.tar';
}
if ($exec['fluxd'] === true) {
$commands['archive'] .= ' fluxd.tar';
}
if ($exec['mrtg'] === true) {
$commands['archive'] .= ' mrtg.tar';
}
//$commands['docroot'] = "cd ".tfb_shellencode($dirBackup)."; tar -cf docroot.tar ".tfb_shellencode($cfg["docroot"]); // with path of docroot
$commands['docroot'] = "cd " . tfb_shellencode($cfg["docroot"]) . "; tar -cf " . tfb_shellencode($files['docroot']) . " .";
// only content of docroot
$commands['transfers'] = "cd " . tfb_shellencode($cfg["transfer_file_path"]) . "; tar -cf " . tfb_shellencode($files['transfers']) . " .";
$commands['fluxd'] = "cd " . tfb_shellencode($cfg["path"] . '.fluxd') . "; tar -cf " . tfb_shellencode($files['fluxd']) . " .";
$commands['mrtg'] = "cd " . tfb_shellencode($cfg["path"] . '.mrtg') . "; tar -cf " . tfb_shellencode($files['mrtg']) . " .";
// action
if ($talk) {
sendLine('<br>');
}
// database-command
if ($commands['db'] != "") {
if ($talk) {
sendLine('Backup of Database <em>' . tfb_htmlencodekeepspaces($cfg["db_name"]) . '</em> ...');
}
shell_exec($commands['db']);
}
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// docroot-command
if ($talk) {
sendLine('Backup of Docroot <em>' . tfb_htmlencodekeepspaces($cfg["docroot"]) . '</em> ...');
}
shell_exec($commands['docroot']);
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// transfers-command
//.........这里部分代码省略.........
示例4: backupCreate
/**
* backup of flux-installation
*
* @param $talk : boolean if function should talk
* @param $compression : 0 = none | 1 = gzip | 2 = bzip2
* @return string with name of backup-archive, string with "" in error-case.
*/
function backupCreate($talk = false, $compression = 0)
{
global $cfg, $error;
// backup-dir
$dirBackup = $cfg["path"] . _DIR_BACKUP;
if (!checkDirectory($dirBackup)) {
$error = "Errors when checking/creating backup-dir : " . $dirBackup;
return "";
}
// files and more strings
$backupName = "backup_" . _VERSION_THIS . "_" . date("YmdHis");
$fileArchiveName = $backupName . ".tar";
$tarSwitch = "-cf";
switch ($compression) {
case 1:
$fileArchiveName .= ".gz";
$tarSwitch = "-zcf";
break;
case 2:
$fileArchiveName .= ".bz2";
$tarSwitch = "-jcf";
break;
}
$fileArchive = $dirBackup . '/' . $fileArchiveName;
$fileDatabase = $dirBackup . '/database.sql';
$fileDocroot = $dirBackup . '/docroot.tar';
// command-strings
$commandArchive = "cd " . $dirBackup . "; tar " . $tarSwitch . " " . $fileArchiveName . " ";
$commandDatabase = "";
switch ($cfg["db_type"]) {
case "mysql":
$commandDatabase = "mysqldump -h " . $cfg["db_host"] . " -u " . $cfg["db_user"] . " --password=" . $cfg["db_pass"] . " --all -f " . $cfg["db_name"] . " > " . $fileDatabase;
$commandArchive .= 'database.sql ';
break;
case "sqlite":
$commandDatabase = "sqlite " . $cfg["db_host"] . " .dump > " . $fileDatabase;
$commandArchive .= 'database.sql ';
break;
case "postgres":
$commandDatabase = "pg_dump -h " . $cfg["db_host"] . " -D " . $cfg["db_name"] . " -U " . $cfg["db_user"] . " -f " . $fileDatabase;
$commandArchive .= 'database.sql ';
break;
}
$commandArchive .= 'docroot.tar';
$docroot = dirname(__FILE__);
//$commandDocroot = "cd ".$dirBackup."; tar -cf docroot.tar ".$docroot; // with path of docroot
$commandDocroot = "cd " . escapeshellarg($docroot) . "; tar -cf " . $fileDocroot . " .";
// only content of docroot
// database-command
if ($commandDatabase != "") {
if ($talk) {
sendLine('Backup of Database <em>' . $cfg["db_name"] . '</em> ...');
}
shell_exec($commandDatabase);
}
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// docroot-command
if ($talk) {
sendLine('Backup of Docroot <em>' . $docroot . '</em> ...');
}
shell_exec($commandDocroot);
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// create the archive
if ($talk) {
sendLine('Creating Archive <em>' . $fileArchiveName . '</em> ...');
}
shell_exec($commandArchive);
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// delete temp-file(s)
if ($talk) {
sendLine('Deleting temp-files ...');
}
if ($commandDatabase != "") {
@unlink($fileDatabase);
}
@unlink($fileDocroot);
if ($talk) {
sendLine(' <font color="green">Ok</font><br>');
}
// log
if ($talk) {
sendLine('<font color="green">Backup Complete.</font><br>');
}
AuditAction($cfg["constants"]["admin"], "FluxBackup Created : " . $fileArchiveName);
return $fileArchiveName;
}
示例5: instance_processFeed
/**
* process a feed
*
* @param $sdir
* @param $filter
* @param $hist
* @param $url
* @return boolean
*/
function instance_processFeed($sdir, $filter, $hist, $url)
{
// (re)set state
$this->state = RSSD_STATE_NULL;
// validate
if (!checkDirectory($sdir, 0777)) {
$this->state = RSSD_STATE_ERROR;
$msg = "Save-Dir " . $sdir . " not valid.";
array_push($this->messages, $msg);
$this->_outputError($msg . "\n");
return false;
}
if (!is_file($filter)) {
$this->state = RSSD_STATE_ERROR;
$msg = "Filter-File " . $filter . " not valid.";
array_push($this->messages, $msg);
$this->_outputError($msg . "\n");
return false;
}
// output
$this->_outputMessage("Processing feed " . $url . " ...\n");
// set vars
$this->_dirSave = checkDirPathString($sdir);
$this->_fileFilters = $filter;
$this->_fileHistory = $hist;
$this->_urlRSS = $url;
$this->_filters = array();
$this->_history = array();
$this->_historyNew = array();
$this->_data = array();
$this->_filesSaved = array();
// load _filters
if (!$this->_loadFilters()) {
return false;
}
// load history
if (!$this->_loadHistory()) {
return false;
}
// load data
if (!$this->_loadData()) {
return false;
}
// something to do ?
if ($this->_data['items_count'] <= 0) {
// no
// state
$this->state = RSSD_STATE_OK;
return true;
}
// process data
if (!$this->_processData()) {
return false;
}
// update history
if (!$this->_updateHistory()) {
return false;
}
// state
$this->state = RSSD_STATE_OK;
// output
$this->_outputMessage("feed processed. downloaded and saved " . count($this->_filesSaved) . " torrents.\n");
// return
return true;
}
示例6: prepareStartTorrentClient
//.........这里部分代码省略.........
}
if ($this->maxcons == '') {
$this->maxcons = $this->cfg["maxcons"];
}
if ($this->sharekill == '') {
$this->sharekill = $this->cfg["sharekill"];
}
}
// queue
if ($this->cfg["AllowQueing"]) {
if (IsAdmin()) {
$this->queue = getRequestVar('queue');
if ($this->queue == 'on') {
$this->queue = "1";
} else {
$this->queue = "0";
}
} else {
$this->queue = "1";
}
} else {
$this->queue = "0";
}
//
$this->torrent = urldecode($torrent);
$this->alias = getAliasName($this->torrent);
$this->owner = getOwner($this->torrent);
if (empty($this->savepath)) {
$this->savepath = $this->cfg['path'] . $this->owner . "/";
}
// ensure path has trailing slash
$this->savepath = checkDirPathString($this->savepath);
// check target-directory, create if not present
if (!checkDirectory($this->savepath, 0777)) {
AuditAction($this->cfg["constants"]["error"], "Error checking " . $this->savepath . ".");
$this->state = -1;
$this->messages .= "Error. TorrentFlux settings are not correct (path-setting).";
global $argv;
if (isset($argv)) {
die($this->messages);
} else {
if (IsAdmin()) {
@header("location: admin.php?op=configSettings");
exit;
} else {
$this->messages .= " please contact an admin.";
showErrorPage($this->messages);
}
}
}
// create AliasFile object and write out the stat file
include_once "AliasFile.php";
$this->af = AliasFile::getAliasFileInstance($this->cfg["torrent_file_path"] . $this->alias . ".stat", $this->owner, $this->cfg, $this->handlerName);
// set param for sharekill
$this->sharekill = intval($this->sharekill);
if ($this->sharekill == 0) {
// nice, we seed forever
$this->sharekill_param = 0;
} elseif ($this->sharekill > 0) {
// recalc sharekill
// sanity-check. catch "data-size = 0".
$transferSize = intval($this->af->size);
if ($transferSize > 0) {
$totalAry = getTorrentTotals($this->torrent);
$upTotal = $totalAry["uptotal"] + 0;
$downTotal = $totalAry["downtotal"] + 0;
示例7: FluAzu
/**
* ctor
*/
function FluAzu()
{
global $cfg;
// paths
$this->_pathDataDir = $cfg["path"] . '.fluazu/';
$this->_pathPidFile = $this->_pathDataDir . 'fluazu.pid';
$this->_pathCommandFile = $this->_pathDataDir . 'fluazu.cmd';
$this->_pathLogFile = $this->_pathDataDir . 'fluazu.log';
$this->_pathStatFile = $this->_pathDataDir . 'fluazu.stat';
$this->_pathTransfers = $this->_pathDataDir . 'cur/';
$this->_pathTransfersRun = $this->_pathDataDir . 'run/';
$this->_pathTransfersDel = $this->_pathDataDir . 'del/';
// check path
if (!checkDirectory($this->_pathDataDir)) {
@error("fluazu-Main-Path does not exist and cannot be created or is not writable", "admin.php?op=serverSettings", "Server-Settings", array("path : " . $this->_pathDataDir));
}
// check if fluazu running
if ($this->instance_isRunning()) {
$this->state = FLUAZU_STATE_RUNNING;
}
}
示例8: checkMainDirectories
/**
* checks main-directories.
*
* @return boolean
*/
function checkMainDirectories()
{
global $cfg;
// main-path
if (!checkDirectory($cfg["path"])) {
@error("Main-Path does not exist and cannot be created or is not writable", "admin.php?op=serverSettings", "Server-Settings", array("path : " . $cfg["path"]));
}
// transfer-path
if (!checkDirectory($cfg["transfer_file_path"])) {
@error("Transfer-File-Path does not exist and cannot be created or is not writable", "admin.php?op=serverSettings", "Server-Settings", array("transfer_file_path : " . $cfg["transfer_file_path"]));
}
}
示例9: define
if (!defined("ENT_COMPAT")) {
define("ENT_COMPAT", 2);
}
if (!defined("ENT_NOQUOTES")) {
define("ENT_NOQUOTES", 0);
}
if (!defined("ENT_QUOTES")) {
define("ENT_QUOTES", 3);
}
// Get RSS feeds from Database
$arURL = GetRSSLinks();
// create lastRSS object
$rss = new lastRSS();
// setup transparent cache
$cacheDir = $cfg['path'] . ".rsscache";
if (!checkDirectory($cacheDir, 0777)) {
@error("Error with rss-cache-dir", "index.php?iid=index", "", array($cacheDir));
}
$rss->cache_dir = $cacheDir;
$rss->cache_time = $cfg["rss_cache_min"] * 60;
// 1200 = 20 min. 3600 = 1 hour
$rss->strip_html = false;
// don't remove HTML from the description
// init template-instance
tmplInitializeInstance($cfg["theme"], "page.readrss.tmpl");
// set vars
// Loop through each RSS feed
$rss_list = array();
foreach ($arURL as $rid => $url) {
if (isset($_REQUEST["debug"])) {
$rss->cache_time = 0;
示例10: checkFile
/*** check table field expand by preload ***/
if (!checkTable()) {
$messages[] = 'You must put extras/extra_preload/upgrade22.class.php in ' . XOOPS_ROOT_PATH . '/preload';
}
/*** check latest language file ***/
$lang = XCube_Root::getSingleton()->mLanguageManager->mLanguageName;
if (!checkLanguage($lang)) {
$messages[] = 'You must move the latest language files from extras/extra_languages/' . $lang . '. DON\'T MOVE /install directory !';
}
/*** check file existing ***/
$files = checkFile();
foreach ($files as $file) {
$messages[] = $file;
}
/*** check directory existing ***/
$directories = checkDirectory();
foreach ($directories as $dir) {
$messages[] = $dir;
}
/*** check directory permission to write ***/
$permissions = checkPermission();
foreach ($permissions as $perm) {
$messages[] = $perm;
}
/*** check module version, if updated by module admin ***/
$modules = checkVersion();
foreach ($modules as $mod) {
$messages[] = 'You must upgrade module "' . $mod . '" in module administration page.';
}
if (count($messages) === 0) {
$messages[] = 'Congraturation! You are ready for upgrade XCL2.2.<br />Remove ' . XOOPS_ROOT_PATH . '/legacy22_check.php file.';
示例11: checkDirectory
/**
* checks a dir. recursive process to emulate "mkdir -p" if dir not present
*
* @param $dir the name of the dir
* @param $mode the mode of the dir if created. default is 0755
* @return boolean if dir exists/could be created
*/
function checkDirectory($dir, $mode = 0755)
{
if (is_dir($dir) && is_writable($dir) || @mkdir($dir, $mode)) {
return true;
}
if (!checkDirectory(dirname($dir), $mode)) {
return false;
}
return @mkdir($dir, $mode);
}
示例12: is_writable
// set vars
// path
$tmpl->setvar('path', $cfg["path"]);
if (is_dir($cfg["path"])) {
$tmpl->setvar('is_path', 1);
$tmpl->setvar('is_writable', is_writable($cfg["path"]) ? 1 : 0);
} else {
$tmpl->setvar('is_path', 0);
}
// docroot
$tmpl->setvar('docroot', $cfg["docroot"]);
$tmpl->setvar('is_docroot', is_file($cfg["docroot"] . "version.php") ? 1 : 0);
// homedirs + incoming
$tmpl->setvar('enable_home_dirs', $cfg["enable_home_dirs"]);
$tmpl->setvar('path_incoming', $cfg["path_incoming"]);
$tmpl->setvar('path_incoming_ok', checkDirectory($cfg["path"] . $cfg["path_incoming"], 0777) ? 1 : 0);
// bins
$tmpl->setvar('btclient_transmission_bin', $cfg["btclient_transmission_bin"]);
$tmpl->setvar('validate_transmission_bin', validateTransmissionCli($cfg["btclient_transmission_bin"]));
$tmpl->setvar('perlCmd', $cfg["perlCmd"]);
$tmpl->setvar('validate_perl', validateBinary($cfg["perlCmd"]));
$tmpl->setvar('bin_grep', $cfg["bin_grep"]);
$tmpl->setvar('validate_grep', validateBinary($cfg["bin_grep"]));
$tmpl->setvar('bin_php', $cfg["bin_php"]);
$tmpl->setvar('validate_php', validatePhpCli($cfg["bin_php"]));
$tmpl->setvar('pythonCmd', $cfg["pythonCmd"]);
$tmpl->setvar('validate_python', validateBinary($cfg["pythonCmd"]));
$tmpl->setvar('bin_awk', $cfg["bin_awk"]);
$tmpl->setvar('validate_awk', validateBinary($cfg["bin_awk"]));
$tmpl->setvar('bin_du', $cfg["bin_du"]);
$tmpl->setvar('validate_du', validateBinary($cfg["bin_du"]));
示例13: checkDirectory
function checkDirectory($path)
{
global $fsPath, $aIgnore;
$fullpath = sprintf('%s/%s', $fsPath, $path);
if (!is_dir($fullpath)) {
print "Not a directory: {$fullpath}\n";
}
if ($path === '/Deleted') {
// Deleted files handled separately.
return;
}
if (!empty($path)) {
$fod = KTBrowseUtil::folderOrDocument($path);
if ($fod === false) {
$GLOBALS['aFoldersToRemove'][] = $path;
return;
}
}
$dh = @opendir($fullpath);
if ($dh === false) {
print "Could not open directory: {$fullpath}\n";
}
while (($filename = readdir($dh)) !== false) {
if (in_array($filename, $aIgnore)) {
continue;
}
$subrelpath = sprintf('%s/%s', $path, $filename);
$subfullpath = sprintf('%s/%s', $fsPath, $subrelpath);
if (is_dir($subfullpath)) {
checkDirectory($subrelpath);
}
if (is_file($subfullpath)) {
checkFile($subrelpath);
}
}
}
示例14: trim
if ($targetDir == "" && isset($_POST['selector'])) {
$targetDir = trim(urldecode($_POST['selector']));
}
$dirValid = true;
if (strlen($targetDir) <= 0) {
$dirValid = false;
} else {
// we need absolute paths or stuff will end up in docroot
// inform user .. dont move it into a fallback-dir which may be a hastle
if ($targetDir[0] != '/') {
echo "Target-dirs must be specified with absolute and not relative paths. <br>";
$dirValid = false;
}
}
// check dir
if ($dirValid && checkDirectory($targetDir, 0777)) {
$targetDir = checkDirPathString($targetDir);
// move
$cmd = "mv \"" . $cfg["path"] . $_POST['file'] . "\" " . $targetDir . "";
$cmd .= ' 2>&1';
$handle = popen($cmd, 'r');
// get the output and print it.
$gotError = -1;
while (!feof($handle)) {
$buff = fgets($handle, 30);
echo nl2br($buff);
@ob_flush();
@flush();
$gotError = $gotError + 1;
}
pclose($handle);
示例15: instance_jobUpdate
/**
* updates a single job
*
* @param $jobNumber
* @param $savedir
* @param $url
* @param $filtername
* @return boolean
*/
function instance_jobUpdate($jobNumber, $savedir, $url, $filtername, $checkdir = false)
{
if ($jobNumber > 0 && strlen($savedir) > 0 && strlen($url) > 0 && strlen($filtername) > 0) {
$jobs = $this->instance_jobsGetList();
if ($jobs !== false && count($jobs) > 0) {
$result = array();
$idx = 1;
while (count($jobs) > 0) {
$job = array_shift($jobs);
if ($idx != $jobNumber) {
array_push($result, $job);
} else {
array_push($result, array('savedir' => trim(checkDirPathString($savedir)), 'url' => $url, 'filtername' => $filtername));
}
$idx++;
}
$jobsString = "";
$resultCount = count($result);
for ($i = 0; $i < $resultCount; $i++) {
$jobsString .= $result[$i]["savedir"] . $this->_delimJob;
$jobsString .= $result[$i]["url"] . $this->_delimJob;
$jobsString .= $result[$i]["filtername"];
if ($i < $resultCount - 1) {
$jobsString .= $this->_delimJobs;
}
}
// check dir
if ($checkdir) {
$check = checkDirectory($savedir);
if (!$check) {
array_push($this->messages, "dir " . $savedir . " does not exist and could not be created.");
}
} else {
$check = true;
}
// update setting
return $check && $this->_jobsUpdate($jobsString);
}
return false;
} else {
return false;
}
}