Пример #1
0
	function NetPlayer_CopyCoverFile ($path) {
      $files = scandir($path);
		foreach ($files as $file) {
		   $extension = pathinfo($file, PATHINFO_EXTENSION);
		   $filename = pathinfo($file, PATHINFO_FILENAME);
		   $cover_jpg = "";
		   $cover_front = "";
		   if (strtolower($extension)=='jpg') {
            $cover_jpg = $path."\\".$file;
		      if (strpos(strtolower($filename),'front')!==false) {
				   $cover_front = $path."\\".$file; }
			}
		}

		$FileOutput = IPS_GetKernelDir()."\\webfront\\user\\NetPlayer\\NetPlayer_Cover.jpg";
		if ($cover_front != "") {
			$FileInput = $cover_front;
		} else if ($cover_jpg != "") {
		   $FileInput = $cover_jpg;
		} else {
		   $FileInput = IPS_GetKernelDir()."\\webfront\\user\\NetPlayer\\NetPlayer_CoverNotFound.jpg";
		}
      IPSLogger_Dbg(__file__, "Copy Cover File '$FileInput' to '$FileOutput'");
		copy ($FileInput, $FileOutput);

	}
Пример #2
0
 public function ApplyChanges()
 {
     parent::ApplyChanges();
     $this->RegisterAction('Volume', 'Lautstärke', $typ = 1, $profil = '');
     $this->RegisterAction('Mute', 'Stumm', $typ = 0, $profil = 'RPC.OnOff');
     $this->RegisterVariableInteger('GroupMember', 'Gruppe', 0);
     if ($this->CheckConfig() === true) {
         $zoneConfig = IPS_GetKernelDir() . '/modules/ips2rpc/sonos_zone.config';
         if (!file_exists($zoneConfig)) {
             $file = $this->API()->BaseUrl(true) . '/status/topology';
             if ($xml = simplexml_load_file($file)) {
                 $out = [];
                 foreach ($xml->ZonePlayers->ZonePlayer as $item) {
                     if ($v = (array) $item->attributes()) {
                         $v = array_shift($v);
                     }
                     $v['name'] = (string) $item;
                     $out[$v['name']] = $v;
                 }
                 file_put_contents($zoneConfig, serialize($out));
             }
         }
         $this->Update();
     }
 }
	function IPSModuleManagerGUI_StoreParameters($module, $data) {
		$fileUsr   = IPS_GetKernelDir().'scripts\\IPSLibrary\\install\\InitializationFiles\\'.$module.'.ini';
		$configUsr = parse_ini_file($fileUsr, true);
		$fileDef   = IPS_GetKernelDir().'scripts\\IPSLibrary\\install\\InitializationFiles\\Default\\'.$module.'.ini';
		$configDef = parse_ini_file($fileDef, true);
		if (!array_key_exists('ID', $configDef)) {
			$configDef['ID'] = '';
		}
		$fileContent = '';
		foreach ($configDef as $section=>$sectionValue) {
			if ($section=='WFC10' or $section=='Mobile') {
				$fileContent .= '['.$section.']'.PHP_EOL;
				foreach ($sectionValue as $property=>$value) {
					if (array_key_exists($property, $configUsr)) {
						$value = $configUsr[$property];
					}
					if (array_key_exists($section.$property, $data)) {
						$value = $data[$section.$property];
						$value = html_entity_decode($value, ENT_COMPAT, 'UTF-8');
					}
					$fileContent .= $property.'="'.$value.'"'.PHP_EOL;
				}
			} else {
				$value = $sectionValue;
				if (array_key_exists($section, $configUsr)) {
					$value = $configUsr[$section];
				}
				$fileContent .= $section.'="'.$value.'"'.PHP_EOL;
			}
		}
		file_put_contents($fileUsr, $fileContent);
	}
Пример #4
0
 public function Update()
 {
     //Anzahl IPS Events ermitteln
     $this->SetValueInteger("IPSEvents", count(IPS_GetEventList()));
     //Anzahl IPS Instanzen ermitteln
     $this->SetValueInteger("IPSInstanzen", count(IPS_GetInstanceList()));
     //Anzahl IPS Kategorien ermitteln
     $this->SetValueInteger("IPSKategorien", count(IPS_GetCategoryList()));
     //Anzahl IPS Links ermitteln
     $this->SetValueInteger("IPSLinks", count(IPS_GetLinkList()));
     //Anzahl IPS Module ermitteln
     $this->SetValueInteger("IPSModule", count(IPS_GetModuleList()));
     //Anzahl IPS Objekte ermitteln
     $this->SetValueInteger("IPSObjekte", count(IPS_GetObjectList()));
     //Anzahl IPS Profile ermitteln
     $this->SetValueInteger("IPSProfile", count(IPS_GetVariableProfileList()));
     //Anzahl IPS Skripte ermitteln
     $this->SetValueInteger("IPSSkripte", count(IPS_GetScriptList()));
     //Anzahl IPS Variablen ermitteln
     $this->SetValueInteger("IPSVariablen", count(IPS_GetVariableList()));
     //Anzahl IPS Variablen ermitteln
     $this->SetValueInteger("IPSMedien", count(IPS_GetMediaList()));
     //Anzahl IPS Librarys ermitteln
     $this->SetValueInteger("IPSLibrarys", count(IPS_GetLibraryList()));
     // Groesse des Script-Verzeichnis
     $this->SetValueFloat("IPSScriptDirSize", $this->GetDirSize(IPS_GetKernelDir() . "scripts"));
     // Groesse des Log-Verzeichnis
     $this->SetValueFloat("IPSLogDirSize", $this->GetDirSize(IPS_GetLogDir()));
     // Groesse des Datenbank-Verzeichnis
     $this->SetValueFloat("IPSDBSize", $this->GetDirSize(IPS_GetKernelDir() . "db"));
     //Letzter IPS-Start
     $this->SetValueInteger("IPSStartTime", IPS_GetUptime());
 }
	function PurgeLogFiles($Directory, $Extension, $ID_OutSwitch, $ID_OutDays) {
	   if (GetValue($ID_OutSwitch)) {
			IPSLogger_Dbg(c_LogId, 'Purging *.'.$Extension.' LogFiles in Directory '.$Directory);
			$Days = GetValue($ID_OutDays);
			$ReferenceDate=Date('Ymd', strtotime("-".$Days." days"));
		   if ($Directory == "") {
				$Directory = IPS_GetKernelDir().'logs\\';
		   }

			if (($handle=opendir($Directory))===false) {
			   IPSLogger_Err(c_LogId, 'Error Opening Directory '.$Directory);
				Exit;
			}

			while (($File = readdir($handle))!==false) {
		      $FileDate      = substr($File, strlen('IPSLogger_'), 8);
		      $FileExtension = substr($File, strlen('IPSLogger_')+8+1, 3);
		      if ($Extension==$FileExtension) {
					IPSLogger_Trc(c_LogId, 'Found File: '.$File.', FileDate='.$FileDate.', RefDate='.$ReferenceDate);
					if ($FileDate < $ReferenceDate) {
						IPSLogger_Inf(c_LogId, 'Delete LogFile: '.$Directory.$File);
					   unlink($Directory.$File);
					}
				}
			}
			closedir($handle);
		}
	}
Пример #6
0
 public function Update()
 {
     //Anzahl IPS Events ermitteln
     $this->SetValueInteger("IPSEvents", count(IPS_GetEventList()));
     //Anzahl IPS Instanzen ermitteln
     $this->SetValueInteger("IPSInstanzen", count(IPS_GetInstanceList()));
     //Anzahl IPS Kategorien ermitteln
     $this->SetValueInteger("IPSKategorien", count(IPS_GetCategoryList()));
     //Anzahl IPS Links ermitteln
     $this->SetValueInteger("IPSLinks", count(IPS_GetLinkList()));
     //Anzahl IPS Module ermitteln
     $this->SetValueInteger("IPSModule", count(IPS_GetModuleList()));
     //Anzahl IPS Objekte ermitteln
     $this->SetValueInteger("IPSObjekte", count(IPS_GetObjectList()));
     //Anzahl IPS Profile ermitteln
     $this->SetValueInteger("IPSProfile", count(IPS_GetVariableProfileList()));
     //Anzahl IPS Skripte ermitteln
     $this->SetValueInteger("IPSSkripte", count(IPS_GetScriptList()));
     //Anzahl IPS Variablen ermitteln
     $this->SetValueInteger("IPSVariablen", count(IPS_GetVariableList()));
     //Anzahl IPS Variablen ermitteln
     $this->SetValueInteger("IPSMedien", count(IPS_GetMediaList()));
     //Anzahl IPS Librarys ermitteln
     $this->SetValueInteger("IPSLibrarys", count(IPS_GetLibraryList()));
     // Groesse des Script-Verzeichnis
     $this->SetValueInteger("IPSScriptDirSize", $this->GetDirSize(IPS_GetKernelDir() . "scripts"));
     // Groesse des Log-Verzeichnis
     $this->SetValueInteger("IPSLogDirSize", $this->GetDirSize(IPS_GetLogDir()));
     // Groesse des Datenbank-Verzeichnis
     $this->SetValueInteger("IPSDBSize", $this->GetDirSize(IPS_GetKernelDir() . "db"));
     //Letzter IPS-Start
     $this->SetValueInteger("IPSStartTime", IPS_GetKernelStartTime());
     //Subscription Ablaufdatum
     $Benutzername = $this->ReadPropertyString("IPSForumBenutzer");
     $Passwort = $this->ReadPropertyString("IPSForumPasswort");
     if (strlen($Benutzername) > 0 and strlen($Passwort) > 0) {
         $page = $this->vBulletinLoginIPS($Benutzername, $Passwort);
         preg_match('|Subskription bis:.(.*)\\W|', $page, $SubscriptionMatch);
         if ($SubscriptionMatch) {
             $SubscriptionAblaufdatumX = $SubscriptionMatch[1];
             $SubscriptionAblaufdatum = trim(strip_tags($SubscriptionAblaufdatumX));
             $SubscriptionAblaufdatum = date_create_from_format('d.m.y', $SubscriptionAblaufdatum);
             $SubscriptionAblaufdatumUnix = strtotime($SubscriptionAblaufdatum->format('d.m.Y'));
             $this->SetValueInteger("SubscriptionAblaufVAR", $SubscriptionAblaufdatumUnix);
         }
         preg_match('|Version:.(.*).#(.*)|', $page, $VersionMatch);
         if ($VersionMatch) {
             $VersionMatchV = $VersionMatch[1];
             $VersionMatchB = $VersionMatch[2];
             $VersionMatchV = trim(strip_tags($VersionMatchV));
             $VersionMatchB = trim(strip_tags($VersionMatchB));
             $VersionALL = $VersionMatchV . " #" . $VersionMatchB;
             $this->SetValueString("IPSVersion", $VersionALL);
             $this->SetValueFloat("IPSVersionMain", (double) $VersionMatchV);
             $this->SetValueInteger("IPSVersionBuild", (int) $VersionMatchB);
         }
     }
 }
		/**
		 * @public
		 *
		 * Initialisierung des IPSComponentPlayer_Sonos Players
		 *
		 * @param string $address IP Addresse des Sonos Players 
		 */
		public function __construct( $address ) {
			if (file_exists(IPS_GetKernelDir().'scripts\\PHPSonos.inc.php')) {
			   include_once IPS_GetKernelDir().'scripts\\PHPSonos.inc.php';
			} else {
				IPSUtils_Include ('PHPSonos.class.php', 'IPSLibrary::app::hardware::Sonos');
			}
		   $this->address = $address;
		   $this->sonos   = new PHPSonos($address);
		}
Пример #8
0
 /**
  * This function will be available automatically after the module is imported with the module control.
  * Using the custom prefix this function will be callable from PHP and JSON-RPC through:
  *
  * UWZ_RequestInfo($id);
  *
  */
 public function RequestInfo()
 {
     $imagePath = IPS_GetKernelDir() . $this->imagePath;
     $area = $this->ReadPropertyString("area");
     $homeX = $this->ReadPropertyInteger("homeX");
     $homeY = $this->ReadPropertyInteger("homeY");
     $homeRadius = $this->ReadPropertyInteger("homeRadius");
     //Calculate time
     $minute = floor(date("i") / 15) * 15;
     $dateline = mktime(date("H"), $minute, 0, date("m"), date("d"), date("y"));
     //Download picture
     $opts = array('http' => array('method' => "GET", 'max_redirects' => 1));
     $context = stream_context_create($opts);
     $remoteImage = "http://www.wetteronline.de/daten/radar/{$area}/" . gmdate("Y", $dateline) . "/" . gmdate("m", $dateline) . "/" . gmdate("d", $dateline) . "/" . gmdate("Hi", $dateline) . ".gif";
     $data = @file_get_contents($remoteImage, false, $context);
     if ($data === false) {
         //No new picture. Download old one.
         $dateline -= 15 * 60;
         $remoteImage = "http://www.wetteronline.de/daten/radar/{$area}/" . gmdate("Y", $dateline) . "/" . gmdate("m", $dateline) . "/" . gmdate("d", $dateline) . "/" . gmdate("Hi", $dateline) . ".gif";
         $data = @file_get_contents($remoteImage, false, $context);
         if ($data === false) {
             return;
         }
     }
     if (strpos($http_response_header[0], "200") === false) {
         return;
     }
     file_put_contents($imagePath, $data);
     //Radarbild auswerten
     $im = ImageCreateFromGIF($imagePath);
     //Stärken
     $regen[6] = imagecolorresolve($im, 250, 2, 250);
     $regen[5] = imagecolorresolve($im, 156, 50, 156);
     $regen[4] = imagecolorresolve($im, 28, 126, 220);
     $regen[3] = imagecolorresolve($im, 44, 170, 252);
     $regen[2] = imagecolorresolve($im, 84, 210, 252);
     $regen[1] = imagecolorresolve($im, 172, 254, 252);
     //Pixel durchgehen
     $regenmenge = 0;
     for ($x = $homeX - $homeRadius; $x <= $homeX + $homeRadius; $x++) {
         for ($y = $homeY - $homeRadius; $y <= $homeY + $homeRadius; $y++) {
             $found = array_search(imagecolorat($im, $x, $y), $regen);
             if (!($found === FALSE)) {
                 $regenmenge += $found;
             }
         }
     }
     // Bereich zeichnen
     $schwarz = ImageColorAllocate($im, 0, 0, 0);
     $rot = ImageColorAllocate($im, 255, 0, 0);
     imagerectangle($im, $homeX - $homeRadius, $homeY - $homeRadius, $homeX + $homeRadius, $homeY + $homeRadius, $rot);
     imagesetpixel($im, $homeX, $homeY, $rot);
     imagegif($im, $localImage);
     imagedestroy($im);
     SetValue($this->GetIDForIdent("RainValue"), $regenmenge);
 }
Пример #9
0
	/**
	 * Function zum Include ander Scripte
	 *
	 * Usage:
	 * <pre>IPSUtils_Include('IPSLogger.inc.php', 'IPSLibrary::app::core::IPSLogger');</pre>
	 *
 	 * @param string $file File das inkludiert werden soll
	 * @param string $namespace namespace des Files, dass inkludiert werden soll (gibt den relativen Pfad vom IPS scripts Verzeichnis an)
	 */
	function IPSUtils_Include($file, $namespace="") {
	   if ($namespace=="") {
	      include_once $file;
	   } else {
	      $file = IPS_GetKernelDir().'\\scripts\\'.str_replace('::','\\',$namespace).'\\'.$file;

	      if (!file_exists($file)) {
				throw new Exception('script '.$file.' could NOT be found!', E_USER_ERROR);
	      }
	      include_once $file;
	   }
	}
	function Unregister_PhpErrorHandler($moduleManager) {
		$file = IPS_GetKernelDir().'scripts\\__autoload.php';

		if (!file_exists($file)) {
			return;
		}
		$FileContent = file_get_contents($file);
		$includeCommand = 'IPSUtils_Include("IPSLogger_PhpErrorHandler.inc.php", "IPSLibrary::app::core::IPSLogger");';
		$FileContent = str_replace($includeCommand, '', $FileContent);
		$moduleManager->LogHandler()->Log('Unregister Php ErrorHandler of IPSLogger in File __autoload.php');
		file_put_contents($file, $FileContent);
	}
		/**
		 * @public
		 *
		 * Initialisierung des IPSFileVersionHandler
		 *
		 * @param string $moduleName Name des Modules
		 */
		public function __construct($moduleName) {
			if ($moduleName=="") {
				die("ModuleName must have a Value!");
			}
			parent::__construct($moduleName);
			$this->fileNameInstalledModules      = IPS_GetKernelDir().'scripts\\'.$this::FILE_INSTALLED_MODULES;
			$this->fileNameAvailableModules      = IPS_GetKernelDir().'scripts\\'.$this::FILE_AVAILABLE_MODULES;
			$this->fileNameKnownModules          = IPS_GetKernelDir().'scripts\\'.$this::FILE_KNOWN_MODULES;
			$this->fileNameKnownRepositories     = IPS_GetKernelDir().'scripts\\'.$this::FILE_KNOWN_REPOSITORIES;
			$this->fileNameKnownUserRepositories = IPS_GetKernelDir().'scripts\\'.$this::FILE_KNOWN_USERREPOSITORIES;
			$this->fileNameRepositoryVersions    = IPS_GetKernelDir().'scripts\\'.$this::FILE_REPOSITORY_VERSIONS;
			$this->fileNameChangeList            = IPS_GetKernelDir().'scripts\\'.$this::FILE_CHANGELIST;
			$this->fileNameRequiredModules       = IPS_GetKernelDir().'scripts\\'.$this::FILE_REQUIRED_MODULES;
			$this->fileNameDownloadList          = IPS_GetKernelDir().'scripts\\'.$this::FILE_DOWNLOADLIST_PATH.$moduleName.$this::FILE_DOWNLOADLIST_SUFFIX;

			$this->ReloadVersionData();
		}
	function Register_IPSUtils() {
		$file = IPS_GetKernelDir().'scripts\\__autoload.php';

		if (!file_exists($file)) {
			echo 'Create File __autoload.php';
			file_put_contents($file, '<?'.PHP_EOL.PHP_EOL.'?>');
		}

		$FileContent = file_get_contents($file);
		$pos = strpos($FileContent, 'IPSUtils.inc.php');

		if ($pos === false) {
			echo 'Register IPSUtils.inc.php in File __autoload.php';
			$includeCommand = '    include_once IPS_GetKernelDir()."\scripts\IPSLibrary\app\core\IPSUtils\IPSUtils.inc.php";';
			$FileContent = str_replace('?>', $includeCommand.PHP_EOL.'?>', $FileContent);
			file_put_contents($file, $FileContent);
		}
	}
Пример #13
0
 public function ApplyChanges()
 {
     // Diese Zeile nicht löschen
     parent::ApplyChanges();
     //Variablenprofil anlegen
     if (!IPS_VariableProfileExists("Megabyte")) {
         IPS_CreateVariableProfile("Megabyte", 2);
         IPS_SetVariableProfileValues("Megabyte", 0, 0, 2);
         IPS_SetVariableProfileText("Megabyte", "", " MB");
     }
     if ($this->ReadPropertyString("IPS_Pfad") != "" and $this->ReadPropertyString("Netzwerkkarte") != "") {
         //Variablen erstellen
         $this->RegisterVariableFloat("CPU_idle", "CPU-Auslastung", "Humidity.F", 1);
         $this->RegisterVariableFloat("CPU_volts", "CPU-Spannung", "Volt", 2);
         $this->RegisterVariableFloat("CPU_temp", "CPU-Temperatur", "Temperature", 3);
         $this->RegisterVariableFloat("HDD_total", "Gesamt Speicherplatz", "Megabyte", 4);
         $this->RegisterVariableFloat("HDD_used", "Belegter Speicherplatz", "Megabyte", 5);
         $this->RegisterVariableFloat("HDD_percent", "HDD-Belegung", "Humidity.F", 6);
         $this->RegisterVariableFloat("HDD_symcon", "IPS-Speicherbelegung", "Megabyte", 7);
         $this->RegisterVariableFloat("RAM_total", "Gesamt RAM", "Megabyte", 8);
         $this->RegisterVariableFloat("RAM_used", "Benutzer RAM", "Megabyte", 9);
         $this->RegisterVariableFloat("RAM_percent", "RAM-Auslastung", "Humidity.F", 10);
         $this->RegisterVariableString("System_Info", "System Informationen", "HTMLBox", 11);
         //Timer zeit setzen
         $this->SetTimerInterval("Update", $this->ReadPropertyInteger("UpdateInterval") * 1000);
     } else {
         //Instanz ist inaktiv
         $this->SetStatus(104);
     }
     //Variablen Logging Aktivieren / Deaktivieren
     $archiveHandlerID = IPS_GetInstanceListByModuleID('{43192F0B-135B-4CE7-A0A7-1475603F3060}')[0];
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_idle"), $this->ReadPropertyBoolean("logCPU_idle"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_volts"), $this->ReadPropertyBoolean("logCPU_volts"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("CPU_temp"), $this->ReadPropertyBoolean("logCPU_temp"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_total"), $this->ReadPropertyBoolean("logHDD_total"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_used"), $this->ReadPropertyBoolean("logHDD_used"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_percent"), $this->ReadPropertyBoolean("logHDD_percent"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("HDD_symcon"), $this->ReadPropertyBoolean("logHDD_symcon"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_total"), $this->ReadPropertyBoolean("logRAM_total"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_used"), $this->ReadPropertyBoolean("logRAM_used"));
     AC_SetLoggingStatus($archiveHandlerID, $this->GetIDForIdent("RAM_percent"), $this->ReadPropertyBoolean("logRAM_percent"));
     IPS_ApplyChanges($archiveHandlerID);
     copy(IPS_GetKernelDir() . "modules/IPS_PI_Monitor/PI_Monitor/Raspi-PGB001.png", IPS_GetKernelDir() . "webfront/user/Raspi-PGB001.png");
 }
Пример #14
0
		/**
		 * @public
		 *
		 * Protokollierung von Error Messages
		 *
		 * @param string $msg Error Message
		 */
		public function Error($msg) {
			$debugTrace = debug_backtrace();
			$stackTxt   = '';
			foreach ($debugTrace as $idx=>$stack) {
				if (array_key_exists('line', $stack) and array_key_exists('function', $stack) and array_key_exists('file', $stack)) {
					$file     = str_replace('scripts\\', '', str_replace(IPS_GetKernelDir(), '', $stack['file']));
					$function = $stack['function'];
					$line     = str_pad($stack['line'],3,' ', STR_PAD_LEFT);
					$stackTxt  .= PHP_EOL."  $line in $file (call $function)";
				} elseif (array_key_exists('function', $stack)) {
					$stackTxt  .= PHP_EOL.'      in '.$stack['function'];
				} else {
					$stackTxt  .= PHP_EOL.'      Unknown Stack ...';
				}
			}
			$this->WritePHPConsole($msg.$stackTxt);
			$this->WriteIPSConsole($msg.$stackTxt);
			$this->WriteFile($msg.$stackTxt);
		}
	$categoryId_Data     = $moduleManager->GetModuleCategoryID('data');
	$categoryId_App      = $moduleManager->GetModuleCategoryID('app');
	$categoryId_DataGraphics  = CreateCategory('Graphics', $categoryId_Data, 10);
	$categoryId_DataValues    = CreateCategory('Values',   $categoryId_Data, 20);

	// Scripts
	$scriptId_Refresh  = IPS_GetScriptIDByName('IPSTwilight',  $categoryId_App);
	$timerId_Refresh   = CreateTimer_OnceADay ('Refresh', $scriptId_Refresh, 0, 15) ;

	// Graphics
	$YearMediaId          = CreateMedia ('IPSTwilight_Year',          $categoryId_DataGraphics, IPS_GetKernelDir().'media\\IPSTwilight_Year.gif',          false,1,'Sun');
	$YearLimitedMediaId   = CreateMedia ('IPSTwilight_YearLimited',   $categoryId_DataGraphics, IPS_GetKernelDir().'media\\IPSTwilight_YearLimited.gif',   false,1,'Sun');
	$YearUnlimitedMediaId = CreateMedia ('IPSTwilight_YearUnlimited', $categoryId_DataGraphics, IPS_GetKernelDir().'media\\IPSTwilight_YearUnlimited.gif', false,1,'Sun');
	$DayMediaId           = CreateMedia ('IPSTwilight_Day',           $categoryId_DataGraphics, IPS_GetKernelDir().'media\\IPSTwilight_Day.gif',           false,1,'Sun');
	$DayLimitedMediaId    = CreateMedia ('IPSTwilight_DayLimited',    $categoryId_DataGraphics, IPS_GetKernelDir().'media\\IPSTwilight_DayLimited.gif',    false,1,'Sun');
	$DayUnlimitedMediaId  = CreateMedia ('IPSTwilight_DayUnlimited',  $categoryId_DataGraphics, IPS_GetKernelDir().'media\\IPSTwilight_DayUnlimited.gif',  false,1,'Sun');

	//Data
	$DisplaySwitchId   = CreateVariable('Display' ,     0 /*Boolean*/, $categoryId_DataValues, 10, '~Switch',$scriptId_Refresh, false,   'Information');

	$SunriseBeg        = CreateVariable("SunriseBegin",           3 /*String*/,  $categoryId_DataValues,  110, '~String', $scriptId_Refresh, '');
	$SunriseEnd        = CreateVariable("SunriseEnd",             3 /*String*/,  $categoryId_DataValues,  120, '~String', $scriptId_Refresh, '');
	$SunriseBegLim     = CreateVariable("SunriseBeginLimited",    3 /*String*/,  $categoryId_DataValues,  130, '~String', $scriptId_Refresh, '');
	$SunriseEndLim     = CreateVariable("SunriseEndLimited",      3 /*String*/,  $categoryId_DataValues,  140, '~String', $scriptId_Refresh, '');
	$SunriseDisplay    = CreateVariable("SunriseDisplay",         3 /*String*/,  $categoryId_DataValues,  150, '~String', null,              '00:00 - 00:00');
	$SunriseLimits     = CreateVariable("SunriseLimits",          3 /*String*/,  $categoryId_DataValues,  160, '~String', $scriptId_Refresh, '05:30-07:30/18:30-20:30');

	$CivilBeg          = CreateVariable("CivilBegin",             3 /*String*/,  $categoryId_DataValues,  210, '~String', $scriptId_Refresh, '');
	$CivilEnd          = CreateVariable("CivilEnd",               3 /*String*/,  $categoryId_DataValues,  220, '~String', $scriptId_Refresh, '');
	$CivilBegLim       = CreateVariable("CivilBeginLimited",      3 /*String*/,  $categoryId_DataValues,  230, '~String', $scriptId_Refresh, '');
	$CivilEndLim       = CreateVariable("CivilEndLimited",        3 /*String*/,  $categoryId_DataValues,  240, '~String', $scriptId_Refresh, '');
	function Register_PhpErrorHandler($moduleManager) {
		$file = IPS_GetKernelDir().'scripts\\__autoload.php';

		if (!file_exists($file)) {
			throw new Exception($file.' could NOT be found!', E_USER_ERROR);
		}
		$FileContent = file_get_contents($file);

		$pos = strpos($FileContent, 'IPSLogger_PhpErrorHandler.inc.php');

		if ($pos === false) {
			$includeCommand = '    IPSUtils_Include("IPSLogger_PhpErrorHandler.inc.php", "IPSLibrary::app::core::IPSLogger");';
			$FileContent = str_replace('?>', $includeCommand.PHP_EOL.'?>', $FileContent);
			$moduleManager->LogHandler()->Log('Register Php ErrorHandler of IPSLogger in File __autoload.php');
			file_put_contents($file, $FileContent);
		}
	}
Пример #17
0
		/**
		 * @private
		 *
		 * Speichert die aktuelle Event Konfiguration
		 *
		 * @param string[] $configuration Konfigurations Array
		 */
		private static function StoreEventConfiguration($configuration) {

			// Build Configuration String
			$configString = '$eventConfiguration = array(';
			foreach ($configuration as $variableId=>$params) {
				$configString .= PHP_EOL.chr(9).chr(9).chr(9).$variableId.' => array(';
				for ($i=0; $i<count($params); $i=$i+3) {
					if ($i>0) $configString .= PHP_EOL.chr(9).chr(9).chr(9).'               ';
					$configString .= "'".$params[$i]."','".$params[$i+1]."','".$params[$i+2]."',";
				}
				$configString .= '),';
			}
			$configString .= PHP_EOL.chr(9).chr(9).chr(9).');'.PHP_EOL.PHP_EOL.chr(9).chr(9);

			// Write to File
			$fileNameFull = IPS_GetKernelDir().'scripts\\IPSLibrary\\config\\core\\IPSMessageHandler\\IPSMessageHandler_Configuration.inc.php';
			if (!file_exists($fileNameFull)) {
				throw new IPSMessageHandlerException($fileNameFull.' could NOT be found!', E_USER_ERROR);
			}
			$fileContent = file_get_contents($fileNameFull, true);
			$pos1 = strpos($fileContent, '$eventConfiguration = array(');
			$pos2 = strpos($fileContent, 'return $eventConfiguration;');

			if ($pos1 === false or $pos2 === false) {
				throw new IPSMessageHandlerException('EventConfiguration could NOT be found !!!', E_USER_ERROR);
			}
			$fileContentNew = substr($fileContent, 0, $pos1).$configString.substr($fileContent, $pos2);
			file_put_contents($fileNameFull, $fileContentNew);
			self::Set_EventConfigurationAuto($configuration);
		}
Пример #18
0
	function GenerateTwilightGraphic($fileName, $useLimited=false, $dayDivisor = 4.4, $dayWidth = 1.8) {
		$dayHeight    = 1440/$dayDivisor;     //24h*60Min=1440Min, 1440/4=360
		$marginLeft   = 20;
		$marginTop    = 5;
		$marginBottom = 30;
		$marginRight  = 5;
		$imageWidth   = (365+30)*$dayWidth+$marginLeft+$marginRight; // 365days, 2*365=730
		$imageHeight  = $dayHeight + $marginBottom + $marginTop;

		$image  = imagecreate($imageWidth,$imageHeight);

		$white         = imagecolorallocate($image,255,255,255);
		$textColor     = imagecolorallocate($image,250,250,250);
		$transparent   = imagecolortransparent($image,$white);
		$black         = imagecolorallocate($image,0,0,0);
		$red           = imagecolorallocate($image,255,0,0);
		$green         = imagecolorallocate($image,0,255,0);
		$blue          = imagecolorallocate($image,0,0,255);
		$grey_back     = imagecolorallocate($image, 100, 100, 100);
		$grey_line     = imagecolorallocate($image, 120, 120, 120);
		$grey_sunrise1 = imagecolorallocate($image, 200, 200, 200);
		$grey_sunrise2 = imagecolorallocate($image, 170, 170, 170);
		$grey_sunrise3 = imagecolorallocate($image, 140, 140, 140);
		$grey          = imagecolorallocate($image, 100, 100, 100);
		$yellow        = imagecolorallocate($image, 255, 255, 0);

		imagefilledrectangle($image,1,1,$imageWidth,$imageHeight,$transparent);
		imagefilledrectangle($image,$marginLeft-2,$marginTop-2,$marginLeft+(365+30)*$dayWidth+1,$marginTop+$dayHeight+2,$black);

		$timestamp  = mktime(12, 0, 0, 1, 1, date("Y"))-15*3600*24;
		for ($day=0; $day<365+30; $day++) {
			$sunrise     = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 90+50/60, date("O")/100);
			$sunset      = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 90+50/60, date("O")/100);
			$sunrise1    = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 96, date("O")/100);
			$sunset1     = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 96, date("O")/100);
			$sunrise2    = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 102, date("O")/100);
			$sunset2     = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 102, date("O")/100);
			$sunrise3    = date_sunrise($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 108, date("O")/100);
			$sunset3     = date_sunset ($timestamp, SUNFUNCS_RET_TIMESTAMP, IPSTWILIGHT_LATITUDE, IPSTWILIGHT_LONGITUDE, 108, date("O")/100);

			if ($useLimited ) {
				LimitValues('SunriseLimits', $sunrise, $sunset);
				LimitValues('CivilLimits', $sunrise1, $sunset1);
				LimitValues('NauticLimits', $sunrise2, $sunset2);
				LimitValues('AstronomicLimits', $sunrise3, $sunset3);
			}

			$sunriseMins = (date("H",$sunrise)*60 + date("i",$sunrise)) / $dayDivisor;
			$sunsetMins  = (date("H",$sunset)*60 +  date("i",$sunset))  / $dayDivisor;
			$sunrise1Mins = (date("H",$sunrise1)*60 + date("i",$sunrise1)) / $dayDivisor;
			$sunset1Mins  = (date("H",$sunset1)*60 +  date("i",$sunset1))  / $dayDivisor;
			$sunrise2Mins = (date("H",$sunrise2)*60 + date("i",$sunrise2)) / $dayDivisor;
			$sunset2Mins  = (date("H",$sunset2)*60 +  date("i",$sunset2))  / $dayDivisor;
			$sunrise3Mins = (date("H",$sunrise3)*60 + date("i",$sunrise3)) / $dayDivisor;
			$sunset3Mins  = (date("H",$sunset3)*60 +  date("i",$sunset3))  / $dayDivisor;
			$middayMins  = (12*60) / $dayDivisor;

			$dayBeg = $marginLeft+$day*$dayWidth-$dayWidth+1;
			$dayEnd = $marginLeft+$day*$dayWidth;


			imagefilledrectangle($image, $dayBeg, $marginTop, $marginLeft+$day*$dayWidth, $marginTop+$dayHeight, $grey );
			if ($sunset3Mins<$sunrise3Mins or $sunset3Mins<$middayMins) {
				imagefilledrectangle($image, $dayBeg, $marginTop,                         $dayEnd, $marginTop+$dayHeight-$sunrise3Mins,  $grey_sunrise3);
				imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunset3Mins, $dayEnd, $marginTop+$dayHeight,                $grey_sunrise3);
			} else {
				imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunrise3Mins, $dayEnd, $marginTop+$dayHeight-$sunset3Mins,  $grey_sunrise3);
			}
			if ($sunset2Mins<$sunrise2Mins or $sunset2Mins<$middayMins) {
				imagefilledrectangle($image, $dayBeg, $marginTop,                         $dayEnd, $marginTop+$dayHeight-$sunrise2Mins,  $grey_sunrise2);
				imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunset2Mins, $dayEnd, $marginTop+$dayHeight,                $grey_sunrise2);
			} else {
				imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunrise2Mins, $dayEnd, $marginTop+$dayHeight-$sunset2Mins,  $grey_sunrise2);
			}
			if ($sunset1Mins<$sunrise1Mins or $sunset1Mins<$middayMins) {
				imagefilledrectangle($image, $dayBeg, $marginTop,                         $dayEnd, $marginTop+$dayHeight-$sunrise1Mins,  $grey_sunrise1);
				imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunset1Mins, $dayEnd, $marginTop+$dayHeight,                $grey_sunrise1);
			} else {
				imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunrise1Mins, $dayEnd, $marginTop+$dayHeight-$sunset1Mins,  $grey_sunrise1);
			}
			imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunriseMins,  $dayEnd, $marginTop+$dayHeight-$sunsetMins,  $yellow );
			imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunriseMins,  $dayEnd, $marginTop+$dayHeight-$sunriseMins, $red );
			imagefilledrectangle($image, $dayBeg, $marginTop+$dayHeight-$sunsetMins,   $dayEnd, $marginTop+$dayHeight-$sunsetMins,  $red );

			// Line for new Month
			if (date("d",$timestamp)==1) {
				imagefilledrectangle($image, $dayEnd, $marginTop, $dayEnd, $marginTop+$dayHeight, $grey_line );
				if ($day<365) {
					imagestring($image,2,$dayBeg+30*$dayWidth/2-8,$marginTop+$dayHeight+5,date('M',$timestamp),$textColor);
				}
			}
			// Line for current Day
			if (date("d",$timestamp)==date("d",time()) and date("m",$timestamp)==date("m",time())) {
				imagefilledrectangle($image, $dayBeg,   $marginTop, $dayEnd,   $marginTop+$dayHeight, $blue );
				imagefilledrectangle($image, $dayBeg-1, $marginTop, $dayEnd-1, $marginTop+$dayHeight, $blue );
			}
			$timestamp = $timestamp+60*60*24;
		}

		// Hour Lines/Text
		for ($hour=0; $hour<=24; $hour=$hour+2) {
			imageline($image, $marginLeft, $marginTop+$dayHeight/24*$hour, $marginLeft+(365+30)*$dayWidth-2, $marginTop+$dayHeight/24*$hour, $grey_line );
			imagestring($image,2,2,$marginTop+$dayHeight-8-($dayHeight/24*$hour),str_pad($hour,2,'0', STR_PAD_LEFT),$textColor);
		}

		//imagestring($image,3,$imageWidth/2-100,15,"Tag- und Nachtstunden in Korneuburg",$textColor);
		imagestring($image,1,10,$marginTop+$dayHeight+$marginBottom-7,"Generated at ".date('d-M-Y H:i:s')." by Brownson",$textColor);
		imagegif ($image, IPS_GetKernelDir().'media\\'.$fileName.'.gif', 90);
		imagedestroy($image);
	}
Пример #19
0
 protected function NEOJSONImport($devicetype, $directory, $CategoryID, $subtype)
 {
     //echo "NEOJSONImport";
     // get file
     $file = IPS_GetKernelDir() . $directory . 'device_db';
     // convert the string to a json object
     $json = json_decode(file_get_contents($file));
     // copy the devices array to a php var
     $devices = $json->devices;
     // listing devices
     foreach ($devices as $device) {
         $name = $device->name;
         //Device name
         $sys = $device->info->sys;
         //System
         //sys ist aio beim AIO Gateway und type IT (Intertechno), FS20, CODE (IR)oder (RF:01) , Lightmanager LEDS, L2, RT (Somfy),
         if ($sys == "aio" && isset($device->info->type)) {
             $type = $device->info->type;
             //Type
             if ($type == $devicetype) {
                 if (isset($device->info->address)) {
                     $address = $device->info->address;
                     //Adresse
                 }
                 if (isset($device->info->data)) {
                     $data = $device->info->data;
                     //Switch / Dimmer / shutter
                 }
                 if (isset($device->info->address) && isset($device->info->data)) {
                     //passende Instanz anlegen
                     switch ($type) {
                         case "FS20":
                             //FS20
                             // Anpassen der Daten
                             $FS20Type = ucfirst($data);
                             //erster Buchstabe groß
                             $AIOFS20Adresse = str_replace(".", "", $address);
                             $this->FS20CreateInstance($name, $AIOFS20Adresse, $FS20Type, $CategoryID);
                             break;
                         case "RT":
                             //Somfy
                             // Anpassen der Daten
                             $SomfyType = $data;
                             $SomfyAdresse = $address;
                             $this->SomfyCreateInstance($name, $address, $data, $CategoryID);
                             break;
                         case "IT":
                             //Intertechno
                             // Anpassen der Daten
                             $adress = str_split($address);
                             $ITType = ucfirst($data);
                             //erster Buchstabe groß
                             $ITDeviceCode = $adress[2] + 1;
                             //Devicecode auf Original umrechen +1
                             $ITFamilyCode = $adress[0];
                             // Zahlencode in Buchstaben Familencode umwandeln
                             $hexsend = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
                             $itfc = array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J");
                             $ITFamilyCode = str_replace($hexsend, $itfc, $ITFamilyCode);
                             $this->ITCreateInstance($name, $ITFamilyCode, $ITDeviceCode, $ITType, $CategoryID);
                             break;
                     }
                 }
                 if (isset($device->info->address) && !isset($device->info->data)) {
                     //passende Instanz anlegen
                     switch ($type) {
                         case "LEDS":
                             //Light Manager 1
                             $this->Light1CreateInstance($name, $address, $CategoryID);
                             break;
                         case "L2":
                             //Light Manager 2
                             $this->Light2CreateInstance($name, $address, $CategoryID);
                             break;
                     }
                 }
                 //IR oder RF Codes adress (IR:01) Sendediode oder RF:01
                 if (isset($device->info->ircodes) && $subtype == "RF" && $address == "RF:01") {
                     $codes = $device->info->ircodes->codes;
                     $InsID = $this->RFCreateInstance($name, $CategoryID);
                     $key = $device->info->ircodes->codes;
                     $count = count($key);
                     $rfcodes = array();
                     for ($i = 0; $i <= $count - 1; $i++) {
                         $rfcodes[$i][0] = $key[$i]->key;
                         $rfcodes[$i][1] = $key[$i]->code;
                         $code = $rfcodes[$i][1];
                         $valcode = substr($code, 0, 1);
                         //del instanz
                         if ($valcode == "{") {
                             $this->DeleteInstance($InsID);
                             break;
                         }
                     }
                     $this->RFAddCode($InsID, $rfcodes, $count);
                 } elseif (isset($device->info->ircodes) && $subtype == "IR" && $address == "IR:01") {
                     $InsID = $this->IRCreateInstance($name, $CategoryID);
                     $key = $device->info->ircodes->codes;
                     $count = count($key);
                     $ircodes = array();
                     for ($i = 0; $i <= $count - 1; $i++) {
                         $ircodes[$i][0] = $key[$i]->key;
                         $ircodes[$i][1] = $key[$i]->code;
                         $code = $ircodes[$i][1];
                         $valcode = substr($code, 0, 1);
                         //del instanz
                         if ($valcode == "{") {
                             $this->DeleteInstance($InsID);
                             break;
                         }
                     }
                     $this->IRAddCode($InsID, $ircodes, $count);
                 }
             }
         }
     }
 }
Пример #20
0
		/**
		 * @public
		 *
		 * Die Funktion kopiert ein Example File auf ein Konfigurationsfile
		 *
		 * @param string $exampleFile Name der Beispiel Datei
		 * @param string $configFile Name der Ziel Datei (Konfigurations File Name)
		 * @param string $namespace Namespace wo das ExampleFile zu finden ist (ohne Angabe des "Example" Verzeichnisses)
		 * @throws IPSFileHandlerException wenn Fehler beim erzeugen der Zieldatei auftritt
		 */
		public function CreateFileFromExample($exampleFile, $configFile, $namespace='') {
		   if ($namespace <> '') {
		      $exampleFile = IPS_GetKernelDir().'\\scripts\\'.str_replace('::','\\',$namespace).'\\examples\\'.$exampleFile;
		      $configFile  = IPS_GetKernelDir().'\\scripts\\'.str_replace('::','\\',$namespace).'\\'.$configFile;
			}

			$this->CopyFile($exampleFile, $configFile);
		}
	function RemoveBlanksBeforePHPTags ($file, $namespace) {
		$moduleManager = $_IPS['MODULEMANAGER'];

		if ($namespace<>'') {
			$namespace = str_replace('::','\\',$namespace).'\\';
		}
		$fileNameFull = IPS_GetKernelDir().'scripts\\'.$namespace.$file;
		if (!file_exists($fileNameFull)) {
			echo 'File '.$file.' not exists (Namespace='.$namespace.')'.PHP_EOL;
			return;
		}
		
		$fileContent = file_get_contents($fileNameFull, true);

		$pos = strpos($fileContent, ' ');
		if ($pos === false or $pos > 0) {
			return;
		}
		$fileContentNew = substr($fileContent, 1);
		$moduleManager->LogHandler()->Debug('Remove Blanks before PHP Tag from File '.$file.'(Namespace='.$namespace.')');
		file_put_contents($fileNameFull, $fileContentNew);
	}
 * @author        Andreas Brauneis
 * @version
 *   Version 2.50.1, 01.11.2012<br/>
 *
 * Anzeige aller verfügbaren IPSLibrary Module Updates
 *
 */
/** @}*/
?>

<?php 
IPSUtils_Include("IPSModuleManager.class.php", "IPSLibrary::install::IPSModuleManager");
$html = '<h2>Installation von Modul ' . $module . '</h2>';
$file = IPS_GetKernelDir() . 'scripts\\IPSLibrary\\install\\InitializationFiles\\' . $module . '.ini';
$configUsr = parse_ini_file($file, true);
$file = IPS_GetKernelDir() . 'scripts\\IPSLibrary\\install\\InitializationFiles\\Default\\' . $module . '.ini';
$configDef = parse_ini_file($file, true);
$html2 = '';
if (array_key_exists('WFC10', $configDef)) {
    if (!array_key_exists('ID', $configDef['WFC10'])) {
        $configDef['WFC10']['ID'] = GetWFCIdDefault();
    }
    if (!array_key_exists('ID', $configUsr['WFC10'])) {
        $configUsr['WFC10']['ID'] = GetWFCIdDefault();
    }
    $html .= '<h4>WebFront (10" Optimierung)</h4>';
    $html .= '<table border=0>';
    $html .= '  <tr><th>Parameter</th><th>Wert</th><th>Default Wert</th><th>Beschreibung</th></tr>';
    $html .= Get_TableRow($configUsr, $configDef, 'WFC10', 'Enabled', 'checkbox', 'WebFront Interface', 'Mit diesem Parameter kann gesteuert werden, ob eine WebFront Installation durchgeführt wird');
    $html .= Get_TableRow($configUsr, $configDef, 'WFC10', 'Path', 'text', 'Installation Pfad', 'Legt fest in welchem Pfad die Struktur für das WebFront Interface in IP-Symcon abgelegt wird');
    $html .= Get_TableRow($configUsr, $configDef, 'WFC10', 'ID', 'text', 'WebFront Konfigurator ID', 'ID des WebFront Konfigurator, der für die Installation des WebFront Interfaces verwendet werden soll');
Пример #23
0
		/**
		 * @public
		 *
		 * Die Funktion registriert ein ScriptFile anhand des Filenames und Directory Pfades in IPS
		 *
		 * @param string $file Name des Script Files
		 */
		public function RegisterScriptByFilename($file) {
			$scriptPath = $this->GetScriptPathByFileName($file);
			$scriptName = $this->GetScriptNameByFileName($file);
			if (strpos($file, IPS_GetKernelDir().'scripts\\')===0) {
				$this->logHandler->Debug("Register Script $scriptName in $scriptPath (File=$file)");
				$categoryId = CreateCategoryPath($scriptPath);
				CreateScript($scriptName, $file, $categoryId);
			} else {
				$this->logHandler->Debug("Script $scriptName NOT registered (Filepath)");
			}
		}
Пример #24
0
 private function ReadCalendar($url, $id, $username, $password)
 {
     $this->Logging("********  Kalender: {$id} / User: {$username}  ********");
     $kscript = $this->GetIDForIdent("UserAktion");
     include IPS_GetKernelDir() . 'scripts/' . "{$kscript}.ips.php";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url . "/index.php/apps/calendar/export.php?calid=" . $id);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
     curl_setopt($ch, CURLOPT_TIMEOUT, 120);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERPWD, $username . ':' . $password);
     $result = curl_exec($ch);
     curl_close($ch);
     if ($result === false) {
         return false;
     }
     if (substr($result, 0, 15) == "BEGIN:VCALENDAR") {
         $kalender_arr_komplett = explode("BEGIN:VEVENT", $result);
         $insert = 0;
         $this->Logging("Kalender erfolgreich gelesen.");
         foreach ($kalender_arr_komplett as $key => $value) {
             $reminderCount = 0;
             if ($value != "" && $key > 0) {
                 // Leere Einträge filtern
                 $sresult = explode("\r\n", $value);
                 $startTime = '';
                 $endTime = '';
                 $alarmData = false;
                 $rettemp = array('');
                 $thisData = '';
                 $thisData['Bezeichnung'] = '';
                 $thisData['Beschreibung'] = '';
                 $thisData['Ort'] = "";
                 $thisData['UserEvent'] = "";
                 $thisData['Datum'] = '';
                 $thisData['ZeitTxt'] = '';
                 $thisData['DatumTxt'] = '';
                 $thisData['EndDatum'] = '';
                 $thisData['EndZeitTxt'] = '';
                 $thisData['EndDatumTxt'] = '';
                 $thisData['Wiederholungen'] = '';
                 $thisData['RRuleFreq'] = '';
                 $thisData['RRuleInterval'] = '';
                 $thisData['RRuleEnd'] = '';
                 $thisData['RRuleEndTxt'] = '';
                 $thisData['RRuleCount'] = '';
                 $thisData['RRuleDays'] = '';
                 $thisData['RRuleMonth'] = '';
                 $thisData['RRuleMonthDay'] = '';
                 $thisData['ReminderTime'] = array('');
                 $thisData['ReminderTimeTxt'] = array('');
                 $thisData['ReminderDateTxt'] = array('');
                 $thisData['ReminderTrigger'] = array('');
                 if ($this->debug) {
                     IPS_LogMessage("ownCloud-Modul", "T:{$key}\n");
                 }
                 foreach ($sresult as $svalue) {
                     if ($svalue != "") {
                         if ($svalue == "BEGIN:VALARM") {
                             $alarmData = true;
                         }
                         if ($svalue == "END:VALARM") {
                             $alarmData = false;
                         }
                         $xvalue = explode(':', $svalue);
                         if (substr($xvalue[0], 0, 7) == "SUMMARY") {
                             $title = "";
                             for ($i = 1; $i < count($xvalue); $i++) {
                                 if ($i > 1) {
                                     $title .= ":";
                                 }
                                 $title .= $xvalue[$i];
                             }
                             $thisData['Bezeichnung'] = iconv('UTF-8', 'ISO-8859-15', ModifyTitle($title));
                         }
                         if ($xvalue[0] == "LOCATION") {
                             $thisData['Ort'] = $xvalue[1];
                         }
                         // Start Datum/Zeit filtern
                         if (substr($xvalue[0], 0, 7) == "DTSTART") {
                             if (strlen($xvalue[1]) == 8) {
                                 $startyear = substr($xvalue[1], 0, 4);
                                 $startmonth = substr($xvalue[1], 4, 2);
                                 $startday = substr($xvalue[1], 6, 2);
                                 $startTime = strtotime("{$startday}.{$startmonth}.{$startyear} 00:00");
                             } else {
                                 $startyear = substr($xvalue[1], 0, 4);
                                 $startmonth = substr($xvalue[1], 4, 2);
                                 $startday = substr($xvalue[1], 6, 2);
                                 $starthour = substr($xvalue[1], 9, 2);
                                 $startminute = substr($xvalue[1], 11, 2);
                                 $startTime = strtotime("{$startday}.{$startmonth}.{$startyear} {$starthour}:{$startminute}");
                             }
                         }
                         // Ende Datum/Zeit filtern
                         if (substr($xvalue[0], 0, 5) == "DTEND") {
                             if (strlen($xvalue[1]) == 8) {
                                 $endyear = substr($xvalue[1], 0, 4);
                                 $endmonth = substr($xvalue[1], 4, 2);
                                 $endday = substr($xvalue[1], 6, 2);
                                 $endTime = strtotime("{$endday}.{$endmonth}.{$endyear} 00:00");
                             } else {
                                 $endyear = substr($xvalue[1], 0, 4);
                                 $endmonth = substr($xvalue[1], 4, 2);
                                 $endday = substr($xvalue[1], 6, 2);
                                 $endhour = substr($xvalue[1], 9, 2);
                                 $endminute = substr($xvalue[1], 11, 2);
                                 $endTime = strtotime("{$endday}.{$endmonth}.{$endyear} {$endhour}:{$endminute}");
                             }
                         }
                         if (substr($xvalue[0], 0, 5) == "RRULE") {
                             $rrule = explode(';', $xvalue[1]);
                             foreach ($rrule as $xrule) {
                                 $srule = explode('=', $xrule);
                                 if ($xrule == "FREQ=DAILY") {
                                     $thisData['RRuleFreq'] = "täglich";
                                 }
                                 if ($xrule == "FREQ=WEEKLY") {
                                     $thisData['RRuleFreq'] = "wöchentlich";
                                 }
                                 if ($xrule == "FREQ=MONTHLY") {
                                     $thisData['RRuleFreq'] = "monatlich";
                                 }
                                 if ($xrule == "FREQ=YEARLY") {
                                     $thisData['RRuleFreq'] = "jährlich";
                                 }
                                 if ($srule[0] == "COUNT") {
                                     $thisData['RRuleCount'] = $srule[1];
                                 }
                                 if ($srule[0] == "BYDAY") {
                                     $thisData['RRuleDays'] = $srule[1];
                                 }
                                 if ($srule[0] == "BYMONTH") {
                                     $thisData['RRuleMonth'] = $srule[1];
                                 }
                                 if ($srule[0] == "BYMONTHDAY") {
                                     $thisData['RRuleMonthDay'] = $srule[1];
                                 }
                                 if ($srule[0] == "INTERVAL") {
                                     $thisData['RRuleInterval'] = $srule[1];
                                 }
                                 if ($srule[0] == "UNTIL") {
                                     $ryear = substr($xrule, 6, 4);
                                     $rmonth = substr($xrule, 10, 2);
                                     $rday = substr($xrule, 12, 2);
                                     $rhour = substr($xrule, 15, 2);
                                     $rminute = substr($xrule, 17, 2);
                                     $thisData['RRuleEnd'] = strtotime("{$rday}.{$rmonth}.{$ryear}");
                                     $thisData['RRuleEndTxt'] = "{$rday}.{$rmonth}.{$ryear}";
                                 }
                             }
                         }
                         if (substr($xvalue[0], 0, 11) == "DESCRIPTION" && $alarmData == false) {
                             $thisData['Beschreibung'] = iconv('UTF-8', 'ISO-8859-15', $xvalue[1]);
                         }
                         if (substr($xvalue[0], 0, 8) == "LOCATION") {
                             $thisData['Ort'] = iconv('UTF-8', 'ISO-8859-15', $xvalue[1]);
                         }
                         if (substr($xvalue[0], 0, 10) == "CATEGORIES") {
                             $thisData['Kategorie'] = $xvalue[1];
                         }
                         if (substr($xvalue[0], 0, 7) == "TRIGGER") {
                             $thisData['ReminderTrigger'][$reminderCount] = substr($xvalue[0], 14) . ":" . $xvalue[1];
                             $reminderCount++;
                         }
                     }
                 }
                 $thisData['Datum'] = $startTime;
                 $thisData['ZeitTxt'] = date("H:i", $startTime);
                 $thisData['DatumTxt'] = date("d.m.Y", $startTime);
                 if ($endTime > 0) {
                     $thisData['EndDatum'] = $endTime;
                     $thisData['EndZeitTxt'] = date("H:i", $endTime);
                     $thisData['EndDatumTxt'] = date("d.m.Y", $endTime);
                     if ($thisData['ZeitTxt'] == "00:00" && $thisData['EndZeitTxt'] == "00:00") {
                         $thisData['EndDatum'] = $endTime - 86400;
                         $thisData['EndDatumTxt'] = date("d.m.Y", strtotime($thisData['EndDatumTxt'] . "-1 day"));
                     }
                 } else {
                     $thisData['EndDatum'] = '';
                     $thisData['EndZeitTxt'] = '';
                     $thisData['EndDatumTxt'] = '';
                 }
                 if ($thisData['Ort'] == "UserEvent") {
                     $thisData['UserEvent'] = substr($thisData['Beschreibung'], 0, strpos($thisData['Beschreibung'], ";") + 1);
                     $thisData['UserEvent'] = str_replace("\\;", ";", $thisData['UserEvent']);
                     $thisData['UserEvent'] = str_replace("\\,", ",", $thisData['UserEvent']);
                 }
                 $this->CheckWiederholungen($thisData);
             }
         }
         $this->Logging("Kalender Auswertung beendet");
         return true;
     } else {
         if ($this->debug == true) {
             IPS_LogMessage("ownCloud-Modul", "Keine Sinnvollen Daten von ownCloud erhalten\n\n" . $url . "/index.php/apps/calendar/export.php?calid=" . $id . "\n" . $result . "\n");
         }
         $this->Logging("Keine Sinnvollen Daten von ownCloud erhalten.\n" . $url . "/index.php/apps/calendar/export.php?calid=" . $id);
         return false;
     }
 }
Пример #25
0
 private function Patch_autoload_inc($ident, $_c = '')
 {
     $result = false;
     $c = empty($_c) ? @file_get_contents(IPS_GetKernelDir() . 'scripts\\__autoload.php') : $_c;
     $c = str_ireplace(array('<?php', '<?', '?>'), '', $c);
     if (!preg_match("/##Rpc4Patch##/", $c, $m)) {
         $f = array('/*##Rpc4Patch##*/');
         $f[] = 'function Rpc4_Patch_generated($ident, $_c=""){';
         $f[] = ' $Patch=function($ident, &$c){';
         $f[] = '  static $a=array("Instance_ID"=>"Instance_ID=0","Channel"=>"Channel=\\"Master\\"","Speed"=>"Speed=1");';
         $f[] = '  $result=false;';
         $f[] = '  if(!preg_match_all("/{$ident}_\\w+\\((.+)\\)/",$c,$m))return $result;';
         $f[] = '  for($j=0;$j<count($m[0]);$j++){';
         $f[] = '   list($line,$found)=array(trim($m[0][$j]),trim($m[1][$j]));';
         $f[] = '   $found=explode(\',\',$found);';
         $f[] = '   foreach($found as &$f){$f=substr(trim($f),1);if(!empty($a[$f]))$f=$a[$f];}';
         $f[] = '   $found=\'$\'.implode(\', $\',$found);';
         $f[] = '   $newline=substr($line,0,strpos($line,\'(\')+1).$found.\')\';';
         $f[] = '   if(strcmp($line,$newline)!=0){$c=str_replace($line,$newline,$c);$result=true;}';
         $f[] = '  }';
         $f[] = '  if($result)$c.="\\nfunction {$ident}_PatchApplyed(){return true;}\\n";';
         $f[] = '  return $result;';
         $f[] = ' };';
         $f[] = ' $c=$_c?$_c:@file_get_contents(IPS_GetKernelDir()."\\scripts\\__generated.inc.php");';
         $f[] = ' $result=false;';
         $f[] = ' if(!$c)return false;';
         $f[] = ' if(is_array($ident)){foreach($ident as $i)if($Patch($i,$c))$result=true;}';
         $f[] = ' else $result=$Patch($ident,$c);';
         $f[] = ' if(!empty($_c))return $c;';
         $f[] = ' return $result?file_put_contents(IPS_GetKernelDir()."\\scripts\\__generated.inc.php",$c):null;';
         $f[] = '}';
         $c = implode("\r\n", $f) . "\n" . $c;
         $result = true;
     }
     if (!preg_match("/##Rpc4RunPatch##/", $c, $m)) {
         $c .= "/*##Rpc4RunPatch##*/ if(!empty(\$patch))Rpc4_Patch_generated(\$patch);";
         $result = true;
     }
     if (!preg_match('/##' . $ident . '##/', $c, $m)) {
         $p = strpos($c, '/*##Rpc4RunPatch');
         $c = substr($c, 0, $p) . "\n/*##{$ident}##*/ if(!function_exists('{$ident}_PatchApplyed'))\$patch[]='{$ident}';\n" . substr($c, $p);
         $result = true;
     }
     $c = "<?php\n{$c}\n?>\n";
     if (!empty($_c)) {
         return $c;
     }
     return $result ? file_put_contents(IPS_GetKernelDir() . 'scripts\\__autoload.php', $c) : null;
 }