static function checkIfUserExists($name, $id) { if (posix_getpwnam($name)) { $username = $name; $list = lfile("/etc/passwd"); $comment = null; foreach ($list as $l) { $l = trim($l); if (csb($l, "{$username}:")) { $useri = explode(":", $l); $comment = $useri[4]; break; } } //dprint($comment . "Hello\n"); if ($comment === uuser::getUserDescription($id)) { log_error("User {$name} Already Exists. But is of the same domain"); return true; } else { log_error("User {$name} Already Exists. But is of NOT of the same domain"); throw new lxexception("User_Exist", 'web_s_uuser_nname', $name); } } return false; }
function openvpn_resync_gwgroup($gwgroupname = "") { global $config; if (!empty($gwgroupname)) { if (isset($config['openvpn']['openvpn-server'])) { foreach ($config['openvpn']['openvpn-server'] as &$settings) { if ($gwgroupname == $settings['interface']) { log_error("Resyncing OpenVPN for gateway group " . $gwgroupname . " server " . $settings["description"] . "."); openvpn_resync('server', $settings); } } } if (isset($config['openvpn']['openvpn-client'])) { foreach ($config['openvpn']['openvpn-client'] as &$settings) { if ($gwgroupname == $settings['interface']) { log_error("Resyncing OpenVPN for gateway group " . $gwgroupname . " client " . $settings["description"] . "."); openvpn_resync('client', $settings); } } } // Note: no need to resysnc Client Specific (csc) here, as changes to the OpenVPN real interface do not effect these. } else { log_error("openvpn_resync_gwgroup called with null gwgroup parameter."); } }
/** * Render debug trace * */ public function render($e) { Charcoal_ParamTrait::validateException(1, $e); $message = $this->output($e); log_error("debug,error,debugtrace", "debugtrace", $message); return TRUE; }
public function log($level, &$message) { switch ($level) { case LogHelper::LEVEL_DEBUG: log_debug($message); break; case LogHelper::LEVEL_INFO: log_info($message); break; case LogHelper::LEVEL_NOTICE: log_notice($message); break; case LogHelper::LEVEL_WARNING: log_warn($message); break; case LogHelper::LEVEL_ERROR: log_error($message); break; case LogHelper::LEVEL_CRITICAL: log_critical($message); break; case LogHelper::LEVEL_ALERT: log_alert($message); break; case LogHelper::LEVEL_EMERGENCY: log_emergency($message); break; } }
function template_wraperror() { global $context, $settings; log_error('Sorry, [action=' . $context['wraperror_action'] . '] is not supported within this theme.', 'template'); echo ' <img src="', $settings['images_url'], '/404.jpg" alt="" style="cursor: pointer; width: 100%;" onclick="javascript: window.history.back();" />'; }
private function request($data = array()) { $data['api_token'] = $GLOBALS['CONFIG']['translation']['sync']['poeditor_api_key']; $data['id'] = $GLOBALS['CONFIG']['translation']['sync']['poeditor_project_id']; //log_debug($data); $res = downloadData('http://poeditor.com/api/', $data); $res = json_decode($res); if (!$res) { $this->Lasterror = "Error connecting to the POEditor API"; log_error($this->Lasterror); return false; } if ($res->response->code != 200) { $this->Lasterror = "POEditor API returned error: " . $res->response->message; log_error($this->Lasterror, "Details: ", $res); return false; } if (isset($res->details)) { $edited = (isset($res->details->added) ? $res->details->added : 0) + (isset($res->details->updated) ? $res->details->updated : 0); if ($edited == 0) { $this->Lasterror = "POEditor API did not add anything"; log_error($this->Lasterror, "Details:", $res, "Request was:", $data); return false; } } return $res; }
function akismet_create_topic($msg_options, $topic_options, $poster_options) { global $modSettings, $scripturl, $smcFunc, $sourcedir; require $sourcedir . '/Akismet.class.php'; // If the subject is 'akismet-test-123', then mark it as spam (this is a test) if ($msg_options['subject'] == 'akismet-test-123') { $spam = true; } else { // If the API key has been set if (isset($modSettings['akismetAPIKey']) && $modSettings['akismetAPIKey'] != "") { // Set up the Akismet class $akismet = new Akismet($scripturl, $modSettings['akismetAPIKey']); $akismet->setAuthor($poster_options['name']); $akismet->setAuthorEmail($poster_options['email']); //$akismet->setCommentAuthorURL(""); -- URL's not used in SMF. $akismet->setContent($msg_options['body']); if (!empty($topic_options['id'])) { $akismet->setPermalink($scripturl . '?topic=' . $topicOptions['id']); } $akismet->setType('smf-post'); // Now, the moment of truth... Send the post to Akismet $akismet_return = $akismet->isSpam(); // Was the server down? if ($akismet_return === 'conn_error') { // Assume it's not spam. We log an error to the error log later $spam = false; // Log it! if (empty($modSettings['akismetNoLog'])) { log_error(sprintf($txt['akismet_cant_connect2'], $_POST['guestname'], $scripturl . '?topic=' . $topic . (isset($_REQUEST['msg']) ? '.msg' . $_REQUEST['msg'] : ''))); } } elseif ($akismet_return === true) { // Oh, the horror! Someone posted spam to your forum! $spam = true; } else { $spam = false; } } else { // No API key, assume it isn't spam $spam = false; } } if ($spam) { // Mark the message as spam and unapprove the post. Post moderation is a big help here. :) $smcFunc['db_query']('', ' UPDATE {db_prefix}topics SET spam = 1, approved = 0, unapproved_posts = 1 WHERE id_topic = {int:id_topic}', array('id_topic' => $topic_options['id'])); $smcFunc['db_query']('', ' UPDATE {db_prefix}messages SET approved = 0 WHERE id_msg = {int:id_msg}', array('id_msg' => $msg_options['id'])); // Increase spam count $smcFunc['db_query']('', ' UPDATE {db_prefix}settings SET value = value + 1 WHERE variable = {string:akismetCaughtSpam}', array('akismetCaughtSpam' => 'akismetCaughtSpam')); } }
function dbtickets_create($len = 32) { $table = 'Tickets' . intval($len); # As in an instance of flamework that has no access to # its mysql config files and/or the ability to set up # a dedicated DB server for tickets. if ($GLOBALS['cfg']['db_enable_poormans_ticketing']) { # ALTER TABLE tbl_name AUTO_INCREMENT = (n) # how the f**k do you set the offset from the SQL CLI ? $rsp = db_tickets_write("SET @@auto_increment_increment=2"); if (!$rsp['ok']) { log_error("Failed to set auto_increment_increment for {$table}"); return null; } $rsp = db_tickets_write("SET @@auto_increment_offset=1"); if (!$rsp['ok']) { log_error("Failed to set auto_increment_offset for {$table}"); return null; } } $rsp = db_tickets_write("REPLACE INTO {$table} (stub) VALUES ('a')"); if (!$rsp['ok'] || !$rsp['insert_id']) { log_error("Failed to replace into {$table}"); return null; } return $rsp['insert_id']; }
function error_message($userdescription, $description = false) { global $infoerror, $errormessage, $config; $infoerror = true; $errormessage = $userdescription; log_error($description); return; }
function fatal_handler() { $error = error_get_last(); if ($error !== NULL) { log_error($error); error_response(500, "There is some technical problem. Kindly contact the administrator."); } }
function lx_mysql_connect($server, $dbadmin, $dbpass) { $rdb = mysql_connect('localhost', $dbadmin, $dbpass); if (!$rdb) { log_error(mysql_error()); throw new lxException('could_not_connect_to_db_admin', '', ''); } return $rdb; }
function log_error_messages($link, $throwflag = true) { if (mysqli_errno($link)) { dprint(mysqli_error($link)); log_error(mysqli_error($link)); if ($throwflag) { throw new lxException('mysql_error', '', mysqli_error($link)); } } }
/** * Parse a string, and return the result or throw a parser exception * @param string $str * @return MC_Parser_Token */ public function parse($str) { $str = ltrim($str); list($loc, $tok) = $this->parsePart($str, 0); if ($loc != strlen($str)) { log_error("An error occurred: '" . substr($str, $loc) . "' (str={$str})(loc={$loc})", $this); throw new MC_Parser_ParseError('An error occurred: "' . substr($str, $loc) . '"', $str, $loc); } return $tok; }
function purge_log($account_id) { $where = $this->test_account_id($account_id); $this->db->query("delete from phpgw_log {$where}", __LINE__, __FILE__); if (isset($this->db->Errno) && $this->db->Errno) { log_error(array('text' => 'Failed to delete log records from database using where clause of %1. DB errno %2: message %3', 'p1' => $where, 'p2' => $this->db->Errno, 'p3' => $this->db->Error, 'file' => __FILE__, 'line' => __LINE__)); return false; } return true; }
function lx_mysql_connect($server, $dbadmin, $dbpass) { // TODO: REPLACE MYSQL_CONNECT OR REMOVE FUNCTION $rdb = mysqli_connect('localhost', $dbadmin, $dbpass); if (!$rdb) { log_error(mysqli_error($rdb)); throw new lxException('could_not_connect_to_db_admin', '', ''); } return $rdb; }
function verify_test_admin() { global $app_cde; global $app_url_path; global $user; verify_logged_in(); if ($user->getRole($app_cde) == NULL) { log_error("Permission exception in verify_admin. User id:" . $user->usr_id); display_user_message("Permission denied. You are not an administrator.", '/' . $app_url_path . '/index.php'); exit; } }
protected function autoloadLibraries() { assert(array_key_exists('autoload', $this->spockzConfig) && is_array($this->spockzConfig['autoload'])); foreach ($this->spockzConfig['autoload'] as $libraryName) { $libraryVarName = strtolower($libraryName); if (isset($this->{$libraryVarName})) { log_error('warning', sprintf('The property %1$s already exists while auto-loading library %2$s. Ignoring this library.', $libraryVarName, $libraryName)); continue; } // $this->$libraryVarName = new $libraryName(); } }
function testCalculatesExpectedLLocForTryCatchStatement($obj) { try { $obj->foo(); } catch (OutOfBoundsException $e) { error_log($e->getMessage()); } catch (DomainException $e) { log_error($e->getMessage()); } catch (RuntimeException $e) { throw new ErrorException($e->getMessage()); } }
public function __construct(Qdmail $qdmail, Exception $previous = NULL) { $this->stack = $qdmail->errorStatment(); $msg = "Qdmail error:" . print_r($this->stack, true); if ($previous) { parent::__construct(s($msg), $previous); } else { parent::__construct(s($msg)); } foreach ($this->stack as $item) { log_error("mail", $item); } }
function download_delete_object($args) { $obj = $args['obj']; if (!isset($obj['type']) || $obj['type'] != 'download') { return false; } load_modules('glue'); $a = expl('.', $obj['name']); $ret = delete_upload(array('pagename' => $a[0], 'file' => $obj['download-file'], 'max_cnt' => 1)); if ($ret['#error']) { log_error('error', 'upload_delete_object: delete_upload returned ' . quot($ret['#error'])); } }
public function load($debug_mode, $profile_name) { $config_file = "{$profile_name}.profile.ini"; try { // get profile directory path $profile_dir = Charcoal_ResourceLocator::getApplicationFile('config/profile'); // make config file object $config_file = new Charcoal_File($config_file, $profile_dir); // check if profile directory exists if (!$profile_dir->exists()) { if ($debug_mode) { echo "profile directory not exists: [{$profile_dir}]" . eol(); } log_error("debug,config,profile", "profile directory not exists: [{$profile_dir}]"); _throw(new Charcoal_ProfileDirectoryNotFoundException($profile_dir)); } // throw exception when config file is not found if (!$config_file->isFile() || !$config_file->canRead()) { if ($debug_mode) { echo "profile config file not exists or not readable: [{$config_file}]" . eol(); } log_error("debug,config,profile", "profile config file not exists or not readable: [{$config_file}]"); _throw(new Charcoal_ProfileConfigFileNotFoundException($config_file)); } // parse config file // log_debug( "debug,config,profile", "profile", "parsing config file: [$config_file]" ); $config_file = $config_file->getAbsolutePath(); if ($debug_mode) { echo "executing parse_ini_file: [{$config_file}]" . eol(); } $config = @parse_ini_file($config_file, FALSE); if ($config === FALSE) { if ($debug_mode) { echo "profile config file format error: [{$config_file}]" . eol(); } log_error("debug,config,profile", "profile config file format error: [{$config_file}]"); _throw(new Charcoal_ProfileConfigFileFormatException($config_file)); } if ($debug_mode) { echo "executed parse_ini_file: " . ad($config) . eol(); } // log_debug( "profile", "profile", "parse_ini_file: " . print_r($config,TRUE) ); // 設定を保存 parent::mergeArray($config); // log_debug( "debug,config,profile", "profile", "marged profile:" . print_r($config,TRUE) ); } catch (Exception $ex) { // log_debug( "system,error,debug", "catch $e" ); _catch($ex); _throw(new Charcoal_ProfileLoadingException($config_file, $profile_name, $ex)); } }
function log_error_messages($throwflag = true) { if (mysql_errno()) { dprint(mysql_error()); if (mysql_errno() === 1007 && csa($this->main->dbname, "_")) { log_message("Mysql Db {$this->main->dbname} already exists. and also has an underscore... Will treat this as the main db.."); log_error(mysql_error()); return true; } if ($throwflag) { throw new lxException('mysql_error', '', mysql_error()); } } }
function __construct($id = '') { global $DB, $Domains; if (!empty($id)) { $this->id = $id; $result = $DB->make_select('Domains', '*', '`DomainID`=' . $this->id); if (!($row = $DB->row($result))) { log_error("DomainID {$this->id} not found", __FILE__, __LINE__); pdata("DomainID {$this->id} not found\n"); } $this->load($row); $Domains[$id] = $this; } }
function ip_to_mac($addr) { $cmd = '/usr/sbin/arp -n ' . $addr; $ret = false; exec($cmd, $out, $ret); if ($ret) { log_error('The command `' . $cmd . '\' failed to execute'); } else { $mac = explode(' ', $out[0]); if (isset($mac[3])) { $ret = $mac[3]; } } return $ret; }
function __construct($id = '') { global $DB, $Companys; if ($id != null) { $this->id = $id; $result = $DB->make_select('Companys', '*', '`CompanyID`=' . $this->id); $row = $DB->row($result); if (!$row) { log_error("Company ID {$this->id} not found", __FILE__, __LINE__); pdata("Company ID {$this->id} not found\n"); } $this->load($row); $Companys[$id] = $this; } else { } }
function GetSqlConnection() { global $config; static $conn = null; if (!is_null($conn)) { //echo "Repeat Connection<br>"; return $conn; } //echo "New Connection<br>"; $conn = new mysqli($config["db"]["host"], $config["db"]["username"], $config["db"]["password"], $config["db"]["dbname"]); if ($conn->connect_error) { log_error("databaselib.php->GetSqlConnection", array("Database Connection failed.", $conn->connect_error)); die("Database Connection failed: " . $conn->connect_error); } return $conn; }
function getUsernameData($id) { global $mysqli; $sql = "SELECT userName FROM bs_users WHERE userId = ?"; try { if ($stmt = $mysqli->prepare($sql)) { $stmt->bind_param("i", $id); return returnJson($stmt); $stmt->close(); $mysqli->close(); } } catch (Exception $e) { log_error($e, $sql, null); return false; } }
function __construct($id = 0) { global $DB, $Payments; if (!empty($id)) { $this->id = $id; $result = $DB->make_select('Payments', '*', '`PaymentID`=' . $this->id); $row = $DB->row($result); if (!$row) { log_error("Payment ID {$this->id} not found", __FILE__, __LINE__); pdata("Payment ID {$this->id} not found\n"); } $this->load($row); $Payments[$id] = $this; } else { $this->id = 0; } }
function mms_save(&$mms) { // save MMS in database $sql = "\n\t\tINSERT INTO " . TABLE_MMS . " \n\t\t(\n\t\t\t`from`, \n\t\t\t`to`, \n\t\t\t`subject`, \n\t\t\t`content_type`\n\t\t) VALUES (\n\t\t\t'" . mysql_escape_string($mms->FROM) . "',\n\t\t\t'" . mysql_escape_string($mms->TO) . "',\n\t\t\t'" . mysql_escape_string($mms->SUBJECT) . "',\n\t\t\t'" . mysql_escape_string($mms->CONTENTTYPE) . "'\n\t\t)\n\t"; //echo $sql; if (!mysql_query($sql)) { log_error('Database error: Could not insert MMS data into database. MySQL: ' . mysql_error()); } $mmsid = mysql_insert_id(); // loop thru parts and save them in database foreach ($mms->PARTS as $part) { $result = mysql_query("INSERT INTO " . TABLE_PARTS . " (mmsid, datalen, content_type, data) VALUES ('{$mmsid}', '" . $part->DATALEN . "', '" . $part->CONTENTTYPE . "', '" . mysql_escape_string($part->DATA) . "')"); if (!$result) { log_error('Database error: Could not insert part data into database. MySQL: ' . mysql_error()); } } }
/** * Dispatch an error page * * @param Exception the throw exception * @param integer $error_type error type to display */ function dispatch_error($exception, $error_type = 501) { if (!production_environment()) { throw $exception; } $error_output = RA_PUBLIC_PATH . "/{$error_type}.html"; if (file_exists($error_output)) { $content = file_get_contents($error_output); header("Content-Type: text/html"); header("Content-Length: " . strlen($content)); echo $content; log_error("error_{$error_type}", $exception->__toString()); die; } else { throw $exception; } }