本文整理匯總了PHP中It::isWindows方法的典型用法代碼示例。如果您正苦於以下問題:PHP It::isWindows方法的具體用法?PHP It::isWindows怎麽用?PHP It::isWindows使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類It
的用法示例。
在下文中一共展示了It::isWindows方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: test_SerialPortList_Windows
public function test_SerialPortList_Windows()
{
$this->assertTrue(It::isWindows());
Yii::app()->params['show_fake_com_ports'] = false;
$result = SysFunc::getAvailableComPortsList();
$expected = array('COM1' => 'Последовательный порт', 'COM2' => 'Последовательный порт');
$this->assertEquals($expected, $result);
}
示例2: killProcess
/**
* Kills process with PID = $pid
*
* @param int $pid
* @return boolean
*/
public static function killProcess($pid)
{
if (It::isLinux()) {
exec('kill -s KILL ' . $pid);
} else {
if (It::isWindows()) {
exec("taskkill /pid " . $pid . " /f");
}
}
}
示例3: killProcess
public function killProcess($pid)
{
self::getLogger()->log(__METHOD__, array('PID' => $pid));
if (It::isLinux()) {
exec('kill -s KILL ' . $pid);
} else {
if (It::isWindows()) {
exec("taskkill /pid " . $pid . " /f");
}
}
}
示例4: rules
public function rules()
{
$res = array(array('overwrite_data_on_import,overwrite_data_on_listening', 'boolean', 'falseValue' => 0, 'trueValue' => 1, 'on' => 'other'), array('current_company_name', 'required', 'on' => 'other'), array('current_company_name', 'length', 'max' => 50, 'allowEmpty' => false, 'on' => 'other'), array('xml_check_frequency', 'numerical', 'integerOnly' => true, 'on' => 'other'), array('local_timezone_id', 'length', 'allowEmpty' => false, 'on' => 'other'), array('mail__use_fake_sendmail', 'boolean', 'allowEmpty' => false, 'trueValue' => 1, 'falseValue' => 0, 'on' => 'mail'), array('mail__sender_address', 'email', 'allowEmpty' => false, 'on' => 'mail'), array('mail__sender_address,mail__sender_name,mail__sender_password,mail__smtp_server', 'length', 'max' => 255, 'allowEmpty' => false, 'on' => 'mail'), array('mail__smtp_port', 'numerical', 'integerOnly' => true, 'on' => 'mail'), array('mail__smtps_support', 'in', 'range' => array('auto', 'ssl', 'tls', 'none'), 'allowEmpty' => false, 'on' => 'mail'), array('db_exp_enabled', 'boolean', 'allowEmpty' => false, 'trueValue' => 1, 'falseValue' => 0, 'on' => 'dbexport'), array('db_exp_period', 'numerical', 'integerOnly' => true, 'on' => 'dbexport'), array('db_exp_frequency', 'numerical', 'integerOnly' => true, 'on' => 'dbexport'), array('db_exp_sql_host', 'checkHost', 'on' => 'dbexport'), array('db_exp_sql_host', 'checkHostExists', 'on' => 'dbexport'), array('db_exp_sql_port', 'numerical', 'integerOnly' => true, 'allowEmpty' => false, 'min' => 1, 'on' => 'dbexport'), array('db_exp_sql_dbname', 'match', 'pattern' => '/^[A-Z,a-z,0-9,_,-]{0,30}$/', 'on' => 'dbexport'), array('db_exp_sql_dbname,db_exp_sql_login', 'required', 'on' => 'dbexport'), array('db_exp_sql_dbname,db_exp_sql_login', 'length', 'allowEmpty' => false, 'max' => 255, 'on' => 'dbexport'), array('db_exp_sql_password', 'checkUser', 'on' => 'dbexport'), array('scheduled_reports_path', 'safe', 'on' => 'other'));
if (It::isLinux()) {
$pattern = '/^[\\/]([A-Za-z0-9-_\\s\\/\\.]){1,251}$/';
//$res[] = array('scheduled_reports_path, xml_messages_path', 'match', 'pattern' => $pattern, 'on' => 'other');
} elseif (It::isWindows()) {
$pattern = '/^([A-Z]{1})(:\\\\)([A-Za-z0-9-_\\s\\.]+[\\\\]?){1,251}$/';
$res[] = array('scheduled_reports_path, xml_messages_path', 'match', 'pattern' => $pattern, 'on' => 'other');
}
return $res;
}
示例5: delete
/**
* Deletes task by name.
*
* @param string $name
*/
public static function delete($name)
{
if (It::isLinux()) {
exec('crontab -l | grep -v ' . $name . ' | crontab -');
} else {
if (It::isWindows()) {
exec('schtasks /delete /tn ' . $name . ' /f');
}
}
}
示例6: runAsynchCommand
public static function runAsynchCommand($command)
{
if (It::isLinux()) {
$output = null;
$return = null;
exec('nohup ' . $command . ' > /dev/null 2> /dev/null &', $output, $return);
} else {
if (It::isWindows()) {
@pclose(@popen('start /B ' . $command, 'r'));
}
}
}
示例7: actionDbsetup
public function actionDbsetup()
{
// #############################################################################
$backups_path = Yii::app()->params['backups_path'];
if (isset($_REQUEST['apply'])) {
$apply = trim($_REQUEST['apply']);
if (file_exists($backups_path . DIRECTORY_SEPARATOR . $apply)) {
ini_set('memory_limit', '-1');
set_time_limit(0);
$sql = file_get_contents($backups_path . DIRECTORY_SEPARATOR . $apply);
//use long or short db
if (stripos($apply, 'long')) {
$res = Yii::app()->db_long->createCommand($sql)->query();
} else {
$res = Yii::app()->db->createCommand($sql)->query();
}
It::memStatus('admin_backup_applied');
$this->redirect($this->createUrl('admin/dbsetup'));
}
}
if (isset($_REQUEST['delete'])) {
$delete = trim($_REQUEST['delete']);
if (file_exists($backups_path . DIRECTORY_SEPARATOR . $delete)) {
unlink($backups_path . DIRECTORY_SEPARATOR . $delete);
It::memStatus('admin_backup_deleted');
$this->redirect($this->createUrl('admin/dbsetup'));
}
}
if (isset($_REQUEST['create'])) {
$backup_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'backups';
if (It::isLinux()) {
$backup_path .= DIRECTORY_SEPARATOR . '`date +%Y_%m_%d`.sql';
} else {
if (It::isWindows()) {
$backup_path .= DIRECTORY_SEPARATOR . '%DATE:~7,4%_%DATE:~3,2%_%DATE:~0,2%.sql';
}
}
$command = Yii::app()->params['applications']['mysqldump_exe_path'] . ' --user="' . Yii::app()->params['db_params']['username'] . '"' . ' --password="' . Yii::app()->params['db_params']['password'] . '"' . ' --result-file="' . $backup_path . '" ' . Yii::app()->params['db_params']['dbname'];
if (DOCKER) {
$backup_name = '`date +%Y_%m_%d`.sql';
$command = 'echo ' . $backup_name . ' >' . dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'new';
}
set_time_limit(1800);
// 30min
$output = null;
$return = null;
exec($command, $output, $return);
if ($return == 0) {
It::memStatus('admin_backup_refreshed');
$this->redirect($this->createUrl('admin/dbsetup'));
}
}
if (isset($_REQUEST['create_long'])) {
$backup_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'backups';
if (It::isLinux()) {
$backup_path .= DIRECTORY_SEPARATOR . '`date +%Y_%m_%d`_long.sql';
} else {
if (It::isWindows()) {
$backup_path .= DIRECTORY_SEPARATOR . '%DATE:~7,4%_%DATE:~3,2%_%DATE:~0,2%_long.sql';
}
}
$command = Yii::app()->params['applications']['mysqldump_exe_path'] . ' --user="' . Yii::app()->params['db_long_params']['username'] . '"' . ' --password="' . Yii::app()->params['db_long_params']['password'] . '"' . ' --result-file="' . $backup_path . '" ' . Yii::app()->params['db_long_params']['dbname'];
if (DOCKER) {
$backup_name = '`date +%Y_%m_%d`_long.sql';
$command = 'echo ' . $backup_name . ' >' . dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . 'files' . DIRECTORY_SEPARATOR . 'backups' . DIRECTORY_SEPARATOR . 'new_long';
}
set_time_limit(1800);
// 30min
$output = null;
$return = null;
exec($command, $output, $return);
if ($return == 0) {
It::memStatus('admin_backup_refreshed');
$this->redirect($this->createUrl('admin/dbsetup'));
}
}
$outputs = null;
if (It::isLinux()) {
$cmd = 'ls -1At ' . $backups_path . ' | egrep -i *.sql';
exec($cmd, $outputs);
} else {
if (It::isWindows()) {
exec('dir ' . $backups_path . DIRECTORY_SEPARATOR . '*.sql /B /4 /T:C /O:D', $outputs);
array_slice($outputs, 0, -1);
}
}
$backups = array();
foreach ($outputs as $output) {
$backups[] = array('filename' => $output, 'created' => filemtime($backups_path . DIRECTORY_SEPARATOR . $output));
}
// #############################################################################
$settings = Settings::model()->find();
if (is_null($settings)) {
$settings = new Settings();
}
$settings->scenario = 'dbexport';
if (Yii::app()->request->isPostRequest && isset($_POST['Settings'])) {
$settings->attributes = $_POST['Settings'];
if (!$settings->attributes['db_exp_enabled']) {
Settings::model()->updateByPk(1, array('db_exp_enabled' => 0));
//.........這裏部分代碼省略.........
示例8: test_IsWindows
public function test_IsWindows()
{
$result = It::isWindows();
$expected = substr(strtolower(php_uname('s')), 0, 7) === 'windows';
$this->assertEquals($expected, $result);
}
示例9: calculateData
/**
* Calculated data
*/
private function calculateData()
{
$databases = array('db' => false, 'db_long' => true);
/**
* for last backups
*/
$backups_path = Yii::app()->params['backups_path'];
$outputs = null;
if (It::isLinux()) {
$cmd = 'ls -1At ' . $backups_path . ' | egrep -i *.sql';
exec($cmd, $outputs);
} else {
if (It::isWindows()) {
exec('dir ' . $backups_path . DIRECTORY_SEPARATOR . '*.sql /B /4 /T:C /O:D', $outputs);
array_slice($outputs, 0, -1);
}
}
/*
* $db_small_stat
* $db_long_small_stat
*/
foreach ($databases as $database => $var) {
$this->{$database . '_small_stat'} = array('Uptime' => number_format($this->{$database . '_stat'}['Uptime'] / 60 / 60) . 'h' . $this->{$database . '_stat'}['Uptime'] % 60 . 'm', 'Queries' => $this->{$database . '_stat'}['Queries']);
foreach ($outputs as $output) {
if (strpos($output, '_long.sql')) {
if ($var) {
$this->{$database . '_small_stat'}['Last_backup'] = date("y-m-d H:i", filemtime($backups_path . DIRECTORY_SEPARATOR . $output));
break;
}
} else {
if (!$var) {
$this->{$database . '_small_stat'}['Last_backup'] = date("y-m-d H:i", filemtime($backups_path . DIRECTORY_SEPARATOR . $output));
break;
}
}
}
$this->{$database . '_small_stat'} += array('Size' => $this->{$database . '_tables_size'}['All'] . 'Mb', 'Data_read' => number_format($this->{$database . '_stat'}['Innodb_data_read'] / 1024) . 'Mb', 'Data_writes' => number_format($this->{$database . '_stat'}['Innodb_data_writes'] / 1024) . 'Mb', 'Rows' => $this->{$database . '_tables_rows'}['All'], 'Rows_deleted' => $this->{$database . '_stat'}['Innodb_rows_deleted'], 'Rows_inserted' => $this->{$database . '_stat'}['Innodb_rows_inserted'], 'Rows_read' => $this->{$database . '_stat'}['Innodb_rows_read'], 'Rows_updated' => $this->{$database . '_stat'}['Innodb_rows_updated'], 'Connections' => $this->{$database . '_stat'}['Connections']);
}
}