コード例 #1
0
ファイル: submit.php プロジェクト: Cyberspace-Networks/TGPX
function txShGallerySubmit($errors = null)
{
    global $C, $DB, $L, $t, $domain;
    $category_query = 'SELECT * FROM `tx_categories` WHERE `hidden`=0 ORDER BY `name`';
    $category_binds = array();
    if ($domain['categories']) {
        $category_query = 'SELECT * FROM `tx_categories` WHERE `hidden`=0 AND `category_id` ' . ($domain['as_exclude'] ? 'NOT IN' : 'IN') . ' (' . CreateBindList($domain['categories']) . ') ORDER BY `name`';
        $category_binds = $domain['categories'];
    }
    $categories =& $DB->FetchAll($category_query, $category_binds);
    if (count($categories) < 1) {
        $t->assign('error', 'There must be at least one category defined before you can submit galleries');
        $t->display($domain['template_prefix'] . 'error-nice.tpl');
        return;
    }
    $t->assign_by_ref('categories', $categories);
    $fields =& GetUserGalleryFields();
    // See if we are full
    if ($C['max_submissions'] != -1) {
        $todays_submissions = $DB->Count('SELECT COUNT(*) FROM `tx_galleries` WHERE type=? AND (partner=? OR partner IS NULL) AND `date_added` BETWEEN ? AND ?', array('submitted', '', MYSQL_CURDATE . ' 00:00:00', MYSQL_CURDATE . ' 23:59:59'));
        if ($todays_submissions >= $C['max_submissions']) {
            $t->display($domain['template_prefix'] . 'submit-full-global.tpl');
            return;
        }
    }
    $t->assign('errors', $errors);
    $t->assign_by_ref('user_fields', $fields);
    $t->assign_by_ref('gallery', $_REQUEST);
    $t->display($domain['template_prefix'] . 'submit-main.tpl');
}
コード例 #2
0
ファイル: common.php プロジェクト: Cyberspace-Networks/TGPX
 function GeneratePiece($field, $operator, $value)
 {
     $piece = '';
     $field = $this->ProcessFieldName($field);
     switch ($operator) {
         case ST_STARTS:
             $piece = "{$field['placeholders']} LIKE ?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = "{$value}%";
             break;
         case ST_MATCHES:
             $piece = "{$field['placeholders']}=?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = $value;
             break;
         case ST_NOT_MATCHES:
             $piece = "{$field['placeholders']}!=?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = $value;
             break;
         case ST_BETWEEN:
             list($min, $max) = explode(',', $value);
             $piece = "{$field['placeholders']} BETWEEN ? AND ?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = $min;
             $this->binds[] = $max;
             break;
         case ST_GREATER:
             $piece = "{$field['placeholders']} > ?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = $value;
             break;
         case ST_LESS:
             $piece = "{$field['placeholders']} < ?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = $value;
             break;
         case ST_EMPTY:
             $piece = "({$field['placeholders']}='' OR {$field['placeholders']} IS NULL)";
             $this->binds = array_merge($this->binds, $field['binds'], $field['binds']);
             break;
         case ST_NOT_EMPTY:
             $piece = "({$field['placeholders']}!='' AND {$field['placeholders']} IS NOT NULL)";
             $this->binds = array_merge($this->binds, $field['binds'], $field['binds']);
             break;
         case ST_NULL:
             $piece = "{$field['placeholders']} IS NULL";
             $this->binds = array_merge($this->binds, $field['binds']);
             break;
         case ST_NOT_NULL:
             $piece = "{$field['placeholders']} IS NOT NULL";
             $this->binds = array_merge($this->binds, $field['binds']);
             break;
         case ST_IN:
             $items = array_unique(explode(',', $value));
             $piece = "{$field['placeholders']} IN (" . CreateBindList($items) . ")";
             $this->binds = array_merge($this->binds, $field['binds'], $items);
             break;
         case ST_NOT_IN:
             $items = array_unique(explode(',', $value));
             $piece = "{$field['placeholders']} NOT IN (" . CreateBindList($items) . ")";
             $this->binds = array_merge($this->binds, $field['binds'], $items);
             break;
         case ST_ANY:
             break;
             // 'contains' is the default
         // 'contains' is the default
         default:
             $piece = "{$field['placeholders']} LIKE ?";
             $this->binds = array_merge($this->binds, $field['binds']);
             $this->binds[] = "%{$value}%";
             break;
     }
     return $piece;
 }
コード例 #3
0
ファイル: accounts.php プロジェクト: hackingman/ToplistX
function tlxAccountAdd()
{
    global $C, $DB, $L, $IMAGE_EXTENSIONS, $t;
    unset($_REQUEST['banner_url_local']);
    // Get domain
    $parsed_url = parse_url($_REQUEST['site_url']);
    $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $parsed_url['host']);
    $v = new Validator();
    // Get selected category (if any) and set variables
    if (isset($_REQUEST['category_id'])) {
        $category = $DB->Row('SELECT * FROM `tlx_categories` WHERE `category_id`=? AND `hidden`=0', array($_REQUEST['category_id']));
        if ($category) {
            $C['min_desc_length'] = $category['desc_min_length'];
            $C['max_desc_length'] = $category['desc_max_length'];
            $C['min_title_length'] = $category['title_min_length'];
            $C['max_title_length'] = $category['title_max_length'];
            $C['banner_max_width'] = $category['banner_max_width'];
            $C['banner_max_height'] = $category['banner_max_height'];
            $C['banner_max_bytes'] = $category['banner_max_bytes'];
            $C['allow_redirect'] = $category['allow_redirect'];
        } else {
            $v->SetError($L['INVALID_CATEGORY']);
        }
    }
    // See if username is taken
    if ($DB->Count('SELECT COUNT(*) FROM `tlx_accounts` WHERE `username`=?', array($_REQUEST['username'])) > 0) {
        $v->SetError($L['USERNAME_TAKEN']);
    }
    // Check for duplicate account information
    if ($DB->Count('SELECT COUNT(*) FROM `tlx_accounts` WHERE `site_url`=? OR `email`=? OR `domain`=?', array($_REQUEST['site_url'], $_REQUEST['email'], $_REQUEST['domain'])) > 0) {
        $v->SetError($L['EXISTING_ACCOUNT']);
    }
    $v->Register($_REQUEST['username'], V_LENGTH, $L['USERNAME_LENGTH'], '4,32');
    $v->Register($_REQUEST['username'], V_ALPHANUM, $L['INVALID_USERNAME']);
    $v->Register($_REQUEST['password'], V_LENGTH, $L['PASSWORD_LENGTH'], '4,9999');
    $v->Register($_REQUEST['email'], V_EMAIL, $L['INVALID_EMAIL']);
    $v->Register($_REQUEST['site_url'], V_URL, sprintf($L['INVALID_URL'], $L['SITE_URL']));
    $v->Register($_REQUEST['password'], V_NOT_EQUALS, $L['USERNAME_IS_PASSWORD'], $_REQUEST['username']);
    $v->Register($_REQUEST['password'], V_EQUALS, $L['PASSWORDS_DONT_MATCH'], $_REQUEST['confirm_password']);
    if (!IsEmptyString($_REQUEST['banner_url'])) {
        $v->Register($_REQUEST['banner_url'], V_URL, sprintf($L['INVALID_URL'], $L['BANNER_URL']));
    }
    // Format keywords and check number
    if ($C['allow_keywords']) {
        $_REQUEST['keywords'] = FormatSpaceSeparated($_REQUEST['keywords']);
        $keywords = explode(' ', $_REQUEST['keywords']);
        $v->Register(count($keywords), V_LESS_EQ, sprintf($L['MAXIMUM_KEYWORDS'], $C['max_keywords']), $C['max_keywords']);
    } else {
        $_REQUEST['keywords'] = null;
    }
    // Verify captcha code
    if ($C['account_add_captcha']) {
        VerifyCaptcha($v);
    }
    // Initial validation
    if (!$v->Validate()) {
        return $v->ValidationError('tlxShAccountAdd', TRUE);
    }
    // Check if the site URL is working
    $http = new Http();
    if ($http->Get($_REQUEST['site_url'], $C['allow_redirect'])) {
        $_REQUEST['html'] = $http->body;
        $_REQUEST['headers'] = $http->raw_response_headers;
    } else {
        $v->SetError(sprintf($L['BROKEN_URL'], $_REQUEST['site_url'], $http->errstr));
    }
    // Check the blacklist
    $blacklisted = CheckBlacklistAccount($_REQUEST);
    if ($blacklisted !== FALSE) {
        $v->SetError(sprintf($blacklisted[0]['reason'] ? $L['BLACKLISTED_REASON'] : $L['BLACKLISTED'], $blacklisted[0]['match'], $blacklisted[0]['reason']));
    }
    // Check site title and description length
    $v->Register($_REQUEST['title'], V_LENGTH, sprintf($L['TITLE_LENGTH'], $C['min_title_length'], $C['max_title_length']), "{$C['min_title_length']},{$C['max_title_length']}");
    $v->Register($_REQUEST['description'], V_LENGTH, sprintf($L['DESCRIPTION_LENGTH'], $C['min_desc_length'], $C['max_desc_length']), "{$C['min_desc_length']},{$C['max_desc_length']}");
    // Validation of user defined fields
    $fields =& GetUserAccountFields();
    foreach ($fields as $field) {
        if ($field['on_create']) {
            if ($field['required_create']) {
                $v->Register($_REQUEST[$field['name']], V_EMPTY, sprintf($L['REQUIRED_FIELD'], $field['label']));
            }
            if (!IsEmptyString($_REQUEST[$field['name']]) && $field['validation']) {
                $v->Register($_REQUEST[$field['name']], $field['validation'], $field['validation_message'], $field['validation_extras']);
            }
        }
    }
    // Download banner to check size
    $banner_file = null;
    if (!IsEmptyString($_REQUEST['banner_url']) && ($C['download_banners'] || $C['host_banners'])) {
        $http = new Http();
        if ($http->Get($_REQUEST['banner_url'], TRUE, $_REQUEST['site_url'])) {
            $banner_file = SafeFilename("{$C['banner_dir']}/{$_REQUEST['username']}.jpg", FALSE);
            FileWrite($banner_file, $http->body);
            $banner_info = @getimagesize($banner_file);
            if ($banner_info !== FALSE) {
                $_REQUEST['banner_width'] = $banner_info[0];
                $_REQUEST['banner_height'] = $banner_info[1];
                if (filesize($banner_file) > $C['banner_max_bytes']) {
                    $v->SetError(sprintf($L['BAD_BANNER_BYTES'], $C['banner_max_bytes']));
                }
                if ($C['host_banners']) {
                    if (isset($IMAGE_EXTENSIONS[$banner_info[2]])) {
                        $banner_ext = strtolower($IMAGE_EXTENSIONS[$banner_info[2]]);
                        if ($banner_ext != 'jpg') {
                            $new_file = preg_replace('~\\.jpg$~', ".{$banner_ext}", $banner_file);
                            rename($banner_file, $new_file);
                            $banner_file = $new_file;
                        }
                        $_REQUEST['banner_url_local'] = "{$C['banner_url']}/{$_REQUEST['username']}.{$banner_ext}";
                    } else {
                        $v->SetError($L['BAD_BANNER_IMAGE']);
                    }
                } else {
                    @unlink($banner_file);
                    $banner_file = null;
                }
            } else {
                $v->SetError($L['BAD_BANNER_IMAGE']);
            }
        } else {
            $v->SetError(sprintf($L['BROKEN_URL'], $_REQUEST['banner_url'], $http->errstr));
        }
    }
    // Check banner dimensions
    if ($_REQUEST['banner_width'] > $C['banner_max_width'] || $_REQUEST['banner_height'] > $C['banner_max_height']) {
        $v->SetError(sprintf($L['BAD_BANNER_SIZE'], $C['banner_max_width'], $C['banner_max_height']));
    }
    // Force banner dimensions
    if ($C['banner_force_size']) {
        $_REQUEST['banner_width'] = $C['banner_max_width'];
        $_REQUEST['banner_height'] = $C['banner_max_height'];
    }
    if (!$v->Validate()) {
        if (!empty($banner_file)) {
            @unlink($banner_file);
        }
        return $v->ValidationError('tlxShAccountAdd', TRUE);
    }
    $_REQUEST['status'] = STATUS_ACTIVE;
    $email_template = 'email-account-added.tpl';
    if ($C['confirm_accounts']) {
        $_REQUEST['status'] = STATUS_UNCONFIRMED;
        $email_template = 'email-account-confirm.tpl';
        $confirm_id = md5(uniqid(rand(), true));
        $t->assign('confirm_url', "{$C['install_url']}/accounts.php?r=confirm&id={$confirm_id}");
        $DB->Update('INSERT INTO `tlx_account_confirms` VALUES (?,?,?)', array($_REQUEST['username'], $confirm_id, MYSQL_NOW));
    } else {
        if ($C['review_new_accounts']) {
            $_REQUEST['status'] = STATUS_PENDING;
            $email_template = 'email-account-pending.tpl';
        }
    }
    // Add account information
    $DB->Update('INSERT INTO `tlx_accounts` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array($_REQUEST['username'], $_REQUEST['email'], $_REQUEST['site_url'], $_REQUEST['domain'], $_REQUEST['banner_url'], $_REQUEST['banner_url_local'], $_REQUEST['banner_height'], $_REQUEST['banner_width'], $_REQUEST['title'], $_REQUEST['description'], $_REQUEST['keywords'], MYSQL_NOW, $_REQUEST['status'] == STATUS_ACTIVE ? MYSQL_NOW : null, MYSQL_NOW, sha1($_REQUEST['password']), $C['return_percent'], $_REQUEST['status'], 0, 0, 0, $_REQUEST['category_id'], null, null, 0, 0, 0, null, null));
    // Create stats tracking data
    $stats_data = array_merge(array($_REQUEST['username']), array_fill(0, 127, 0));
    $DB->Update('INSERT INTO `tlx_account_hourly_stats` VALUES (' . CreateBindList($stats_data) . ')', $stats_data);
    // Insert user defined database fields
    $query_data = CreateUserInsert('tlx_account_fields', $_REQUEST);
    $DB->Update('INSERT INTO `tlx_account_fields` VALUES (' . $query_data['bind_list'] . ')', $query_data['binds']);
    // Assign template values
    $_REQUEST['category'] = $category['name'];
    $t->assign_by_ref('account', $_REQUEST);
    $t->assign_by_ref('user_fields', $fields);
    $t->assign('tracking_url', $C['tracking_mode'] == 'unique_link' ? "{$C['in_url']}?id={$_REQUEST['username']}" : $C['in_url']);
    // Send e-mail to account submitter
    if ($C['confirm_accounts'] || $C['email_new_accounts']) {
        SendMail($_REQUEST['email'], $email_template, $t);
    }
    // Send e-mail to administrators
    $administrators =& $DB->FetchAll('SELECT * FROM `tlx_administrators`');
    foreach ($administrators as $administrator) {
        if ($administrator['notifications'] & E_ACCOUNT_ADDED) {
            SendMail($administrator['email'], 'email-admin-account-added.tpl', $t);
        }
    }
    // Display confirmation page
    $t->display('accounts-added.tpl');
}
コード例 #4
0
ファイル: functions.php プロジェクト: hackingman/ToplistX
function GetWhichAccounts($update = FALSE)
{
    global $DB;
    $result = null;
    $req = $_REQUEST;
    if (IsEmptyString($_REQUEST['which'])) {
        parse_str($_REQUEST['results'], $req);
    }
    switch ($req['which']) {
        case 'specific':
            $result = $DB->Query('SELECT * FROM `tlx_accounts` WHERE `username`=?', array($req['username']));
            break;
        case 'matching':
            // TODO
            break;
        case 'all':
            $result = $DB->Query('SELECT * FROM `tlx_accounts`');
            break;
        default:
            if ($update) {
                $update->AddWhere('username', ST_IN, join(',', $req['username']));
                $result = $update;
            } else {
                $bind_list = CreateBindList($req['username']);
                $result = $DB->Query('SELECT * FROM `tlx_accounts` WHERE `username` IN (' . $bind_list . ')', $req['username']);
            }
            break;
    }
    return $result;
}
コード例 #5
0
ファイル: arphp-convert.php プロジェクト: hackingman/ToplistX
function ConvertData()
{
    global $C, $DB, $from_shell;
    $errors = array();
    if (!is_dir($_REQUEST['directory'])) {
        $errors[] = "The directory " . htmlspecialchars($_REQUEST['directory']) . " does not exist on your server";
        return DisplayMain($errors);
    }
    if (!is_file("{$_REQUEST['directory']}/arphp.php")) {
        $errors[] = "The arphp.php file could not be found in the " . htmlspecialchars($_REQUEST['directory']) . " directory";
        return DisplayMain($errors);
    }
    if (!is_readable("{$_REQUEST['directory']}/arphp.php")) {
        $errors[] = "The arphp.php file in the " . htmlspecialchars($_REQUEST['directory']) . " directory could not be opened for reading";
        return DisplayMain($errors);
    }
    // Check version
    $version_file_contents = file_get_contents("{$_REQUEST['directory']}/common.php");
    if (preg_match('~\\$VERSION\\s+=\\s+\'(.*?)\'~', $version_file_contents, $matches)) {
        list($a, $b, $c) = explode('.', $matches[1]);
        if ($a < 3) {
            $errors[] = "Your AutoRank PHP installation is outdated; please upgrade to the 3.0.x series";
            return DisplayMain($errors);
        }
    } else {
        $errors[] = "Unable to extract version information from arphp.php; your version of AutoRank PHP is likely too old";
        return DisplayMain($errors);
    }
    // Extract variables
    $mysql_file_contents = file_get_contents("{$_REQUEST['directory']}/data/variables");
    if ($mysql_file_contents === FALSE) {
        $errors[] = "Unable to read contents of the variables file";
        return DisplayMain($errors);
    }
    $vars = array();
    if (preg_match_all('~^\\$([a-z0-9_]+)\\s+=\\s+\'(.*?)\';$~msi', $mysql_file_contents, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            $vars[$match[1]] = $match[2];
        }
    }
    if (!isset($vars['USERNAME']) || !isset($vars['DATABASE']) || !isset($vars['HOSTNAME'])) {
        $errors[] = "Unable to extract MySQL database information from the variables file";
        return DisplayMain($errors);
    }
    $CONVERTDB = new DB($vars['HOSTNAME'], $vars['USERNAME'], $vars['PASSWORD'], $vars['DATABASE']);
    $CONVERTDB->Connect();
    $CONVERTDB->Update('SET `wait_timeout`=86400');
    if (!$from_shell) {
        echo "<pre>";
    }
    //
    // Copy banners
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying member account banners...\n");
    echo "Copying member account banners...\n";
    flush();
    $banners =& DirRead($vars['BANNER_DIR'], '\\.(png|jpg|gif|bmp)$');
    foreach ($banners as $banner) {
        @copy("{$vars['BANNER_DIR']}/{$banner}", "{$C['banner_dir']}/{$banner}");
        @chmod("{$C['banner_dir']}/{$banner}", 0666);
    }
    //
    // Dump categories
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting categories...\n");
    echo "Converting categories...\n";
    flush();
    $categories = array();
    $category_ids = array();
    $DB->Update('DELETE FROM `tlx_categories`');
    $DB->Update('ALTER TABLE `tlx_categories` AUTO_INCREMENT=0');
    foreach (explode(',', $vars['CATEGORIES']) as $category) {
        $DB->Update('INSERT INTO `tlx_categories` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $category, 0, $vars['FORWARD_URL'], null, $vars['BANNER_WIDTH'], $vars['BANNER_HEIGHT'], $vars['BANNER_SIZE'], intval($vars['O_FORCE_DIMS']), intval($vars['O_CHECK_DIMS']), intval($vars['O_SERVE_BANNERS']), 1, 1, $vars['MAX_TITLE'], 1, $vars['MAX_DESC'], intval($vars['O_REQ_RECIP'])));
        $category_ids[$category] = $DB->InsertID();
    }
    //
    // Import icons
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting account icons...\n");
    echo "Converting account icons...\n";
    flush();
    $DB->Update('DELETE FROM `tlx_icons`');
    $DB->Update('ALTER TABLE `tlx_icons` AUTO_INCREMENT=0');
    IniParse("{$_REQUEST['directory']}/data/icons", TRUE, $icons_ini);
    $icons = array();
    foreach ($icons_ini as $key => $value) {
        $DB->Update('INSERT INTO `tlx_icons` VALUES (?,?,?)', array(null, $key, trim($value)));
        $icons[$key] = $DB->InsertID();
    }
    //
    // Import user defined fields
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting user defined database fields...\n");
    echo "Converting user defined database fields...\n";
    flush();
    $DB->Update('DELETE FROM `tlx_account_field_defs`');
    $DB->Update('ALTER TABLE `tlx_account_field_defs` AUTO_INCREMENT=0');
    $DB->Update('DROP TABLE IF EXISTS `tlx_account_fields`');
    $DB->Update('CREATE TABLE `tlx_account_fields` (`username` CHAR(32) NOT NULL PRIMARY KEY)');
    for ($i = 1; $i <= 3; $i++) {
        if (!IsEmptyString($vars["NAME_FIELD_{$i}"])) {
            $DB->Update('INSERT INTO `tlx_account_field_defs` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)', array(null, "user_field_{$i}", $vars["NAME_FIELD_{$i}"], FT_TEXT, null, null, 0, null, null, 1, intval($vars["O_REQ_FIELD_{$i}"]), 1, intval($vars["O_REQ_FIELD_{$i}"])));
            $DB->Update("ALTER TABLE `tlx_account_fields` ADD COLUMN # TEXT", array("user_field_{$i}"));
        }
    }
    //
    // Dump account data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting account data...\n");
    echo "Converting account data...\n";
    flush();
    $DB->Update('DELETE FROM `tlx_accounts`');
    $DB->Update('DELETE FROM `tlx_account_hourly_stats`');
    $DB->Update('DELETE FROM `tlx_account_daily_stats`');
    $DB->Update('DELETE FROM `tlx_account_country_stats`');
    $DB->Update('DELETE FROM `tlx_account_referrer_stats`');
    $DB->Update('DELETE FROM `tlx_account_icons`');
    $DB->Update('DELETE FROM `tlx_account_comments`');
    $DB->Update('DELETE FROM `tlx_account_ranks`');
    $result = $CONVERTDB->Query('SELECT * FROM `arphp_Accounts`');
    while ($account = $CONVERTDB->NextRow($result)) {
        $parsed_url = parse_url($account['Site_URL']);
        $account['Domain'] = preg_replace('~^www\\.~i', '', $parsed_url['host']);
        $account['Banner_URL'] = str_replace($vars['BANNER_URL'], $C['banner_url'], $account['Banner_URL']);
        $DB->Update('INSERT INTO `tlx_accounts` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array($account['Username'], $account['Email'], $account['Site_URL'], $account['Domain'], $account['Banner_URL'], $account['Banner_URL'], $account['Banner_Height'], $account['Banner_Width'], $account['Title'], $account['Description'], null, date(DF_DATETIME, $account['Signup']), date(DF_DATETIME, $account['Signup']), null, sha1($account['Password']), $C['return_percent'], STATUS_ACTIVE, intval($account['Locked']), intval($account['Suspended']), 0, $category_ids[$account['Category']], 0, 0, $account['Num_Ratings'], $account['Rating_Total'], $account['Inactive'], null, $account['Comments']));
        $stats = array_merge(array($account['Username']), array_fill(0, 127, 0));
        $DB->Update('INSERT INTO `tlx_account_hourly_stats` VALUES (' . CreateBindList($stats) . ')', $stats);
        $account_info = array('username' => $account['Username'], 'user_field_1' => $account['Field_1'], 'user_field_2' => $account['Field_2'], 'user_field_3' => $account['Field_3']);
        $insert = CreateUserInsert('tlx_account_fields', $account_info);
        $DB->Update('INSERT INTO `tlx_account_fields` VALUES (' . $insert['bind_list'] . ')', $insert['binds']);
        foreach (explode(',', $account['Icons']) as $icon_id) {
            if (isset($icons[$icon_id])) {
                $DB->Update('INSERT INTO `tlx_account_icons` VALUES (?,?)', array($account['Username'], $icons[$icon_id]));
            }
        }
    }
    $CONVERTDB->Free($result);
    //
    // Dump account comments
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting account comments...\n");
    echo "Converting account comments...\n";
    flush();
    $DB->Update('DELETE FROM `tlx_account_comments`');
    $result = $CONVERTDB->Query('SELECT * FROM `arphp_Comments`');
    while ($comment = $CONVERTDB->NextRow($result)) {
        $DB->Update('INSERT INTO `tlx_account_comments` VALUES (?,?,?,?,?,?,?,?)', array(null, $comment['Username'], date(DF_DATETIME, $comment['Timestamp']), $comment['IP'], $comment['Name'], $comment['Email'], strtolower($comment['Status']), $comment['Comment']));
    }
    $CONVERTDB->Free($result);
    //
    // Dump ranking page data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting ranking pages...\n");
    echo "Converting ranking pages...\n";
    flush();
    $build_order = 1;
    $DB->Update('DELETE FROM `tlx_pages`');
    $DB->Update('ALTER TABLE `tlx_pages` AUTO_INCREMENT=0');
    $result = $CONVERTDB->Query('SELECT * FROM `arphp_Pages`');
    while ($page = $CONVERTDB->NextRow($result)) {
        $template = file_get_contents("{$_REQUEST['directory']}/data/pages/{$page['Identifier']}");
        $template = ConvertTemplate($template);
        $compiled = '';
        $DB->Update('INSERT INTO `tlx_pages` VALUES (?,?,?,?,?,?,?)', array(null, "tlx_pages/{$page['Identifier']}.html", $page['category'] == 'Mixed' ? null : $category_ids[$page['category']], $build_order++, null, $template, $compiled));
    }
    $CONVERTDB->Free($result);
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "\nData conversion complete!");
    echo "\nData conversion complete!\n";
    if (!$from_shell) {
        echo "</pre>";
    }
    $CONVERTDB->Disconnect();
}
コード例 #6
0
function GetWhichGalleries($update = FALSE)
{
    global $DB;
    $result = null;
    $req = $_REQUEST;
    if (IsEmptyString($_REQUEST['which'])) {
        parse_str($_REQUEST['results'], $req);
    }
    switch ($req['which']) {
        case 'specific':
            $result = $DB->Query('SELECT * FROM `tx_galleries` WHERE `gallery_id`=?', array($req['gallery_id']));
            break;
        case 'matching':
            // Extract search form information
            $search_form = array();
            parse_str($_REQUEST['search_form'], $search_form);
            if ($update) {
                GallerySearchSelect($update, $search_form);
                $result = $update;
            } else {
                // Build select query
                $select = new SelectBuilder('*', 'tx_galleries');
                GallerySearchSelect($select, $search_form);
                // Execute the query
                $result = $DB->Query($select->Generate(), $select->binds);
            }
            break;
        case 'all':
            $result = $DB->Query('SELECT * FROM `tx_galleries`');
            break;
        default:
            if ($update) {
                $update->AddWhere('gallery_id', ST_IN, join(',', $req['gallery_id']));
                $result = $update;
            } else {
                $bind_list = CreateBindList($req['gallery_id']);
                $result = $DB->Query('SELECT * FROM `tx_galleries` WHERE `gallery_id` IN (' . $bind_list . ')', $req['gallery_id']);
            }
            break;
    }
    return $result;
}
コード例 #7
0
ファイル: index.php プロジェクト: hackingman/ToplistX
function tlxAccountAdd()
{
    global $DB, $C, $IMAGE_EXTENSIONS;
    VerifyPrivileges(P_ACCOUNT_ADD);
    $_REQUEST['return_percent'] /= 100;
    // Get domain
    $parsed_url = parse_url($_REQUEST['site_url']);
    $_REQUEST['domain'] = preg_replace('~^www\\.~', '', $parsed_url['host']);
    $v = new Validator();
    $v->Register($_REQUEST['username'], V_LENGTH, 'The account username must be between 4 and 32 characters', '4,32');
    $v->Register($_REQUEST['username'], V_ALPHANUM, 'The account username may only contain English letters and numbers');
    $v->Register($_REQUEST['password'], V_LENGTH, 'The account password must be at least 4 characters', '4,9999');
    $v->Register($_REQUEST['email'], V_EMAIL, 'The E-mail Address is not properly formatted');
    $v->Register($_REQUEST['site_url'], V_URL, 'The Site URL is not properly formatted');
    $v->Register($_REQUEST['date_added'], V_DATETIME, 'The Date Added value is not properly formatted');
    if (!IsEmptyString($_REQUEST['banner_url'])) {
        $v->Register($_REQUEST['banner_url'], V_URL, sprintf($L['INVALID_URL'], $L['BANNER_URL']));
    }
    if (!$v->Validate()) {
        return $v->ValidationError('tlxShAccountAdd');
    }
    // Handling of banner_url_local
    if ($_REQUEST['download_banner']) {
        $http = new Http();
        if ($http->Get($_REQUEST['banner_url'], TRUE, $_REQUEST['site_url'])) {
            $banner_file = SafeFilename("{$C['banner_dir']}/{$_REQUEST['username']}.jpg", FALSE);
            FileWrite($banner_file, $http->body);
            $banner_info = @getimagesize($banner_file);
            if ($banner_info !== FALSE) {
                $_REQUEST['banner_width'] = $banner_info[0];
                $_REQUEST['banner_height'] = $banner_info[1];
                $banner_ext = strtolower($IMAGE_EXTENSIONS[$banner_info[2]]);
                if ($banner_ext != 'jpg') {
                    $new_file = preg_replace('~\\.jpg$~', ".{$banner_ext}", $banner_file);
                    rename($banner_file, $new_file);
                    $banner_file = $new_file;
                }
                $_REQUEST['banner_url_local'] = "{$C['banner_url']}/{$_REQUEST['username']}.{$banner_ext}";
            } else {
                @unlink($banner_file);
                $banner_file = null;
            }
        }
    }
    NullIfEmpty($_REQUEST['banner_url_local']);
    NullIfEmpty($_REQUEST['admin_comments']);
    // Add account data to the database
    $DB->Update('INSERT INTO `tlx_accounts` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array($_REQUEST['username'], $_REQUEST['email'], $_REQUEST['site_url'], $_REQUEST['domain'], $_REQUEST['banner_url'], $_REQUEST['banner_url_local'], $_REQUEST['banner_height'], $_REQUEST['banner_width'], $_REQUEST['title'], $_REQUEST['description'], $_REQUEST['keywords'], $_REQUEST['date_added'], $_REQUEST['status'] == STATUS_ACTIVE ? MYSQL_NOW : null, null, sha1($_REQUEST['password']), $_REQUEST['return_percent'], $_REQUEST['status'], intval($_REQUEST['locked']), intval($_REQUEST['disabled']), 0, $_REQUEST['category_id'], null, null, intval($_REQUEST['ratings']), intval($_REQUEST['ratings_total']), 0, null, $_REQUEST['admin_comments']));
    // Add click stats to the database
    $stats = array($_REQUEST['username']);
    $totals = array('raw_in_total' => 0, 'unique_in_total' => 0, 'raw_out_total' => 0, 'unique_out_total' => 0, 'clicks_total' => 0);
    foreach (range(0, 23) as $hour) {
        $stats[] = $_REQUEST["raw_in_{$hour}"];
        $stats[] = $_REQUEST["unique_in_{$hour}"];
        $stats[] = $_REQUEST["raw_out_{$hour}"];
        $stats[] = $_REQUEST["unique_out_{$hour}"];
        $stats[] = $_REQUEST["clicks_{$hour}"];
        $totals['raw_in_total'] += $_REQUEST["raw_in_{$hour}"];
        $totals['unique_in_total'] += $_REQUEST["unique_in_{$hour}"];
        $totals['raw_out_total'] += $_REQUEST["raw_out_{$hour}"];
        $totals['unique_out_total'] += $_REQUEST["unique_out_{$hour}"];
        $totals['clicks_total'] += $_REQUEST["clicks_{$hour}"];
    }
    array_push($stats, $totals['raw_in_total'], $totals['unique_in_total'], $totals['raw_out_total'], $totals['unique_out_total'], $totals['clicks_total'], 0, 0);
    $DB->Update('INSERT INTO `tlx_account_hourly_stats` VALUES (' . CreateBindList($stats) . ')', $stats);
    // Add user defined fields
    $query_data = CreateUserInsert('tlx_account_fields', $_REQUEST);
    $DB->Update('INSERT INTO `tlx_account_fields` VALUES (' . $query_data['bind_list'] . ')', $query_data['binds']);
    // Add icons
    if (is_array($_REQUEST['icons'])) {
        foreach ($_REQUEST['icons'] as $icon_id) {
            $DB->Update('INSERT INTO `tlx_account_icons` VALUES (?,?)', array($_REQUEST['username'], $icon_id));
        }
    }
    $GLOBALS['message'] = 'New account successfully added';
    $GLOBALS['added'] = true;
    UnsetArray($_REQUEST);
    tlxShAccountAdd();
}