本文整理匯總了PHP中It類的典型用法代碼示例。如果您正苦於以下問題:PHP It類的具體用法?PHP It怎麽用?PHP It使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了It類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getAvailableComPortsList
/**
* Returns array of serial ports. Can return fake list for testing purposes.
*
* @return array Array of serial ports.
*/
public static function getAvailableComPortsList()
{
if (Yii::app()->params['show_fake_com_ports']) {
return array('COM1' => 'COM1', 'COM2' => 'COM2');
}
$output = null;
$result = array();
if (It::isLinux()) {
exec('setserial -g /dev/ttyS*', $output);
if (is_array($output)) {
foreach ($output as $line) {
$matches = array();
if (preg_match('/\\/dev\\/ttyS([0-9])/', $line, $matches)) {
$serialPort = 'COM' . ($matches[1] + 1);
$result[$serialPort] = $matches[0];
}
}
}
$result = array_unique($result);
} else {
if (it::isWindows()) {
exec('wmic path Win32_SerialPort get Description, DeviceID /format:csv', $output);
if (is_array($output) && count($output) > 1) {
$output = array_slice($output, 2);
foreach ($output as $line) {
$values = explode(',', $line);
$result[$values[2]] = $values[1];
}
}
}
}
return $result;
}
示例2: _sendInMessageBody
protected function _sendInMessageBody()
{
$stationsIdCodesArray = array();
$reportStationsMessage = '';
foreach ($this->scheduleProcessedReports as $process) {
$file_path = dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "files" . DIRECTORY_SEPARATOR . "schedule_reports" . DIRECTORY_SEPARATOR . $process->schedule_processed_id;
$report_type = strtoupper($this->schedule_report->report_type);
$fileArray['file_name'] = $process->ScheduleReportToStation->realStation->station_id_code . '_' . $report_type . '_' . gmdate('Y-m-d_Hi', strtotime($process->check_period_end)) . '.' . $this->schedule_report->report_format;
$fileArray['file_string'] = file_get_contents($file_path);
$attachments[] = $fileArray;
$reportStationsMessage .= '<b>' . $process->ScheduleReportToStation->realStation->station_id_code . ' ';
$reportStationsMessage .= $report_type . ' </b><br> ';
$reportStationsMessage .= $fileArray['file_string'];
$reportStationsMessage .= "<br>=====================================================<br><br>";
$stationsIdCodesArray[] = $process->ScheduleReportToStation->realStation->station_id_code;
}
$this->_logger->log(__METHOD__ . ' stations: ' . print_r($stationsIdCodesArray, 1));
$mail_params = array('{report_id}' => $this->schedule_report->schedule_id, '{stations_id_code}' => implode(', ', $stationsIdCodesArray), '{actuality_time}' => $this->scheduleProcessedReports[0]->created, '{schedule_period}' => Yii::app()->params['schedule_generation_period'][$this->schedule_report->period], '{link}' => Yii::app()->params['site_url_for_console'] . '/site/schedulehistory/schedule_id/' . $this->schedule_report->schedule_id, '{report_type}' => $report_type, '{messages_content}' => $reportStationsMessage);
$subject = Yii::t('letter', 'scheduled_report_allstations_mail_subject', $mail_params, null, 'en');
$body = Yii::t('letter', 'scheduled_report_allstations_messages_inside_mail_message', $mail_params, null, 'en');
if (count($this->destinations) > 0) {
foreach ($this->destinations as $i => $destination) {
if ($destination->method === 'mail') {
It::sendLetter($destination->destination_email, $subject, $body);
}
}
}
}
示例3: _prepareDataPairs
public function _prepareDataPairs()
{
$body = str_replace('MM', '00', $this->incoming_sensor_value);
$length = strlen($body);
if ($length != 123 && $length != 7) {
return false;
}
if ($length == 7) {
return true;
}
$message = substr($body, 3, 120);
$rain_data_minutes = str_split($message, 2);
$event_period_sum = 0;
$initial_time = $this->incoming_measuring_timestamp;
$needed_feature = array();
foreach ($this->sensor_features_info as $feature) {
if ($feature['feature_code'] == 'rain') {
$needed_feature = $feature;
}
}
foreach ($rain_data_minutes as $rain_key => $rain_value) {
$rain_value = $rain_value == 'MM' ? 0 : intval($rain_value);
$initial_time_shifted = $initial_time - 60 * $rain_key;
$this->prepared_pairs[] = array('feature_code' => 'rain', 'period' => 1, 'value' => $rain_value, 'measuring_timestamp' => $initial_time_shifted, 'metric_id' => $needed_feature['metric_id'], 'normilized_value' => It::convertMetric($rain_value, $needed_feature['metric_code'], $needed_feature['general_metric_code']));
}
return true;
}
示例4: 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);
}
示例5: setTimeStep
public function setTimeStep()
{
$this->parse_time = false;
$nextTimeSeconds = ScheduleTypeReports::getNextPeriodTime($this->period * 60, It::timeToUnixTimestamp($this->next_run_planned));
$this->next_run_planned = date('Y-m-d H:i:s', $nextTimeSeconds);
$nextTimeSeconds = ScheduleTypeReports::getNextPeriodTime($this->period * 60, It::timeToUnixTimestamp($this->start_datetime));
$this->start_datetime = date('Y-m-d H:i:s', $nextTimeSeconds);
$this->save(false);
}
示例6: 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");
}
}
}
示例7: generateMessage
public function generateMessage()
{
$station = Station::model()->findByPk($this->station_id);
$command = 'C';
$command .= $station->station_id_code;
$command .= $this->sms_command_code;
$command .= implode($this->sms_command_params ? $this->sms_command_params : []);
$command .= It::prepareCRC($command);
$command = '@' . $command . '$';
return $command;
}
示例8: prepareXMLValue
public function prepareXMLValue($xml_data, $db_features)
{
if ($xml_data['water_level'][0] == 'M') {
$direction = 'M';
$data = 'MMM';
} else {
$tmp = 10 * It::convertMetric($xml_data['water_level'], 'mm', $db_features['water_level']);
$direction = $tmp > 0 ? '1' : '0';
$data = str_pad(abs(round($tmp)), 3, "0", STR_PAD_LEFT);
}
return $direction . $data;
}
示例9: 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;
}
示例10: _prepareDataPairs
public function _prepareDataPairs()
{
$length = strlen($this->incoming_sensor_value);
$initial_time = $this->incoming_measuring_timestamp;
$needed_feature = array();
foreach ($this->sensor_features_info as $feature) {
if ($feature['feature_code'] == 'rain') {
$needed_feature = $feature;
}
}
$this->prepared_pairs[] = array('feature_code' => 'rain', 'period' => 1, 'value' => $this->incoming_sensor_value, 'measuring_timestamp' => $this->incoming_measuring_timestamp, 'metric_id' => $needed_feature['metric_id'], 'normilized_value' => It::convertMetric($this->incoming_sensor_value, $needed_feature['metric_code'], $needed_feature['general_metric_code']));
return true;
}
示例11: actionCheckExtraUpdate
function actionCheckExtraUpdate()
{
ini_set('memory_limit', '-1');
set_time_limit(0);
// $version = getConfigValue('version');
$version = array();
$method_name = 'm_' . $version['stage'] . '_' . $version['sprint'] . '_' . $version['update'];
$form = new UpdateScriptForm();
if (method_exists($form, $method_name)) {
$form->{$method_name}(Yii::app()->db);
It::memStatus('update__success');
}
$this->redirect($this->createUrl('update/index'));
//print ('<script type="text/javascript"> setTimeout(function(){document.location.href="'.Yii::app()->controller->createUrl('update/index').'"}, 500)</script>');
}
示例12: run
public function run($args)
{
if (empty($args[0])) {
exit;
}
$logger = LoggerFactory::getFileLogger('listener/' . $args[0]);
// $logger = LoggerFactory::getConsoleLogger();
$logger->log(__METHOD__ . ' args:' . print_r($args, 1));
// creates object of ProcessListen class, which duty is listening
try {
(new ProcessListen($logger, $args[0], $args[1], $args[2]))->run();
} catch (Exception $e) {
It::sendLetter(Yii::app()->params['developer_email'], 'Problem', $e->getMessage());
}
}
示例13: run
public function run($args)
{
// don't run backup at the most busy minutes
if (in_array(date('i'), array('00', '01', '15', '16', '30', '31', '45', '46'))) {
return;
}
if (Yii::app()->mutex->lock('BackupOldData', 60 * 60)) {
try {
$obj = new BackupOldData();
$obj->run();
} catch (Exception $e) {
It::debug('BackupOldDataCommand: backup old data process was failed: ' . $e->getMessage(), 'backup_database');
}
Yii::app()->mutex->unlock();
}
}
示例14: actionImportMessage
public function actionImportMessage()
{
if (It::isGuest()) {
print json_encode(array('errors' => array('Sign in first.'), 'ok' => 0));
CApplication::end();
}
$message = isset($_POST['message']) ? trim($_POST['message']) : null;
if ($message) {
$st = time();
$settings = Settings::model()->find();
ListenerLogTemp::addNew($message, 0, $settings->overwrite_data_on_import, 'import', 0);
// ListenerLog::addNew($message, 0, $settings->overwrite_data_on_import, 'import', 0);
print json_encode(array('ok' => 1));
} else {
print json_encode(array('ok' => 0));
}
CApplication::end();
}
示例15: createSync
public function createSync()
{
$applicationsPaths = $this->getConfigFile('application_params');
if (TaskManager::check($this->sync_id) === false) {
$command = $applicationsPaths['php_exe_path'] . " -f " . dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "console.php syncdb";
TaskManager::create($this->sync_id, $command, $this->sync_periodicity, $this->sync_interval, $this->sync_startTime);
}
if (TaskManager::check($this->db_backup_id) === false) {
$backup_path = Yii::app()->params['backups_path'] . DIRECTORY_SEPARATOR . (It::isLinux() ? '`echo "$""(date +\\%a)"`' : '%DATE:~0,3%') . '_long.sql';
// Schedule daily database backup
// $command = $install->getConfigSection('path','mysqldump_exe_path') .
$command = $applicationsPaths['mysqldump_exe_path'] . ' --user="' . $this->user . '"' . ' --password="' . $this->password . '"' . ' --result-file="' . $backup_path . '" ' . $this->dbname;
TaskManager::create($this->db_backup_id, $command, 'daily', 1, '4:00');
}
if (TaskManager::check($this->heartbeat_id) === false) {
$command = $applicationsPaths['php_exe_path'] . " -f " . dirname(Yii::app()->request->scriptFile) . DIRECTORY_SEPARATOR . "console.php heartbeatreport";
TaskManager::create($this->heartbeat_id, $command, 'minutely', 10);
}
}