function register()
{
    global $SETTINGS, $APP;
    # NOTE: Disabling or modifying licensing or registration code violates your license agreement and is willful copyright infringement.
    # NOTE: Copyright infringement can be very expensive: http://en.wikipedia.org/wiki/Statutory_damages_for_copyright_infringement
    # NOTE: Please do not steal our software.
    // get filepath
    $caller = array_pop(@debug_backtrace());
    $filepath = realpath($caller['file']);
    ### Build registration query
    $hostname = getFirstDefinedValue($_SERVER["HTTP_HOST"], $_SERVER["SERVER_NAME"], @$_SERVER["SERVER_ADDR"]);
    $url = $_SERVER["SCRIPT_NAME"];
    $reginfo = 'reg1=' . urlencode($SETTINGS['licenseCompanyName']);
    # Company Name
    $reginfo .= '&reg2=' . urlencode($SETTINGS['licenseDomainName']);
    # Domain Name
    $reginfo .= '&lnum=' . isValidProductId($SETTINGS['licenseProductId']);
    # License Number
    $reginfo .= '&prog=' . $APP['id'];
    # Program Id
    $reginfo .= '&ver=' . $APP['version'];
    # Program Version
    $reginfo .= '&url=' . urlencode("{$hostname}{$url}");
    # script url
    $reginfo .= '&filepath=' . urlencode($filepath);
    # script filepath
    # get license status
    list($response, $statusCode) = getPage("http://www.registerSoftware.to/register/register.cgi?{$reginfo}");
    if (preg_match('/license.invalid/', $response)) {
        $isDisabled = 1;
    } else {
        if (preg_match('/license.valid/', $response)) {
            $isDisabled = 0;
        } else {
            $isDisabled = $SETTINGS['isDisabled'];
        }
    }
    # on unrecognized response do nothing
    # save settings
    $SETTINGS['installPath'] = _getInstallPath();
    $SETTINGS['isDisabled'] = $isDisabled;
    $SETTINGS['dateRegistered'] = time();
    saveSettings();
    //
    return !$isDisabled;
}
Ejemplo n.º 2
0
function showBuildInfo()
{
    global $APP, $SETTINGS;
    # NOTE: Disabling or modifying licensing or registration code violates your license agreement and is willful copyright infringement.
    # NOTE: Copyright infringement can be very expensive: http://en.wikipedia.org/wiki/Statutory_damages_for_copyright_infringement
    # NOTE: Please do not steal our software.
    // display build info
    echo "\n<!--\n";
    if (isset($_SERVER['QUERY_STRING']) && sha1($_SERVER['QUERY_STRING']) == '3831b0376dab413292f03dd30523e749bdd3279e') {
        $buildId = join('.', array($APP['build'], $APP['id'], isValidProductId($SETTINGS['licenseProductId'])));
        echo "{$SETTINGS['programName']} v{$APP['version']} (Build: {$buildId})\n";
        echo "Licensed to: {$SETTINGS['licenseCompanyName']} ~ {$SETTINGS['licenseDomainName']}\n";
    }
    echo "Execute time: " . showExecuteSeconds('return') . " seconds\n";
    echo "-->\n";
}
function admin_saveSettings($savePagePath)
{
    global $SETTINGS, $APP;
    // error checking
    clearAlertsAndNotices();
    // so previous alerts won't prevent saving of admin options
    // security checks
    security_dieUnlessPostForm();
    security_dieUnlessInternalReferer();
    security_dieOnInvalidCsrfToken();
    //
    disableInDemoMode('settings', $savePagePath);
    # license error checking
    if (array_key_exists('licenseProductId', $_REQUEST)) {
        if (!isValidProductId($_REQUEST['licenseProductId'])) {
            alert("Invalid Product License ID!");
        } else {
            if ($SETTINGS['licenseProductId'] != $_REQUEST['licenseProductId']) {
                $SETTINGS['licenseCompanyName'] = $_REQUEST['licenseCompanyName'];
                // update settings
                $SETTINGS['licenseDomainName'] = $_REQUEST['licenseDomainName'];
                // ...
                $SETTINGS['licenseProductId'] = $_REQUEST['licenseProductId'];
                // ...
                $isValid = register();
                // validate productId (and save new settings)
                if (!$isValid) {
                    redirectBrowserToURL('?menu=admin', true);
                    exit;
                }
            }
        }
    }
    # program url / adminUrl
    if (array_key_exists('adminUrl', $_REQUEST)) {
        if (!preg_match('/^http/i', $_REQUEST['adminUrl'])) {
            alert("Program URL must start with http:// or https://<br/>\n");
        }
        if (preg_match('/\\?/i', $_REQUEST['adminUrl'])) {
            alert("Program URL can not contain a ?<br/>\n");
        }
    }
    # webPrefixUrl - v2.53
    if (@$_REQUEST['webPrefixUrl'] != '') {
        if (!preg_match("|^(\\w+:/)?/|", $_REQUEST['webPrefixUrl'])) {
            alert(t("Website Prefix URL must start with /") . "<br/>\n");
        }
        if (preg_match("|/\$|", $_REQUEST['webPrefixUrl'])) {
            alert(t("Website Prefix URL cannot end with /") . "<br/>\n");
        }
    }
    # upload url/dir
    if (array_key_exists('uploadDir', $_REQUEST)) {
        #    if      (!preg_match('/\/$/',      $_REQUEST['uploadDir'])) { alert("Upload Directory must end with a slash! (eg: /www/htdocs/uploads/)<br/>\n"); }
    }
    if (array_key_exists('uploadUrl', $_REQUEST)) {
        #    if      (preg_match('/^\w+:\/\//', $_REQUEST['uploadUrl'])) { alert("Upload Folder Url must be the web path only without a domain (eg: /uploads/)<br/>\n"); }
        #    else if (!preg_match('/^\//',      $_REQUEST['uploadUrl'])) { alert("Upload Folder Url must start with a slash! (eg: /uploads/)<br/>\n"); }
        #    if      (!preg_match('/\/$/',      $_REQUEST['uploadUrl'])) { alert("Upload Folder Url must end with a slash! (eg: /uploads/)<br/>\n"); }
        $_REQUEST['uploadUrl'] = chop($_REQUEST['uploadUrl'], '\\\\/');
        // remove trailing slashes
    }
    # admin email
    if (array_key_exists('adminEmail', $_REQUEST) && !isValidEmail($_REQUEST['adminEmail'])) {
        alert("Admin Email must be a valid email (example: user@example.com)<br/>\n");
    }
    // error checking - require HTTPS
    if (@$_REQUEST['requireHTTPS'] && !isHTTPS()) {
        alert("Require HTTPS: You must be logged in with a secure HTTPS url to set this option!<br/>\n");
    }
    // error checking - require HTTPS
    if (@$_REQUEST['restrictByIP'] && !isIpAllowed(true, @$_REQUEST['restrictByIP_allowed'])) {
        alert(t("Restrict IP Access: You current IP address must be in the allowed IP list!") . "<br/>\n");
    }
    // error checking - session values
    $sessionErrors = getCustomSessionErrors(@$_REQUEST['session_cookie_domain'], @$_REQUEST['session_save_path']);
    if ($sessionErrors) {
        alert($sessionErrors);
    }
    # show errors
    if (alert()) {
        showInterface('admin/general.php');
        exit;
    }
    ### update global settings
    $globalSettings =& $SETTINGS;
    foreach (array_keys($globalSettings) as $key) {
        if (array_key_exists($key, $_REQUEST)) {
            $globalSettings[$key] = $_REQUEST[$key];
        }
    }
    # update subsection settings
    $subsections = array('advanced', 'wysiwyg');
    foreach ($subsections as $subsection) {
        $sectionSettings =& $SETTINGS[$subsection];
        foreach (array_keys($sectionSettings) as $key) {
            if (array_key_exists($key, $_REQUEST)) {
                $sectionSettings[$key] = $_REQUEST[$key];
            }
        }
    }
    # save to file
    saveSettings();
    # return to admin home
    notice('Settings have been saved.');
    showInterface($savePagePath);
}