本文整理汇总了PHP中io类的典型用法代码示例。如果您正苦于以下问题:PHP io类的具体用法?PHP io怎么用?PHP io使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了io类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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
示例3: anchorStart
/**
* Output the anchor start tag
*
* @return string the HTML content
* @access private
*/
function anchorStart($tagName, $anchor, $attributes)
{
if (strpos($_SERVER['SCRIPT_NAME'], PATH_ADMIN_WR) !== false && strpos($_SERVER['SCRIPT_NAME'], 'page-previsualization.php') === false) {
return '<' . $tagName . ' href="' . $anchor . '"' . $attributes . '>';
}
return '<' . $tagName . ' href="' . (pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_BASENAME) != 'index.php' ? $_SERVER['SCRIPT_NAME'] : pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME) . (pathinfo($_SERVER['SCRIPT_NAME'], PATHINFO_DIRNAME) == '/' ? '' : '/')) . (isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] ? '?' . io::htmlspecialchars($_SERVER["QUERY_STRING"]) : '') . $anchor . '"' . $attributes . '>';
}
开发者ID:davidmottet,项目名称:automne,代码行数:13,代码来源:anchor.php
示例4: __construct
/**
* Setup and configure the benchmark library class.
*/
public function __construct()
{
// Run the first benchmark
self::mark('init');
// Register shortcut aliases using io::method();
\io::alias(__CLASS__, get_class_methods(__CLASS__));
}
开发者ID:olscore,项目名称:ornithopter.io,代码行数:10,代码来源:benchmark.php
示例5: _compute
/**
* Compute the tag
*
* @return string the PHP / HTML content computed
* @access private
*/
protected function _compute()
{
//decode ampersand
$this->_attributes['what'] = io::decodeEntities($this->_attributes['what']);
$return = '
$ifcondition_' . $this->_uniqueID . ' = CMS_polymod_definition_parsing::replaceVars("' . $this->replaceVars($this->_attributes['what'], false, false, array($this, 'encloseWithPrepareVar')) . '", @$replace);
';
//if attribute name is set, store if result
if (isset($this->_attributes['name']) && $this->_attributes['name']) {
$return .= '$atmIfResults[\'' . $this->_attributes['name'] . '\'][\'if\'] = false;';
}
$return .= '
if ($ifcondition_' . $this->_uniqueID . '):
$func_' . $this->_uniqueID . ' = @create_function("","return (".$ifcondition_' . $this->_uniqueID . '.");");
if ($func_' . $this->_uniqueID . ' === false) {
CMS_grandFather::raiseError(\'Error in atm-if [' . $this->_uniqueID . '] syntax : \'.$ifcondition_' . $this->_uniqueID . ');
}
if ($func_' . $this->_uniqueID . ' && $func_' . $this->_uniqueID . '()):
';
//if attribute name is set, store if result
if (isset($this->_attributes['name']) && $this->_attributes['name']) {
$return .= '$atmIfResults[\'' . $this->_attributes['name'] . '\'][\'if\'] = true;';
}
$return .= '
' . $this->_computeChilds() . '
endif;
unset($func_' . $this->_uniqueID . ');
endif;
unset($ifcondition_' . $this->_uniqueID . ');
';
return $return;
}
开发者ID:davidmottet,项目名称:automne,代码行数:38,代码来源:if.php
示例6: __construct
/**
* Constructor.
* initializes the linxCondition.
*
* @param string $property The page property we're gonna test. Only a set of these are available here.
* @param string $operator The comparison operator serving to test the condition.
* @param string $tagContent The tag content.
* @return void
* @access public
*/
function __construct($tag)
{
$authorized_properties = array("rank", "title", "id", "lvl", "father", "website", "codename");
$property = $tag->getAttribute('property');
$operator = $tag->getAttribute('operator');
if (SensitiveIO::isInSet($property, $authorized_properties)) {
$this->_pageProperty = $property;
$this->_operator = io::decodeEntities(io::decodeEntities(io::decodeEntities($operator)));
$values = $tag->getElementsByTagName('value');
if ($values->length > 0) {
$value = $values->item(0);
//if value type is "nodeproperty", we must parse the inner content to find a nodespec tag
if ($value->hasAttribute("type") && $value->getAttribute("type") == "nodeproperty") {
$this->_valueIsScalar = false;
$this->_valueNodespecProperty = $value->getAttribute("property");
$nodespecs = $value->getElementsByTagName('nodespec');
if ($nodespecs->length > 0) {
$nodespec = $nodespecs->item(0);
$this->_valueNodespec = CMS_linxNodespec::createNodespec($nodespec);
}
} else {
$this->_valueScalar = $value->nodeValue;
}
} else {
$this->raiseError("Malformed innerContent");
return;
}
} else {
$this->raiseError("Unknown property : " . $property);
}
}
开发者ID:davidmottet,项目名称:automne,代码行数:41,代码来源:linxcondition.php
示例7: 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
示例8: __construct
/**
* Initialize file helper class.
*
* @return object
*/
public function __construct()
{
// By default exclude annoying files
self::exclusive();
// Register shortcut aliases using h::method();
\io::alias(__CLASS__, get_class_methods(__CLASS__));
}
开发者ID:olscore,项目名称:ornithopter.io,代码行数:12,代码来源:file.php
示例9: create
public static function create($campaignId, $data = array())
{
if (!io::isPositiveInteger($campaignId)) {
return false;
}
$sql = 'INSERT INTO mod_mailjet VALUES (' . $campaignId . ',"' . json_encode($data) . '");';
$query = new CMS_query($sql);
return !$query->hasError();
}
开发者ID:arthurgorjux,项目名称:mailjetAutomne,代码行数:9,代码来源:MailjetCampaign.php
示例10: countByCodename
public static function countByCodename($codename, $id = null)
{
$sql = 'SELECT count(*) as count from mod_object_oembed_definition where codename_mood = "' . io::sanitizeSQLString($codename) . '"';
if ($id) {
$sql .= ' AND id_mood <> ' . $id;
}
$query = new CMS_query($sql);
$data = array_pop($query->getAll());
return (int) $data['count'];
}
开发者ID:davidmottet,项目名称:automne,代码行数:10,代码来源:poly_oembed_definition_catalog.php
示例11: setValue
/**
* Sets the string value.
*
* @param string $value the string value to set
* @return boolean true on success, false on failure
* @access public
*/
function setValue($value)
{
//add some complementary checks on values
if ($value && io::strlen($value) > 255) {
$this->raiseError("Setting a too long string for string value : max 255 cars, set : " . io::strlen($value));
return false;
}
$this->_value = $value;
return true;
}
开发者ID:davidmottet,项目名称:automne,代码行数:17,代码来源:subobject_string.php
示例12: 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
示例13: getObjectsNames
/**
* Gets all available objects class names
*
* @return array(string "CMS_object_{type}")
* @access public
* @static
*/
function getObjectsNames()
{
//Automatic listing
$excludedFiles = array('object_catalog.php', 'object_common.php');
$packages_dir = dir(PATH_MODULES_FS . '/' . MOD_POLYMOD_CODENAME . '/objects/');
while (false !== ($file = $packages_dir->read())) {
if (io::substr($file, -4) == ".php" && !in_array($file, $excludedFiles) && class_exists('CMS_' . io::substr($file, 0, -4))) {
$objectsCatalog[] = 'CMS_' . io::substr($file, 0, -4);
}
}
return $objectsCatalog;
}
开发者ID:davidmottet,项目名称:automne,代码行数:19,代码来源:object_catalog.php
示例14: deleteQueue
public function deleteQueue($c)
{
if (!DB::query('SELECT id from ' . self::TABLE . ' WHERE queue="' . $c . '"')) {
io::out("Queue {$c} is not exists", IO::MESSAGE_FAIL);
return;
}
if (IO::YES == io::dialog('Realy you really want to delete all jobs with queue ' . $c . '?', IO::NO | IO::YES, IO::NO)) {
DB::query("DELETE FROM " . self::TABLE . " WHERE queue='" . $c . "'");
io::done('Deleting...');
} else {
io::done('Cancel delete');
}
}
开发者ID:point,项目名称:cassea,代码行数:13,代码来源:CmdBgworkDelete.php
示例15: getTextDefinition
/**
* Get the text definition.
*
* @return string The text definition based on the current elements
* @access public
*/
function getTextDefinition()
{
$text = '';
foreach ($this->_elements as $atom) {
$text .= $atom[0];
if ($this->_valuesByAtom == 2) {
$text .= "," . $atom[1];
}
$text .= ";";
}
$text = io::substr($text, 0, -1);
return $text;
}
开发者ID:davidmottet,项目名称:automne,代码行数:19,代码来源:stack.php
示例16: __construct
/**
* Initialize the agent class.
*
* @return
*/
public function __construct()
{
// Initialize
self::timeout();
self::secure();
// Configure user agent (name)
$this->data['agent']['name'] = \io::helper('web')->proper();
// Configure user agent (site or domain)
$this->data['agent']['site'] = \io::helper('web')->site();
// Prepares parameters for new CURL request
$this->resetter('pre', 'post', 'status');
// Maximum number of redirects
$this->data['max_redirects'] = 10;
}
开发者ID:olscore,项目名称:ornithopter.io,代码行数:19,代码来源:agent.php
示例17: __construct
/**
* Constructor
*
* @param string $filename, the filename to use. io::sanitizeAsciiString will be used to clean this filename
* @param string $filepath, the filepath to use (FS relativeà). The path must exists and be writable. Default : PATH_TMP_FS
* @param string $separator, the CSV fields separator (default ;)
* @param string $enclosure, the CSV fields enclosure (default ")
* @return void
*/
function __construct($filename, $filepath = PATH_TMP_FS, $separator = ';', $enclosure = '"')
{
if (is_dir($filepath) && is_writable($filepath)) {
$this->_filepath = $filepath;
} else {
$this->raiseError('File path does not exists or is not writable : ' . $filepath);
return false;
}
$this->_filename = io::sanitizeAsciiString($filename);
$this->_separator = $separator;
$this->_enclosure = $enclosure;
if (!($this->_file = @fopen($this->_filepath . '/' . $this->_filename, 'ab+'))) {
$this->raiseError('Cannot open file ' . ($this->_filepath . '/' . $this->_filename) . ' for writing');
return false;
}
}
开发者ID:davidmottet,项目名称:automne,代码行数:25,代码来源:array2csv.php
示例18: backgroundScript
/**
* Constructor.
* Initializes the process manager and lauches the action if all went well, then delete the PIDFile
* NOTE : SCRIPT_CODENAME is a constant that must be defined, and unique accross all usage of the background scripts
* (i.e. One background script for one application should have the same, but two applications having the same script shouldn't collate)
*
* @param boolean $debug Set to true if you want a debug of what the script does
* @return void
* @access public
*/
function backgroundScript($debug = false, $scriptID = 'Master')
{
$this->_debug = $debug;
$this->_processManager = new processManager(SCRIPT_CODENAME . '_' . $scriptID);
// Cleans previous PIDs
if (isset($_SERVER['argv']['3']) && $_SERVER['argv']['3'] == '-F') {
if (!APPLICATION_IS_WINDOWS) {
$tmpDir = dir($this->_processManager->getTempPath());
while (false !== ($file = $tmpDir->read())) {
if (io::strpos($file, SCRIPT_CODENAME) !== false) {
@unlink($this->_processManager->getTempPath() . '/' . $file);
}
}
} else {
$files = glob(realpath($this->_processManager->getTempPath()) . '/' . SCRIPT_CODENAME . '*.*', GLOB_NOSORT);
if (is_array($files)) {
foreach ($files as $file) {
if (!CMS_file::deleteFile($file)) {
$this->raiseError("Can't delete file " . $file);
}
}
}
}
}
//write script process PID File
if ($this->_processManager->writePIDFile()) {
if ($this->_debug) {
$this->raiseError("PID file successfully written (" . $this->_processManager->getPIDFileName() . ").");
}
//start script process
$this->activate($this->_debug);
//delete script process PID File
if ($this->_processManager->deletePIDFile()) {
if ($this->_debug) {
$this->raiseError("PID file successfully deleted (" . $this->_processManager->getPIDFileName() . ").");
}
} else {
$this->raiseError("Can not delete PID file (" . $this->_processManager->getPIDFileName() . ").");
}
exit;
} else {
if ($this->_debug) {
$this->raiseError("PID file already exists or impossible to write (" . $this->_processManager->getPIDFileName() . ").");
}
exit;
}
}
开发者ID:davidmottet,项目名称:automne,代码行数:57,代码来源:backgroundscript.php
示例19: __construct
/**
* Initialize cron helper class.
*
* @return object
*/
public function __construct()
{
// Initialize defaults
self::$data['jobs'] = array();
self::$data['crontab'] = '/usr/bin/crontab';
// Reads the crontab file into a string
$crontab = stream_get_contents(popen(self::$data['crontab'] . ' -l', 'r'));
// Iterates through all non-empty lines from crontab file
foreach (array_filter(explode(PHP_EOL, $crontab)) as $line) {
// Ignore comment lines
if (trim($line)[0] != '#') {
// Parse jobs into a developer friendly format
self::$data['jobs'][md5($line)] = self::parse($line);
}
}
// Register shortcut aliases using h::method();
\io::alias(__CLASS__, ['tasks', 'flush', 'schedule', 'unschedule']);
}
开发者ID:olscore,项目名称:ornithopter.io,代码行数:23,代码来源:cron.php
示例20: 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 . '~~~');
}
开发者ID:point,项目名称:cassea,代码行数:42,代码来源:CmdSwitch.php
注:本文中的io类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论