本文整理匯總了PHP中IO::done方法的典型用法代碼示例。如果您正苦於以下問題:PHP IO::done方法的具體用法?PHP IO::done怎麽用?PHP IO::done使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類IO
的用法示例。
在下文中一共展示了IO::done方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: process
function process()
{
if (!($c = ArgsHolder::get()->shiftCommand())) {
return io::out('Incorrect parameter', IO::MESSAGE_FAIL) | 1;
}
$root = Config::get('ROOT_DIR');
$file = $root . '/includes/env/' . strtolower($c) . '_env.php';
if (!file_exists($file)) {
return io::out('Mode ' . $c . ' not exists', IO::MESSAGE_FAIL) | 1;
}
IO::out('Updating Loader', false);
$loader = fopen($root . '/includes/env/Loader.php', 'w');
flock($loader, LOCK_EX);
$put = '<?php require_once("' . $c . '_env.php");';
fwrite($loader, $put);
flock($loader, LOCK_UN);
fclose($loader);
io::done();
io::out('Backup config.ini', false);
if (copy($root . '/config/config.ini', $root . '/config/config.ini.bak')) {
io::done();
} else {
return IO::out('Can\'t backup file config.ini', IO::MESSAGE_FAIL) | 1;
}
IO::out('Updating config.ini', false);
$file_array = file($root . '/config/config.ini');
$str = null;
foreach ($file_array as $fa) {
if (preg_match('/\\[\\s*config\\s*:\\s*\\S+\\]/', $fa, $match)) {
$str .= '[config : ' . $c . ']' . PHP_EOL;
} else {
$str .= $fa;
}
}
$config = fopen($root . '/config/config.ini', 'w');
flock($config, LOCK_EX);
fwrite($config, $str);
flock($config, LOCK_UN);
fclose($config);
io::done();
IO::done('Enviroments set to ~WHITE~' . $c . '~~~');
}
示例2: createController
public function createController($name)
{
IO::out('~WHITE~Checking:~~~');
if (file_exists($this->root_dir . '/controllers/' . $name . '.php')) {
return io::out('Controller with name ~WHITE~' . $name . '~~~ exist!', IO::MESSAGE_FAIL);
}
io::done(' controllers ');
if (file_exists($this->root_dir . $this->models_dir . '/' . $name)) {
return io::out('Model with name ~WHITE~' . $name . '~~~ exist!', IO::MESSAGE_FAIL);
}
io::done(' models');
$pages = Config::get('xmlpages_dir');
if (file_exists($this->root_dir . '/' . $pages . '/' . $name)) {
return io::out('Pages for model with name ~WHITE~' . $name . ' ~~~ exist!', IO::MESSAGE_FAIL);
}
io::done(' pages');
IO::out('~WHITE~Creating:~~~');
// TODO models_dir
if (mkdir($this->root_dir . $this->models_dir . '/' . $name, 0775)) {
IO::done(" {$this->models_dir} / " . $name);
} else {
return IO::out("Error while creating directory {$this->models_dir} / " . $name, IO::MESSAGE_FAIL);
}
if (copy(dirname(__FILE__) . '/templates/autoload.tpl', $this->root_dir . $this->models_dir . '/' . $name . '/autoload.php')) {
io::done(" {$this->models_dir} /" . $name . '/autoload.php');
} else {
return IO::out('Error while creating ' . $this->models_dir . '/' . $name . '/autoload.php', IO::MESSAGE_FAIL);
}
// TODO xmlpages_dir
if (mkdir($this->root_dir . '/pages/' . $name, 0775)) {
IO::done(' /pages/' . $name);
} else {
return IO::out('Error while creating directory /pages/' . $name, IO::MESSAGE_FAIL);
}
if (copy(dirname(__FILE__) . '/templates/controller.tpl', $this->root_dir . '/controllers/' . $name . '.php')) {
io::done(' /controllers/' . $name . '.php');
} else {
return IO::out('Error while creating /controllers/' . $name . '.php', IO::MESSAGE_FAIL);
}
}
示例3: process
public function process()
{
Console::initCore();
$this->separate = ArgsHolder::get()->getOption('separate');
$this->all = ArgsHolder::get()->getOption('all');
if ($r = ArgsHolder::get()->getOption('send-email')) {
$this->send_email = true;
$this->email_address = explode(",", $r);
foreach ($this->email_address as $emails) {
if (!preg_match(POSTChecker::$email_regexp, $emails)) {
io::out("Incorrect email address format", IO::MESSAGE_FAIL);
return;
}
}
}
try {
$root = Config::get('ROOT_DIR');
$name = basename($root);
//Create MySQL dump
$sqlname = $this->createMySQL($root, $name, $this->separate);
//Create backup file
$filename = $this->createTar($root, $name, $this->separate);
if (!$this->separate) {
unlink($root . '/' . $sqlname);
}
if ($this->send_email) {
if (is_array($this->email_address)) {
$toout = implode(',', $this->email_address);
} else {
$toout = $this->email_address;
}
io::out("Sending email to ~WHITE~" . $toout . '~~~', false);
$a = Mail::CreateMail();
foreach ($this->email_address as $emails) {
$a->toAdd($emails);
}
$a->setSubject("Backup " . $filename);
$a->setFromname(Config::getInstance()->mail->default_from_name);
$a->setFrom(Config::getInstance()->mail->default_from);
$a->Message("Backup with filename " . $filename);
$a->attachAdd($root . "/" . $filename);
if ($this->separate) {
$a->attachAdd($root . "/" . $sqlname);
}
$r = $a->send();
if ($r === false) {
io::out('', IO::MESSAGE_FAIL);
} else {
io::done();
if (ArgsHolder::get()->getOption('clean')) {
IO::out('Cleaning ', false);
if ($this->separate) {
IO::out($sqlname . ' ', false);
unlink($root . '/' . $sqlname);
}
IO::out($filename . ' ', false);
unlink($root . '/' . $filename);
IO::done();
}
}
}
} catch (Exception $e) {
io::out($e->getMessage(), IO::MESSAGE_FAIL);
return;
}
}
示例4: process
//.........這裏部分代碼省略.........
if ((int) $pms >= (int) $umf && (int) $pms < (int) $ml) {
IO::out('upload_max_filesize(' . $umf . ')=< ini.post_max_size(' . $pms . ') < ini.memory_limit(' . $ml . ')', IO::MESSAGE_OK);
}
if (is_writable('/tmp')) {
IO::out('Temp dir is writable.', IO::MESSAGE_OK);
} else {
IO::out('Temp dir is not writable!', IO::MESSAGE_FAIL);
}
IO::out();
IO::out('Check for extensions:');
exec("{$php_path} -m", $output);
foreach ($this->ext as $e) {
if ($e == 'gd') {
if (!in_array($e, $output)) {
if (!in_array('imagick', $output)) {
io::out('Extension ' . $e . ' or imagick are not loaded.', IO::MESSAGE_FAIL);
} else {
io::out('Extension imagick is loaded.', IO::MESSAGE_OK);
}
} else {
io::out('Extension ' . $e . ' is loaded.', IO::MESSAGE_OK);
}
continue;
}
if (!in_array($e, $output)) {
io::out('Extension ' . $e . ' is not loaded.', IO::MESSAGE_FAIL);
} else {
if ($e == 'apc') {
io::out('Extension ' . $e . ' is loaded.You can set "apc.enabled=On" in php.ini.', IO::MESSAGE_OK);
continue;
} else {
io::out('Extension ' . $e . ' is loaded.', IO::MESSAGE_OK);
}
}
}
IO::out();
IO::out('Check for modes:');
IO::out('Check for Production:');
foreach ($this->mod_production as $k => $v) {
$output = array();
$subcmd = '<?php ini_set("' . $k . '",' . (int) $v . ');$r=ini_get("' . $k . '");if($r==' . $v . ') echo 1; else echo (int)$r;';
exec("echo '" . $subcmd . "' | {$php_path} -q", $output);
if ($output[0]) {
IO::out($k . ' = ' . $v, IO::MESSAGE_OK);
} else {
IO::out($k . ' = ' . $output[0], IO::MESSAGE_FAIL);
}
}
IO::out();
IO::out('Check for Development:');
foreach ($this->mod_dev as $k => $v) {
$output = array();
$subcmd = '<?php ini_set("' . $k . '",' . (int) $v . ');$r=ini_get("' . $k . '");if($r==' . $v . ') echo 1; else echo (int)$r;';
exec("echo '" . $subcmd . "' | {$php_path} -q", $output);
if ($output[0]) {
IO::out($k . ' = ' . $v, IO::MESSAGE_OK);
} else {
IO::out($k . ' = ' . $output[0], IO::MESSAGE_FAIL);
}
}
IO::out();
if (ArgsHolder::get()->getOption('generate-ini')) {
if (!empty($toini)) {
io::out('Generating php.ini', false);
$res = array();
if (file_exists(Config::get('ROOT_DIR') . '/php.ini')) {
$file = file(Config::get('ROOT_DIR') . '/php.ini');
for ($i = 0; $i < count($file); $i++) {
if ($file[$i] != "\n") {
$res[strtok($file[$i], '=')] = strtok('=');
}
}
}
foreach ($toini as $k => $v) {
if (!isset($res[$k])) {
$res[$k] = $v;
}
if ($res[$k] != $toini[$k]) {
$res[$k] = $toini[$k];
}
}
foreach ($res as $key => $val) {
$write[] = $key . '=' . $val;
}
$f = fopen(Config::get('ROOT_DIR') . '/php.ini', 'w');
if (flock($f, LOCK_EX)) {
fwrite($f, implode("\n", $write));
flock($f, LOCK_UN);
} else {
echo "Couldn't get the lock!";
}
fclose($f);
IO::done();
}
}
} catch (exception $e) {
io::out($e->getmessage(), IO::MESSAGE_FAIL);
return;
}
}