示例#1
0
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']}/tgpr.pl")) {
        $errors[] = "The tgpr.pl file could not be found in the " . htmlspecialchars($_REQUEST['directory']) . " directory";
        return DisplayMain($errors);
    }
    if (!is_readable("{$_REQUEST['directory']}/tgpr.pl")) {
        $errors[] = "The tgpr.pl 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']}/tgpr.pl");
    if (preg_match('~\\$VERSION\\s+=\\s+\'(.*?)\'~', $version_file_contents, $matches)) {
        list($a, $b, $c) = explode('.', $matches[1]);
        if ($b < 2 || strpos($c, '-SS') === FALSE) {
            $errors[] = "Your TGP Rotator installation is outdated; please upgrade to the very latest snapshot release (1.2.1-SS)";
            return DisplayMain($errors);
        }
    } else {
        $errors[] = "Unable to extract version information from tgpr.pl; your version of TGP Rotator is likely too old";
        return DisplayMain($errors);
    }
    // Extract MySQL information
    $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);
    }
    if (!is_writable("{$GLOBALS['BASE_DIR']}/annotations")) {
        $errors[] = "Change the permissions on the TGPX annotations directory to 777";
        return DisplayMain($errors);
    }
    if ($C['preview_dir'] == $vars['THUMB_DIR']) {
        $errors[] = "The TGPX Thumbnail URL cannot be the same as the TGP Rotator Thumbnail URL";
        return DisplayMain($errors);
    }
    $CONVERTDB = new DB($vars['HOSTNAME'], $vars['USERNAME'], $vars['PASSWORD'], $vars['DATABASE']);
    $CONVERTDB->Connect();
    $CONVERTDB->Update('SET wait_timeout=86400');
    $columns = $CONVERTDB->GetColumns('tr_Galleries');
    if (!in_array('Thumbnail_URL', $columns)) {
        $errors[] = "Your TGP Rotator installation is outdated; please upgrade to the latest snapshot release";
        return DisplayMain($errors);
    }
    if (!$from_shell) {
        echo "<pre>";
    }
    // Copy annotations
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying annotation font files and images...\n");
    echo "Copying annotation font files and images...\n";
    flush();
    $annotations =& DirRead($vars['ANNOTATION_DIR'], '^[^.]');
    foreach ($annotations as $annotation) {
        @copy("{$vars['ANNOTATION_DIR']}/{$annotation}", "{$GLOBALS['BASE_DIR']}/annotations/{$annotation}");
    }
    // Copy thumbnail previews
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying thumbnail preview images...\n");
    echo "Copying thumbnail preview images...\n";
    flush();
    $thumbs =& DirRead($vars['THUMB_DIR'], '\\.jpg$');
    foreach ($thumbs as $thumb) {
        @copy("{$vars['THUMB_DIR']}/{$thumb}", "{$C['preview_dir']}/t_{$thumb}");
        @chmod("{$C['preview_dir']}/t_{$thumb}", 0666);
    }
    //
    // Dump annotations
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting annotation settings...\n");
    echo "Converting annotation settings...\n";
    flush();
    $annotations = array();
    $DB->Update('DELETE FROM `tx_annotations`');
    $result = $CONVERTDB->Query('SELECT * FROM `tr_Annotations`');
    while ($annotation = $CONVERTDB->NextRow($result)) {
        $DB->Update('INSERT INTO `tx_annotations` VALUES (?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $annotation['Identifier'], strtolower($annotation['Type']), $annotation['String'], 0, $annotation['Font_File'], $annotation['Size'], $annotation['Color'], $annotation['Shadow'], $annotation['Image_File'], $annotation['Transparency'], $annotation['Location']));
        $annotations[$annotation['Unique_ID']] = $DB->InsertID();
    }
    $CONVERTDB->Free($result);
    //
    // 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 `tx_categories`');
    $result = $CONVERTDB->Query('SELECT * FROM `tr_Categories`');
    while ($category = $CONVERTDB->NextRow($result)) {
        $tag = CreateCategoryTag($category['Name']);
        $categories[$category['Name']] = $tag;
        $DB->Update('INSERT INTO `tx_categories` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $category['Name'], $tag, empty($category['Pictures']) ? 0 : 1, $category['Pictures'], 10, 30, 12288, "{$vars['THUMB_WIDTH']}x{$vars['THUMB_HEIGHT']}", 1, $annotations[$category['Ann_Pictures']], empty($category['Movies']) ? 0 : 1, $category['Movies'], 5, 30, 102400, "{$vars['THUMB_WIDTH']}x{$vars['THUMB_HEIGHT']}", 1, $annotations[$category['Ann_Movies']], -1, 0, null, null, null));
        $category_ids[$category['Name']] = $DB->InsertID();
    }
    $CONVERTDB->Free($result);
    //
    // Dump sponsors
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting sponsors...\n");
    echo "Converting sponsors...\n";
    flush();
    $counter = 1;
    $sponsors = array();
    $DB->Update('DELETE FROM `tx_sponsors`');
    $result = $CONVERTDB->Query('SELECT DISTINCT `Sponsor` FROM `tr_Galleries` WHERE `Sponsor`!=?', array(''));
    while ($sponsor = $CONVERTDB->NextRow($result)) {
        $sponsors[$sponsor['Sponsor']] = $counter;
        $DB->Update("INSERT INTO `tx_sponsors` VALUES (?,?,?)", array($counter++, $sponsor['Sponsor'], null));
    }
    $CONVERTDB->Free($result);
    //
    // Dump gallery data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting gallery data...\n");
    echo "Converting gallery data...\n";
    flush();
    $DB->Update('DELETE FROM `tx_galleries`');
    $DB->Update('DELETE FROM `tx_gallery_fields`');
    $DB->Update('DELETE FROM `tx_gallery_icons`');
    $DB->Update('DELETE FROM `tx_gallery_previews`');
    $DB->Update('ALTER TABLE `tx_galleries` AUTO_INCREMENT=0');
    $DB->Update('ALTER TABLE `tx_gallery_previews` AUTO_INCREMENT=0');
    $result = $CONVERTDB->Query('SELECT * FROM `tr_Galleries` ORDER BY `Gallery_ID`');
    $preview_sizes = array();
    while ($gallery = $CONVERTDB->NextRow($result)) {
        $DB->Update("INSERT INTO `tx_galleries` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", array(null, $gallery['Gallery_URL'], $gallery['Description'], $gallery['Keywords'], $gallery['Thumbnails'], $C['from_email'], null, $gallery['Weight'], $gallery['Clicks'], $_SERVER['REMOTE_ADDR'], null, !empty($gallery['Sponsor']) ? $sponsors[$gallery['Sponsor']] : null, 'permanent', strtolower($gallery['Type']), $gallery['Status'] == 'Pending' ? 'approved' : strtolower($gallery['Status']), $gallery['Status'] == 'Disabled' ? 'approved' : null, date(DF_DATETIME, TimeWithTz($gallery['Added'])), date(DF_DATETIME, TimeWithTz($gallery['Added'])), date(DF_DATETIME, TimeWithTz($gallery['Added'])), empty($gallery['Scheduled_Date']) ? null : "{$gallery['Scheduled_Date']} 00:00:00", empty($gallery['Display_Date']) ? null : "{$gallery['Display_Date']} 12:00:00", null, null, 'TGPR Convert', '', null, 0, empty($gallery['Thumbnail_URL']) ? 0 : 1, $gallery['Allow_Scan'], $gallery['Allow_Thumb'], $gallery['Times_Selected'], $gallery['Used_Counter'], $gallery['Build_Counter'], null, MIXED_CATEGORY . " " . $categories[$gallery['Category']]));
        $gallery_id = $DB->InsertID();
        $gallery_info = array('gallery_id' => $gallery_id);
        $insert = CreateUserInsert('tx_gallery_fields', $gallery_info);
        $DB->Update('INSERT INTO `tx_gallery_fields` VALUES (' . $insert['bind_list'] . ')', $insert['binds']);
        foreach (explode(',', $gallery['Icons']) as $icon_id) {
            if (isset($icons[$icon_id])) {
                $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($gallery_id, $icons[$icon_id]));
            }
        }
        if (!empty($gallery['Thumbnail_URL'])) {
            $dimensions = '';
            if (!empty($gallery['Thumb_Width']) && !empty($gallery['Thumb_Height'])) {
                $dimensions = "{$gallery['Thumb_Width']}x{$gallery['Thumb_Height']}";
                $preview_sizes[$dimensions] = TRUE;
            }
            $DB->Update('INSERT INTO `tx_gallery_previews` VALUES (?,?,?,?)', array(null, $gallery_id, '', $dimensions));
            $preview_id = $DB->InsertID();
            if (preg_match('~^' . preg_quote($vars['THUMB_URL']) . '~i', $gallery['Thumbnail_URL'])) {
                $gallery['Thumbnail_URL'] = "{$C['preview_url']}/{$preview_id}.jpg";
                $DB->Update('UPDATE `tx_gallery_previews` SET `preview_url`=? WHERE `preview_id`=?', array($gallery['Thumbnail_URL'], $preview_id));
                @rename("{$C['preview_dir']}/t_{$gallery['Gallery_ID']}.jpg", "{$C['preview_dir']}/{$preview_id}.jpg");
            }
        }
    }
    $CONVERTDB->Free($result);
    // Update the stored thumbnail preview sizes
    $sizes = unserialize(GetValue('preview_sizes'));
    if (!is_array($sizes)) {
        $sizes = array();
    }
    $sizes = array_merge($sizes, array_keys($preview_sizes));
    StoreValue('preview_sizes', serialize(array_unique($sizes)));
    //
    // Dump TGP page data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting TGP pages...\n");
    echo "Converting TGP pages...\n";
    flush();
    $build_order = 1;
    $DB->Update('DELETE FROM `tx_pages`');
    $DB->Update('ALTER TABLE `tx_pages` AUTO_INCREMENT=0');
    $result = $CONVERTDB->Query('SELECT * FROM `tr_Pages` ORDER BY `Build_Order`');
    while ($page = $CONVERTDB->NextRow($result)) {
        $template = file_get_contents("{$_REQUEST['directory']}/data/pages/{$page['Page_ID']}");
        $template = ConvertTemplate($template);
        $compiled = '';
        $page['Directory'] = preg_replace('~/$~', '', $page['Directory']);
        $DB->Update('INSERT INTO `tx_pages` VALUES (?,?,?,?,?,?,?,?,?)', array(null, "{$page['Directory']}/{$page['Filename']}", $page['Page_URL'], $page['Category'] == 'Mixed' ? null : $category_ids[$page['Category']], $build_order++, 0, 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>";
    }
}
示例#2
0
function BuildPages(&$pages, $callback = null, $all = FALSE)
{
    global $DB, $C, $L;
    // One at a time please
    $wouldblock = FALSE;
    $fd = fopen("{$GLOBALS['BASE_DIR']}/data/_build_lock", 'w');
    flock($fd, LOCK_EX | LOCK_NB, $wouldblock);
    if ($wouldblock) {
        return;
    }
    // Clear old build history
    $DB->Update('DELETE FROM `tx_build_history` WHERE `date_start` < DATE_ADD(?, INTERVAL -14 DAY)', array(MYSQL_NOW));
    $DB->Update('INSERT INTO `tx_build_history` VALUES (?,?,?,?,?,?,?)', array(null, MYSQL_NOW, null, null, count($pages), 0, null));
    $GLOBALS['build_history_id'] = $DB->InsertID();
    if (!preg_match('~^\\d\\d\\d$~', $C['page_permissions'])) {
        $C['page_permissions'] = $GLOBALS['FILE_PERMISSIONS'];
    } else {
        $C['page_permissions'] = octdec('0' . $C['page_permissions']);
    }
    // Clear records of currently used galleries on these pages
    ClearUsedGalleries($pages, $all);
    // Process the clicklog
    ProcessClickLog();
    // Cache icons
    if (!isset($GLOBALS['ICON_CACHE'])) {
        $GLOBALS['ICON_CACHE'] =& $DB->FetchAll('SELECT * FROM `tx_icons`', null, 'icon_id');
    }
    // Cache categories by tag
    if (!isset($GLOBALS['CATEGORY_CACHE_TAG'])) {
        $GLOBALS['CATEGORY_CACHE_TAG'] =& $DB->FetchAll('SELECT * FROM `tx_categories` ORDER BY `name`', null, 'tag');
    }
    // Cache categories by id
    if (!isset($GLOBALS['CATEGORY_CACHE_ID'])) {
        $GLOBALS['CATEGORY_CACHE_ID'] =& $DB->FetchAll('SELECT * FROM `tx_categories`', null, 'category_id');
        $GLOBALS['CATEGORY_CACHE_ID'][''] = array('name' => $L['MIXED'], 'category_id' => 0);
    }
    // Cache sponsors by id
    if (!isset($GLOBALS['SPONSOR_CACHE'])) {
        $GLOBALS['SPONSOR_CACHE'] =& $DB->FetchAll('SELECT * FROM `tx_sponsors`', null, 'sponsor_id');
    }
    // Clear data on galleries used during the previous build
    $DB->Update('UPDATE `tx_gallery_used` SET `this_build`=0,`new`=0');
    // Remove galleries scheduled for deletion
    $result = $DB->Query('SELECT * FROM `tx_galleries` WHERE `date_deletion` <= ?', array(MYSQL_NOW));
    while ($gallery = $DB->NextRow($result)) {
        DeleteGallery($gallery['gallery_id'], $gallery);
    }
    $DB->Free($result);
    // Delete old submitted galleries that are currently holding
    $result = $DB->Query('SELECT * FROM `tx_galleries` WHERE `status`=? AND `type`=? AND `date_displayed` <= SUBDATE(?, INTERVAL ? DAY)', array('holding', 'submitted', MYSQL_NOW, $C['submitted_hold']));
    while ($gallery = $DB->NextRow($result)) {
        DeleteGallery($gallery['gallery_id'], $gallery);
    }
    $DB->Free($result);
    // Rotate permanent galleries from holding back to approved queue
    $DB->Update('UPDATE `tx_galleries` SET ' . "`status`='approved', " . "`date_displayed`=NULL, " . "`build_counter`=IF(?, 0, `build_counter`), " . "`used_counter`=IF(?, 0, `used_counter`), " . "`clicks`=IF(?, 0, `clicks`) " . "WHERE `status`='holding' AND `type`='permanent' AND `date_displayed` <= SUBDATE(?, INTERVAL ? DAY)", array(intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), MYSQL_NOW, $C['permanent_hold']));
    // Count total thumbs and galleries
    $GLOBALS['_totals'] = $DB->Row("SELECT COUNT(*) AS `galleries`,SUM(`thumbnails`) AS `thumbnails` FROM `tx_galleries` WHERE `status` IN ('approved','used')");
    $GLOBALS['_totals']['categories'] = count($GLOBALS['CATEGORY_CACHE_ID']) - 1;
    // Build each page
    foreach ($pages as $page) {
        $page_all = $DB->Row('SELECT * FROM `tx_pages` WHERE `page_id`=?', array($page['page_id']));
        if ($page_all['locked'] && !$GLOBALS['override_page_lock']) {
            continue;
        }
        if ($callback) {
            call_user_func($callback, $page_all);
        }
        $DB->Update('DELETE FROM `tx_gallery_used_page`');
        $DB->Update('DELETE FROM `tx_ads_used_page`');
        $DB->Update('UPDATE `tx_build_history` SET `current_page_url`=? WHERE `history_id`=?', array($page_all['page_url'], $GLOBALS['build_history_id']));
        BuildPage($page_all);
        $DB->Update('UPDATE `tx_build_history` SET `pages_built`=`pages_built`+1 WHERE `history_id`=?', array($GLOBALS['build_history_id']));
        unset($page_all);
        unset($page);
    }
    // Mark newly selected galleries as used
    // Update counters for galleries used this build
    $DB->Update('UPDATE `tx_galleries` JOIN `tx_gallery_used` USING (`gallery_id`) SET ' . '`build_counter`=`build_counter`+1, ' . '`used_counter`=`used_counter`+1, ' . '`times_selected`=IF(`new`=1, `times_selected`+1, `times_selected`), ' . '`status`=?, ' . '`date_displayed`=IF(`new`=1, ?, `date_displayed`) ' . 'WHERE `this_build`=1', array('used', MYSQL_NOW));
    // Move no longer used galleries to holding queue (or rotate back to approved if permanent holding period is 0)
    if ($C['permanent_hold'] == 0) {
        $DB->Update('UPDATE `tx_galleries` LEFT JOIN `tx_gallery_used` USING (`gallery_id`) SET ' . "`status`=IF(`type`='permanent', 'approved', 'holding'), " . "`date_displayed`=IF(`type`='permanent', NULL, `date_displayed`), " . "`date_approved`=IF(`type`='permanent', NULL, `date_approved`), " . "`date_scheduled`=IF(`type`='permanent', NULL, `date_scheduled`), " . "`build_counter`=IF(`type`='permanent', IF(?, 0, `build_counter`+1), `build_counter`+1), " . "`used_counter`=IF(`type`='permanent', IF(?, 0, `used_counter`), `used_counter`), " . "`clicks`=IF(`type`='permanent', IF(?, 0, `clicks`), `clicks`) " . "WHERE `status`='used' AND `page_id` IS NULL", array(intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), intval($C['reset_on_rotate']), 'used'));
    } else {
        $DB->Update('UPDATE `tx_galleries` LEFT JOIN `tx_gallery_used` USING (`gallery_id`) SET `status`=?,`build_counter`=`build_counter`+1 WHERE `status`=? AND `page_id` IS NULL', array('holding', 'used'));
    }
    $DB->Update('UPDATE `tx_build_history` SET `date_end`=?,`current_page_url`=NULL WHERE `history_id`=?', array(gmdate(DF_DATETIME, TimeWithTz()), $GLOBALS['build_history_id']));
    flock($fd, LOCK_UN);
    fclose($fd);
    @chmod("{$GLOBALS['BASE_DIR']}/data/_build_lock", 0666);
}
示例#3
0
function ProcessAccount(&$account, &$exception)
{
    global $configuration, $exceptions, $penalties, $DB, $config_id, $history_id;
    $removed = FALSE;
    $message = '';
    $penalty = 0x0;
    $reasons = array('connect' => "Connection error: {$account['http']->errstr}", 'forward' => "Redirecting URL: {$account['http']->response_headers['status']}", 'broken' => "Broken URL: {$account['http']->response_headers['status']}", 'blacklist' => "Blacklisted data: " . htmlspecialchars($account['blacklist_item']));
    // Determine the most strict penalty based on the infractions that were found
    foreach ($exceptions as $key => $value) {
        if ($exception & $value && $configuration['action_' . $key] >= $penalty) {
            $message = $reasons[$key];
            $penalty = intval($configuration['action_' . $key], 16);
        }
    }
    // Blacklist
    if ($penalty & $penalties['blacklist']) {
        $action = 'Blacklisted';
        $removed = TRUE;
        AutoBlacklist($account);
        DeleteAccount($account['username'], $account);
        // Update history
        $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1,`blacklisted`=`blacklisted`+1 WHERE `history_id`=?', array($history_id));
    } else {
        if ($penalty & $penalties['delete']) {
            $action = 'Deleted';
            $removed = TRUE;
            DeleteAccount($account['username'], $account);
            // Update history
            $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1,`deleted`=`deleted`+1 WHERE `history_id`=?', array($history_id));
        } else {
            if ($penalty & $penalties['disable']) {
                $action = 'Disabled';
                // Disable account
                $DB->Update('UPDATE `tlx_accounts` SET `disabled`=1 WHERE `username`=?', array($account['username']));
                // Update history
                $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1,`disabled`=`disabled`+1 WHERE `history_id`=?', array($history_id));
            } else {
                if ($penalty & $penalties['report']) {
                    $action = 'Unchanged';
                    // Update history
                    $DB->Update('UPDATE `tlx_scanner_history` SET `exceptions`=`exceptions`+1 WHERE `history_id`=?', array($history_id));
                } else {
                    // Do nothing
                    $exception = 0x0;
                    return $removed;
                }
            }
        }
    }
    $DB->Update('INSERT INTO `tlx_scanner_results` VALUES (?,?,?,?,?,?,?)', array($config_id, $account['username'], $account['site_url'], $account['http']->response_headers['status'], gmdate(DF_DATETIME, TimeWithTz()), $action, $message));
    return $removed;
}
<?php

if (!defined('TGPX')) {
    die("Access denied");
}
$defaults = array('submit_ip' => $_SERVER['REMOTE_ADDR'], 'status' => 'active', 'date_added' => gmdate(DF_DATETIME, TimeWithTz()), 'date_modified' => '', 'clicks' => 0, 'ratings' => 0, 'rating_total' => 0, 'weight' => $C['gallery_weight'], 'allow_scan' => true, 'allow_preview' => true);
if (!$editing) {
    $_REQUEST = array_merge($defaults, $_REQUEST);
}
$categories =& $DB->FetchAll('SELECT `name`,`category_id` FROM `tx_categories` ORDER BY `name`');
$sponsors =& $DB->FetchAll('SELECT `sponsor_id`,`name` FROM `tx_sponsors` ORDER BY `name`');
$icons =& $DB->FetchAll('SELECT * FROM `tx_icons` ORDER BY `identifier`');
$jscripts = array('includes/calendar.js');
$csses = array('includes/calendar.css');
include_once 'includes/header.php';
?>

<script language="JavaScript">
$(function()
  {
      $('#description').bind('keyup', function() { $('#charcount').html($(this).val().length); });
      $('#description').trigger('keyup');
  });

function searchUsers()
{
    var term = $('#partner').val();

    if( !term )
    {
        alert('Please enter an e-mail address or username to search for');
示例#5
0
文件: ajax.php 项目: hackingman/LinkX
/**
* Get the current date and time with timezone offset
*/
function lxGetDate()
{
    global $json;
    $date = gmdate($_REQUEST['dateonly'] ? DF_DATE : DF_DATETIME, TimeWithTz());
    echo $json->encode(array('status' => JSON_SUCCESS, 'date' => $date, 'field' => $_REQUEST['field']));
}
示例#6
0
define('ST_GREATER_EQ', 'greatereq');
define('ST_LESS', 'less');
define('ST_LESS_EQ', 'lesseq');
define('ST_EMPTY', 'empty');
define('ST_ANY', 'any');
define('ST_IN', 'in');
define('ST_NOT_IN', 'not_in');
define('ST_NOT_EMPTY', 'not_empty');
define('ST_NULL', 'null');
define('ST_NOT_MATCHES', 'not_matches');
define('ST_NOT_NULL', 'not_null');
// Other
define('MYSQL_EXPIRES', '2000-01-01 00:00:00');
define('MYSQL_NOW', gmdate(DF_DATETIME, TimeWithTz()));
define('MYSQL_CURDATE', gmdate(DF_DATE, TimeWithTz()));
define('TIME_NOW', TimeWithTz());
define('RE_DATETIME', '~^\\d\\d\\d\\d-\\d\\d-\\d\\d \\d\\d:\\d\\d:\\d\\d$~');
define('JSON_SUCCESS', 'Success');
define('JSON_FAILURE', 'Failure');
// Blacklist types
$GLOBALS['BLIST_TYPES'] = array('submit_ip' => 'Submitter IP', 'email' => 'E-mail Address', 'url' => 'Domain/URL', 'domain_ip' => 'Domain IP', 'word' => 'Word', 'html' => 'HTML', 'headers' => 'HTTP Headers', 'dns' => 'DNS Server');
// Image file extensions
$GLOBALS['IMAGE_EXTENSIONS'] = array('', 'gif', 'jpg', 'png');
function ProcessHourlyStats()
{
    global $DB, $C;
    $now = TIME_NOW;
    $datetime = gmdate('Y-m-d-G', $now);
    // Lock tables to prevent multiple updates
    $DB->Query('LOCK TABLES `tlx_stored_values` WRITE, `tlx_account_hourly_stats` WRITE, `tlx_ip_log_in` WRITE, `tlx_ip_log_out` WRITE, `tlx_ip_log_clicks` WRITE');
    $last_updates = unserialize(GetValue('last_updates'));
示例#7
0
<?php

if (!defined('ToplistX')) {
    die("Access denied");
}
$defaults = array('status' => 'active', 'date_added' => gmdate(DF_DATETIME, TimeWithTz()), 'ratings' => 0, 'ratings_total' => 0, 'return_percent' => $C['return_percent']);
if (!$editing) {
    $_REQUEST = array_merge($defaults, $_REQUEST);
}
$categories =& $DB->FetchAll('SELECT `name`,`category_id` FROM `tlx_categories` ORDER BY `name`');
$icons =& $DB->FetchAll('SELECT * FROM `tlx_icons` ORDER BY `identifier`');
$jscripts = array('includes/calendar.js');
$csses = array('includes/calendar.css');
include_once 'includes/header.php';
?>

<script language="JavaScript">
$(function()
  {
      $('#description').bind('keyup', function() { $('#description_charcount').html($(this).val().length); });
      $('#description').trigger('keyup');

      $('#title').bind('keyup', function() { $('#title_charcount').html($(this).val().length); });
      $('#title').trigger('keyup');

      updateRating();
  });

function updateRating()
{
    var ratings = parseInt($('#ratings').val());
示例#8
0
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']}/ags.pl")) {
        $errors[] = "The ags.pl file could not be found in the " . htmlspecialchars($_REQUEST['directory']) . " directory";
        return DisplayMain($errors);
    }
    if (!is_readable("{$_REQUEST['directory']}/ags.pl")) {
        $errors[] = "The ags.pl 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']}/ags.pl");
    if (preg_match('~\\$VERSION\\s+=\\s+\'(.*?)\'~', $version_file_contents, $matches)) {
        if ($matches[1] != '3.6.2-SS') {
            $errors[] = "Your AutoGallery SQL installation is outdated ({$matches[1]}); please upgrade to version 3.6.2-SS";
            return DisplayMain($errors);
        }
    } else {
        $errors[] = "Unable to extract version information from ags.pl; your version of AutoGallery SQL is likely too old";
        return DisplayMain($errors);
    }
    // Extract MySQL information
    $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);
    }
    if (!is_writable("{$GLOBALS['BASE_DIR']}/annotations")) {
        $errors[] = "Change the permissions on the TGPX annotations directory to 777";
        return DisplayMain($errors);
    }
    if (!is_writable($C['font_dir'])) {
        $errors[] = "Change the permissions on the TGPX fonts directory to 777";
        return DisplayMain($errors);
    }
    if ($C['preview_dir'] == $vars['THUMB_DIR']) {
        $errors[] = "The TGPX Thumbnail URL cannot be the same as the AutoGallery SQL Thumbnail URL";
        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 fonts for validation codes
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying font files for verification codes...\n");
    echo "Copying font files for verification codes...\n";
    flush();
    $fonts =& DirRead($vars['FONT_DIR'], '^[^.]');
    foreach ($fonts as $font) {
        @copy("{$vars['FONT_DIR']}/{$font}", "{$C['font_dir']}/{$font}");
    }
    // Copy annotations
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying annotation font files and images...\n");
    echo "Copying annotation font files and images...\n";
    flush();
    $annotations =& DirRead($vars['ANNOTATION_DIR'], '^[^.]');
    foreach ($annotations as $annotation) {
        @copy("{$vars['ANNOTATION_DIR']}/{$annotation}", "{$GLOBALS['BASE_DIR']}/annotations/{$annotation}");
    }
    // Copy thumbnail previews
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Copying thumbnail preview images...\n");
    echo "Copying thumbnail preview images...\n";
    flush();
    $thumbs =& DirRead($vars['THUMB_DIR'], '\\.jpg$');
    foreach ($thumbs as $thumb) {
        @copy("{$vars['THUMB_DIR']}/{$thumb}", "{$C['preview_dir']}/t_{$thumb}");
        @chmod("{$C['preview_dir']}/t_{$thumb}", 0666);
    }
    //
    // Dump e-mail log
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting e-mail log...\n");
    echo "Converting e-mail log...\n";
    flush();
    $emails = file("{$_REQUEST['directory']}/data/emails");
    $DB->Update('DELETE FROM `tx_email_log`');
    foreach ($emails as $email) {
        $email = trim($email);
        if (empty($email)) {
            continue;
        }
        $DB->Update('REPLACE INTO `tx_email_log` VALUES (?)', array($email));
    }
    //
    // Dump blacklist
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting blacklist...\n");
    echo "Converting blacklist...\n";
    flush();
    $DB->Update('DELETE FROM `tx_blacklist`');
    $types = array('submit_ip' => 'submitip', 'email' => 'email', 'url' => 'domain', 'domain_ip' => 'domainip', 'word' => 'word', 'html' => 'html', 'headers' => 'headers', 'dns' => 'dns');
    foreach ($types as $new_type => $old_type) {
        if (is_file("{$_REQUEST['directory']}/data/blacklist/{$old_type}")) {
            $blist_items = file("{$_REQUEST['directory']}/data/blacklist/{$old_type}");
            foreach ($blist_items as $html) {
                $html = trim($html);
                if (empty($html)) {
                    continue;
                }
                $regex = 0;
                if (strpos($html, '*') !== FALSE) {
                    $regex = 1;
                    $html = preg_quote($html);
                    $html = str_replace('\\*', '.*?', $html);
                }
                $DB->Update('INSERT INTO `tx_blacklist` VALUES (?,?,?,?,?)', array(null, $new_type, $regex, $html, ''));
            }
        }
    }
    //
    // Dump whitelist
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting whitelist...\n");
    echo "Converting whitelist...\n";
    flush();
    $DB->Update('DELETE FROM `tx_whitelist`');
    $wlist_items = file("{$_REQUEST['directory']}/data/blacklist/whitelist");
    foreach ($wlist_items as $html) {
        $html = trim($html);
        if (empty($html)) {
            continue;
        }
        $regex = 0;
        if (strpos($html, '*') !== FALSE) {
            $regex = 1;
            $html = preg_quote($html);
            $html = str_replace('\\*', '.*?', $html);
        }
        $DB->Update('INSERT INTO `tx_whitelist` VALUES (?,?,?,?,?,?,?,?,?,?)', array(null, 'url', $regex, $html, '', 1, 0, 0, 0, 0));
    }
    //
    // Dump reciprocal links
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting reciprocal link settings...\n");
    echo "Converting reciprocal link settings...\n";
    flush();
    $DB->Update('DELETE FROM `tx_reciprocals`');
    IniParse("{$_REQUEST['directory']}/data/generalrecips", TRUE, $recips);
    IniParse("{$_REQUEST['directory']}/data/trustedrecips", TRUE, $recips);
    foreach ($recips as $identifier => $html) {
        $regex = 0;
        if (strpos($html, '*') !== FALSE) {
            $regex = 1;
            $html = preg_quote($html);
            $html = str_replace('\\*', '.*?', $html);
        }
        $DB->Update('INSERT INTO `tx_reciprocals` VALUES (?,?,?,?)', array(null, $identifier, $html, $regex));
    }
    //
    // Dump 2257 code
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting 2257 search code...\n");
    echo "Converting 2257 search code...\n";
    flush();
    $counter = 1;
    $c2257s = file("{$_REQUEST['directory']}/data/2257");
    $DB->Update('DELETE FROM `tx_2257`');
    foreach ($c2257s as $html) {
        $html = trim($html);
        if (empty($html)) {
            continue;
        }
        $regex = 0;
        if (strpos($html, '*') !== FALSE) {
            $regex = 1;
            $html = preg_quote($html);
            $html = str_replace('\\*', '.*?', $html);
        }
        $DB->Update('INSERT INTO `tx_2257` VALUES (?,?,?,?)', array(null, "AGS Converted #{$counter}", $html, $regex));
        $counter++;
    }
    //
    // Dump icons
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting icons...\n");
    echo "Converting icons...\n";
    flush();
    $icons = array();
    $DB->Update('DELETE FROM `tx_icons`');
    IniParse("{$_REQUEST['directory']}/data/icons", TRUE, $icons_ini);
    foreach ($icons_ini as $identifier => $html) {
        $identifier = trim($identifier);
        $html = trim($html);
        if (empty($identifier) || empty($html)) {
            continue;
        }
        $DB->Update('INSERT INTO `tx_icons` VALUES (?,?,?)', array(null, $identifier, $html));
        $icons[$identifier] = $DB->InsertID();
    }
    //
    // Dump annotations
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting annotation settings...\n");
    echo "Converting annotation settings...\n";
    flush();
    $annotations = array();
    $DB->Update('DELETE FROM `tx_annotations`');
    $result = $CONVERTDB->Query('SELECT * FROM `ags_Annotations`');
    while ($annotation = $CONVERTDB->NextRow($result)) {
        $DB->Update('INSERT INTO `tx_annotations` VALUES (?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $annotation['Identifier'], strtolower($annotation['Type']), $annotation['String'], 0, $annotation['Font_File'], $annotation['Size'], $annotation['Color'], $annotation['Shadow'], $annotation['Image_File'], $annotation['Transparency'], $annotation['Location']));
        $annotations[$annotation['Unique_ID']] = $DB->InsertID();
    }
    $CONVERTDB->Free($result);
    //
    // 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 `tx_categories`');
    $result = $CONVERTDB->Query('SELECT * FROM `ags_Categories`');
    while ($category = $CONVERTDB->NextRow($result)) {
        $tag = CreateCategoryTag($category['Name']);
        $categories[$category['Name']] = $tag;
        $DB->Update('INSERT INTO `tx_categories` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(null, $category['Name'], $tag, empty($category['Ext_Pictures']) ? 0 : 1, $category['Ext_Pictures'], $category['Min_Pictures'], $category['Max_Pictures'], $category['Size_Pictures'], "{$vars['THUMB_WIDTH']}x{$vars['THUMB_HEIGHT']}", 1, $annotations[$category['Ann_Pictures']], empty($category['Ext_Movies']) ? 0 : 1, $category['Ext_Movies'], $category['Min_Movies'], $category['Max_Movies'], $category['Size_Movies'], "{$vars['THUMB_WIDTH']}x{$vars['THUMB_HEIGHT']}", 1, $annotations[$category['Ann_Movies']], $category['Per_Day'], $category['Hidden'], null, null, null));
        $category_ids[$category['Name']] = $DB->InsertID();
    }
    $CONVERTDB->Free($result);
    //
    // Dump sponsors
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting sponsors...\n");
    echo "Converting sponsors...\n";
    flush();
    $counter = 1;
    $sponsors = array();
    $DB->Update('DELETE FROM `tx_sponsors`');
    $result = $CONVERTDB->Query('SELECT DISTINCT `Sponsor` FROM `ags_Galleries` WHERE `Sponsor`!=?', array(''));
    while ($sponsor = $CONVERTDB->NextRow($result)) {
        $sponsors[$sponsor['Sponsor']] = $counter;
        $DB->Update("INSERT INTO `tx_sponsors` VALUES (?,?,?)", array($counter++, $sponsor['Sponsor'], null));
    }
    $CONVERTDB->Free($result);
    //
    // Dump gallery data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting gallery data...\n");
    echo "Converting gallery data...\n";
    flush();
    $DB->Update('DELETE FROM `tx_galleries`');
    $DB->Update('DELETE FROM `tx_gallery_fields`');
    $DB->Update('DELETE FROM `tx_gallery_icons`');
    $DB->Update('DELETE FROM `tx_gallery_previews`');
    $DB->Update('ALTER TABLE `tx_galleries` AUTO_INCREMENT=0');
    $DB->Update('ALTER TABLE `tx_gallery_previews` AUTO_INCREMENT=0');
    $result = $CONVERTDB->Query('SELECT * FROM `ags_Galleries` ORDER BY `Gallery_ID`');
    $preview_sizes = array();
    while ($gallery = $CONVERTDB->NextRow($result)) {
        $DB->Update("INSERT INTO `tx_galleries` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", array(null, $gallery['Gallery_URL'], $gallery['Description'], $gallery['Keywords'], $gallery['Thumbnails'], $gallery['Email'], $gallery['Nickname'], $gallery['Weight'], $gallery['Clicks'], $gallery['Submit_IP'], $gallery['Gallery_IP'], !empty($gallery['Sponsor']) ? $sponsors[$gallery['Sponsor']] : null, strtolower($gallery['Type']), strtolower($gallery['Format']), strtolower($gallery['Status']), $gallery['Status'] == 'Disabled' ? 'approved' : null, date(DF_DATETIME, TimeWithTz($gallery['Added_Stamp'])), date(DF_DATETIME, TimeWithTz($gallery['Added_Stamp'])), empty($gallery['Approve_Stamp']) ? null : date(DF_DATETIME, TimeWithTz($gallery['Approve_Stamp'])), empty($gallery['Scheduled_Date']) ? null : "{$gallery['Scheduled_Date']} 00:00:00", empty($gallery['Display_Date']) ? null : "{$gallery['Display_Date']} 12:00:00", empty($gallery['Delete_Date']) ? null : "{$gallery['Delete_Date']} 00:00:00", $gallery['Account_ID'], $gallery['Moderator'], $gallery['Comments'], null, $gallery['Has_Recip'], empty($gallery['Thumbnail_URL']) ? 0 : 1, $gallery['Allow_Scan'], $gallery['Allow_Thumb'], $gallery['Times_Selected'], $gallery['Used_Counter'], $gallery['Build_Counter'], null, MIXED_CATEGORY . " " . $categories[$gallery['Category']]));
        $gallery_id = $DB->InsertID();
        $gallery_info = array('gallery_id' => $gallery_id);
        $insert = CreateUserInsert('tx_gallery_fields', $gallery_info);
        $DB->Update('INSERT INTO `tx_gallery_fields` VALUES (' . $insert['bind_list'] . ')', $insert['binds']);
        foreach (explode(',', $gallery['Icons']) as $icon_id) {
            if (isset($icons[$icon_id])) {
                $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($gallery_id, $icons[$icon_id]));
            }
        }
        if (!empty($gallery['Thumbnail_URL'])) {
            $dimensions = '';
            if (!empty($gallery['Thumb_Width']) && !empty($gallery['Thumb_Height'])) {
                $dimensions = "{$gallery['Thumb_Width']}x{$gallery['Thumb_Height']}";
                $preview_sizes[$dimensions] = TRUE;
            }
            $DB->Update('INSERT INTO `tx_gallery_previews` VALUES (?,?,?,?)', array(null, $gallery_id, '', $dimensions));
            $preview_id = $DB->InsertID();
            if (preg_match('~^' . preg_quote($vars['THUMB_URL']) . '~i', $gallery['Thumbnail_URL'])) {
                $gallery['Thumbnail_URL'] = "{$C['preview_url']}/{$preview_id}.jpg";
                $DB->Update('UPDATE `tx_gallery_previews` SET `preview_url`=? WHERE `preview_id`=?', array($gallery['Thumbnail_URL'], $preview_id));
                @rename("{$C['preview_dir']}/t_{$gallery['Gallery_ID']}.jpg", "{$C['preview_dir']}/{$preview_id}.jpg");
            }
        }
    }
    $CONVERTDB->Free($result);
    //
    // Dump partner data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting partner accounts...\n");
    echo "Converting partner accounts...\n";
    flush();
    $DB->Update('DELETE FROM `tx_partners`');
    $DB->Update('DELETE FROM `tx_partner_fields`');
    $DB->Update('DELETE FROM `tx_partner_icons`');
    $DB->Update('DELETE FROM `tx_partner_confirms`');
    $result = $CONVERTDB->Query('SELECT * FROM `ags_Accounts`');
    while ($partner = $CONVERTDB->NextRow($result)) {
        $DB->Update('INSERT INTO `tx_partners` VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array($partner['Account_ID'], sha1($partner['Password']), '', $partner['Email'], null, MYSQL_NOW, $partner['Submitted'] > 0 ? MYSQL_NOW : null, empty($partner['Start_Date']) ? null : "{$partner['Start_Date']} 00:00:00", empty($partner['End_Date']) ? null : "{$partner['End_Date']} 23:59:59", $partner['Allowed'], round($partner['Weight']), null, 0, null, 0, $partner['Submitted'], $partner['Removed'], 'active', null, null, 0, $partner['Check_Recip'] ? 0 : 1, $partner['Auto_Approve'], $partner['Confirm'] ? 0 : 1, $partner['Check_Black'] ? 0 : 1));
        $partner_info = array('username' => $partner['Account_ID']);
        $insert = CreateUserInsert('tx_partner_fields', $partner_info);
        $DB->Update('INSERT INTO `tx_partner_fields` VALUES (' . $insert['bind_list'] . ')', $insert['binds']);
        foreach (explode(',', $partner['Icons']) as $icon_id) {
            if (isset($icons[$icon_id])) {
                $DB->Update('INSERT INTO `tx_partner_icons` VALUES (?,?)', array($partner['Account_ID'], $icons[$icon_id]));
            }
        }
    }
    $CONVERTDB->Free($result);
    // Update the stored thumbnail preview sizes
    $sizes = unserialize(GetValue('preview_sizes'));
    if (!is_array($sizes)) {
        $sizes = array();
    }
    $sizes = array_merge($sizes, array_keys($preview_sizes));
    StoreValue('preview_sizes', serialize(array_unique($sizes)));
    //
    // Dump TGP page data
    FileAppend("{$GLOBALS['BASE_DIR']}/data/convert.log", "Converting TGP pages...\n");
    echo "Converting TGP pages...\n";
    flush();
    $build_order = 1;
    $docroot_url = parse_url($vars['CGI_URL']);
    $DB->Update('DELETE FROM `tx_pages`');
    $DB->Update('ALTER TABLE `tx_pages` AUTO_INCREMENT=0');
    $result = $CONVERTDB->Query('SELECT * FROM `ags_Pages` ORDER BY `Build_Order`');
    while ($page = $CONVERTDB->NextRow($result)) {
        $template = file_get_contents("{$_REQUEST['directory']}/data/html/{$page['Page_ID']}");
        $template = ConvertTemplate($template);
        $compiled = '';
        $DB->Update('INSERT INTO `tx_pages` VALUES (?,?,?,?,?,?,?,?,?)', array(null, "{$vars['DOCUMENT_ROOT']}/{$page['Filename']}", "http://{$docroot_url['host']}/{$page['Filename']}", $page['Category'] == 'Mixed' ? null : $category_ids[$page['Category']], $build_order++, 0, 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>";
    }
}
示例#9
0
function ProcessLink(&$link, &$scan_result, $exception)
{
    global $configuration, $exceptions, $penalties, $DB, $config_id;
    $deleted = FALSE;
    $message = '';
    $penalty = 0x0;
    $reasons = array('connect' => "Connection Error: {$scan_result['site_url']['error']}", 'forward' => "Redirecting URL: {$scan_result['site_url']['status']}", 'broken' => "Broken URL: {$scan_result['site_url']['status']}", 'blacklist' => "Blacklisted Data: " . htmlspecialchars($scan_result['blacklist_item']), 'norecip' => "No Reciprocal Link Found");
    // Determine the most strict penalty based on the infractions that were found
    foreach ($exceptions as $key => $value) {
        if ($exception & $value && $configuration['action_' . $key] >= $penalty) {
            $message = $reasons[$key];
            $penalty = intval($configuration['action_' . $key], 16);
        }
    }
    // Blacklist
    if ($penalty & $penalties['blacklist']) {
        $action = 'Blacklisted';
        $deleted = TRUE;
        AutoBlacklist($link);
        DeleteLink($link['link_id'], TRUE, $link);
    } else {
        if ($penalty & $penalties['delete']) {
            $action = 'Deleted';
            $deleted = TRUE;
            DeleteLink($link['link_id'], TRUE, $link);
        } else {
            if ($penalty & $penalties['disable']) {
                $action = 'Disabled';
                // Don't re-disable a link
                if ($link['status'] != 'disabled') {
                    $DB->Update('UPDATE lx_links SET status=? WHERE link_id=?', array('disabled', $link['link_id']));
                    // Update category link count
                    $result = $DB->Query('SELECT category_id FROM lx_links JOIN lx_link_cats USING (link_id) WHERE lx_links.link_id=?', array($link['link_id']));
                    while ($category = $DB->NextRow($result)) {
                        UpdateLinkCount($category['category_id']);
                    }
                    $DB->Free($result);
                }
            } else {
                if ($penalty & $penalties['report']) {
                    $action = 'Unchanged';
                } else {
                    // Do nothing
                    return FALSE;
                }
            }
        }
    }
    $DB->Update('INSERT INTO lx_scanner_results VALUES (?,?,?,?,?,?,?)', array($config_id, $link['link_id'], $link['site_url'], $scan_result['site_url']['status'], gmdate(DF_DATETIME, TimeWithTz()), $action, $message));
    return $deleted;
}
示例#10
0
function ProcessGallery(&$gallery, &$scan, &$exception)
{
    global $configuration, $exceptions, $penalties, $DB, $config_id, $history_id;
    $removed = FALSE;
    $message = '';
    $penalty = 0x0;
    $reasons = array('connect' => "Connection error: {$scan['errstr']}", 'forward' => "Redirecting URL: {$scan['status']}", 'broken' => "Broken URL: {$scan['status']}", 'blacklist' => "Blacklisted data: " . htmlspecialchars($scan['blacklist_item']), 'norecip' => "No reciprocal link found", 'no2257' => "No 2257 code found", 'excessivelinks' => "Too many links found on the gallery: {$scan['links']}", 'thumbchange' => "Thumbnail count has changed from {$gallery['thumbnails_old']} to {$scan['thumbnails']}", 'pagechange' => "Page content has changed", 'content_server' => 'The gallery content is not hosted on the same server as the gallery', 'badformat' => 'The gallery format is not allowed in this category');
    // Determine the most strict penalty based on the infractions that were found
    foreach ($exceptions as $key => $value) {
        if ($exception & $value && $configuration['action_' . $key] >= $penalty) {
            $message = $reasons[$key];
            $penalty = intval($configuration['action_' . $key], 16);
        }
    }
    // Blacklist
    if ($penalty & $penalties['blacklist']) {
        $action = 'Blacklisted';
        $removed = TRUE;
        AutoBlacklist($gallery);
        DeleteGallery($gallery['gallery_id'], $gallery);
        // Update history
        $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1,`blacklisted`=`blacklisted`+1 WHERE `history_id`=?', array($history_id));
    } else {
        if ($penalty & $penalties['delete']) {
            $action = 'Deleted';
            $removed = TRUE;
            DeleteGallery($gallery['gallery_id'], $gallery);
            // Update history
            $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1,`deleted`=`deleted`+1 WHERE `history_id`=?', array($history_id));
        } else {
            if ($penalty & $penalties['disable']) {
                $action = 'Disabled';
                // Don't re-disable a gallery
                if ($gallery['status'] != 'disabled') {
                    //$DB->Update('UPDATE `tx_galleries` SET `status`=?,`admin_comments`=? WHERE `gallery_id`=?', array('disabled', $message, $gallery['gallery_id']));
                    $gallery['previous_status'] = $gallery['status'];
                    $gallery['status'] = 'disabled';
                    $gallery['admin_comments'] = $message;
                }
                // Update history
                $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1,`disabled`=`disabled`+1 WHERE `history_id`=?', array($history_id));
            } else {
                if ($penalty & $penalties['report']) {
                    $action = 'Unchanged';
                    // Update history
                    $DB->Update('UPDATE `tx_scanner_history` SET `exceptions`=`exceptions`+1 WHERE `history_id`=?', array($history_id));
                } else {
                    // Do nothing
                    $exception = 0x0;
                    return $removed;
                }
            }
        }
    }
    $DB->Update('INSERT INTO `tx_scanner_results` VALUES (?,?,?,?,?,?,?)', array($config_id, $gallery['gallery_id'], $gallery['gallery_url'], $scan['status'], gmdate(DF_DATETIME, TimeWithTz()), $action, $message));
    return $removed;
}
示例#11
0
function DailyPartnerMaintenance()
{
    global $DB, $C;
    $args = ParseCommandLine();
    // Remove inactive partner accounts
    if (isset($args['remove-inactive']) && is_numeric($args['remove-inactive'])) {
        $min_last_submit = gmdate(DF_DATETIME, TimeWithTz() - $args['remove-inactive'] * 86400);
        $result = $DB->Query('SELECT * FROM `tx_partners` WHERE `date_last_submit` <= ? OR (`date_last_submit` IS NULL AND `date_added` <= ?)', array($min_last_submit, $min_last_submit));
        while ($partner = $DB->NextRow($result)) {
            DeletePartner($partner['username'], $partner);
        }
        $DB->Free($result);
    }
    // Send an e-mail message to partner accounts that are inactive
    if (isset($args['email-inactive']) && is_numeric($args['email-inactive'])) {
        // Prepare the template
        $t = new Template();
        $t->assign_by_ref('config', $C);
        $t->assign('inactive', $args['email-inactive']);
        // Determine the time range to select
        $start = gmdate(DF_DATE, strtotime('-' . $args['email-inactive'] . ' day', TimeWithTz())) . ' 00:00:00';
        $end = gmdate(DF_DATE, strtotime('-' . $args['email-inactive'] . ' day', TimeWithTz())) . ' 23:59:59';
        // Find matching partners
        $result = $DB->Query('SELECT * FROM `tx_partners` WHERE `date_last_submit` BETWEEN ? AND ? OR (`date_last_submit` IS NULL AND `date_added` BETWEEN ? AND ?)', array($start, $end, $start, $end));
        while ($partner = $DB->NextRow($result)) {
            $t->assign_by_ref('partner', $partner);
            SendMail($partner['email'], 'email-partner-inactive.tpl', $t);
        }
        $DB->Free($result);
    }
    // Send an e-mail message to partner accounts that are expiring soon
    if (isset($args['email-expiring']) && is_numeric($args['email-expiring'])) {
        // Prepare the template
        $t = new Template();
        $t->assign_by_ref('config', $C);
        // Determine the time range to select
        $start = gmdate(DF_DATE, strtotime('+' . $args['email-expiring'] . ' day', TimeWithTz())) . ' 00:00:00';
        $end = gmdate(DF_DATE, strtotime('+' . $args['email-expiring'] . ' day', TimeWithTz())) . ' 23:59:59';
        // Find matching partners
        $result = $DB->Query('SELECT * FROM `tx_partners` WHERE `date_end` BETWEEN ? AND ?', array($start, $end));
        while ($partner = $DB->NextRow($result)) {
            $partner['date_end'] = strtotime($partner['date_end']);
            $t->assign_by_ref('partner', $partner);
            SendMail($partner['email'], 'email-partner-expiring.tpl', $t);
        }
        $DB->Free($result);
    }
}