public function lost() { $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG); $log->logInfo("usergameaction > lost > start userId : " . $this->userId . " opponentId : " . $this->opponentId . " action : " . $this->action_ . " time : " . $this->time . " room groupId : " . $this->roomGroupId . " gameId : " . $this->gameId . " normal : " . $this->normal . " type : " . $this->type . " double : " . $this->double); if (!empty($this->userId)) { $user = GameUsers::getGameUserById($this->userId); if (!empty($user)) { $userId = $user->getUserId(); if (!empty($userId)) { $user->getUserLevel(); $opponent = GameUsers::getGameUserById($this->opponentId); $opponentId = null; if (!empty($opponent)) { $opponentId = $opponent->getUserId(); $opponent->getUserLevel(); } $result = GameUtils::gameResult($user, $opponent, $this->roomGroupId, $this->action_, $this->gameId, $this->double, $this->normal, $this->type, $this->time); if (!empty($result) && $result->success) { $log->logInfo("usergameaction > lost > success "); } else { $log->logError("usergameaction > lost > error : " . $result->result); } unset($userId); unset($user); } else { $log->logError("usergameaction > lost > user Id is empty "); } } else { $log->logError("usergameaction > lost > user Id is empty "); } } else { $log->logError("usergameaction > lost > user Id is empty "); } }
public function log() { $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG); $log->logInfo("userxplog > log > start userId : " . $this->userId . " xp : " . $this->xp . " type : " . $this->type . " time : " . $this->time . " gameId : " . $this->gameId . " result : " . $this->result . " opponentId : " . $this->opponentId); if (!empty($this->userId)) { $userXPLog = new GameUserXpLog(); $userXPLog->setUserId($this->userId); $userXPLog->setXp($this->xp); $userXPLog->setTime($this->time); $userXPLog->setType($this->type); $userXPLog->setGameId($this->gameId); $userXPLog->setResult($this->result); $userXPLog->setOpponentId($this->opponentId); try { $user = GameUsers::getGameUserById($this->userId); if (!empty($user)) { $userXPLog->setUserLevel($user->userLevelNumber); $userXPLog->setUserCoin($user->coins); //$userCoinLog->setUserSpentCoin($user->opponentId); } } catch (Exception $exc) { $log->logError("userxplog > log > User Error : " . $exc->getTraceAsString()); } try { $userXPLog->insertIntoDatabase(DBUtils::getConnection()); $log->logInfo("userxplog > log > Success"); } catch (Exception $exc) { $log->logError("userxplog > log > Error : " . $exc->getTraceAsString()); } } else { $log->logError("userxplog > log > user Id is empty "); } }
public function __construct() { date_default_timezone_set("PRC"); self::$log = \KLogger::instance(dirname(__FILE__) . "/../log", \KLogger::DEBUG); require_once '../config/Config.php'; $this->config = $METAQ_CONFIG; $this->initPartitionList(); }
public function __construct($config) { if ($config['logging']['enabled'] && $config['logging']['level'] > 0) { $this->KLogger = KLogger::instance($config['logging']['path'] . '/website', $config['logging']['level']); $this->logging = true; $this->floatStartTime = microtime(true); } }
public function saveMIDItoFile() { //$this->filename = base_convert(mt_rand(), 10, 36); if($this->filenameSet === true) { $this->midi->saveMidFile($this->filepath.'.mid', 0666); if (defined('DEBUG')) $log = KLogger::instance(dirname(DEBUG), KLogger::DEBUG); if (defined('DEBUG')) $log->logInfo("Saved MIDI to file: $this->filepath"); return true; } }
public function __construct($class = "GLOBAL", $user = "******", $prefix = "") { global $LOGS_PATH; global $LOGS_SEVERITY; if (!isset(Logger::$log)) { Logger::$log = KLogger::instance($LOGS_PATH, $LOGS_SEVERITY); } $this->class = $class; $this->user = $user; $this->prefix = $prefix; }
public function generateAudio($filepath) { //we could also make use of FIFOs: //http://stackoverflow.com/questions/60942/how-can-i-send-the-stdout-of-one-process-to-multiple-processes-using-preferably $command = '/usr/bin/timidity -A110 -Ow --verbose=-2 --reverb=f,100 --output-file=- '.$filepath.'.mid | tee >(lame --silent -V6 - '.$filepath.'.mp3) | oggenc -Q -q1 -o '.$filepath.'.ogg -'; //file_put_contents('command', $command); if (defined('ASYNCHRONOUS_LAUNCH')) $this->launchBackgroundProcess('/bin/bash -c "'.$command.'"'); else shell_exec('/bin/bash -c "'.$command.'"'); if (defined('DEBUG')) $log = KLogger::instance(dirname(DEBUG), KLogger::DEBUG); if (defined('DEBUG')) $log->logInfo("Converted MIDI to audio files with the command: $command"); return true; }
public function __construct($template, $action, $urlValues, $standalone = false, $signinRequired = false) { $this->action = $action; $this->urlValues = $urlValues; $this->template = $template; $this->_standalone = $standalone; $this->log = KLogger::instance(KLOGGER_PATH, KLogger::DEBUG); $this->language = LANG_TR_TR; if (!isset($_SESSION)) { session_start(); } if ($signinRequired) { $this->redirect("/"); } }
public function updateImage() { $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG); $log->logInfo("user > updateImage > start userId : " . $this->userId); try { $userId = $this->userId; if (!empty($userId)) { $result = UserProfileImageUtils::updateUserImage($userId); $log->logInfo("user > updateImage >userId : " . $this->userId . " Result " . json_encode($result)); } else { $log->logError("user > updateImage > start userId : " . $this->userId . " user found user id empty"); } } catch (Exception $exc) { $log->logError("user > updateImage > error userId : " . $this->userId . " Error :" . $exc->getMessage()); } $log->logInfo("user > updateImage > finished userId : " . $this->userId); }
<?php # Should log to the same directory as this file require dirname(__FILE__) . '/../src/KLogger.php'; $log = KLogger::instance(dirname(__FILE__), KLogger::DEBUG); $log->logInfo('Info Test'); $log->logNotice('Notice Test'); $log->logWarn('Warn Test'); $log->logError('Error Test'); $log->logFatal('Fatal Test'); $log->logAlert('Alert Test'); $log->logCrit('Crit test'); $log->logEmerg('Emerg Test');
$cron_name = basename($_SERVER['PHP_SELF'], '.php'); // Include our configuration (holding defines for the requires) require_once BASEPATH . '../include/bootstrap.php'; require_once BASEPATH . '../include/version.inc.php'; // Command line switches array_shift($argv); foreach ($argv as $option) { switch ($option) { case '-f': $monitoring->setStatus($cron_name . "_disabled", "yesno", 0); $monitoring->setStatus($cron_name . "_active", "yesno", 0); break; } } // Load 3rd party logging library for running crons $log = KLogger::instance(BASEPATH . '../logs/' . $cron_name, KLogger::INFO); $log->LogDebug('Starting ' . $cron_name); // Load the start time for later runtime calculations for monitoring $cron_start[$cron_name] = microtime(true); // Check if our cron is activated if ($monitoring->isDisabled($cron_name)) { $log->logFatal('Cronjob is currently disabled due to errors, use -f option to force running cron.'); $monitoring->endCronjob($cron_name, 'E0018', 1, true, false); } // Mark cron as running for monitoring $log->logDebug('Marking cronjob as running for monitoring'); if (!$monitoring->startCronjob($cron_name)) { $log->logFatal('Unable to start cronjob: ' . $monitoring->getCronError()); exit; } // Check if we need to halt our crons due to an outstanding upgrade
public function __construct($log_directory, $debug_level) { $level = $debug_level != null ? $debug_level : \KLogger::DEBUG; $this->log = \KLogger::instance($log_directory, $level); }
/** * Importiert die Daten aus der aus Kufer SQL exportierten XML Datei. * @global mixed[] $REX Redaxo Variable */ public static function syncData() { global $REX; // error reporting if (KUFER_IMPORT_DEBUG_MODE) { ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); } else { ini_set('display_startup_errors', 0); ini_set('display_errors', 0); error_reporting(0); } include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php'; // init logger $logFile = KUFER_IMPORT_LOG_FILE_PATH; $log = KLogger::instance($logFile, KLogger::INFO); // PHP Log Einstellungen werden ausgelesen, damit sie später zurückgesetzt werden können $phpLogErrors = ini_get('log_errors'); $phperrorLog = ini_get('error_log'); ini_set('log_errors', 1); ini_set('error_log', $log->getLogFilePath()); $log->logInfo('======================================== START Kufer Import ========================================'); $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml'))); $xmlUrl = $REX['ADDON']['kufer_import']['settings']['xml_url']; // XML Datei auslesen $xmlString = file_get_contents($xmlUrl, false, $context); $kufer_kurse = simplexml_load_string($xmlString, null, LIBXML_NOCDATA); // Bestehende Kurse auslesen, falls sie aktualisiert werden require_once $REX['INCLUDE_PATH'] . '/addons/d2u_kurse/classes/class.kurs.inc.php'; $kurse = Kurs::getAll($REX['TABLE_PREFIX'], FALSE); // Nur die Kurse sind von Interesse, die durch kufer_import hinzugefügt wurden $importierte_kurse = array(); foreach ($kurse as $kurs) { if ($kurs->import == KUFER_IMPORT_STRING) { $importierte_kurse[$kurs->kursnummer] = $kurs; } } // Kufer Kurse hinzufügen oder aktualisieren $counter_new = 0; $counter_update = 0; $kurskategorien = Kurskategorie::getAll($kurs->table_prefix, 0, FALSE); $terminkategorien = Terminkategorie::getAll($kurs->table_prefix, FALSE); $zielgruppen = Zielgruppe::getAll($kurs->table_prefix, FALSE); foreach ($kufer_kurse->kurs as $kufer_kurs) { // Kurse, die ausfallen werden nicht importiert if (isset($kufer_kurs->ausfall)) { continue; } // Kurse, die schon begonnen haben werden nicht importiert if (isset($kufer_kurs->beginndat) && $kufer_kurs->beginndat != "") { $d = explode(".", $kufer_kurs->beginndat); $beginndat_time = mktime(0, 0, 0, $d[1], $d[0], $d[2]); if (strtotime("-1 day") > $beginndat_time) { continue; } } $kurs = Kurs::factory($REX['TABLE_PREFIX']); // Wurde Kurs schon einmal importiert? if (isset($kufer_kurs->knr)) { $kufer_kursnummer = (string) $kufer_kurs->knr; if (array_key_exists($kufer_kursnummer, $importierte_kurse)) { // Kurs aus Array holen ... $kurs = $importierte_kurse[$kufer_kursnummer]; // ... und entfernen, denn übrige Kurse werden später gelöscht unset($importierte_kurse[$kufer_kursnummer]); } } // Werte aus Import holen und in Kursobjekt schreiben // Kursnummer if (isset($kufer_kurs->knr)) { $kurs->kursnummer = (string) $kufer_kurs->knr; } // Titel if (isset($kufer_kurs->titelkurz) && $kufer_kurs->titelkurz != "") { $kurs->titel = (string) $kufer_kurs->titelkurz; } else { if (isset($kufer_kurs->titellang) && $kufer_kurs->titellang != "") { $kurs->titel = (string) $kufer_kurs->titellang; } } // Beschreibung $kurs->beschreibung = ""; // Zuerst Zurücksetzen if (isset($kufer_kurs->titellang) && $kufer_kurs->titellang != "") { $kurs->beschreibung = "<p><b>" . (string) $kufer_kurs->titellang . "</b></p>"; } if (isset($kufer_kurs->web_info) && $kufer_kurs->web_info != "") { $kurs->beschreibung .= "<p>" . nl2br($kufer_kurs->web_info) . "</p>"; } else { if (isset($kufer_kurs->inhalt) && $kufer_kurs->inhalt != "") { $kurs->beschreibung .= "<p>" . nl2br($kufer_kurs->inhalt) . "</p>"; } } if (isset($kufer_kurs->material) && $kufer_kurs->material != "") { $kurs->beschreibung .= "<p><b>Material</b></p>"; $kurs->beschreibung .= "<p>" . nl2br($kufer_kurs->material) . "</p>"; } // Anmeldung mit Warenkorb möglich if (isset($kufer_kurs->keinewebanmeldung) && $kufer_kurs->keinewebanmeldung == "F") { $kurs->anmeldung_moeglich = "ja"; } else { if (isset($kufer_kurs->keinewebanmeldung) && $kufer_kurs->keinewebanmeldung == "W") { $kurs->anmeldung_moeglich = "nein"; } } if (isset($kufer_kurs->tnmax) && isset($kufer_kurs->tnanmeldungen) && (int) $kufer_kurs->tnmax > 0 && $kufer_kurs->tnanmeldungen >= (int) $kufer_kurs->tnmax) { $kurs->anmeldung_moeglich = "ausgebucht"; } // Datum Kurs if (isset($kufer_kurs->beginndat) && $kufer_kurs->beginndat != "") { // Beginn $kurs->datum_von = kufer_sync::formatDate($kufer_kurs->beginndat); // Ende if (isset($kufer_kurs->endedat) && $kufer_kurs->endedat != "" && trim($kufer_kurs->beginndat) != trim($kufer_kurs->endedat)) { $kurs->datum_bis = kufer_sync::formatDate($kufer_kurs->endedat); $kurs->uhrzeit = ""; } else { $kurs->datum_bis = ""; // Uhrzeit bei eintägigen Veranstaltungen ... if (isset($kufer_kurs->beginnuhr) && $kufer_kurs->beginnuhr != "") { $kurs->uhrzeit = $kufer_kurs->beginnuhr; if (isset($kufer_kurs->endeuhr) && $kufer_kurs->endeuhr != "") { $kurs->uhrzeit .= " - " . $kufer_kurs->endeuhr; } $kurs->uhrzeit .= " Uhr"; } } } if (isset($kufer_kurs->termine) && $kufer_kurs->termine->termin->count() > 1) { // ... bei mehrtätigen Veranstaltungen Termine in Beschreibung schreiben $kurs->beschreibung .= "<p><b>Termine</b></p>"; $kurs->beschreibung .= "<ul>"; for ($i = 0; $i < $kufer_kurs->termine->termin->count(); $i++) { $kurs->beschreibung .= "<li>" . $kufer_kurs->termine->termin[$i]->tag; if (isset($kufer_kurs->termine->termin[$i]->zeitvon) && $kufer_kurs->termine->termin[$i]->zeitvon != "") { $kurs->beschreibung .= ": " . $kufer_kurs->termine->termin[$i]->zeitvon; if (isset($kufer_kurs->termine->termin[$i]->zeitbis) && $kufer_kurs->termine->termin[$i]->zeitbis != "") { $kurs->beschreibung .= " - " . $kufer_kurs->termine->termin[$i]->zeitbis; } $kurs->beschreibung .= " Uhr"; } $kurs->beschreibung .= "</li>"; } $kurs->beschreibung .= "</ul>"; } if (isset($kufer_kurs->dauerdetails) && $kufer_kurs->dauerdetails != "") { $kurs->beschreibung .= "<p><b>Zusätzliche Bemerkungen zum Termin:</b></p><p>" . $kufer_kurs->dauerdetails . "</p>"; } // Kursort: siehe Einstellungen $kurs->ort = new Kursort($REX['ADDON']['kufer_import']['settings']['default_ort_id'], $kurs->table_prefix); // Kursgebühren if (isset($kufer_kurs->gebnorm) && floatval($kufer_kurs->gebnorm) > 0) { $kurs->kosten = floatval($kufer_kurs->gebnorm); } if (isset($kufer_kurs->geberm) && floatval($kufer_kurs->geberm) > 0 && $kufer_kurs->gebnorm != $kufer_kurs->geberm) { $kurs->kosten_erm = floatval($kufer_kurs->geberm); } // Maximale Teilnehmer if (isset($kufer_kurs->tnmax) && $kufer_kurs->tnmax > 0) { $kurs->teilnehmer_max = (int) $kufer_kurs->tnmax; // Konvertierung zu int nötig } // Minimale Teilnehmer if (isset($kufer_kurs->tnmin) && $kufer_kurs->tnmin > 0) { $kurs->teilnehmer_min = (int) $kufer_kurs->tnmin; // Konvertierung zu int nötig } // Anzahl Anmeldunngen if (isset($kufer_kurs->tnanmeldungen) && $kufer_kurs->tnanmeldungen > 0) { $kurs->teilnehmer_angemeldet = (int) $kufer_kurs->tnanmeldungen; // Konvertierung zu int nötig } // Anzahl auf Warteliste if (isset($kufer_kurs->tnwarteliste) && $kufer_kurs->tnwarteliste > 0) { $kurs->teilnehmer_warteliste = (int) $kufer_kurs->tnwarteliste; // Konvertierung zu int nötig } // Dozenten if (isset($kufer_kurs->dozenten) && count($kufer_kurs->dozenten) > 0) { $kurs->kursleiter = ""; // Erst Reset der Variable for ($i = 0; $i < $kufer_kurs->dozenten->dozent->count(); $i++) { $dozent = $kufer_kurs->dozenten->dozent[$i]; if (strlen($kurs->kursleiter) > 3) { $kurs->kursleiter .= ", "; } if (isset($dozent->titel)) { $kurs->kursleiter .= $dozent->titel . " "; } if (isset($dozent->vorname) && isset($dozent->name)) { $kurs->kursleiter .= $dozent->vorname . " " . $dozent->name; } } } // Ort: Raumname if (isset($kufer_kurs->ortraumname) && $kufer_kurs->ortraumname != "") { $kurs->raum = $kufer_kurs->ortraumname; } // Für die Zuordnung der Kategorien und Zielgruppen zuerst ein Reset $kurs->kurskategorie = FALSE; $kurs->sekundaere_kurskategorie_ids = array(); $kurs->zielgruppen_ids = array(); // Kategorien if (isset($kufer_kurs->kategorien) && count($kufer_kurs->kategorien) > 0) { // Erst mal nur die Kufer Kursbezeichnungen holen $kufer_kurs_bezeichnungstrukturen = array(); for ($i = 0; $i < $kufer_kurs->kategorien->kategorie->count(); $i++) { $kufer_kurs_bezeichnungstrukturen[] = (string) $kufer_kurs->kategorien->kategorie[$i]->bezeichnungstruktur; } // Kurskategorie zuordnen $kurskategorie_counter = 0; foreach ($kurskategorien as $kurskategorie) { foreach ($kurskategorie->kufer_kategorien_bezeichnungsstrukturen as $kurskategorie_bezeichnungsstruktur) { if (in_array($kurskategorie_bezeichnungsstruktur, $kufer_kurs_bezeichnungstrukturen) && !in_array($kurskategorie->kurskategorie_id, $kurs->sekundaere_kurskategorie_ids)) { if ($kurskategorie_counter == 0) { $kurs->kurskategorie = $kurskategorie; } $kurs->sekundaere_kurskategorie_ids[] = $kurskategorie->kurskategorie_id; } } } // Terminkategorie zuordnen foreach ($terminkategorien as $terminkategorie) { foreach ($terminkategorie->kufer_kategorien_bezeichnungsstrukturen as $terminkategorie_bezeichnungsstruktur) { if (in_array($terminkategorie_bezeichnungsstruktur, $kufer_kurs_bezeichnungstrukturen) && !in_array($terminkategorie->terminkategorie_id, $kurs->terminkategorie_ids)) { $kurs->terminkategorie_ids[] = $terminkategorie->terminkategorie_id; } } } // Zielgruppe aus Katgeorien zuordnen foreach ($zielgruppen as $zielgruppe) { foreach ($zielgruppe->kufer_kategorien_bezeichnungsstrukturen as $zielgruppe_bezeichnungsstruktur) { if (in_array($zielgruppe_bezeichnungsstruktur, $kufer_kurs_bezeichnungstrukturen) && !in_array($zielgruppe->zielgruppe_id, $kurs->zielgruppen_ids)) { $kurs->zielgruppen_ids[] = $zielgruppe->zielgruppe_id; } } } } // Falls immernoch keine Kurskategorie gesetzt wurde if ($kurs->kurskategorie === FALSE) { $kurs->kurskategorie = new Kurskategorie($REX['ADDON']['kufer_import']['settings']['default_kurs_kategorie_id'], $kurs->table_prefix); $kurs->sekundaere_kurskategorie_ids = array($REX['ADDON']['kufer_import']['settings']['default_kurs_kategorie_id']); } // Zielgruppe aus Zielgruppe if (isset($kufer_kurs->zielgruppe) && $kufer_kurs->zielgruppe != "") { foreach ($zielgruppen as $zielgruppe) { if ($zielgruppe->kufer_zielgruppe_name == $kufer_kurs->zielgruppe && !in_array($zielgruppe->zielgruppe_id, $kurs->zielgruppen_ids)) { $kurs->zielgruppen_ids[] = $zielgruppe->zielgruppe_id; } } } else { if (count($kurs->zielgruppen_ids) == 0) { $kurs->zielgruppen_ids[] = $REX['ADDON']['kufer_import']['settings']['default_zielgruppe_id']; } } // Status $kurs->status = "online"; // Importiert durch Kufer SQL $kurs->import = KUFER_IMPORT_STRING; // Kurs speichern und Ergebnis loggen if ($kurs->kurs_id == 0) { $counter_new++; } else { $counter_update++; } $log->logInfo($kurs->save()); } print "<h1>Kufer Import Ergebnis</h1>"; print "<p>" . $counter_new . " Kurse hinzugefügt.</p>"; print "<p>" . $counter_update . " Kurse aktualisiert.</p>"; // Übrige importierte Kurse löschen $counter_delete = 0; foreach ($importierte_kurse as $importierter_kurs) { $log->logInfo($importierter_kurs->delete()); $counter_delete++; } print "<p>" . $counter_delete . " Kurse gelöscht.</p>"; // Einstellungen zum Loggen zurücksetzen ini_set('log_errors', $phpLogErrors); ini_set('error_log', $phperrorLog); $log->logInfo('======================================== ENDE Kufer Import ========================================'); }
public static function syncData() { global $REX, $I18N; // error reporting if (HR4YOU_SYNC_DEBUG_MODE) { ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1); } else { ini_set('display_startup_errors', 0); ini_set('display_errors', 0); error_reporting(0); } // necessary stuff so mediapool function can work properly in frontend $REX['USER'] = new rex_fe_user(); $I18N = rex_create_lang($REX['LANG']); include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_generate.inc.php'; include_once $REX['INCLUDE_PATH'] . '/functions/function_rex_mediapool.inc.php'; // init logger $logFile = HR4YOU_SYNC_LOG_FILE_PATH; $log = KLogger::instance($logFile, KLogger::INFO); $phpLogErrors = ini_get('log_errors'); $phperrorLog = ini_get('error_log'); ini_set('log_errors', 1); ini_set('error_log', $log->getLogFilePath()); $log->logInfo('======================================== START HR4YOU SYNC ========================================'); $context = stream_context_create(array('http' => array('header' => 'Accept: application/xml'))); $xmlUrl = $REX['ADDON']['hr4you_sync']['settings']['xml_url']; $defaultClangId = $REX['ADDON']['hr4you_sync']['settings']['default_clang_id']; $defaultArticleId = $REX['ADDON']['hr4you_sync']['settings']['default_article_id']; $defaultMediaCategoryId = $REX['ADDON']['hr4you_sync']['settings']['default_media_category_id']; $defaultJobCategoryId = $REX['ADDON']['hr4you_sync']['settings']['default_job_category_id']; $xmlString = file_get_contents($xmlUrl, false, $context); $jobs = new SimpleXMLElement($xmlString); // remove all previously synced jobs and media files $log->logInfo('>> [INF] remove all previously synced jobs and media files'); $sql = rex_sql::factory(); $sql->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql, "SELECT * FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen` WHERE hr4you_jobid > 0 ORDER BY stellen_id ASC"); for ($i = 0; $i < $sql->getRows(); $i++) { $sql2 = rex_sql::factory(); $sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql2, 'DELETE FROM `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen` WHERE stellen_id = ' . $sql->getValue('stellen_id')); rex_hr4you_sync_utils::logQuery($log, $sql2, 'DELETE FROM `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen_lang` WHERE stellen_id = ' . $sql->getValue('stellen_id')); // delete media $log->logInfo('>> [INF] delete media: ' . $sql->getValue('bild')); $media = OOMedia::getMediaByFileName($sql->getValue('bild')); if (is_object($media)) { $mediaInUse = $media->isInUse(); if ($mediaInUse === false) { if ($media->delete() !== false) { // success $log->logInfo('>> [INF] media deleted'); } else { // failed $log->logError('>> [ERR] media not deleted'); } } else { $log->logInfo('>> [INF] media not deleted because still in use'); } } else { $log->logInfo('>> [INF] media does not exist anymore'); } $sql->next(); } // add jobs $log->logInfo('>> [INF] add jobs'); foreach ($jobs->entry as $job) { $sql = rex_sql::factory(); $sql->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql, "SELECT * FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_stellen` WHERE hr4you_jobid = " . $job->jobid); if ($sql->getRows() < 1) { // for safety reasons: only addon new job if it does not already exist // copy media file $log->logInfo('>> [INF] copy media file'); $pathInfo = pathinfo($job->kopfgrafik_url); $originalFile = $pathInfo['basename']; $originalFileWithPath = $REX['MEDIAFOLDER'] . DIRECTORY_SEPARATOR . $originalFile; $mediaFile = self::rex_mediapool_filename_nosubindex($pathInfo['basename'], false); $mediaFileWithPath = $REX['MEDIAFOLDER'] . DIRECTORY_SEPARATOR . $mediaFile; if (!file_exists($mediaFileWithPath)) { if (copy($job->kopfgrafik_url, $mediaFileWithPath)) { $log->logInfo('>> [INF] media file sucessfully copied because it does not exist'); } if (chmod($mediaFileWithPath, $REX['FILEPERM'])) { $log->logInfo('>> [INF] media file chmod to: ' . $REX['FILEPERM']); } $mpSyncReturn = rex_mediapool_syncFile($mediaFile, $defaultMediaCategoryId, $job->kopfgrafik_name); $log->logInfo('>> [INF] media file synced width return value: ', $mpSyncReturn); } else { $log->logInfo('>> [INF] media file already exists'); } // retrieve id of contact by email address $log->logInfo('>> [INF] retrieve id of contact by email address'); $sql2 = rex_sql::factory(); $sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql2, "SELECT kontakt_id FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kontakt` WHERE email LIKE '" . $job->ap_email . "'"); if ($sql2->getRows() > 0) { //contact found $contactId = $sql2->getValue('kontakt_id'); $log->logInfo('>> [INF] contact found! id:' . $contactId); } else { $log->logInfo('>> [INF] contact not found. adding new contact'); $sql2 = rex_sql::factory(); $sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql2, 'INSERT INTO `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_kontakt` (name, bild, telefon, email) VALUES ("' . $job->ap_vorname . ' ' . $job->ap_nachname . '","", "' . $job->ap_telefon . '", "' . $job->ap_email . '")'); $contactId = $sql2->getLastId(); $log->logInfo('>> [INF] contact id: ' . $contactId); } // checkout job category id as xml and addon ids are different $log->logInfo('>> [INF] checkout job category id as xml and addon ids are different'); $sql2 = rex_sql::factory(); $sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql2, "SELECT kategorie_id FROM `" . $REX['TABLE_PREFIX'] . "d2u_stellenmarkt_kategorien` WHERE hr4you_berufskategorie_id LIKE '" . $job->berufskategorie_id . "'"); if ($sql2->getRows() > 0) { // job category found $log->logInfo('>> [INF] job category found!'); $jobCategoryId = $sql2->getValue('kategorie_id'); } else { $log->logInfo('>> [INF] job category not found! using default job category id'); $jobCategoryId = $defaultJobCategoryId; } // add new job $log->logInfo('>> [INF] add new job'); $sql2 = rex_sql::factory(); $sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql2, 'INSERT INTO `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen` (hr4you_jobid, interne_bezeichnung, interne_nummer, datum, status, kontakt_id, artikel_id, kategorie_ids, bild, hr4you_url_application_form) VALUES (' . $job->jobid . ',"' . $job->titel . '", ' . $job->referenznummer . ', "' . $job->von_datum . '", "online", ' . $contactId . ', ' . $defaultArticleId . ', "|' . $jobCategoryId . '|", "' . $mediaFile . '", "' . $job->url_application_form . '")'); $theJobId = $sql2->getLastId(); // get blocks and headings $block1 = self::trimString($job->block1_html); $block2 = self::trimString($job->block2_html); $block3 = self::trimString($job->block3_html); $headline1 = self::getHeadline($block1); $headline2 = self::getHeadline($block2); $headline3 = self::getHeadline($block3); include_once $REX['INCLUDE_PATH'] . '/addons/xoutputfilter/classes/class.xoutputfilter.inc.php'; $xoutputFilter = new xoutputfilter(); if ($block1 != '') { if ($headline1 == '') { $headline1 = $xoutputFilter->get('###aufgaben_ueberschrift###', $defaultClangId); $log->logInfo('>> [INF] headline1 not found. using default: ' . $headline1); } else { $block1 = self::stripHeadline($block1); } } if ($block2 != '') { if ($headline2 == '') { $headline2 = $xoutputFilter->get('###profil_ueberschrift###', $defaultClangId); $log->logInfo('>> [INF] headline2 not found. using default: ' . $headline2); } else { $block2 = self::stripHeadline($block2); } } if ($block3 != '') { if ($headline3 == '') { $headline3 = $xoutputFilter->get('###angebot_ueberschrift###', $defaultClangId); $log->logInfo('>> [INF] headline3 not found. using default: ' . $headline3); } else { $block3 = self::stripHeadline($block3); } } // add lang specific stuff for new job $log->logInfo('>> [INF] add lang specific stuff for new job'); $sql2 = rex_sql::factory(); $sql2->setDebug(HR4YOU_SYNC_DEBUG_MODE); rex_hr4you_sync_utils::logQuery($log, $sql2, 'INSERT INTO `' . $REX['TABLE_PREFIX'] . 'd2u_stellenmarkt_stellen_lang` (stellen_id, clang_id, bezeichnung, aufgaben_ueberschrift, aufgaben_text, profil_ueberschrift, profil_text, angebot_ueberschrift, angebot_text, hr4you_einleitung) VALUES (' . $theJobId . ', ' . $defaultClangId . ', "' . $job->titel . '", "' . $headline1 . '", "' . htmlspecialchars($block1) . '", "' . $headline2 . '", "' . htmlspecialchars($block2) . '", "' . $headline3 . '", "' . htmlspecialchars($block3) . '", "' . $job->einleitung . '")'); } } // delete pathlist as ids of jobs have changed $log->logInfo('>> [INF] delete pathlist'); seo42_generate_pathlist(array()); // restore vars and settings unset($REX['USER']); unset($I18N); ini_set('log_errors', $phpLogErrors); ini_set('error_log', $phperrorLog); $log->logInfo('======================================== END HR4YOU SYNC ========================================'); }
<?php define("__ROOT__", __DIR__ . "/../"); require_once __ROOT__ . 'config/constants.php'; require_once __ROOT__ . '/vendors/KLogger.php'; $log = KLogger::instance(KLOGGER_PATH . "queue_high/", KLogger::DEBUG); if (isset($_POST["data"])) { $data = $_POST["data"]; $obj = json_decode($data); $log->logInfo("processHigh > " . $data); $method = $obj->method; $action = $obj->action; unset($obj->method); unset($obj->action); $processorClass = ucfirst(strtolower($method)) . "Processor"; if (!file_exists(__ROOT__ . "processor/" . $method . ".class.php")) { $log->logError("processHigh > method " . $method . " not found!"); header('HTTP/1.0 404 Not Found'); exit; } require __ROOT__ . "processor/" . $method . ".class.php"; if (class_exists($processorClass)) { $processor = new $processorClass(); if (method_exists($processor, $action)) { $vars = array_keys(get_object_vars($processor)); foreach ($obj as $key => $value) { if (in_array($key, $vars)) { $processor->{$key} = $value; } } try {
*/ include "user/database.php"; /* configuration file which contains the application settings. */ include "user/config.php"; /* start sessions for the application. user sessions are stored in database rather than session files for enhanced security. */ include MODS_DIRECTORY . "/class.dbsession.php"; $session = new dbSession($db, $_setting['session_timeout']); /* this is the logging class to log errors, warnings and notices generated by the application. */ include MODS_DIRECTORY . "/class.logger.php"; $log = KLogger::instance(dirname(__FILE__) . "/" . MODS_DIRECTORY . "/logs/", KLogger::DEBUG); /* pagination class for rendering pages in the application. */ include MODS_DIRECTORY . "/class.pagination.php"; /* gravatar class for fetching user profile photo associated with their email address on the gravatar.com website */ include MODS_DIRECTORY . "/class.gravatar.php"; /* classes which form the base of the application. Do not remove any of these. */ include USER_DIRECTORY . "/functions.php"; include USER_DIRECTORY . "/session.inc.php"; /* inclusion of this file helps in making the application translation ready.
function findClosestEquivalent($note1, $note2, $distance = 7, $scale) { if (defined('DEBUG')) $log = KLogger::instance(dirname(DEBUG), KLogger::DEBUG); if (defined('DEBUG')) $log->logDebug("finding closest equivalent for $note1 vs $note2 with distance $distance"); if ($this->checkInterval($note1, $note2) > $distance) { return $this->oneOctaveTransposeCloser($note1, $note2, $distance, $scale); } else return $note1; }
<?php # Should log to the same directory as this file require dirname(__FILE__) . '/../src/KLogger.php'; $fileAttributes = array('prefix' => 'frets', 'suffix' => 'txt', 'appendDate' => true, 'appendPID' => true); $log = KLogger::instance(dirname(__FILE__), KLogger::DEBUG, $fileAttributes); $args1 = array('a' => array('b' => 'c'), 'd'); $args2 = NULL; $log->logInfo('Info Test'); $log->logNotice('Notice Test'); $log->logWarn('Warn Test'); $log->logError('Error Test'); $log->logFatal('Fatal Test'); $log->logAlert('Alert Test'); $log->logCrit('Crit test'); $log->logEmerg('Emerg Test'); $log->logInfo('Testing passing an array or object', $args1); $log->logWarn('Testing passing a NULL value', $args2);
public function add() { $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG); $log->logInfo("leaderboard > add > start userId : " . $this->userId . " diff Coin : " . $this->difCoin . " time : " . $this->time); if (!empty($this->userId)) { $user = GameUsers::getGameUserById($this->userId); if (!empty($user)) { $userId = $user->getUserId(); if (!empty($userId)) { $daily = GameLeaderboardDaily::getRecordByUserId($userId); if (empty($daily)) { $daily = new GameLeaderboardDaily(); $daily->setId(-1); $daily->setUserId($userId); $daily->setCoins(0); } $daily->setLastPlayed($this->time); $weekly = GameLeaderboardWeekly::getRecordByUserId($userId); if (empty($weekly)) { $weekly = new GameLeaderboardWeekly(); $weekly->setId(-1); $weekly->setUserId($userId); $weekly->setCoins(0); } $weekly->setLastPlayed($this->time); $dCoins = $daily->getCoins() + (int) $this->difCoin; if ($dCoins < 0) { $dCoins = 0; } $daily->setCoins($dCoins); try { $daily->updateInsertToDatabase(DBUtils::getConnection()); $log->logInfo("leaderboard > add > daily success "); } catch (Exception $exc) { $log->logError("leaderboard > add > error daily : " . $exc->getMessage() . " detail : " . $exc->getTraceAsString()); } $wCoins = $weekly->getCoins() + (int) $this->difCoin; if ($wCoins < 0) { $wCoins = 0; } $weekly->setCoins($wCoins); try { $weekly->updateInsertToDatabase(DBUtils::getConnection()); $log->logInfo("leaderboard > add > weekly success "); } catch (Exception $exc) { $log->logError("leaderboard > add > error weekly : " . $exc->getMessage() . " detail : " . $exc->getTraceAsString()); } $log->logInfo("leaderboard > add > finished "); unset($dCoins); unset($wCoins); unset($user); unset($userId); unset($weekly); unset($daily); } else { $log->logError("leaderboard > add > user found Id is empty"); } } else { $log->logError("leaderboard > add > user Id not found"); } } else { $log->logError("leaderboard > add > user Id is empty "); } }
// this if you also whitelist specific URLs using $valid_url_regex, to avoid // possible XSS vulnerabilities. Defaults to false. // $valid_url_regex - This regex is matched against the url parameter to // ensure that it is valid. This setting only needs to be used if either // $enable_jsonp or $enable_native are enabled. Defaults to '/.*/' which // validates all URLs. // // ############################################################################ error_reporting(E_ERROR | E_PARSE); // Change these configuration options if needed, see above descriptions for info. $enable_jsonp = false; $enable_native = true; $valid_url_regex = '/.*/'; // ############################################################################ require_once "utils.php"; $log = KLogger::instance(dirname(__FILE__) . "/logs/", KLogger::DEBUG); $url = $_GET['url']; if (!$url) { // Passed url not specified. $contents = 'ERROR: url not specified'; $status = array('http_code' => 'ERROR'); } else { if (!preg_match($valid_url_regex, $url)) { // Passed url doesn't match $valid_url_regex. $contents = 'ERROR: invalid url'; $status = array('http_code' => 'ERROR'); } else { $log->logInfo("Current Url: " . $url); $log->logInfo("GETS: " . count($_GET)); if (count($_GET) > 1 && strtolower($_SERVER['REQUEST_METHOD']) == 'get') { $log->logInfo("HERE");
$quantity = $_POST['quantity']; } else { if (isset($_GET['quantity'])) { $quantity = $_GET['quantity']; } } if ($quantity < 1) { $quantity = 1; } if (!UtilFunctions::checkUserSession($userId)) { $result->result = "401 : auth error"; header("HTTP/1.1 401 Unauthorized"); echo json_encode($result); exit(1); } $log = KLogger::instance(KLOGGER_PATH . "apis/", KLogger::DEBUG); $error = false; if (!empty($userId)) { $user = GameUsers::getGameUserById($userId); if (empty($user)) { $error = false; $log->logError(LanguageUtils::getText("LANG_API_USER_EMPTY")); $result->result = LanguageUtils::getText("LANG_API_USER_EMPTY"); } else { $error = true; } } else { $log->logError(LanguageUtils::getText("LANG_API_USER_ID_EMPTY")); $result->result = LanguageUtils::getText("LANG_API_USER_ID_EMPTY"); } if ($error) {
public static function destroyWebsite($websiteId) { global $REX, $I18N; $sql = rex_sql::factory(); $tablePrefix = rex_website::constructTablePrefix($websiteId); $generatedDir = rex_website::constructGeneratedDir($websiteId); $mediaDir = rex_website::constructMediaDir($websiteId); // init logger $logFile = WEBSITE_MANAGER_LOG_DIR; $log = KLogger::instance($logFile, KLogger::INFO); $log->logInfo('======================================== DESTROY WEBSITE WITH ID = ' . $websiteId . ' ========================================'); // just for security reasons if ($websiteId == rex_website::firstId) { $log->logError('Website ID = 1 detected --> Exit!'); echo rex_warning($I18N->msg('website_manager_destroy_website_security_msg')); exit; } // include custom php file with additional userdefined stuff require_once WEBSITE_MANAGER_CUSTOM_DIR . 'destroy_website.before.inc.php'; // extension point rex_register_extension_point('WEBSITE_BEFORE_DESTROYED', array('website_id' => $websiteId, 'sql_object' => $sql, 'table_prefix' => $tablePrefix, 'generated_dir' => $generatedDir, 'media_dir' => $mediaDir, 'log_object' => $log)); // *************************************************************************************************** // database views // *************************************************************************************************** // users rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'user'); // clangs if ($REX['WEBSITE_MANAGER_SETTINGS']['identical_clangs']) { rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'clang'); } // media if ($REX['WEBSITE_MANAGER_SETTINGS']['identical_media']) { rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'file'); rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'file_category'); } // modules if ($REX['WEBSITE_MANAGER_SETTINGS']['identical_modules']) { rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'module'); rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'module_action'); rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'action'); } // templates if ($REX['WEBSITE_MANAGER_SETTINGS']['identical_templates']) { rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . 'template'); } // meta infos if ($REX['WEBSITE_MANAGER_SETTINGS']['identical_meta_infos']) { rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . '62_type'); rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . '62_params'); } // image types if ($REX['WEBSITE_MANAGER_SETTINGS']['identical_image_types']) { rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . '679_types'); rex_website_manager_utils::logQuery($log, $sql, 'DROP VIEW ' . $tablePrefix . '679_type_effects'); } // *************************************************************************************************** // database tables // *************************************************************************************************** $tables = $sql->showTables(1, $tablePrefix); for ($i = 0; $i < count($tables); $i++) { rex_website_manager_utils::logQuery($log, $sql, 'DROP TABLE ' . $tables[$i]); } // *************************************************************************************************** // directories // *************************************************************************************************** $generatedPath = realpath($REX['HTDOCS_PATH'] . 'redaxo/include/') . DIRECTORY_SEPARATOR . $generatedDir; $mediaPath = realpath($REX['HTDOCS_PATH']) . DIRECTORY_SEPARATOR . $mediaDir; rex_website_manager_utils::rrmdir($generatedPath); if (is_dir($generatedPath)) { $log->logError('[REMOVE DIR] ' . $generatedPath); } else { $log->logInfo('[REMOVE DIR] ' . $generatedPath); } if (!$REX['WEBSITE_MANAGER_SETTINGS']['identical_media']) { rex_website_manager_utils::rrmdir($mediaPath); if (is_dir($mediaPath)) { $log->logError('[REMOVE DIR] ' . $mediaPath); } else { $log->logInfo('[REMOVE DIR] ' . $mediaPath); } } // include custom php file with additional userdefined stuff require_once WEBSITE_MANAGER_CUSTOM_DIR . 'destroy_website.after.inc.php'; // extension point rex_register_extension_point('WEBSITE_AFTER_DESTROYED', array('website_id' => $websiteId, 'sql_object' => $sql, 'table_prefix' => $tablePrefix, 'generated_dir' => $generatedDir, 'media_dir' => $mediaDir, 'log_object' => $log)); }