public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Log::create([]); } }
/** * Add a log handler. * Works as a fluent interface. * * @param mixed $type Error number (int) or Exception class name. * @param Q\Logger $log May also be a DSN string. * @param More logs can be specified as additional arguments. * @return ErrorHandler_Log */ public function setLog($type, $log) { if (is_string($type)) { $type = self::errnoForType($type); } $logs = array(); $logs_dsn = func_get_args(); array_shift($logs_dsn); foreach ($logs_dsn as $log_dsn) { try { $logs[] = Log::create($log_dsn); } catch (Exception $e) { trigger_error("Failed to create Log '{$log_dsn}'.\n" . (string) $e, E_USER_WARNING); } } // Set logs for specific error code(s) or exception if (is_int($type)) { for ($i = 1; $i <= 4096; $i = $i << 1) { if ($i & $type) { $this->addLogForType($type, $log); } } } else { $this->addLogForType($type, $log); } return $this; }
public static function add($uid, $oid, $info) { $Log = new Log(); $Log->uid = $uid; $Log->oid = $oid; $Log->info = $info; $Log->addtime = time(); if ($Log->create()) { return true; } $Log->outputErrors($Log); return false; }
<?php require_once "../initialize.php"; $id = $_GET['id']; $object = Group::get_by_id($id); GroupUser::delete_all_by_sectionid($object->id); $object->delete(); $log = new Log($session->user_id, $clientip, "WEB", "DELETED CLUB: " . $object->id); $log->create(); echo "success";
/** * @param $data * * @throws Exception */ protected static function _save_log($data) { $log = new Log(); $log->create($data); $log->save(); $log->clear(); }
/** * Creates instance of App class and initialize the application * * @param array $params initialization parameters * @return void * @static */ public static function create(array $params = null) { self::$app_mode = self::MODE_DEVELOPMENT; if (is_null(self::$instance)) { self::$instance = new self(); } // setting up autoloader spl_autoload_register(array('App', 'autoload')); try { // setup config Config::create(isset($params['config']) ? $params['config'] : null); Config::setVar($params); // application mode self::setMode(Config::getVar('mode', self::MODE_DEVELOPMENT)); // our error handler if (!self::isDevMode()) { set_error_handler(array('App', 'handleErrors')); } // language specific params if (function_exists('mb_internal_encoding')) { mb_internal_encoding(Config::getVar('app_encoding', 'UTF-8')); } if (function_exists('date_default_timezone_set')) { date_default_timezone_set(Config::getVar('app_timezone', 'UTC')); } setlocale(LC_CTYPE, Config::getVar('app_locale', 'en_US.UTF-8')); // creating base objects Log::create(); Request::create(); // saving application params self::$params = $params; // unregister globals if (ini_get('register_globals')) { self::unregisterGlobals(array('_POST', '_GET', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES')); ini_set('register_globals', false); } } catch (Exception $e) { self::$instance->handleDefaultException($e); } }
public static function getRegistrationResult($idRegistration) { $app = \Slim\Slim::getInstance(); try { $scormcloudorigin = ScormEngineUtilities::getCanonicalOriginString("IgnitorLabs", "Ignitor Portal", "Version 2.0"); $ScormService = new ScormEngineService(ScormCloudAPIController::$scromCloudUrl, ScormCloudAPIController::$scromCloudAppId, ScormCloudAPIController::$scormCloudSecretKey, ScormCloudAPIController::$scormcloudorigin, null, ScormCloudAPIController::$scromCloudMgmtAppId, ScormCloudAPIController::$scormCloudMgmtSecretKey); $registrationService = $ScormService->getRegistrationService(); if ($registrationService->Exists($idRegistration)) { $regResult = $registrationService->GetRegistrationResult($idRegistration, 2, 1); $json_result = json_encode(simplexml_load_string($regResult), JSON_PRETTY_PRINT); $data = array("action" => "get", "type" => "scorm-cloud", "source" => "api", "source_version" => "1.0", "description" => $json_result, "ip" => $_SERVER['REMOTE_ADDR'], "browser_type" => $_SERVER['HTTP_USER_AGENT'], "referral" => $_SERVER['HTTP_REFERER'], "auth_token" => $app->request->headers->get('X_Authorization')); $log = Log::create($data); $log->save(); $app->redirect(ScormCloudAPIController::$websiteLink . "/library"); // return "<html><head><script type=\"text/javascript\">window.location=\"" . ScormCloudAPIController::$websiteLink . "/library\"</script></head><body></body></html>"; } else { return json_encode("failure"); } } catch (Exception $e) { $app->halt("400", json_encode($e->getMessage())); return json_encode("failure"); } }
/** * Add any number of log handlers. * (fluent interface) * * @param mixed $log Logger, dsn (string) or a set of log handlers as array * @param More log handlers may be specified as additional arguments * @return Log_Container */ public function add($log) { if (func_num_args() > 1) { $log = func_get_args(); } if (is_string($log)) { try { $log = Log::create($log); } catch (\Exception $e) { trigger_error("Creation of log handler failed. " . $e->getMessage(), E_USER_WARNING); return $this; } } if (is_array($log)) { foreach ($log as $curlog) { $this->add($curlog); } return $this; } if (!$log instanceof Logger) { trigger_error("Can't add log handler: value is not a " . __NAMESPACE__ . "::Logger, DSN string or array.", E_USER_WARNING); return $this; } $this->logs[] = $log; return $this; }
public function formObject() { $this->data->Log = Log::create($this->data->id)->getData(); $this->render(); }