Example #1
0
 /**
  * Get supported HTML5 formats
  * @return array Return array of formats
  */
 public function getSupportedHTML5Formats()
 {
     $browser = $this->detectSupportedFormats();
     $formats = $this->getSupportedFormats();
     $html5 = array("oga", "mp3", "m4a", "wav");
     $final = array();
     $missing = array();
     $unsupported = array();
     foreach ($html5 as $i) {
         if (in_array($i, $browser) && in_array($i, $formats['out'])) {
             $final[] = $i;
         } elseif (in_array($i, $browser) && !in_array($i, $formats['out'])) {
             $missing[] = $i;
         } else {
             $unsupported[] = $i;
         }
     }
     $nt = notifications::create();
     $mmm = $this->getConfig('mediamissingmessage');
     if (!empty($missing) && empty($mmm)) {
         $brand = $this->FreePBX->Config->get("DASHBOARD_FREEPBX_BRAND");
         $nt->add_notice("framework", "missing_html5", _("Missing HTML5 format converters"), sprintf(_("You are missing support for the following HTML5 codecs: %s. To fully support HTML5 browser playback you will need to install programs that can not be distributed with %s. If you'd like to install the binaries needed for these conversions click 'Resolve' in the lower left corner of this message. You can also safely ignore this message but browser playback might not work in your browser."), implode(",", $missing), $brand), "http://wiki.freepbx.org/display/FOP/Installing+Media+Conversion+Libraries", true, true);
         $this->setConfig('mediamissingmessage', true);
     } elseif (empty($missing) && !empty($mmm)) {
         $nt->delete("framework", "missing_html5");
         $this->setConfig('mediamissingmessage', false);
     }
     return !empty($final[0]) ? array($final[0]) : array();
 }
function weakpasswords_get_config($engine)
{
    switch ($engine) {
        case "asterisk":
            // Clear all weak password notifications
            $nt = notifications::create($db);
            $security_notifications = $nt->list_security();
            foreach ($security_notifications as $notification) {
                if ($notification['module'] == "weakpasswords") {
                    $nt->delete($notification['module'], $notification['id']);
                }
            }
            // Generate new notifications
            $weak = weakpasswords_get_users();
            if (sizeof($weak) > 0) {
                $extended_text = _("Warning: The use of weak SIP/IAX passwords can compromise this system resulting in toll theft of your telephony service.  You should change the reported devices and trunks to use strong secrets.") . "<br /><br />";
                $count = 0;
                foreach ($weak as $details) {
                    $extended_text .= sprintf(_("%s: %s / %s<br>"), $details['deviceortrunk'], $details['name'], $details['message']);
                    $count++;
                }
                if ($count == 1) {
                    $nt->add_security("weakpasswords", "all", $count . " " . _("extension/trunk has weak secret"), $extended_text);
                } else {
                    $nt->add_security("weakpasswords", "all", $count . " " . _("extensions/trunks have weak secrets"), $extended_text);
                }
            }
            break;
    }
}
Example #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $args = $input->getArgument('args');
     $nt = \notifications::create();
     if ($input->getOption('list')) {
         $notifications = array();
         foreach ($nt->list_all() as $notif) {
             $notifications[] = array($notif['module'], $notif['id'], $notif['display_text']);
         }
         if ($input->getOption('json')) {
             $output->writeln(json_encode($notifications));
         } else {
             $table = new Table($output);
             $table->setHeaders(array('Module', 'ID', 'Text'))->setRows($notifications);
             $table->render();
         }
     }
     if ($input->getOption('delete')) {
         if (!isset($args[1])) {
             $output->writeln("Usage: fwconsole notifications --delete module id");
         }
         if ($nt->exists($args[0], $args[1])) {
             $output->writeln("Deleting notification");
             $nt->delete($args[0], $args[1]);
             if (!$nt->exists($args[0], $args[1])) {
                 $output->writeln("Notification Deleted");
             } else {
                 $output->writeln("Notification did not delete");
             }
         } else {
             $output->writeln("Specified notification does not exist");
         }
     }
 }
Example #4
0
 function __construct($mode = 'local')
 {
     if ($mode == 'local') {
         //Setup our objects for use
         //FreePBX is the FreePBX Object
         $this->FreePBX = \FreePBX::create();
         //UCP is the UCP Specific Object from BMO
         $this->Ucp = $this->FreePBX->Ucp;
         //System Notifications Class
         //TODO: pull this from BMO
         $this->notifications = \notifications::create();
         //database subsystem
         $this->db = $this->FreePBX->Database;
         //This causes crazy errors later on. Dont use it
         //$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     }
     $this->emoji = new Client(new Ruleset());
     $this->emoji->imagePathPNG = 'assets/images/emoji/png/';
     // defaults to jsdelivr's free CDN
     $this->emoji->imagePathSVG = 'assets/images/emoji/svg/';
     // defaults to jsdelivr's free CDN
     $this->detect = new \Mobile_Detect();
     // Ensure the local object is available
     self::$uobj = $this;
 }
Example #5
0
 function index()
 {
     if (isset($_GET['key'])) {
         $frontlinesms_key = $_GET['key'];
     }
     if (isset($_GET['s'])) {
         $message_from = $_GET['s'];
         // Remove non-numeric characters from string
         $message_from = ereg_replace("[^0-9]", "", $message_from);
     }
     if (isset($_GET['m'])) {
         $message_description = $_GET['m'];
     }
     if (!empty($frontlinesms_key) && !empty($message_from) && !empty($message_description)) {
         // Is this a valid FrontlineSMS Key?
         $keycheck = ORM::factory('settings', 1)->where('frontlinesms_key', $frontlinesms_key)->find();
         if ($keycheck->loaded == TRUE) {
             $services = new Service_Model();
             $service = $services->where('service_name', 'SMS')->find();
             if (!$service) {
                 return;
             }
             $reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message_from)->find();
             if (!$reporter->loaded == TRUE) {
                 // get default reporter level (Untrusted)
                 $level = ORM::factory('level')->where('level_weight', 0)->find();
                 $reporter->service_id = $service->id;
                 $reporter->level_id = $level->id;
                 $reporter->service_userid = null;
                 $reporter->service_account = $message_from;
                 $reporter->reporter_first = null;
                 $reporter->reporter_last = null;
                 $reporter->reporter_email = null;
                 $reporter->reporter_phone = null;
                 $reporter->reporter_ip = null;
                 $reporter->reporter_date = date('Y-m-d');
                 $reporter->save();
             }
             // Save Message
             $message = new Message_Model();
             $message->parent_id = 0;
             $message->incident_id = 0;
             $message->user_id = 0;
             $message->reporter_id = $reporter->id;
             $message->message_from = $message_from;
             $message->message_to = null;
             $message->message = $message_description;
             $message->message_type = 1;
             // Inbox
             $message->message_date = date("Y-m-d H:i:s", time());
             $message->service_messageid = null;
             $message->save();
             // Notify Admin Of New Email Message
             $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_sms.subject'), Kohana::lang('notifications.admin_new_sms.message'));
         }
     }
 }
Example #6
0
function fatal($text, $extended_text = "", $type = "FATAL")
{
    global $db;
    echo "[{$type}] " . $text . " " . $extended_text . "\n";
    if (!DB::isError($db)) {
        $nt = notifications::create($db);
        $nt->add_critical('cron_manager', $type, $text, $extended_text);
    }
    exit(1);
}
Example #7
0
 public static function installed()
 {
     $loc = fpbx_which("sox");
     $process = new Process($loc . ' --version');
     $process->run();
     // executes after the command finishes
     $nt = \notifications::create();
     if (!$process->isSuccessful()) {
         $nt->add_warning("FRAMEWORK", "MISSING_SOX", _("System is missing SOX"), _("To perform the minimal amount of file conversions for HTML5 support and conversion support you need to at least install SOX"), "http://wiki.freepbx.org/display/FOP/Installing+Media+Conversion+Libraries");
         return false;
     } else {
         $nt->delete("FRAMEWORK", "MISSING_SOX");
     }
     return true;
 }
Example #8
0
function frameworkPasswordCheck()
{
    global $amp_conf, $db;
    $nt = notifications::create($db);
    // Moved most of the other checks to retrieve_conf to avoid running every page load. These have been left
    // here becuase both of these settings could be affected differently in the php apache related settings vs.
    // what retrieve_conf would see running the CLI version of php
    //
    // send error if magic_quotes_gpc is enabled on this system as much of the code base assumes not
    //
    if (get_magic_quotes_gpc()) {
        $nt->add_error('core', 'MQGPC', _("Magic Quotes GPC"), _("You have magic_quotes_gpc enabled in your php.ini, http or .htaccess file which will cause errors in some modules. FreePBX expects this to be off and runs under that assumption"));
    } else {
        $nt->delete('core', 'MQGPC');
    }
}
Example #9
0
 function __construct($mode = 'local')
 {
     if ($mode == 'local') {
         //Setup our objects for use
         //FreePBX is the FreePBX Object
         $this->FreePBX = \FreePBX::create();
         //UCP is the UCP Specific Object from BMO
         $this->Ucp = $this->FreePBX->Ucp;
         //System Notifications Class
         //TODO: pull this from BMO
         $this->notifications = \notifications::create();
         //database subsystem
         $this->db = $this->FreePBX->Database;
         //This causes crazy errors later on. Dont use it
         //$this->db->setAttribute(\PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
     }
     $this->detect = new \Mobile_Detect();
     // Ensure the local object is available
     self::$obj = $this;
 }
Example #10
0
$projects_active = $grey_main && $kind != 8 && $kind != 2 && $kind != 4;
$konkurs_active = $grey_main && $kind == 2;
$vacancy_active = $grey_main && $kind == 4;
$grey_catalog = isset($grey_catalog) && @$grey_catalog == 1;
//Уведомления ЛС
$tip_msg = notifications::getMessTip();
//Уведомления по БС
$tip_sbr = notifications::getAllSbrTip();
$link_sbr = '/' . sbr::NEW_TEMPLATE_SBR . '/';
//Уведомления гуповое по проектам и заказам
//$tip_group = notifications::getEmpGroupTip();
//Уведомления и ссылки для Проектов
$tip_prj = notifications::getProjectsTipEmp();
//Уведомления и ссылки для Заказов ТУ
if (@$_SESSION['tu_orders']) {
    $tip_tu = notifications::getTServicesOrdersTip();
}
$account_sum_is_plus = $_SESSION['ac_sum'] >= 0;
$account_sum_format = view_account_format();
?>
<script type="text/javascript">
var notification_delay = '<?php 
echo NOTIFICATION_DELAY;
?>
';
var prj_check_delay = '<?php 
echo PRJ_CHECK_DELAY;
?>
';
</script>
 /**
  * Displays a report.
  * @param boolean $id If id is supplied, a report with that id will be
  * retrieved.
  */
 public function view($id = FALSE)
 {
     $this->template->header->this_page = 'reports';
     $this->template->content = new View('reports/detail');
     // Load Akismet API Key (Spam Blocker)
     $api_akismet = Kohana::config('settings.api_akismet');
     // Sanitize the report id before proceeding
     $id = intval($id);
     if ($id > 0) {
         $incident = ORM::factory('sharing_incident')->where('id', $id)->where('incident_active', 1)->find();
         // Not Found
         if (!$incident->loaded) {
             url::redirect('reports/');
         }
         // Comment Post?
         // Setup and initialize form field names
         $form = array('comment_author' => '', 'comment_description' => '', 'comment_email' => '', 'comment_ip' => '', 'captcha' => '');
         $captcha = Captcha::factory();
         $errors = $form;
         $form_error = FALSE;
         // Check, has the form been submitted, if so, setup validation
         if ($_POST and Kohana::config('settings.allow_comments')) {
             // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
             $post = Validation::factory($_POST);
             // Add some filters
             $post->pre_filter('trim', TRUE);
             // Add some rules, the input field, followed by a list of checks, carried out in order
             if (!$this->user) {
                 $post->add_rules('comment_author', 'required', 'length[3,100]');
                 $post->add_rules('comment_email', 'required', 'email', 'length[4,100]');
             }
             $post->add_rules('comment_description', 'required');
             $post->add_rules('captcha', 'required', 'Captcha::valid');
             // Test to see if things passed the rule checks
             if ($post->validate()) {
                 // Yes! everything is valid
                 if ($api_akismet != "") {
                     // Run Akismet Spam Checker
                     $akismet = new Akismet();
                     // Comment data
                     $comment = array('website' => "", 'body' => $post->comment_description, 'user_ip' => $_SERVER['REMOTE_ADDR']);
                     if ($this->user) {
                         $comment['author'] = $this->user->name;
                         $comment['email'] = $this->user->email;
                     } else {
                         $comment['author'] = $post->comment_author;
                         $comment['email'] = $post->comment_email;
                     }
                     $config = array('blog_url' => url::site(), 'api_key' => $api_akismet, 'comment' => $comment);
                     $akismet->init($config);
                     if ($akismet->errors_exist()) {
                         if ($akismet->is_error('AKISMET_INVALID_KEY')) {
                             // throw new Kohana_Exception('akismet.api_key');
                         } elseif ($akismet->is_error('AKISMET_RESPONSE_FAILED')) {
                             // throw new Kohana_Exception('akismet.server_failed');
                         } elseif ($akismet->is_error('AKISMET_SERVER_NOT_FOUND')) {
                             // throw new Kohana_Exception('akismet.server_not_found');
                         }
                         $comment_spam = 0;
                     } else {
                         $comment_spam = $akismet->is_spam() ? 1 : 0;
                     }
                 } else {
                     // No API Key!!
                     $comment_spam = 0;
                 }
                 $comment = new Comment_Model();
                 $comment->incident_id = 0;
                 if ($this->user) {
                     $comment->user_id = $this->user->id;
                     $comment->comment_author = $this->user->name;
                     $comment->comment_email = $this->user->email;
                 } else {
                     $comment->comment_author = strip_tags($post->comment_author);
                     $comment->comment_email = strip_tags($post->comment_email);
                 }
                 $comment->comment_description = strip_tags($post->comment_description);
                 $comment->comment_ip = $_SERVER['REMOTE_ADDR'];
                 $comment->comment_date = date("Y-m-d H:i:s", time());
                 // Activate comment for now
                 if ($comment_spam == 1) {
                     $comment->comment_spam = 1;
                     $comment->comment_active = 0;
                 } else {
                     $comment->comment_spam = 0;
                     $comment->comment_active = Kohana::config('settings.allow_comments') == 1 ? 1 : 0;
                 }
                 $comment->save();
                 // link comment to sharing_incident
                 $incident_comment = ORM::factory('sharing_incident_comment');
                 $incident_comment->comment_id = $comment->id;
                 $incident_comment->sharing_incident_id = $incident->id;
                 $incident_comment->save();
                 // Event::comment_add - Added a New Comment
                 Event::run('ushahidi_action.comment_add', $comment);
                 // Notify Admin Of New Comment
                 $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . utf8::strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/sharing/view/' . $id);
                 // Redirect
                 url::redirect('reports/sharing/view/' . $id);
             } else {
                 // No! We have validation errors, we need to show the form again, with the errors
                 // Repopulate the form fields
                 $form = arr::overwrite($form, $post->as_array());
                 // Populate the error fields, if any
                 $errors = arr::overwrite($errors, $post->errors('comments'));
                 $form_error = TRUE;
             }
         }
         // Filters
         $incident_title = $incident->incident_title;
         $incident_description = $incident->incident_description;
         Event::run('ushahidi_filter.report_title', $incident_title);
         Event::run('ushahidi_filter.report_description', $incident_description);
         $this->template->header->page_title .= $incident_title . Kohana::config('settings.title_delimiter');
         // Add Features
         // hardcode geometries to empty
         $this->template->content->features_count = 0;
         $this->template->content->features = array();
         $this->template->content->incident_id = $incident->id;
         $this->template->content->incident_title = $incident_title;
         $this->template->content->incident_description = $incident_description;
         $this->template->content->incident_location = $incident->location->location_name;
         $this->template->content->incident_latitude = $incident->location->latitude;
         $this->template->content->incident_longitude = $incident->location->longitude;
         $this->template->content->incident_date = date('M j Y', strtotime($incident->incident_date));
         $this->template->content->incident_time = date('H:i', strtotime($incident->incident_date));
         $this->template->content->incident_category = ORM::factory('sharing_incident_category')->where('sharing_incident_id', $incident->id)->find_all();
         // Incident rating
         $rating = ORM::factory('rating')->join('incident', 'incident.id', 'rating.incident_id', 'INNER')->where('rating.incident_id', $incident->id)->find();
         $this->template->content->incident_rating = $rating->rating == '' ? 0 : $rating->rating;
         // Retrieve Media
         $incident_news = array();
         $incident_video = array();
         $incident_photo = array();
         foreach ($incident->media as $media) {
             if ($media->media_type == 4) {
                 $incident_news[] = $media->media_link;
             } elseif ($media->media_type == 2) {
                 $incident_video[] = $media->media_link;
             } elseif ($media->media_type == 1) {
                 $incident_photo[] = array('large' => url::convert_uploaded_to_abs($media->media_link), 'thumb' => url::convert_uploaded_to_abs($media->media_thumb));
             }
         }
         $this->template->content->incident_verified = $incident->incident_verified;
         // Retrieve Comments (Additional Information)
         $this->template->content->comments = "";
         if (Kohana::config('settings.allow_comments')) {
             $this->template->content->comments = new View('reports/comments');
             $incident_comments = array();
             if ($id) {
                 $incident_comments = Sharing_Incident_Model::get_comments($id);
             }
             $this->template->content->comments->incident_comments = $incident_comments;
         }
     } else {
         url::redirect('reports');
     }
     // Add extra info to meta
     Event::add('ushahidi_action.report_display_media', array($this, 'report_display_media'));
     // Add Neighbors
     $this->template->content->incident_neighbors = Sharing_Incident_Model::get_neighbouring_incidents($id, TRUE, 0, 5);
     // News Source links
     $this->template->content->incident_news = $incident_news;
     // Video links
     $this->template->content->incident_videos = $incident_video;
     // Images
     $this->template->content->incident_photos = $incident_photo;
     // Create object of the video embed class
     $video_embed = new VideoEmbed();
     $this->template->content->videos_embed = $video_embed;
     // Javascript Header
     $this->themes->map_enabled = TRUE;
     $this->themes->photoslider_enabled = TRUE;
     $this->themes->videoslider_enabled = TRUE;
     $this->themes->js = new View('reports/view_js');
     $this->themes->js->incident_id = $incident->id;
     $this->themes->js->incident_json_url = 'json/share/single/' . $incident->id;
     $this->themes->js->default_map = Kohana::config('settings.default_map');
     $this->themes->js->default_zoom = Kohana::config('settings.default_zoom');
     $this->themes->js->latitude = $incident->location->latitude;
     $this->themes->js->longitude = $incident->location->longitude;
     $this->themes->js->incident_zoom = null;
     //$incident->incident_zoom;
     $this->themes->js->incident_photos = $incident_photo;
     // Initialize custom field array
     $this->template->content->custom_forms = new View('reports/detail_custom_forms');
     $form_field_names = customforms::get_custom_form_fields($id, 1, FALSE, "view");
     $this->template->content->custom_forms->form_field_names = $form_field_names;
     // Are we allowed to submit comments?
     $this->template->content->comments_form = "";
     if (Kohana::config('settings.allow_comments')) {
         $this->template->content->comments_form = new View('reports/comments_form');
         $this->template->content->comments_form->user = $this->user;
         $this->template->content->comments_form->form = $form;
         $this->template->content->comments_form->form_field_names = $form_field_names;
         $this->template->content->comments_form->captcha = $captcha;
         $this->template->content->comments_form->errors = $errors;
         $this->template->content->comments_form->form_error = $form_error;
     }
     // If the Admin is Logged in - Allow for an edit link
     $this->template->content->logged_in = $this->logged_in;
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
     $this->template->footer->footer_block = $this->themes->footer_block();
 }
Example #12
0
 /**
  * Hook Definitions
  * @param {string} $conf The Configuration being passed through
  */
 public function writeConfig($conf)
 {
     //we also need to do port checking and if in chan sip mode port on 5060, if in both mode then put if on 5061
     $nt = \notifications::create();
     $ast_sip_driver = $this->freepbx->Config->get_conf_setting('ASTSIPDRIVER');
     if (version_compare($this->version, '12', 'ge')) {
         if ($ast_sip_driver == 'both') {
             $this->freepbx->ModulesConf->removenoload("chan_sip.so");
             foreach ($this->PJSipModules as $mod) {
                 $this->freepbx->ModulesConf->removenoload($mod);
             }
         } elseif ($ast_sip_driver == 'chan_pjsip') {
             $this->enablePJSipModules();
         } elseif ($ast_sip_driver == 'chan_sip') {
             $this->disablePJSipModules();
         }
     } else {
         // We don't support pjsip. If we're trying to use it, don't. Note
         // that if there are devices or trunks trying to use chan_pjsip, we
         // complain loudly about it core_devices_configpageload
         if ($ast_sip_driver == 'chan_pjsip' || $ast_sip_driver == 'both') {
             $this->freepbx->Config->set_conf_values(array('ASTSIPDRIVER' => 'chan_sip'), true, true);
         }
     }
     $this->freepbx->WriteConfig($conf);
 }
Example #13
0
 private function createIntermediaries()
 {
     //generate intermediary file
     $ts = time() . rand(0, 1000);
     $soxClass = "Media\\Driver\\Drivers\\SoxShell";
     if (!$soxClass::installed()) {
         throw new \Exception("Sox needs to be installed");
     }
     //Convert everything to 48k, so we upscale and downscale
     //This is on purpose.
     //Transform into a wav file
     foreach ($this->getDrivers() as $driver) {
         if ($this->extension == "wav" && $driver == "AsteriskShell") {
             continue;
             //just dont allow it
         }
         $class = "Media\\Driver\\Drivers\\" . $driver;
         if ($class::installed() && $class::isCodecSupported($this->extension, "in")) {
             $d = new $class($this->track, $this->extension, $this->mime, 48000, 1, 16);
             $d->convert($this->tempDir . "/temp." . $ts . ".wav", "wav", "audio/x-wav");
             $intermediary['wav']['path'] = $this->tempDir . "/temp." . $ts . ".wav";
             $intermediary['wav']['extension'] = "wav";
             $intermediary['wav']['mime'] = "audio/x-wav";
             break;
         }
     }
     if (!isset($intermediary['wav']['path']) || !file_exists($intermediary['wav']['path'])) {
         throw new \Exception(sprintf(_("Unable to find an intermediary converter for %s"), $this->track));
     }
     //Asterisk 11 should support sln48 but it doesnt, it says it does but then complains
     //It might be a bug, regardless this is fixed in 13 people should just use it
     $ver = \FreePBX::Config()->get("ASTVERSION");
     if (version_compare_freepbx($ver, "13.0", "ge") && \Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln48", "in")) {
         $type = "sln48";
         $samplerate = 48000;
     } elseif (\Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln16", "in")) {
         $type = "sln16";
         $samplerate = 16000;
     } else {
         $type = "wav16";
         $samplerate = 16000;
     }
     $nt = \notifications::create();
     if (version_compare_freepbx($ver, "13.0", "ge") && !\Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln48", "in")) {
         //something is wacky here
         $nt->add_warning("FRAMEWORK", "UNSUPPORTED_SLN48", _("The file format sln48 is not supported on your system"), _("The file format sln48 is not supported by Asterisk when it should be. Audio conversion quality will be limited to 16k instead of 48k"));
     } else {
         $nt->delete("FRAMEWORK", "UNSUPPORTED_SLN48");
     }
     //Now transform into a raw audio file
     $d = new $soxClass($intermediary['wav']['path'], $intermediary['wav']['extension'], $intermediary['wav']['mime'], $samplerate, 1, 16);
     $d->convert($this->tempDir . "/temp." . $ts . "." . $type, $type, "audio/x-raw");
     $intermediary['sln']['path'] = $this->tempDir . "/temp." . $ts . "." . $type;
     $intermediary['sln']['extension'] = $type;
     $intermediary['sln']['mime'] = "audio/x-raw";
     if (empty($intermediary)) {
         throw new \Exception("No Driver found for " . $this->extension);
     }
     if (!file_exists($intermediary['wav']['path']) || !file_exists($intermediary['sln']['path'])) {
         throw new \Exception("Intermediary files could not be created");
     }
     return $intermediary;
 }
Example #14
0
        <script src="http://www.formmail-maker.com/var/demo/jquery-popup-form/jquery.colorbox-min.js"></script>
        <script type="text/javascript" language="javascript" src="http://cdn.datatables.net/1.10.1/js/jquery.dataTables.min.js"></script>
        <script>
            $(document).ready(function () {
                $(".iframe").colorbox({iframe: true, fastIframe: false, width: "500px", height: "480px", transition: "fade", scrolling: false});
                $('#datatable').dataTable();
            });
        </script>
        <style>
            #cboxOverlay{background:#666666;}
            .iframe{margin-left: 5px;}
        </style>
        <?php 
include "configure/connectivity.php";
include "configure/class.notifications.php";
$obj = new notifications();
?>
    </head>
    <body> <?php 
include_once 'include/menu.php';
?>
        <div class="content1">
            <div class="welcome"><h3>Welcome <?php 
echo $_SESSION['username'];
?>
!</h3></div>
            <table id="datatable" class="display" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <td><b>S.no</b></td>
                        <td><b>Notification</b></td>
Example #15
0
function fax_get_destinations()
{
    global $db;
    $sql = "SELECT fax_users.user,fax_users.faxemail,fax_users.faxattachformat FROM fax_users where fax_users.faxenabled = 'true' ORDER BY fax_users.user";
    $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
    if (DB::IsError($results)) {
        die_freepbx($results->getMessage() . "<br><br>Error selecting from fax");
    }
    $final = array();
    $warning = array();
    foreach ($results as $res) {
        $o = \FreePBX::Userman()->getUserByID($res['user']);
        if (!empty($o)) {
            if (empty($o['email'])) {
                $warning[] = $o['username'];
                continue;
            }
            $res['uname'] = $o['username'];
            $res['name'] = !empty($o['displayname']) ? $o['displayname'] : $o['fname'] . " " . $o['lname'];
            $res['name'] = trim($res['name']);
            $res['name'] = !empty($res['name']) ? $res['name'] : $o['username'];
            $final[] = $res;
        }
    }
    $nt = \notifications::create();
    if (!empty($warning)) {
        $nt->add_warning("fax", "invalid_email", _("Invalid Email for Inbound Fax"), sprintf(_("User Manager users '%s' have the ability to receive faxes but have no email address defined so they will not be able to receive faxes."), implode(",", $warning)), "", true, true);
    } else {
        $nt->delete("fax", "invalid_email");
    }
    return $final;
}
#!/usr/bin/php -q
<?php 
//include bootstrap
//	License for all code of this FreePBX module can be found in the license file inside the module directory
//	Copyright 2013-2015 Schmooze Com Inc.
//
$bootstrap_settings['freepbx_auth'] = false;
if (!@(include_once getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
    include_once '/etc/asterisk/freepbx.conf';
}
// Define the notification class for logging to the dashboard
//
$nt = notifications::create($db);
// Check to see if email should be sent
//
$cm =& cronmanager::create($db);
$cm->run_jobs();
//If we have sysadmin installed
$from_email = get_current_user() . '@' . gethostname();
if (function_exists('sysadmin_get_storage_email')) {
    $emails = sysadmin_get_storage_email();
    //Check that what we got back above is a email address
    if (!empty($emails['fromemail']) && filter_var($emails['fromemail'], FILTER_VALIDATE_EMAIL)) {
        //Fallback address
        $from_email = $emails['fromemail'];
    }
}
//Send email with our mail class
function chron_scheduler_send_message($to, $from, $subject, $message)
{
    $em = new \CI_Email();
Example #17
0
function setReadAllProject()
{
    session_start();
    $objResponse = new xajaxResponse();
    if (is_emp()) {
        projects::SetReadAll(get_uid(false));
        $tip = notifications::getEmpGroupTip();
        $objResponse->script("\n            \$('new_offers_content').dispose();\n            \$\$('.new-offer-image').each(function(elm) {\n                var span = new Element('span', {'html': \$(elm).getNext().get('html')});\n                \$(elm).getNext().dispose();\n                \$(elm).grab(span, 'after');\n                \$(elm).dispose();\n            });\n            \n            var mt = \$\$('.b-user-menu-tasks-clause a');\n            if(mt)\n            {\n                mt.set('title','{$tip['tip']}');\n                var mt_cnt = mt.getElement('.b-user-menu-clause-quantity');    \n                if(mt_cnt){" . ($tip['count'] > 0 ? "mt_cnt.set('html',{$tip['count']})" : "mt_cnt.destroy();") . "}\n            }\n        ");
    }
    return $objResponse;
}
Example #18
0
/**
 * Update AMI credentials in manager.conf
 *
 * @author Philippe Lindheimer
 * @pram mixed $user false means don't change
 * @pram mixed $pass password false means don't change
 * @pram mixed $writetimeout false means don't change
 * @returns boolean
 *
 * allows FreePBX to update the manager credentials primarily used by Advanced Settings and Backup and Restore.
 */
function fpbx_ami_update($user = false, $pass = false, $writetimeout = false)
{
    global $amp_conf, $astman, $db, $bootstrap_settings;
    $conf_file = $amp_conf['ASTETCDIR'] . '/manager.conf';
    $ret = $ret2 = $ret3 = 0;
    $output = array();
    if (strpos($amp_conf['ASTETCDIR'], "..") === false && !file_exists($conf_file)) {
        return;
    }
    if ($user !== false && $user != '') {
        $sed_arg = escapeshellarg('s/\\s*\\[general\\].*$/TEMPCONTEXT/;s/\\[.*\\]/\\[' . $amp_conf['AMPMGRUSER'] . '\\]/;s/^TEMPCONTEXT$/\\[general\\]/');
        exec("sed -i.bak {$sed_arg} {$conf_file}", $output, $ret);
        if ($ret) {
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI user to [%s], internal failure details follow:"), $amp_conf['AMPMGRUSER']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
    }
    if ($pass !== false && $pass != '') {
        unset($output);
        $sed_arg = escapeshellarg('s/secret\\s*=.*$/secret = ' . $amp_conf['AMPMGRPASS'] . '/');
        exec("sed -i.bak {$sed_arg} {$conf_file}", $output2, $ret2);
        if ($ret2) {
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI password to [%s], internal failure details follow:"), $amp_conf['AMPMGRPASS']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
        // We've changed the password, let's update the notification
        //
        $nt = notifications::create($db);
        $freepbx_conf =& freepbx_conf::create();
        if ($amp_conf['AMPMGRPASS'] == $freepbx_conf->get_conf_default_setting('AMPMGRPASS')) {
            if (!$nt->exists('core', 'AMPMGRPASS')) {
                $nt->add_warning('core', 'AMPMGRPASS', _("Default Asterisk Manager Password Used"), _("You are using the default Asterisk Manager password that is widely known, you should set a secure password"));
            }
        } else {
            $nt->delete('core', 'AMPMGRPASS');
        }
    }
    //attempt to set writetimeout
    unset($output);
    if ($writetimeout) {
        $sed_arg = escapeshellarg('s/writetimeout\\s*=.*$/writetimeout = ' . $amp_conf['ASTMGRWRITETIMEOUT'] . '/');
        exec("sed -i.bak {$sed_arg} {$conf_file}", $output3, $ret3);
        if ($ret3) {
            freepbx_log(FPBX_LOG_ERROR, sprintf(_("Failed changing AMI writetimout to [%s], internal failure details follow:"), $amp_conf['ASTMGRWRITETIMEOUT']));
            foreach ($output as $line) {
                freepbx_log(FPBX_LOG_ERROR, sprintf(_("AMI failure details:"), $line));
            }
        }
    }
    if ($ret || $ret2 || $ret3) {
        dbug("aborting early because previous errors");
        return false;
    }
    if (is_object($astman) && method_exists($astman, "connected") && $astman->connected()) {
        $ast_ret = $astman->Command('module reload manager');
    } else {
        unset($output);
        dbug("no astman connection so trying to force through linux command line");
        exec(fpbx_which('asterisk') . " -rx 'module reload manager'", $output, $ret2);
        if ($ret2) {
            freepbx_log(FPBX_LOG_ERROR, _("Failed to reload AMI, manual reload will be necessary, try: [asterisk -rx 'module reload manager']"));
        }
    }
    if (is_object($astman) && method_exists($astman, "connected") && $astman->connected()) {
        $astman->disconnect();
    }
    if (!is_object($astman) || !method_exists($astman, "connected")) {
        //astman isn't initiated so escape
        return true;
    }
    if (!($res = $astman->connect($amp_conf["ASTMANAGERHOST"] . ":" . $amp_conf["ASTMANAGERPORT"], $amp_conf["AMPMGRUSER"], $amp_conf["AMPMGRPASS"], $bootstrap_settings['astman_events']))) {
        // couldn't connect at all
        freepbx_log(FPBX_LOG_CRITICAL, "Connection attmempt to AMI failed");
    } else {
        $bmo = FreePBX::create();
        $bmo->astman = $astman;
    }
    return true;
}
Example #19
0
function voicemail_mailbox_remove($mbox)
{
    global $amp_conf;
    $uservm = voicemail_getVoicemail();
    $vmcontexts = array_keys($uservm);
    $return = true;
    foreach ($vmcontexts as $vmcontext) {
        if (isset($uservm[$vmcontext][$mbox])) {
            $vm_dir = $amp_conf['ASTSPOOLDIR'] . "/voicemail/{$vmcontext}/{$mbox}";
            exec("rm -rf {$vm_dir}", $output, $ret);
            if ($ret) {
                $return = false;
                $text = sprintf(_("Failed to delete vmbox: %s@%s"), $mbox, $vmcontext);
                $etext = sprintf(_("failed with retcode %s while removing %s:"), $ret, $vm_dir) . "<br>";
                $etext .= implode("<br>", $output);
                $nt =& notifications::create($db);
                $nt->add_error('voicemail', 'MBOXREMOVE', $text, $etext, '', true, true);
                //
                // TODO: this does not work but we should give some sort of feedback that id did not work
                //
                // echo "<script>javascript:alert('$text\n"._("See notification panel for details")."')</script>";
            }
        }
    }
    return $return;
}
Example #20
0
    }
}
if (isset($no_auth) && empty($display)) {
    $display = 'noauth';
}
// handle special requests
if (!in_array($display, array('noauth', 'badrefer')) && isset($_REQUEST['handler'])) {
    $module = isset($_REQUEST['module']) ? $_REQUEST['module'] : '';
    $file = isset($_REQUEST['file']) ? $_REQUEST['file'] : '';
    fileRequestHandler($_REQUEST['handler'], $module, $file);
    exit;
}
if (!$quietmode) {
    $modulef = module_functions::create();
    $modulef->run_notification_checks();
    $nt = notifications::create();
    if (!isset($_SERVER['HTACCESS']) && preg_match("/apache/i", $_SERVER['SERVER_SOFTWARE'])) {
        // No .htaccess support
        if (!$nt->exists('framework', 'htaccess')) {
            $nt->add_security('framework', 'htaccess', _('.htaccess files are disable on this webserver. Please enable them'), sprintf(_("To protect the integrity of your server, you must allow overrides in your webserver's configuration file for the User Control Panel. For more information see: %s"), '<a href="http://wiki.freepbx.org/display/F2/Webserver+Overrides">http://wiki.freepbx.org/display/F2/Webserver+Overrides</a>'), "http://wiki.freepbx.org/display/F2/Webserver+Overrides");
        }
    } elseif (!preg_match("/apache/i", $_SERVER['SERVER_SOFTWARE'])) {
        $sql = "SELECT value FROM admin WHERE variable = 'htaccess'";
        $sth = FreePBX::Database()->prepare($sql);
        $sth->execute();
        $o = $sth->fetch();
        if (empty($o)) {
            if ($nt->exists('framework', 'htaccess')) {
                $nt->delete('framework', 'htaccess');
            }
            $nt->add_warning('framework', 'htaccess', _('.htaccess files are not supported on this webserver.'), sprintf(_("htaccess files help protect the integrity of your server. Please make sure file paths and directories are locked down properly. For more information see: %s"), '<a href="http://wiki.freepbx.org/display/F2/Webserver+Overrides">http://wiki.freepbx.org/display/F2/Webserver+Overrides</a>'), "http://wiki.freepbx.org/display/F2/Webserver+Overrides", true, true);
Example #21
0
        if ($action == 'status_action') {
            $resend = __paramInit('bool', NULL, 'resend');
            $del = __paramInit('bool', NULL, 'del');
            $cancel = __paramInit('bool', NULL, 'cancel');
            $id = __paramInit('int', NULL, 'id');
            $ok = true;
            if ($resend) {
                $ok = $sbr->resendCanceled($id);
            } else {
                if ($cancel) {
                    $ok = $sbr->cancel($id);
                } else {
                    if ($del) {
                        $ok = $sbr->delete($id);
                    }
                }
            }
            if ($ok) {
                header_location_exit('/norisk2/' . ($del ? '' : "?id={$id}"));
            }
        }
        $anchor = __paramInit('int', 'id');
        if (!($sbr_currents = $sbr->getCurrents())) {
            header_location_exit('/promo/sbr/');
        } else {
            $sbr->getUserReqvs();
        }
        $_SESSION['sbr_tip_old'] = notifications::getSbrTip('old');
        $sbr->setLastView('old');
        break;
}
 /**
  * Submit comments
  *
  * @return int
  */
 private function _add_comment()
 {
     $api_akismet = Kohana::config('settings.api_akismet');
     // Comment Post?
     // Setup and initialize form field names
     $form = array('incident_id' => '', 'comment_author' => '', 'comment_description' => '', 'comment_email' => '');
     $captcha = Captcha::factory();
     $errors = $form;
     $form_error = FALSE;
     $ret_value = 0;
     // Check, has the form been submitted, if so, setup validation
     if ($_POST and Kohana::config('settings.allow_comments')) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('incident_id', 'required');
         $post->add_rules('comment_author', 'required', 'length[3,100]');
         $post->add_rules('comment_description', 'required');
         $post->add_rules('comment_email', 'required', 'email', 'length[4,100]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             $incident = ORM::factory('incident')->where('id', $post->incident_id)->where('incident_active', 1)->find();
             if ($incident->id == 0) {
                 return $this->response(1, "No incidents with that ID");
             }
             if ($api_akismet != "") {
                 // Run Akismet Spam Checker
                 $akismet = new Akismet();
                 // Comment data
                 $comment = array('author' => $post->comment_author, 'email' => $post->comment_email, 'website' => "", 'body' => $post->comment_description, 'user_ip' => $_SERVER['REMOTE_ADDR']);
                 $config = array('blog_url' => url::site(), 'api_key' => $api_akismet, 'comment' => $comment);
                 $akismet->init($config);
                 if ($akismet->errors_exist()) {
                     if ($akismet->is_error('AKISMET_INVALID_KEY')) {
                         // throw new Kohana_Exception('akismet.api_key');
                     } elseif ($akismet->is_error('AKISMET_RESPONSE_FAILED')) {
                         // throw new Kohana_Exception('akismet.server_failed');
                     } elseif ($akismet->is_error('AKISMET_SERVER_NOT_FOUND')) {
                         // throw new Kohana_Exception('akismet.server_not_found');
                     }
                     // If the server is down, we have to post
                     // the comment :(
                     // $this->_post_comment($comment);
                     $comment_spam = 0;
                 } else {
                     if ($akismet->is_spam()) {
                         $comment_spam = 1;
                     } else {
                         $comment_spam = 0;
                     }
                 }
             } else {
                 // No API Key!!
                 $comment_spam = 0;
             }
             $comment = new Comment_Model();
             $comment->incident_id = strip_tags($post->incident_id);
             $comment->comment_author = strip_tags($post->comment_author);
             $comment->comment_description = strip_tags($post->comment_description);
             $comment->comment_email = strip_tags($post->comment_email);
             $comment->comment_ip = $_SERVER['REMOTE_ADDR'];
             $comment->comment_date = date("Y-m-d H:i:s", time());
             // Activate comment for now
             if ($comment_spam == 1) {
                 $comment->comment_spam = 1;
                 $comment->comment_active = 0;
             } else {
                 $comment->comment_spam = 0;
                 if (Kohana::config('settings.allow_comments') == 1) {
                     // Auto Approve
                     $comment->comment_active = 1;
                 } else {
                     // Manually Approve
                     $comment->comment_active = 0;
                 }
             }
             $comment->save();
             // Notify Admin Of New Comment
             $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/view/' . $post->incident_id);
         } else {
             // No! We have validation errors, we need to show the form again, with the errors
             // Repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // Populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('comments'));
             foreach ($errors as $error_item => $error_description) {
                 if (!is_array($error_description)) {
                     $this->error_messages .= $error_description;
                     if ($error_description != end($errors)) {
                         $this->error_messages .= " - ";
                     }
                 }
             }
             $ret_value = 1;
             // Validation error
         }
     } else {
         $ret_value = 3;
     }
     return $this->response($ret_value, $this->error_messages);
 }
Example #23
0
 /**
  * Adds email to the database and saves the sender as a new
  * Reporter if they don't already exist
  * @param string $messages
  */
 private function add_email($messages)
 {
     $service = ORM::factory('service')->where('service_name', 'Email')->find();
     if (!$service->loaded) {
         return;
     }
     if (empty($messages) or !is_array($messages)) {
         return;
     }
     foreach ($messages as $message) {
         $reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message['email'])->find();
         if (!$reporter->loaded == true) {
             // Add new reporter
             $names = explode(' ', $message['from'], 2);
             $last_name = '';
             if (count($names) == 2) {
                 $last_name = $names[1];
             }
             // get default reporter level (Untrusted)
             $level = ORM::factory('level')->where('level_weight', 0)->find();
             $reporter->service_id = $service->id;
             $reporter->level_id = $level->id;
             $reporter->service_account = $message['email'];
             $reporter->reporter_first = $names[0];
             $reporter->reporter_last = $last_name;
             $reporter->reporter_email = $message['email'];
             $reporter->reporter_phone = null;
             $reporter->reporter_ip = null;
             $reporter->reporter_date = date('Y-m-d');
             $reporter->save();
         }
         if ($reporter->level_id > 1 && count(ORM::factory('message')->where('service_messageid', $message['message_id'])->find_all()) == 0) {
             // Save Email as Message
             $email = new Message_Model();
             $email->parent_id = 0;
             $email->incident_id = 0;
             $email->user_id = 0;
             $email->reporter_id = $reporter->id;
             $email->message_from = $message['from'];
             $email->message_to = null;
             $email->message = $message['subject'];
             $email->message_detail = $message['body'];
             $email->message_type = 1;
             // Inbox
             $email->message_date = $message['date'];
             $email->service_messageid = $message['message_id'];
             $email->save();
             // Attachments?
             foreach ($message['attachments'] as $attachments) {
                 foreach ($attachments as $attachment) {
                     $media = new Media_Model();
                     $media->location_id = 0;
                     $media->incident_id = 0;
                     $media->message_id = $email->id;
                     $media->media_type = 1;
                     // Images
                     $media->media_link = $attachment[0];
                     $media->media_medium = $attachment[1];
                     $media->media_thumb = $attachment[2];
                     $media->media_date = date("Y-m-d H:i:s", time());
                     $media->save();
                 }
             }
             // Auto-Create A Report if Reporter is Trusted
             $reporter_weight = $reporter->level->level_weight;
             $reporter_location = $reporter->location;
             if ($reporter_weight > 0 and $reporter_location) {
                 // Create Incident
                 $incident = new Incident_Model();
                 $incident->location_id = $reporter_location->id;
                 $incident->incident_title = $message['subject'];
                 $incident->incident_description = $message['body'];
                 $incident->incident_date = $message['date'];
                 $incident->incident_dateadd = date("Y-m-d H:i:s", time());
                 $incident->incident_active = 1;
                 if ($reporter_weight == 2) {
                     $incident->incident_verified = 1;
                 }
                 $incident->save();
                 // Update Message with Incident ID
                 $email->incident_id = $incident->id;
                 $email->save();
                 // Save Incident Category
                 $trusted_categories = ORM::factory("category")->where("category_trusted", 1)->find();
                 if ($trusted_categories->loaded) {
                     $incident_category = new Incident_Category_Model();
                     $incident_category->incident_id = $incident->id;
                     $incident_category->category_id = $trusted_categories->id;
                     $incident_category->save();
                 }
                 // Add Attachments
                 $attachments = ORM::factory("media")->where("message_id", $email->id)->find_all();
                 foreach ($attachments as $attachment) {
                     $attachment->incident_id = $incident->id;
                     $attachment->save();
                 }
             }
             // Notify Admin Of New Email Message
             $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_email.subject'), Kohana::lang('notifications.admin_new_email.message'));
             // Action::message_email_add - Email Received!
             Event::run('ushahidi_action.message_email_add', $email);
         }
     }
 }
 /**
  * Get all Cached Signatures, update if it doesnt exist
  * @param {bool} $cached=true Whether to use cached data or not
  */
 function getAllSignatures($cached = true, $online = false)
 {
     FreePBX::GPG();
     //declare class to get constants
     $sql = "SELECT modulename, signature FROM modules";
     $sth = FreePBX::Database()->prepare($sql);
     $sth->execute();
     $res = $sth->fetchAll(PDO::FETCH_ASSOC);
     $modules = array();
     $globalValidation = true;
     // String below, if i18n'ed, must be identical to that in GPG class.
     // Read the comment there.
     $amportal = FreePBX::Config()->get('AMPSBIN') . "/amportal " . _("altered");
     if (!$cached && $online) {
         FreePBX::GPG()->refreshKeys();
     }
     foreach ($res as $mod) {
         // Ignore ARI for the moment.
         if ($mod['modulename'] == 'fw_ari') {
             continue;
         }
         //TODO: determine if this should be in here or not.
         if (!$cached || empty($mod['signature'])) {
             $mod['signature'] = $this->updateSignature($mod['modulename']);
         } else {
             $mod['signature'] = json_decode($mod['signature'], TRUE);
         }
         $modules['modules'][$mod['modulename']] = $mod;
         if (!is_int($mod['signature']['status'])) {
             $modules['statuses']['unsigned'][] = sprintf(_('Module "%s" is is missing its signature status.'), $modname);
             continue;
         }
         if (~$mod['signature']['status'] & GPG::STATE_GOOD) {
             $globalValidation = false;
         }
         $trusted = $mod['signature']['status'] & GPG::STATE_TRUSTED;
         $tampered = $mod['signature']['status'] & GPG::STATE_TAMPERED;
         $unsigned = $mod['signature']['status'] & GPG::STATE_UNSIGNED;
         $invalid = $mod['signature']['status'] & GPG::STATE_INVALID;
         $revoked = $mod['signature']['status'] & GPG::STATE_REVOKED;
         //if revoked then disable
         $md = $this->getInfo();
         $modname = !empty($md[$mod['modulename']]['name']) ? $md[$mod['modulename']]['name'] : sprintf(_('%s [not enabled]'), $mod['modulename']);
         if ($invalid) {
             $modules['statuses']['tampered'][] = sprintf(_('Module "%s" signed by an invalid key.'), $modname);
         }
         if ($unsigned) {
             if ($mod['modulename'] == "framework" || $mod['modulename'] == "core") {
                 // Unsigned framework or core is extremely terribly bad.
                 $modules['statuses']['tampered'][] = sprintf(_('Critical Module "%s" is unsigned, re-download immediately'), $modname);
             } else {
                 $modules['statuses']['unsigned'][] = sprintf(_('Module "%s" is unsigned and should be re-downloaded'), $modname);
             }
         } else {
             if ($tampered) {
                 foreach ($mod['signature']['details'] as $d) {
                     if ($d == $amportal) {
                         $modules['statuses']['tampered'][] = sprintf(_("Module: '%s', File: '%s' (If you just updated FreePBX, you'll need to run 'amportal chown' and then 'amportal a r' to clear this message. If you did not just update FreePBX, your system may have been compromised)"), $modname, $d);
                     } else {
                         $modules['statuses']['tampered'][] = sprintf(_('Module: "%s", File: "%s"'), $modname, $d);
                     }
                 }
             }
             if (!$trusted) {
                 if ($revoked) {
                     $modules['statuses']['revoked'][] = sprintf(_('Module: "%s"\'s signature has been revoked. Module has been automatically disabled'), $modname);
                 }
             }
         }
     }
     $statuses = array('untrusted' => _('untrusted'), 'unsigned' => _('unsigned'), 'tampered' => _('tampered'), 'unknown' => _('unknown'), 'revoked' => _('revoked'));
     $nt = notifications::create();
     foreach ($statuses as $type => $name) {
         if (!empty($modules['statuses'][$type]) && FreePBX::Config()->get('SIGNATURECHECK')) {
             switch ($type) {
                 case 'unsigned':
                     //TODO: check the hash
                     $hash = md5(json_encode($modules['statuses'][$type]));
                     $sth = FreePBX::Database()->prepare("SELECT value FROM admin WHERE variable = 'unsigned' LIMIT 1");
                     $sth->execute();
                     $o = $sth->fetch();
                     if (empty($o)) {
                         $nt->add_signature_unsigned('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s unsigned modules'), count($modules['statuses'][$type])), implode("<br>", $modules['statuses'][$type]), '', true, true);
                         sql("INSERT INTO admin (variable, value) VALUE ('unsigned', '{$hash}')");
                     } elseif ($o['value'] != $hash) {
                         $nt->add_signature_unsigned('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s unsigned modules'), count($modules['statuses'][$type])), implode("<br>", $modules['statuses'][$type]), '', true, true);
                         $sth = FreePBX::Database()->prepare("UPDATE admin SET value = ? WHERE variable = 'unsigned'");
                         $sth->execute(array($hash));
                     }
                     break;
                 case 'tampered':
                     $nt->add_security('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s tampered files'), count($modules['statuses'][$type])), implode("<br>", $modules['statuses'][$type]));
                     break;
                 default:
                     $nt->add_security('freepbx', 'FW_' . strtoupper($type), sprintf(_('You have %s %s modules'), count($modules['statuses'][$type]), $name), implode("<br>", $modules['statuses'][$type]));
                     break;
             }
         } else {
             $nt->delete('freepbx', 'FW_' . strtoupper($type));
         }
     }
     $modules['validation'] = $globalValidation;
     return $modules;
 }
Example #25
0
 /** run_jobs()
  *  select all entries that need to be run now and run them, then update the times.
  *  
  *  1. select all entries
  *  2. foreach entry, if its paramters indicate it should be run, then run it and
  *     update it was run in the time stamp.
  */
 function run_jobs()
 {
     $errors = 0;
     $error_arr = array();
     $now = time();
     $jobs = sql("SELECT * FROM cronmanager", "getAll", DB_FETCHMODE_ASSOC);
     foreach ($jobs as $job) {
         $nexttime = $job['lasttime'] + $job['freq'] * 3600;
         if ($nexttime <= $now) {
             if ($job['time'] >= 0 && $job['time'] < 24) {
                 $date_arr = getdate($now);
                 // Now if lasttime is 0, then we want this kicked off at the proper hour
                 // after wich the frequencey will set the pace for same time each night
                 //
                 if ($date_arr['hours'] != $job['time'] && !$job['lasttime']) {
                     continue;
                 }
             }
         } else {
             // no need to run job, time is not up yet
             continue;
         }
         // run the job
         exec($job['command'], $job_out, $ret);
         if ($ret) {
             $errors++;
             $error_arr[] = array($job['command'], $ret);
             // If there where errors, let's print them out in case the script is being debugged or running
             // from cron which will then put the errors out through the cron system.
             //
             foreach ($job_out as $line) {
                 echo $line . "\n";
             }
         } else {
             $module = $job['module'];
             $id = $job['id'];
             $sql = "UPDATE cronmanager SET lasttime = {$now} WHERE module = '{$module}' AND id = '{$id}'";
             sql($sql);
         }
     }
     if ($errors) {
         $nt =& notifications::create($db);
         $text = sprintf(_("Cronmanager encountered %s Errors"), $errors);
         $extext = _("The following commands failed with the listed error");
         foreach ($error_arr as $item) {
             $extext .= "<br />" . $item[0] . " (" . $item[1] . ")";
         }
         $nt->add_error('cron_manager', 'EXECFAIL', $text, $extext, '', true, true);
     }
 }
Example #26
0
    out(_("not needed"));
}
outn(_("Checking for retvm.."));
$sql = "SELECT retvm FROM ivr";
$check = $db->getRow($sql, DB_FETCHMODE_ASSOC);
if (DB::IsError($check)) {
    //  Add retvm field
    //
    $sql = "ALTER TABLE ivr ADD retvm VARCHAR(8);";
    $result = $db->query($sql);
    if (DB::IsError($result)) {
        out(_("fatal error"));
        die_freepbx($result->getDebugInfo());
    } else {
        out(_("added"));
    }
} else {
    out(_("not needed"));
}
$count = sql('SELECT COUNT(*) FROM `ivr` WHERE `enable_directory` = "CHECKED"', 'getOne');
if ($count) {
    global $db;
    $notifications =& notifications::create($db);
    $extext = sprintf(_("There are %s IVRs that have the legacy Directory dialing enabled. This has been deprecated and will be removed from future releases. You should convert your IVRs to use the Directory module for this functionality and assign an IVR destination to a desired Directory. You can install the Directory module from the Online Module Repository"), $count);
    $notifications->add_notice('ivr', 'DIRECTORY_DEPRECATED', sprintf(_('Deprecated Directory used by %s IVRs'), $count), $extext, '', true, true);
    out(_("posting notice about deprecated functionality"));
}
// This used to be called from page.ivr.php every time, it should not be needed, it should
// be called once and be done with.
//
ivr_init();
Example #27
0
 /**
  * Adds email to the database and saves the sender as a new
  * Reporter if they don't already exist
  * @param string $messages
  */
 private function add_email($messages)
 {
     $services = new Service_Model();
     $service = $services->where('service_name', 'Email')->find();
     if (!$service) {
         return;
     }
     if (empty($messages) || !is_array($messages)) {
         return;
     }
     foreach ($messages as $message) {
         $reporter = ORM::factory('reporter')->where('service_id', $service->id)->where('service_account', $message['email'])->find();
         if (!$reporter->loaded == true) {
             // Add new reporter
             $names = explode(' ', $message['from'], 2);
             $last_name = '';
             if (count($names) == 2) {
                 $last_name = $names[1];
             }
             // get default reporter level (Untrusted)
             $level = ORM::factory('level')->where('level_weight', 0)->find();
             $reporter->service_id = $service->id;
             $reporter->level_id = $level->id;
             $reporter->service_userid = null;
             $reporter->service_account = $message['email'];
             $reporter->reporter_first = $names[0];
             $reporter->reporter_last = $last_name;
             $reporter->reporter_email = $message['email'];
             $reporter->reporter_phone = null;
             $reporter->reporter_ip = null;
             $reporter->reporter_date = date('Y-m-d');
             $reporter->save();
         }
         if ($reporter->level_id > 1 && count(ORM::factory('message')->where('service_messageid', $message['message_id'])->find_all()) == 0) {
             // Save Email as Message
             $email = new Message_Model();
             $email->parent_id = 0;
             $email->incident_id = 0;
             $email->user_id = 0;
             $email->reporter_id = $reporter->id;
             $email->message_from = $message['from'];
             $email->message_to = null;
             $email->message = $message['subject'];
             $email->message_detail = $message['body'];
             $email->message_type = 1;
             // Inbox
             $email->message_date = $message['date'];
             $email->service_messageid = $message['message_id'];
             $email->save();
             // Notify Admin Of New Email Message
             $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_email.subject'), Kohana::lang('notifications.admin_new_email.message'));
         }
     }
 }
<?php

#########################################
#  Author  : D3W4 & SAHAT               #
#  Created : May 8, 2012 8:46:25 PM    #
#########################################
use_class('notifications');
$notifications = new notifications();
if (isset($_GET['sender']) && $_GET['sender'] != '') {
    $sender = tep_db_prepare_input($_GET['sender']);
    $filter = "AND posted_by = '{$sender}'";
}
if (isset($_POST['me_action'])) {
    if ($_POST['me_action'] == 'DELETENOTIFICATIONS') {
        $ids = $_POST['ids'];
        list($notifications_id, $not_class) = split('-', $ids);
        $notifications->delete($notifications_id);
        $result = array();
        $result['notifications_id'] = $notifications_id;
        $result['not_class'] = $not_class;
        ajaxReturn($result);
        exit;
    } elseif ($_POST['me_action'] == 'CLOSEFEEDBACK') {
        $ids = $_POST['ids'];
        list($notifications_id, $not_class) = split('-', $ids);
        $notifications->closeOpenFeedback($notifications_id);
        $result = array();
        $result['ids'] = $ids;
        $result['notifications_id'] = $notifications_id;
        ajaxReturn($result);
        exit;
Example #29
0
 /**
  * Displays a report.
  * @param boolean $id If id is supplied, a report with that id will be
  * retrieved.
  */
 public function view($id = false)
 {
     $this->template->header->this_page = 'reports';
     $this->template->content = new View('reports_view');
     // Load Akismet API Key (Spam Blocker)
     $api_akismet = Kohana::config('settings.api_akismet');
     if (!$id) {
         url::redirect('main');
     } else {
         $incident = ORM::factory('incident', $id);
         if ($incident->id == 0) {
             url::redirect('main');
         }
         // Comment Post?
         // Setup and initialize form field names
         $form = array('comment_author' => '', 'comment_description' => '', 'comment_email' => '', 'comment_ip' => '', 'captcha' => '');
         $captcha = Captcha::factory();
         $errors = $form;
         $form_error = FALSE;
         // Check, has the form been submitted, if so, setup validation
         if ($_POST) {
             // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
             $post = Validation::factory($_POST);
             // Add some filters
             $post->pre_filter('trim', TRUE);
             // Add some rules, the input field, followed by a list of checks, carried out in order
             $post->add_rules('comment_author', 'required', 'length[3,100]');
             $post->add_rules('comment_description', 'required');
             $post->add_rules('comment_email', 'required', 'email', 'length[4,100]');
             $post->add_rules('captcha', 'required', 'Captcha::valid');
             // Test to see if things passed the rule checks
             if ($post->validate()) {
                 // Yes! everything is valid
                 if ($api_akismet != "") {
                     // Run Akismet Spam Checker
                     $akismet = new Akismet();
                     // comment data
                     $comment = array('author' => $post->comment_author, 'email' => $post->comment_email, 'website' => "", 'body' => $post->comment_description, 'user_ip' => $_SERVER['REMOTE_ADDR']);
                     $config = array('blog_url' => url::site(), 'api_key' => $api_akismet, 'comment' => $comment);
                     $akismet->init($config);
                     if ($akismet->errors_exist()) {
                         if ($akismet->is_error('AKISMET_INVALID_KEY')) {
                             // throw new Kohana_Exception('akismet.api_key');
                         } elseif ($akismet->is_error('AKISMET_RESPONSE_FAILED')) {
                             // throw new Kohana_Exception('akismet.server_failed');
                         } elseif ($akismet->is_error('AKISMET_SERVER_NOT_FOUND')) {
                             // throw new Kohana_Exception('akismet.server_not_found');
                         }
                         // If the server is down, we have to post
                         // the comment :(
                         // $this->_post_comment($comment);
                         $comment_spam = 0;
                     } else {
                         if ($akismet->is_spam()) {
                             $comment_spam = 1;
                         } else {
                             $comment_spam = 0;
                         }
                     }
                 } else {
                     // No API Key!!
                     $comment_spam = 0;
                 }
                 $comment = new Comment_Model();
                 $comment->incident_id = $id;
                 $comment->comment_author = strip_tags($post->comment_author);
                 $comment->comment_description = strip_tags($post->comment_description);
                 $comment->comment_email = strip_tags($post->comment_email);
                 $comment->comment_ip = $_SERVER['REMOTE_ADDR'];
                 $comment->comment_date = date("Y-m-d H:i:s", time());
                 // Activate comment for now
                 if ($comment_spam == 1) {
                     $comment->comment_spam = 1;
                     $comment->comment_active = 0;
                 } else {
                     $comment->comment_spam = 0;
                     $comment->comment_active = 1;
                 }
                 $comment->save();
                 // Notify Admin Of New Comment
                 $send = notifications::notify_admins("[" . Kohana::config('settings.site_name') . "] " . Kohana::lang('notifications.admin_new_comment.subject'), Kohana::lang('notifications.admin_new_comment.message') . "\n\n'" . strtoupper($incident->incident_title) . "'" . "\n" . url::base() . 'reports/view/' . $id);
                 // Redirect
                 url::redirect('reports/view/' . $id);
             } else {
                 // repopulate the form fields
                 $form = arr::overwrite($form, $post->as_array());
                 // populate the error fields, if any
                 $errors = arr::overwrite($errors, $post->errors('comments'));
                 $form_error = TRUE;
             }
         }
         $this->template->content->incident_id = $incident->id;
         $this->template->content->incident_title = $incident->incident_title;
         $this->template->content->incident_description = nl2br($incident->incident_description);
         $this->template->content->incident_location = $incident->location->location_name;
         $this->template->content->incident_latitude = $incident->location->latitude;
         $this->template->content->incident_longitude = $incident->location->longitude;
         $this->template->content->incident_date = date('M j Y', strtotime($incident->incident_date));
         $this->template->content->incident_time = date('H:i', strtotime($incident->incident_date));
         $this->template->content->incident_category = $incident->incident_category;
         if ($incident->incident_rating == '') {
             $this->template->content->incident_rating = 0;
         } else {
             $this->template->content->incident_rating = $incident->incident_rating;
         }
         // Retrieve Media
         $incident_news = array();
         $incident_video = array();
         $incident_photo = array();
         foreach ($incident->media as $media) {
             if ($media->media_type == 4) {
                 $incident_news[] = $media->media_link;
             } elseif ($media->media_type == 2) {
                 $incident_video[] = $media->media_link;
             } elseif ($media->media_type == 1) {
                 $incident_photo[] = $media->media_link;
             }
         }
         $this->template->content->incident_verified = $incident->incident_verified;
         // Retrieve Comments (Additional Information)
         $incident_comments = array();
         if ($id) {
             $incident_comments = ORM::factory('comment')->where('incident_id', $id)->where('comment_active', '1')->where('comment_spam', '0')->orderby('comment_date', 'asc')->find_all();
         }
         $this->template->content->incident_comments = $incident_comments;
     }
     // Add Neighbors
     $this->template->content->incident_neighbors = $this->_get_neighbors($incident->location->latitude, $incident->location->longitude);
     // Get RSS News Feeds
     $this->template->content->feeds = ORM::factory('feed_item')->limit('5')->orderby('item_date', 'desc')->find_all();
     // Video links
     $this->template->content->incident_videos = $incident_video;
     //images
     $this->template->content->incident_photos = $incident_photo;
     // Create object of the video embed class
     $video_embed = new VideoEmbed();
     $this->template->content->videos_embed = $video_embed;
     // Javascript Header
     $this->template->header->map_enabled = TRUE;
     $this->template->header->photoslider_enabled = TRUE;
     $this->template->header->videoslider_enabled = TRUE;
     $this->template->header->js = new View('reports_view_js');
     $this->template->header->js->incident_id = $incident->id;
     $this->template->header->js->default_map = Kohana::config('settings.default_map');
     $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
     $this->template->header->js->latitude = $incident->location->latitude;
     $this->template->header->js->longitude = $incident->location->longitude;
     $this->template->header->js->incident_photos = $incident_photo;
     // Pack the javascript using the javascriptpacker helper
     $myPacker = new javascriptpacker($this->template->header->js, 'Normal', false, false);
     $this->template->header->js = $myPacker->pack();
     // initialize custom field array
     $form_field_names = $this->_get_custom_form_fields($id, $incident->form_id, false);
     // Retrieve Custom Form Fields Structure
     $disp_custom_fields = $this->_get_custom_form_fields($id, $incident->form_id, true);
     $this->template->content->disp_custom_fields = $disp_custom_fields;
     // Forms
     $this->template->content->form = $form;
     $this->template->content->form_field_names = $form_field_names;
     $this->template->content->captcha = $captcha;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     // If the Admin is Logged in - Allow for an edit link
     $this->template->content->logged_in = $this->logged_in;
 }
Example #30
-1
function set_language()
{
    global $amp_conf, $db;
    $nt = notifications::create($db);
    if (extension_loaded('gettext')) {
        $nt->delete('core', 'GETTEXT');
        if (php_sapi_name() !== 'cli') {
            if (empty($_COOKIE['lang']) || !preg_match('/^[\\w\\._@-]+$/', $_COOKIE['lang'], $matches)) {
                $lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
                if (empty($_COOKIE['lang'])) {
                    setcookie("lang", $lang);
                }
            } else {
                preg_match('/^([\\w\\._@-]+)$/', $_COOKIE['lang'], $matches);
                $lang = !empty($matches[1]) ? $matches[1] : 'en_US';
            }
            $_COOKIE['lang'] = $lang;
        } else {
            $lang = $amp_conf['UIDEFAULTLANG'] ? $amp_conf['UIDEFAULTLANG'] : 'en_US';
        }
        putenv('LC_ALL=' . $lang);
        putenv('LANG=' . $lang);
        putenv('LANGUAGE=' . $lang);
        setlocale(LC_ALL, $lang);
        bindtextdomain('amp', $amp_conf['AMPWEBROOT'] . '/admin/i18n');
        bind_textdomain_codeset('amp', 'utf8');
        textdomain('amp');
        return $lang;
    }
    $nt->add_warning('core', 'GETTEXT', _("Gettext is not installed"), _("Please install gettext so that the PBX can properly translate itself"), 'https://www.gnu.org/software/gettext/');
    return 'en_US';
}