function getWarnings()
 {
     $warn = array();
     $setupUrl = REL_ROOT_URL . "/admin-setup";
     if (!$this->getDi()->config->get('maintenance')) {
         // cron run
         $t = Am_Cron::getLastRun();
         $diff = time() - $t;
         $tt = $t ? 'at ' . amTime($t) : "NEVER (oops! no records that it has been running at all!)";
         if ($diff > 24 * 3600) {
             $warn[] = "Cron job has been running last time {$tt}, it is more than 24 hours before.<br />\n                Most possible external cron job has been set incorrectly. It may cause very serious problems with the script";
         }
     }
     ////
     if (!$this->getDi()->productTable->count()) {
         $warn[] = "You have not added any products, your signup forms will not work until you <a href='admin-products'>add at least one product</a>";
     }
     // @todo email_queue_enabled enabled without external_cron
     $db_version = $this->getDi()->store->get('db_version');
     if (empty($db_version)) {
         $this->getDi()->store->set('db_version', AM_VERSION);
     } elseif ($db_version != AM_VERSION) {
         $url = REL_ROOT_URL . '/admin-upgrade-db';
         $warn[] = "Seems you have upgraded you aMember Pro installation. Please do not forget to " . "<a href='{$url}'>run database upgrade script</a>";
     }
     // load all plugins
     try {
         foreach ($this->getDi()->plugins as $m) {
             $m->loadEnabled();
         }
     } catch (Exception $e) {
     }
     $event = $this->getDi()->hook->call(Am_Event::ADMIN_WARNINGS);
     $warn = array_merge($warn, $event->getReturn());
     // return
     return $warn;
 }
    function indexAction()
    {
        check_demo();
        $this->view->title = ___('Version Info');
        $trial = "";
        if ('==TRIAL==' != '==' . 'TRIAL==') {
            $trial = "Trial Version (expires ==TRIAL_EXPIRES==)";
        }
        if ('==LITE==' != '==' . 'LITE==') {
            $trial = "<b>LITE Version</b>";
        }
        $am_version = AM_VERSION;
        $zend_version = Zend_Version::VERSION;
        $cron_last_run = Am_Cron::getLastRun() ? amDatetime(Am_Cron::getLastRun()) : ___('Never');
        $cron_last_run_title = ___('Cron Last Run');
        $now = amDatetime('now');
        $now_title = ___('Current Server Date and Time');
        $timezone = date_default_timezone_get();
        $timezone_title = ___('Server Timezone');
        $phpversion = phpversion() . " (" . php_sapi_name() . ")";
        $os = substr(php_uname(), 0, 28);
        if (strlen($os) == 28) {
            $os = "{$os}...";
        }
        $mysql = $this->getDi()->db->selectCell("SELECT VERSION()");
        $db = $this->getDi()->getParameter('db');
        $dsn = sprintf("mysql://%s@%s:%d/%s.%s", $db['mysql']['user'], $db['mysql']['host'], $db['mysql']['port'] ? $db['mysql']['port'] : 3306, $db['mysql']['db'], $db['mysql']['prefix']);
        $root = ROOT_DIR;
        $root_title = ___('Root Folder');
        $modules = array();
        foreach ($this->getDi()->modules->getEnabled() as $m) {
            $fn = APPLICATION_PATH . '/' . $m . '/module.xml';
            if (!file_exists($fn)) {
                continue;
            }
            $xml = simplexml_load_file($fn);
            if (!$xml) {
                continue;
            }
            $version = "(" . $xml->version . ")";
            $modules[] = "{$m} {$version}";
        }
        $modules = join("<br />", $modules);
        $modules_title = ___('Modules');
        $plugins = "";
        foreach (array_merge($this->getDi()->plugins_payment->loadEnabled()->getAllEnabled(), $this->getDi()->plugins_protect->loadEnabled()->getAllEnabled()) as $p) {
            $rClass = new ReflectionClass(get_class($p));
            $plugins .= sprintf("%s (%s - %s) <br />\n", $p->getId(), preg_replace('/\\$' . 'Revision: (\\d+).*/', '$1', $rClass->getConstant('PLUGIN_REVISION')), preg_replace('/\\$' . 'Date: (.+?)\\s+.+/', '$1', $rClass->getConstant('PLUGIN_DATE')));
        }
        $plugins_title = ___('Plugins');
        $_ = explode('_', get_class($this->getDi()->cacheBackend));
        $cacheBackend = array_pop($_);
        $cacheBackend_title = ___('Cache Backend');
        $version_title = ___('Software version info');
        $amInfo = <<<CUT
<div class="grid-container">
<table class="grid">
<tr>
    <th colspan="2">{$version_title}</th>
</tr>
<tr>
    <td align="right">{$now_title}</td>
    <td><strong>{$now}</strong></td>
</tr>
<tr>
    <td align="right">{$timezone_title}</td>
    <td><strong>{$timezone}</strong></td>
</tr>
<tr>
    <td align="right">aMember</td>
    <td><strong>{$am_version}</strong>
    {$trial}
    </td>
</tr>
<tr class="odd">
    <td align="right">Zend Framework</td>
    <td><strong>{$zend_version}</strong></td>
</tr>
<tr>
    <td align="right">PHP</td>
    <td><strong>{$phpversion}</strong></td>
</tr>
<tr class="odd">
    <td align="right">OS</td>
    <td><strong>{$os}</strong></td>
</tr>
<tr>
    <td align="right" rowspan="2">MySQL</td>
    <td><strong>{$mysql}</strong></td>
</tr>
<tr>
    <td><strong>{$dsn}</strong></td>
</tr>
<tr class="odd">
    <td align="right">{$cacheBackend_title}</td>
    <td><strong>{$cacheBackend}</strong></td>
</tr>
<tr>
    <td align="right">{$root_title}</td>
    <td><strong>{$root}</strong></td>
</tr>
<tr class="odd">
    <td align="right">{$cron_last_run_title}</td>
    <td><strong>{$cron_last_run}</strong></td>
</tr>
<tr>
    <td align="right">{$modules_title}</td>
    <td>{$modules}</td>
</tr>
<tr class="odd">
    <td align="right">{$plugins_title}</td>
    <td>{$plugins}</td>
</tr>
</table>
</div>
<br /><br />
CUT;
        ob_start();
        phpinfo(1 | 4 | 8 | 16 | 32);
        $phpInfo = ob_get_clean();
        $phpStyles = <<<CUT
#phpinfo {background-color: #ffffff; color: #000000;}
#phpinfo td, #phpinfo th, #phpinfo h1, #phpinfo h2 {font-family: sans-serif;}
#phpinfo pre {margin: 0px; font-family: monospace;}
#phpinfo a:link {color: #000099; text-decoration: none; background-color: #ffffff;}
#phpinfo a:hover {text-decoration: underline;}
#phpinfo table {border-collapse: collapse;}
#phpinfo .center {text-align: center;}
#phpinfo .center table { margin-left: auto; margin-right: auto; text-align: left;}
#phpinfo .center th { text-align: center !important; }
#phpinfo td, #phpinfo th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;}
#phpinfo h1 {font-size: 150%;}
#phpinfo h2 {font-size: 125%;}
#phpinfo .p {text-align: left;}
#phpinfo .e {background-color: #ccccff; font-weight: bold; color: #000000;}
#phpinfo .h {background-color: #9999cc; font-weight: bold; color: #000000;}
#phpinfo .v {background-color: #cccccc; color: #000000;}
#phpinfo .vr {background-color: #cccccc; text-align: right; color: #000000;}
#phpinfo img {float: right; border: 0px;}
#phpinfo hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;}
CUT;
        preg_match('/<body>(.*)<\\/body>/s', $phpInfo, $matches);
        $phpInfo = $matches[1];
        $content = sprintf('<style type="text/css">%s</style>%s<h1>PHP info</h1><div id="phpinfo" class="grid-container"><br />%s</div>', $phpStyles, $amInfo, $phpInfo);
        $this->view->assign('content', $content);
        $this->view->display("admin/layout.phtml");
    }
Esempio n. 3
0
    function getWarnings()
    {
        $warn = array();
        $setupUrl = REL_ROOT_URL . "/admin-setup";
        $rootUrl = REL_ROOT_URL;
        if (!$this->getDi()->config->get('maintenance')) {
            // cron run
            $t = Am_Cron::getLastRun();
            $diff = time() - $t;
            $tt = $t ? ___('at ') . amDatetime($t) : ___('NEVER (oops! no records that it has been running at all!)');
            if ($diff > 24 * 3600 && APPLICATION_ENV != 'demo') {
                $warn[] = ___('Cron job has been running last time %s, it is more than 24 hours before.
Most possible external cron job has been set incorrectly. It may cause very serious problems with the script.
You can find info how to set up cron job for your installation <a class="link" href="http://www.amember.com/docs/Cron" target="_blank">here</a>.', $tt);
            }
        }
        ////
        if (!$this->getDi()->productTable->count()) {
            $warn[] = ___('You have not added any products, your signup forms will not work until you <a class="link" href="' . $rootUrl . '/admin-products">add at least one product</a>');
        }
        // Check for not approved users.
        if ($this->getDi()->config->get('manually_approve')) {
            $na_users = $this->getDi()->db->selectCell('select count(*) from ?_user where is_approved<1');
            if ($na_users) {
                $warn[] = sprintf(___('Number of users who require approval: %d. %sClick here%s to review these users.'), $na_users, '<a class="link" href="' . REL_ROOT_URL . '/admin-users?_u_search[field-is_approved][val]=0">', '</a>');
            }
        }
        // Check for not approved invoices.
        if ($this->getDi()->config->get('manually_approve_invoice')) {
            $na_invoices = $this->getDi()->db->selectCell('select count(*) from ?_invoice where status=?', Invoice::NOT_CONFIRMED);
            if ($na_invoices) {
                $warn[] = sprintf(___('Number of invoices which require approval: %d. %sClick here%s to review these invoices.'), $na_invoices, '<a class="link" href="' . REL_ROOT_URL . '/default/admin-payments/p/not-approved/index">', '</a>');
            }
        }
        if ($this->getDi()->config->get('email_queue_enabled') && !$this->getDi()->config->get('use_cron')) {
            $warn[] = ___('%sEnable%s and %sconfigure%s external cron if you are using E-Mail Throttle Queue', '<a class="link" href="' . REL_ROOT_URL . '/admin-setup/advanced">', '</a>', '<a class="link" href="http://www.amember.com/docs/Cron">', '</a>');
        }
        if ($this->getDi()->db->selectCell("SELECT COUNT(*) FROM ?_email_template WHERE name in (?a)", array('pending_to_user', 'pending_to_admin', 'expire', 'autoresponder')) && !$this->getDi()->config->get('use_cron')) {
            $warn[] = ___('%sEnable%s and %sconfigure%s external cron if you are using Periodic E-Mails (Autoresponder/Expiration/Pending Notifications)', '<a class="link" href="' . REL_ROOT_URL . '/admin-setup/advanced">', '</a>', '<a class="link" href="http://www.amember.com/docs/Cron">', '</a>');
        }
        // load all plugins
        try {
            foreach ($this->getDi()->plugins as $m) {
                $m->loadEnabled();
            }
        } catch (Exception $e) {
        }
        $event = $this->getDi()->hook->call(Am_Event::ADMIN_WARNINGS);
        $warn = array_merge($warn, $event->getReturn());
        // return
        return $warn;
    }