Exemplo n.º 1
0
function _xForgotPasswordConfirm()
{
    global $t, $C;
    require_once 'validator.php';
    $v =& Validator::Get();
    $v->Register($_REQUEST['domain'], VT_NOT_EMPTY, "The 'Domain' field is required");
    $v->Register($_REQUEST['email'], VT_VALID_EMAIL, "The 'E-mail' field must be a valid e-mail address");
    $trade = null;
    if (!string_is_empty($_REQUEST['domain'])) {
        require_once 'dirdb.php';
        $db = new TradeDB();
        $trade = $db->Retrieve($_REQUEST['domain']);
        $v->Register(empty($trade), VT_IS_FALSE, "The Domain entered does not exist in our database");
        if (!empty($trade)) {
            $v->Register($_REQUEST['email'], VT_EQUALS, "The E-mail entered does not match the e-mail address for this domain", $trade['email']);
        }
    }
    if (!$v->Validate()) {
        $t->Assign('g_errors', $v->GetErrors());
        return _xForgotPasswordShow();
    }
    require_once 'textdb.php';
    $trade['confirm_id'] = md5(uniqid(rand(), true));
    $db = new PasswordConfirmsDB();
    $db->Add(array('confirm_id' => $trade['confirm_id'], 'domain' => $_REQUEST['domain'], 'timestamp' => time()));
    $t->AssignByRef('g_trade', $trade);
    require_once 'mailer.php';
    $m = new Mailer();
    $m->Mail('email-forgot-confirm.tpl', $t, $trade['email'], $trade['email']);
    $t->Display('trade-stats-forgot-confirm.tpl');
}
Exemplo n.º 2
0
 function Mailer()
 {
     global $C;
     $this->From = $C['email_address'];
     $this->FromName = $C['email_name'];
     $this->CharSet = 'UTF-8';
     switch ($C['email_method']) {
         case MAILER_METHOD_PHP:
             $this->IsMail();
             break;
         case MAILER_METHOD_SENDMAIL:
             $this->IsSendmail();
             $this->Sendmail = $C['sendmail_path'];
             break;
         case MAILER_METHOD_SMTP:
             $this->IsSMTP();
             $this->Host = $C['smtp_hostname'];
             $this->Port = $C['smtp_port'];
             $this->SMTPSecure = $C['flag_smtp_ssl'] ? MAILER_OPTION_SSL : '';
             $this->Username = $C['smtp_username'];
             $this->Password = $C['smtp_password'];
             if (!string_is_empty($this->Username)) {
                 $this->SMTPAuth = true;
             }
             break;
     }
     $this->greeting = file_get_contents(DIR_COMPILED . '/email-global-greeting.tpl');
     $this->signature = file_get_contents(DIR_COMPILED . '/email-global-signature.tpl');
 }
Exemplo n.º 3
0
function _xCronGrabThumbs()
{
    global $start;
    CronAppendLog(FILE_LOG_GRABBER, 'Grabber starting...', true);
    require_once 'dirdb.php';
    $db = new TradeDB();
    foreach ($db->RetrieveAll() as $trade) {
        if ($trade['flag_grabber']) {
            if (string_is_empty($trade['grabber_url'])) {
                $trade['grabber_url'] = $trade['return_url'];
            }
            $thumbnails = grab_thumbs($trade['domain'], $trade['grabber_url'], $trade['trigger_strings']);
            switch ($thumbnails) {
                case null:
                    CronAppendLog(FILE_LOG_GRABBER, 'Thumbnails could not be downloaded from ' . $trade['domain']);
                    break;
                case 0:
                    CronAppendLog(FILE_LOG_GRABBER, 'HTTP connection for ' . $trade['domain'] . ' has failed');
                    break;
                default:
                    $db->Update($trade['domain'], array('thumbnails' => $thumbnails));
                    break;
            }
        }
    }
    CronAppendLog(FILE_LOG_GRABBER, 'Grabber exiting...', true);
}
Exemplo n.º 4
0
 function AddFilter($field, $value, $multi = false)
 {
     if (!string_is_empty($value)) {
         $this->filters[] = array('field' => $field, 'value' => $value, 'multi' => $multi);
     }
 }
Exemplo n.º 5
0
 function VerifyRequiredAttributes($required, &$attributes, $tag)
 {
     foreach ($required as $r) {
         if (!isset($attributes[$r]) || string_is_empty($attributes[$r])) {
             trigger_error("{" . $tag . "} tag is missing the '{$r}' attribute", E_USER_NOTICE);
         }
     }
 }
Exemplo n.º 6
0
function _xConfirmShow()
{
    global $t, $C;
    require_once 'textdb.php';
    $db = new RegisterConfirmsDB();
    $db->DeleteExpired();
    $confirm = $db->Retrieve($_REQUEST['id']);
    require_once 'validator.php';
    $v =& Validator::Get();
    $v->Register(empty($confirm), VT_IS_FALSE, 'Invalid or expired confirmation code');
    if (!$v->Validate()) {
        $t->Assign('g_invalid_confirm', true);
    } else {
        $db->Delete($_REQUEST['id']);
        $defaults = unserialize(file_get_contents(FILE_NEW_TRADE_DEFAULTS));
        require_once 'dirdb.php';
        $password = get_random_password();
        $db = new TradeDB();
        $trade = $db->Update($confirm['domain'], array('status' => $defaults['status'], 'timestamp_autostop' => time(), 'password' => sha1($password)));
        $trade['password'] = $password;
        $t->AssignByRef('g_trade', $trade);
        require_once 'mailer.php';
        if ($C['flag_register_email_user'] && !string_is_empty($trade['email'])) {
            $m = new Mailer();
            $m->Mail('email-register-complete.tpl', $t, $trade['email'], $trade['email']);
        }
        if ($C['flag_register_email_admin']) {
            $m = new Mailer();
            $m->Mail('email-register-admin.tpl', $t, $C['email_address'], $C['email_name']);
        }
    }
    $t->Display('register-confirm.tpl');
}
Exemplo n.º 7
0
function check_image_resizer()
{
    global $C;
    $C['have_magick'] = 0;
    $C['have_gd'] = 0;
    // Check ImageMagick
    if (!string_is_empty($C['magick_mogrify_path'])) {
        set_error_handler('shell_exec_error_handler');
        $output = shell_exec($C['magick_mogrify_path'] . ' -resize "90x120^" 2>&1');
        restore_error_handler();
        if (empty($output) && empty($GLOBALS['shell_exec_errors'])) {
            $C['have_magick'] = 1;
        }
    }
    // Check GD
    if (extension_loaded('gd')) {
        $gdinfo = gd_info();
        if ($gdinfo['JPG Support']) {
            $C['have_gd'] = 1;
        }
    }
}
Exemplo n.º 8
0
function file_sanitize($filename, $allowed_extensions = null, $force_extension = null)
{
    $info = pathinfo($filename);
    $last_period = strrpos($info['basename'], '.');
    $filename = $last_period === false ? $info['basename'] : substr($info['basename'], 0, $last_period);
    $extension = isset($info['extension']) ? $info['extension'] : '';
    $filename = preg_replace('~[^a-z0-9_\\-.]~', '', $filename);
    if (!empty($allowed_extensions)) {
        if (!is_array($allowed_extensions)) {
            $allowed_extensions = explode(',', $allowed_extensions);
        }
        if (!in_array($info['extension'], $allowed_extensions)) {
            $extension = $force_extension;
        }
    } else {
        if (!empty($force_extension)) {
            $extension = $force_extension;
        }
    }
    $extension = !empty($extension) ? '.' . preg_replace('~[^a-z0-9]~', '', $extension) : '';
    if (string_is_empty($filename)) {
        $filename = 'none';
    }
    return preg_replace('~\\.+~', '.', $filename . $extension);
}
Exemplo n.º 9
0
function _xSkimSchemesDynamicEdit()
{
    require_once 'textdb.php';
    $db = new SkimSchemesDynamicDB();
    $db->db_file = DIR_SKIM_SCHEMES_DYNAMIC . '/' . $_REQUEST['scheme'];
    $db->Clear();
    for ($i = 0; $i < count($_REQUEST['rule']); $i++) {
        $data = array();
        foreach ($_REQUEST as $field => $value) {
            if (is_array($value)) {
                $data[$field] = $value[$i];
            }
        }
        if (string_is_empty($data['cycle_1'])) {
            $data['cycle_1'] = 70;
        }
        $db->Add($data);
    }
    JSON::Success(array(JSON_KEY_MESSAGE => 'Dynamic skim scheme settings have been saved', JSON_KEY_DIALOG => _xIncludeCapture('skim-schemes-dynamic.php', $_REQUEST)));
}