當前位置: 首頁>>代碼示例>>PHP>>正文


PHP IO類代碼示例

本文整理匯總了PHP中IO的典型用法代碼示例。如果您正苦於以下問題:PHP IO類的具體用法?PHP IO怎麽用?PHP IO使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IO類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: load

 /**
  * Load a settings file. 
  * Can auto detect file type from the file's extention.
  * @param string $filename file to load.
  * @param string|null $type The type of file being loaded.
  * @param boolean $array Return data as an array or object.
  * @return array|stdClass Data from file.
  */
 public function load($filename, $type = null, $array = false)
 {
     if ($type == null) {
         $type = strtoupper(pathinfo($filename, PATHINFO_EXTENSION));
     }
     $data = NULL;
     if (file_exists($filename)) {
         switch ($type) {
             case 'JSON':
                 $io = new IO();
                 $data = $io->read($filename);
                 if ($data === false) {
                     return null;
                 }
                 $data = json_decode($data, $array);
                 break;
             case 'INI':
                 $data = $array ? parse_ini_file($filename, true) : (object) parse_ini_file($filename, true);
                 if ($data === false) {
                     $data = NULL;
                 }
                 break;
             default:
                 $data = NULL;
         }
     }
     return $data;
 }
開發者ID:nojacko,項目名稱:twuddle-core,代碼行數:36,代碼來源:Settings.php

示例2: process

 function process()
 {
     Console::initCore();
     if ($r = ArgsHolder::get()->getOption('count')) {
         $this->count = $r;
     }
     if (($c = ArgsHolder::get()->shiftCommand()) == 'help') {
         return $this->cmdHelp();
     }
     try {
         IO::out("");
         $sql = 'SELECT * FROM ' . self::TABLE . ' where not isnull(finished_at) and not 
             isnull(locked_at) and isnull(failed_at) ORDER BY run_at DESC';
         if ($this->count) {
             $list = DB::query($sql . ' LIMIT ' . $this->count);
         } else {
             $list = DB::query($sql);
         }
         if (!count($list)) {
             IO::out("No finished work!", IO::MESSAGE_FAIL);
             return;
         }
         io::out(sprintf("%-10s %-7s %-3s %-20s %-20s %-19s %-4s %-5s", "~CYAN~id", "queue", "pr", "run_at", "locked_at", "finished_at", "att", "call_to~~~"));
         foreach ($list as $l) {
             $handler = unserialize($l["handler"]);
             io::out(sprintf("%-4s %-7s %-3s %-20s %-20s %-20s %-3s %-5s", $l["id"], $l["queue"], $l["priority"], $l["run_at"], $l["locked_at"], $l["finished_at"], $l["attempts"], $handler["class"] . "::" . $handler["method"] . "(...)"));
         }
     } catch (Exception $e) {
         io::out($e->getMessage(), IO::MESSAGE_FAIL);
         return;
     }
     IO::out("");
 }
開發者ID:point,項目名稱:cassea,代碼行數:33,代碼來源:CmdBgworkCompleted.php

示例3: RestartById

 public function RestartById($c)
 {
     if (!count(DB::query('SELECT * from ' . self::TABLE . ' WHERE id="' . $c . '"'))) {
         io::out("Work with id={$c} is not exists", IO::MESSAGE_FAIL);
         return;
     }
     $list = DB::query('SELECT * FROM ' . self::TABLE . ' where isnull(finished_at) and not 
         isnull(locked_at) and isnull(failed_at) and id=' . $c . ' ORDER BY run_at DESC');
     if (count($list)) {
         IO::out("This is working now...You cant restart!", IO::MESSAGE_FAIL);
         return;
     }
     if (IO::YES == io::dialog('Do you really want to restart work with id ' . $c . '?', IO::NO | IO::YES, IO::NO)) {
         DB::query("UPDATE " . self::TABLE . " set attempts='1',finished_at=null, locked_at=null, \n                failed_at=null, run_at=now()  WHERE  id='" . $c . "'");
         $php_path = exec("which php");
         if (empty($php_path)) {
             return $this->log("###" . date("c") . " Call from console PHP executable not found");
         }
         if (!is_executable($php_path)) {
             return $this->log("###" . date("c") . " Call from console {$php_path} could not be executed");
         }
         exec($php_path . ' ' . trim(escapeshellarg(Config::get('ROOT_DIR') . "/vendors/delayedjob/JobHandler.php"), "'") . ' >> ' . Config::get('ROOT_DIR') . '/logs/delayedjob.log 2>&1 &');
         io::done('Restarting...');
     } else {
         io::done('Cancel restart');
     }
     IO::out("");
 }
開發者ID:point,項目名稱:cassea,代碼行數:28,代碼來源:CmdBgworkRestart.php

示例4: pick_count

function pick_count()
{
    //clear_pick_cache(1);//緩存定期清理
    //clear_search_index(1);//清除索引
    clear_log(1);
    //清除日誌
    pload('C:cache');
    $arr['search_index']['name'] = milu_lang('rules_search_index');
    $arr['search_index']['msg'] = milu_lang('search_index_notice');
    $arr['search_index']['show'] = '<span style=" width:120px; float:left">' . milu_lang('search_index_c') . '<hr>';
    $type_arr = array('1' => milu_lang('fast_pick_rules'), '2' => milu_lang('dxc_system_rules'), '3' => milu_lang('fastpick_evo'));
    $type_arr2 = array('3' => milu_lang('server_'), '4' => milu_lang('local_'));
    foreach ($type_arr as $k => $v) {
        foreach ($type_arr2 as $k2 => $v2) {
            $type = $k . $k2;
            $show_name = '<span style=" width:120px; float:left">' . $type_arr[$k] . $type_arr2[$k2] . '</span>';
            $search_index_count = DB::result(DB::query("SELECT COUNT(*) FROM " . DB::table('strayer_searchindex') . " WHERE type='{$type}'"), 0);
            $arr['search_index']['show'] .= $show_name . ' ' . $search_index_count . '<br />';
        }
    }
    $log_info = IO::info(PICK_DIR . '/data/log');
    $arr['log']['name'] = milu_lang('log_size');
    $arr['log']['msg'] = milu_lang('auto_pick_notice');
    $arr['log']['show'] = sizecount($log_info['size']);
    $cache_info = IO::info(PICK_CACHE, 1, 1);
    $arr['cache']['name'] = milu_lang('cache_file_size');
    $arr['cache']['show'] = milu_lang('cache_size_value', array('s' => sizecount($cache_info['size']), 'p' => PICK_CACHE_SIZE));
    $arr['cache']['msg'] = milu_lang('cache_notice');
    return $arr;
}
開發者ID:edmundwong,項目名稱:V604,代碼行數:30,代碼來源:pick_info.inc.php

示例5: editIni

 /**
  * Edits php.ini
  *
  * @author Art <a.molcanovas@gmail.com>
  * @return PHP
  */
 protected function editIni()
 {
     $timezone = SET::$s->php_date_timezone;
     $ini = $this->unzipped_destination . 'php.ini';
     if (!$timezone) {
         $timezone = 'Europe/London';
         _echo('Your timezone setting wasn\'t found. Setting it to Europe/London.');
         SET::$s->php_date_timezone = $timezone;
         SET::$s->save();
     }
     $contents = file_get_contents($ini);
     $err_log_dir = '"' . str_replace(DIRECTORY_SEPARATOR, '/', DIR_LOGS) . 'php/php_errors.log"';
     if ($contents) {
         $contents = str_ireplace([';date.timezone =', '; extension_dir = "ext"', ';error_log = php_errors.log'], ['date.timezone = ' . $timezone, 'extension_dir = "' . $this->unzipped_destination . 'ext"', 'error_log = ' . $err_log_dir . ''], $contents);
         if (file_put_contents($ini, $contents) !== false) {
             _echo('php.ini edited');
         } else {
             $msg = 'Failed to edit php.ini. You will have to set the following yourself:' . PHP_EOL . "\t Find ';date.timezone =' and change it to 'date.timezone = ' . {$timezone}'" . PHP_EOL . "\t Find '; extension_dir = \"ext\"' and change it to 'extension_dir = \"ext\"'" . PHP_EOL . "\t Find ';error_log = php_errors.log' and change it to 'error_log = {$err_log_dir}'";
             _echo($msg . PHP_EOL . 'Press ENTER to continue');
             \IO::readline();
         }
     } else {
         _echo('Failed to open php.ini for editing. You will have to set the timezone yourself.');
     }
     return $this;
 }
開發者ID:alorel,項目名稱:alo-wamp,代碼行數:32,代碼來源:php.php

示例6: process

 function process()
 {
     Console::initCore();
     if (($c = ArgsHolder::get()->shiftCommand()) == 'help') {
         return $this->cmdHelp();
     }
     try {
         $format = "%-25s %s";
         IO::out("");
         $s = DB::query('SELECT * FROM ' . self::TABLE . ' where id="' . $c . '"');
         if (!count($s)) {
             io::out("Work with id={$c} is not exists", IO::MESSAGE_FAIL);
             return;
         }
         io::out(sprintf($format, "~CYAN~id~~~", $c));
         io::out(sprintf($format, "~CYAN~queue~~~", $this->emp($s[0]['queue'])));
         io::out(sprintf($format, "~CYAN~priority~~~", $this->emp($s[0]['priority'])));
         io::out(sprintf($format, "~CYAN~run at~~~", $this->emp($s[0]['run_at'])));
         io::out(sprintf($format, "~CYAN~locked at~~~", $this->emp($s[0]['locked_at'])));
         io::out(sprintf($format, "~CYAN~finished at~~~", $this->emp($s[0]['finished_at'])));
         io::out(sprintf($format, "~CYAN~failed at~~~", $this->emp($s[0]['failed_at'])));
         io::out(sprintf($format, "~CYAN~attemts~~~", $this->emp($s[0]['attempts'])));
         $handler = unserialize($s[0]["handler"]);
         io::out(sprintf($format, "~CYAN~call~~~", $handler["class"] . "::" . $handler["method"]) . "(...)");
         if (isset($handler["param"])) {
             io::out(sprintf($format, "~CYAN~params~~~", trim(self::walker($handler['param']), ',')));
         }
     } catch (Exception $e) {
         io::out($e->getMessage(), IO::MESSAGE_FAIL);
         return;
     }
     IO::out("");
 }
開發者ID:point,項目名稱:cassea,代碼行數:33,代碼來源:CmdBgworkSingle.php

示例7: stderr

 /**
  * Возвращает объект класса IO.Stream.ResourceStream, соответствующий stderr.
  *
  * @return IO_Stream_ResourceStream
  */
 public static function stderr($stderr = null)
 {
     if ($stderr instanceof IO_Stream_AbstractStream) {
         self::$stderr = $stderr;
     }
     return self::$stderr ? self::$stderr : (self::$stderr = IO_Stream::ResourceStream(STDERR));
 }
開發者ID:techart,項目名稱:tao,代碼行數:12,代碼來源:IO.php

示例8: checkCondition

 /**
  * Проверяет условия указанные в теге condition.
  *
  * В данной момент реализована проверка установленного пакета
  *
  * @param DOMNode 
  * @return bool
  */
 private function checkCondition(DOMNode $node)
 {
     IO::info('Check Condition ', false);
     $attr = $node->attributes;
     $packageName = is_null($attr->getNamedItem('package')) ? null : $attr->getNamedItem('package')->nodeValue;
     if (!is_null($packageName)) {
         $version = is_null($attr->getNamedItem('version')) ? null : $attr->getNamedItem('version')->nodeValue;
         $rel = is_null($attr->getNamedItem('rel')) ? null : Deps::normalizeRel($attr->getNamedItem('rel')->nodeValue);
         if (is_null($version) && $rel != '!=') {
             $version = '0.0';
             $rel = '>=';
         } elseif (is_null($rel)) {
             $rel = '=';
         }
         io::info($packageName . ' ' . $rel . ' ' . $version . "\t", false);
         $p = PackageManager::getInstalledPackage($packageName);
         if ($rel == '!=') {
             $res = $p === false;
         } elseif ($p !== false) {
             $res = version_compare($p->version, $version, $rel);
         } else {
             $res = false;
         }
         io::info('', $res ? IO::MESSAGE_OK : IO::MESSAGE_FAIL);
         return $res;
     }
 }
開發者ID:point,項目名稱:cassea,代碼行數:35,代碼來源:Deployer.php

示例9: cmdUnlock

 function cmdUnlock()
 {
     IO::out('Unlocking Package Manager', false);
     $pm = new PM();
     if ($pm->unlock(true)) {
         io::done();
     }
 }
開發者ID:point,項目名稱:cassea,代碼行數:8,代碼來源:PackageManagerFacade.php

示例10: CmdList

 function CmdList()
 {
     io::out('~WHITE~Current env~~~: ' . ($env = EnvManager::getCurrent()));
     io::out();
     IO::OUt('~WHITE~Avaible enviroments:~~~');
     foreach (EnvManager::envList() as $e) {
         if ($e != $env) {
             io::out('    ' . $e);
         }
     }
 }
開發者ID:point,項目名稱:cassea,代碼行數:11,代碼來源:CmdEnv.php

示例11: initialize

 public static function initialize(array $options = array())
 {
     self::options($options);
     if (!class_exists('Google_Client') && set_include_path(get_include_path() . PATH_SEPARATOR . self::option('lib_path') . 'src/')) {
         if (!@(include_once 'Google_Client.php')) {
             throw new Service_Google_API_ClientLibraryModuleNotFoundException('src/Google_Client.php', self::option('lib_path'));
         }
     }
     self::$cache = Cache::connect(self::option('cache_path'), 0);
     self::$stdin = IO::stdin();
 }
開發者ID:techart,項目名稱:tao,代碼行數:11,代碼來源:API.php

示例12: send

 public function send(IO $io)
 {
     $io->send("GNTP/1.0 NOTIFY NONE");
     $io->send("Application-Name: " . $this->applicationName);
     $io->send("Notification-Name: " . $this->notificationName);
     $io->send("Notification-Title: " . $this->notificationTitle);
     if (isset($this->options['text'])) {
         $io->send("Notification-Text: " . $this->options['text']);
     }
     if (isset($this->options['icon_file'])) {
         $resource = $this->getResouce($this->options['icon_file']);
         $io->send("Notification-Icon: x-growl-resource://" . $resource['hash']);
     }
     $io->send("");
     $this->sendResources($io);
     $io->send("");
 }
開發者ID:iakio,項目名稱:gntp-notify,代碼行數:17,代碼來源:NotificationRequest.php

示例13: run

 /**
  * Запускает приложение
  *
  * @param array $argv
  *
  * @return int
  */
 public function run(array $argv)
 {
     $cache = Cache::connect($this->config->dsn);
     if ($this->config->modules != null) {
         foreach (Core_Strings::split_by(',', $this->config->modules) as $v) {
             Core::load($v);
         }
     }
     foreach ($argv as $v) {
         IO::stdout()->write_line($v)->write_line(var_export($cache[$v], true));
     }
     return 0;
 }
開發者ID:techart,項目名稱:tao,代碼行數:20,代碼來源:Dump.php

示例14: cmdList

 function cmdList()
 {
     $list = $this->rl->getList();
     if (!count($list)) {
         return IO::out('Repository List empty.');
     }
     io::out('~WHITE~List of  Repositories~~~:');
     for ($i = 0, $c = count($list); $i < $c; $i++) {
         io::out($list[$i]);
     }
     io::out();
     io::out('Total: ' . $c);
 }
開發者ID:point,項目名稱:cassea,代碼行數:13,代碼來源:RepositoryManager.php

示例15: checkWebDir

 /**
  * Checks if the www dir is set up
  *
  * @author Art <a.molcanovas@gmail.com>
  */
 protected function checkWebDir()
 {
     if (!SET::$s->web_dir) {
         $new_dir = \IO::readline('Your default website name was not found - please enter a name (defaults to my-default-website if left empty)');
         if (!$new_dir) {
             $new_dir = 'my-default-website';
         }
         SET::$s->web_dir = $new_dir;
         SET::$s->save();
     }
     if (!file_exists(DIR_WWW . SET::$s->web_dir . DIRECTORY_SEPARATOR)) {
         mkdir(DIR_WWW . SET::$s->web_dir . DIRECTORY_SEPARATOR, 777, true);
     }
 }
開發者ID:alorel,項目名稱:alo-wamp,代碼行數:19,代碼來源:apache.php


注:本文中的IO類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。