function show_debug() { global $mypbx, $debug, $phone_data, $data_credit; if (is_array($phone_data['number'])) { $k = array_keys($phone_data['number']); $data_credit = $phone_data[$k[0]]; } if (function_exists(debug_log) && $debug) { if (count($debug) < 200) { $debug = array_reverse($debug); foreach ($debug as $key => $log) { if ($log['level'] == 'd' && ($mypbx['logging'] == 'debug' || $data_credit['debugphone'] == 'd' && $data_credit['phoneid'] == true)) { //echo $log['file']."-".$log['status']."-".$log['log']."<br>"; debug_log($log['log'], $log['status'], $log['file']); } elseif ($log['level'] == 'v' && ($mypbx['logging'] == 'debug' || $mypbx['logging'] == 'verbose' || $data_credit['debugphone'] == 'v' && $data_credit['phoneid'] == true || $data_credit['debugphone'] == 'd' && $data_credit['phoneid'] == true)) { //echo $log['file']."-".$log['status']."-".$log['log']."<br>"; debug_log($log['log'], $log['status'], $log['file']); } elseif ($log['level'] == 'm' && ($mypbx['logging'] == 'minimal' || $mypbx['logging'] == 'verbose' || $mypbx['logging'] == 'debug' || $data_credit['debugphone'] == 'm' && $data_credit['phoneid'] == true || $data_credit['debugphone'] == 'v' && $data_credit['phoneid'] == true || $data_credit['debugphone'] == 'd' && $data_credit['phoneid'] == true)) { debug_log($log['log'], $log['status'], $log['file']); } elseif ($log['level'] == '' && ($mypbx['logging'] == 'minimal' || $mypbx['logging'] == 'verbose' || $mypbx['logging'] == 'debug' || $data_credit['debugphone'] == 'm' && $data_credit['phoneid'] == true || $data_credit['debugphone'] == 'v' && $data_credit['phoneid'] == true || $data_credit['debugphone'] == 'd' && $data_credit['phoneid'] == true)) { //echo $log['file']."-".$log['status']."-".$log['log']."<br>"; debug_log($log['log'], $log['status'], $log['file']); } } } else { debug_log("Count of log is to high: " . count($debug), 'problem', __FILE__ . ":" . __LINE__); } } }
/** * Check if custom session timeout has been reached for server $ldapserver. * If it has: * - automatically log out user by calling $ldapserver->unsetLoginDN() * - if $server_id is equal to right frame $server_id, load timeout.php page in the right frame * - return true * * @param object $ldapserver The LDAPServer object of the server which the user has logged in. * @return bool true on success, false on failure. */ function session_timed_out($ldapserver) { if (DEBUG_ENABLED) { debug_log('session_timed_out(): Entered with (%s)', 1, $ldapserver->server_id); } # If session hasn't expired yet if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) { # If $session_timeout not defined, use (session_cache_expire() - 1) if (!isset($ldapserver->session_timeout)) { $session_timeout = session_cache_expire() - 1; } else { $session_timeout = $ldapserver->session_timeout; } # Get the $last_activity and $rightframe_server_id value $last_activity = $_SESSION['activity']['server'][$ldapserver->server_id]; # If diff between current time and last activity greater than $session_timeout, log out user if (time() - $last_activity > $session_timeout * 60) { if (in_array($ldapserver->auth_type, array('cookie', 'session'))) { syslog_notice('Logout for ' . $ldapserver->getLoggedInDN()); $ldapserver->unsetLoginDN() or pla_error(_('Could not logout.')); } return true; } else { return false; } } }
public function addValue($new_val, $i = -1) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 5, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $this->addOption($new_val, $i); }
function register_email($account) { global $_url, $MMORPG_Name, $MMORPG_Description; //----------------------------------------------- //DECLARE LES VARIABLES //----------------------------------------------- $sujet = "{$MMORPG_Name} - Validation inscription"; $destinataire = $account['Account_Email']; //'*****@*****.**'; $url_valid = get_link('Register', 'User', array('Valid' => 'Activer', 'Account_Key' => $account['Account_Key'], 'Account_Email' => $account['Account_Email'])); $message_texte = 'Bonjour,' . "\n\n" . 'utilisier ce lien dans votre navigateur pour valider votre inscription' . "\n\n" . $url_valid; $message_html = '<html> <head> <title>' . $MMORPG_Name . ' - valider votre inscription</title> </head> <body> ' . $MMORPG_Description . '<hr/> Vous venez d\'effectuer l\'inscription sur le site <a href="' . $_url . '">' . $MMORPG_Name . '</a> .<br/><br/> Pour valider votre inscription, cliquez sur ce bouton : <form method="post" action="' . get_link('Register', 'User') . '"> <input type="hidden" name="Account_Key" value="' . $account['Account_Key'] . '"/> <input type="hidden" name="Account_Email" value="' . $account['Account_Email'] . '"/> <input type="submit" name="Valid" value="Activer"/> </form> Ou sur <a href="' . $url_valid . '">ce lien</a> </body> </html>'; debug_log($message_html, false); send_email($account['Account_Email'], $sujet, $message_texte, $message_html); }
protected function download(Request $request, $prefix, $attachment = false) { $path = $request->path(); // trim prefix if (starts_with($path, $prefix)) { $path = substr($path, strlen($prefix)); } debug_log('File Download[File Path]', $path); // make absolute file path $path = wordpress_path($path); // ERROR: file not found if (!is_file($path)) { debug_log('File Download: [Abort]: not found'); abort(404); } $extension = pathinfo($path, PATHINFO_EXTENSION); // ERROR: file extension is .php if ($extension == 'php') { debug_log('File Download: [Abort]: .php'); abort(404); } debug_log('File Download[Content Type]', $this->getMimeType($path, $extension)); $headers = ['Content-Type' => $this->getMimeType($path, $extension)]; if ($attachment === false) { return response()->make(file_get_contents($path), 200, $headers); } return response()->download($path, 200, $headers); }
function exception_error_handler($errno, $errstr, $errfile, $errline) { if (function_exists("debug_log")) { debug_log("Error {$errno} : {$errstr} - {$errfile} @ {$errline}"); } throw new ErrorException($errstr, 0, $errno, $errfile, $errline); }
function login() { global $secteur, $page, $_path, $newsAmodifier, $array_adm; if ($page == 'login') { //Si l'id passé en paramètre dans l'url n'existe pas, c'est que le visiteur a été amenené ici par hasard if (!request_confirm('admin-login')) { //Donc on redirige vers index.php header('location:' . getenv('HTTP_REFERER')); //Puis on stoppe l'exécution du script exit; } debug_log('page login'); // si on s'identifie if (request_confirm('admin-login')) { debug_log('form login'); $login = request_post('pseudo'); $pass = request_post('password'); if (array_key_exists($login, $array_adm)) { debug_log('exists login' . "test({$pass} == " . $array_adm[$login] . ")"); if ($pass == $array_adm[$login]) { debug_log('pass login'); $_SESSION['admin'] = true; $_SESSION['user'] = $login; } else { $_SESSION['error'] = "Mot de passe erroné."; } } else { $_SESSION['error'] = "Cet accès n'existe pas."; } header('location:' . getenv('HTTP_REFERER')); } } }
public function nameavailableAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); debug_log('[DatasetsController::nameavailableAction]: ' . $_GET["n"]); if ($this->session->userid === null || isset($_GET["n"]) === false) { $this->getResponse()->clearAllHeaders(); $this->getResponse()->setRawHeader("HTTP/1.0 403 Forbidden"); $this->getResponse()->setHeader("Status", "403 Forbidden"); return; } $name = $this->_getParam("n"); $id = $this->_getParam("id"); if (is_numeric($id) && intval($id) <= 0) { $id = 0; } $res = Datasets::nameAvailability($name, $id); header('Content-type: text/xml'); if ($res === true) { echo "<response>OK</response>"; } else { echo "<response error='" . htmlentities("The given name is already used by another dataset.") . "' >"; echo "<search>"; echo htmlentities($name); echo "</search>"; foreach ($res as $k => $v) { echo "<" . $k . ">"; echo htmlentities($v); echo "</" . $k . ">"; } echo "</response>"; } }
/** * Report or log an exception. * * This is a great spot to send exceptions to Sentry, Bugsnag, etc. * * @param \Exception $e * @return void */ public function report(Exception $e) { if ($e instanceof MethodNotAllowedHttpException) { $request = app('request'); debug_log(get_class($e), $request->method() . ' ' . $request->fullUrl()); } return parent::report($e); }
public function loadClass($base_path, $relative_class_name) { $path = $base_path . '/' . str_replace('\\', '/', $relative_class_name) . '.php'; debug_log('try include', $path); if (file_exists($path)) { require_once $path; } }
function debugFlag($message, $tag = null) { global $DEBUG_FLAG_TAG; if (!isset($DEBUG_FLAG_TAG)) { $DEBUG_FLAG_TAG = isset($tag) ? $tag : time(); } debug_log(getToolNameForConsole() . " {$DEBUG_FLAG_TAG} {$message}"); }
function response_json($value) { $response = raw_json_encode($value); debug_log("Response: " . $response); header('Content-Type: application/json'); // 古いIEがおかしいMIMEタイプ判定をしてXSSの原因になる問題を避けるための呪符 header('X-Content-Type-Options: nosniff'); echo $response; }
/** * Helper function to log formatted messages to log. In case of * DEBUG or INFO type the logging occurs only for development * instances of the application. * * @param string $message The message to log * @param string $type Type of logging. EG DEBUG, INFO, ERROR, WARN */ private static function log($message, $type = 'ERROR') { $txt = '[EmailService::' . strtoupper($type) . ']: ' . $message; if ($type === 'DEBUG' || $type === 'INFO') { debug_log($txt); } else { error_log('[EmailService::' . strtoupper($type) . ']: ' . $message); } }
function register_email($account) { global $MMORPG_Name; debug_log("register-member-end => send mail init"); $sujet = "{$MMORPG_Name} - Validation inscription"; $destinataire = $account['Account_Email']; //'*****@*****.**'; list($message_texte, $message_html) = content_valid_mail($account); send_email($account['Account_Email'], $sujet, $message_texte, $message_html); }
function addObjectProperty($name, $value = NULL) { debug_log("%s::%s(%s, %s)", __CLASS__, __FUNCTION__, $name, $value); $element = $this->createObjectPropertyElement($name); $this->payload->appendChild($element); if ($value instanceof DomNode) { $element->appendChild($value); } elseif (isset($value)) { $element->appendChild($this->createTextNode($value)); } return $element; }
/** * @错误记录。方便调试 */ private function logWxTemple($data) { $log = ' #=============================================================================================================== #DEBUG-WxTemplate(微信模版消息) start |执行时间:%s (ms) #=============================================================================================================== #请求接口:%s #User-Agent:%s #返回数据(Array): $data=%s; #==================================================debug end====================================================' . "\r\n\r\n"; debug_log($log, $data); }
function get_locals() { global $language_codes, $country_codes; $locale_data = array(); //Get locales from Linux terminal command locale $chain_locales = shell_exec('locale -a'); debug_log("<pre>{$chain_locales}<pre>"); $locales = explode("\n", $chain_locales); debug_log(print_r($locales, 1)); foreach ($locales as $c => $l) { if (strlen($l)) { $_dot = strpos($l, '.'); if ($_dot !== false) { $parts = explode('.', $l); $lc = $parts[0]; } else { $lc = $l; $parts[1] = ""; } $_usc = strpos($lc, '_'); if ($_usc !== false) { list($lcode, $ccode) = explode('_', $lc); if (isset($lcode)) { $lcode = strtolower($lcode); if (isset($language_codes[$lcode])) { $language = $language_codes[$lcode]; } if (isset($country_codes[$ccode])) { $country = $country_codes[$ccode]; } if (isset($language) and isset($country) and strlen($language) and strlen($country)) { $locale_data[$l] = "{$language} - {$country}"; if (isset($parts[1]) && $parts[1] != "") { $locale_data[$l] .= "- {$parts[1]}"; } } } } } } return $locale_data; }
public function createUser($email, $password, $extra = '') { debug_log("Creating new user " . __FILE__ . "::" . __LINE__); //This is a new user and member $username = $email; $password = $password; $duplicateEmail = email_exists($email); if (!$duplicateEmail) { $id = wp_create_user($username, $password, $email); //include other things if (!empty($extra) && is_int($id)) { $update_array = array('ID' => $id); $update_array = array_merge($update_array, $extra); wp_update_user($update_array); } return $id; } else { //Return email already exists return new WP_Error('existing_user_email', __('Sorry, that email address is already used!')); } }
function get_months($year = '2000', $month = '01') { $_m = str_pad($month, 2, "0", STR_PAD_LEFT); $_y = str_pad($year, 4, "0", STR_PAD_LEFT); debug_log("period=>({$_y},{$_m})=>" . $_y . "-" . $_m . "-01"); $period = new DateTime($_y . "-" . $_m . "-01"); //strtotime($_y."-".$_m."-01");// $t = intval($period->format('t')); //intval(date('t',$period));// debug_log("period=>({$_y},{$_m})=>" . $t); $r = array(); for ($i = 1; $i <= $t; $i++) { $_i = str_pad($i, 2, "0", STR_PAD_LEFT); $r[$_i] = str_replace(0, 7, intval($period->format('w'))); //str_replace(0,7,intval(date('w',$period)));// $period->modify('+ 1 day'); //add(new DateInterval('P1D'));//+=(24*60*60);// } unset($period); return $r; }
public function refresh($format = '', $userid = '', $xmldetailed = false) { global $application; $limit = ''; if (isset($this->limit)) { $limit .= ' LIMIT ' . $this->limit; } if (isset($this->offset)) { $limit .= ' OFFSET ' . $this->offset; } $having = ''; if (!$this->viewModerated) { $having = 'HAVING ((app).moderated = FALSE) AND ((app).deleted = FALSE) '; } $where = $this->__filterItems(); if ($where != '') { $where = ' WHERE ' . $where; } $application->getBootstrap()->getResource('db')->setFetchMode(Zend_Db::FETCH_OBJ); if ($format === 'xml') { debug_log('SELECT xmlelement(name "application:relatedapp", xmlattributes(\'http://appdb.egi.eu/api/0.2/application\' as "xmlns:application", MIN(rank) as rank,' . $this->_appid . ' as parentID, (SELECT name FROM applications WHERE id = ' . $this->_appid . ') as parentName),app_to_xml((app).id)) as relatedapp FROM related_apps(' . $this->_appid . ') INNER JOIN applications ON applications.id = (app).id' . $where . ' GROUP BY app ' . $having . 'ORDER BY MIN(rank),(app).name' . $limit); $res = $application->getBootstrap()->getResource('db')->query('SELECT xmlelement(name "application:relatedapp", xmlattributes(\'http://appdb.egi.eu/api/0.2/application\' as "xmlns:application", MIN(rank) as rank,' . $this->_appid . ' as parentID, (SELECT name FROM applications WHERE id = ' . $this->_appid . ') as parentName),app_to_xml((app).id)) as relatedapp FROM related_apps(' . $this->_appid . ') INNER JOIN applications ON applications.id = (app).id' . $where . ' GROUP BY app ' . $having . 'ORDER BY MIN(rank),(app).name' . $limit)->fetchAll(); } else { $res = $application->getBootstrap()->getResource('db')->query('SELECT DISTINCT (app).*, MIN(rank) AS rank FROM related_apps(' . $this->_appid . ') GROUP BY app ' . $having . 'ORDER BY rank,name' . $limit . ';')->fetchAll(); } $a = array(); foreach ($res as $row) { if ($format == 'xml') { $app = $row->relatedapp; } else { $app = new Default_Model_RelatedApplication(); $this->getMapper()->populate($app, $row); $app->rank = $row->rank; } $a[] = $app; } $this->_items = $a; return $this; }
/** * Sets the message edition mode (stored in session) * * @param boolean $message_edit * @return boolean */ public static function setMessageEditionMode($message_edit = null) { if (verif_access("Admin", true)) { if (!is_null($message_edit)) { $_SESSION['Account_Data']['Message_Mode'] = $message_edit; } elseif (isset($_SESSION['Account_Data']['Message_Mode'])) { if ($_SESSION['Account_Data']['Message_Mode'] === true) { $_SESSION['Account_Data']['Message_Mode'] = false; } else { if ($_SESSION['Account_Data']['Message_Mode'] === false) { $_SESSION['Account_Data']['Message_Mode'] = true; } } $message_edit = $_SESSION['Account_Data']['Message_Mode']; } else { $_SESSION['Account_Data']['Message_Mode'] = true; } } else { $_SESSION['Account_Data']['Message_Mode'] = false; } debug_log("mode " . ($message_edit ? "activé" : "desactivé")); header('location:' . getenv('HTTP_REFERER')); }
/** * The only function which should be called by a user * * @see common.php * @see PLA_SESSION_ID * @return bool Returns true if the session was started the first time */ function pla_session_start() { if (DEBUG_ENABLED) { debug_log('pla_session_start(): Entered with ()', 1); } // If session.auto_start is on in the server's PHP configuration (php.ini), then // we will have problems loading our schema cache since the session will have started // prior to loading the SchemaItem (and descedants) class. Destroy the auto-started // session to prevent this problem. if (ini_get('session.auto_start')) { @session_destroy(); } // Do we already have a session? if (@session_id()) { return; } @session_name(PLA_SESSION_ID); @session_start(); // Do we have a valid session? $is_initialized = is_array($_SESSION) && array_key_exists(pla_session_id_init, $_SESSION); if (!$is_initialized) { if (pla_session_id_paranoid) { ini_set('session.use_trans_sid', 0); @session_destroy(); @session_id(pla_session_get_id()); @session_start(); ini_set('session.use_trans_sid', 1); } $_SESSION[pla_session_id_init] = true; } @header("Cache-control: private"); // IE 6 Fix if (pla_session_id_paranoid && !pla_session_verify_id()) { pla_error("Session inconsistent or session timeout"); } return !$is_initialized ? true : false; }
$debug['aastra/getprov'][] = " (get_provision) MAC={$mac}, {$model}" . $phone_data['callerid'] . " {$add}"; } else { global $debug; $debug['aastra/getprov'][] = " (get_provision) is not supported from phone provisioned=" . $phone_data['provisioned']; } } else { global $debug; $debug['aastra/prov'][] = "(provision failed) mac=" . strtoupper($mac) . " && Timediff:" . filemtime("/tmp/phone-" . strtoupper($mac)); } } } break; if (function_exists(debug_log) && $debug) { foreach ($debug as $k1 => $deb) { foreach ($deb as $k2 => $detail) { debug_log('[' . $k1 . '][' . $k2 . '] ' . $detail . ']', $k1); } } } } function Aastra_decode_HTTP_header() { if ($_REQUEST['user_agent'] != false) { $user_agent = $_REQUEST['user_agent']; } else { $user_agent = $_SERVER["HTTP_USER_AGENT"]; } if (stristr($user_agent, "Aastra")) { $value = preg_split("/ MAC:/", $user_agent); $fin = preg_split("/ /", $value[1]); $value[1] = preg_replace("/\\-/", "", $fin[0]);
public function syncStatus($site = null) { error_log("OCCI ARGO status sync started"); db()->beginTransaction(); db()->query("ALTER TABLE gocdb.va_providers DISABLE TRIGGER tr_gocdb_va_providers_99_refresh_permissions;"); db()->setFetchMode(Zend_Db::FETCH_NUM); if (isset($site)) { $vas = db()->query("SELECT pkey, sitename, hostname, service_status, service_status_date FROM gocdb.va_providers WHERE sitename = ? ORDER BY sitename, hostname", array($site))->fetchAll(); } else { $vas = db()->query("SELECT pkey, sitename, hostname, service_status, service_status_date FROM gocdb.va_providers ORDER BY sitename, hostname")->fetchAll(); } if (is_array($vas) && count($vas) > 0) { foreach ($vas as $va) { $id = $va[0]; $sitename = $va[1]; $endpoint = $va[2]; $status = $va[3]; $lastChecked = $va[4]; if (is_null($lastChecked)) { $wfrom = "2016-01-01T00:00:00Z"; } else { // create datetime object from SQL server in local timezone $tmptime1 = strtotime($lastChecked); // format datetime object to string in UTC date_default_timezone_set("UTC"); $wfrom = date("Y-m-d\\TH:i:s\\Z", $tmptime1); // restore local timezone date_default_timezone_set($this->_timezone); } $wto = gmdate("Y-m-d\\TH:i:s\\Z"); $xml = $this->_callAPI("/status/" . $this->_reportType . "/SITES/{$sitename}/services/" . $this->_serviceType . "/endpoints/{$endpoint}?start_time={$wfrom}&end_time={$wto}"); if ($xml === false) { error_log("connection error in Argo::syncStatus for site {$sitename} and endpoint {$endpoint}: " . var_export(curl_error($ch), true)); db()->query("ALTER TABLE gocdb.va_providers ENABLE TRIGGER tr_gocdb_va_providers_99_refresh_permissions;"); error_log("OCCI ARGO status sync failed"); db()->rollBack(); return; } try { $xml = new SimpleXMLElement($xml); } catch (Exception $e) { error_log("error reading OCCI status XML output in Argo::syncStatus for site {$sitename} and endpoint {$endpoint}: {$e}"); continue; } $statuses = $xml->xpath("//status"); if (is_array($statuses) && count($statuses) > 0) { $T = strtotime($wfrom); $V = ""; foreach ($statuses as $status) { $timestamp = strtotime($status->attributes()->timestamp); if ($timestamp >= $T) { $value = strval($status->attributes()->value); if (strtolower(trim($value)) != "" && strtolower(trim($value)) != "missing") { $T = $timestamp; $V = $value; } } } if ($V != "") { try { debug_log("SITE: {$sitename} ENDPOINT_ID: {$id} STATE: {$V} TIMESTAMP: {$T}"); db()->query("UPDATE gocdb.va_providers SET service_status = ?, service_status_date = ? WHERE pkey = ?", array($V, date("Y-m-d H:i:s", $T), $id))->fetchAll(); } catch (Exception $e) { error_log("error updating OCCI ARGO status in DB for site {$sitename} and endpoint {$endpoint}: {$e}"); } } } } } db()->query("ALTER TABLE gocdb.va_providers ENABLE TRIGGER tr_gocdb_va_providers_99_refresh_permissions;"); db()->query("REFRESH MATERIALIZED VIEW CONCURRENTLY va_providers;"); db()->commit(); error_log("OCCI ARGO status sync ended"); }
function bfl_lock() { global $action; $bfl_file = "/tmp/webide.login.bfl"; $wait = 100000; // Initially wait 0.1s $wait_inc = 100000; // Every time increase interval by 0.1s $wait_add = $wait_inc; $ultimate_limit = 100000000; // Break in after 100s while (file_exists($bfl_file)) { debug_log("{$action} ceka na bfl"); print "Čekam na bfl\n"; usleep($wait); $wait += $wait_add; $wait_add += $wait_inc; if ($wait >= $ultimate_limit) { break; } } exec("touch {$bfl_file}"); }
/** * Takes a shadow* attribute and returns the date as an integer. * * @param array Attribute objects * @param string A shadow attribute name */ private function shadow_date($attribute) { if (DEBUG_ENABLED && (($fargs = func_get_args()) || ($fargs = 'NOARGS'))) { debug_log('Entered (%%)', 129, 0, __FILE__, __LINE__, __METHOD__, $fargs); } $shadowattr = array(); $shadowattr['lastchange'] = $this->template->getAttribute('shadowlastchange'); $shadowattr['max'] = $this->template->getAttribute('shadowmax'); $shadow = array(); $shadow['lastchange'] = $shadowattr['lastchange'] ? $shadowattr['lastchange']->getValue(0) : null; $shadow['max'] = $shadowattr['max'] ? $shadowattr['max']->getValue(0) : null; if ($attribute->getName() == 'shadowlastchange' && $shadow['lastchange']) { $shadow_date = $shadow['lastchange']; } elseif ($attribute->getName() == 'shadowmax' && $shadow['max'] > 0 && $shadow['lastchange']) { $shadow_date = $shadow['lastchange'] + $shadow['max']; } elseif ($attribute->getName() == 'shadowwarning' && $attribute->getValue(0) > 0 && $shadow['lastchange'] && $shadow['max'] && $shadow['max'] > 0) { $shadow_date = $shadow['lastchange'] + $shadow['max'] - $attribute->getValue(0); } elseif ($attribute->getName() == 'shadowinactive' && $attribute->getValue(0) > 0 && $shadow['lastchange'] && $shadow['max'] && $shadow['max'] > 0) { $shadow_date = $shadow['lastchange'] + $shadow['max'] + $attribute->getValue(0); } elseif ($attribute->getName() == 'shadowmin' && $attribute->getValue(0) > 0 && $shadow['lastchange']) { $shadow_date = $shadow['lastchange'] + $attribute->getValue(0); } elseif ($attribute->getName() == 'shadowexpire' && $attribute->getValue(0) > 0) { $shadow_date = $shadowattr->getValue(0); } else { return false; } return $shadow_date * 24 * 3600; }
if ($search_string_len <= 2) { // $sql .= "SUBSTRING(c.surname,1,$search_string_len)=('$search_string') "; $sql .= "c.surname LIKE '{$search_string}%' "; } else { $sql .= "c.surname LIKE '%{$search_string}%' OR c.forenames LIKE '%{$search_string}%' OR "; $sql .= "CONCAT(c.forenames,' ',c.surname) LIKE '%{$search_string}%'"; } $sql .= " ) "; } if ($displayinactive == "false") { $sql .= " AND c.active = 'true' AND s.active = 'true'"; } $sql .= " ORDER BY surname ASC"; // execute query $result = mysql_query($sql); debug_log($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } } if (mysql_num_rows($result) == 0) { echo "<p align='center'>"; if (empty($search_string)) { echo $strNoRecords; } else { printf($strSorryNoRecordsMatchingX, "<em>{$search_string}</em>"); } echo "</p>\n"; } else { echo "<p align='center'>" . sprintf($strDisplayingXcontactMatchingY, mysql_num_rows($result), "<em>{$search_string}</em>") . "</p>"; echo "<table align='center'>\n <tr>\n <th>{$strName}</th>\n <th>{$strSite}</th>\n <th>{$strEmail}</th>\n <th>{$strTelephone}</th>\n <th>{$strFax}</th>\n <th>{$strAction}</th>\n </tr>";
/** * The main "auto_create" function * The function is specific to rules sent to our clients regarding the naming of * their email Subject: * For this reason the plugin is specific but not impossible to adapt * Clients send their email like this: * "Hardware [Productname] Serial number Reference" * or "Software [Softwarename] Version Reference" * or "Warranty [Productname] Serial number Reference" * This helps to simplify the creation, and detection of this function * @author Nico du toit * @return Returns the newly created incidentid to the inbopund script to * continue processing * OR returns nothing and the new update goes to the holding queue as before */ function auto_create_incidents($params) { unset($GLOBALS['plugin_reason']); $incidentid = $params['incidentid']; $contactid = $params['contactid']; $subject = $params['subject']; $decoded = $params['decoded']; $send_email = 1; global $CONFIG, $dbIncidents, $now; debug_log("incident ID : " . $incidentid . " \n Contactid: " . $contactid . "\n" . "Subject : " . $subject); if ($incidentid > 0) { return $incidentid; } if (in_array($contactid, $CONFIG['auto_create_contact_exclude'])) { debug_log("For this client : " . $contactid . " autocreate is forbidden! see the config file"); $GLOBALS['plugin_reason'] = 'Contact BLOCKED'; return; } if ($contactid < 1) { $GLOBALS['plugin_reason'] = 'Contact not in DataBase'; return; } $cc = find_cc_decoded($decoded); if (stristr($cc, $CONFIG['support_email'])) { debug_log("Support was in the copy of the email!!"); $GLOBALS['plugin_reason'] = 'Support in CC of email'; return; } debug_log("Redirecting to function checking for duplicates ... "); //Check if duplicates exists in the incidents DB $create_incident = check_for_duplicates($subject, $contactid); if ($create_incident == "NO") { debug_log("case 0: more than 1 duplicate"); $GLOBALS['plugin_reason'] = 'Possible DUPLICATE'; return; } if ($create_incident != "YES" && $create_incident != "NO") { debug_log("case 1: only 1 duplicate"); debug_log("The duplicate incidentID =: " . $create_incident); return $create_incident; } if ($create_incident == "YES") { debug_log("case 2: No duplicates found"); debug_log("Proceeding to - Auto create"); $ccemail = $cc; $origsubject = mysql_real_escape_string($subject); $subject = strtolower($subject); //Check if any of our keywords exists TODO: Need to make the keywords //configurable in the config file $warranty = preg_match("/warranty|warrantee|waranty|diagnostic/i", $subject); $hard = preg_match("/hardware|hard/i", $subject); $soft = preg_match("/soft|software/i", $subject); if ($warranty == 1 && $hard == 0 && $soft == 0) { $case = 0; debug_log("Match for Warranty in : " . $subject); } elseif ($hard == 1 && $soft == 0 && $warranty == 0) { $case = 1; debug_log("Match for Hardware in : " . $subject); } elseif ($soft == 1 && $hard == 0 && $warranty == 0) { $case = 2; debug_log("Match for Software in : " . $subject); } else { $case = 3; debug_log("NO match found for any keyword in : " . $subject); } switch ($case) { case 0: debug_log("Case type Warranty : "); $product = 9; //Hardware //$software = 41;//Warranty clam $software = find_tags_in_subject($subject); debug_log("The software tag returned is : " . $software); if (!$software || !in_array($software, $CONFIG['auto_create_warranty_include'])) { debug_log("The soft is not in the accepted warranty list or is 0 :"); $software = 41; //if no tags are found use the normal warranty claim } $servicelevel = $CONFIG['default_service_level']; $siteid = contact_siteid($contactid); $sql = "SELECT id FROM `sit_maintenance` WHERE site='{$siteid}' AND product='{$product}' "; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $row = mysql_fetch_row($result); $contrid = $row[0]; //Create the incident based on the info we have $incidentid = ''; $incidentid = create_incident($origsubject, $contactid, $servicelevel, $contrid, $product, $software, $priority = 1, $owner = 0, $status = 1, $productversion = '', $productservicepacks = '', $opened = '', $lastupdated = ''); debug_log("Incident ID created : " . $incidentid); debug_log("CC address(es) found : " . $ccemail); //If we have some cc addresses, then we can update them into the case if ($ccemail) { $sql = "UPDATE `{$dbIncidents}` "; $sql .= "SET ccemail='{$ccemail}', lastupdated='{$now}' WHERE id='{$incidentid}'"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } if (!$result) { debug_log("Update to the incident cc email succesfull!!"); } } if ($incidentid > 0) { // Insert the first SLA update, this indicates the start of an incident $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$sit[2]}', '1', 'show', 'opened','The incident is open and awaiting action.')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } // Insert the first Review update, this indicates the review period of an incident has started $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'reviewmet', '{$now}', '{$sit[2]}', '1', 'hide', 'opened','')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } trigger('TRIGGER_INCIDENT_CREATED', array('incidentid' => $incidentid, 'sendemail' => $send_email)); debug_log("Succesfully created incident: " . $incidentid); //Insert the initial response as we see the first email as the initial response $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$owner}', '1', 'show', 'initialresponse','The Initial Response has been made by the automated tracker email.')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } } //In case we have no incident ID it means the function failed - FALSE returned by function if ($incidentid == FALSE) { debug_log("Incident auto create failed: " . $subject); return; } $send_email = 1; $owner = suggest_reassign_userid($incidentid, $exceptuserid = 0); if ($owner > 0) { //Update owner in incidents $sql = "UPDATE `sit_incidents` SET owner='{$owner}', lastupdated='{$now}' WHERE id='{$incidentid}'"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } trigger('TRIGGER_INCIDENT_ASSIGNED', array('userid' => $owner, 'incidentid' => $incidentid)); // add update $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, nextaction) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'reassigning', '{$now}', '{$owner}', '1', '{$nextaction}')"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } debug_log("Incident re-assigned to: " . $owner); } return $incidentid; case 1: debug_log("Case type Hardware : "); $product = 9; //Hardware product //Try to recover the product name that is in the email subject (only if the sender followed the rules!) $recovprod = trim(recup_prodName($subject, '[', ']')); if ($recovprod) { $prodword = $recovprod; } elseif (!$recovprod) { //$prodword = 'HARDWARE NOT AUTOMATICALLY RECOGNISED'; $prodword = software_name(find_tags_in_subject($subject)); if (!$prodword) { $GLOBALS['plugin_reason'] = 'Hardware [Skill-Product not set]'; return; } } $sql = "SELECT LOWER(id) FROM `sit_software` WHERE name LIKE '%{$prodword}%' "; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $numresults = mysql_num_rows($result); $row = mysql_fetch_row($result); //No match found if ($numresults == 0) { //Set the software to a precreated value in the DB //$software = 53; $GLOBALS['plugin_reason'] = 'Hardware [Skill-Product not set]'; return; } //Multiple matches found, take the first one //TODO: Improve this as it is not that accurate if ($numresults > 0) { $software = $row[0]; } $servicelevel = $CONFIG['default_service_level']; $siteid = contact_siteid($contactid); //Find the hardware contract for this contact $sql = "SELECT id FROM `sit_maintenance` WHERE site='{$siteid}' AND product='{$product}' "; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $row = mysql_fetch_row($result); $contrid = $row[0]; /*TODO: This was not working correctly, but can be fixed i am sure... * The idea is to change the priority according to the product or skill * if ($software == 4||5||6||7||8||13||17||18||37||45||48) { $priority = 3; } else { $priority = 2; } echo "CONTRACT"; echo $contrid; echo "<br>"; //Allthese are created as priority medium - Need still to fix the above //$priority = 2;*/ $incidentid = ''; $incidentid = create_incident($origsubject, $contactid, $servicelevel, $contrid, $product, $software, $priority = 2, $owner = 0, $status = 1, $productversion = '', $productservicepacks = '', $opened = '', $lastupdated = ''); debug_log("Incident ID created : " . $incidentid); debug_log("CC address(es) found : " . $ccemail); //If we have some cc addresses, then we can update them into the case if ($ccemail) { $sql = "UPDATE `{$dbIncidents}` "; $sql .= "SET ccemail='{$ccemail}', lastupdated='{$now}' WHERE id='{$incidentid}'"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } if (!$result) { debug_log("Update to the incident cc email succesfull!!"); } } // If we have an incident id - we can now do the updates if ($incidentid > 0) { // Insert the first SLA update, this indicates the start of an incident $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$sit[2]}', '1', 'show', 'opened','The incident is open and awaiting action.')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } // Insert the first Review update, this indicates the review period of an incident has started $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'reviewmet', '{$now}', '{$sit[2]}', '1', 'hide', 'opened','')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } trigger('TRIGGER_INCIDENT_CREATED', array('incidentid' => $incidentid, 'sendemail' => $send_email)); debug_log("Succesfully created incident: " . $incidentid); //Insert the initial response as we see the first email as the initial response $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$owner}', '1', 'show', 'initialresponse','The Initial Response has been made by the automated tracker email.')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } } //In case we have no incident ID it means the function failed - FALSE returned by function if ($incidentid == FALSE) { debug_log("Incident auto create failed: " . $subject); return; } $send_email = 1; $owner = suggest_reassign_userid($incidentid, $exceptuserid = 0); //update the Db with the suggested user to reassign to if ($owner > 0) { $sql = "UPDATE `sit_incidents` SET owner='{$owner}', lastupdated='{$now}' WHERE id='{$incidentid}'"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } trigger('TRIGGER_INCIDENT_ASSIGNED', array('userid' => $owner, 'incidentid' => $incidentid)); // add update $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, nextaction) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'reassigning', '{$now}', '{$owner}', '1', '{$nextaction}')"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } debug_log("Incident re-assigned to: " . $owner); } return $incidentid; case 2: debug_log("Case type Software : "); $product = 10; //Software product //Try to recover the product name that is in the email subject (only if the sender followed the rules!) $recovprod = trim(recup_prodName($subject, '[', ']')); if ($recovprod) { $prodword = $recovprod; } elseif (!$recovprod) { //$prodword = 'SOFTWARE NOT AUTOMATICALLY RECOGNISED'; $prodword = software_name(find_tags_in_subject($subject)); if (!$prodword) { $GLOBALS['plugin_reason'] = 'Software [Skill-Product not set]'; return; } } $sql = "SELECT LOWER(id) FROM `sit_software` WHERE name LIKE '%{$prodword}%' "; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $numresults = mysql_num_rows($result); $row = mysql_fetch_row($result); //No match found if ($numresults == 0) { //$software = 54; $GLOBALS['plugin_reason'] = 'Software [Skill-Product not set]'; return; } //Multiple matches found, take the first one //TODO: Improve this as it is not that accurate if ($numresults > 0) { $software = $row[0]; } $servicelevel = $CONFIG['default_service_level']; $siteid = contact_siteid($contactid); //Find the software contract for this contact $sql = "SELECT id FROM `sit_maintenance` WHERE site='{$siteid}' AND product='{$product}' "; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $row = mysql_fetch_row($result); $contrid = $row[0]; /*TODO: This was not working correctly, but can be fixed i am sure... * The idea is to change the priority according to the product or skill echo $contrid; echo "<br>"; if ($software == 54||36||38) { $priority = 1; } else { $priority = 2; } //Allthese are created as priority medium - Need still to fix the above //$priority = 2;*/ $incidentid = ''; $incidentid = create_incident($origsubject, $contactid, $servicelevel, $contrid, $product, $software, $priority = 2, $owner = 0, $status = 1, $productversion = '', $productservicepacks = '', $opened = '', $lastupdated = ''); debug_log("Incident ID created : " . $incidentid); debug_log("CC address(es) found : " . $ccemail); //If we have some cc addresses, then we can update them into the case if ($ccemail) { $sql = "UPDATE `{$dbIncidents}` "; $sql .= "SET ccemail='{$ccemail}', lastupdated='{$now}' WHERE id='{$incidentid}'"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } if (!$result) { debug_log("Update to the incident cc email succesfull!!"); } } if ($incidentid > 0) { // Insert the first SLA update, this indicates the start of an incident $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$sit[2]}', '1', 'show', 'opened','The incident is open and awaiting action.')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } // Insert the first Review update, this indicates the review period of an incident has started $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'reviewmet', '{$now}', '{$sit[2]}', '1', 'hide', 'opened','')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } trigger('TRIGGER_INCIDENT_CREATED', array('incidentid' => $incidentid, 'sendemail' => $send_email)); debug_log("Succesfully created incident: " . $incidentid); //Insert the initial response as we see the first email as the initial response $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, customervisibility, sla, bodytext) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'slamet', '{$now}', '{$owner}', '1', 'show', 'initialresponse','The Initial Response has been made by the automated tracker email.')"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } } //In case we have no incident ID it means the function failed - FALSE returned by function if ($incidentid == FALSE) { debug_log("Incident auto create failed: " . $subject); return; } $send_email = 1; $owner = suggest_reassign_userid($incidentid, $exceptuserid = 0); //Update the Db with the suggested owner if ($owner > 0) { $sql = "UPDATE `sit_incidents` SET owner='{$owner}', lastupdated='{$now}' WHERE id='{$incidentid}'"; mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } trigger('TRIGGER_INCIDENT_ASSIGNED', array('userid' => $owner, 'incidentid' => $incidentid)); // add update $sql = "INSERT INTO `sit_updates` (incidentid, userid, type, timestamp, currentowner, currentstatus, nextaction) "; $sql .= "VALUES ('{$incidentid}', '{$sit[2]}', 'reassigning', '{$now}', '{$owner}', '1', '{$nextaction}')"; $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_ERROR); } debug_log("Incident re-assigned to: " . $owner); } return $incidentid; case 3: $GLOBALS['plugin_reason'] = 'INCORRECTLY formatted'; debug_log("There was no reference found for the correct skill in: " . $subject); return; } } }
function uloz_behy() { global $model, $G; $G["behy"] = array(); $model->for_each('process_behy'); #$G["config"]->__set("behy",serialize($G["behy"])); debug_log("ukladám zmeny v zozname behov"); #echo "ukladam udaje\n"; $GLOBALS["vars"]["behy_zmena"] = false; #var_export($G["behy"]); # $G["config"]->save(); }
public static function getNews($request) { $t = $request; if ($t->type == "app-entry") { $t->type = "app"; } $t->filter = str_replace("”", '"', $t->filter); if (trim($t->filter) !== '') { if ($t->type === 'ppl') { $t->filter = FilterParser::normalizeFilter($t->filter, FilterParser::NORM_PPL, $err); $f = FilterParser::getPeople($t->filter); } else { if ($t->type === 'app') { $t->filter = FilterParser::normalizeFilter($t->filter, FilterParser::NORM_APP, $err); $f = FilterParser::getApplications($t->filter); } } } $news = new Default_Model_AggregateNews(); if ($t->length != '') { $news->filter->limit($t->length); } if ($t->offset != '') { $news->filter->offset($t->offset); } $nf = new Default_Model_AggregateNewsFilter(); if (count($t->action) > 0) { if ($t->type == "app" && in_array("update", $t->action) == true) { $t->action[] = "updaterel"; } for ($i = 0; $i < count($t->action); $i += 1) { if (isset($a)) { $a = $a->or($nf->action->equals(trim($t->action[$i]))); } else { $a = $nf->action->equals(trim($t->action[$i])); } } $news->filter = $news->filter->chain($nf, "AND"); } if (trim($t->type) != '') { $nf->subjecttype->equals(trim($t->type)); $news->filter = $news->filter->chain($nf, "AND"); } $nf->timestamp->between(array($t->from, $t->to)); $news->filter = $news->filter->chain($nf, "AND"); if (isset($f)) { if (is_array($f->expr())) { $f->SetExpr("(" . implode(") AND (", $f->expr()) . ")"); } if ($f->expr() != '') { $nf = $nf->chain($f, "AND"); } } $news->filter = $news->filter->chain($nf, "AND"); debug_log($news->filter->expr()); $news->filter->orderBy('timestamp DESC'); $news->refresh(); return $news; }