function get_smtp_user(&$user, &$pass) { global $username, $smtp_auth_mech, $smtp_sitewide_user, $smtp_sitewide_pass; if ($smtp_auth_mech == 'none') { $user = ''; $pass = ''; } elseif (isset($smtp_sitewide_user) && isset($smtp_sitewide_pass) && !empty($smtp_sitewide_user)) { $user = $smtp_sitewide_user; $pass = $smtp_sitewide_pass; } else { $user = $username; $pass = sqauth_read_password(); } // plugin authors note: override $user or $pass by // returning an array where the new username is the // first array value and the new password is the // second array value e.g., return array($myuser, $mypass); // $ret = do_hook_function('smtp_auth', array($user, $pass)); if (!empty($ret[0])) { $user = $ret[0]; } if (!empty($ret[1])) { $pass = $ret[1]; } }
/** * Return the value for the preference given by $string. */ function getPref($data_dir, $username, $string, $default = '') { global $prefs_cache; $result = do_hook_function('get_pref_override', array($username, $string)); if (!$result) { cachePrefValues($data_dir, $username); if (isset($prefs_cache[$string])) { $result = $prefs_cache[$string]; } else { $result = do_hook_function('get_pref', array($username, $string)); if (!$result) { $result = $default; } } } return $result; }
/** * Given a path to a SquirrelMail file, return a HTML link to it * * @param string path the SquirrelMail file to link to * @param string text the link text * @param string target the target frame for this link */ function makeInternalLink($path, $text, $target = '') { sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); if ($target != '') { $target = " target=\"{$target}\""; } $hooktext = do_hook_function('internal_link', $text); if ($hooktext != '') { $text = $hooktext; } return '<a href="' . $base_uri . $path . '"' . $target . '>' . $text . '</a>'; }
} break; case 3: if ($thold_data['expression'] != '') { $currentval = thold_calculate_expression($thold_data, $currentval, $rrd_reindexed, $rrd_time_reindexed); } break; } if (is_numeric($currentval)) { $currentval = round($currentval, 4); } else { $currentval = ''; } db_execute("UPDATE thold_data SET \n\t\t\ttcheck=1, lastread='{$currentval}',\n\t\t\tlasttime='" . date('Y-m-d H:i:s', $currenttime) . "',\n\t\t\toldvalue='" . $item[$thold_data['name']] . "'\n\t\t\tWHERE id = " . $thold_data['thold_id']); } /* check all thresholds */ $sql_query = "SELECT td.*\n\t\tFROM plugin_thold_daemon_data AS tdd\n\t\tINNER JOIN thold_data AS td\n\t\tON td.id = tdd.id\n\t\tLEFT JOIN data_template_rrd AS dtr\n\t\tON dtr.id = td.data_template_rrd_id\n\t\tWHERE tdd.pid = '{$pid}' \n\t\tAND td.thold_enabled='on' \n\t\tAND td.tcheck=1"; $tholds = do_hook_function('thold_get_live_hosts', db_fetch_assoc($sql_query)); $total_tholds = sizeof($tholds); foreach ($tholds as $thold) { thold_check_threshold($thold); } db_execute("UPDATE thold_data SET thold_data.thold_server_pid = '', tcheck=0 WHERE thold_data.thold_server_pid = '{$pid}'"); db_execute("DELETE FROM `plugin_thold_daemon_data` WHERE `pid` = '{$pid}'"); db_execute("UPDATE `plugin_thold_daemon_processes` SET `end` = " . time() . ", `processed_items` = " . $total_tholds); } function display_help() { print "tbd ... blablabla ..."; exit; }
* @package squirrelmail * @subpackage prefs */ /** Include global.php */ require_once SM_PATH . 'functions/global.php'; require_once SM_PATH . 'functions/plugin.php'; /** include this for error messages */ include_once SM_PATH . 'functions/display_messages.php'; sqgetGlobalVar('prefs_cache', $prefs_cache, SQ_SESSION); sqgetGlobalVar('prefs_are_cached', $prefs_are_cached, SQ_SESSION); $rg = ini_get('register_globals'); if (!sqsession_is_registered('prefs_are_cached') || !isset($prefs_cache) || !is_array($prefs_cache)) { $prefs_are_cached = false; $prefs_cache = array(); } $prefs_backend = do_hook_function('prefs_backend'); if (isset($prefs_backend) && !empty($prefs_backend) && file_exists(SM_PATH . $prefs_backend)) { require_once SM_PATH . $prefs_backend; } elseif (isset($prefs_dsn) && !empty($prefs_dsn)) { require_once SM_PATH . 'functions/db_prefs.php'; } else { require_once SM_PATH . 'functions/file_prefs.php'; } /* Hashing functions */ /** * Given a username and datafilename, this will return the path to the * hashed location of that datafile. * * @param string username the username of the current user * @param string dir the squirrelmail datadir * @param string datafile the name of the file to open
/* Display error messages */ if (!empty($formerror)) { echo html_tag('table', html_tag('tr', html_tag('td', "\n" . '<br /><strong><font color="' . $color[2] . '">' . _("ERROR") . ': ' . htmlspecialchars($formerror) . '</font></strong>' . "\n", 'center')), 'center', '', 'width="100%"'); } /* Display the address management part */ if ($showaddrlist) { /* Get and sort address list */ $alist = $abook->list_addr(); if (!is_array($alist)) { $abook->error = htmlspecialchars($abook->error); plain_error_message($abook->error, $color); exit; } usort($alist, 'alistcmp'); // filter listing as needed $hook_return = do_hook_function('abook_list_filter', $alist); if (!empty($hook_return)) { $alist = $hook_return; } $prevbackend = -1; $headerprinted = false; $compose_to_in_new_window_javascript = ' onclick="var send_to = \'\'; var f = document.forms.length; var i = 0; var grab_next_hidden = \'\'; while (i < f) { var e = document.forms[i].elements.length; var j = 0; while (j < e) { if (document.forms[i].elements[j].type == \'checkbox\' && document.forms[i].elements[j].checked) { var pos = document.forms[i].elements[j].value.indexOf(\':\'); if (pos >= 1) { grab_next_hidden = document.forms[i].elements[j].value; } } else if (document.forms[i].elements[j].type == \'hidden\' && grab_next_hidden == document.forms[i].elements[j].name) { if (send_to != \'\') { send_to += \', \'; } send_to += document.forms[i].elements[j].value; } j++; } i++; } if (send_to != \'\') { comp_in_new(\'' . $base_uri . 'src/compose.php?send_to=\' + send_to); } return false;"'; echo html_tag('div', '<a href="#AddAddress">' . _("Add address") . '</a>', 'center') . "\n"; /* List addresses */ if (count($alist) > 0) { echo addForm($form_url, 'post', 'address_book_form'); if ($abook->add_extra_field) { $abook_fields = 6; } else { $abook_fields = 5; }
/** * Decodes encoded message body * * This function decodes the body depending on the encoding type. * Currently quoted-printable and base64 encodings are supported. * decode_body hook was added to this function in 1.4.2/1.5.0 * @param string $body encoded message body * @param string $encoding used encoding * @return string decoded string * @since 1.0 */ function decodeBody($body, $encoding) { $body = str_replace("\r\n", "\n", $body); $encoding = strtolower($encoding); $encoding_handler = do_hook_function('decode_body', $encoding); // plugins get first shot at decoding the body if (!empty($encoding_handler) && function_exists($encoding_handler)) { $body = $encoding_handler('decode', $body); } elseif ($encoding == 'quoted-printable' || $encoding == 'quoted_printable') { /** * quoted_printable_decode() function is broken in older * php versions. Text with \r\n decoding was fixed only * in php 4.3.0. Minimal code requirement 4.0.4 + * str_replace("\r\n", "\n", $body); call. */ $body = quoted_printable_decode($body); } elseif ($encoding == 'base64') { $body = base64_decode($body); } // All other encodings are returned raw. return $body; }
/** * Format message toolbar * * @param string $mailbox Name of current mailbox * @param int $passed_id UID of current message * @param int $passed_ent_id Id of entity within message * @param object $message Current message object * @param object $mbx_response */ function formatMenubar($aMailbox, $passed_id, $passed_ent_id, $message, $removedVar, $nav_on_top = TRUE) { global $base_uri, $draft_folder, $where, $what, $color, $sort, $startMessage, $PHP_SELF, $save_as_draft, $enable_forward_as_attachment, $imapConnection, $lastTargetMailbox, $data_dir, $username, $delete_prev_next_display, $compose_new_win, $javascript_on; //FIXME cleanup argument list, use $aMailbox where possible $mailbox = $aMailbox['NAME']; $topbar_delimiter = ' | '; $double_delimiter = ' '; $urlMailbox = urlencode($mailbox); $msgs_url = $base_uri . 'src/'; // BEGIN NAV ROW - PREV/NEXT, DEL PREV/NEXT, LINKS TO INDEX, etc. $nav_row = '<tr><td align="left" colspan="2" style="border: 1px solid ' . $color[9] . ';"><small>'; // Create Prev & Next links // Handle nested entities first (i.e. Mime Attach parts) if (isset($passed_ent_id) && $passed_ent_id) { // code for navigating through attached message/rfc822 messages $url = set_url_var($PHP_SELF, 'passed_ent_id', 0); $entities = array(); $entity_count = array(); $c = 0; foreach ($message->parent->entities as $ent) { if ($ent->type0 == 'message' && $ent->type1 == 'rfc822') { $c++; $entity_count[$c] = $ent->entity_id; $entities[$ent->entity_id] = $c; } } $prev_link = _("Previous"); if ($entities[$passed_ent_id] > 1) { $prev_ent_id = $entity_count[$entities[$passed_ent_id] - 1]; $prev_link = '<a href="' . set_url_var($PHP_SELF, 'passed_ent_id', $prev_ent_id) . '">' . $prev_link . '</a>'; } $next_link = _("Next"); if ($entities[$passed_ent_id] < $c) { $next_ent_id = $entity_count[$entities[$passed_ent_id] + 1]; $next_link = '<a href="' . set_url_var($PHP_SELF, 'passed_ent_id', $next_ent_id) . '">' . $next_link . '</a>'; } $par_ent_id = $message->parent->entity_id; $up_link = ''; if ($par_ent_id) { $par_ent_id = substr($par_ent_id, 0, -2); if ($par_ent_id != 0) { $up_link = $topbar_delimiter; $url = set_url_var($PHP_SELF, 'passed_ent_id', $par_ent_id); $up_link .= '<a href="' . $url . '">' . _("Up") . '</a>'; } } $nav_row .= $prev_link . $up_link . $topbar_delimiter . $next_link; $nav_row .= $double_delimiter . '[<a href="' . $url . '">' . _("View Message") . '</a>]'; // Prev/Next links for regular messages } else { if (true) { //!(isset($where) && isset($what)) ) { /** * Check if cache is still valid */ if (!is_array($aMailbox['UIDSET'][$what])) { fetchMessageHeaders($imapConnection, $aMailbox); } $prev = findPreviousMessage($aMailbox['UIDSET'][$what], $passed_id); $next = findNextMessage($aMailbox['UIDSET'][$what], $passed_id); $prev_link = _("Previous"); if ($prev >= 0) { $uri = $base_uri . 'src/read_body.php?passed_id=' . $prev . '&mailbox=' . $urlMailbox . '&sort=' . $sort . "&where={$where}&what={$what}" . '&startMessage=' . $startMessage . '&show_more=0'; $prev_link = '<a href="' . $uri . '">' . $prev_link . '</a>'; } $next_link = _("Next"); if ($next >= 0) { $uri = $base_uri . 'src/read_body.php?passed_id=' . $next . '&mailbox=' . $urlMailbox . '&sort=' . $sort . "&where={$where}&what={$what}" . '&startMessage=' . $startMessage . '&show_more=0'; $next_link = '<a href="' . $uri . '">' . $next_link . '</a>'; } // Only bother with Delete & Prev and Delete & Next IF // top display is enabled. if ($delete_prev_next_display == 1 && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true)) { $del_prev_link = _("Delete & Prev"); if ($prev >= 0) { $uri = $base_uri . 'src/read_body.php?passed_id=' . $prev . '&mailbox=' . $urlMailbox . '&sort=' . $sort . '&startMessage=' . $startMessage . '&show_more=0' . "&where={$where}&what={$what}" . '&delete_id=' . $passed_id; $del_prev_link = '<a href="' . $uri . '">' . $del_prev_link . '</a>'; } $del_next_link = _("Delete & Next"); if ($next >= 0) { $uri = $base_uri . 'src/read_body.php?passed_id=' . $next . '&mailbox=' . $urlMailbox . '&sort=' . $sort . '&startMessage=' . $startMessage . '&show_more=0' . "&where={$where}&what={$what}" . '&delete_id=' . $passed_id; $del_next_link = '<a href="' . $uri . '">' . $del_next_link . '</a>'; } } $nav_row .= '[' . $prev_link . $topbar_delimiter . $next_link . ']'; if (isset($del_prev_link) && isset($del_next_link)) { $nav_row .= $double_delimiter . '[' . $del_prev_link . $topbar_delimiter . $del_next_link . ']'; } } } // Start with Search Results or Message List link. $msgs_url .= "{$where}?where=read_body.php&what={$what}&mailbox=" . $urlMailbox . "&startMessage={$startMessage}"; if ($where == 'search.php') { $msgs_str = _("Search Results"); } else { $msgs_str = _("Message List"); } $nav_row .= $double_delimiter . '[<a href="' . $msgs_url . '">' . $msgs_str . '</a>]'; $nav_row .= '</small></td></tr>'; // BEGIN MENU ROW - DELETE/REPLY/FORWARD/MOVE/etc. $menu_row = '<tr bgcolor="' . $color[0] . '"><td><small>'; $comp_uri = $base_uri . 'src/compose.php' . '?passed_id=' . $passed_id . '&mailbox=' . $urlMailbox . '&startMessage=' . $startMessage . (isset($passed_ent_id) ? '&passed_ent_id=' . $passed_ent_id : ''); // Start form for reply/reply all/forward.. $target = ''; $on_click = ''; $method = 'method="post" '; if ($compose_new_win == '1') { if ($javascript_on) { $on_click = ' onclick="comp_in_new_form(\'' . $comp_uri . '\', this, this.form)"'; $comp_uri = 'javascript:void(0)'; $method = 'method="get" '; } else { $target = 'target="_blank"'; } } $menu_row .= "\n" . '<form name="composeForm" action="' . $comp_uri . '" ' . $method . $target . ' style="display: inline">' . "\n"; // If Draft folder - create Resume link if ($mailbox == $draft_folder && $save_as_draft) { $new_button = 'smaction_draft'; $comp_alt_string = _("Resume Draft"); } else { if (handleAsSent($mailbox)) { // If in Sent folder, edit as new $new_button = 'smaction_edit_new'; $comp_alt_string = _("Edit Message as New"); } } // Show Alt URI for Draft/Sent if (isset($comp_alt_string)) { $menu_row .= getButton('submit', $new_button, $comp_alt_string, $on_click) . "\n"; } $menu_row .= getButton('submit', 'smaction_reply', _("Reply"), $on_click) . "\n"; $menu_row .= getButton('submit', 'smaction_reply_all', _("Reply All"), $on_click) . "\n"; $menu_row .= getButton('submit', 'smaction_forward', _("Forward"), $on_click); if ($enable_forward_as_attachment) { $menu_row .= '<input type="checkbox" name="smaction_attache" />' . _("As Attachment") . ' ' . "\n"; } $menu_row .= '</form> '; if (in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true)) { // Form for deletion. Form is handled by the originating display in $where. This is right_main.php or search.php $delete_url = $base_uri . "src/{$where}"; $menu_row .= '<form name="deleteMessageForm" action="' . $delete_url . '" method="post" style="display: inline">'; if (!(isset($passed_ent_id) && $passed_ent_id)) { $menu_row .= addHidden('mailbox', $aMailbox['NAME']); $menu_row .= addHidden('msg[0]', $passed_id); $menu_row .= addHidden('startMessage', $startMessage); $menu_row .= getButton('submit', 'delete', _("Delete")); $menu_row .= '<input type="checkbox" name="bypass_trash" />' . _("Bypass Trash"); } else { $menu_row .= getButton('submit', 'delete', _("Delete"), '', FALSE) . "\n"; // delete button is disabled } $menu_row .= '</form>'; } // Add top move link $menu_row .= '</small></td><td align="right">'; if (!(isset($passed_ent_id) && $passed_ent_id) && in_array('\\deleted', $aMailbox['PERMANENTFLAGS'], true)) { $menu_row .= '<form name="moveMessageForm" action="' . $base_uri . 'src/' . $where . '?' . '" method="post" style="display: inline">' . '<small>' . addHidden('mailbox', $aMailbox['NAME']) . addHidden('msg[0]', $passed_id) . _("Move to:") . '<select name="targetMailbox" style="padding: 0px; margin: 0px">'; if (isset($lastTargetMailbox) && !empty($lastTargetMailbox)) { $menu_row .= sqimap_mailbox_option_list($imapConnection, array(strtolower($lastTargetMailbox))); } else { $menu_row .= sqimap_mailbox_option_list($imapConnection); } $menu_row .= '</select> '; $menu_row .= getButton('submit', 'moveButton', _("Move")) . "\n" . '</form>'; } $menu_row .= '</td></tr>'; // echo rows, with hooks $ret = do_hook_function('read_body_menu_top', array($nav_row, $menu_row)); if (is_array($ret)) { if (isset($ret[0]) && !empty($ret[0])) { $nav_row = $ret[0]; } if (isset($ret[1]) && !empty($ret[1])) { $menu_row = $ret[1]; } } echo '<table width="100%" cellpadding="3" cellspacing="0" align="center" border="0">'; echo $nav_on_top ? $nav_row . $menu_row : $menu_row . $nav_row; echo '</table>' . "\n"; do_hook('read_body_menu_bottom'); }
function weathermap_singleview($mapid) { global $colors; $is_wm_admin = false; $outdir = dirname(__FILE__) . '/output/'; $confdir = dirname(__FILE__) . '/configs/'; $userid = isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1; $map = db_fetch_assoc("select weathermap_maps.* from weathermap_auth,weathermap_maps where weathermap_maps.id=weathermap_auth.mapid and active='on' and (userid=" . $userid . " or userid=0) and weathermap_maps.id=" . $mapid); if (sizeof($map)) { # print do_hook_function ('weathermap_page_top', array($map[0]['id'], $map[0]['titlecache']) ); print do_hook_function('weathermap_page_top', ''); $htmlfile = $outdir . $map[0]['filehash'] . ".html"; $maptitle = $map[0]['titlecache']; if ($maptitle == '') { $maptitle = "Map for config file: " . $map[0]['configfile']; } weathermap_mapselector($mapid); html_graph_start_box(1, true); ?> <tr bgcolor="<?php print $colors["panel"]; ?> "><td><table width="100%" cellpadding="0" cellspacing="0"><tr><td class="textHeader" nowrap><?php print $maptitle; if ($is_wm_admin) { print "<span style='font-size: 80%'>"; print "[ <a href='weathermap-cacti-plugin-mgmt.php?action=map_settings&id=" . $mapid . "'>Map Settings</a> |"; print "<a href='weathermap-cacti-plugin-mgmt.php?action=perms_edit&id=" . $mapid . "'>Map Permissions</a> |"; print "<a href=''>Edit Map</a> ]"; print "</span>"; } ?> </td></tr></table></td></tr> <?php print "<tr><td>"; if (file_exists($htmlfile)) { include $htmlfile; } else { print "<div align=\"center\" style=\"padding:20px\"><em>This map hasn't been created yet."; global $config, $user_auth_realms, $user_auth_realm_filenames; $realm_id2 = 0; if (isset($user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')])) { $realm_id2 = $user_auth_realm_filenames[basename('weathermap-cacti-plugin.php')]; } $userid = isset($_SESSION["sess_user_id"]) ? intval($_SESSION["sess_user_id"]) : 1; if (db_fetch_assoc("select user_auth_realm.realm_id from user_auth_realm where user_auth_realm.us\n\t\t\t\ter_id='" . $userid . "' and user_auth_realm.realm_id='{$realm_id2}'") || empty($realm_id2)) { print " (If this message stays here for more than one poller cycle, then check your cacti.log file for errors!)"; } print "</em></div>"; } print "</td></tr>"; html_graph_end_box(); } }
function getKey($user, $key, $default = '') { global $prefs_cache; $result = do_hook_function('get_pref_override', array($user, $key)); //FIXME: testing below for !$result means that a plugin cannot fetch its own pref value of 0, '0', '', FALSE, or anything else that evaluates to boolean FALSE. if (!$result) { cachePrefValues($user); if (isset($prefs_cache[$key])) { $result = $prefs_cache[$key]; } else { //FIXME: is there justification for having these TWO hooks so close together? who uses these? $result = do_hook_function('get_pref', array($user, $key)); //FIXME: testing below for !$result means that a plugin cannot fetch its own pref value of 0, '0', '', FALSE, or anything else that evaluates to boolean FALSE. if (!$result) { if (isset($this->default[$key])) { $result = $this->default[$key]; } else { $result = $default; } } } } return $result; }
/** * Renames a mailbox. */ function sqimap_mailbox_rename($imap_stream, $old_name, $new_name) { if ($old_name != $new_name) { global $delimiter, $imap_server_type, $data_dir, $username; if (substr($old_name, -1) == $delimiter) { $old_name = substr($old_name, 0, strlen($old_name) - 1); $new_name = substr($new_name, 0, strlen($new_name) - 1); $postfix = $delimiter; } else { $postfix = ''; } $boxesall = sqimap_mailbox_list_all($imap_stream); $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); sqimap_unsubscribe($imap_stream, $old_name . $postfix); $oldpref_thread = getPref($data_dir, $username, 'thread_' . $old_name . $postfix); $oldpref_collapse = getPref($data_dir, $username, 'collapse_folder_' . $old_name . $postfix); removePref($data_dir, $username, 'thread_' . $old_name . $postfix); removePref($data_dir, $username, 'collapse_folder_' . $old_name . $postfix); sqimap_subscribe($imap_stream, $new_name . $postfix); setPref($data_dir, $username, 'thread_' . $new_name . $postfix, $oldpref_thread); setPref($data_dir, $username, 'collapse_folder_' . $new_name . $postfix, $oldpref_collapse); do_hook_function('rename_or_delete_folder', $args = array($old_name, 'rename', $new_name)); $l = strlen($old_name) + 1; $p = 'unformatted'; foreach ($boxesall as $box) { if (substr($box[$p], 0, $l) == $old_name . $delimiter) { $new_sub = $new_name . $delimiter . substr($box[$p], $l); /* With Cyrus IMAPd >= 2.0 rename is recursive, so don't check for errors here */ if ($imap_server_type == 'cyrus') { $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"'; $data = sqimap_run_command($imap_stream, $cmd, false, $response, $message); } $was_subscribed = sqimap_mailbox_is_subscribed($imap_stream, $box[$p]); if ($was_subscribed) { sqimap_unsubscribe($imap_stream, $box[$p]); } $oldpref_thread = getPref($data_dir, $username, 'thread_' . $box[$p]); $oldpref_collapse = getPref($data_dir, $username, 'collapse_folder_' . $box[$p]); removePref($data_dir, $username, 'thread_' . $box[$p]); removePref($data_dir, $username, 'collapse_folder_' . $box[$p]); if ($was_subscribed) { sqimap_subscribe($imap_stream, $new_sub); } setPref($data_dir, $username, 'thread_' . $new_sub, $oldpref_thread); setPref($data_dir, $username, 'collapse_folder_' . $new_sub, $oldpref_collapse); do_hook_function('rename_or_delete_folder', $args = array($box[$p], 'rename', $new_sub)); } } } }
function thold_check_all_thresholds() { global $config; include $config['base_path'] . '/plugins/thold/includes/arrays.php'; include_once $config['base_path'] . '/plugins/thold/thold_functions.php'; $sql_query = "SELECT td.*, dtr.data_source_name\n\t\tFROM thold_data AS td\n\t\tLEFT JOIN data_template_rrd AS dtr\n\t\tON dtr.id=td.data_template_rrd_id\n\t\tWHERE td.thold_enabled='on' AND td.tcheck=1"; $tholds = do_hook_function('thold_get_live_hosts', db_fetch_assoc($sql_query)); $total_tholds = sizeof($tholds); foreach ($tholds as $thold) { thold_check_threshold($thold); } db_execute('UPDATE thold_data SET tcheck=0'); return $total_tholds; }
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | GNU General Public License for more details. | +-------------------------------------------------------------------------+ | Cacti: The Complete RRDTool-based Graphing Solution | +-------------------------------------------------------------------------+ | This code is designed, written, and maintained by the Cacti Group. See | | about.php and/or the AUTHORS file for specific developer information. | +-------------------------------------------------------------------------+ | http://www.cacti.net/ | +-------------------------------------------------------------------------+ */ require(CACTI_BASE_PATH . "/include/auth/auth_arrays.php"); if (!defined('VALID_HOST_FIELDS')) { $string = do_hook_function('valid_device_fields', '(hostname|snmp_community|snmp_username|snmp_password|snmp_auth_protocol|snmp_priv_passphrase|snmp_priv_protocol|snmp_context|snmp_version|snmp_port|snmp_timeout)'); define('VALID_HOST_FIELDS', $string); } /* file: user_admin.php, action: user_edit (device) */ $fields_user_user_edit_device = array( "username" => array( "method" => "textbox", "friendly_name" => __("User Name"), "description" => __("The login name for this user."), "value" => "|arg1:username|", "max_length" => "255", "size" => "70" ), "full_name" => array( "method" => "textbox",
function decodeBody($body, $encoding) { global $show_html_default; $body = str_replace("\r\n", "\n", $body); $encoding = strtolower($encoding); $encoding_handler = do_hook_function('decode_body', $encoding); // plugins get first shot at decoding the body // if (!empty($encoding_handler) && function_exists($encoding_handler)) { $body = $encoding_handler('decode', $body); } else { if ($encoding == 'quoted-printable' || $encoding == 'quoted_printable') { $body = quoted_printable_decode($body); while (ereg("=\n", $body)) { $body = ereg_replace("=\n", '', $body); } } else { if ($encoding == 'base64') { $body = base64_decode($body); } } } // All other encodings are returned raw. return $body; }
function sqimap_mailbox_rename($imap_stream, $old_name, $new_name) { if ($old_name != $new_name) { global $delimiter, $imap_server_type, $data_dir, $username; if (substr($old_name, -1) == $delimiter) { $old_name = substr($old_name, 0, strlen($old_name) - 1); $new_name = substr($new_name, 0, strlen($new_name) - 1); $postfix = $delimiter; } else { $postfix = ''; } $boxesall = sqimap_mailbox_list($imap_stream); $cmd = 'RENAME "' . $old_name . '" "' . $new_name . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); sqimap_unsubscribe($imap_stream, $old_name . $postfix); $oldpref = getPref($data_dir, $username, 'thread_' . $old_name . $postfix); removePref($data_dir, $username, 'thread_' . $old_name . $postfix); sqimap_subscribe($imap_stream, $new_name . $postfix); setPref($data_dir, $username, 'thread_' . $new_name . $postfix, $oldpref); do_hook_function('rename_or_delete_folder', $args = array($old_name, 'rename', $new_name)); $l = strlen($old_name) + 1; $p = 'unformatted'; foreach ($boxesall as $box) { if (substr($box[$p], 0, $l) == $old_name . $delimiter) { $new_sub = $new_name . $delimiter . substr($box[$p], $l); if ($imap_server_type == 'cyrus') { $cmd = 'RENAME "' . $box[$p] . '" "' . $new_sub . '"'; $data = sqimap_run_command($imap_stream, $cmd, true, $response, $message); } sqimap_unsubscribe($imap_stream, $box[$p]); $oldpref = getPref($data_dir, $username, 'thread_' . $box[$p]); removePref($data_dir, $username, 'thread_' . $box[$p]); sqimap_subscribe($imap_stream, $new_sub); setPref($data_dir, $username, 'thread_' . $new_sub, $oldpref); do_hook_function('rename_or_delete_folder', $args = array($box[$p], 'rename', $new_sub)); } } } }
function plgexample_check_all_thresholds () { global $config; include_once($config['base_path'] . '/plugins/thold/thold_functions.php'); $tholds = do_hook_function('thold_get_live_hosts', db_fetch_assoc("SELECT * FROM thold_data WHERE thold_enabled = 'on' AND tcheck = 1")); $total_tholds = sizeof($tholds); foreach ($tholds as $thold) { $ds = db_fetch_cell('SELECT data_source_name FROM data_template_rrd WHERE id=' . $thold['data_id']); thold_check_threshold ($thold['rra_id'], $thold['data_id'], $ds, $thold['lastread'], $thold['cdef']); } # db_execute('UPDATE thold_data SET tcheck = 0'); return $total_tholds; }
/** * Process messages list form and handle the cache gracefully. If $sButton and * $aUid are provided as argument then you can fake a message list submit and * use it i.e. in read_body.php for del move next and update the cache * * @param resource $imapConnection imap connection * @param array $aMailbox (reference) cached mailbox * @param string $sButton fake a submit button * @param array $aUid fake the $msg array * @return string $sError error string in case of an error * @author Marc Groot Koerkamp */ function handleMessageListForm($imapConnection, &$aMailbox, $sButton = '', $aUid = array()) { /* incoming formdata */ $sButton = sqgetGlobalVar('moveButton', $sTmp, SQ_POST) ? 'move' : $sButton; $sButton = sqgetGlobalVar('expungeButton', $sTmp, SQ_POST) ? 'expunge' : $sButton; $sButton = sqgetGlobalVar('attache', $sTmp, SQ_POST) ? 'attache' : $sButton; $sButton = sqgetGlobalVar('delete', $sTmp, SQ_POST) ? 'setDeleted' : $sButton; $sButton = sqgetGlobalVar('undeleteButton', $sTmp, SQ_POST) ? 'setDeleted' : $sButton; $sButton = sqgetGlobalVar('markRead', $sTmp, SQ_POST) ? 'setSeen' : $sButton; $sButton = sqgetGlobalVar('markUnread', $sTmp, SQ_POST) ? 'unsetSeen' : $sButton; $sButton = sqgetGlobalVar('markFlagged', $sTmp, SQ_POST) ? 'setFlagged' : $sButton; $sButton = sqgetGlobalVar('markUnflagged', $sTmp, SQ_POST) ? 'unsetFlagged' : $sButton; sqgetGlobalVar('targetMailbox', $targetMailbox, SQ_POST); sqgetGlobalVar('bypass_trash', $bypass_trash, SQ_POST); sqgetGlobalVar('msg', $msg, SQ_POST); $sError = ''; $mailbox = $aMailbox['NAME']; /* retrieve the check boxes */ $aUid = isset($msg) && is_array($msg) ? array_values($msg) : $aUid; if (count($aUid) && $sButton != 'expunge') { $aUpdatedMsgs = false; $bExpunge = false; switch ($sButton) { case 'setDeleted': // check if id exists in case we come from read_body if (count($aUid) == 1 && is_array($aMailbox['UIDSET'][$aMailbox['SETINDEX']]) && !in_array($aUid[0], $aMailbox['UIDSET'][$aMailbox['SETINDEX']])) { break; } $aUpdatedMsgs = sqimap_msgs_list_delete($imapConnection, $mailbox, $aUid, $bypass_trash); $bExpunge = true; break; case 'unsetDeleted': case 'setSeen': case 'unsetSeen': case 'setFlagged': case 'unsetFlagged': // get flag $sFlag = substr($sButton, 0, 3) == 'set' ? '\\' . substr($sButton, 3) : '\\' . substr($sButton, 5); $bSet = substr($sButton, 0, 3) == 'set' ? true : false; $aUpdatedMsgs = sqimap_toggle_flag($imapConnection, $aUid, $sFlag, $bSet, true); break; case 'move': $aUpdatedMsgs = sqimap_msgs_list_move($imapConnection, $aUid, $targetMailbox); sqsession_register($targetMailbox, 'lastTargetMailbox'); $bExpunge = true; break; case 'attache': $aMsgHeaders = array(); foreach ($aUid as $iUid) { $aMsgHeaders[$iUid] = $aMailbox['MSG_HEADERS'][$iUid]; } if (count($aMsgHeaders)) { $composesession = attachSelectedMessages($imapConnection, $aMsgHeaders); // dirty hack, add info to $aMailbox $aMailbox['FORWARD_SESSION'] = $composesession; } break; default: // Hook for plugin buttons do_hook_function('mailbox_display_button_action', $aUid); break; } /** * Updates messages is an array containing the result of the untagged * fetch responses send by the imap server due to a flag change. That * response is parsed in a array with msg arrays by the parseFetch function */ if ($aUpdatedMsgs) { // Update the message headers cache $aDeleted = array(); foreach ($aUpdatedMsgs as $iUid => $aMsg) { if (isset($aMsg['FLAGS'])) { /** * Only update the cached headers if the header is * cached. */ if (isset($aMailbox['MSG_HEADERS'][$iUid])) { $aMailbox['MSG_HEADERS'][$iUid]['FLAGS'] = $aMsg['FLAGS']; } /** * Count the messages with the \Delete flag set so we can determine * if the number of expunged messages equals the number of flagged * messages for deletion. */ if (isset($aMsg['FLAGS']['\\deleted']) && $aMsg['FLAGS']['\\deleted']) { $aDeleted[] = $iUid; } } } if ($bExpunge && $aMailbox['AUTO_EXPUNGE'] && ($iExpungedMessages = sqimap_mailbox_expunge($imapConnection, $aMailbox['NAME'], true))) { if (count($aDeleted) != $iExpungedMessages) { // there are more messages deleted permanently then we expected // invalidate the cache $aMailbox['UIDSET'][$aMailbox['SETINDEX']] = false; $aMailbox['MSG_HEADERS'] = false; } else { // remove expunged messages from cache $aUidSet = $aMailbox['UIDSET'][$aMailbox['SETINDEX']]; if (is_array($aUidSet)) { // create a UID => array index temp array $aUidSetDummy = array_flip($aUidSet); foreach ($aDeleted as $iUid) { // get the id as well in case of SQM_SORT_NONE if ($aMailbox['SORT'] == SQSORT_NONE) { $aMailbox['ID'] = false; //$iId = $aMailbox['MSG_HEADERS'][$iUid]['ID']; //unset($aMailbox['ID'][$iId]); } // unset the UID and message header unset($aUidSetDummy[$iUid]); unset($aMailbox['MSG_HEADERS'][$iUid]); } $aMailbox['UIDSET'][$aMailbox['SETINDEX']] = array_keys($aUidSetDummy); } } // update EXISTS info if ($iExpungedMessages) { $aMailbox['EXISTS'] -= (int) $iExpungedMessages; } // Change the startMessage number if the mailbox was changed if ($aMailbox['PAGEOFFSET'] - 1 >= $aMailbox['EXISTS']) { $aMailbox['PAGEOFFSET'] = $aMailbox['PAGEOFFSET'] > $aMailbox['LIMIT'] ? $aMailbox['PAGEOFFSET'] - $aMailbox['LIMIT'] : 1; $aMailbox['OFFSET'] = $aMailbox['PAGEOFFSET'] - 1; } } } } else { if ($sButton == 'expunge') { /** * on expunge we do not know which messages will be deleted * so it's useless to try to sync the cache * Close the mailbox so we do not need to parse the untagged expunge * responses which do not contain uid info. * NB: Closing a mailbox is faster then expunge because the imap * server does not need to generate the untagged expunge responses */ sqimap_run_command($imapConnection, 'CLOSE', false, $result, $message); $aMbxResponse = sqimap_mailbox_select($imapConnection, $aMailbox['NAME']); // update the $aMailbox array $aMailbox['EXISTS'] = $aMbxResponse['EXISTS']; $aMailbox['UIDSET'] = false; } else { if ($sButton) { $sError = _("No messages were selected."); } } } return $sError; }
private function singleMapHeader($mapID, $mapTitle, $mapHash) { $colors = $this->colours; print do_hook_function('weathermap_page_top', ''); $this->outputMapSelectorBox($mapHash); html_graph_start_box(1, true); ?> <tr bgcolor="<?php print $colors["panel"]; ?> "> <td> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td class="textHeader" nowrap><?php print $mapTitle; if ($this->isWeathermapAdmin()) { print "<span style='font-size: 80%'>"; print "[ <a href='weathermap-cacti-plugin-mgmt.php?action=map_settings&id=" . $mapID . "'>Map Settings</a> |"; print "<a href='weathermap-cacti-plugin-mgmt.php?action=perms_edit&id=" . $mapID . "'>Map Permissions</a> |"; print "<a href=''>Edit Map</a> ]"; print "</span>"; } ?> </td> </tr> </table> </td> </tr> <tr><td> <?php }