Esempio n. 1
0
 /**
  * The usual process of a query: check the parameters, send the query to the server, check the results
  *
  * Return the results as an array (for SELECT queries), true for other successfull queries, false on failure
  *
  * @version 1.1.1
  * @date 20100709 (greg) (v1.1.1) changed is_resource() to !empty() because it may return something else
  * @param mixed $parameters
  * @return array or boolean
  */
 public function invoke($parameters = null)
 {
     try {
         if ($this->checkParameters($parameters)) {
             $res = $this->query($parameters);
             // Fix to prevent invoke from returning false if INSERT REPLACE DELETE etc... is executed on success.
             if ($res === true && empty($this->returnId)) {
                 return $this->connector->affectedRows();
             }
             if (!empty($res)) {
                 $results = $this->getResults();
                 if ($this->checkResults($results)) {
                     return $results;
                 }
             } else {
                 return $res;
             }
         }
         return false;
     } catch (Exception $e) {
         $msg = '<p>The faulty query source sql is:<br /><pre class="ui-state-highlight ui-corner-all">' . $this->sql() . '</pre><br />';
         if (!empty($parameters)) {
             $msg .= 'The parameters were:<br /><tt>' . PU_dumpArray($parameters) . '</tt></p>';
         }
         throw new PHPDS_databaseException($msg, 0, $e);
     }
 }
 public function __construct($message = "", $code = 0, $previous = null)
 {
     $msg = '<p>The faulty string source is:<br /><pre class="ui-state-highlight ui-corner-all">' . htmlentities($message) . '</pre><br />';
     if (!empty($code)) {
         $msg .= 'The parameters were:<br /><tt>' . PU_dumpArray($code, null, true) . '</tt></p>';
     }
     parent::__construct($msg, 0, $previous);
 }
 public function __construct($message = "", $code = 0, $previous = null)
 {
     if (is_array($message)) {
         list($format, $key) = $message;
         $msg = sprintf('Missing named argument: "%s"', $key);
     } else {
         $format = $message;
         $msg = 'Unable to build the string using sprintf';
     }
     $this->extendedMessage = '<p>The faulty string source is:</p><pre>' . htmlentities($format) . '</pre>';
     if (!empty($code)) {
         $this->extendedMessage .= '<em>' . PU_dumpArray($code, _('The sprintfn parameters were:'), true) . '</em>';
     }
     parent::__construct($msg, 0, $previous);
 }
Esempio n. 4
0
/**
 * Outputs an array in html
 * A slightly better version of print_r()
 * Note: this output is html
 *
 * @version 2.0
 * @author greg
 *
 * @date 20100825 (greg) (v1.1) updated to deal with associative arrays
 * @date 20110211 (greg) (v1.2) added $htmlize parameter
 * @data 20120630 (greg) (v2.0) made it recursive; improved html
 *
 * @param array $a
 * @param string $title
 * @param boolean $htmlize (default to false) if true html is escaped to be displayed as source
 *
 * @return string
 */
function PU_dumpArray($a, $title = '', $htmlize = false)
{
    $s = $title ? "<p>{$title}</p>" : '';
    if (!(is_array($a) || is_object($a))) {
        $a = array($a);
    }
    if (count($a) == 0) {
        $s .= '(empty array)';
    } else {
        $s .= '<ul class="array_dump">';
        foreach ($a as $k => $e) {
            $t = gettype($e);
            switch ($t) {
                case 'array':
                    $t .= ', ' . count($e) . ' elements';
                    break;
                case 'string':
                    $t .= ', ' . strlen($e) . ' chars, ' . mb_detect_encoding($e);
                    break;
                case 'object':
                    $t .= ' of class "' . get_class($e) . '"';
                    break;
            }
            $s .= '<li>' . '<span class="array_key"><span class="array_grey">[&nbsp;</span>' . $k . '<span class="array_grey">&nbsp;]&nbsp;=&gt;</span></span>' . '&nbsp;<span class="array_type">(' . $t . ')</span>&nbsp;';
            if (is_array($e) || is_object($e)) {
                $e = PU_dumpArray($e, null, $htmlize);
            } else {
                if ($htmlize) {
                    $e = htmlentities($e);
                }
            }
            $s .= '<span class="array_value">' . (string) $e . '</li>';
        }
        $s .= '</ul>';
    }
    return $s;
}
Esempio n. 5
0
        echo "<dd><code>" . (empty($config['guest_group']) ? 'not set' : $config['guest_group']) . "</code></dd>";
        list($plugin, $menu_link) = $navigation->menuPath();
        echo "<dt>Active plugin</dt>";
        $menu_link_ = empty($menu_link) ? '' : ' (path is ' . $menu_link . ')';
        echo "<dd><code>" . (empty($plugin) ? 'not set' : $plugin . $menu_link_) . "</code></dd>";
        echo "<dt>Basepath</dt>";
        echo "<dd><code>" . BASEPATH . "</code></dd>";
        echo "<dt>Working directory</dt>";
        echo "<dd><code>" . getcwd() . "</code></dd>";
        ?>
                    </dl>
                </div>
                <div>
                    <h3>Variable Registry</h3>
                    <pre><?php 
        echo PU_dumpArray($this->classFactory->PluginClasses);
        ?>
</pre>
                </div>
                <?php 
        echo PHPDS_backtrace::phpInfo();
        ?>
                <?php 
    }
    ?>
                <div class="alert alert-success">
                    <strong>End of Report</strong><br>
                    PHP <?php 
    echo phpversion();
    ?>
                </div>
 /**
  * Display an Exception
  *
  * This function will load a predefined template page (in PHP form) in order to warn the user something has gone wrong.
  *
  * If an exception is provided, it will be detailed as much as possible ; if not, only a generic message will be displayed
  *
  * @date 20100918
  * @date 20120511 (v1.1) (greg) output is captured in case we want to save it
  * @date 20120724 (v1.2) (greg) added "probable origin"
  * @version 1.2
  * @author greg <*****@*****.**>
  *
  * @return string the whole output
  *
  * @param Exception $e (optional) the exception to explain
  * @param boolean $detailed whether the details should be displayed or replaced y a generic message
  */
 public function showException(Exception $e = null, $detailed = true)
 {
     // we stop on the first unhandled error
     $this->I_give_up = true;
     if ($this->PHPDS_dependance()->isEmbedded()) {
         return;
     }
     PU_cleanBuffers();
     if (is_a($e, 'Exception')) {
         $lineno = $e->getLine();
         $filepath = $e->getFile();
         $trace = is_a($e, 'PHPDS_exception') ? $e->getExtendedTrace() : $e->getTrace();
         $ignore = is_a($e, 'PHPDS_exception') ? $e->getIgnoreLines() : -1;
         $filefragment = PHPDS_backtrace::fetchCodeFragment($filepath, $lineno);
         if (isset($trace[$ignore])) {
             $frame = $trace[$ignore];
             $framefragment = PHPDS_backtrace::fetchCodeFragment($frame['file'], $frame['line']);
         } else {
             $ignore = -1;
         }
         $message = $e->getMessage();
         $code = $e->getCode();
         $extendedMessage = is_a($e, 'PHPDS_exception') ? $e->getExtendedMessage() : '';
         $config = $this->configuration;
         if (!empty($config)) {
             if (isset($config['config_files_used'])) {
                 $conf['used'] = PU_dumpArray($config['config_files_used']);
             }
             if (isset($config['config_files_missing'])) {
                 $conf['missing'] = PU_dumpArray($config['config_files_missing']);
             }
         }
         $bt = PHPDS_backtrace::asHTML($ignore, $trace);
     } else {
         $message = "Unknown exception...";
         $code = null;
     }
     // now use the theme's error page to format the actual display
     $protocol = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
     // Need this for absolute URL configuration to be sef safe.
     $aurl = $protocol . $_SERVER['SERVER_NAME'] . str_replace('/index.php', '', $_SERVER['PHP_SELF']);
     ob_start();
     // Load error page: $e is the handled exception
     require BASEPATH . 'themes/default/error.php';
     $output = ob_get_clean();
     if (!empty($this->crumbs)) {
         $output = str_replace('<crumbs/>', implode("\n", $this->crumbs), $output);
     }
     if (PU_isAJAX()) {
         // If the error occurred during an AJAX request, we'll send back a lightweight ouput
         $message = $this->display ? "{$message} - file {$filepath} line {$lineno}" : 'Error Concealed - Disabled in config';
         PU_silentHeader('Status: 500 ' . $message);
         PU_silentHeader('HTTP/1.1 500 ' . $message);
         print $message;
     } else {
         // for a regular request, we present a nicely formatted html page; if provided, an extended description of the error is displayed
         if ($detailed) {
             echo $output;
         } else {
             $message = '';
             require BASEPATH . 'themes/default/error.php';
             // $message being empty, only a genetic message is output
         }
     }
     return $output;
 }
 /**
  * Display an Exception
  *
  * This function will load a predefined template page (in PHP form) in order to warn the user something has gone wrong.
  *
  * If an exception is provided, it will be detailed as much as possible ; if not, only a generic message will be displayed
  *
  * @date 20100918
  * @date 20120511 (v1.1) (greg) output is captured in case we want to save it
  * @version 1.1
  * @author greg
  *
  * @return string the whole output
  *
  * @param Exception $e (optional)
  */
 public function showException(Exception $e = null, $display = true)
 {
     // we stop on the first unhandled error
     $this->I_give_up = true;
     if ($this->PHPDS_dependance()->isEmbedded()) {
         return;
     }
     PU_cleanBuffers();
     if (is_a($e, 'Exception')) {
         $lineno = $e->getLine();
         $filepath = $e->getFile();
         $trace = is_a($e, 'PHPDS_exception') ? $e->getExtendedTrace() : $e->getTrace();
         $ignore = is_a($e, 'PHPDS_exception') ? $e->getIgnoreLines() : 1;
         $filefragment = PHPDS_backtrace::fetchCodeFragment($filepath, $lineno);
         $message = $e->getMessage();
         $extendedMessage = is_a($e, 'PHPDS_exception') ? $e->getExtendedMessage() : '';
         $config = $this->configuration;
         if (!empty($config)) {
             if (isset($config['config_files_used'])) {
                 $conf['used'] = PU_dumpArray($config['config_files_used']);
             }
             if (isset($config['config_files_missing'])) {
                 $conf['missing'] = PU_dumpArray($config['config_files_missing']);
             }
         }
         $bt = PHPDS_backtrace::asHTML($ignore, $trace);
     }
     $protocol = empty($_SERVER['HTTPS']) ? 'http://' : 'https://';
     // Need this for absolute URL configuration to be sef safe.
     $aurl = $protocol . $_SERVER['SERVER_NAME'] . str_replace('/index.php', '', $_SERVER['PHP_SELF']);
     ob_start();
     // Load error page: $e is the handled exception
     require_once BASEPATH . 'themes/cloud/error.php';
     $output = ob_get_clean();
     if ($display) {
         echo $output;
     }
     return $output;
 }
Esempio n. 8
0
 /**
  * Execute Controller
  * @author Jason Schoeman
  */
 public function execute()
 {
     // Header information
     $this->template->heading(_('System Information'));
     // Get server variables.
     $php_uname = php_uname();
     $php_os = PHP_OS;
     $mysql_get_server_info = mysql_get_server_info();
     $mysql_get_host_info = mysql_get_host_info();
     $mysql_get_client_info = mysql_get_client_info();
     $mysql_client_encoding = mysql_client_encoding();
     $status = explode('  ', mysql_stat());
     if (function_exists('apache_get_version')) {
         $apache_get_version = apache_get_version();
     } else {
         $apache_get_version = _('Unknown');
     }
     if (function_exists('apache_get_modules')) {
         $apache_modules = apache_get_modules();
     } else {
         $apache_modules = _('Unknown');
     }
     $list_apache_modules = false;
     $list_php_extensions = false;
     $phpversion = phpversion();
     $php_loaded_extensions = get_loaded_extensions();
     // Do some basic checks. //////////////////////////////////////////////////////////
     if ($this->db->selectQuick('_db_core_plugin_activation', 'version', 'plugin_folder', 'PHPDevShell') == $this->configuration['phpdevshell_db_version']) {
         $this->template->ok(_('DATABASE : Your database is up to date.'), false, false);
     } else {
         $this->template->warning(_('DATABASE : Your database version seems to be out dated please read the UPGRADE instructions before attempting to upgrade through the GUI. Upgrade instructions may differ from version to version.'));
     }
     // Check if system down bypass is activated in config.
     if ($this->configuration['system_down_bypass'] == true) {
         $this->template->warning(_('System down bypass is set true in configuration.php, you should set this to false.'));
     }
     // Check if firePHP is running.
     if (!empty($this->configuration['debug']['firePHP'])) {
         $this->template->notice(_('Please be aware, FirePHP is currently switched on, this is a security risk.'));
     }
     ///////////////////////////////////////////////////////////////////////////////////
     // Define.
     $RESULTS = false;
     // Loop $this->configuration array and retrieve data.
     foreach ($this->configuration as $c_key => $c_data) {
         // Alternate color.
         if (is_array($c_data)) {
             $c_data = PU_dumpArray($c_data);
         } else {
             $c_data = print_r($c_data, true);
         }
         $RESULTS[] = array('c_key' => $c_key, 'c_data' => $c_data);
     }
     // Load views.
     $view = $this->factory('views');
     // Set Array.
     $view->set('RESULTS', $RESULTS);
     // Set Values.
     $view->set('phpdevshell_version', $this->configuration['phpdevshell_version']);
     $view->set('php_uname', $php_uname);
     $view->set('mysql_get_server_info', $mysql_get_server_info);
     $view->set('mysql_get_host_info', $mysql_get_host_info);
     $view->set('mysql_get_client_info', $mysql_get_client_info);
     $view->set('mysql_client_encoding', $mysql_client_encoding);
     $view->set('status', $status);
     $view->set('apache_get_version', $apache_get_version);
     $view->set('apache_modules', $apache_modules);
     $view->set('phpversion', $phpversion);
     $view->set('php_loaded_extensions', $php_loaded_extensions);
     // Output Template.
     $view->show();
 }