function entry_exists($line, $attachments, $fn) { if (!file_exists($fn)) { return false; } $file = file_get_contents($fn); return strpos($file, format_line($line, $attachments)) !== false; }
function get_ctab_syscall($info, $size_tab) { $nb = 0; foreach ($info as $k => $v) { if ($nb != $k) { while ($nb < $k) { $nb++; $line .= format_line(0, "NULL", "NULL", "NULL"); } } if ($nb < $size_tab) { $line .= format_line(count($v["proto"]), $v["name"], $v["proto"], $v["return"]); } else { $line .= format_line(count($v["proto"]), $v["name"], $v["proto"], $v["return"], true); } $nb++; } return $line; }
function section_messaging() { $ou = $_SESSION["ou"]; $ldap = new clladp(); $tpl = new templates(); $domains = $ldap->Hash_domains_table($ou); while (list($num, $ligne) = each($domains)) { $doms[] = "(LENGTH(delivery_user)>0 AND delivery_domain='{$num}')"; } $sql = "SELECT * FROM smtp_logs WHERE 1 AND " . implode(" OR ", $doms) . " ORDER BY time_stamp DESC LIMIT 0,200"; $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); if (!$q->ok) { echo "<H2> Failed: {$sql}</H2><H2>{$q->mysql_error}</H2>"; return; } $count = 0; while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $count = $count + 1; $tr = $tr . format_line($ligne); } $html = "\n\t<table style='width:100%'>\n\t{$tr}\n\t</table>"; echo $tpl->_ENGINE_parse_body($html); }
function rttm_logs() { if (!isset($_GET["force-refresh"])) { if (GET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__)) { return null; } } $sql = __sql_domain($_GET["ou"]); $q = new mysql(); $results = $q->QUERY_SQL($sql, "artica_events"); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $count = $count + 1; $tr = $tr . format_line($ligne); } $tpl = new templates(); $html = $tpl->_ENGINE_parse_body("\n\t<hr><div style='text-align:right;padding:4px'>" . imgtootltip("refresh-24.png", "{refresh}", "RefreshRTMMTableForce()") . "</div>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<th> </th>\n\t\t<th>{date}</th>\n\t\t<th>{from}</th>\n\t\t<th> </th>\n\t\t<th>{to}</th>\n\t\t<th>{status}</th>\n\t</tr>\n\t{$tr}</table>"); SET_CACHED(__FILE__, __FUNCTION__, __FUNCTION__, $html); echo $html; }
mkdir(dirname($fn)); } if (!file_exists($fn)) { file_put_contents($fn, html_template()); } $attachment_query = $db->query('SELECT attachment.* FROM attachment JOIN message_attachment_join ON message_attachment_join.attachment_id=attachment.ROWID WHERE message_attachment_join.message_id = ' . $line['ROWID']); $attachments = array(); while ($attachment = $attachment_query->fetch(PDO::FETCH_ASSOC)) { $attachments[] = $attachment; } if (!entry_exists($line, $attachments, $fn)) { $fp = fopen($fn, 'a'); $log = format_line($line, $attachments); fwrite($fp, $log . "\n"); fclose($fp); echo date('c', $line['date']) . "\t" . $line['contact'] . "\t" . $line['text'] . "\n"; foreach ($attachments as $at) { $imgsrc = attachment_folder($line['contact'], $line['date']) . $at['transfer_name']; if (!file_exists(dirname($imgsrc))) { mkdir(dirname($imgsrc)); } copy(str_replace('~/', $_SERVER['HOME'] . '/', $at['filename']), $imgsrc); } } if ($line['date'] > $last_timestamp) { $last_timestamp = $line['date']; } }
function BuildHeader($sql_query, $html_file = "last-100-mails.html", $maxmail, $subtitle = null) { $date_start = time(); $q = new mysql(); $results = $q->QUERY_SQL($sql_query, "artica_events"); if (!$q->ok) { RTMevents("Wrong sql query {$q->mysql_error}"); return null; } $count = 0; while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $count = $count + 1; $tr = $tr . format_line($ligne); } if ($_GET["COUNT_MAILS"] == null) { $sql = "SELECT count(*) as tcount FROM smtp_logs"; $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_events")); $count_table = $ligne["tcount"]; $count_table = number_format($count_table, 0, ',', ' '); $_GET["COUNT_MAILS"] = $count_table; } else { $count_table = $_GET["COUNT_MAILS"]; } if ($subtitle == null) { $subtitle = "{all}"; } $date_end = time(); $calculate = distanceOfTimeInWords($date_start, $date_end); RTMevents("{$calculate}"); $html = "\n<table style='width:100%'>\n<tr>\n\t<td><H3 style='font-weight:bold;border-bottom:1px solid #CCCCCC;margin-bottom:4px;'>{last_mails} ({$maxmail})</H3>\n\t\t<p class=caption>{filter}:<strong>{$subtitle} ({$calculate})</strong> - {$count_table} eMails {total}</p>\n\t</td>\n\t<td>\n\t\t<table style='width:100%'>\n\t\t<td>\n\t\t" . postfixlogger_progress() . "</td>\n\t\t</tr>\n\t\t</table>\n\t</td>\n</tr>\n</table>\n\t<div style='width:100%;height:300px;overflow:auto'>\n\t<table style='width:100%'>\n\t{$tr}\n\t</table>\n</div>\n"; RTMevents("BuildHeader():: Saving usr/share/artica-postfix/ressources/logs/{$html_file} ({$count})"); file_put_contents("/usr/share/artica-postfix/ressources/logs/{$html_file}", $tr); file_put_contents("/usr/share/artica-postfix/ressources/logs/" . str_replace("-", ".", $html_file), $html); @chmod("/usr/share/artica-postfix/ressources/logs/{$html_file}", 0755); @chmod("/usr/share/artica-postfix/ressources/logs/" . str_replace("-", ".", $html_file), 0755); }
# Display results if ($nb_softkeys == 6) { # Regular phone if ($action == 'display') { $object->addLine($data['last']['source'] . ' to ' . $data['last']['target'], NULL, 'center'); } else { $object->addLine($data['favorites'][$selection]['source'] . ' to ' . $data['favorites'][$selection]['target'], NULL, 'center'); } $object->setScrollStart(Aastra_size_formattedtextscreen() - 1); $nb_carac = Aastra_size_display_line(); $object->addLine(''); $object->addLine(format_line($nb_carac, Aastra_get_label('Last Trade', $language), $return[1][0][1])); $object->addLine(format_line($nb_carac, Aastra_get_label('Ask', $language), $return[1][0][4])); $object->addLine(format_line($nb_carac, Aastra_get_label('Bid', $language), $return[1][0][5])); $object->addLine(format_line($nb_carac, Aastra_get_label('Date', $language), $return[1][0][2])); $object->addLine(format_line($nb_carac, Aastra_get_label('Time', $language), $return[1][0][3])); $object->addLine(Aastra_get_label('Powered by Yahoo', $language), '', 'center'); $object->setScrollEnd(); } else { # 6739i if ($action == 'display') { $object->addLine($data['last']['source'] . ' to ' . $data['last']['target'], 'double', 'center'); } else { $object->addLine($data['favorites'][$selection]['source'] . ' to ' . $data['favorites'][$selection]['target'], 'double', 'center'); } $object->setScrollStart(); $object->addLine(''); $object->addLine(Aastra_get_label('Last Trade', $language) . ': ' . $return[1][0][1]); $object->addLine(Aastra_get_label('Ask', $language) . ': ' . $return[1][0][4]); $object->addLine(Aastra_get_label('Bid', $language) . ': ' . $return[1][0][5]); $object->addLine(Aastra_get_label('Date', $language) . ': ' . $return[1][0][2]);
function ShoweventsORG() { $ldap = new clladp(); $pattern = $_GET["SendQuery"]; $pattern = str_replace('*', '%', $pattern); if (strpos(" {$pattern}", '%') == 0) { $pattern = $pattern . "%"; } if ($_SESSION["RTTM"]["M"][md5($pattern)] != null) { echo $_SESSION["RTTM"]["M"][md5($pattern)]; return; } $hash = $ldap->hash_get_domains_ou($_SESSION["ou"]); if (!is_array($hash)) { return null; } while (list($num, $ligne) = each($hash)) { $sender_domain[] = "(sender_domain='{$num}')"; $sender_domain[] = "(delivery_domain='{$num}')"; } $or = implode(" OR ", $sender_domain); $first = "((delivery_user LIKE '{$pattern}') OR (sender_user LIKE '{$pattern}'))"; $sql = "SELECT * FROM smtp_logs WHERE {$first} AND ({$or}) ORDER BY time_stamp DESC limit 0,100"; $q = new mysql(); $results = $q->QUERY_SQL($sql, 'artica_events'); while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) { $count = $count + 1; $tr = $tr . format_line($ligne); } $tpl = new templates(); $html = $tpl->_parse_body("<table style='width:99%'>{$tr}</table>"); $_SESSION["RTTM"]["M"][md5($pattern)] = $html; echo $html; }
/** * @param $key * @param $value * * @return bool */ public function set($key, $value) { $set = $replaced = false; $new_line = format_line($key, $value); foreach ($this->lines as &$line) { if ($this->is_key_match($key, $line)) { $line = $new_line; $set = $replaced = true; } } // if it wasn't replaced, append it if (!$replaced) { $this->add_line($new_line); $set = true; } return $set; }
# Create the object require_once 'AastraIPPhoneFormattedTextScreen.class.php'; $object = new AastraIPPhoneFormattedTextScreen(); # No color FTS if (!Aastra_is_formattedtextscreen_color_supported()) { # Process the results $nb_carac = Aastra_size_display_line(); $object->setScrollStart(Aastra_size_formattedtextscreen()); foreach ($return[1] as $key => $value) { if ($value != NULL) { if ($value[8] != 'N/A') { $last = 'Not Found'; } else { $last = $value[2]; } $object->addLine(format_line($nb_carac, $value[0], $last)); } } $object->addLine(Aastra_get_label('Powered by Yahoo', $language), '', 'center'); $object->setScrollEnd(); } else { # Color FTS $object->setScrollStart(); foreach ($return[1] as $key => $value) { if ($value != NULL) { if ($value[8] != 'N/A') { $last = 'Not Found'; } else { $last = $value[2]; } if ($value[6] < 0) {
function load_2014() { $dir_path = '/home/mikhaili/CMS/PSPS_2014'; $year = '14'; $total_count = 0; foreach (range(1, 25) as $n) { if ($n < 10) { $file = $dir_path . '/PSPS0' . $n . '/PSPS0' . $n . '.txt'; $new_file = $dir_path . '/PSPSFormattedAll/PSPS0' . $n . '_NEW.txt'; } else { $file = $dir_path . '/PSPS' . $n . '/PSPS' . $n . '.txt'; $new_file = $dir_path . '/PSPSFormattedAll/PSPS' . $n . '_NEW.txt'; } $line_count = 0; $handle = fopen("{$file}", "r"); $new_handle = fopen("{$new_file}", "w"); if ($handle) { while (($line = fgets($handle)) !== false) { $line_count += 1; $total_count += 1; //if ($line_count > 10 ) break; //echo $line . "\n\r"; $new_line = format_line($line); fwrite($new_handle, $new_line); // process the line read. } fclose($handle); fclose($new_handle); } else { // error opening the file. } echo $line_count . ' Lines were inserted in file ' . $new_file . "\n\r"; //die(); } echo $total_count . ' Lines were inserted in all files '; }