示例#1
0
function validate_root_url($field, $vars)
{
    $url = $vars[$field['name']];
    if (!preg_match('/^http(s|):\\/\\/.+$/', $url)) {
        return "{$field['title']} - must start from <i>http://</i> or <i>https://</i>";
    }
    if (preg_match('/\\/+$/', $url)) {
        return "{$field['title']} - must be without trailing slash";
    }
    ////
    if (function_exists('is_trial') && is_trial()) {
        return;
    }
    $up = parse_url($url);
    global $_amember_license;
    $matched_url = 0;
    foreach (array_merge($_amember_license['domain'], $_amember_license['secure_domain']) as $d) {
        $d = preg_quote($d);
        if (preg_match("/(^|\\.){$d}\$/", $up['host'])) {
            $matched_url++;
        }
    }
    $list_domains = join(',', array_unique(array_merge($_amember_license['domain'], $_amember_license['secure_domain'])));
    if (!$matched_url) {
        return "URL '{$url}' doesn't match license domain(s): {$list_domains}";
    }
}
示例#2
0
function check_trial($errmsg = "Sorry, this function is available in aMember Pro not-trial version only")
{
    if (is_trial()) {
        throw new Am_Exception_FatalError($errmsg);
    }
}
示例#3
0
function get_warnings()
{
    global $db, $config, $member_additional_fields, $plugins, $plugin_error;
    $warn = array();
    if ($config['db_version'] < $config['require_db_version'] && $config['require_db_version']) {
        $warn[] = "Please upgrade your SQL database, upload latest file amember/amember.sql \n        then run <a href='{$config['root_url']}/admin/upgrade_db.php' target=_blank>upgrade script</a><br />\n        Your database has version [{$config['db_version']}], your aMember requires [{$config['require_db_version']}]";
    }
    if (defined("INCREMENTAL_CONTENT_PLUGIN") && !function_exists('get_incremental_plugin_files')) {
        $warn[] = 'You have outdated version of Incremental Content plugin installed.
        Please download latest plugin version from your account
        <a href="http://www.amember.com/amember/member.php">account</a>
        and reupload all files from the plugin package into your
        /amember/plugins/protect/incremental_content/ folder
        (replace existing files). If you need help with this contact us in
        <a href="http://www.amember.com/support/">helpdesk</a>.';
    }
    ///check for configuration problems
    foreach ($member_additional_fields as $f) {
        if ($f['name'] == 'cc') {
            $has_cc_fields++;
        }
    }
    if ((function_exists('cc_core_init') || $has_cc_fields) && !$config['use_cron']) {
        $warn[] = "Enable and configure external cron (<a href=\"setup.php?notebook=Advanced\" target=_blank>aMember CP -> Setup -> Advanced</a>) if you are using credit card payment plugins";
        if (!amConfig('agreed_cc_warning') && $_GET['agreed_cc_warning'] == '') {
            $t =& new_smarty();
            $t->display('admin/cc_warning.html');
            exit;
        }
    }
    $q = $db->query("SELECT UNIX_TIMESTAMP(MAX(time)) FROM {$db->config[prefix]}cron_run");
    list($t) = mysql_fetch_row($q);
    $diff = time() - $t;
    $tt = $t ? strftime('at ' . $config['time_format'], $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 (!count($db->get_products_list())) {
        $warn[] = "You have not added any products, your signup forms will not work until you <a href='products.php'>add at least one product</a>";
    }
    //
    if ($has_cc_fields || function_exists('cc_core_init')) {
        if (!extension_loaded("curl") && !$config['curl']) {
            $warn[] = "You must <a href='setup.php'>enter cURL path into settings</a>, because your host doesn't have built-in cURL functions.";
        }
    }
    // check for license expiration
    if (!function_exists('is_trial') || !is_trial()) {
        global $_amember_license;
        $tm1 = strtotime($_amember_license['expire']);
        $tm2 = time();
        $df = round(($tm1 - $tm2) / (3600 * 24));
        if ($df >= 0 && $df <= 25) {
            define('AMEMBER_LICENSE_EXPIRES_SOON', $df);
            $t = strftime($config['date_format'], $tm1);
            $warn[] = "Your aMember license key will expire within {$df} days ({$t}).\n            Please login into <a href='https://www.amember.com/amember/member.php' target=_blank>members area</a>,\n            get your lifetime license (it is FREE) and paste it to \n            \"aMember CP -> Setup -> License\"";
        }
    }
    //check protect plugins setup
    foreach ($plugins['protect'] as $plugin_name) {
        $func = "check_setup_" . $plugin_name;
        if (function_exists($func)) {
            $res = $func();
            if ($res) {
                $warn[] = $res;
            }
        }
        //check if $plugin_error[$plugin_name] not same as result of "check_setup_" . $plugin_name
        if (trim($plugin_error[$plugin_name]) && trim($res) != trim($plugin_error[$plugin_name])) {
            $warn[] = ucfirst($plugin_name) . " plugin error: " . $plugin_error[$plugin_name];
        }
    }
    return $warn;
}