Свойства класса:
Методы класса:
Объекты класса:
// это однократный будильник, выключем его sg("AlarmOne.AlarmOn",0); // все проснулись setGlobal("SleepAllMode.active",0); say('Пора вставать!'); // включим радио callMethod("Radio.RadioPlay"); // запланируем выключить радио через 1час SetTimeOut("AlarmOne_RadioStop",'callMethod("Radio.RadioStop");', 3600);
{ if (isWeekDay()){ // сегодня рабочий день // все проснулись setGlobal("SleepAllMode.active",0); say('Пора вставать!'); // включим радио callMethod("Radio.RadioPlay"); // запланируем выключить радио SetTimeOut("AlarmWeekEnd_RadioStop",'callMethod("Radio.RadioStop");', 60*60); } }
{ if (isWeekEnd()){ // сегодня выходной день // все проснулись setGlobal("SleepAllMode.active",0); say('Пора вставать!'); // включим радио callMethod("Radio.RadioPlay"); // запланируем выключить радио SetTimeOut("AlarmWeekEnd_RadioStop",'callMethod("Radio.RadioStop");', 60*60); } }
Свойства класса:
Методы класса:
Объекты класса:
$command=$params['command']; $short_command=''; $dt=recognizeTime($command,$short_command); if (preg_match('/скажи сколько время/is',$command)) { if ($dt>0) { addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt); say('Задача принята'); return; } global $voicemode; $voicemode='on'; say('Сейчас '.timeNow()); } elseif (preg_match('/сколько время/is',$command)) { if ($dt>0) { addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt); say('Задача принята'); echo $short_command; return; } say('Сейчас '.timeNow()); } elseif (preg_match('/повтори (.+)/is',$command,$m) || preg_match('/скажи (.+)/is',$command,$m)) { if ($dt>0) { addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt); say('Задача принята'); return; } global $voicemode; $voicemode='on'; say($m[1]); } else { say('Неизвестная команда...'); }
say("Отключено питание");
Свойства класса:
Методы класса:
$this->setProperty('status',$params['status']); $this->setProperty('updatedTimestamp',time()); $this->setProperty("alive",1); $ot=$this->object_title; $alive_timeout=(int)$this->getProperty("aliveTimeOut"); if (!$alive_timeout) { $alive_timeout=12*60*60; } clearTimeOut($ot."_alive"); setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);
Свойства класса:
Методы класса:
$this->setProperty('status',$params['status']); $this->setProperty('updatedTimestamp',time()); $this->setProperty('alive',1); $ot=$this->object_title; $alive_timeout=(int)$this->getProperty("aliveTimeOut"); if (!$alive_timeout) { $alive_timeout=24*60*60; } clearTimeOut($ot."_alive"); setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout); if ($params['status']) { $this->setProperty('motionDetected',1); clearTimeOut($this->object_title.'_detected'); setTimeOut($this->object_title.'_detected',"setGlobal('".$this->object_title.".motionDetected',0);",30); $linked_room=$this->getProperty('LinkedRoom'); if ($linked_room!='') { callMethod($linked_room.'.onActivity'); } if (getGlobal('somebodyHome')!=1) { setGlobal('somebodyHome',1); } $last_register=registeredEventTime('inhouseMovement'); registerEvent('inhouseMovement',$this->name,2); if (!$last_register || ((time()-$last_register)>2*60*60)) { if (timeBetween('06:00', '12:00')) { runScript('morningGreeting'); } if (timeBetween('16:00', '01:00')) { runScript('eveningGreeting'); } } }
Свойства класса:
Методы класса:
$file = simplexml_load_file("http://www.cbr.ru/scripts/XML_daily.asp?date_req=".date("d/m/Y".rand())); // USD $xml = $file->xpath("//Valute[@ID='R01235']"); $valute = strval($xml[0]->Value); $this->setProperty('USD', round(str_replace(",",".",$valute)*100)/100); // EURO $xml = $file->xpath("//Valute[@ID='R01239']"); $valute = strval($xml[0]->Value); $this->setProperty('EURO', round(str_replace(",",".",$valute)*100)/100); $this->setProperty("uptime",date("d m Y H:i:s",time())); say("Курс валют обновлен", 0);
Объекты класса:
if (!isOnline('Internet')) { return; } $file = simplexml_load_file("http://www.cbr.ru/scripts/XML_daily.asp?date_req=".date("d/m/Y")); // Американский доллар $xml = $file->xpath("//Valute[@ID='R01235']"); $valute = strval($xml[0]->Value); $valute = str_replace(",",".",$valute); $valute = round($valute,2); sg("USD",$valute); // Евро $xml = $file->xpath("//Valute[@ID='R01239']"); $valute = strval($xml[0]->Value); $valute = str_replace(",",".",$valute); $valute = round($valute,2); sg("EURO",$valute); say("Курс валют обновлен", 0);
Свойства класса:
Методы класса:
Объекты класса:
Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty("updated",time()); $this->setProperty("updatedTime",date('H:i')); if ($this->getProperty('status')) { say("Ночной режим ".$this->getProperty('title')." активирован."); } else { say("Ночной режим ".$this->getProperty('title')." отключен."); }
sg('DarknessMode.volumebefore', gg('ThisComputer.volumeLevel'));//Записываем текущую громкость в DarknessMode.volumebefore CallMethod('ThisComputer.VolumeLevelChanged', array('VALUE'=>0)); //Выставляем системную громкость на 0 say('Ночной режим активирован');
$this->setProperty('active',0); CallMethod('ThisComputer.VolumeLevelChanged', array('VALUE'=>gg('DarknessMode.volumebefore'))); //Возвращаем громкость на уровень до включения режима say('Ночной режим отключен');
Объекты класса:
Свойства класса:
Методы класса:
Объекты класса:
//say("Установим уровень громкости радио ".getGlobal("Radio.RadioVolume").""); $vol=gg("Radio.RadioVolume"); $url=gg("Radio.URL"); getURL($url.'/requests/status.xml?command=volume&val='.$vol,0);
if (getGlobal("Radio.RadioIsPlay")){ getURL(gg("Radio.UrlStancia"),0); //say("Включаю радио"); setGlobal("Radio.RadioPlayBeginTime",time()); setGlobal("Radio.RadioMenuOn",Вкл); setGlobal("Radio.RadioLedOn",10); }else{ getURL(gg("Radio.URL").'/requests/status.xml?command=pl_stop',0); //say("Радио выключено"); setGlobal("Radio.RadioMenuOn",Выкл); setGlobal("Radio.RadioLedOn",5); }
$this->setProperty("RadioIsPlay",0); $this->callMethod("RadioSwitch");
//if(!getGlobal("NobodyHomeMode.active")){ $this->setProperty("RadioIsPlay",1); $this->callMethod("RadioSwitch"); //}else{ // say('Никого нет дома, радио не включаю'); //}
$stX=(gg("Radio.Stancia")); $url=gg("Radio.URL"); switch ($stX){ case 'Record': $urlS=$url.'/requests/status.xml?command=in_play&input=http://air.radiorecord.ru:8101/rr_320'; break; case 'Trancemission': $urlS=$url.'/requests/status.xml?command=in_play&input=http://air.radiorecord.ru:8102/tm_320'; break; case 'Russian Mix': $urlS=$url.'/requests/status.xml?command=in_play&input=http://air.radiorecord.ru:8102/rus_320'; break; } getURL($urlS,0); setGlobal('Radio.UrlStancia',$urlS);
include_once(DIR_MODULES.'app_radio/app_radio.class.php'); $app_radio=new app_radio(); if(is_array($params)) { if(isset($params['sta'])) $app_radio->change_station($params['sta'],$app_radio); if(isset($params['cmd'])) $app_radio->control($params['cmd']); if(isset($params['vol'])) $app_radio->set_volume($params['vol'],$app_radio); } else { if($params=='play' || $params=='stop') $app_radio->control($params); else if(strpos($params, "vol")===0) $app_radio->set_volume((int)substr($params,3),$app_radio); else if(strpos($params, "sta:")===0) $app_radio->change_station(substr($params,4),$app_radio); }
Свойства класса:
Методы класса:
$this->setProperty("status",0);
$this->setProperty("status",1);
$status=$this->getProperty("status"); if ($status) { $this->callMethod('turnOn'); } else { $this->callMethod('turnOff'); }
$status=$this->getProperty("status"); if ($status) { $this->callMethod('turnOff'); } else { $this->callMethod('turnOn'); }
Объекты класса:
Свойства класса:
Методы класса:
$latestActivity=$this->getProperty('LatestActivity'); $this->setProperty('LatestActivity',time()); $this->setProperty('LatestActivityTime',date('H:i')); $this->setProperty('SomebodyHere',1); $ot=$this->object_title; $activity_timeout=10*60; clearTimeOut($ot."_activity_timeout"); setTimeOut($ot."_activity_timeout","callMethod('".$ot.".onIdle');",$activity_timeout);
$this->setProperty('SomebodyHere',0);
Объекты класса:
Методы класса:
Объекты класса:
echo "status received: ".$params['status'];
global $voicemode; $voicemode='off'; processCommand($params['message']);
Свойства класса:
Методы класса:
Объекты класса:
$details=array(); $red_state=0; $yellow_state=0; if ($red_state) { $state='red'; $state_title='Красный'; } elseif ($yellow_state) { $state='yellow'; $state_title='Желтый'; } else { $state='green'; $state_title='Зеленый'; } $new_details=implode(". ",$details); if ($this->getProperty("stateDetails")!=$new_details) { $this->setProperty('stateDetails',$new_details); } if ($this->getProperty('stateColor')!=$state) { $this->setProperty('stateColor',$state); $this->setProperty('stateTitle',$state_title); if ($state!='green') { say("Статус системы изменен на ".$state_title."."); say(implode(". ",$details)); } else { say("Статус системы восстановлен на ".$state_title); } $this->callMethod('stateChanged'); }
$details=array(); $red_state=0; $yellow_state=0; $cycles=array('states'=>'states cycle','main'=>'main cycle','execs'=>'exec cycle','scheduler'=>'scheduler cycle'); foreach($cycles as $k=>$v) { $tm=getGlobal('ThisComputer.cycle_'.$k.'Run'); if (time()-$tm>5*60) { $red_state=1; $details[]=$v." stopped."; } } $cycles=array('ping'=>'ping cycle','webvars'=>'webvars cycle','watchfolders'=>'watch folders cycle','rss'=>'RSS cycle'); foreach($cycles as $k=>$v) { $tm=getGlobal('ThisComputer.cycle_'.$k.'Run'); if (time()-$tm>10*60) { $yellow_state=1; $details[]=$v." stopped."; } } if ($red_state) { $state='red'; $state_title='Red'; } elseif ($yellow_state) { $state='yellow'; $state_title='Yellow'; } else { $state='green'; $state_title='Green'; } $new_details=implode(". ",$details); if ($this->getProperty("stateDetails")!=$new_details) { $this->setProperty('stateDetails',$new_details); } if ($this->getProperty('stateColor')!=$state) { $this->setProperty('stateColor',$state); $this->setProperty('stateTitle',$state_title); if ($state!='green') { say("System state changed to ".$state_title."."); say(implode(". ",$details)); } else { say("System state restored to ".$state_title); } $this->callMethod('stateChanged'); }
$details=array(); $red_state=0; $yellow_state=0; if ($red_state) { $state='red'; $state_title='Red'; } elseif ($yellow_state) { $state='yellow'; $state_title='Yellow'; } else { $state='green'; $state_title='Green'; } $new_details=implode(". ",$details); if ($this->getProperty("stateDetails")!=$new_details) { $this->setProperty('stateDetails',$new_details); } if ($this->getProperty('stateColor')!=$state) { $this->setProperty('stateColor',$state); $this->setProperty('stateTitle',$state_title); if ($state!='green') { say("System state changed to ".$state_title."."); say(implode(". ",$details)); } else { say("System state restored to ".$state_title); } $this->callMethod('stateChanged'); }
Свойства класса:
Методы класса:
//$params['t'] $this->setProperty("updated",time()); $this->setProperty("updatedTime",date("H:i",time())); $this->setProperty("alive",1); $ot=$this->object_title; $alive_timeout=(int)$this->getProperty("aliveTimeOut"); if (!$alive_timeout) { $alive_timeout=30*60; } clearTimeOut($ot."_alive"); setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout); if (!isset($params['t'])) { return; } $old_humidity=$this->getProperty('humidity'); $t=round($params['h'],1); $this->setProperty('humidity',$t); if ($t>$old_humidity) { $d=1; } elseif ($t<$old_humidity) { $d=-1; } else { $d=0; } $old_temp=$this->getProperty('temp'); $t=round($params['t'],1); if ($t>110) return; $this->setProperty('temp',$t); if ($params['uptime']) { $this->setProperty('uptime',$params['uptime']); } if ($t>$old_temp) { $d=1; } elseif ($t<$old_temp) { $d=-1; } else { $d=0; } $this->setProperty('direction',$d); $linked_room=$this->getProperty("LinkedRoom"); if ($linked_room) { setGlobal($linked_room.'.Temperature',$t); }
Объекты класса:
Свойства класса:
Методы класса:
//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module//START openweather module $updateTime = gg('ow_setting.updateTime'); if($updateTime > 0) { $count = gg('ow_setting.countTime'); if($count >= $updateTime) { include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php'); $app_openweather = new app_openweather(); $app_openweather->get_weather(gg('ow_city.id')); sg('ow_setting.countTime', 1); } else { $count++; sg('ow_setting.countTime', $count); } } // END openweather module/* START yaWeather module*/ $updateTime = gg('yw_setting.updateTime'); if($updateTime > 0){ $count = gg('yw_setting.countTime'); if($count >= $updateTime){ include_once(DIR_MODULES.'app_yaweather/app_yaweather.class.php'); $app_yaweather=new app_yaweather(); $app_yaweather->get_weather(gg('yw_setting.city_id')); sg('yw_setting.countTime',1); } else { $count++; sg('yw_setting.countTime',$count); } }/* END yaWeather*/
$h=(int)date('G',time()); $m=date('i',time()); //Записываем текущее время sg("ThisComputer.timeNow",date( "H:i", time())); if (isWeekDay()) { } setGlobal('testOnNewMinute.value', 'START'); setGlobal('testOnNewMinute.value', 'OK'); if (($h>=8)) { if ($m=="00") { say(timeNow()); } } runScript('timer_2s'); //Ночной режим if (timeIs(getGlobal('DarknessMode.timeon'))) { callMethod('DarknessMode.activate'); } if (timeIs(getGlobal('DarknessMode.timeoff'))) { callMethod('DarknessMode.deactivate'); } //будильник $objects=getObjectsByClass("AlarmClock"); foreach($objects as $obj) { // переберем все будильники в системе if (getGlobal($obj['TITLE'].".AlarmOn") && timeIs(getGlobal($obj['TITLE'].".AlarmTime"))){ //если будильник включен и время совпало callMethod($obj['TITLE'].".AlarmRun"); // выполним метод будильника } }
$seconds = date('s', time()); $seconds = $seconds / 10; $a = ""; for ($i = 0; $i <= $seconds; $i++) { $a = $a.'●'; }
Объекты класса:
$h=(int)date('G',time()); $m=date('i',time()); //1 //Записываем текущее время sg("ThisComputer.timeNow",date( "H:i", time())); if (isWeekDay()) { } setGlobal('testOnNewMinute.value', 'START'); setGlobal('testOnNewMinute.value', 'OK'); if (($h>=8)) { if ($m=="00") { say(timeNow()); } } runScript('timer_2s'); //Ночной режим if (timeIs(getGlobal('DarknessMode.timeon'))) { callMethod('DarknessMode.activate'); } if (timeIs(getGlobal('DarknessMode.timeoff'))) { callMethod('DarknessMode.deactivate'); } $uptime=shell_exec('uptime'); setGlobal("ThisComputer.uptime",$uptime); $mem=shell_exec("free -m|grep Mem|awk '{print $2,$3,$4}'"); $mem=explode(" ",$mem); $mem="Всего: ".$mem[0]." Занято: ".$mem[1]." Доступно: ".$mem[2]; setGlobal("ThisComputer.memory",$mem); $disk=shell_exec("df -h|grep sda0|awk '{print $2,$3,$5}'"); // p.s. sda1 нужно изменить на свой диск $disk=explode(" ",$disk); $disk=$disk[1]."/".$disk[0]." ( ".$disk[2].")"; setGlobal("ThisComputer.driveStatus",$disk); //будильник $objects=getObjectsByClass("AlarmClock"); foreach($objects as $obj) { // переберем все будильники в системе if (getGlobal($obj['TITLE'].".AlarmOn") && timeIs(getGlobal($obj['TITLE'].".AlarmTime"))){ //если будильник включен и время совпало callMethod($obj['TITLE'].".AlarmRun"); // выполним метод будильника } }
//проверяем IP-адрес сервера и порт $sql="SELECT * FROM `terminals`"; $value=SQLSelectOne($sql); setGlobal('Radio.HOST',$value['HOST']); setGlobal('Radio.PORT',$value['PLAYER_PORT']); setGlobal('Radio.PLAYER_PASSWORD',$value['PLAYER_PASSWORD']); setGlobal('Radio.PLAYER_USERNAME',$value['PLAYER_USERNAME']); $url='http://'.$value['PLAYER_USERNAME'].':'.$value['PLAYER_PASSWORD'].'@'.$value['HOST'].":".$value['PLAYER_PORT']; setGlobal('Radio.URL',$url); runScript('informer_primety'); runScript('bashorg'); // обновим курс валюты каждые 4 часа if (!($h%4)) {callMethod("cbr.update");} $h=(int)date('G',time()); $day[0]="Воскресенье"; $day[1]="Понедельник"; $day[2]="Вторник"; $day[3]="Среда"; $day[4]="Четверг"; $day[5]="Пятница"; $day[6]="Суббота"; if (($h=="00")) { sg("ThisComputer.Date",date( "d.m.Y", time())); sg("ThisComputer.Day",$day[date("w")]); }
$seconds = date('s', time()); $seconds = $seconds / 10; $a = ""; for ($i = 0; $i <= $seconds; $i++) { $a = $a.'●'; }
Свойства класса:
Методы класса:
// МЕТОД view - подготовка кода для отображения $todo = $this->getProperty("todo"); // установим внутреннюю кодировку символов mb_internal_encoding("UTF-8"); $td = explode("|", $todo); $str_cod = '<div id="list"> <div class="new"> <input id="newtask" placeholder="New Item" type="text"> <button onClick="btnRunClicked();" class="fa fa-plus"></button> </div> <div class="list">'; for($i = 1; $i < sizeof($td); $i++) { // выделим и сохраним первый символ $check = mb_substr($td[$i], 0, 1); // обрежем строку, не будем отображать первый символ + или - $task = mb_substr($td[$i], 1); // начинаем формировать код hsl(196,'.(73-24*(($i-1)%2)).'%,50%) $str_cod = $str_cod.' <div class="item" id="taskbox_'.$i.'" style ="background: hsl('.(190+$i*6).',73%,50%);"> <span id="task_'.$i.'"'; // если певый символ "+" то значит задание "выполнено" if ($check == "+") { $str_cod = $str_cod.' class="checked"'; } $str_cod = $str_cod.'>'.$task.'</span>'; $str_cod = $str_cod.' <div class="rightblock"> <button id="check_'.$i.'" class="check fa fa-check" onClick="checkClicked('.$i.');"></button> <button id="delete_'.$i.'" class="delete fa fa-times" onClick="deleteClicked('.$i.');"></button> </div> </div>'; } $str_cod = $str_cod.' </div> </div>'; // записываем получившийся код $this->setProperty("StreamingCodeScene",$str_cod); $str_cod_css = "<style>".$this->getProperty("menuCSS")."</style>"; $str_cod_js = "<script type='text/javascript'>".$this->getProperty("JS")."</script>"; $str_cod = $str_cod_css.$str_cod_js.$str_cod; $this->setProperty("StreamingCodeMenu",$str_cod);
// МЕТОД check $todo = $this->getProperty("todo"); // установим внутреннюю кодировку символов mb_internal_encoding("UTF-8"); $td = explode("|", $todo); if (isset($params["task"])) { $ct = $params["task"]; for($i = 0; ($i < sizeof($td)); $i++) { // выделим и сохраним первый символ $check = mb_substr($td[$i], 0, 1); // обрежем строку, не будем отображать первый символ + или - $task = mb_substr($td[$i], 1); // если совпадает номер строки if ($i == $ct) { // инвентируем check $check = ($check == "+") ? "-" : "+"; $tcheck = ($check == "+") ? ""выполненно"" : ""не выполнено""; $sayTodo = gg("Sets.sayTodo"); if ($sayTodo) { say ("Todo задача: "".$task."" - отмечена как ".$tcheck,($sayTodo-2)); } } $td[$i] = $check.$task; } $todo = implode("|", $td); $this->setProperty("todo", $todo); } // выполним подготовку для отображения // callMethod("TodoList.view");
// МЕТОД delete $todo = $this->getProperty("todo"); $dt = $params["task"]; // получаем номер строки на удаление $td = explode("|", $todo); // Считываем всё в массив for($i = 0; $i < sizeof($td); $i++) { if($i == $dt) { $sayTodo = gg("Sets.sayTodo"); if ($sayTodo) { say ("Из листа todo удалена задача: "".mb_substr($td[$i], 1).""",($sayTodo-2)); } unset($td[$i]); } } $todo = implode("|", $td); $this->setProperty("todo", $todo); // выполним подготовку для отображения // callMethod("TodoList.view");
// МЕТОД new if (isset($params["task"])) { $todo = $this->getProperty("todo"); $mytask = "-".$params["task"]; // строка задачи $sayTodo = gg("Sets.sayTodo"); if ($sayTodo) { say ("В лист todo добавлена задача: "".$params["task"].""",($sayTodo-2)); } $todo = $todo."|".$mytask; // добавляем с разделителем $this->setProperty("todo", $todo); }
Объекты класса:
// ****************************************************************** // * TO DO app - by Vovix - 30.11.2015 г. - v 3.1 * // ****************************************************************** // создадим класс и объекты addClass('ToDo'); addClassObject('ToDo','TodoList'); addClassProperty('ToDo','StreamingCodeMenu'); // HTML для меню addClassProperty('ToDo','StreamingCodeScene'); // HTML для сцен addClassProperty('ToDo','menuCSS'); // CSS для меню addClassProperty('ToDo','sceneCSS'); // CSS для сцены addClassProperty('ToDo','JS'); // общий код javascript addClassProperty('ToDo','todo'); // сам лист to do // $this->setProperty('todo', '- to do list by Vovix -'); $menuCSS=' @import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css"); #item194 { /* здесь item194 - это номер ID пункта меню в котором он размещен */ padding: 0; } #list { position: relative; /* width: calc(100% + 40px); */ /* margin: 0 -20px 0 -20px; */ width: 100%; margin: 0; } #list .new { width: 100%; height: 50px; padding: 0; margin: 0; } #list .new #newtask { float: left; width: calc(100% - 76px); height: 50px; padding: 0; margin: 0; background: #333333; text-indent: 8px; } #list .new input { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 14px; color: #FFF; text-align: justify; line-height: normal; outline: 0; border: 0; border-radius: 0px; text-shadow: none; } #list .new #newtask::-webkit-input-placeholder { color: rgba(255, 255, 255, 0.5); } #list .new button { cursor: pointer; float: right; width: 76px; height: 50px; padding: 0; outline: 0; border: 0; border-radius: 0px; margin: -9px 0 0 0; background: #111111; font-size: 24px; color: #FFF; } #list .list .item { clear: both; width: 100%; height: 38px; margin: 0; } #list .list .item span { cursor: default; float: left; width: calc(100% - 76px); height: 20px; padding: 9px 0 0 0; margin: 0; outline: 0; border: 0; background: transparent; text-indent: 8px; font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 14px; color: #FFF; text-align: justify; text-shadow: none; } #list .list .item span.checked { opacity: .5; text-decoration: line-through; } #list .list .item .rightblock { float: right; width: 76px; height: 38px; padding: 0; margin: 0; } #list .list .item .rightblock button { cursor: pointer; float: left; width: 38px; height: 38px; padding: 0px; margin: 0; outline: 0; border: 0; border-radius: 0px; background: rgba(0,0,0,0.1); font-size: 20px; color: #FFF; } '; $this->setProperty('menuCSS', $menuCSS); $sceneCSS=' #list { position: relative; width: 100%; max-height: 528px; overflow: auto; margin: 0; } #list .new #newtask { float: left; width: calc(100% - 100px); height: 100px; padding: 0; margin: 0; outline: 0; border: 0; background: #333333; line-height: 50px; text-indent: 25px; } #list .new input { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 28px; color: #FFF; text-align: justify; line-height: normal; outline: 0; border: 0; border-radius: 0px; text-shadow: 0px; } #list .new #newtask::-webkit-input-placeholder { color: rgba(255, 255, 255, 0.5); } #list .new button { cursor: pointer; float: right; width: 100px; height: 100px; padding: 0; margin: 0; outline: 0; border: 0; border-radius: 0px; background: #111111; font-size: 84px; color: #FFF; } #list .list .item { clear: both; width: 100%; height: 50px; margin: 0; padding: 5px 0 0 0; } #list .list .item span { cursor: default; float: left; width: calc(100% - 150px); height: 50px; padding: 0; margin: 0; outline: 0; border: 0; background: transparent; text-indent: 25px; font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 28px; color: #FFF; text-align: justify; line-height: normal; } #list .list .item span.checked { opacity: .5; text-decoration: line-through; } #list .list .item .rightblock { float: right; padding: 0; margin: -2px 0 0 0; } #list .list .item button{ cursor: pointer; float: left; width: 50px; height: 50px; padding: 0; margin: 0; outline: 0; border: 0; box-shadow: 0 0 3px rgba(0,0,0,0.2); background: rgba(0,0,0,0.1); font-size: 32px; color: #FFF; } '; $this->setProperty('sceneCSS', $sceneCSS); $JS=' function btnRunClicked() { var newtask = $("#newtask").val(), ni = $("div.item").length + 1; $("#newtask").val(""); if (newtask) { var task1 = String(newtask); var codItem1 = \'<div class="item" id="taskbox_\' + ni + \'" style ="background: hsl(\' + (190+ni*6) + \',73%,50%);">\'; var codItem2 = \'<span id="task_\' + ni + \'">\' + task1 + \'</span>\'; var codItem3 = \'<div class="rightblock"><button id="check_\' + ni + \'" class="check fa fa-check ui-btn ui-shadow ui-corner-all" onClick="checkClicked(\' + ni +\');"></button>\'; var codItem4 = \'<button id="delete_\' + ni + \'" class="delete fa fa-times ui-btn ui-shadow ui-corner-all" onClick="deleteClicked(\' + ni + \');"></button></div></div>\'; $.get( "/objects/", { object:"TodoList", op:"m", m:"new", task:newtask } ); setTimeout(function() { $.get( "/objects/", { object:"TodoList", op:"m", m:"view" } ) }, 100); $(codItem1 + codItem2 + codItem3 + codItem4).appendTo("div.list"); return false; } } function checkClicked(ctask) { if (ctask) { $.get( "/objects/", { object:"TodoList", op:"m",m:"check", task:ctask } ); $("#task_"+ctask).toggleClass("checked"); setTimeout(function() { $.get( "/objects/", { object:"TodoList", op:"m", m:"view" } ) }, 100); return false; } } function deleteClicked(dtask) { if (dtask) { $.get( "/objects/", { object:"TodoList", op:"m", m:"delete", task:dtask } ); $("#taskbox_"+dtask).remove(); setTimeout(function() { $.get( "/objects/", { object:"TodoList", op:"m", m:"view" } ) }, 100); return false; } } '; $this->setProperty('JS', $JS); $view=' // МЕТОД view - подготовка кода для отображения $todo = $this->getProperty("todo"); // установим внутреннюю кодировку символов mb_internal_encoding("UTF-8"); $td = explode("|", $todo); $str_cod = \'<div id="list"> <div class="new"> <input id="newtask" placeholder="New Item" type="text"> <button onClick="btnRunClicked();" class="fa fa-plus"></button> </div> <div class="list">\'; for($i = 1; $i < sizeof($td); $i++) { // выделим и сохраним первый символ $check = mb_substr($td[$i], 0, 1); // обрежем строку, не будем отображать первый символ + или - $task = mb_substr($td[$i], 1); // начинаем формировать код hsl(196,\'.(73-24*(($i-1)%2)).\'%,50%) $str_cod = $str_cod.\' <div class="item" id="taskbox_\'.$i.\'" style ="background: hsl(\'.(190+$i*6).\',73%,50%);"> <span id="task_\'.$i.\'"\'; // если певый символ "+" то значит задание "выполнено" if ($check == "+") { $str_cod = $str_cod.\' class="checked"\'; } $str_cod = $str_cod.\'>\'.$task.\'</span>\'; $str_cod = $str_cod.\' <div class="rightblock"> <button id="check_\'.$i.\'" class="check fa fa-check" onClick="checkClicked(\'.$i.\');"></button> <button id="delete_\'.$i.\'" class="delete fa fa-times" onClick="deleteClicked(\'.$i.\');"></button> </div> </div>\'; } $str_cod = $str_cod.\' </div> </div>\'; // записываем получившийся код $this->setProperty("StreamingCodeScene",$str_cod); $str_cod_css = "<style>".$this->getProperty("menuCSS")."</style>"; $str_cod_js = "<script type=\'text/javascript\'>".$this->getProperty("JS")."</script>"; $str_cod = $str_cod_css.$str_cod_js.$str_cod; $this->setProperty("StreamingCodeMenu",$str_cod); '; addClassMethod('ToDo', 'view', $view); $check=' // МЕТОД check $todo = $this->getProperty("todo"); // установим внутреннюю кодировку символов mb_internal_encoding("UTF-8"); $td = explode("|", $todo); if (isset($params["task"])) { $ct = $params["task"]; for($i = 0; ($i < sizeof($td)); $i++) { // выделим и сохраним первый символ $check = mb_substr($td[$i], 0, 1); // обрежем строку, не будем отображать первый символ + или - $task = mb_substr($td[$i], 1); // если совпадает номер строки if ($i == $ct) { // инвентируем check $check = ($check == "+") ? "-" : "+"; $tcheck = ($check == "+") ? ""выполненно"" : ""не выполнено""; $sayTodo = gg("Sets.sayTodo"); if ($sayTodo) { say ("Todo задача: "".$task."" - отмечена как ".$tcheck,($sayTodo-2)); } } $td[$i] = $check.$task; } $todo = implode("|", $td); $this->setProperty("todo", $todo); } // выполним подготовку для отображения // callMethod("TodoList.view"); '; addClassMethod('ToDo', 'check', $check); $delete = ' // МЕТОД delete $todo = $this->getProperty("todo"); $dt = $params["task"]; // получаем номер строки на удаление $td = explode("|", $todo); // Считываем всё в массив for($i = 0; $i < sizeof($td); $i++) { if($i == $dt) { $sayTodo = gg("Sets.sayTodo"); if ($sayTodo) { say ("Из листа todo удалена задача: "".mb_substr($td[$i], 1).""",($sayTodo-2)); } unset($td[$i]); } } $todo = implode("|", $td); $this->setProperty("todo", $todo); // выполним подготовку для отображения // callMethod("TodoList.view"); '; addClassMethod('ToDo', 'delete', $delete); $new = ' // МЕТОД new if (isset($params["task"])) { $todo = $this->getProperty("todo"); $mytask = "-".$params["task"]; // строка задачи $sayTodo = gg("Sets.sayTodo"); if ($sayTodo) { say ("В лист todo добавлена задача: "".$params["task"].""",($sayTodo-2)); } $todo = $todo."|".$mytask; // добавляем с разделителем $this->setProperty("todo", $todo); } '; addClassMethod('ToDo', 'new', $new); callMethod("TodoList.view");
Методы класса:
Объекты класса:
if ($params['serial']=='' && $params['devname']!='') { $params['serial']=$params['devname']; } $device=SQLSelectOne("SELECT * FROM usbdevices WHERE SERIAL LIKE '".$params['serial']."'"); if (!$device['ID']) { // new device connected //say("Подключено новое устройство",1); $device=array(); $device['SERIAL']=$params['serial']; $device['TITLE']='устройство '.$params['devname']; $device['FIRST_FOUND']=date('Y-m-d H:i:s'); $device['LAST_FOUND']=date('Y-m-d H:i:s'); $device['LOG'].=$device['FIRST_FOUND'].' подключено (впервые)'."\n"; $device['ID']=SQLInsert('usbdevices',$device); } else { // device already in our database //say("Подключено ".$device['TITLE'],1); if ($device['USER_ID']) { $user=SQLSelectOne("SELECT * FROM users WHERE ID='".$device['USER_ID']."'"); if ($user['ID']) { //$user['NAME']; // теперь мы знаем имя пользователя, связанного с этим устройством } } $device['LAST_FOUND']=date('Y-m-d H:i:s'); $device['LOG']=$device['LAST_FOUND'].' подключено'."\n".$device['LOG']; SQLUpdate('usbdevices',$device); if ($device['SCRIPT_ID']!='') { runScript($device['SCRIPT_ID'],$params); } elseif ($device['SCRIPT']!='') { eval($device['SCRIPT']); } }
Объекты класса:
, Россия
© 2024 - Site Built By SergeJey | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving