Please make sure IN_MYBB is defined."); } $plugins->add_hook("global_start", "EMS_globals"); $plugins->add_hook("admin_config_menu", "EMS_nav"); $plugins->add_hook("admin_config_action_handler", "EMS_actionhandler"); $plugins->add_hook("admin_load", "EMS_admin"); function ems_info() { return array( "name" => "Emergency Message System", "description" => "This Pluging will display a message to users on every page or just the index page, based on the settings you set.", "website" => "http://nitemare.ca", "author" => "Nitemare", "authorsite" => "http://nitemare.ca", "version" => "4.1.3", "guid" => "", "compatibility" => "14*" ); } function EMS_install(){ global $db; $db->query("CREATE TABLE `".TABLE_PREFIX."ems` ( `eid` int(11) NOT NULL auto_increment, `message` varchar(255) NOT NULL, `type` varchar(100) NOT NULL, `index` tinyint(1) NOT NULL default '1', `author` int(10) NOT NULL, `created` int(25) NOT NULL, `order` smallint(10) NOT NULL default '1', PRIMARY KEY (`eid`) ) ENGINE=MyISAM"); $boardmsg_text_template = array( "title" => "boardmessage_styles", "template" => '', "sid" => "-1", ); $db->insert_query("templates", $boardmsg_text_template); } function EMS_is_installed() { global $db; if($db->table_exists("ems")){ return true; } return false; } function EMS_activate(){ require MYBB_ROOT.'/inc/adminfunctions_templates.php'; find_replace_templatesets( "header", '#'.preg_quote('').'#', '
{$messagestyle}{$boardmessage}' ); } function EMS_deactivate(){ require MYBB_ROOT.'/inc/adminfunctions_templates.php'; find_replace_templatesets( "header", '#'.preg_quote('
{$messagestyle}{$boardmessage}').'#', '', 0 ); } function EMS_uninstall() { global $db; $db->drop_table("ems"); $db->delete_query("templates", "title = 'boardmessage_styles'"); } function EMS_globals(){ global $db, $mybb, $templates, $boardmessage, $messagestyle; $query = $db->query("SELECT * FROM ".TABLE_PREFIX."ems ORDER BY `order` ASC"); $sql = Array(); While ($row = $db->fetch_array($query)){ $sql[]= $row; } $mess = $sql; if (count($mess) != 0 ){ for ($i=0; $i <= $db->num_rows($query)-1; $i++) { if ($mess[$i]['index'] == true){ if ($_SERVER['SCRIPT_FILENAME'] == MYBB_ROOT."index.php"){ $message = $message."

".$mess[$i]['message']."

"; } }else{ $message = $message."

".$mess[$i]['message']."

"; } } } eval("\$messagestyle = \"".$templates->get("boardmessage_styles")."\";"); $boardmessage = doEMSsmilies($message); } function doEMSsmilies($message, $url="") { global $db, $cache; if($url != "") { if(substr($url, strlen($url) -1) != "/") { $url = $url."/"; } } $smiliecache = $cache->read("smilies"); if(is_array($smiliecache)) { reset($smiliecache); foreach($smiliecache as $sid => $smilie) { $message = str_replace($smilie['find'], "".$smilie[", $message); } } return $message; } function EMS_nav($sub_menu){ $sub_menu[] = array( "id" => "ems", "title" => "EMS Alert", "link" => "index.php?module=config/ems" ); } function EMS_actionhandler(&$action) { $action['ems'] = array('active' => 'ems', 'file' => ''); } function EMS_admin(){ global $mybb, $db, $page, $lang; require_once("../inc/functions_time.php"); if($page->active_action != "ems") { return; } if ($mybb->input['add']){ $page->add_breadcrumb_item("EMS system"); $page->output_header("EMS Alert system"); add_form(); $page->output_footer(); exit; }elseif ($mybb->input['do_add']){ $page->add_breadcrumb_item("EMS system"); $page->output_header("EMS Alert system"); if (!$mybb->input['message']){ flash_message("You must enter a message", 'error'); add_form(); }elseif (!$mybb->input['type']){ flash_message("You must select an alert type", 'error'); add_form($mybb->input['message']); }elseif (!$mybb->input['local']){ flash_message("You must select an alert location", 'error'); add_form($mybb->input['message']); }else{ if ($mybb->input['local'] == "index"){ $index = true; }else if ($mybb->input['local'] == "whole"){ $index = false; } $time = adodb_getdate(); $stuff = Array( "message" => $db->escape_string($mybb->input['message']), "type" => $mybb->input['type'], "order" => revert_nums($mybb->input['order']), "created" => $time[0], "index" => $index, "author" => $mybb->user['uid']); $db->insert_query("ems", $stuff); flash_message("Message added sucessfully.", 'success'); admin_redirect("index.php?module=config/ems"); } $page->output_footer(); exit; }elseif ($mybb->input['edit']){ $page->add_breadcrumb_item("EMS system"); $page->output_header("EMS Alert system"); edit_form(); $page->output_footer(); exit; }elseif ($mybb->input['do_edit']){ $page->add_breadcrumb_item("EMS system"); $page->output_header("EMS Alert system"); if (!$mybb->input['message']){ flash_message("You must enter a message", 'error'); edit_form(); }elseif (!$mybb->input['type']){ flash_message("You must select an alert type", 'error'); edit_form(); }elseif (!$mybb->input['local']){ flash_message("You must select an alert location", 'error'); add_form($mybb->input['message']); }else{ if ($mybb->input['local'] == "index"){ $index = true; }else if ($mybb->input['local'] == "whole"){ $index = false; } $stuff = Array( "message" => $db->escape_string($mybb->input['message']), "order" => revert_nums($mybb->input['order']), "type" => $mybb->input['type'], "index" => $index); $db->update_query("ems", $stuff, "eid = '".$mybb->input['eid']."'"); flash_message("Message with ID:".$mybb->input['eid']." edited sucessfully.", 'success'); admin_redirect("index.php?module=config/ems"); } $page->output_footer(); exit; }elseif ($mybb->input['delete']){ $query = $db->query("SELECT * FROM ".TABLE_PREFIX."ems WHERE eid = '".$mybb->input['eid']."'"); $message = $db->fetch_array($query); $page->add_breadcrumb_item("EMS system"); $page->output_header("EMS Alert system"); $form = new Form("index.php?module=config/ems", "post"); $table = new Table; $table->construct_header("Delete Alert",array('class' => 'align_center', 'colspan' => 1)); $table->construct_cell("Are you sure you want to delete the message with ID:".$message['eid']." and starting: ".turn($message['message']),array('class' => 'align_center')); $table->construct_row(); $table->construct_cell($form->generate_hidden_field('eid', $message['eid']). $form->generate_submit_button("Delete", array('name' => 'do_delete')) ." ". $form->generate_submit_button("Cancel", array('name' => 'cancel')) ,array('class' => 'align_center')); $table->construct_row(); $table->output("
Emergency Message System
"); $form->end(); $page->output_footer(); exit; }elseif ($mybb->input['do_delete']){ $db->delete_query("ems", "eid = '".$mybb->input['eid']."'"); flash_message("Message with ID:".$mybb->input['eid']." deleted sucessfully.", 'success'); admin_redirect("index.php?module=config/ems"); }else{ $query = $db->query("SELECT * FROM ".TABLE_PREFIX."ems"); $sql = Array(); While ($row = $db->fetch_array($query)){ $sql[]= $row; } $mess = $sql; $page->add_breadcrumb_item("EMS system"); $page->output_header("EMS Alert system"); $table = new Table; $table->construct_header("EMS Current Alerts",array('class' => 'align_center', 'colspan' => 6)); $form = new Form("index.php?module=config/ems", "post"); $table->construct_cell("Alert ID",array('class' => 'align_center','width' => '65')); $table->construct_cell("Alert Message",array('class' => 'align_center')); $table->construct_cell("Display Order", array('class' => 'align_center','width' => '100')); $table->construct_cell("Alert Type", array('class' => 'align_center','width' => '100')); $table->construct_cell("Created", array('class' => 'align_center','width' => '175')); $table->construct_cell("Author", array('class' => 'align_center','width' => '250')); $table->construct_row(); for ($i = 0; $i <= count($mess)-1; $i++) { switch($mess[$i]['type']){ Case "yellow": $colour = "#FFF6BF"; break; Case "blue": $colour = "#ADCBE7"; break; Case "red": $colour = "#FFB2B2"; break; Case "green": $colour = "#D6ECA6"; break; Case "black": $colour = "#B2B2B2"; break; Case "purple": $colour = "#E0B2FF"; break; Case "orange": $colour = "#FFC57F"; break; Case "light_blue": $colour = "#9BFFFF"; break; } switch($mess[$i]['index']){ Case true: $index = "Index Only"; break; Case false: $index = "Whole site"; break; } $table->construct_cell($form->generate_radio_button("eid", $mess[$i]['eid'], $mess[$i]['eid']),array('class' => 'align_center','style' => 'background: '.$colour.';', 'width' => '75')); $table->construct_cell(doEMSsmilies($mess[$i]['message'],"../"),array('class' => 'align_center','style' => 'background: '.$colour.';')); $table->construct_cell($mess[$i]['order'],array('class' => 'align_center','style' => 'background: '.$colour.';')); $table->construct_cell(ucfirst($mess[$i]['type'])."
".$index,array('class' => 'align_center','style' => 'background: '.$colour.';','width' => '100')); $user = get_user($mess[$i]['author']); //adodb_date() //$mess[$i]['created'] $temp = adodb_getdate(); $table->construct_cell( adodb_date("d/m/Y h:i:s A",$mess[$i]['created']),array('class' => 'align_center','style' => 'background: '.$colour.';','width' => '175')); $table->construct_cell($user['username'],array('class' => 'align_center','style' => 'background: '.$colour.';','width' => '250')); $table->construct_row(); } $table->construct_cell( $form->generate_submit_button("Add", array('name' => 'add')) ." ". $form->generate_submit_button("Edit", array('name' => 'edit')) ." ". $form->generate_submit_button("Delete", array('name' => 'delete')) ,array('colspan' => '6','class' => 'align_center')); $table->construct_row(); $table->output("
Emergency Message System
"); $form->end(); $page->output_footer(); exit; } } function turn($data, $length="25"){ if (strlen($data) >= $length){ return substr($data,0,$length-3)."..."; }else{ return $data; } } function Add_form($message_text = ""){ global $db, $mybb, $page; $form = new Form("index.php?module=config/ems", "post"); $table = new Table; $table->construct_header("Add Alert",array('class' => 'align_center', 'colspan' => 1)); $table->construct_cell($form->generate_text_area("message",$message_text),array('class' => 'align_center')); $table->construct_row(); $options = ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $table->construct_cell("Alert Location: ".$form->generate_radio_button("local","index","Index Only",Array("checked" => 1))." ".$form->generate_radio_button("local","whole","Whole Site")."
Alert Type:   Display Order: ",array('class' => 'align_center')); $table->construct_row(); $table->construct_cell( $form->generate_submit_button("Add", array('name' => 'do_add')) ." ". $form->generate_reset_button("Reset", array('name' => 'reset')) ,array('class' => 'align_center')); $table->construct_row(); $table->output("
Emergency Message System
"); $form->end(); } function edit_form(){ global $db, $mybb, $page; if (!$mybb->input['eid']){ flash_message("You must select an alert first.", 'error'); admin_redirect("index.php?module=config/ems"); } $query = $db->query("SELECT * FROM ".TABLE_PREFIX."ems WHERE eid = '".$mybb->input['eid']."'"); $message = $db->fetch_array($query); $form = new Form("index.php?module=config/ems", "post"); $table = new Table; $table->construct_header("Edit Alert, Id:".$mybb->input['eid'],array('class' => 'align_center', 'colspan' => 1)); $table->construct_cell($form->generate_text_area("message", $message['message']),array('class' => 'align_center')); $table->construct_row(); if ($message["type"] == "red"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "blue"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "green"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "yellow"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "black"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "purple"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "orange"){ $options .= ""; }else{ $options .= ""; } if ($message["type"] == "light_blue"){ $options .= ""; }else{ $options .= ""; } if ($message["index"] == true){ $radio1 = Array("checked" => 1); }else{ $radio2 = Array("checked" => 1); } $table->construct_cell("Alert Location: ".$form->generate_radio_button("local","index","Index Only", $radio1)." ".$form->generate_radio_button("local","whole","Whole Site",$radio2)."
Alert Type:   Display Order: ",array('class' => 'align_center')); $table->construct_row(); $table->construct_cell($form->generate_hidden_field('eid', $message['eid']). $form->generate_submit_button("Edit", array('name' => 'do_edit')) ." ". $form->generate_reset_button("Reset", array('name' => 'reset')) ,array('class' => 'align_center')); $table->construct_row(); $table->output("
Emergency Message System
"); $form->end(); } function select_order_options($premade = ""){ if ($premade == "1" || !$premade){ $options .= ""; }else{ $options .= ""; } if ($premade == "2"){ $options .= ""; }else{ $options .= ""; } if ($premade == "3"){ $options .= ""; }else{ $options .= ""; } if ($premade == "4"){ $options .= ""; }else{ $options .= ""; } if ($premade == "5"){ $options .= ""; }else{ $options .= ""; } if ($premade == "6"){ $options .= ""; }else{ $options .= ""; } if ($premade == "7"){ $options .= ""; }else{ $options .= ""; } if ($premade == "2"){ $options .= ""; }else{ $options .= ""; } if ($premade == "2"){ $options .= ""; }else{ $options .= ""; } if ($premade == "2"){ $options .= ""; }else{ $options .= ""; } return $options; } function revert_nums($value){ switch($value){ Case "one": $returner = "1"; break; Case "two": $returner = "2"; break; Case "three": $returner = "3"; break; Case "four": $returner = "4"; break; Case "five": $returner = "5"; break; Case "six": $returner = "6"; break; Case "seven": $returner = "7"; break; Case "eight": $returner = "8"; break; Case "nine": $returner = "9"; break; Case "ten": $returner = "10"; break; } return $returner; } ?> LRIG Bay Area Forums
The following warnings occurred:
Warning [2] Cannot modify header information - headers already sent by (output started at /home/httpd/lrigbayarea/forums/inc/plugins/ems.php:661) - Line: 1680 - File: inc/functions.php PHP 5.3.3 (Linux)
File Line Function
[PHP]   errorHandler->error
/inc/functions.php 1680 header
/inc/class_session.php 360 my_setcookie
/inc/class_session.php 98 session->load_guest
/global.php 55 session->init
/memberlist.php 17 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/httpd/lrigbayarea/forums/inc/plugins/ems.php:661) - Line: 1680 - File: inc/functions.php PHP 5.3.3 (Linux)
File Line Function
[PHP]   errorHandler->error
/inc/functions.php 1680 header
/inc/class_session.php 365 my_setcookie
/inc/class_session.php 98 session->load_guest
/global.php 55 session->init
/memberlist.php 17 require_once
Warning [2] Cannot modify header information - headers already sent by (output started at /home/httpd/lrigbayarea/forums/inc/plugins/ems.php:661) - Line: 1680 - File: inc/functions.php PHP 5.3.3 (Linux)
File Line Function
[PHP]   errorHandler->error
/inc/functions.php 1680 header
/inc/class_session.php 106 my_setcookie
/global.php 55 session->init
/memberlist.php 17 require_once







LRIG Bay Area Forums
You are either not logged in or do not have permission to view this page. This could be because one of the following reasons:
  1. You are not logged in or registered. Please use the form at the bottom of this page to login.
  2. You do not have permission to access this page. Are you trying to access administrative pages or a resource that you shouldn't be? Check in the forum rules that you are allowed to perform this action.
  3. Your account may have been disabled by an administrator, or it may be awaiting account activation.
  4. You have accessed this page directly rather than using appropriate forms or links.
Login
Password:
Need to register? | Forgotten your password?