getUserAgent() public method

Get the user agent value in use to determine the browser
public getUserAgent ( ) : string
return string The user agent from the HTTP header
コード例 #1
0
 public static function log($logType, $user = false, $data1 = false)
 {
     $browser = new Browser();
     $text = '';
     $timestamp = time();
     if ($user !== false) {
         $userId = $user->get('id');
     } else {
         $userId = 0;
     }
     $data = '';
     switch ($logType) {
         case 3:
             foreach ($data1 as $key => $value) {
                 $data .= ' ' . $key . ': ' . $value . '|';
             }
             break;
         case 4:
             $data = 'Plattform: ' . $browser->getPlatform() . ' | Browser: ' . $browser->getBrowser() . ' | Version: ' . $browser->getVersion() . ' | UserAgent: ' . $browser->getUserAgent();
             break;
         default:
             break;
     }
     $text = Texter::get('log|' . $logType);
     database::Query('INSERT INTO log (`type`, `text`, `data`, `userId`, `timestamp`) VALUES (' . $logType . ', :var1, :var2, :var3, :var4);', array('var1' => $text, 'var2' => $data, 'var3' => $userId, 'var4' => $timestamp));
 }
コード例 #2
0
 /**
  * Routine to determine the browser type.
  *
  * @param Browser $browser
  * @param UserAgent $userAgent
  *
  * @return bool
  */
 public static function detect(Browser $browser, UserAgent $userAgent = null)
 {
     self::$browser = $browser;
     if (is_null($userAgent)) {
         $userAgent = self::$browser->getUserAgent();
     }
     self::$userAgentString = $userAgent->getUserAgentString();
     self::$browser->setName(Browser::UNKNOWN);
     self::$browser->setVersion(Browser::VERSION_UNKNOWN);
     self::checkChromeFrame();
     foreach (self::$browsersList as $browserName) {
         $funcName = self::FUNC_PREFIX . $browserName;
         if (self::$funcName()) {
             return true;
         }
     }
     return false;
 }
コード例 #3
0
ファイル: CTimeline.php プロジェクト: buildshop/bs-common
 public function set($message, $params = array())
 {
     $browser = new Browser();
     $model = new Timeline();
     $model->user_id = Yii::app()->user->id;
     $model->message = Yii::t('timeline', $message, $params);
     $model->user_agent = $browser->getUserAgent();
     $model->ip = CMS::getip();
     $model->user_platform = $browser->getPlatform();
     $model->save(false, false, false);
 }
コード例 #4
0
ファイル: form.php プロジェクト: densem-2013/exikom
 /**
  * Save data
  *
  * @param   Array   $dataForms                Data form
  * @param   Array   &$return                  Return
  * @param   Array   $post                     Post form
  * @param   String  $submissionsData          Submission Data
  * @param   String  $fieldId                  Field Id
  * @param   String  $dataContentEmail         Data content Email
  * @param   Strig   $nameFileByIndentifier    Get name Field by Indentifier
  * @param   String  $requiredField            required field
  * @param   String  $fileAttach               Email File Attach
  *
  * @return boolean
  */
 private function _save($dataForms, &$return, $post, $submissionsData, $dataContentEmail, $nameFileByIndentifier, $requiredField, $fileAttach, $recepientEmail)
 {
     $user = JFactory::getUser();
     $ip = getenv('REMOTE_ADDR');
     $country = $this->countryCityFromIP($ip);
     $browser = new Browser();
     $checkSaveSubmission = true;
     $formSettings = !empty($dataForms->form_settings) ? json_decode($dataForms->form_settings) : "";
     $plgName = JSNUniformHelper::getPluginUniform();
     if (isset($plgName) && !empty($plgName)) {
         if (is_array($plgName)) {
             foreach ($plgName as $k => $v) {
                 $v = (array) $v;
                 $name = form_ . '' . $v['value'];
                 $data[$v['value']] = $formSettings->{$name};
                 $data['post'] = $post;
                 $data['sub'] = $submissionsData;
                 if ($v['value'] == 'mailchimp') {
                     if (isset($post['mailchimp_subcriber']) && $post['mailchimp_subcriber'] == 'on') {
                         JPluginHelper::importPlugin('uniform', $v['value']);
                         $dispatcher = JDispatcher::getInstance();
                         $dispatcher->trigger('saveFrontEnd', array($data));
                     }
                 }
             }
         }
     }
     if (!empty($formSettings->action_save_submissions) && $formSettings->action_save_submissions == "No") {
         $checkSaveSubmission = false;
     }
     if ($checkSaveSubmission) {
         $dateTime = JHtml::_('date', 'now', JText::_('Y-m-d H:i:s'));
         $table = JTable::getInstance('JsnSubmission', 'JSNUniformTable');
         $table->bind(array('form_id' => (int) $post['form_id'], 'user_id' => $user->id, 'submission_ip' => $ip, 'submission_country' => $country['country'], 'submission_country_code' => $country['country_code'], 'submission_browser' => $browser->getBrowser(), 'submission_browser_version' => $browser->getVersion(), 'submission_browser_agent' => $browser->getUserAgent(), 'submission_os' => $browser->getPlatform(), 'submission_created_by' => $user->id, 'submission_created_at' => $dateTime, 'submission_state' => 1));
         if (!$table->store()) {
             $return->error = $table->getError();
             return false;
         }
     }
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_templates')->where("form_id = " . (int) $dataForms->form_id));
     $dataTemplates = $this->_db->loadObjectList();
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_emails')->where("form_id = " . (int) $dataForms->form_id));
     $dataEmails = $this->_db->loadObjectList();
     if (count($recepientEmail)) {
         $recepientEmail = json_decode($recepientEmail);
         foreach ($recepientEmail as $recepient) {
             $recepient = explode('|', $recepient);
             $emailName = trim($recepient[0]);
             $email = trim(end($recepient));
             $dataRecepient = (object) array('email_id' => '', 'form_id' => '', 'user_id' => '0', 'email_name' => $emailName, 'email_address' => $email, 'email_state' => '1');
             $dataEmails = array_merge($dataEmails, array($dataRecepient));
         }
     }
     $formSubmitter = isset($dataForms->form_submitter) ? json_decode($dataForms->form_submitter) : '';
     $checkEmailSubmitter = true;
     $defaultSubject = isset($dataForms->form_title) ? $dataForms->form_title : '';
     if ($dataTemplates) {
         foreach ($dataTemplates as $emailTemplate) {
             if (!empty($emailTemplate->template_message)) {
                 $emailTemplate->template_message = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_message);
             } else {
                 $htmlMessage = array();
                 if ($dataContentEmail) {
                     $htmlMessage = $this->_emailTemplateDefault($dataContentEmail, $nameFileByIndentifier, $requiredField);
                 }
                 $emailTemplate->template_message = $htmlMessage;
             }
             $emailTemplate->template_subject = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_subject);
             $emailTemplate->template_subject = !empty($emailTemplate->template_subject) ? $emailTemplate->template_subject : $defaultSubject;
             $emailTemplate->template_from = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_from);
             $emailTemplate->template_reply_to = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_reply_to);
             $emailTemplate->template_subject = strip_tags($emailTemplate->template_subject);
             $emailTemplate->template_from = strip_tags($emailTemplate->template_from);
             $emailTemplate->template_reply_to = strip_tags($emailTemplate->template_reply_to);
             if ($emailTemplate->template_notify_to == 0 && count($formSubmitter)) {
                 $checkEmailSubmitter = false;
                 $listEmailSubmitter = array();
                 foreach ($formSubmitter as $item) {
                     if (!empty($item)) {
                         $emailSubmitter = new stdClass();
                         $emailSubmitter->email_address = isset($dataContentEmail[$item]) ? $dataContentEmail[$item] : "";
                         if (!empty($emailSubmitter->email_address)) {
                             $listEmailSubmitter[] = $emailSubmitter;
                         }
                     }
                 }
                 $sent = $this->_sendEmailList($emailTemplate, $listEmailSubmitter, $fileAttach);
                 // Set the success message if it was a success
                 if (!JError::isError($sent)) {
                     $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
                 }
             }
             if ($emailTemplate->template_notify_to == 1) {
                 $sent = $this->_sendEmailList($emailTemplate, $dataEmails, $fileAttach);
                 // Set the success message if it was a success
                 if (!JError::isError($sent)) {
                     $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
                 }
             }
         }
     }
     if ($checkEmailSubmitter && count($formSubmitter)) {
         $emailTemplate = new stdClass();
         $htmlMessage = array();
         if ($dataContentEmail) {
             $htmlMessage = $this->_emailTemplateDefault($dataContentEmail, $nameFileByIndentifier, $requiredField);
         }
         $emailTemplate->template_message = $htmlMessage;
         $listEmailSubmitter = array();
         foreach ($formSubmitter as $item) {
             if (!empty($item)) {
                 $emailSubmitter = new stdClass();
                 $emailSubmitter->email_address = isset($dataContentEmail[$item]) ? $dataContentEmail[$item] : "";
                 if (!empty($emailSubmitter->email_address)) {
                     $listEmailSubmitter[] = $emailSubmitter;
                 }
             }
         }
         $sent = $this->_sendEmailList($emailTemplate, $listEmailSubmitter);
         // Set the success message if it was a success
         if (!JError::isError($sent)) {
             $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
         }
     }
     if ($checkSaveSubmission) {
         foreach ($submissionsData as $submission) {
             if (!empty($submission)) {
                 $submission['submission_id'] = $table->submission_id;
                 if ($post['use_payment_gateway'] == 1) {
                     $dispatcher = JEventDispatcher::getInstance();
                     JPluginHelper::importPlugin('uniform', (string) $dataForms->form_payment_type);
                     if ($submission['field_type'] == 'choices' || $submission['field_type'] == 'list' || $submission['field_type'] == 'dropdown' || $submission['field_type'] == 'checkboxes' || $submission['field_type'] == 'currency' || $submission['field_type'] == 'number') {
                         $fieldValue = $submission['submission_data_value'];
                         if ($submission['field_type'] == 'list' || $submission['field_type'] == 'checkboxes') {
                             $fieldValue = json_decode($fieldValue);
                             $submissionValue = array();
                             foreach ($fieldValue as $itemValue) {
                                 $tmpMoney = explode('|', $itemValue);
                                 $moneyValue = trim($tmpMoney[1]);
                                 $moneyValue = $dispatcher->trigger('displayCurrency', $moneyValue);
                                 $qty = trim(end($tmpMoney));
                                 $tmpMoney = trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')';
                                 $submissionValue[] = json_encode($tmpMoney);
                             }
                             if (!empty($submissionValue)) {
                                 $submission['submission_data_value'] = '[' . implode(',', $submissionValue) . ']';
                             }
                         } else {
                             $tmpMoney = explode('|', $fieldValue);
                             $moneyValue = trim($tmpMoney[1]);
                             if ($moneyValue != '') {
                                 $moneyValue = $dispatcher->trigger('displayCurrency', $moneyValue);
                                 $qty = trim(end($tmpMoney));
                                 $submission['submission_data_value'] = trim($tmpMoney[0]) . ' (' . strip_tags($moneyValue[0]) . ' x ' . $qty . ')';
                             } else {
                                 $submission['submission_data_value'] = $fieldValue;
                             }
                         }
                         if ($submission['field_type'] == 'currency') {
                             if (!empty($fieldValue)) {
                                 $fieldValue = str_replace(',', '.', $fieldValue);
                                 $currecyValue = $dispatcher->trigger('displayCurrency', $fieldValue);
                                 $currecyValue = strip_tags($currecyValue[0]);
                                 $submission['submission_data_value'] = $currecyValue;
                             }
                         }
                     }
                 }
                 $tableSubmission = JTable::getInstance('JsnSubmissiondata', 'JSNUniformTable');
                 $tableSubmission->bind($submission);
                 if (!$tableSubmission->store()) {
                     $return->error = $tableSubmission->getError();
                     return false;
                 }
             }
         }
         $this->_db->setQuery($this->_db->getQuery(true)->select('count(submission_id)')->from("#__jsn_uniform_submissions")->where("form_id=" . (int) $post['form_id']));
         $countSubmission = $this->_db->loadResult();
         $edition = defined('JSN_UNIFORM_EDITION') ? strtolower(JSN_UNIFORM_EDITION) : "free";
         if ($countSubmission == 250 && $edition == "free") {
             $templateEmail = new stdClass();
             $templateEmail->template_subject = $defaultSubject;
             $templateEmail->template_message = "<p>Hello there,</p>\n\t    <p>This is a quick message to let you know you're getting lots of submissions of your form which will soon exceed limit. Please upgrade to PRO edition to accept unlimited number of submissions. <a href=\"http://www.joomlashine.com/joomla-extensions/jsn-uniform-download.html\" target=\"_blank\">Upgrade now</a>.</p>\n\t    <p>Thank you and all the best,</p>\n\t    <p>The JoomlaShine Team</p>";
             $app = JFactory::getApplication();
             $mailfrom = $app->getCfg('mailfrom');
             $emailMaster = new stdClass();
             $emailMaster->email_address = $mailfrom;
             $this->_sendEmailList($templateEmail, array($emailMaster));
         }
         $table = JTable::getInstance('JsnForm', 'JSNUniformTable');
         $table->bind(array('form_id' => (int) $post['form_id'], 'form_last_submitted' => date('Y-m-d H:i:s'), 'form_submission_cout' => $countSubmission));
         if (!$table->store()) {
             $return->error = $table->getError();
             return false;
         }
     }
     if (!empty($_SESSION['securimage_code_value'][$_POST['form_name']])) {
         unset($_SESSION['securimage_code_value'][$_POST['form_name']]);
         unset($_SESSION['securimage_code_disp'][$_POST['form_name']]);
         unset($_SESSION['securimage_code_ctime'][$_POST['form_name']]);
     }
     return true;
 }
コード例 #5
0
ファイル: web_index.php プロジェクト: jingyexu/ezcast
template_load_dictionnary('translations.xml');
//
// Login/logout
//
// Saves the URL used to access the website
if (!isset($_SESSION['first_input']) && isset($input['action']) && $input['action'] != 'logout' && $input['action'] != 'login' && $input['action'] != 'client_trace') {
    $_SESSION['first_input'] = array_merge($_GET, $_POST);
}
// Saves user's web browser information
if (!isset($_SESSION['browser_name']) || !isset($_SESSION['browser_version']) || !isset($_SESSION['user_os'])) {
    Autoloader::register();
    $browser = new Browser();
    $os = new Os();
    $_SESSION['browser_name'] = $browser->getName();
    $_SESSION['browser_version'] = $browser->getVersion();
    $user_agent = $browser->getUserAgent();
    $_SESSION['browser_full'] = $user_agent->getUserAgentString();
    $_SESSION['user_os'] = $os->getName();
}
// If we're not logged in, we try to log in or display the login form
if (!user_logged_in()) {
    // if the url contains the parameter 'anon' the session is assumed as anonymous
    if (isset($input['anon']) && $input['anon'] == true) {
        user_anonymous_session();
    } else {
        if (isset($input['action']) && $input['action'] == 'login') {
            // The user continues without any authentication
            if (isset($_POST['anonymous_session'])) {
                user_anonymous_session();
                // The user want to authenticate
            } else {
コード例 #6
0
ファイル: form.php プロジェクト: sillysachin/teamtogether
 /**
  * Save data
  *
  * @param   Array   $dataForms                Data form
  * @param   Array   &$return                  Return
  * @param   Array   $post                     Post form
  * @param   String  $submissionsData          Submission Data
  * @param   String  $fieldId                  Field Id
  * @param   String  $dataContentEmail         Data content Email
  * @param   Strig   $nameFileByIndentifier    Get name Field by Indentifier
  * @param   String  $requiredField            required field
  * @param   String  $fileAttach               Email File Attach
  *
  * @return boolean
  */
 private function _save($dataForms, &$return, $post, $submissionsData, $dataContentEmail, $nameFileByIndentifier, $requiredField, $fileAttach)
 {
     $user = JFactory::getUser();
     $ip = getenv('REMOTE_ADDR');
     $country = $this->countryCityFromIP($ip);
     $browser = new Browser();
     $checkSaveSubmission = true;
     $formSettings = !empty($dataForms->form_settings) ? json_decode($dataForms->form_settings) : "";
     if (!empty($formSettings->action_save_submissions) && $formSettings->action_save_submissions == "No") {
         $checkSaveSubmission = false;
     }
     if ($checkSaveSubmission) {
         $table = JTable::getInstance('Submission', 'JSNUniformTable');
         $table->bind(array('form_id' => (int) $post['form_id'], 'user_id' => $user->id, 'submission_ip' => $ip, 'submission_country' => $country['country'], 'submission_country_code' => $country['country_code'], 'submission_browser' => $browser->getBrowser(), 'submission_browser_version' => $browser->getVersion(), 'submission_browser_agent' => $browser->getUserAgent(), 'submission_os' => $browser->getPlatform(), 'submission_created_by' => $user->id, 'submission_created_at' => date('Y-m-d H:i:s'), 'submission_state' => 1));
         if (!$table->store()) {
             $return->error = $table->getError();
             return false;
         }
     }
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_templates')->where("form_id = " . (int) $dataForms->form_id));
     $dataTemplates = $this->_db->loadObjectList();
     $this->_db->setQuery($this->_db->getQuery(true)->select('*')->from('#__jsn_uniform_emails')->where("form_id = " . (int) $dataForms->form_id));
     $dataEmails = $this->_db->loadObjectList();
     $formSubmitter = isset($dataForms->form_submitter) ? json_decode($dataForms->form_submitter) : '';
     $checkEmailSubmitter = true;
     $defaultSubject = isset($dataForms->form_title) ? $dataForms->form_title . " [" . $dataForms->form_id . "]" : '';
     if ($dataTemplates) {
         foreach ($dataTemplates as $emailTemplate) {
             if (!empty($emailTemplate->template_message)) {
                 $emailTemplate->template_message = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_message);
             } else {
                 $htmlMessage = array();
                 if ($dataContentEmail) {
                     $htmlMessage = $this->_emailTemplateDefault($dataContentEmail, $nameFileByIndentifier, $requiredField);
                 }
                 $emailTemplate->template_message = $htmlMessage;
             }
             $emailTemplate->template_subject = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_subject);
             $emailTemplate->template_subject = !empty($emailTemplate->template_subject) ? $emailTemplate->template_subject : $defaultSubject;
             $emailTemplate->template_from = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_from);
             $emailTemplate->template_reply_to = preg_replace('/\\{\\$([^\\}]+)\\}/ie', '@$dataContentEmail["\\1"]', $emailTemplate->template_reply_to);
             $emailTemplate->template_subject = strip_tags($emailTemplate->template_subject);
             $emailTemplate->template_from = strip_tags($emailTemplate->template_from);
             $emailTemplate->template_reply_to = strip_tags($emailTemplate->template_reply_to);
             if ($emailTemplate->template_notify_to == 0 && count($formSubmitter)) {
                 $checkEmailSubmitter = false;
                 $listEmailSubmitter = array();
                 foreach ($formSubmitter as $item) {
                     if (!empty($item)) {
                         $emailSubmitter = new stdClass();
                         $emailSubmitter->email_address = isset($dataContentEmail[$item]) ? $dataContentEmail[$item] : "";
                         if (!empty($emailSubmitter->email_address)) {
                             $listEmailSubmitter[] = $emailSubmitter;
                         }
                     }
                 }
                 $sent = $this->_sendEmailList($emailTemplate, $listEmailSubmitter, $fileAttach);
                 // Set the success message if it was a success
                 if (!JError::isError($sent)) {
                     $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
                 }
             }
             if ($emailTemplate->template_notify_to == 1) {
                 $sent = $this->_sendEmailList($emailTemplate, $dataEmails, $fileAttach);
                 // Set the success message if it was a success
                 if (!JError::isError($sent)) {
                     $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
                 }
             }
         }
     }
     if ($checkEmailSubmitter && count($formSubmitter)) {
         $emailTemplate = new stdClass();
         $htmlMessage = array();
         if ($dataContentEmail) {
             $htmlMessage = $this->_emailTemplateDefault($dataContentEmail, $nameFileByIndentifier, $requiredField);
         }
         $emailTemplate->template_message = $htmlMessage;
         $listEmailSubmitter = array();
         foreach ($formSubmitter as $item) {
             if (!empty($item)) {
                 $emailSubmitter = new stdClass();
                 $emailSubmitter->email_address = isset($dataContentEmail[$item]) ? $dataContentEmail[$item] : "";
                 if (!empty($emailSubmitter->email_address)) {
                     $listEmailSubmitter[] = $emailSubmitter;
                 }
             }
         }
         $sent = $this->_sendEmailList($emailTemplate, $listEmailSubmitter);
         // Set the success message if it was a success
         if (!JError::isError($sent)) {
             $msg = JText::_('JSN_UNIFORM_EMAIL_THANKS');
         }
     }
     if ($checkSaveSubmission) {
         foreach ($submissionsData as $submission) {
             if (!empty($submission)) {
                 $submission['submission_id'] = $table->submission_id;
                 $tableSubmission = JTable::getInstance('Submissiondata', 'JSNUniformTable');
                 $tableSubmission->bind($submission);
                 if (!$tableSubmission->store()) {
                     $return->error = $tableSubmission->getError();
                     return false;
                 }
             }
         }
         $this->_db->setQuery($this->_db->getQuery(true)->select('count(submission_id)')->from("#__jsn_uniform_submissions")->where("form_id=" . (int) $post['form_id']));
         $countSubmission = $this->_db->loadResult();
         $edition = defined('JSN_UNIFORM_EDITION') ? strtolower(JSN_UNIFORM_EDITION) : "free";
         if ($countSubmission == 250 && $edition == "free") {
             $templateEmail = new stdClass();
             $templateEmail->template_subject = $defaultSubject;
             $templateEmail->template_message = "<p>Hello there,</p>\n\t    <p>This is a quick message to let you know you're getting lots of submissions of your form which will soon exceed limit. Please upgrade to PRO edition to accept unlimited number of submissions. <a href=\"http://www.joomlashine.com/joomla-extensions/jsn-uniform-download.html\" target=\"_blank\">Upgrade now</a>.</p>\n\t    <p>Thank you and all the best,</p>\n\t    <p>The JoomlaShine Team</p>";
             $app = JFactory::getApplication();
             $mailfrom = $app->getCfg('mailfrom');
             $emailMaster = new stdClass();
             $emailMaster->email_address = $mailfrom;
             $this->_sendEmailList($templateEmail, array($emailMaster));
         }
         $table = JTable::getInstance('Form', 'JSNUniformTable');
         $table->bind(array('form_id' => (int) $post['form_id'], 'form_last_submitted' => date('Y-m-d H:i:s'), 'form_submission_cout' => $countSubmission));
         if (!$table->store()) {
             $return->error = $table->getError();
             return false;
         }
     }
     if (!empty($_SESSION['securimage_code_value'][$_POST['form_name']])) {
         unset($_SESSION['securimage_code_value'][$_POST['form_name']]);
         unset($_SESSION['securimage_code_disp'][$_POST['form_name']]);
         unset($_SESSION['securimage_code_ctime'][$_POST['form_name']]);
     }
     return true;
 }
コード例 #7
0
    /**
     * Output page markup.
     *
     * @since 3.0.0
     */
    public function html()
    {
        ?>
		<div id="simcal-system-status-report">
			<p><?php 
        _e('Please copy and paste this information when contacting support:', 'google-calendar-events');
        ?>
 </p>
			<textarea readonly="readonly" onclick="this.select();"></textarea>
			<p><?php 
        _e('You can also download your information as a text file to attach, or simply view it below.', 'google-calendar-events');
        ?>
</p>
			<p><a href="#" id="simcal-system-status-report-download" class="button button-primary"><?php 
        _e('Download System Report', 'google-calendar-events');
        ?>
</a></p>
		</div>
		<hr>
		<?php 
        global $wpdb;
        $wp_version = get_bloginfo('version');
        $sections = array();
        $panels = array('wordpress' => array('label' => __('WordPress Installation', 'google-calendar-events'), 'export' => 'WordPress Installation'), 'theme' => array('label' => __('Active Theme', 'google-calendar-events'), 'export' => 'Active Theme'), 'plugins' => array('label' => __('Active Plugins', 'google-calendar-events'), 'export' => 'Active Plugins'), 'server' => array('label' => __('Server Environment', 'google-calendar-events'), 'export' => 'Server Environment'), 'client' => array('label' => __('Client Information', 'google-calendar-events'), 'export' => 'Client Information'));
        /**
         * Plugin Information
         * ==================
         */
        // @todo add report information section for current plugin
        /**
         * WordPress Installation
         * ======================
         */
        $debug_mode = $script_debug = __('No', 'google-calendar-events');
        if (defined('WP_DEBUG')) {
            $debug_mode = true === WP_DEBUG ? __('Yes', 'google-calendar-events') : $debug_mode;
        }
        if (defined('SCRIPT_DEBUG')) {
            $script_debug = true === SCRIPT_DEBUG ? __('Yes', 'google-calendar-events') : $script_debug;
        }
        $memory = $this->let_to_num(WP_MEMORY_LIMIT);
        $memory_export = size_format($memory);
        if ($memory < 67108864) {
            $memory = '<mark class="error">' . sprintf(__('%1$s - It is recomendend to set memory to at least 64MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'google-calendar-events'), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP') . '</mark>';
        } else {
            $memory = '<mark class="ok">' . $memory_export . '</mark>';
        }
        $permalinks = get_option('permalink_structure');
        $permalinks = empty($permalinks) ? '/?' : $permalinks;
        $is_multisite = is_multisite();
        $sections['wordpress'] = array('name' => array('label' => __('Site Name', 'google-calendar-events'), 'label_export' => 'Site Name', 'result' => get_bloginfo('name')), 'home_url' => array('label' => __('Home URL', 'google-calendar-events'), 'label_export' => 'Home URL', 'result' => home_url()), 'site_url' => array('label' => __('Site URL', 'google-calendar-events'), 'label_export' => 'Site URL', 'result' => site_url()), 'version' => array('label' => __('Version', 'google-calendar-events'), 'label_export' => 'Version', 'result' => $wp_version), 'locale' => array('label' => __('Locale', 'google-calendar-events'), 'label_export' => 'Locale', 'result' => get_locale()), 'wp_timezone' => array('label' => __('Timezone', 'google-calendar-events'), 'label_export' => 'Timezone', 'result' => simcal_get_wp_timezone()), 'multisite' => array('label' => __('Multisite', 'google-calendar-events'), 'label_export' => 'Multisite', 'result' => $is_multisite ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => $is_multisite ? 'Yes' : 'No'), 'permalink' => array('label' => __('Permalinks', 'google-calendar-events'), 'label_export' => 'Permalinks', 'result' => '<code>' . $permalinks . '</code>', 'result_export' => $permalinks), 'memory_limit' => array('label' => 'WP Memory Limit', 'result' => $memory, 'result_export' => $memory_export), 'debug_mode' => array('label' => 'WP Debug Mode', 'result' => $debug_mode), 'script_debug' => array('label' => 'Script Debug', 'result' => $script_debug));
        /**
         * Active Theme
         * ============
         */
        include_once ABSPATH . 'wp-admin/includes/theme-install.php';
        if (version_compare($wp_version, '3.4', '<')) {
            $active_theme = get_theme_data(get_stylesheet_directory() . '/style.css');
            $theme_name = '<a href="' . $active_theme['URI'] . '" target="_blank">' . $active_theme['Name'] . '</a>';
            $theme_version = $active_theme['Version'];
            $theme_author = '<a href="' . $active_theme['AuthorURI'] . '" target="_blank">' . $active_theme['Author'] . '</a>';
            $theme_export = $active_theme['Name'] . ' - ' . $theme_version;
        } else {
            $active_theme = wp_get_theme();
            $theme_name = '<a href="' . $active_theme->ThemeURI . '" target="_blank">' . $active_theme->Name . '</a>';
            $theme_version = $active_theme->Version;
            $theme_author = $active_theme->Author;
            $theme_export = $active_theme->Name . ' - ' . $theme_version;
        }
        $theme_update_version = $theme_version;
        $api = themes_api('theme_information', array('slug' => get_template(), 'fields' => array('sections' => false, 'tags' => false)));
        if ($api && !is_wp_error($api)) {
            $theme_update_version = $api->version;
        }
        if (version_compare($theme_version, $theme_update_version, '<')) {
            $theme_version = '<mark class="error">' . $theme_version . ' (' . sprintf(__('%s is available', 'google-calendar-events'), esc_html($theme_update_version)) . ')</mark>';
        } else {
            $theme_version = '<mark class="ok">' . $theme_version . '</mark>';
        }
        $theme = '<dl>';
        $theme .= '<dt>' . __('Name', 'google-calendar-events') . '</dt>';
        $theme .= '<dd>' . $theme_name . '</dd>';
        $theme .= '<dt>' . __('Author', 'google-calendar-events') . '</dt>';
        $theme .= '<dd>' . $theme_author . '</dd>';
        $theme .= '<dt>' . __('Version', 'google-calendar-events') . '</dt>';
        $theme .= '<dd>' . $theme_version . '</dd>';
        $theme .= '</dl>';
        $is_child_theme = is_child_theme();
        $parent_theme = $parent_theme_export = '-';
        if ($is_child_theme) {
            if (version_compare($wp_version, '3.4', '<')) {
                $parent_theme = $parent_theme_export = $active_theme['Template'];
            } else {
                $parent = wp_get_theme($active_theme->Template);
                $parent_theme = '<dl>';
                $parent_theme .= '<dt>' . __('Name', 'google-calendar-events') . '</dt>';
                $parent_theme .= '<dd>' . $parent->Name . '</dd>';
                $parent_theme .= '<dt>' . __('Author', 'google-calendar-events') . '</dt>';
                $parent_theme .= '<dd>' . $parent->Author . '</dd>';
                $parent_theme .= '<dt>' . __('Version', 'google-calendar-events') . '</dt>';
                $parent_theme .= '<dd>' . $parent->Version . '</dd>';
                $parent_theme .= '</dl>';
                $parent_theme_export = strip_tags($parent->Name) . ' - ' . $parent->Version;
            }
        }
        $sections['theme'] = array('theme' => array('label' => __('Theme Information', 'google-calendar-events'), 'label_export' => 'Theme', 'result' => $theme, 'result_export' => $theme_export), 'theme_child' => array('label' => __('Child Theme', 'google-calendar-events'), 'label_export' => 'Child Theme', 'result' => $is_child_theme ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => $is_child_theme ? 'Yes' : 'No'), 'theme_parent' => array('label' => __('Parent Theme', 'google-calendar-events'), 'label_export' => 'Parent Theme', 'result' => $parent_theme, 'result_export' => $parent_theme_export));
        /**
         * Active Plugins
         * ==============
         */
        include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
        $active_plugins = (array) get_option('active_plugins', array());
        if (is_multisite()) {
            $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
        }
        foreach ($active_plugins as $plugin) {
            $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
            if (!empty($plugin_data['Name'])) {
                $plugin_name = $plugin_data['Title'];
                $plugin_author = $plugin_data['Author'];
                $plugin_version = $plugin_update_version = $plugin_data['Version'];
                // Afraid that querying many plugins may risk a timeout.
                if (count($active_plugins) <= 10) {
                    $api = plugins_api('plugin_information', array('slug' => $plugin_data['Name'], 'fields' => array('version' => true)));
                    if ($api && !is_wp_error($api)) {
                        if (!empty($api->version)) {
                            $plugin_update_version = $api->version;
                            if (version_compare($plugin_version, $plugin_update_version, '<')) {
                                $plugin_version = '<mark class="error">' . $plugin_version . ' (' . sprintf(__('%s is available', 'google-calendar-events'), esc_html($plugin_update_version)) . ')</mark>';
                            } else {
                                $plugin_version = '<mark class="ok">' . $plugin_version . '</mark>';
                            }
                        }
                    }
                }
                $plugin = '<dl>';
                $plugin .= '<dt>' . __('Author', 'google-calendar-events') . '</dt>';
                $plugin .= '<dd>' . $plugin_author . '</dd>';
                $plugin .= '<dt>' . __('Version', 'google-calendar-events') . '</dt>';
                $plugin .= '<dd>' . $plugin_version . '</dd>';
                $plugin .= '</dl>';
                $sections['plugins'][sanitize_key(strip_tags($plugin_name))] = array('label' => $plugin_name, 'label_export' => strip_tags($plugin_data['Title']), 'result' => $plugin, 'result_export' => $plugin_data['Version']);
            }
        }
        if (isset($sections['plugins'])) {
            rsort($sections['plugins']);
        }
        /**
         * Server Environment
         * ==================
         */
        if (version_compare(PHP_VERSION, '5.4', '<')) {
            $php = '<mark class="error">' . sprintf(__('%1$s - It is recomendend to upgrade at least to PHP version 5.4 for security reasons. <a href="%2$s" target="_blank">Read more.</a>', 'google-calendar-events'), PHP_VERSION, 'http://www.wpupdatephp.com/update/') . '</mark>';
        } else {
            $php = '<mark class="ok">' . PHP_VERSION . '</mark>';
        }
        if ($wpdb->use_mysqli) {
            $mysql = @mysqli_get_server_info($wpdb->dbh);
        } else {
            $mysql = @mysql_get_server_info();
        }
        $host = $_SERVER['SERVER_SOFTWARE'];
        if (defined('WPE_APIKEY')) {
            $host .= ' (WP Engine)';
        } elseif (defined('PAGELYBIN')) {
            $host .= ' (Pagely)';
        }
        $default_timezone = $server_timezone_export = date_default_timezone_get();
        if ('UTC' !== $default_timezone) {
            $server_timezone = '<mark class="error">' . sprintf(__('Server default timezone is %s - it should be UTC', 'google-calendar-events'), $default_timezone) . '</mark>';
        } else {
            $server_timezone = '<mark class="ok">UTC</mark>';
        }
        // WP Remote POST test.
        $response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array('timeout' => 60, 'body' => array('cmd' => '_notify-validate')));
        if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
            $wp_post_export = 'Yes';
            $wp_post = '<mark class="ok">' . __('Yes', 'google-calendar-events') . '</mark>';
        } else {
            $wp_post_export = 'No';
            $wp_post = '<mark class="error">' . __('No', 'google-calendar-events');
            if (is_wp_error($response)) {
                $error = ' (' . $response->get_error_message() . ')';
                $wp_post .= $error;
                $wp_post_export .= $error;
            } else {
                $error = ' (' . $response['response']['code'] . ')';
                $wp_post .= $error;
                $wp_post_export .= $error;
            }
            $wp_post .= '</mark>';
        }
        // WP Remote GET test.
        $response = wp_safe_remote_get(get_home_url('/?p=1'));
        if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
            $wp_get_export = 'Yes';
            $wp_get = '<mark class="ok">' . __('Yes', 'google-calendar-events') . '</mark>';
        } else {
            $wp_get_export = 'No';
            $wp_get = '<mark class="error">' . __('No', 'google-calendar-events');
            if (is_wp_error($response)) {
                $error = ' (' . $response->get_error_message() . ')';
                $wp_get .= $error;
                $wp_get_export .= $error;
            } else {
                $error = ' (' . $response['response']['code'] . ')';
                $wp_get .= $error;
                $wp_get_export .= $error;
            }
            $wp_get .= '</mark>';
        }
        $php_memory_limit = ini_get('memory_limit');
        $php_max_upload_filesize = ini_get('upload_max_filesize');
        $php_post_max_size = ini_get('post_max_size');
        $php_max_execution_time = ini_get('max_execution_time');
        $php_max_input_vars = ini_get('max_input_vars');
        $sections['server'] = array('host' => array('label' => __('Web Server', 'google-calendar-events'), 'label_export' => 'Web Server', 'result' => $host), 'php_version' => array('label' => __('PHP Version', 'google-calendar-events'), 'label_export' => 'PHP Version', 'result' => $php, 'result_export' => PHP_VERSION), 'mysql_version' => array('label' => __('MySQL Version', 'google-calendar-events'), 'label_export' => 'MySQL Version', 'result' => version_compare($mysql, '5.5', '>') ? '<mark class="ok">' . $mysql . '</mark>' : $mysql, 'result_export' => $mysql), 'server_timezone' => array('label' => __('Server Timezone', 'google-calendar-events'), 'label_export' => 'Server Timezone', 'result' => $server_timezone, 'result_export' => $server_timezone_export), 'display_errors' => array('label' => 'Display Errors', 'result' => ini_get('display_errors') ? __('Yes', 'google-calendar-events') . ' (' . ini_get('display_errors') . ')' : '-', 'result_export' => ini_get('display_errors') ? 'Yes' : 'No'), 'php_safe_mode' => array('label' => 'Safe Mode', 'result' => ini_get('safe_mode') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => ini_get('safe_mode') ? 'Yes' : 'No'), 'php_memory_limit' => array('label' => 'Memory Limit', 'result' => $php_memory_limit ? $php_memory_limit : '-'), 'upload_max_filesize' => array('label' => 'Upload Max Filesize', 'result' => $php_max_upload_filesize ? $php_max_upload_filesize : '-'), 'post_max_size' => array('label' => 'Post Max Size', 'result' => $php_post_max_size ? $php_post_max_size : '-'), 'max_execution_time' => array('label' => 'Max Execution Time', 'result' => $php_max_execution_time ? $php_max_execution_time : '-'), 'max_input_vars' => array('label' => 'Max Input Vars', 'result' => $php_max_input_vars ? $php_max_input_vars : '-'), 'fsockopen' => array('label' => 'fsockopen', 'result' => function_exists('fsockopen') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => function_exists('fsockopen') ? 'Yes' : 'No'), 'curl_init' => array('label' => 'cURL', 'result' => function_exists('curl_init') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => function_exists('curl_init') ? 'Yes' : 'No'), 'soap' => array('label' => 'SOAP', 'result' => class_exists('SoapClient') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => class_exists('SoapClient') ? 'Yes' : 'No'), 'suhosin' => array('label' => 'SUHOSIN', 'result' => extension_loaded('suhosin') ? __('Yes', 'google-calendar-events') : __('No', 'google-calendar-events'), 'result_export' => extension_loaded('suhosin') ? 'Yes' : 'No'), 'wp_remote_post' => array('label' => 'WP Remote POST', 'result' => $wp_post, 'result_export' => $wp_post_export), 'wp_remote_get' => array('label' => 'WP Remote GET', 'result' => $wp_get, 'result_export' => $wp_get_export));
        /**
         * Client Information
         * ==================
         */
        $user_client = new \Browser();
        $browser = '<dl>';
        $browser .= '<dt>' . __('Name:', 'google-calendar-events') . '</dt>';
        $browser .= '<dd>' . $user_client->getBrowser() . '</dd>';
        $browser .= '<dt>' . __('Version:', 'google-calendar-events') . '</dt>';
        $browser .= '<dd>' . $user_client->getVersion() . '</dd>';
        $browser .= '<dt>' . __('User Agent:', 'google-calendar-events') . '</dt>';
        $browser .= '<dd>' . $user_client->getUserAgent() . '</dd>';
        $browser .= '<dt>' . __('Platform:', 'google-calendar-events') . '</dt>';
        $browser .= '<dd>' . $user_client->getPlatform() . '</dd>';
        $browser .= '</dl>';
        $browser_export = $user_client->getBrowser() . ' ' . $user_client->getVersion() . ' (' . $user_client->getPlatform() . ')';
        $sections['client'] = array('user_ip' => array('label' => __('IP Address', 'google-calendar-events'), 'label_export' => 'IP Address', 'result' => $_SERVER['SERVER_ADDR']), 'browser' => array('label' => __('Browser', 'google-calendar-events'), 'result' => $browser, 'result_export' => $browser_export));
        /**
         * Final Output
         * ============
         */
        $panels = apply_filters('simcal_system_status_report_panels', $panels);
        $sections = apply_filters('simcal_system_status_report_sections', $sections);
        foreach ($panels as $panel => $v) {
            if (isset($sections[$panel])) {
                ?>
				<table class="widefat simcal-system-status-report-panel">
					<thead class="<?php 
                echo $panel;
                ?>
">
						<tr>
							<th colspan="3" data-export="<?php 
                echo $v['export'];
                ?>
"><?php 
                echo $v['label'];
                ?>
</th>
						</tr>
					</thead>
					<tbody>
						<?php 
                foreach ($sections[$panel] as $row => $cell) {
                    ?>
							<tr>
								<?php 
                    $label_export = isset($cell['label_export']) ? $cell['label_export'] : $cell['label'];
                    $result_export = isset($cell['result_export']) ? $cell['result_export'] : $cell['result'];
                    ?>
								<td class="tooltip"><?php 
                    echo isset($cell['tooltip']) ? ' <i class="simcal-icon-help simcal-help-tip" data-tip="' . $cell['tooltip'] . '"></i> ' : '';
                    ?>
</td>
								<td class="label" data-export="<?php 
                    echo trim($label_export);
                    ?>
"><?php 
                    echo $cell['label'];
                    ?>
</td>
								<td class="result" data-export="<?php 
                    echo trim($result_export);
                    ?>
"><?php 
                    echo $cell['result'];
                    ?>
</td>
							</tr>
						<?php 
                }
                ?>
					</tbody>
				</table>
				<?php 
            }
        }
        $this->inline_scripts();
    }
コード例 #8
0
ファイル: index.php プロジェクト: dougersa2/shimansky.biz
if (!$ttl) {
    $ttl = 'No title';
}
$ttl = $ExternalCounters->prepare_str(str_replace(" ", "+", $ttl));
$encoding = $ExternalCounters->get_query_param('encoding');
$ttl = $ExternalCounters->fix_ttl_encoding($encoding, $ttl, $rfrr);
$is_robot = '';
$ua = '';
$ua_str = '';
$ua_version = '';
$os = '';
if (!isset($browser) || empty($browser)) {
    $browser = new Browser();
    $is_robot = $browser->isRobot() ? $browser->getBrowser() : '';
    $ua = $browser->getBrowser() ? $browser->getBrowser() : '';
    $ua_str = $browser->getUserAgent() ? $browser->getUserAgent() : 'unknown';
    $ua_version = $browser->getVersion() ? $browser->getVersion() : '';
    $os = $browser->getPlatform() ? $browser->getPlatform() : '';
}
$table_name = $pt_externalcounters_table_name;
$DBH->exec("CREATE TABLE IF NOT EXISTS `" . $table_name . "` ( `id` mediumint(9) NOT NULL AUTO_INCREMENT, `adddate` int(11) DEFAULT NULL, `random` varchar(50) DEFAULT NULL, `user_login` mediumtext NOT NULL, `referer` mediumtext NOT NULL, `self` mediumtext NOT NULL, `page_title` mediumtext NOT NULL, `browser` mediumtext NOT NULL, `number` mediumtext NOT NULL, `os` mediumtext NOT NULL, `os_number` mediumtext NOT NULL, `host` mediumtext NOT NULL, `ip` mediumtext NOT NULL, PRIMARY KEY (`id`), FULLTEXT KEY `page_title` (`page_title`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
if (!$is_robot) {
    try {
        /**
         * if table exists
         */
        if ($ExternalCounters->db_table_exists($DBH, $table_name)) {
            $SQL = "INSERT INTO `" . $table_name . "` ";
            $SQL .= "(`adddate`, `random`, `user_login`, `referer`, `self`, `page_title`, `browser`, `number`, `os`, `os_number`, `host`, `ip`) ";
            //$SQL .= "VALUES (?,?,?,?,?,?,?,?,?,?,?,?);";
            $SQL .= "VALUES (:adddate, :random, :user_login, :referer, :self, :page_title, :browser, :number, :os, :os_number, :host, :ip);";
コード例 #9
0
 /**
  * Get status
  * Credits to @link(https://github.com/reduxframework/redux-framework/blob/master/ReduxCore/inc/class.redux_helpers.php#L367)
  *
  * @since  1.0.0
  * @global  $wpdb | WordPress database object
  * @param  boolean $output_as_json
  * @param  boolean $remote_checks
  * @return array
  */
 public static function get_status($output_as_json = false, $remote_checks = true)
 {
     global $wpdb;
     $data = array();
     // WordPress
     $data['home_url'] = home_url();
     $data['site_url'] = site_url();
     $data['wp_content_url'] = WP_CONTENT_URL;
     $data['wp_ver'] = get_bloginfo('version');
     $data['wp_multisite'] = is_multisite();
     $data['permalink_structure'] = get_option('permalink_structure') ? get_option('permalink_structure') : 'Default';
     $data['front_page_display'] = get_option('show_on_front');
     if ($data['front_page_display'] == 'page') {
         $front_page_id = get_option('page_on_front');
         $blog_page_id = get_option('page_for_posts');
         $data['front_page'] = $front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset';
         $data['posts_page'] = $blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset';
     }
     $data['wp_mem_limit_raw'] = self::let_to_num(WP_MEMORY_LIMIT);
     $data['wp_mem_limit_size'] = size_format($data['wp_mem_limit_raw']);
     $data['db_table_prefix'] = 'Length: ' . strlen($wpdb->prefix) . ' - Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable');
     $data['wp_debug'] = 'false';
     if (defined('WP_DEBUG') && WP_DEBUG) {
         $data['wp_debug'] = 'true';
     }
     $data['wp_lang'] = get_locale();
     // server
     $data['server_info'] = esc_html($_SERVER['SERVER_SOFTWARE']);
     $data['localhost'] = self::bool_to_string(self::is_local_host());
     $data['php_ver'] = function_exists('phpversion') ? esc_html(phpversion()) : 'phpversion() function does not exist.';
     $data['abspath'] = ABSPATH;
     if (function_exists('ini_get')) {
         $data['php_mem_limit'] = size_format(self::let_to_num(ini_get('memory_limit')));
         $data['php_post_max_size'] = size_format(self::let_to_num(ini_get('post_max_size')));
         $data['php_time_limit'] = ini_get('max_execution_time');
         $data['php_max_input_var'] = ini_get('max_input_vars');
         $data['php_display_errors'] = self::bool_to_string(ini_get('display_errors'));
     }
     $data['suhosin_installed'] = extension_loaded('suhosin');
     $data['mysql_ver'] = $wpdb->db_version();
     $data['max_upload_size'] = size_format(wp_max_upload_size());
     $data['def_tz_is_utc'] = 'true';
     if (date_default_timezone_get() !== 'UTC') {
         $data['def_tz_is_utc'] = 'false';
     }
     $data['fsockopen_curl'] = 'false';
     if (function_exists('fsockopen') || function_exists('curl_init')) {
         $data['fsockopen_curl'] = 'true';
     }
     // remote
     if ($remote_checks == true) {
         $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', array('sslverify' => false, 'timeout' => 60, 'body' => array('cmd' => '_notify-validate')));
         if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
             $data['wp_remote_post'] = 'true';
             $data['wp_remote_post_error'] = '';
         } else {
             $data['wp_remote_post'] = 'false';
             $data['wp_remote_post_error'] = $response->get_error_message();
         }
     }
     // custom
     $custom_key = apply_filters('PWP_System_Status\\custom_key', 'custom');
     $custom_array = apply_filters('PWP_System_Status\\custom_array', array());
     $data[$custom_key] = $custom_array;
     // $data['redux_ver']      = esc_html( ReduxFramework::$_version );
     // $data['redux_data_dir'] = ReduxFramework::$_upload_dir;
     // Only is a file-write check
     // $f                         = 'fo' . 'pen';
     // $data['redux_data_writeable'] = self::bool_to_string( @$f( ReduxFramework::$_upload_dir . 'test-log.log', 'a' ) );
     // browser
     if (!class_exists('Browser')) {
         require_once __DIR__ . '/Browser.php';
         // require_once __DIR__ . '/vendor/cbschuld/browser.php/lib/Browser.php'; // @@todo \\
     }
     $browser = new Browser();
     $data['browser']['agent'] = $browser->getUserAgent();
     $data['browser']['browser'] = $browser->getBrowser();
     $data['browser']['version'] = $browser->getVersion();
     $data['browser']['platform'] = $browser->getPlatform();
     $data['browser']['mobile'] = $browser->isMobile() ? 'true' : 'false';
     // theme
     $active_theme = wp_get_theme();
     $data['theme']['name'] = $active_theme->Name;
     $data['theme']['version'] = $active_theme->Version;
     $data['theme']['author_uri'] = $active_theme->{'Author URI'};
     $data['theme']['is_child'] = self::bool_to_string(is_child_theme());
     if (is_child_theme()) {
         $parent_theme = wp_get_theme($active_theme->Template);
         $data['theme']['parent_name'] = $parent_theme->Name;
         $data['theme']['parent_version'] = $parent_theme->Version;
         $data['theme']['parent_author_uri'] = $parent_theme->{'Author URI'};
     }
     // plugins
     $active_plugins = (array) get_option('active_plugins', array());
     if (is_multisite()) {
         $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
     }
     $data['plugins'] = array();
     foreach ($active_plugins as $plugin) {
         $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
         $plugin_name = esc_html($plugin_data['Name']);
         $data['plugins'][$plugin_name] = $plugin_data;
     }
     return $data;
 }
コード例 #10
0
        public static function set_content()
        {
            ?>

            <div class="wrap">
                <div id="sc-settings">
                    <div id="sc-settings-content">

                        <h1><?php 
            _e('System Report', 'sc');
            ?>
</h1>

                        <div id="sc-system-status-report">
                            <p>
                                <?php 
            _e('Please copy and paste this information when contacting support:', 'sc');
            ?>
                            </p>

                            <textarea readonly="readonly" onclick="this.select();"></textarea>

                            <p>
                                <?php 
            _e('You can also download your information as a text file to attach, or simply view it below.', 'sc');
            ?>
                            </p>
                            <p>
                                <a href="#" id="sc-system-status-report-download"
                                   class="button button-primary"><?php 
            _e('Download System Report', 'sc');
            ?>
</a>
                            </p>
                        </div>
                        <hr>
                        <?php 
            global $wpdb, $wp_version;
            $sections = array();
            $panels = array('wordpress' => array('label' => __('WordPress Installation', 'sc'), 'export' => 'WordPress Installation'), 'simple_pay' => array('label' => __('Simple Pay Settings', 'sc'), 'export' => 'Simple Pay Settings'), 'theme' => array('label' => __('Active Theme', 'sc'), 'export' => 'Active Theme'), 'plugins' => array('label' => __('Active Plugins', 'sc'), 'export' => 'Active Plugins'), 'server' => array('label' => __('Server Environment', 'sc'), 'export' => 'Server Environment'), 'client' => array('label' => __('Client Information', 'sc'), 'export' => 'Client Information'));
            // @todo add report information section for current plugin
            global $sc_options;
            $simple_pay_settings = $sc_options->get_settings();
            $sections['simple_pay'] = array();
            // Show version stored in database
            $sections['simple_pay']['sc_version'] = array('label' => __('Plugin Version', 'sc'), 'label_export' => 'Plugin Version', 'result' => get_option('sc_version'));
            foreach ($simple_pay_settings as $key => $value) {
                // Check to see if it's a live key. If it is then we want to hide it in the export.
                if ($key === 'live_secret_key' || $key === 'live_publish_key') {
                    $sections['simple_pay'][$key] = array('label' => $key, 'label_export' => '', 'result' => $value . ' ' . __('(hidden in downloadable report)', 'sc'), 'result_export' => '');
                } else {
                    $sections['simple_pay'][$key] = array('label' => $key, 'label_export' => $key, 'result' => $value);
                }
            }
            /**
             * WordPress Installation
             * ======================
             */
            $debug_mode = $script_debug = __('No', 'sc');
            if (defined('WP_DEBUG')) {
                $debug_mode = true === WP_DEBUG ? __('Yes', 'sc') : $debug_mode;
            }
            if (defined('SCRIPT_DEBUG')) {
                $script_debug = true === SCRIPT_DEBUG ? __('Yes', 'sc') : $script_debug;
            }
            $memory = self::let_to_num(WP_MEMORY_LIMIT);
            $memory_export = size_format($memory);
            if ($memory < 41943040) {
                $memory = '<mark class="error">' . sprintf(__('%1$s - It is recommendend to set memory to at least 40MB. See: <a href="%2$s" target="_blank">Increasing memory allocated to PHP</a>', 'sc'), $memory_export, 'http://codex.wordpress.org/Editing_wp-config.php#Increasing_memory_allocated_to_PHP') . '</mark>';
            } else {
                $memory = '<mark class="ok">' . $memory_export . '</mark>';
            }
            $permalinks = get_option('permalink_structure');
            $permalinks = empty($permalinks) ? '/?' : $permalinks;
            $is_multisite = is_multisite();
            $sections['wordpress'] = array('name' => array('label' => __('Site Name', 'sc'), 'label_export' => 'Site Name', 'result' => get_bloginfo('name')), 'home_url' => array('label' => __('Home URL', 'sc'), 'label_export' => 'Home URL', 'result' => home_url()), 'site_url' => array('label' => __('Site URL', 'sc'), 'label_export' => 'Site URL', 'result' => site_url()), 'version' => array('label' => __('Version', 'sc'), 'label_export' => 'Version', 'result' => $wp_version), 'locale' => array('label' => __('Locale', 'sc'), 'label_export' => 'Locale', 'result' => get_locale()), 'multisite' => array('label' => __('Multisite', 'sc'), 'label_export' => 'Multisite', 'result' => $is_multisite ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => $is_multisite ? 'Yes' : 'No'), 'permalink' => array('label' => __('Permalinks', 'sc'), 'label_export' => 'Permalinks', 'result' => '<code>' . $permalinks . '</code>', 'result_export' => $permalinks), 'memory_limit' => array('label' => __('WP Memory Limit', 'sc'), 'result' => $memory, 'result_export' => $memory_export), 'debug_mode' => array('label' => __('WP Debug Mode', 'sc'), 'result' => $debug_mode), 'script_debug' => array('label' => 'Script Debug', 'result' => $script_debug));
            /**
             * Active Theme
             * ============
             */
            include_once ABSPATH . 'wp-admin/includes/theme-install.php';
            if (version_compare($wp_version, '3.4', '<')) {
                $active_theme = get_theme_data(get_stylesheet_directory() . '/style.css');
                $theme_name = '<a href="' . $active_theme['URI'] . '" target="_blank">' . $active_theme['Name'] . '</a>';
                $theme_version = $active_theme['Version'];
                $theme_author = '<a href="' . $active_theme['AuthorURI'] . '" target="_blank">' . $active_theme['Author'] . '</a>';
                $theme_export = $active_theme['Name'] . ' - ' . $theme_version;
            } else {
                $active_theme = wp_get_theme();
                $theme_name = '<a href="' . $active_theme->ThemeURI . '" target="_blank">' . $active_theme->Name . '</a>';
                $theme_version = $active_theme->Version;
                $theme_author = $active_theme->Author;
                $theme_export = $active_theme->Name . ' - ' . $theme_version;
            }
            $theme_update_version = $theme_version;
            $api = themes_api('theme_information', array('slug' => get_template(), 'fields' => array('sections' => false, 'tags' => false)));
            if ($api && !is_wp_error($api)) {
                $theme_update_version = $api->version;
            }
            if (version_compare($theme_version, $theme_update_version, '<')) {
                $theme_version = '<mark class="error">' . $theme_version . ' (' . sprintf(__('%s is available', 'sc'), esc_html($theme_update_version)) . '</mark>';
            } else {
                $theme_version = '<mark class="ok">' . $theme_version . '</mark>';
            }
            $theme = '<dl>';
            $theme .= '<dt>' . __('Name', 'sc') . '</dt>';
            $theme .= '<dd>' . $theme_name . '</dd>';
            $theme .= '<dt>' . __('Author', 'sc') . '</dt>';
            $theme .= '<dd>' . $theme_author . '</dd>';
            $theme .= '<dt>' . __('Version', 'sc') . '</dt>';
            $theme .= '<dd>' . $theme_version . '</dd>';
            $theme .= '</dl>';
            $is_child_theme = is_child_theme();
            $parent_theme = $parent_theme_export = '-';
            if ($is_child_theme) {
                if (version_compare($wp_version, '3.4', '<')) {
                    $parent_theme = $parent_theme_export = $active_theme['Template'];
                } else {
                    $parent = wp_get_theme($active_theme->Template);
                    $parent_theme = '<dl>';
                    $parent_theme .= '<dt>' . __('Name', 'sc') . '</dt>';
                    $parent_theme .= '<dd>' . $parent->Name . '</dd>';
                    $parent_theme .= '<dt>' . __('Author', 'sc') . '</dt>';
                    $parent_theme .= '<dd>' . $parent->Author . '</dd>';
                    $parent_theme .= '<dt>' . __('Version', 'sc') . '</dt>';
                    $parent_theme .= '<dd>' . $parent->Version . '</dd>';
                    $parent_theme .= '</dl>';
                    $parent_theme_export = strip_tags($parent->Name) . ' - ' . $parent->Version;
                }
            }
            $sections['theme'] = array('theme' => array('label' => __('Theme Information', 'sc'), 'label_export' => 'Theme', 'result' => $theme, 'result_export' => $theme_export), 'theme_child' => array('label' => __('Child Theme', 'sc'), 'label_export' => 'Child Theme', 'result' => $is_child_theme ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => $is_child_theme ? 'Yes' : 'No'), 'theme_parent' => array('label' => __('Parent Theme', 'sc'), 'label_export' => 'Parent Theme', 'result' => $parent_theme, 'result_export' => $parent_theme_export));
            /**
             * Active Plugins
             * ==============
             */
            include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
            $active_plugins = (array) get_option('active_plugins', array());
            if (is_multisite()) {
                $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
            }
            foreach ($active_plugins as $plugin) {
                $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
                if (!empty($plugin_data['Name'])) {
                    $plugin_name = $plugin_data['Title'];
                    $plugin_author = $plugin_data['Author'];
                    $plugin_version = $plugin_update_version = $plugin_data['Version'];
                    // Afraid that querying many plugins may risk a timeout.
                    if (count($active_plugins) <= 10) {
                        $api = plugins_api('plugin_information', array('slug' => $plugin_data['Name'], 'fields' => array('version' => true)));
                        if ($api && !is_wp_error($api)) {
                            if (!empty($api->version)) {
                                $plugin_update_version = $api->version;
                                if (version_compare($plugin_version, $plugin_update_version, '<')) {
                                    $plugin_version = '<mark class="error">' . $plugin_version . ' (' . sprintf(__('%s is available', 'sc'), esc_html($plugin_update_version)) . '</mark>';
                                } else {
                                    $plugin_version = '<mark class="ok">' . $plugin_version . '</mark>';
                                }
                            }
                        }
                    }
                    $plugin = '<dl>';
                    $plugin .= '<dt>' . __('Author', 'sc') . '</dt>';
                    $plugin .= '<dd>' . $plugin_author . '</dd>';
                    $plugin .= '<dt>' . __('Version', 'sc') . '</dt>';
                    $plugin .= '<dd>' . $plugin_version . '</dd>';
                    $plugin .= '</dl>';
                    $sections['plugins'][sanitize_key(strip_tags($plugin_name))] = array('label' => $plugin_name, 'label_export' => strip_tags($plugin_data['Title']), 'result' => $plugin, 'result_export' => $plugin_data['Version']);
                }
            }
            if (isset($sections['plugins'])) {
                rsort($sections['plugins']);
            }
            /**
             * Server Environment
             * ==================
             */
            if (version_compare(PHP_VERSION, '5.4', '<')) {
                $php = '<mark class="error">' . sprintf(__('%1$s - It is recommendend to upgrade at least to PHP version 5.4 for security reasons. <a href="%2$s" target="_blank">Read more.</a>', 'sc'), PHP_VERSION, 'http://www.wpupdatephp.com/update/') . '</mark>';
            } else {
                $php = '<mark class="ok">' . PHP_VERSION . '</mark>';
            }
            if ($wpdb->use_mysqli) {
                $mysql = @mysqli_get_server_info($wpdb->dbh);
            } else {
                $mysql = @mysql_get_server_info();
            }
            $host = $_SERVER['SERVER_SOFTWARE'];
            if (defined('WPE_APIKEY')) {
                $host .= ' (WP Engine)';
            } elseif (defined('PAGELYBIN')) {
                $host .= ' (Pagely)';
            }
            $default_timezone = $server_timezone_export = date_default_timezone_get();
            if ('UTC' !== $default_timezone) {
                $server_timezone = '<mark class="error">' . sprintf(__('Server default timezone is %s - it should be UTC', 'sc'), $default_timezone) . '</mark>';
            } else {
                $server_timezone = '<mark class="ok">UTC</mark>';
            }
            // WP Remote POST test.
            $response = wp_safe_remote_post('https://www.paypal.com/cgi-bin/webscr', array('timeout' => 60, 'body' => array('cmd' => '_notify-validate')));
            if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
                $wp_post_export = 'Yes';
                $wp_post = '<mark class="ok">' . __('Yes', 'gce') . '</mark>';
            } else {
                $wp_post_export = 'No';
                $wp_post = '<mark class="error">' . __('No', 'gce');
                if (is_wp_error($response)) {
                    $error = ' (' . $response->get_error_message() . ')';
                    $wp_post .= $error;
                    $wp_post_export .= $error;
                } else {
                    $error = ' (' . $response['response']['code'] . ')';
                    $wp_post .= $error;
                    $wp_post_export .= $error;
                }
                $wp_post .= '</mark>';
            }
            // WP Remote GET test.
            $response = wp_safe_remote_get(get_home_url('/?p=1'));
            if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
                $wp_get_export = 'Yes';
                $wp_get = '<mark class="ok">' . __('Yes', 'gce') . '</mark>';
            } else {
                $wp_get_export = 'No';
                $wp_get = '<mark class="error">' . __('No', 'gce');
                if (is_wp_error($response)) {
                    $error = ' (' . $response->get_error_message() . ')';
                    $wp_get .= $error;
                    $wp_get_export .= $error;
                } else {
                    $error = ' (' . $response['response']['code'] . ')';
                    $wp_get .= $error;
                    $wp_get_export .= $error;
                }
                $wp_get .= '</mark>';
            }
            $php_memory_limit = ini_get('memory_limit');
            $php_max_upload_filesize = ini_get('upload_max_filesize');
            $php_post_max_size = ini_get('post_max_size');
            $php_max_execution_time = ini_get('max_execution_time');
            $php_max_input_vars = ini_get('max_input_vars');
            $sections['server'] = array('host' => array('label' => __('Web Server', 'sc'), 'label_export' => 'Web Server', 'result' => $host), 'php_version' => array('label' => __('PHP Version', 'sc'), 'label_export' => 'PHP Version', 'result' => $php, 'result_export' => PHP_VERSION), 'mysql_version' => array('label' => __('MySQL Version', 'sc'), 'label_export' => 'MySQL Version', 'result' => version_compare($mysql, '5.5', '>') ? '<mark class="ok">' . $mysql . '</mark>' : $mysql, 'result_export' => $mysql), 'server_timezone' => array('label' => __('Server Timezone', 'sc'), 'label_export' => 'Server Timezone', 'result' => $server_timezone, 'result_export' => $server_timezone_export), 'display_errors' => array('label' => __('Display Errors', 'sc'), 'result' => ini_get('display_errors') ? __('Yes', 'sc') . ' (' . ini_get('display_errors') . ')' : '-', 'result_export' => ini_get('display_errors') ? 'Yes' : 'No'), 'php_safe_mode' => array('label' => __('Safe Mode', 'sc'), 'result' => ini_get('safe_mode') ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => ini_get('safe_mode') ? 'Yes' : 'No'), 'php_memory_limit' => array('label' => __('Memory Limit', 'sc'), 'result' => $php_memory_limit ? $php_memory_limit : '-'), 'upload_max_filesize' => array('label' => __('Upload Max Filesize', 'sc'), 'result' => $php_max_upload_filesize ? $php_max_upload_filesize : '-'), 'post_max_size' => array('label' => __('Post Max Size', 'sc'), 'result' => $php_post_max_size ? $php_post_max_size : '-'), 'max_execution_time' => array('label' => __('Max Execution Time', 'sc'), 'result' => $php_max_execution_time ? $php_max_execution_time : '-'), 'max_input_vars' => array('label' => __('Max Input Vars', 'sc'), 'result' => $php_max_input_vars ? $php_max_input_vars : '-'), 'fsockopen' => array('label' => 'fsockopen', 'result' => function_exists('fsockopen') ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => function_exists('fsockopen') ? 'Yes' : 'No'), 'curl_init' => array('label' => 'cURL', 'result' => function_exists('curl_init') ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => function_exists('curl_init') ? 'Yes' : 'No'), 'soap' => array('label' => 'SOAP', 'result' => class_exists('SoapClient') ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => class_exists('SoapClient') ? 'Yes' : 'No'), 'suhosin' => array('label' => 'SUHOSIN', 'result' => extension_loaded('suhosin') ? __('Yes', 'sc') : __('No', 'sc'), 'result_export' => extension_loaded('suhosin') ? 'Yes' : 'No'), 'wp_remote_post' => array('label' => __('WP Remote POST', 'sc'), 'result' => $wp_post, 'result_export' => $wp_post_export), 'wp_remote_get' => array('label' => __('WP Remote GET', 'sc'), 'result' => $wp_get, 'result_export' => $wp_get_export));
            /**
             * Client Information
             * ==================
             */
            if (!class_exists('Browser')) {
                include_once SC_DIR_PATH . 'libraries/browser-php/Browser.php';
                $user_client = new \Browser();
                $browser = '<dl>';
                $browser .= '<dt>' . __('Name:', 'sc') . '</dt>';
                $browser .= '<dd>' . $user_client->getBrowser() . '</dd>';
                $browser .= '<dt>' . __('Version:', 'sc') . '</dt>';
                $browser .= '<dd>' . $user_client->getVersion() . '</dd>';
                $browser .= '<dt>' . __('User Agent:', 'sc') . '</dt>';
                $browser .= '<dd>' . $user_client->getUserAgent() . '</dd>';
                $browser .= '<dt>' . __('Platform:', 'sc') . '</dt>';
                $browser .= '<dd>' . $user_client->getPlatform() . '</dd>';
                $browser .= '</dl>';
                $browser_export = $user_client->getBrowser() . ' ' . $user_client->getVersion() . ' (' . $user_client->getPlatform() . ')';
            } else {
                $browser = '<dl>';
                $browser .= '<dt>' . __('User Agent:', 'sc') . '</dt>';
                $browser .= '<dd>' . $_SERVER['HTTP_USER_AGENT'] . '</dd>';
                $browser .= '</dl>';
                $browser_export = $_SERVER['HTTP_USER_AGENT'];
            }
            $sections['client'] = array('user_ip' => array('label' => __('IP Address', 'sc'), 'label_export' => 'IP Address', 'result' => $_SERVER['SERVER_ADDR']), 'browser' => array('label' => __('Browser', 'sc'), 'result' => $browser, 'result_export' => $browser_export));
            /**
             * Final Output
             * ============
             */
            $panels = apply_filters('sc_system_status_report_panels', $panels);
            $sections = apply_filters('sc_system_status_report_sections', $sections);
            foreach ($panels as $panel => $v) {
                if (isset($sections[$panel])) {
                    ?>
                                <table class="widefat sc-system-status-report-panel">
                                    <thead class="<?php 
                    echo $panel;
                    ?>
">
                                    <tr>
                                        <th colspan="3" data-export="<?php 
                    echo $v['export'];
                    ?>
"><?php 
                    echo $v['label'];
                    ?>
</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <?php 
                    foreach ($sections[$panel] as $row => $cell) {
                        ?>
                                        <tr>
                                            <?php 
                        $label_export = isset($cell['label_export']) ? $cell['label_export'] : $cell['label'];
                        $result_export = isset($cell['result_export']) ? $cell['result_export'] : $cell['result'];
                        ?>
                                            <td class="tooltip"><?php 
                        echo isset($cell['tooltip']) ? ' <i class="sc-icon-help sc-help-tip" data-tip="' . $cell['tooltip'] . '"></i> ' : '';
                        ?>
</td>
                                            <td class="label" data-export="<?php 
                        echo trim($label_export);
                        ?>
"><?php 
                        echo $cell['label'];
                        ?>
</td>
                                            <td class="result" data-export="<?php 
                        echo trim($result_export);
                        ?>
"><?php 
                        echo $cell['result'];
                        ?>
</td>
                                        </tr>
                                    <?php 
                    }
                    ?>
                                    </tbody>
                                </table>
                                <?php 
                }
            }
            do_action('sc_system_status_report');
            ?>
                        <script type="text/javascript">

                            var report = '';

                            jQuery('.sc-system-status-report-panel thead, .sc-system-status-report-panel tbody').each(function () {

                                if (jQuery(this).is('thead')) {

                                    var label = jQuery(this).find('th').data('export');
                                    report = report + '\n### ' + jQuery.trim(label) + ' ###\n\n';

                                } else {

                                    jQuery('tr', jQuery(this)).each(function () {

                                        var label = jQuery(this).find('td:eq(1)').data('export');
                                        var the_name = jQuery.trim(label).replace(/(<([^>]+)>)/ig, ''); // Remove HTML
                                        var image = jQuery(this).find('td:eq(2)').find('img'); // Get WP 4.2 emojis
                                        var prefix = ( undefined === image.attr('alt') ) ? '' : image.attr('alt') + ' '; // Remove WP 4.2 emojis
                                        var the_value = jQuery.trim(prefix + jQuery(this).find('td:eq(2)').data('export'));
                                        var value_array = the_value.split(', ');
                                        if (value_array.length > 1) {
                                            var temp_line = '';
                                            jQuery.each(value_array, function (key, line) {
                                                temp_line = temp_line + line + '\n';
                                            });
                                            the_value = temp_line;
                                        }

                                        if ( the_name.trim() !== '' ) {
                                            report = report + '' + the_name.trim() + ': ' + the_value.trim() + '\n';
                                        }
                                    });

                                }

                            });

                            try {
                                jQuery('#sc-system-status-report textarea').val(report).focus().select();
                            } catch (e) {
                                console.log(e);
                            }

                            function downloadReport(text, name, type) {
                                var a = document.getElementById('sc-system-status-report-download');
                                var file = new Blob([text], {type: type});
                                a.href = URL.createObjectURL(file);
                                a.download = name;
                            }

                            jQuery('#sc-system-status-report-download').on('click', function () {
                                var file = new Blob([report], {type: 'text/plain'});
                                jQuery(this).attr('href', URL.createObjectURL(file));
                                jQuery(this).attr('download', '<?php 
            echo sanitize_title(str_replace(array('http://', 'https://'), '', get_bloginfo('url')) . '-system-report-' . date('Y-m-d', time()));
            ?>
');
                            });

                        </script>
                    </div></div></div>
            <?php 
        }
コード例 #11
0
 function checkloginAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     # check that an email has been provided
     if (isEmptyString(trim($this->_getParam("email")))) {
         $session->setVar(ERROR_MESSAGE, $this->_translate->translate("profile_email_error"));
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         // return to the home page
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     if (isEmptyString(trim($this->_getParam("password")))) {
         $session->setVar(ERROR_MESSAGE, $this->_translate->translate("profile_password_error"));
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         // return to the home page
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     # check which field user is using to login. default is username
     $credcolumn = "username";
     $login = (string) trim($this->_getParam("email"));
     // $password = encode(sha1(trim($this->_getParam("password"))));
     # check if credcolumn is emai
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($login)) {
         $usertable = new UserAccount();
         if ($usertable->findByEmail($login)) {
             $credcolumn = 'email';
         }
     }
     if (stringContains('!@#', $login)) {
         $credcolumn = 'trx';
         $loginarray = explode('.', $login);
         // debugMessage($loginarray);
         $id = $loginarray[0];
     }
     // debugMessage($credcolumn); exit;
     $browser = new Browser();
     $audit_values = $browser_session = array("browserdetails" => $browser->getBrowserDetailsForAudit(), "browser" => $browser->getBrowser(), "version" => $browser->getVersion(), "useragent" => $browser->getUserAgent(), "os" => $browser->getPlatform(), "ismobile" => $browser->isMobile() ? '1' : 0, "ipaddress" => $browser->getIPAddress());
     // debugMessage($audit_values);
     if ($credcolumn == 'email' || $credcolumn == 'username') {
         $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get("dbAdapter"));
         // define the table, fields and additional rules to use for authentication
         $authAdapter->setTableName('useraccount');
         $authAdapter->setIdentityColumn($credcolumn);
         $authAdapter->setCredentialColumn('password');
         $authAdapter->setCredentialTreatment("sha1(?) AND status = '1' ");
         // set the credentials from the login form
         $authAdapter->setIdentity($login);
         $authAdapter->setCredential($this->_getParam("password"));
         // new class to audit the type of Browser and OS that the visitor is using
         if (!$authAdapter->authenticate()->isValid()) {
             // debugMessage('invalid'); exit;
             // add failed login to audit trail
             $audit_values['module'] = 1;
             $audit_values['usecase'] = '1.1';
             $audit_values['transactiontype'] = USER_LOGIN;
             $audit_values['status'] = "N";
             $audit_values['transactiondetails'] = "Login for user with id '" . $this->_getParam("email") . "' failed. Invalid username or password";
             // exit();
             $this->notify(new sfEvent($this, USER_LOGIN, $audit_values));
             // return to the home page
             if (!isArrayKeyAnEmptyString(URL_FAILURE, $formvalues)) {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
             } else {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoSimple('login', "user");
             }
             return false;
         }
         // user is logged in sucessfully so add information to the session
         $user = $authAdapter->getResultRowObject();
         $useraccount = new UserAccount();
         $useraccount->populate($user->id);
     }
     // exit;
     # trx login
     if ($credcolumn == 'trx') {
         $useraccount = new UserAccount();
         $useraccount->populate($id);
         // debugMessage($result); exit();
         if (isEmptyString($useraccount->getID())) {
             // return to the home page
             if (!isArrayKeyAnEmptyString(URL_FAILURE, $formvalues)) {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
             } else {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoSimple('login', "user");
             }
             return false;
         }
     }
     // debugMessage($useraccount->toArray()); exit();
     $session->setVar("userid", $useraccount->getID());
     $session->setVar("username", $useraccount->getUserName());
     $session->setVar("type", $useraccount->getType());
     $session->setVar("companyid", $useraccount->getCompanyID());
     $session->setVar("istimesheetuser", $useraccount->getIsTimesheetUser());
     $session->setVar("browseraudit", $browser_session);
     $session->setVar("user", json_encode($useraccount->toArray()));
     $session->setVar("company", json_encode($useraccount->getCompany()->toArray()));
     // clear user specific cache, before it is used again
     $this->clearUserCache();
     // Add successful login event to the audit trail
     $audit_values['module'] = 1;
     $audit_values['usecase'] = '1.1';
     $audit_values['transactiontype'] = USER_LOGIN;
     $audit_values['status'] = "Y";
     $audit_values['userid'] = $useraccount->getID();
     $audit_values['transactiondetails'] = "Login for user with id '" . $this->_getParam("email") . "' successful";
     // $this->notify(new sfEvent($this, USER_LOGIN, $audit_values));
     if (isEmptyString($this->_getParam("redirecturl"))) {
         # forward to the dashboard
         $this->_helper->redirector->gotoSimple("index", "dashboard");
     } else {
         # redirect to the page the user was coming from
         if (!isEmptyString($this->_getParam(SUCCESS_MESSAGE))) {
             $successmessage = decode($this->_getParam(SUCCESS_MESSAGE));
             $session->setVar(SUCCESS_MESSAGE, $successmessage);
         }
         $this->_helper->redirector->gotoUrl(decode($this->_getParam("redirecturl")));
     }
 }
コード例 #12
0
/**
 * Render the diagnostics page (adapted from https://github.com/WordImpress/Give/blob/master/includes/admin/system-info.php)
 */
function render_page()
{
    global $wpdb;
    $browser = new \Browser();
    ?>
	<div class="wrap">
		<h1><?php 
    _e('Diagnostics', 'pressbooks');
    ?>
</h1>
		<p><?php 
    _e('Please submit this information with any bug reports.', 'pressbooks');
    ?>
</p>
		<textarea style="width: 800px; max-width: 100%; height: 600px; background: #fff; font-family: monospace;" readonly="readonly" onclick="this.focus(); this.select()" title="<?php 
    _e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'pressbooks');
    ?>
">
<?php 
    $output = "### System Information\n\n";
    $output .= "#### Book Info\n\n";
    $output .= 'Book ID: ' . get_current_blog_id() . "\n";
    $output .= 'Book URL: ' . trailingslashit(get_bloginfo('url')) . "\n";
    $output .= 'Book Privacy: ' . (get_bloginfo('blog_public') ? 'Public' : 'Private') . "\n\n";
    $output .= "#### Browser\n\n";
    $output .= 'Platform: ' . str_replace('mac', 'Mac', $browser->getPlatform()) . "\n";
    $output .= 'Browser Name: ' . $browser->getBrowser() . "\n";
    $output .= 'Browser Version: ' . $browser->getVersion() . "\n";
    $output .= 'User Agent String: ' . $browser->getUserAgent() . "\n\n";
    $output .= '#### WordPress Configuration' . "\n\n";
    $output .= 'Network URL: ' . network_home_url() . "\n";
    $output .= 'Network Type: ' . (is_subdomain_install() ? 'Subdomain' : 'Subdirectory') . "\n";
    $output .= 'Version: ' . get_bloginfo('version') . "\n";
    $output .= 'Language: ' . (defined('WPLANG') && WPLANG ? WPLANG : 'en_US') . "\n";
    $output .= 'WP_ENV: ' . (defined('WP_ENV') ? WP_ENV : 'Not set') . "\n";
    $output .= 'WP_DEBUG: ' . (defined('WP_DEBUG') ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set') . "\n";
    $output .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n\n";
    $output .= "#### Pressbooks Configuration\n\n";
    $output .= 'Version: ' . PB_PLUGIN_VERSION . "\n";
    $theme = wp_get_theme();
    switch_to_blog($GLOBALS['current_site']->blog_id);
    $root_theme = wp_get_theme();
    restore_current_blog();
    $output .= 'Book Theme: ' . $theme->get('Name') . "\n";
    $output .= 'Book Theme Version: ' . $theme->get('Version') . "\n";
    $output .= 'Root Theme: ' . $root_theme->get('Name') . "\n";
    $output .= 'Root Theme Version: ' . $root_theme->get('Version') . "\n\n";
    $output .= "#### Pressbooks Dependencies\n\n";
    $output .= 'Epubcheck: ' . (\Pressbooks\Utility\check_epubcheck_install() ? 'Installed' : 'Not Installed') . "\n";
    // TODO: version
    $output .= 'Kindlegen: ' . (\Pressbooks\Utility\check_kindlegen_install() ? 'Installed' : 'Not Installed') . "\n";
    // TODO: version
    $output .= 'xmllint: ' . (\Pressbooks\Utility\check_xmllint_install() ? 'Installed' : 'Not Installed') . "\n";
    // TODO: version
    $output .= 'PrinceXML: ' . (\Pressbooks\Utility\check_prince_install() ? 'Installed' : 'Not Installed') . "\n";
    // TODO: version
    $output .= 'Saxon-HE: ' . (\Pressbooks\Utility\check_saxonhe_install() ? 'Installed' : 'Not Installed') . "\n\n";
    // TODO: version
    $muplugins = get_mu_plugins();
    if (count($muplugins > 0)) {
        $output .= '#### Must-Use Plugins' . "\n\n";
        foreach ($muplugins as $plugin => $plugin_data) {
            $output .= $plugin_data['Name'] . ': ' . ($plugin_data['Version'] ? $plugin_data['Version'] : 'n/a') . "\n";
        }
    }
    $output .= "\n#### Network Active Plugins\n\n";
    $plugins = get_plugins();
    $network_active_plugins = get_site_option('active_sitewide_plugins', array());
    foreach ($plugins as $plugin_path => $plugin) {
        if (!array_key_exists($plugin_path, $network_active_plugins)) {
            continue;
        }
        $output .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $output .= "\n#### Book Active Plugins\n\n";
    $plugins = get_plugins();
    $active_plugins = get_option('active_plugins', array());
    foreach ($plugins as $plugin_path => $plugin) {
        if (!in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $output .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $output .= "\n#### Inactive Plugins\n\n";
    foreach ($plugins as $plugin_path => $plugin) {
        if (array_key_exists($plugin_path, $network_active_plugins) || in_array($plugin_path, $active_plugins)) {
            continue;
        }
        $output .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
    }
    $output .= "\n#### Server Configuration\n\n";
    $output .= 'PHP Version: ' . PHP_VERSION . "\n";
    $output .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
    $output .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n\n";
    $output .= "#### PHP Configuration\n\n";
    $output .= 'Safe Mode: ' . (ini_get('safe_mode') ? 'Enabled' : 'Disabled' . "\n");
    $output .= 'Memory Limit: ' . ini_get('memory_limit') . "\n";
    $output .= 'Upload Max Size: ' . ini_get('upload_max_filesize') . "\n";
    $output .= 'Post Max Size: ' . ini_get('post_max_size') . "\n";
    $output .= 'Upload Max Filesize: ' . ini_get('upload_max_filesize') . "\n";
    $output .= 'Time Limit: ' . ini_get('max_execution_time') . "\n";
    $output .= 'Max Input Vars: ' . ini_get('max_input_vars') . "\n";
    $output .= 'URL-aware fopen: ' . (ini_get('allow_url_fopen') ? 'On (' . ini_get('allow_url_fopen') . ')' : 'N/A') . "\n";
    $output .= 'Display Errors: ' . (ini_get('display_errors') ? 'On (' . ini_get('display_errors') . ')' : 'N/A') . "\n\n";
    $output .= "#### PHP Extensions\n\n";
    $output .= 'cURL: ' . (function_exists('curl_init') ? 'Supported' : 'Not Supported') . "\n";
    if (function_exists('curl_init') && function_exists('curl_version')) {
        $curl_values = curl_version();
        $output .= 'cURL Version: ' . $curl_values['version'] . "\n";
    }
    $output .= 'imagick: ' . (extension_loaded('imagick') ? 'Installed' : 'Not Installed') . "\n";
    $output .= 'sass: ' . (extension_loaded('sass') ? 'Installed' : 'Not Installed') . "\n";
    $output .= 'xsl: ' . (extension_loaded('xsl') ? 'Installed' : 'Not Installed');
    echo $output;
    ?>
</textarea>
</div>
<?php 
}
コード例 #13
0
ファイル: index.php プロジェクト: cinno/sptoolkit
                document.getElementById('alert_content').innerHTML = 'Attempting to send now...';                
            }
        </script>
    </head>
    <body onload='login_form.u.focus()'>
        
        <?php 
//pull in alert
include "includes/alert.php";
//pull in browser script
include "includes/browser.php";
//put browser info into variable
$browser = new Browser();
//firefox check
if ($browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() <= 7) {
    echo "\n            <div id=\"browser_warning\">Your browser's user agent is <i>" . $browser->getUserAgent() . "</i><br />From this information we can determine you are running an older version of Firefox (v" . $browser->getVersion() . ") that has not been tested...Please update to the latest version of Firefox for maximum compatibility.</div>";
}
//chrome check
if ($browser->getBrowser() == Browser::BROWSER_CHROME && $browser->getVersion() <= 14) {
    echo "\n            <div id=\"browser_warning\">Your browser's user agent is <i>" . $browser->getUserAgent() . "</i><br />From this information we can determine you are running an older version of Chrome (v" . $browser->getVersion() . ") that has not been tested...Please update to the latest version for maximum compatibility.</div>";
}
//ie check
if ($browser->getBrowser() == Browser::BROWSER_IE && $browser->getVersion() <= 8.9) {
    echo "\n            <div id=\"browser_warning\">Your browser's user agent is <i>" . $browser->getUserAgent() . "</i><br />From this information we can determine you are running an older version of Internet Explorer (v" . $browser->getVersion() . ") that has not been tested...Please update to the latest version for maximum compatibility.</div>";
}
if ($browser->getBrowser() != Browser::BROWSER_IE && $browser->getBrowser() != Browser::BROWSER_CHROME && $browser->getBrowser() != Browser::BROWSER_FIREFOX) {
    echo "\n            <div id=\"browser_warning\">Your browser's user agent is <i>" . $browser->getUserAgent() . "</i><br />From this information we can determine you are running a web browser that has not been tested.  Try the latest version of <a href=\"http://google.com/chrome\" target=\"_blank\">Google Chrome</a>, <a href=\"http://microsoft.com/ie\" target=\"_blank\">Microsoft Internet Explorer</a> or <a href=\"http://mozilla.org/firefox\" target=\"_blank\">Mozilla Firefox to ensure maximum compatibility.</a></div>";
}
//look for login errors
if (isset($_SESSION['alert_message'])) {
    //create alert popover
コード例 #14
0
ファイル: Logger.php プロジェクト: romainneutron/Phraseanet
 /**
  *
  * @param Application $app
  * @param databox     $databox
  * @param Browser     $browser
  *
  * @return Session_Logger
  */
 public static function create(Application $app, databox $databox, Browser $browser)
 {
     $colls = [];
     if ($app['authentication']->getUser()) {
         $bases = $app['acl']->get($app['authentication']->getUser())->get_granted_base([], [$databox->get_sbas_id()]);
         foreach ($bases as $collection) {
             $colls[] = $collection->get_coll_id();
         }
     }
     $conn = $databox->get_connection();
     $sql = "INSERT INTO log\n              (id, date,sit_session, user, site, usrid, nav,\n                version, os, res, ip, user_agent,appli, fonction,\n                societe, activite, pays)\n            VALUES\n              (null,now() , :ses_id, :usr_login, :site_id, :usr_id\n              , :browser, :browser_version,  :platform, :screen, :ip\n              , :user_agent, :appli, :fonction, :company, :activity, :country)";
     $params = [':ses_id' => $app['session']->get('session_id'), ':usr_login' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getLogin() : null, ':site_id' => $app['conf']->get(['main', 'key']), ':usr_id' => $app['authentication']->isAuthenticated() ? $app['authentication']->getUser()->getId() : null, ':browser' => $browser->getBrowser(), ':browser_version' => $browser->getExtendedVersion(), ':platform' => $browser->getPlatform(), ':screen' => $browser->getScreenSize(), ':ip' => $browser->getIP(), ':user_agent' => $browser->getUserAgent(), ':appli' => serialize([]), ':fonction' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getJob() : null, ':company' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getCompany() : null, ':activity' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getActivity() : null, ':country' => $app['authentication']->getUser() ? $app['authentication']->getUser()->getCountry() : null];
     $stmt = $conn->prepare($sql);
     $stmt->execute($params);
     $log_id = $conn->lastInsertId();
     $stmt->closeCursor();
     $sql = "INSERT INTO log_colls (id, log_id, coll_id) VALUES (null, :log_id, :coll_id)";
     $stmt = $conn->prepare($sql);
     foreach ($colls as $collId) {
         $stmt->execute([':log_id' => $log_id, ':coll_id' => $collId]);
     }
     $stmt->closeCursor();
     unset($stmt, $conn);
     return new Session_Logger($databox, $log_id);
 }
コード例 #15
0
ファイル: store.php プロジェクト: Simo22/smt2
if (!$d) {
    $did = db_insert(TBL_PREFIX . TBL_DOMAINS, "domain", "'" . $domain . "'");
} else {
    $did = $d['id'];
}
/* create database entry ---------------------------------------------------- */
$fields = "client_id,cache_id,domain_id,os_id,browser_id,browser_ver,user_agent,";
$fields .= "ftu,ip,scr_width,scr_height,vp_width,vp_height,";
$fields .= "sess_date,sess_time,fps,coords_x,coords_y,clicks,hovered,clicked";
$values = "'" . $_POST['client'] . "',";
$values .= "'" . $cache_id . "',";
$values .= "'" . $did . "',";
$values .= "'" . $osid . "',";
$values .= "'" . $browserid . "',";
$values .= "'" . (double) $browser->getVersion() . "',";
$values .= "'" . $browser->getUserAgent() . "',";
$values .= "'" . (int) $_POST['ftu'] . "',";
$values .= "'" . get_ip() . "',";
$values .= "'" . (int) $_POST['screenw'] . "',";
$values .= "'" . (int) $_POST['screenh'] . "',";
$values .= "'" . (int) $_POST['pagew'] . "',";
$values .= "'" . (int) $_POST['pageh'] . "',";
$values .= "NOW(),";
$values .= "'" . (double) $_POST['time'] . "',";
$values .= "'" . (int) $_POST['fps'] . "',";
$values .= "'" . $_POST['xcoords'] . "',";
$values .= "'" . $_POST['ycoords'] . "',";
$values .= "'" . $_POST['clicks'] . "',";
$values .= "'" . array_sanitize($_POST['elhovered']) . "',";
$values .= "'" . array_sanitize($_POST['elclicked']) . "'";
$uid = db_insert(TBL_PREFIX . TBL_RECORDS, $fields, $values);
コード例 #16
0
 public static function compileSystemStatus($json_output = false, $remote_checks = false)
 {
     global $wpdb;
     $sysinfo = array();
     $sysinfo['home_url'] = home_url();
     $sysinfo['site_url'] = site_url();
     $sysinfo['redux_ver'] = esc_html(ReduxFramework::$_version);
     $sysinfo['redux_data_dir'] = ReduxFramework::$_upload_dir;
     $f = 'fo' . 'pen';
     // Only is a file-write check
     $sysinfo['redux_data_writeable'] = self::makeBoolStr(@$f(ReduxFramework::$_upload_dir . 'test-log.log', 'a'));
     $sysinfo['wp_content_url'] = WP_CONTENT_URL;
     $sysinfo['wp_ver'] = get_bloginfo('version');
     $sysinfo['wp_multisite'] = is_multisite();
     $sysinfo['permalink_structure'] = get_option('permalink_structure') ? get_option('permalink_structure') : 'Default';
     $sysinfo['front_page_display'] = get_option('show_on_front');
     if ($sysinfo['front_page_display'] == 'page') {
         $front_page_id = get_option('page_on_front');
         $blog_page_id = get_option('page_for_posts');
         $sysinfo['front_page'] = $front_page_id != 0 ? get_the_title($front_page_id) . ' (#' . $front_page_id . ')' : 'Unset';
         $sysinfo['posts_page'] = $blog_page_id != 0 ? get_the_title($blog_page_id) . ' (#' . $blog_page_id . ')' : 'Unset';
     }
     $sysinfo['wp_mem_limit']['raw'] = self::let_to_num(WP_MEMORY_LIMIT);
     $sysinfo['wp_mem_limit']['size'] = size_format($sysinfo['wp_mem_limit']['raw']);
     $sysinfo['db_table_prefix'] = 'Length: ' . strlen($wpdb->prefix) . ' - Status: ' . (strlen($wpdb->prefix) > 16 ? 'ERROR: Too long' : 'Acceptable');
     $sysinfo['wp_debug'] = 'false';
     if (defined('WP_DEBUG') && WP_DEBUG) {
         $sysinfo['wp_debug'] = 'true';
     }
     $sysinfo['wp_lang'] = get_locale();
     if (!class_exists('Browser')) {
         require_once ReduxFramework::$_dir . 'inc/browser.php';
     }
     $browser = new Browser();
     $sysinfo['browser'] = array('agent' => $browser->getUserAgent(), 'browser' => $browser->getBrowser(), 'version' => $browser->getVersion(), 'platform' => $browser->getPlatform());
     $sysinfo['server_info'] = esc_html($_SERVER['SERVER_SOFTWARE']);
     $sysinfo['localhost'] = self::makeBoolStr(self::isLocalHost());
     $sysinfo['php_ver'] = function_exists('phpversion') ? esc_html(phpversion()) : 'phpversion() function does not exist.';
     $sysinfo['abspath'] = ABSPATH;
     if (function_exists('ini_get')) {
         $sysinfo['php_mem_limit'] = size_format(self::let_to_num(ini_get('memory_limit')));
         $sysinfo['php_post_max_size'] = size_format(self::let_to_num(ini_get('post_max_size')));
         $sysinfo['php_time_limit'] = ini_get('max_execution_time');
         $sysinfo['php_max_input_var'] = ini_get('max_input_vars');
         $sysinfo['php_display_errors'] = self::makeBoolStr(ini_get('display_errors'));
     }
     $sysinfo['suhosin_installed'] = extension_loaded('suhosin');
     $sysinfo['mysql_ver'] = $wpdb->db_version();
     $sysinfo['max_upload_size'] = size_format(wp_max_upload_size());
     $sysinfo['def_tz_is_utc'] = 'true';
     if (date_default_timezone_get() !== 'UTC') {
         $sysinfo['def_tz_is_utc'] = 'false';
     }
     $sysinfo['fsockopen_curl'] = 'false';
     if (function_exists('fsockopen') || function_exists('curl_init')) {
         $sysinfo['fsockopen_curl'] = 'true';
     }
     //$sysinfo['soap_client'] = 'false';
     //if ( class_exists( 'SoapClient' ) ) {
     //    $sysinfo['soap_client'] = 'true';
     //}
     //
     //$sysinfo['dom_document'] = 'false';
     //if ( class_exists( 'DOMDocument' ) ) {
     //    $sysinfo['dom_document'] = 'true';
     //}
     //$sysinfo['gzip'] = 'false';
     //if ( is_callable( 'gzopen' ) ) {
     //    $sysinfo['gzip'] = 'true';
     //}
     if ($remote_checks == true) {
         $response = wp_remote_post('https://www.paypal.com/cgi-bin/webscr', array('sslverify' => false, 'timeout' => 60, 'user-agent' => 'ReduxFramework/' . ReduxFramework::$_version, 'body' => array('cmd' => '_notify-validate')));
         if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
             $sysinfo['wp_remote_post'] = 'true';
             $sysinfo['wp_remote_post_error'] = '';
         } else {
             $sysinfo['wp_remote_post'] = 'false';
             $sysinfo['wp_remote_post_error'] = $response->get_error_message();
         }
         $response = wp_remote_get('http://reduxframework.com/wp-admin/admin-ajax.php?action=get_redux_extensions');
         if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300) {
             $sysinfo['wp_remote_get'] = 'true';
             $sysinfo['wp_remote_get_error'] = '';
         } else {
             $sysinfo['wp_remote_get'] = 'false';
             $sysinfo['wp_remote_get_error'] = $response->get_error_message();
         }
     }
     $active_plugins = (array) get_option('active_plugins', array());
     if (is_multisite()) {
         $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
     }
     $sysinfo['plugins'] = array();
     foreach ($active_plugins as $plugin) {
         $plugin_data = @get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin);
         $plugin_name = esc_html($plugin_data['Name']);
         $sysinfo['plugins'][$plugin_name] = $plugin_data;
     }
     $redux = ReduxFrameworkInstances::get_all_instances();
     $sysinfo['redux_instances'] = array();
     if (!empty($redux) && is_array($redux)) {
         foreach ($redux as $inst => $data) {
             Redux::init($inst);
             $sysinfo['redux_instances'][$inst]['args'] = $data->args;
             $sysinfo['redux_instances'][$inst]['sections'] = $data->sections;
             foreach ($sysinfo['redux_instances'][$inst]['sections'] as $sKey => $section) {
                 if (isset($section['fields']) && is_array($section['fields'])) {
                     foreach ($section['fields'] as $fKey => $field) {
                         if (isset($field['validate_callback'])) {
                             unset($sysinfo['redux_instances'][$inst]['sections'][$sKey]['fields'][$fKey]['validate_callback']);
                         }
                         if ($field['type'] == "js_button") {
                             if (isset($field['script']) && isset($field['script']['ver'])) {
                                 unset($sysinfo['redux_instances'][$inst]['sections'][$sKey]['fields'][$fKey]['script']['ver']);
                             }
                         }
                     }
                 }
             }
             $sysinfo['redux_instances'][$inst]['extensions'] = Redux::getExtensions($inst);
             if (isset($data->extensions['metaboxes'])) {
                 $data->extensions['metaboxes']->init();
                 $sysinfo['redux_instances'][$inst]['metaboxes'] = $data->extensions['metaboxes']->boxes;
             }
             if (isset($data->args['templates_path']) && $data->args['templates_path'] != '') {
                 $sysinfo['redux_instances'][$inst]['templates'] = self::getReduxTemplates($data->args['templates_path']);
             }
         }
     }
     $active_theme = wp_get_theme();
     $sysinfo['theme']['name'] = $active_theme->Name;
     $sysinfo['theme']['version'] = $active_theme->Version;
     $sysinfo['theme']['author_uri'] = $active_theme->{'Author URI'};
     $sysinfo['theme']['is_child'] = self::makeBoolStr(is_child_theme());
     if (is_child_theme()) {
         $parent_theme = wp_get_theme($active_theme->Template);
         $sysinfo['theme']['parent_name'] = $parent_theme->Name;
         $sysinfo['theme']['parent_version'] = $parent_theme->Version;
         $sysinfo['theme']['parent_author_uri'] = $parent_theme->{'Author URI'};
     }
     //if ( $json_output ) {
     //    $sysinfo = json_encode( $sysinfo );
     //}
     //print_r($sysinfo);
     //exit();
     return $sysinfo;
 }
コード例 #17
0
 function processattendanceAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get("config");
     $this->_translate = Zend_Registry::get("translate");
     $validshift = false;
     $formvalues = $this->_getAllParams();
     /* $formvalues = array(
       	 "id" => "",
       			"successmessage" => "Check-In Successfull",
       			"datein" => "Apr 24, 2015",
       			"timein" => "8:40 PM",
       			"inremarks" => "",
       			"status" => "",
       			"userid" => "93"
       	); */
     // debugMessage($formvalues);  //  exit;
     $id = decode($formvalues['id']);
     $formvalues['id'] = $id;
     $timesheet = new Timesheet();
     $user = new UserAccount();
     $user->populate($formvalues['userid']);
     # no shift available at all on profile
     // validate that user is checking into right shift
     if (isEmptyString($id)) {
         $checkindate = date('Y-m-d', strtotime($formvalues['datein']));
         $checkintime = date('H:i:s', strtotime($formvalues['timein']));
         $checkinfulldate = $checkindate . ' ' . $checkintime;
         debugMessage('checkin: ' . $checkinfulldate);
         // if user is already checkin, throw exception
         if (isCheckedIn($formvalues['userid'], $checkindate)) {
             $message = "Check-In failed. Active session already exists";
             $session->setVar(ERROR_MESSAGE, $message);
             exit;
         }
         $hasshift = false;
         $scheduleentry = getSessionEntry($user->getID());
         // debugMessage($scheduleentry);
         if (!isEmptyString($scheduleentry['id']) && !isEmptyString($user->getShift()) && $scheduleentry['status'] == 1) {
             $hasshift = true;
         }
         if ($hasshift) {
             $shift = new ShiftSchedule();
             $shift->populate($scheduleentry['id']);
             // debugMessage($shift->toArray());
             $validstartdate = $checkindate;
             $validstarttime = !isEmptyString($shift->getStartTime()) ? $shift->getStartTime() : $shift->getSession()->getStartTime();
             $validfullstartdate = $validstartdate . ' ' . $validstarttime;
             debugMessage('startin: ' . $validfullstartdate);
             # compute end date and time
             $endtime = !isEmptyString($shift->getEndTime()) ? $shift->getEndTime() : $shift->getSession()->getEndTime();
             $endday = $checkindate;
             $starthr = date('H', strtotime($validstarttime));
             //debugMessage($starthr);
             $endhr = date('H', strtotime($endtime));
             //debugMessage($endhr);
             if ($endhr < $starthr) {
                 $nxtday = date('Y-m-d', strtotime($checkindate . " + 1 day"));
                 $endday = $nxtday;
             }
             $validenddate = $endday;
             $validendtime = $endtime;
             $validfullenddate = $validenddate . ' ' . $validendtime;
             debugMessage('ending: ' . $validfullenddate);
             // validate start and end dates for each session
             $rangevalid = false;
             if (strtotime($checkinfulldate) >= strtotime($shift->getStartDate() . ' 00:00:00')) {
                 $rangevalid = true;
                 if (!isEmptyString($shift->getEndDate())) {
                     $rangevalid = false;
                     if (strtotime($checkinfulldate) <= strtotime($shift->getEndDate() . ' 23:00:00')) {
                         $rangevalid = true;
                     }
                 }
             }
             // also check if the days of the week are in the valid range
             if ($rangevalid) {
                 $todaywkno = date('w', strtotime($checkinfulldate));
                 // debugMessage($todaywkno);
                 $wkdaysprofiled = $user->getDaysOfWeekArray();
                 // debugMessage($wkdaysprofiled);
                 if (!isEmptyString($scheduleentry['workingdays'])) {
                     $wkdaysprofiled = explode(',', preg_replace('!\\s+!', '', trim($scheduleentry['workingdays'])));
                     // debugMessage($wkdaysprofiled);
                 }
                 if (count($wkdaysprofiled) > 0) {
                     if (!in_array($todaywkno, $wkdaysprofiled)) {
                         $rangevalid = false;
                     }
                 }
             }
             // now validate the time within the session
             if ($rangevalid) {
                 if (strtotime($checkinfulldate) >= strtotime($validfullstartdate) && strtotime($checkinfulldate) < strtotime($validfullenddate)) {
                     $validshift = true;
                     $browser = new Browser();
                     $audit_values = $browser_session = array("browserdetails" => $browser->getBrowserDetailsForAudit(), "browser" => $browser->getBrowser(), "version" => $browser->getVersion(), "useragent" => $browser->getUserAgent(), "os" => $browser->getPlatform(), "ismobile" => $browser->isMobile() ? '1' : 0, "ipaddress" => $browser->getIPAddress());
                     $formvalues['sessionid'] = $scheduleentry['sessionid'];
                     $formvalues['ipaddress'] = $audit_values['ipaddress'];
                     $formvalues['browser_details'] = json_encode($audit_values);
                 }
             }
         }
     }
     /* if(!$validshift){
       		 debugMessage('shift fail');
       	} else {
       		debugMessage('shift passed');
       	}
       	debugMessage($formvalues);
       	exit; */
     if (isEmptyString($id)) {
         $formvalues['createdby'] = $session->getVar('userid');
         if (isArrayKeyAnEmptyString('isrequest', $formvalues)) {
             $formvalues['isrequest'] = 0;
             $formvalues['status'] = 0;
             $formvalues['timesheetdate'] = date('Y-m-d', strtotime($formvalues['datein']));
         } else {
             $formvalues['isrequest'] = 1;
             if (isArrayKeyAnEmptyString('status', $formvalues)) {
                 $formvalues['status'] = 2;
             }
         }
     }
     if (!isEmptyString($id)) {
         $timesheet->populate($id);
         $formvalues['lastupdatedby'] = $session->getVar('userid');
         if (isArrayKeyAnEmptyString('isrequest', $formvalues)) {
             if (isEmptyString($timesheet->getHours())) {
                 $timesheet->setHours($timesheet->getComputedHours());
             }
             $formvalues['isrequest'] = 0;
         } else {
             $formvalues['isrequest'] = 1;
         }
         $validshift = true;
     }
     if ($validshift) {
         $timesheet->processPost($formvalues);
         /* debugMessage($timesheet->toArray());
         		 debugMessage('error '.$timesheet->getErrorStackAsString()); exit(); */
         if ($timesheet->hasError()) {
             $session->setVar(ERROR_MESSAGE, $timesheet->getErrorStackAsString());
         } else {
             try {
                 $timesheet->save();
                 $session->setVar(SUCCESS_MESSAGE, $this->_translate->translate($this->_getParam(SUCCESS_MESSAGE)));
             } catch (Exception $e) {
                 $session->setVar(ERROR_MESSAGE, $e->getMessage());
             }
         }
     } else {
         $message = "Check-In failed. Invalid shift or session time detected. <br/> Contact admin for resolution.";
         $session->setVar('contactadmin', 1);
         if (isAdmin() || isCompanyAdmin()) {
             $session->setVar('contactadmin', '');
             $url = $this->view->baseUrl('config/shifts/tab/schedules/userid/' . $user->getID());
             $message = 'Check-In failed. Invalid shift or session time detected. <br/> <a href="' . $url . '">Click here</a> to update schedule for ' . $user->getName();
         }
         $session->setVar(ERROR_MESSAGE, $message);
     }
 }