Exemple #1
0
/**
 * Get a new file to write an attachment to.
 * This function makes sure it doesn't overwrite other attachments,
 * preventing collisions and race conditions.
 *
 * @return filename of the tempfile only (not full path)
 * @since 1.5.2
 */
function sq_get_attach_tempfile()
{
    global $username, $attachment_dir;
    $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
    // using PHP >= 4.3.2 we can be truly atomic here
    $filemods = check_php_version(4, 3, 2) ? 'x' : 'w';
    // give up after 1000 tries
    $TMP_MAX = 1000;
    for ($try = 0; $try < $TMP_MAX; ++$try) {
        $localfilename = GenerateRandomString(32, '', 7);
        $full_localfilename = "{$hashed_attachment_dir}/{$localfilename}";
        // filename collision. try again
        if (file_exists($full_localfilename)) {
            continue;
        }
        // try to open for (binary) writing
        $fp = @fopen($full_localfilename, $filemods);
        if ($fp !== FALSE) {
            // success! make sure it's not readable, close and return filename
            chmod($full_localfilename, 0600);
            fclose($fp);
            return $localfilename;
        }
    }
    // we tried 1000 times but didn't succeed.
    error_box(_("Could not open temporary file to store attachment. Contact your system administrator to resolve this issue."));
    return FALSE;
}
Exemple #2
0
/**
 * Generates a unique file in a specific directory and
 * returns the file name (without the path).
 *
 * @param directory The directory within which to create the file
 *
 * @return mixed FALSE when a failure occurs, otherwise a string
 *               containing the filename of the file only (not
 *               its full path)
 *
 * @since 1.5.2
 *
 */
function sq_create_tempfile($directory)
{
    // give up after 1000 tries
    $maximum_tries = 1000;
    // using PHP >= 4.3.2 we can be truly atomic here
    $filemods = check_php_version(4, 3, 2) ? 'x' : 'w';
    for ($try = 0; $try < $maximum_tries; ++$try) {
        $localfilename = GenerateRandomString(32, '', 7);
        $full_localfilename = $directory . DIRECTORY_SEPARATOR . $localfilename;
        // filename collision. try again
        if (file_exists($full_localfilename)) {
            continue;
        }
        // try to open for (binary) writing
        $fp = @fopen($full_localfilename, $filemods);
        if ($fp !== FALSE) {
            // success! make sure it's not readable, close and return filename
            chmod($full_localfilename, 0600);
            fclose($fp);
            return $localfilename;
        }
    }
    // we tried as many times as we could but didn't succeed.
    return FALSE;
}
 function get_content()
 {
     global $CFG;
     if (empty($CFG->enableglobalsearch)) {
         return '';
     }
     //cache block contents
     if ($this->content !== NULL) {
         return $this->content;
     }
     //if
     $this->content = new stdClass();
     //lazy check for the moment
     if (check_php_version("5.0.0")) {
         //fetch values if defined in admin, otherwise use defaults
         $label = !empty($CFG->block_search_text) ? $CFG->block_search_text : get_string('searchmoodle', 'block_search');
         $button = !empty($CFG->block_search_button) ? $CFG->block_search_button : get_string('go', 'block_search');
         //basic search form
         $this->content->text = '<form id="searchquery" method="get" action="' . $CFG->wwwroot . '/search/query.php"><div>' . '<label for="block_search_q">' . $label . '</label>' . '<input id="block_search_q" type="text" name="query_string" />' . '<input type="submit" value="' . $button . '" />' . '</div></form>';
     } else {
         $this->content->text = "Sorry folks, PHP 5 is needed for the new search module.";
     }
     //else
     //no footer, thanks
     $this->content->footer = '';
     return $this->content;
 }
function wp_eMember_membership_level()
{
    echo '<div class="wrap"><h2>WP eMembers - Manage Access Levels v' . WP_EMEMBER_VERSION . '</h2>';
    echo check_php_version();
    echo eMember_admin_submenu_css();
    $current = isset($_GET['level_action']) && $_GET['level_action'] > 0 && $_GET['level_action'] < 4 ? $_GET['level_action'] : 1;
    ?>
    <h3 class="nav-tab-wrapper">
        <a class="nav-tab <?php 
    echo $current == 1 ? 'nav-tab-active' : '';
    ?>
" href="admin.php?page=eMember_membership_level_menu&level_action=1">Manage Levels</a>
        <a class="nav-tab <?php 
    echo $current == 2 ? 'nav-tab-active' : '';
    ?>
" href="admin.php?page=eMember_membership_level_menu&level_action=2">Manage Content Protection</a>
    </h3>
    <?php 
    switch ($current) {
        case '2':
            content_protection();
            break;
        default:
            manage_access_levels();
            break;
    }
    echo '</div>';
}
Exemple #5
0
/**
 *
 * LICENSE: GNU General Public License, version 2 (GPLv2)
 * Copyright 2001 - 2014 Ampache.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License v2
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
function check_php()
{
    if (check_php_version() && check_php_hash() && check_php_hash_algo() && check_php_pdo() && check_php_pdo_mysql() && check_php_session() && check_php_json() && check_php_safemode()) {
        return true;
    }
    return false;
}
Exemple #6
0
 /**
  * Constructor
  *
  * @param mixed $dbh
  * DB handle, or WikiDB object (from which the DB handle will
  * be extracted.
  *
  * @param string $table
  * Name of SQL table containing session data.
  */
 function DbSession(&$dbh, $table = 'session')
 {
     // Check for existing DbSession handler
     $db_type = $dbh->getParam('dbtype');
     if (isa($dbh, 'WikiDB')) {
         // will fail with php4 and case-sensitive filesystem
         //$db_type = substr(get_class($dbh),7);
         // < 4.1.2 crash on dba sessions at session_write_close().
         // (Tested with 4.1.1 and 4.1.2)
         // Didn't try postgres sessions.
         if (!check_php_version(4, 1, 2) and $db_type == 'dba') {
             return false;
         }
         @(include_once "lib/DbSession/" . $db_type . ".php");
         $class = "DbSession_" . $db_type;
         if (class_exists($class)) {
             // dba has no ->_dbh, so this is used for the session link
             $this->_backend = new $class($dbh->_backend->_dbh, $table);
             return $this;
         }
     }
     //Fixme: E_USER_WARNING ignored!
     trigger_error(sprintf(_("Your WikiDB DB backend '%s' cannot be used for DbSession.") . " " . _("Set USE_DB_SESSION to false."), $db_type), E_USER_WARNING);
     return false;
 }
Exemple #7
0
/**
 * Check if user has previously logged in to the SquirrelMail session.  If user
 * has not logged in, execution will stop inside this function.
 *
 * @return int A positive value is returned if user has previously logged in
 * successfully.
 */
function is_logged_in()
{
    if (sqsession_is_registered('user_is_logged_in')) {
        return;
    } else {
        global $PHP_SELF, $HTTP_POST_VARS, $_POST, $session_expired_post, $session_expired_location, $squirrelmail_language;
        //  First we store some information in the new session to prevent
        //  information-loss.
        //
        if (!check_php_version(4, 1)) {
            $session_expired_post = $HTTP_POST_VARS;
        } else {
            $session_expired_post = $_POST;
        }
        $session_expired_location = $PHP_SELF;
        if (!sqsession_is_registered('session_expired_post')) {
            sqsession_register($session_expired_post, 'session_expired_post');
        }
        if (!sqsession_is_registered('session_expired_location')) {
            sqsession_register($session_expired_location, 'session_expired_location');
        }
        session_write_close();
        // signout page will deal with users who aren't logged
        // in on its own; don't show error here
        //
        if (strpos($PHP_SELF, 'signout.php') !== FALSE) {
            return;
        }
        include_once SM_PATH . 'functions/display_messages.php';
        set_up_language($squirrelmail_language, true);
        logout_error(_("You must be logged in to access this page."));
        exit;
    }
}
Exemple #8
0
/**
 * Decode euc-kr encoded string
 * @param string $string euc-kr string
 * @param boolean $save_html don't html encode special characters if true
 * @return string $string decoded string
 */
function charset_decode_euc_kr($string, $save_html = false)
{
    // global $aggressive_decoding;
    // don't do decoding when there are no 8bit symbols
    if (!sq_is8bit($string, 'euc-kr')) {
        return $string;
    }
    // this is CPU intensive task. Use recode functions if they are available.
    if (function_exists('recode_string')) {
        // if string is already sanitized, undo htmlspecial chars
        if (!$save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        $string = recode_string("euc-kr..html", $string);
        // if string sanitizing is not needed, undo htmlspecialchars applied by recode.
        if ($save_html) {
            $string = str_replace(array('&quot;', '&lt;', '&gt;', '&amp;'), array('"', '<', '>', '&'), $string);
        }
        return $string;
    }
    /*
     * iconv does not support html target, but internal utf-8 decoding is faster 
     * than pure php implementation. 
     */
    if (function_exists('iconv') && file_exists(SM_PATH . 'functions/decode/utf_8.php')) {
        include_once SM_PATH . 'functions/decode/utf_8.php';
        $string = iconv('euc-kr', 'utf-8', $string);
        return charset_decode_utf_8($string);
    }
    // try mbstring
    if (function_exists('mb_convert_encoding') && function_exists('sq_mb_list_encodings') && check_php_version(4, 3, 0) && in_array('euc-kr', sq_mb_list_encodings())) {
        return mb_convert_encoding($string, 'HTML-ENTITIES', 'EUC-KR');
    }
    return $string;
}
Exemple #9
0
 function WikiDB_backend_PearDB($dbparams)
 {
     // Find and include PEAR's DB.php. maybe we should force our private version again...
     // if DB would have exported its version number, it would be easier.
     @(require_once 'DB/common.php');
     // Either our local pear copy or the system one
     // check the version!
     $name = check_php_version(5) ? "escapeSimple" : strtolower("escapeSimple");
     // TODO: apparently some Pear::Db version adds LIMIT 1,0 to getOne(),
     // which is invalid for "select version()"
     if (!in_array($name, get_class_methods("DB_common"))) {
         $finder = new FileFinder();
         $dir = dirname(__FILE__) . "/../../pear";
         $finder->_prepend_to_include_path($dir);
         include_once "{$dir}/DB/common.php";
         // use our version instead.
         if (!in_array($name, get_class_methods("DB_common"))) {
             $pearFinder = new PearFileFinder("lib/pear");
             $pearFinder->includeOnce('DB.php');
         } else {
             include_once "{$dir}/DB.php";
         }
     } else {
         include_once "DB.php";
     }
     // Install filter to handle bogus error notices from buggy DB.php's.
     // TODO: check the Pear_DB version, but how?
     if (DEBUG) {
         global $ErrorManager;
         $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_pear_notice_filter'));
         $this->_pearerrhandler = true;
     }
     // Open connection to database
     $this->_dsn = $dbparams['dsn'];
     $this->_dbparams = $dbparams;
     $this->_lock_count = 0;
     // persistent is usually a DSN option: we override it with a config value.
     //   phptype://username:password@hostspec/database?persistent=false
     $dboptions = array('persistent' => DATABASE_PERSISTENT, 'debug' => 2);
     //if (preg_match('/^pgsql/', $this->_dsn)) $dboptions['persistent'] = false;
     $this->_dbh = DB::connect($this->_dsn, $dboptions);
     $dbh =& $this->_dbh;
     if (DB::isError($dbh)) {
         trigger_error(sprintf("Can't connect to database: %s", $this->_pear_error_message($dbh)), isset($dbparams['_tryroot_from_upgrade']) ? E_USER_WARNING : E_USER_ERROR);
         if (isset($dbparams['_tryroot_from_upgrade'])) {
             return;
         }
     }
     $dbh->setErrorHandling(PEAR_ERROR_CALLBACK, array($this, '_pear_error_callback'));
     $dbh->setFetchMode(DB_FETCHMODE_ASSOC);
     $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
     $this->_table_names = array('page_tbl' => $prefix . 'page', 'version_tbl' => $prefix . 'version', 'link_tbl' => $prefix . 'link', 'recent_tbl' => $prefix . 'recent', 'nonempty_tbl' => $prefix . 'nonempty');
     $page_tbl = $this->_table_names['page_tbl'];
     $version_tbl = $this->_table_names['version_tbl'];
     $this->page_tbl_fields = "{$page_tbl}.id AS id, {$page_tbl}.pagename AS pagename, {$page_tbl}.hits AS hits";
     $this->version_tbl_fields = "{$version_tbl}.version AS version, {$version_tbl}.mtime AS mtime, " . "{$version_tbl}.minor_edit AS minor_edit, {$version_tbl}.content AS content, {$version_tbl}.versiondata AS versiondata";
     $this->_expressions = array('maxmajor' => "MAX(CASE WHEN minor_edit=0 THEN version END)", 'maxminor' => "MAX(CASE WHEN minor_edit<>0 THEN version END)", 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "content<>''");
 }
Exemple #10
0
 function open($mode = 'w')
 {
     if ($this->_dbh) {
         return;
     }
     // already open.
     $watchdog = $this->_timeout;
     global $ErrorManager;
     $this->_dba_open_error = false;
     $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_dba_open_error_handler'));
     // oops, you don't have DBA support.
     if (!function_exists("dba_open")) {
         echo "You don't seem to have DBA support compiled into PHP.";
     }
     // lock supported since 4.3.0:
     if (check_php_version(4, 3, 0) and strlen($mode) == 1) {
         // PHP 4.3.x Windows lock bug workaround: http://bugs.php.net/bug.php?id=23975
         if (isWindows()) {
             $mode .= "-";
             // suppress locking, or
         } elseif ($this->_handler != 'gdbm') {
             // gdbm does it internally
             $mode .= "d";
             // else use internal locking
         }
     }
     while (($dbh = dba_open($this->_file, $mode, $this->_handler)) < 1) {
         if ($watchdog <= 0) {
             break;
         }
         flush();
         // "c" failed, try "w" instead.
         if (substr($mode, 0, 1) == "c" and file_exists($this->_file)) {
             $mode = "w";
         }
         // conflict: wait some random time to unlock (see ethernet)
         $secs = 0.5 + (double) rand(1, 32767) / 32767;
         sleep($secs);
         $watchdog -= $secs;
         if (strlen($mode) == 2) {
             $mode = substr($mode, 0, -1);
         }
     }
     $ErrorManager->popErrorHandler();
     if (!$dbh) {
         if ($error = $this->_dba_open_error) {
             $error->errno = E_USER_ERROR;
             $error->errstr .= "\nfile: " . $this->_file . "\nmode: " . $mode . "\nhandler: " . $this->_handler;
             $ErrorManager->handleError($error);
         } else {
             trigger_error("dba_open failed", E_USER_ERROR);
         }
     }
     $this->_dbh = $dbh;
     return !empty($dbh);
 }
Exemple #11
0
 function _DbPassUser($UserName = '', $prefs = false)
 {
     if (!$this->_prefs) {
         if ($prefs) {
             $this->_prefs = $prefs;
         }
     }
     if (!isset($this->_prefs->_method)) {
         _PassUser::_PassUser($UserName);
     } elseif (!$this->isValidName($UserName)) {
         trigger_error(_("Invalid username."), E_USER_WARNING);
         return false;
     }
     $this->_authmethod = 'Db';
     //$this->getAuthDbh();
     //$this->_auth_crypt_method = @$GLOBALS['DBAuthParams']['auth_crypt_method'];
     $dbi =& $GLOBALS['request']->_dbi;
     $dbtype = $dbi->getParam('dbtype');
     if ($dbtype == 'ADODB') {
         include_once "lib/WikiUser/AdoDb.php";
         if (check_php_version(5)) {
             return new _AdoDbPassUser($UserName, $this->_prefs);
         } else {
             $user = new _AdoDbPassUser($UserName, $this->_prefs);
             eval("\$this = \$user;");
             return $user;
         }
     } elseif ($dbtype == 'SQL') {
         include_once "lib/WikiUser/PearDb.php";
         if (check_php_version(5)) {
             return new _PearDbPassUser($UserName, $this->_prefs);
         } else {
             $user = new _PearDbPassUser($UserName, $this->_prefs);
             eval("\$this = \$user;");
             return $user;
         }
     } elseif ($dbtype == 'PDO') {
         include_once "lib/WikiUser/PdoDb.php";
         if (check_php_version(5)) {
             return new _PdoDbPassUser($UserName, $this->_prefs);
         } else {
             $user = new _PdoDbPassUser($UserName, $this->_prefs);
             eval("\$this = \$user;");
             return $user;
         }
     }
     return false;
 }
function wp_eMember_dashboard()
{
    echo '<div class="wrap"><h2>WP eMembers - Dashboard v' . WP_EMEMBER_VERSION . '</h2>';
    echo check_php_version();
    echo eMember_admin_submenu_css();
    ?>
    <h3 class="nav-tab-wrapper">
        <a class="nav-tab nav-tab-active" href="#">Dashboard</a>
        <a class="nav-tab" href="admin.php?page=wp_eMember_manage">Members</a>
        <a class="nav-tab" href="admin.php?page=eMember_membership_level_menu">Membership Levels</a>
        <a class="nav-tab" href="admin.php?page=eMember_settings_menu">Settings</a>
    </h3>
    <?php 
    wp_eMember_dashboard1();
    echo '</div>';
}
 function testLinks()
 {
     $uplink = 'http://' . (defined('SERVER_NAME') ? SERVER_NAME : '') . DATA_PATH . '/uploads/image.jpg';
     $tests = array("[label|link]" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:4:"link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', "[ label | link.jpg ]" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:8:"link.jpg";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', "[ image.jpg | link ]" => check_php_version(5) ? 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"HtmlElement":4:{s:4:"_tag";s:6:"object";s:5:"_attr";a:5:{s:3:"src";s:0:"";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:12:"inlineobject";s:4:"type";b:0;}s:8:"_content";a:1:{i:0;O:11:"HtmlElement":4:{s:4:"_tag";s:5:"embed";s:5:"_attr";a:5:{s:3:"src";s:0:"";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:12:"inlineobject";s:4:"type";b:0;}s:8:"_content";a:0:{}s:11:"_properties";i:4;}}s:11:"_properties";i:6;}}i:2;s:0:"";}}' : 'o:10:"xmlcontent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;o:15:"cached_wikilink":2:{s:5:"_page";s:4:"link";s:6:"_label";o:11:"htmlelement":4:{s:8:"_content";a:1:{i:0;o:11:"htmlelement":4:{s:8:"_content";a:0:{}s:4:"_tag";s:5:"embed";s:5:"_attr";a:5:{s:3:"src";s:0:"";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:12:"inlineobject";s:4:"type";b:0;}s:11:"_properties";i:4;}}s:4:"_tag";s:6:"object";s:5:"_attr";a:5:{s:3:"src";s:0:"";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:12:"inlineobject";s:4:"type";b:0;}s:11:"_properties";i:6;}}i:2;s:0:"";}}', "[ Upload:image.jpg | link ]" => !check_php_version(5) ? 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"HtmlElement":4:{s:8:"_content";a:0:{}s:4:"_tag";s:3:"img";s:5:"_attr";a:4:{s:3:"src";s:' . strlen($uplink) . ':"' . $uplink . '";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:11:"inlineimage";}s:11:"_properties";i:7;}}i:2;s:0:"";}}' : 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"HtmlElement":4:{s:4:"_tag";s:3:"img";s:5:"_attr";a:4:{s:3:"src";s:' . strlen($uplink) . ':"' . $uplink . '";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:11:"inlineimage";}s:8:"_content";a:0:{}s:11:"_properties";i:7;}}i:2;s:0:"";}}', "[ http://server/image.jpg | link ]" => !check_php_version(5) ? 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"HtmlElement":4:{s:8:"_content";a:0:{}s:4:"_tag";s:3:"img";s:5:"_attr";a:4:{s:3:"src";s:23:"http://server/image.jpg";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:11:"inlineimage";}s:11:"_properties";i:7;}}i:2;s:0:"";}}' : 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:15:"Cached_WikiLink":2:{s:5:"_page";s:4:"link";s:6:"_label";O:11:"HtmlElement":4:{s:4:"_tag";s:3:"img";s:5:"_attr";a:4:{s:3:"src";s:23:"http://server/image.jpg";s:3:"alt";s:4:"link";s:5:"title";s:4:"link";s:5:"class";s:11:"inlineimage";}s:8:"_content";a:0:{}s:11:"_properties";i:7;}}i:2;s:0:"";}}', "[ label | http://server/link ]" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"Cached_ExternalLink":2:{s:4:"_url";s:18:"http://server/link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', "[ label | Upload:link ]" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:20:"Cached_InterwikiLink":2:{s:5:"_link";s:11:"Upload:link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', "[ label | phpwiki:action=link ]" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:17:"Cached_PhpwikiURL":2:{s:4:"_url";s:19:"phpwiki:action=link";s:6:"_label";s:5:"label";}i:2;s:0:"";}}', "Upload:image.jpg" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:20:"Cached_InterwikiLink":1:{s:5:"_link";s:16:"Upload:image.jpg";}i:2;s:0:"";}}', "http://server/image.jpg" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"Cached_ExternalLink":1:{s:4:"_url";s:23:"http://server/image.jpg";}i:2;s:0:"";}}', "http://server/link" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"Cached_ExternalLink":1:{s:4:"_url";s:18:"http://server/link";}i:2;s:0:"";}}', "[http:/server/~name/]" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"Cached_ExternalLink":1:{s:4:"_url";s:18:"http:/server/name/";}i:2;s:0:"";}}', "http:/server/~name/" => 'O:10:"XmlContent":1:{s:8:"_content";a:3:{i:0;s:0:"";i:1;O:19:"Cached_ExternalLink":1:{s:4:"_url";s:18:"http:/server/name/";}i:2;s:0:"";}}');
     //$i = 0;
     foreach ($tests as $wiki => $expected) {
         //print $i++ . " .. ";
         $xml = TransformInline($wiki);
         $this->assertTrue(isa($xml, 'XmlContent'));
         $actual = serialize($xml);
         if (!check_php_version(5)) {
             $expected = strtolower($expected);
             $actual = strtolower($actual);
         }
         $this->assertEquals($expected, $actual);
     }
 }
Exemple #14
0
function wp_eMember_members()
{
    echo '<div class="wrap"><h2>WP eMembers - Members v' . WP_EMEMBER_VERSION . '</h2>';
    echo check_php_version();
    echo eMember_admin_submenu_css();
    $_GET['members_action'] = isset($_GET['members_action']) ? $_GET['members_action'] : "";
    switch ($_GET['members_action']) {
        case 'add_edit':
            build_menu(2);
            wp_eMember_add_memebers();
            break;
        case 'manage_list':
            build_menu(3);
            wp_eMember_manage_memebers_lists();
            break;
        case 'edit_ip_lock':
            build_menu(1);
            wp_eMember_edit_ip_lock();
            break;
        case 'add_wp_members':
            build_menu(4);
            wp_eMember_add_wp_members();
            break;
        case 'manage_blacklist':
            build_menu(5);
            wp_eMember_manage_blackList();
            break;
        case 'manage_upgrade':
            build_menu(6);
            wp_eMember_manage_upgrade();
            break;
        case 'manage':
        default:
            build_menu(1);
            wp_eMember_manage_members();
            break;
    }
    echo '</div>';
}
Exemple #15
0
 /** A BogoLoginUser requires no password at all
  *  But if there's one stored, we override it with the PersonalPagePassUser instead
  */
 function checkPass($submitted_password)
 {
     if ($this->_prefs->get('passwd')) {
         if (isset($this->_prefs->_method) and $this->_prefs->_method == 'HomePage') {
             $user = new _PersonalPagePassUser($this->_userid, $this->_prefs);
             if ($user->checkPass($submitted_password)) {
                 if (!check_php_version(5)) {
                     eval("\$this = \$user;");
                 }
                 // /*PHP5 patch*/$this = $user;
                 $user = UpgradeUser($this, $user);
                 $this->_level = WIKIAUTH_USER;
                 return $this->_level;
             } else {
                 $this->_level = WIKIAUTH_ANON;
                 return $this->_level;
             }
         } else {
             $stored_password = $this->_prefs->get('passwd');
             if ($this->_checkPass($submitted_password, $stored_password)) {
                 $this->_level = WIKIAUTH_USER;
                 return $this->_level;
             } elseif (USER_AUTH_POLICY === 'strict') {
                 $this->_level = WIKIAUTH_FORBIDDEN;
                 return $this->_level;
             } else {
                 return $this->_tryNextPass($submitted_password);
             }
         }
     }
     if (isWikiWord($this->_userid)) {
         $this->_level = WIKIAUTH_BOGO;
     } else {
         $this->_level = WIKIAUTH_ANON;
     }
     return $this->_level;
 }
Exemple #16
0
} elseif ($_step == 1) {
    ?>
		<h3>安裝環境檢測</h3>
		<table class="table table-striped">
			<tr>
			  <th width="30%">項目</th>
			  <th width="25%">最低配置</th>
			  <th width="25%">最佳配置</th>
			  <th width="20%">檢測結果</th>
			</tr>
			<tr>
			  <td>PHP</td>
			  <td>5.3</td>
			  <td>5.3~5.6</td>
			  <td><?php 
    check_php_version(5.3);
    ?>
</td>
			</tr>
			<tr>
			  <td>GD函式庫</td>
			  <td>必須支援</td>
			  <td>必須支援</td>
			  <td><?php 
    check_extension('gd');
    ?>
</td>
			</tr>
			<tr>
			  <td>Multibyte String函式庫</td>
			  <td>必須支援</td>
Exemple #17
0
/**
 * checks system compliance for 4.5+ codebase
 * @return array Mixed values
 */
function checkSystemCompliance()
{
    global $sugar_config;
    global $current_language;
    global $db;
    global $mod_strings;
    if (!defined('SUGARCRM_MIN_MEM')) {
        define('SUGARCRM_MIN_MEM', 40);
    }
    $installer_mod_strings = getModuleLanguagePack($current_language, './install');
    $ret = array();
    $ret['error_found'] = false;
    // PHP version
    $php_version = constant('PHP_VERSION');
    $check_php_version_result = check_php_version($php_version);
    switch ($check_php_version_result) {
        case -1:
            $ret['phpVersion'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
            $ret['error_found'] = true;
            break;
        case 0:
            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_PHP_UNSUPPORTED']} {$php_version} )</span></b>";
            break;
        case 1:
            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_PHP_OK']} {$php_version} )</span></b>";
            break;
    }
    // database and connect
    switch ($sugar_config['dbconfig']['db_type']) {
        case 'mysql':
            // mysql version
            $q = "SELECT version();";
            $r = $db->query($q);
            $a = $db->fetchByAssoc($r);
            if (version_compare($a['version()'], '4.1.2') < 0) {
                $ret['error_found'] = true;
                $ret['mysqlVersion'] = "<b><span class=stop>" . $mod_strings['ERR_UW_MYSQL_VERSION'] . $a['version()'] . "</span></b>";
            }
            break;
        case 'mssql':
            break;
        case 'oci8':
            break;
    }
    // XML Parsing
    if (function_exists('xml_parser_create')) {
        $ret['xmlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['xmlStatus'] = "<b><span class=stop>{$installer_mod_strings['LBL_CHECKSYS_NOT_AVAILABLE']}</span></b>";
        $ret['error_found'] = true;
    }
    // cURL
    if (function_exists('curl_init')) {
        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</font></b>";
    } else {
        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_CURL']}</font></b>";
        $ret['error_found'] = false;
    }
    // mbstrings
    if (function_exists('mb_strlen')) {
        $ret['mbstringStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</font></b>";
    } else {
        $ret['mbstringStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_MBSTRING']}</font></b>";
        $ret['error_found'] = true;
    }
    // imap
    if (function_exists('imap_open')) {
        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_IMAP']}</span></b>";
        $ret['error_found'] = false;
    }
    // safe mode
    if ('1' == ini_get('safe_mode')) {
        $ret['safeModeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_SAFE_MODE']}</span></b>";
        $ret['error_found'] = true;
    } else {
        $ret['safeModeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // call time pass by ref
    if ('1' == ini_get('allow_call_time_pass_reference')) {
        $ret['callTimeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_CALL_TIME']}</span></b>";
        //continue upgrading
    } else {
        $ret['callTimeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // memory limit
    $ret['memory_msg'] = "";
    $memory_limit = "-1";
    //ini_get('memory_limit');
    $sugarMinMem = constant('SUGARCRM_MIN_MEM');
    // logic based on: http://us2.php.net/manual/en/ini.core.php#ini.memory-limit
    if ($memory_limit == "") {
        // memory_limit disabled at compile time, no memory limit
        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_OK']}</span></b>";
    } elseif ($memory_limit == "-1") {
        // memory_limit enabled, but set to unlimited
        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_UNLIMITED']}</span></b>";
    } else {
        rtrim($memory_limit, 'M');
        $memory_limit_int = (int) $memory_limit;
        if ($memory_limit_int < constant('SUGARCRM_MIN_MEM')) {
            $ret['memory_msg'] = "<b><span class=\"stop\">{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_1']}" . constant('SUGARCRM_MIN_MEM') . "{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_2']}</span></b>";
            $ret['error_found'] = true;
        } else {
            $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']} ({$memory_limit})</span></b>";
        }
    }
    /* mbstring.func_overload
    	$ret['mbstring.func_overload'] = '';
    	$mb = ini_get('mbstring.func_overload');
    
    	if($mb > 1) {
    		$ret['mbstring.func_overload'] = "<b><span class=\"stop\">{$mod_strings['ERR_UW_MBSTRING_FUNC_OVERLOAD']}</b>";
    		$ret['error_found'] = true;
    	}
    	*/
    return $ret;
}
Exemple #18
0
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
/**
 * Web services wrapper library script
 *
 * @package   moodlecore
 * @copyright 1999 onwards Martin Dougiamas  {@link http://moodle.com}
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
if (check_php_version('5') && class_exists('SoapClient')) {
    /** Use the native PHP5 support */
    require_once $CFG->libdir . '/soap/phpsoap.php';
} else {
    /** Use nuSOAP instead */
    require_once $CFG->libdir . '/soap/nusoap.php';
    function make_soap_fault($faultcode, $faultstring, $faultactor = '', $detail = '', $faultname = '', $headerfault = '')
    {
        return new soap_fault($faultcode, $faultactor, $faultstring, $detail);
    }
    function is_soap_fault($obj)
    {
        if (!is_object($obj)) {
            return false;
        }
        return strcasecmp(get_class($obj), 'soap_fault') === 0;
Exemple #19
0
 function _setTightness($top, $bot)
 {
     if (count($this->_content) == 1) {
         $li =& $this->_content[0];
         $li->setTightness($top, $bot);
     } else {
         // This is where php5 usually brakes.
         // wrong duplicated <li> contents
         if (DEBUG and DEBUG & _DEBUG_PARSER and check_php_version(5)) {
             if (count($this->_content) != 2) {
                 echo "<pre>";
                 /*
                 $class = new Reflection_Class('XmlElement');
                 // Print out basic information
                 printf(
                        "===> The %s%s%s %s '%s' [extends %s]\n".
                        "     declared in %s\n".
                        "     lines %d to %d\n".
                        "     having the modifiers %d [%s]\n",
                        $class->isInternal() ? 'internal' : 'user-defined',
                        $class->isAbstract() ? ' abstract' : '',
                        $class->isFinal() ? ' final' : '',
                        $class->isInterface() ? 'interface' : 'class',
                        $class->getName(),
                        var_export($class->getParentClass(), 1),
                        $class->getFileName(),
                        $class->getStartLine(),
                        $class->getEndline(),
                        $class->getModifiers(),
                        implode(' ', Reflection::getModifierNames($class->getModifiers()))
                        );
                 // Print class properties
                 printf("---> Properties: %s\n", var_export($class->getProperties(), 1));
                 */
                 echo 'count($this->_content): ', count($this->_content), "\n";
                 echo "\$this->_content[0]: ";
                 var_dump($this->_content[0]);
                 for ($i = 1; $i < min(5, count($this->_content)); $i++) {
                     $c =& $this->_content[$i];
                     echo '$this->_content[', $i, "]: \n";
                     echo "_tag: ";
                     var_dump($c->_tag);
                     echo "_content: ";
                     var_dump($c->_content);
                     echo "_properties: ";
                     var_dump($c->_properties);
                 }
                 debug_print_backtrace();
                 if (DEBUG & _DEBUG_APD) {
                     if (function_exists("xdebug_get_function_stack")) {
                         var_dump(xdebug_get_function_stack());
                     }
                 }
                 echo "</pre>";
             }
         }
         if (!check_php_version(5)) {
             assert(count($this->_content) == 2);
         }
         $dt =& $this->_content[0];
         $dd =& $this->_content[1];
         $dt->setTightness($top, false);
         $dd->setTightness(false, $bot);
     }
 }
Exemple #20
0
        <table cellpadding="0" cellspacing="0" border="0" class="table">
          <tr>
            <th align="left" class="th">Component</th>

            <th class="th" style="text-align: right;">Status</th>
          </tr>

		<tr>
            <td class="tdComponent">PHP version</td>

            <td align="right" class="tdValues"><strong>
            <?php 
$error_found = false;
$php_version = constant('PHP_VERSION');
$check_php_version_result = check_php_version($php_version);
switch ($check_php_version_result) {
    case -1:
        echo "<b><font color='red'>Invalid version, ({$php_version}) Installed</font></b>";
        $error_found = true;
        break;
    case 0:
        echo "<b><font color='red'>Unsupported (ver {$php_version})</font></b>";
        break;
    case 1:
        echo "<b><font color='green'>OK (ver {$php_version})</font></b>";
        break;
}
?>
            </strong></td>
          </tr>
function sqimap_login($username, $password, $imap_server_address, $imap_port, $hide)
{
    global $color, $squirrelmail_language, $onetimepad, $use_imap_tls, $imap_auth_mech;
    if (!isset($onetimepad) || empty($onetimepad)) {
        sqgetglobalvar('onetimepad', $onetimepad, SQ_SESSION);
    }
    $imap_server_address = sqimap_get_user_server($imap_server_address, $username);
    $host = $imap_server_address;
    if ($use_imap_tls == true and check_php_version(4, 3) and extension_loaded('openssl')) {
        /* Use TLS by prefixing "tls://" to the hostname */
        $imap_server_address = 'tls://' . $imap_server_address;
    }
    $imap_stream = fsockopen($imap_server_address, $imap_port, $error_number, $error_string, 15);
    /* Do some error correction */
    if (!$imap_stream) {
        if (!$hide) {
            set_up_language($squirrelmail_language, true);
            require_once SM_PATH . 'functions/display_messages.php';
            $string = sprintf(_("Error connecting to IMAP server: %s.") . "<br>\r\n", $imap_server_address) . "{$error_number} : {$error_string}<br>\r\n";
            logout_error($string, $color);
        }
        exit;
    }
    $server_info = fgets($imap_stream, 1024);
    /* Decrypt the password */
    $password = OneTimePadDecrypt($password, $onetimepad);
    if ($imap_auth_mech == 'cram-md5' or $imap_auth_mech == 'digest-md5') {
        // We're using some sort of authentication OTHER than plain or login
        $tag = sqimap_session_id(false);
        if ($imap_auth_mech == 'digest-md5') {
            $query = $tag . " AUTHENTICATE DIGEST-MD5\r\n";
        } elseif ($imap_auth_mech == 'cram-md5') {
            $query = $tag . " AUTHENTICATE CRAM-MD5\r\n";
        }
        fputs($imap_stream, $query);
        $answer = sqimap_fgets($imap_stream);
        // Trim the "+ " off the front
        $response = explode(" ", $answer, 3);
        if ($response[0] == '+') {
            // Got a challenge back
            $challenge = $response[1];
            if ($imap_auth_mech == 'digest-md5') {
                $reply = digest_md5_response($username, $password, $challenge, 'imap', $host);
            } elseif ($imap_auth_mech == 'cram-md5') {
                $reply = cram_md5_response($username, $password, $challenge);
            }
            fputs($imap_stream, $reply);
            $read = sqimap_fgets($imap_stream);
            if ($imap_auth_mech == 'digest-md5') {
                // DIGEST-MD5 has an extra step..
                if (substr($read, 0, 1) == '+') {
                    // OK so far..
                    fputs($imap_stream, "\r\n");
                    $read = sqimap_fgets($imap_stream);
                }
            }
            $results = explode(" ", $read, 3);
            $response = $results[1];
            $message = $results[2];
        } else {
            // Fake the response, so the error trap at the bottom will work
            $response = "BAD";
            $message = 'IMAP server does not appear to support the authentication method selected.';
            $message .= '  Please contact your system administrator.';
        }
    } elseif ($imap_auth_mech == 'login') {
        // Original IMAP login code
        $query = 'LOGIN "' . quoteimap($username) . '" "' . quoteimap($password) . '"';
        $read = sqimap_run_command($imap_stream, $query, false, $response, $message);
    } elseif ($imap_auth_mech == 'plain') {
        /* Replace this with SASL PLAIN if it ever gets implemented */
        $response = "BAD";
        $message = 'SquirrelMail does not support SASL PLAIN yet. Rerun conf.pl and use login instead.';
    } else {
        $response = "BAD";
        $message = "Internal SquirrelMail error - unknown IMAP authentication method chosen.  Please contact the developers.";
    }
    /* If the connection was not successful, lets see why */
    if ($response != 'OK') {
        if (!$hide) {
            if ($response != 'NO') {
                /* "BAD" and anything else gets reported here. */
                $message = htmlspecialchars($message);
                set_up_language($squirrelmail_language, true);
                require_once SM_PATH . 'functions/display_messages.php';
                if ($response == 'BAD') {
                    $string = sprintf(_("Bad request: %s") . "<br>\r\n", $message);
                } else {
                    $string = sprintf(_("Unknown error: %s") . "<br>\n", $message);
                }
                if (isset($read) && is_array($read)) {
                    $string .= '<br>' . _("Read data:") . "<br>\n";
                    foreach ($read as $line) {
                        $string .= htmlspecialchars($line) . "<br>\n";
                    }
                }
                error_box($string, $color);
                exit;
            } else {
                /*
                 * If the user does not log in with the correct
                 * username and password it is not possible to get the
                 * correct locale from the user's preferences.
                 * Therefore, apply the same hack as on the login
                 * screen.
                 *
                 * $squirrelmail_language is set by a cookie when
                 * the user selects language and logs out
                 */
                set_up_language($squirrelmail_language, true);
                include_once SM_PATH . 'functions/display_messages.php';
                sqsession_destroy();
                logout_error(_("Unknown user or password incorrect."));
                exit;
            }
        } else {
            exit;
        }
    }
    return $imap_stream;
}
Exemple #22
0
 function sqsetcookie($sName, $sValue = 'deleted', $iExpire = 0, $sPath = "", $sDomain = "", $bSecure = false, $bHttpOnly = true, $bReplace = false)
 {
     // if we have a secure connection then limit the cookies to https only.
     global $is_secure_connection;
     if ($sName && $is_secure_connection) {
         $bSecure = true;
     }
     // admin config can override the restriction of secure-only cookies
     //
     // (we have to check if the value is set and default it to true if
     // not because when upgrading without re-running conf.pl, it will
     // not be found in config/config.php and thusly evaluate to false,
     // but we want to default people who upgrade to true due to security
     // implications of setting this to false)
     //
     global $only_secure_cookies;
     if (!isset($only_secure_cookies)) {
         $only_secure_cookies = true;
     }
     if (!$only_secure_cookies) {
         $bSecure = false;
     }
     if (false && check_php_version(5, 2)) {
         // php 5 supports the httponly attribute in setcookie, but because setcookie seems a bit
         // broken we use the header function for php 5.2 as well. We might change that later.
         //setcookie($sName,$sValue,(int) $iExpire,$sPath,$sDomain,$bSecure,$bHttpOnly);
     } else {
         if (!empty($sDomain)) {
             // Fix the domain to accept domains with and without 'www.'.
             if (strtolower(substr($sDomain, 0, 4)) == 'www.') {
                 $sDomain = substr($sDomain, 4);
             }
             $sDomain = '.' . $sDomain;
             // Remove port information.
             $Port = strpos($sDomain, ':');
             if ($Port !== false) {
                 $sDomain = substr($sDomain, 0, $Port);
             }
         }
         if (!$sValue) {
             $sValue = 'deleted';
         }
         header('Set-Cookie: ' . rawurlencode($sName) . '=' . rawurlencode($sValue) . (empty($iExpire) ? '' : '; expires=' . gmdate('D, d-M-Y H:i:s', $iExpire) . ' GMT') . (empty($sPath) ? '' : '; path=' . $sPath) . (empty($sDomain) ? '' : '; domain=' . $sDomain) . (!$bSecure ? '' : '; secure') . (!$bHttpOnly ? '' : '; HttpOnly'), $bReplace);
     }
 }
Exemple #23
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if (defined('CHARSET')) {
         $rss_parser = new RSSParser(CHARSET);
     } else {
         $rss_parser = new RSSParser();
     }
     if (!empty($url)) {
         $rss_parser->parse_url($url, $debug);
     }
     if (!empty($rss_parser->channel['title'])) {
         $feed = $rss_parser->channel['title'];
     }
     if (!empty($rss_parser->channel['link'])) {
         $url = $rss_parser->channel['link'];
     }
     if (!empty($rss_parser->channel['description'])) {
         $description = $rss_parser->channel['description'];
     }
     if (!empty($feed)) {
         if (!empty($url)) {
             $titre = HTML::span(HTML::a(array('href' => $rss_parser->channel['link']), $rss_parser->channel['title']));
         } else {
             $titre = HTML::span($rss_parser->channel['title']);
         }
         $th = HTML::div(array('class' => 'feed'), $titre);
         if (!empty($description)) {
             $th->pushContent(HTML::p(array('class' => 'chandesc'), HTML::raw($description)));
         }
     } else {
         $th = HTML();
     }
     if (!empty($rss_parser->channel['date'])) {
         $th->pushContent(HTML::raw("<!--" . $rss_parser->channel['date'] . "-->"));
     }
     $html = HTML::div(array('class' => 'rss'), $th);
     if ($rss_parser->items) {
         // only maxitem's
         if ($maxitem > 0) {
             $rss_parser->items = array_slice($rss_parser->items, 0, $maxitem);
         }
         foreach ($rss_parser->items as $item) {
             $cell = HTML::div(array('class' => 'rssitem'));
             if ($item['link'] and empty($item['title'])) {
                 $item['title'] = $item['link'];
             }
             $cell_title = HTML::div(array('class' => 'itemname'), HTML::a(array('href' => $item['link']), HTML::raw($item['title'])));
             $cell->pushContent($cell_title);
             $cell_author = HTML::raw($item['author']);
             $cell_pubDate = HTML::raw($item['pubDate']);
             $cell_authordate = HTML::div(array('class' => 'authordate'), $cell_author, HTML::raw(" - "), $cell_pubDate);
             $cell->pushContent($cell_authordate);
             if (!$titleonly && !empty($item['description'])) {
                 $cell->pushContent(HTML::div(array('class' => 'itemdesc'), HTML::raw($item['description'])));
             }
             $html->pushContent($cell);
         }
     } else {
         $html = HTML::div(array('class' => 'rss'), HTML::em(_("no RSS items")));
     }
     if (!check_php_version(5)) {
         $rss_parser->__destruct();
     }
     return $html;
 }
Exemple #24
0
if ($squirrelmail_default_language != 'en_US') {
    $loc_path = SM_PATH . 'locale/' . $squirrelmail_default_language . '/LC_MESSAGES/squirrelmail.mo';
    if (!file_exists($loc_path)) {
        do_err('You have set <i>' . $squirrelmail_default_language . '</i> as your default language, but I cannot find this translation (should be ' . 'in <tt>' . $loc_path . '</tt>). Please note that you have to download translations ' . 'separately from the main SquirrelMail package.', FALSE);
    } elseif (!is_readable($loc_path)) {
        do_err('You have set <i>' . $squirrelmail_default_language . '</i> as your default language, but I cannot read this translation (file ' . 'in <tt>' . $loc_path . '</tt> unreadable).', FALSE);
    } else {
        echo $IND . "Default language OK.<br />\n";
    }
} else {
    echo $IND . "Default language OK.<br />\n";
}
echo $IND . "Base URL detected as: <tt>" . htmlspecialchars($test_location) . "</tt> (location base " . (empty($config_location_base) ? 'autodetected' : 'set to <tt>' . htmlspecialchars($config_location_base) . "</tt>") . ")<br />\n";
/* check outgoing mail */
if ($use_smtp_tls || $use_imap_tls) {
    if (!check_php_version(4, 3, 0)) {
        do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
    }
    if (!extension_loaded('openssl')) {
        do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
    }
}
echo "Checking outgoing mail service....<br />\n";
if ($useSendmail) {
    // is_executable also checks for existance, but we want to be as precise as possible with the errors
    if (!file_exists($sendmail_path)) {
        do_err("Location of sendmail program incorrect ({$sendmail_path})!");
    }
    if (!is_executable($sendmail_path)) {
        do_err("I cannot execute the sendmail program ({$sendmail_path})!");
    }
Exemple #25
0
/**
 * checks system compliance for 4.5+ codebase
 * @return array Mixed values
 */
function checkSystemCompliance()
{
    global $sugar_config;
    global $current_language;
    global $db;
    global $mod_strings;
    global $app_strings;
    if (!defined('SUGARCRM_MIN_MEM')) {
        define('SUGARCRM_MIN_MEM', 40);
    }
    $installer_mod_strings = getModuleLanguagePack($current_language, './install');
    $ret = array();
    $ret['error_found'] = false;
    // PHP version
    $php_version = constant('PHP_VERSION');
    $check_php_version_result = check_php_version($php_version);
    switch ($check_php_version_result) {
        case -1:
            $ret['phpVersion'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_PHP_INVALID_VER']} {$php_version} )</span></b>";
            $ret['error_found'] = true;
            break;
        case 0:
            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_PHP_UNSUPPORTED']} {$php_version} )</span></b>";
            break;
        case 1:
            $ret['phpVersion'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_PHP_OK']} {$php_version} )</span></b>";
            break;
    }
    // database and connect
    $canInstall = $db->canInstall();
    if ($canInstall !== true) {
        $ret['error_found'] = true;
        if (count($canInstall) == 1) {
            $ret['dbVersion'] = "<b><span class=stop>" . $installer_mod_strings[$canInstall[0]] . "</span></b>";
        } else {
            $ret['dbVersion'] = "<b><span class=stop>" . sprintf($installer_mod_strings[$canInstall[0]], $canInstall[1]) . "</span></b>";
        }
    }
    // XML Parsing
    if (function_exists('xml_parser_create')) {
        $ret['xmlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['xmlStatus'] = "<b><span class=stop>{$installer_mod_strings['LBL_CHECKSYS_NOT_AVAILABLE']}</span></b>";
        $ret['error_found'] = true;
    }
    // cURL
    if (function_exists('curl_init')) {
        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['curlStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_CURL']}</span></b>";
        $ret['error_found'] = false;
    }
    // mbstrings
    if (function_exists('mb_strlen')) {
        $ret['mbstringStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['mbstringStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_MBSTRING']}</span></b>";
        $ret['error_found'] = true;
    }
    // imap
    if (function_exists('imap_open')) {
        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['imapStatus'] = "<b><span class=go>{$installer_mod_strings['ERR_CHECKSYS_IMAP']}</span></b>";
        $ret['error_found'] = false;
    }
    // safe mode
    if ('1' == ini_get('safe_mode')) {
        $ret['safeModeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_SAFE_MODE']}</span></b>";
        $ret['error_found'] = true;
    } else {
        $ret['safeModeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // call time pass by ref
    if ('1' == ini_get('allow_call_time_pass_reference')) {
        $ret['callTimeStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_CALL_TIME']}</span></b>";
        //continue upgrading
    } else {
        $ret['callTimeStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // memory limit
    $ret['memory_msg'] = "";
    $memory_limit = "-1";
    //ini_get('memory_limit');
    $sugarMinMem = constant('SUGARCRM_MIN_MEM');
    // logic based on: http://us2.php.net/manual/en/ini.core.php#ini.memory-limit
    if ($memory_limit == "") {
        // memory_limit disabled at compile time, no memory limit
        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_OK']}</span></b>";
    } elseif ($memory_limit == "-1") {
        // memory_limit enabled, but set to unlimited
        $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_MEM_UNLIMITED']}</span></b>";
    } else {
        rtrim($memory_limit, 'M');
        $memory_limit_int = (int) $memory_limit;
        if ($memory_limit_int < constant('SUGARCRM_MIN_MEM')) {
            $ret['memory_msg'] = "<b><span class=\"stop\">{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_1']}" . constant('SUGARCRM_MIN_MEM') . "{$installer_mod_strings['ERR_CHECKSYS_MEM_LIMIT_2']}</span></b>";
            $ret['error_found'] = true;
        } else {
            $ret['memory_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']} ({$memory_limit})</span></b>";
        }
    }
    // zip support
    if (!class_exists("ZipArchive")) {
        $ret['ZipStatus'] = "<b><span class=stop>{$installer_mod_strings['ERR_CHECKSYS_ZIP']}</span></b>";
        $ret['error_found'] = true;
    } else {
        $ret['ZipStatus'] = "<b><span class=go>{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    }
    // Suhosin allow to use upload://
    $ret['stream_msg'] = '';
    if (UploadStream::getSuhosinStatus() == true) {
        $ret['stream_msg'] = "<b><span class=\"go\">{$installer_mod_strings['LBL_CHECKSYS_OK']}</span></b>";
    } else {
        $ret['stream_msg'] = "<b><span class=\"stop\">{$app_strings['ERR_SUHOSIN']}</span></b>";
        $ret['error_found'] = true;
    }
    /* mbstring.func_overload
    	$ret['mbstring.func_overload'] = '';
    	$mb = ini_get('mbstring.func_overload');
    
    	if($mb > 1) {
    		$ret['mbstring.func_overload'] = "<b><span class=\"stop\">{$mod_strings['ERR_UW_MBSTRING_FUNC_OVERLOAD']}</b>";
    		$ret['error_found'] = true;
    	}
    	*/
    return $ret;
}
Exemple #26
0
function MakeWikiZipHtml(&$request)
{
    $request->_TemplatesProcessed = array();
    $zipname = "wikihtml.zip";
    $zip = new ZipWriter("Created by PhpWiki " . PHPWIKI_VERSION, $zipname);
    $dbi =& $request->_dbi;
    $thispage = $request->getArg('pagename');
    // for "Return to ..."
    if ($exclude = $request->getArg('exclude')) {
        // exclude which pagenames
        $excludeList = explodePageList($exclude);
    } else {
        $excludeList = array();
    }
    if ($pages = $request->getArg('pages')) {
        // which pagenames
        if ($pages == '[]') {
            // current page
            $pages = $thispage;
        }
        $page_iter = new WikiDB_Array_PageIterator(explodePageList($pages));
    } else {
        $page_iter = $dbi->getAllPages(false, false, false, $excludeList);
    }
    global $WikiTheme;
    if (defined('HTML_DUMP_SUFFIX')) {
        $WikiTheme->HTML_DUMP_SUFFIX = HTML_DUMP_SUFFIX;
    }
    $WikiTheme->DUMP_MODE = 'ZIPHTML';
    $_bodyAttr = @$WikiTheme->_MoreAttr['body'];
    unset($WikiTheme->_MoreAttr['body']);
    /* ignore fatals in plugins */
    if (check_php_version(4, 1)) {
        global $ErrorManager;
        $ErrorManager->pushErrorHandler(new WikiFunctionCb('_dump_error_handler'));
    }
    $request_args = $request->args;
    $timeout = !$request->getArg('start_debug') ? 20 : 240;
    while ($page = $page_iter->next()) {
        $request->args = $request_args;
        // some plugins might change them (esp. on POST)
        longer_timeout($timeout);
        // Reset watchdog
        $current = $page->getCurrentRevision();
        if ($current->getVersion() == 0) {
            continue;
        }
        $pagename = $page->getName();
        if (in_array($pagename, $excludeList)) {
            continue;
        }
        $attrib = array('mtime' => $current->get('mtime'), 'is_ascii' => 1);
        if ($page->get('locked')) {
            $attrib['write_protected'] = 1;
        }
        $request->setArg('pagename', $pagename);
        // Template::_basepage fix
        $filename = FilenameForPage($pagename) . $WikiTheme->HTML_DUMP_SUFFIX;
        $revision = $page->getCurrentRevision();
        $transformedContent = $revision->getTransformedContent();
        $template = new Template('browse', $request, array('revision' => $revision, 'CONTENT' => $transformedContent));
        $data = GeneratePageasXML($template, $pagename);
        $zip->addRegularFile($filename, $data, $attrib);
        if (USECACHE) {
            $request->_dbi->_cache->invalidate_cache($pagename);
            unset($request->_dbi->_cache->_pagedata_cache);
            unset($request->_dbi->_cache->_versiondata_cache);
            unset($request->_dbi->_cache->_glv_cache);
        }
        unset($request->_dbi->_cache->_backend->_page_data);
        unset($revision->_transformedContent);
        unset($revision);
        unset($template->_request);
        unset($template);
        unset($data);
    }
    $page_iter->free();
    $attrib = false;
    // Deal with css and images here.
    if (!empty($WikiTheme->dumped_images) and is_array($WikiTheme->dumped_images)) {
        // dirs are created automatically
        //if ($WikiTheme->dumped_images) $zip->addRegularFile("images", "", $attrib);
        foreach ($WikiTheme->dumped_images as $img_file) {
            if ($from = $WikiTheme->_findFile($img_file, true) and basename($from)) {
                $target = "images/" . basename($img_file);
                if (check_php_version(4, 3)) {
                    $zip->addRegularFile($target, file_get_contents($WikiTheme->_path . $from), $attrib);
                } else {
                    $zip->addRegularFile($target, join('', file($WikiTheme->_path . $from)), $attrib);
                }
            }
        }
    }
    if (!empty($WikiTheme->dumped_buttons) and is_array($WikiTheme->dumped_buttons)) {
        //if ($WikiTheme->dumped_buttons) $zip->addRegularFile("images/buttons", "", $attrib);
        foreach ($WikiTheme->dumped_buttons as $text => $img_file) {
            if ($from = $WikiTheme->_findFile($img_file, true) and basename($from)) {
                $target = "images/buttons/" . basename($img_file);
                if (check_php_version(4, 3)) {
                    $zip->addRegularFile($target, file_get_contents($WikiTheme->_path . $from), $attrib);
                } else {
                    $zip->addRegularFile($target, join('', file($WikiTheme->_path . $from)), $attrib);
                }
            }
        }
    }
    if (!empty($WikiTheme->dumped_css) and is_array($WikiTheme->dumped_css)) {
        foreach ($WikiTheme->dumped_css as $css_file) {
            if ($from = $WikiTheme->_findFile(basename($css_file), true) and basename($from)) {
                $target = basename($css_file);
                if (check_php_version(4, 3)) {
                    $zip->addRegularFile($target, file_get_contents($WikiTheme->_path . $from), $attrib);
                } else {
                    $zip->addRegularFile($target, join('', file($WikiTheme->_path . $from)), $attrib);
                }
            }
        }
    }
    $zip->finish();
    if (check_php_version(4, 1)) {
        global $ErrorManager;
        $ErrorManager->popErrorHandler();
    }
    $WikiTheme->HTML_DUMP_SUFFIX = '';
    $WikiTheme->DUMP_MODE = false;
    $WikiTheme->_MoreAttr['body'] = $_bodyAttr;
}
Exemple #27
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $source =& $this->source;
     $this->sanify_colors($string, $comment, $keyword, $bg, $default, $html);
     $this->set_colors($string, $comment, $keyword, $bg, $default, $html);
     if ($wrap) {
         /* Wrap with "<?php\n" and "\n?>" required by
          * highlight_string(): */
         $source = "<?php\n" . $source . "\n?>";
     } else {
         $source = str_replace(array('< ?php', '? >'), array('<?php', '?>'), $source);
     }
     if (!check_php_version(4, 2, 0)) {
         ob_start();
         highlight_string($source);
         $str = ob_get_contents();
         ob_end_clean();
     } else {
         $str = highlight_string($source, true);
     }
     if ($wrap) {
         /* Remove "<?php\n" and "\n?>" again: */
         $str = str_replace(array('&lt;?php<br />', '?&gt;'), '', $str);
     }
     /**
      * We might have made some empty font tags. (The following
      * str_replace string does not produce results on my system,
      * maybe a php bug? '<font color="$color"></font>')
      */
     foreach (array($string, $comment, $keyword, $bg, $default, $html) as $color) {
         $search = "<font color=\"{$color}\"></font>";
         $str = str_replace($search, '', $str);
     }
     /* restore default colors in case of multiple invocations of
        this plugin on one page */
     $this->restore_colors();
     return new RawXml($str);
 }
Exemple #28
0
        }
    }
}
if ($f_db_type == 'db2') {
    # If schema name is supplied, then separate it from database name.
    if (strpos($f_database_name, '/') != false) {
        $f_db2AS400 = $f_database_name;
        list($f_database_name, $f_db_schema) = explode('/', $f_db2AS400, 2);
    }
}
if (0 == $t_install_state) {
    ?>

<!-- Check PHP Version -->
<?php 
    print_test(' Checking PHP version (your version is ' . phpversion() . ')', check_php_version(phpversion()), true, 'Upgrade to a more recent version of PHP');
    ?>

<!-- Check Safe Mode -->
<?php 
    print_test('Checking if safe mode is enabled for install script', !ini_get('SAFE_MODE'), true, 'Disable safe_mode in php.ini before proceeding');
    ?>

<?php 
    print_test('Checking there is no config_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/config_inc.php'), true, 'Move config_inc.php to config/config_inc.php.');
    print_test('Checking there is no custom_constants_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/custom_constants_inc.php'), true, 'Move custom_constants_inc.php to config/custom_constants_inc.php.');
    print_test('Checking there is no custom_strings_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/custom_strings_inc.php'), true, 'Move custom_strings_inc.php to config/custom_strings_inc.php.');
    print_test('Checking there is no custom_functions_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/custom_functions_inc.php'), true, 'Move custom_functions_inc.php to config/custom_functions_inc.php.');
    print_test('Checking there is no custom_relationships_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/custom_relationships_inc.php'), true, 'Move custom_relationships_inc.php to config/custom_relationships_inc.php.');
    print_test('Checking there is no mc_config_defaults_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/api/soap/mc_config_defaults_inc.php'), true, 'Delete this file.');
    print_test('Checking there is no mc_config_inc.php in 1.2.x location.', !file_exists(dirname(dirname(__FILE__)) . '/api/soap/mc_config_inc.php'), true, 'Move contents to config_inc.php file.');
Exemple #29
0
 function _tryNextUser()
 {
     if (DEBUG & _DEBUG_LOGIN) {
         $class = strtolower(get_class($this));
         if (substr($class, -10) == "dbpassuser") {
             $class = "_dbpassuser";
         }
         $GLOBALS['USER_AUTH_ERROR'][$class] = 'nosuchuser';
     }
     if (USER_AUTH_POLICY === 'strict' or USER_AUTH_POLICY === 'stacked') {
         $class = $this->nextClass();
         while ($user = new $class($this->_userid, $this->_prefs)) {
             if (!check_php_version(5)) {
                 eval("\$this = \$user;");
             }
             $user = UpgradeUser($this, $user);
             if ($user->userExists()) {
                 $user = UpgradeUser($this, $user);
                 return true;
             }
             if ($class == "_ForbiddenPassUser") {
                 return false;
             }
             $class = $this->nextClass();
         }
     }
     return false;
 }
Exemple #30
0
function report_session_error()
{
    global $CFG, $FULLME;
    if (empty($CFG->lang)) {
        $CFG->lang = "en";
    }
    // Set up default theme and locale
    theme_setup();
    moodle_setlocale();
    //clear session cookies
    if (check_php_version('5.2.0')) {
        //PHP 5.2.0
        setcookie('MoodleSession' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure, $CFG->cookiehttponly);
        setcookie('MoodleSessionTest' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure, $CFG->cookiehttponly);
    } else {
        setcookie('MoodleSession' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure);
        setcookie('MoodleSessionTest' . $CFG->sessioncookie, '', time() - 3600, $CFG->sessioncookiepath, $CFG->sessioncookiedomain, $CFG->cookiesecure);
    }
    //increment database error counters
    if (isset($CFG->session_error_counter)) {
        set_config('session_error_counter', 1 + $CFG->session_error_counter);
    } else {
        set_config('session_error_counter', 1);
    }
    redirect($FULLME, get_string('sessionerroruser2', 'error'), 5);
}