コード例 #1
0
ファイル: submit.php プロジェクト: Cyberspace-Networks/TGPX
function txConfirm()
{
    global $DB, $L, $C, $t, $domain;
    // Delete old confirmations
    $DB->Update('DELETE FROM `tx_gallery_confirms` WHERE `date_sent` < ?', array(gmdate(DF_DATETIME, TIME_NOW - 86400)));
    $confirmation = $DB->Row('SELECT * FROM `tx_gallery_confirms` WHERE `confirm_id`=?', array($_REQUEST['id']));
    if ($confirmation) {
        $gallery = $DB->Row('SELECT * FROM `tx_galleries` WHERE `gallery_id`=?', array($confirmation['gallery_id']));
        if ($gallery) {
            // Defaults
            $gallery['status'] = 'pending';
            $gallery['date_approved'] = null;
            $gallery['administrator'] = null;
            // Load gallery information to determine how to process the gallery
            $whitelisted = CheckWhitelist($gallery);
            if ($gallery['partner']) {
                $partner = $DB->Row('SELECT * FROM `tx_partners` WHERE `username`=?', array($gallery['partner']));
            }
            $whitelisted = MergeWhitelistOptions($whitelisted, $partner);
            // Determine if gallery should be auto-approved
            $autoapprove_general = empty($partner) && ($C['allow_autoapprove'] || $whitelisted['allow_autoapprove']);
            $autoapprove_partner = !empty($partner) && $whitelisted['allow_autoapprove'];
            if ($autoapprove_general || $autoapprove_partner) {
                $gallery['status'] = 'approved';
                $gallery['date_approved'] = MYSQL_NOW;
                $gallery['administrator'] = 'AUTO';
            }
            // Update gallery data
            $DB->Update('UPDATE `tx_galleries` SET `status`=?,`date_approved`=?,`administrator`=? WHERE `gallery_id`=?', array($gallery['status'], $gallery['date_approved'], $gallery['administrator'], $gallery['gallery_id']));
            // Remove the confirmation code
            $DB->Update('DELETE FROM `tx_gallery_confirms` WHERE `confirm_id`=?', array($confirmation['confirm_id']));
            // Get category
            $categories = CategoriesFromTags($gallery['categories']);
            $gallery['category'] = $categories[0]['name'];
            // Get preview URL (if any)
            $gallery['preview_url'] = $DB->Count('SELECT `preview_url` FROM `tx_gallery_previews` WHERE `gallery_id`=?', array($gallery['gallery_id']));
            $fields =& GetUserGalleryFields($gallery);
            $t->assign('confirmed', true);
            $t->assign_by_ref('gallery', $gallery);
            $t->assign_by_ref('user_fields', $fields);
            $t->display($domain['template_prefix'] . 'submit-complete.tpl');
        } else {
            $t->assign('error', $L['BAD_GALLERY_ID']);
            $t->display($domain['template_prefix'] . 'error-nice.tpl');
        }
    } else {
        $t->assign('error', $L['INVALID_CONFIRMATION']);
        $t->display($domain['template_prefix'] . 'error-nice.tpl');
    }
}
コード例 #2
0
ファイル: ajax.php プロジェクト: Cyberspace-Networks/TGPX
function txGalleryIPE()
{
    global $DB, $C;
    VerifyPrivileges(P_GALLERY_MODIFY, TRUE);
    // Format output
    $update = TRUE;
    $output = $_REQUEST['value'];
    switch ($_REQUEST['update']) {
        case 'date_scheduled':
        case 'date_deletion':
        case 'date_displayed':
            NullIfEmpty($_REQUEST['value']);
            $update = preg_match(RE_DATETIME, $_REQUEST['value']) || empty($_REQUEST['value']);
            $output = empty($_REQUEST['value']) ? '-' : date(DF_SHORT, strtotime($_REQUEST['value']));
            break;
        case 'status':
            $output = ucfirst($_REQUEST['value']);
            if ($_REQUEST['value'] == 'approved') {
                $_REQUEST['update'] = array('status', 'date_approved');
                $_REQUEST['value'] = array($_REQUEST['value'], MYSQL_NOW);
            }
            break;
        case 'type':
        case 'format':
            $output = ucfirst($_REQUEST['value']);
            break;
        case 'weight':
        case 'clicks':
        case 'thumbnails':
            $update = is_numeric($_REQUEST['value']);
            $output = number_format($_REQUEST['value'], 0, $C['dec_point'], $C['thousands_sep']);
            break;
        case 'description':
        case 'keywords':
        case 'tags':
            $output = StringChopTooltip(htmlspecialchars($_REQUEST['value']), 90);
            break;
        case 'gallery_url':
            $output = StringChopTooltip(htmlspecialchars($_REQUEST['value']), 100, true);
            break;
        case 'nickname':
        case 'email':
            $output = StringChopTooltip(htmlspecialchars($_REQUEST['value']), 40);
            break;
        case 'sponsor_id':
            NullIfEmpty($_REQUEST['value']);
            if ($_REQUEST['value'] == null) {
                $output = '';
            } else {
                $output = $DB->Count('SELECT `name` FROM `tx_sponsors` WHERE `sponsor_id`=?', array($_REQUEST['value']));
            }
            break;
        case 'categories':
            $_REQUEST['value'] = CategoryTagsFromIds(explode(',', $_REQUEST['value']));
            $categories =& CategoriesFromTags($_REQUEST['value']);
            $names = array();
            foreach ($categories as $category) {
                $names[] = $category['name'];
            }
            $output = StringChopTooltip(htmlspecialchars(join(', ', $names)), 90);
            break;
        case 'icons':
            if (isset($_REQUEST['multi'])) {
                $result = GetWhichGalleries();
                while ($gallery = $DB->NextRow($result)) {
                    $DB->Update('DELETE FROM `tx_gallery_icons` WHERE `gallery_id`=?', array($gallery['gallery_id']));
                    foreach (explode(',', $_REQUEST['value']) as $icon_id) {
                        $icon_id = trim($icon_id);
                        if (is_numeric($icon_id)) {
                            $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($gallery['gallery_id'], $icon_id));
                        }
                    }
                }
                $DB->Free($result);
            } else {
                $DB->Update('DELETE FROM `tx_gallery_icons` WHERE `gallery_id`=?', array($_REQUEST['gallery_id']));
                foreach (explode(',', $_REQUEST['value']) as $icon_id) {
                    $icon_id = trim($icon_id);
                    if (is_numeric($icon_id)) {
                        $DB->Update('INSERT INTO `tx_gallery_icons` VALUES (?,?)', array($_REQUEST['gallery_id'], $icon_id));
                    }
                }
            }
            echo '<img src="images/icons.png" alt="Icons" title="Icons" class="click-image function">';
            return;
            break;
    }
    if ($update) {
        $update = new UpdateBuilder('tx_galleries');
        if (is_array($_REQUEST['update'])) {
            foreach ($_REQUEST['update'] as $index => $field) {
                $update->AddSet($_REQUEST['update'][$index], $_REQUEST['value'][$index]);
            }
        } else {
            $update->AddSet($_REQUEST['update'], $_REQUEST['value']);
        }
        if (isset($_REQUEST['multi'])) {
            $update = GetWhichGalleries($update);
        } else {
            $update->AddWhere('gallery_id', ST_MATCHES, $_REQUEST['gallery_id']);
        }
        $DB->Update($update->Generate(), $update->binds);
    }
    echo $update ? $output : JSON_FAILURE;
}
コード例 #3
0
ファイル: partner.php プロジェクト: Cyberspace-Networks/TGPX
function txShPartnerGalleries()
{
    global $C, $DB, $L, $t, $domain;
    $partner = ValidPartnerLogin();
    if ($partner !== FALSE) {
        $sorters = array('added' => 'date_added', 'approved' => 'date_approved', 'clicks' => 'clicks', 'status' => 'status');
        $directions = array('asc' => 'ASC', 'desc' => 'DESC');
        // Filter user input
        $_REQUEST['p'] = is_numeric($_REQUEST['p']) ? $_REQUEST['p'] : 1;
        $_REQUEST['s'] = isset($sorters[$_REQUEST['s']]) ? $_REQUEST['s'] : 'added';
        $_REQUEST['d'] = isset($directions[$_REQUEST['d']]) ? $_REQUEST['d'] : 'asc';
        // Setup data for the query
        $galleries = array();
        $per_page = 10;
        $page = $_REQUEST['p'];
        $sort = isset($sorters[$_REQUEST['s']]) ? $sorters[$_REQUEST['s']] : 'date_added';
        $direction = isset($directions[$_REQUEST['d']]) ? $directions[$_REQUEST['d']] : 'ASC';
        // Load this partner's galleries
        $result = $DB->QueryWithPagination('SELECT * FROM `tx_galleries` WHERE `partner`=? AND `status`!=? ORDER BY # ' . $direction, array($partner['username'], 'submitting', $sort), $page, $per_page);
        if ($result['result']) {
            while ($gallery = $DB->NextRow($result['result'])) {
                DatetimeToTime($gallery['date_added']);
                DatetimeToTime($gallery['date_approved']);
                DatetimeToTime($gallery['date_scheduled']);
                DatetimeToTime($gallery['date_displayed']);
                // Load a thumbnail for this gallery
                $preview = $DB->Row('SELECT * FROM `tx_gallery_previews` WHERE `gallery_id`=? LIMIT 1', array($gallery['gallery_id']));
                if ($preview) {
                    list($preview['preview_width'], $preview['preview_height']) = explode('x', $preview['dimensions']);
                    $gallery = array_merge($preview, $gallery);
                }
                // Get the categories for this gallery
                $gallery['categories'] =& CategoriesFromTags($gallery['tags']);
                // Get user defined fields
                $fields = $DB->Row('SELECT * FROM `tx_gallery_fields` WHERE `gallery_id`=?', array($gallery['gallery_id']));
                if ($fields) {
                    $fields = array_merge($fields, $gallery);
                }
                $galleries[] = $gallery;
            }
            $DB->Free($result['result']);
        }
        $t->assign('sort', $_REQUEST['s']);
        $t->assign('direction', $_REQUEST['d']);
        $t->assign_by_ref('pagination', $result);
        $t->assign_by_ref('partner', $partner);
        $t->assign_by_ref('galleries', $galleries);
        $t->display($domain['template_prefix'] . 'partner-galleries.tpl');
    }
}
コード例 #4
0
$formats = array('pictures' => 'Pictures', 'movies' => 'Movies');
echo OptionTags($formats, $gallery['format']);
?>
</select>
</td>
</tr>

<tr>
<td align="right" width="80" class="bold" valign="top" style="padding-top: 3px">
Categories
</td>
<td width="425">
<div id="category_selects">
<?php 
$all_categories =& $DB->FetchAll('SELECT * FROM `tx_categories` ORDER BY `name`');
$categories =& CategoriesFromTags($gallery['categories']);
foreach ($categories as $category) {
    ?>
  <div style="margin-bottom: 3px;">
  <select name="categories[]">
  <?php 
    echo OptionTagsAdv($all_categories, $category['category_id'], 'category_id', 'name', 50);
    ?>
  </select>
  <img src="images/add-small.png" onclick="addCategorySelect(this)" class="click-image" alt="Add Category">
  <img src="images/remove-small.png" onclick="removeCategorySelect(this)" class="click-image" alt="Remove Category">
  </div>
<?php 
}
?>
</div>
コード例 #5
0
ファイル: index.php プロジェクト: hackingman/TGPX
function txShGalleryScan()
{
    global $DB, $C;
    // Get gallery information
    $gallery = $DB->Row('SELECT * FROM `tx_galleries` WHERE `gallery_id`=?', array($_REQUEST['gallery_id']));
    $partner = null;
    if ($gallery['partner']) {
        $partner = $DB->Row('SELECT * FROM `tx_partners` WHERE `username`=?', array($gallery['partner']));
    }
    $categories =& CategoriesFromTags($gallery['categories']);
    $whitelisted = MergeWhitelistOptions(CheckWhitelist($gallery), $partner);
    // Scan the gallery
    $scan =& ScanGallery($gallery, $categories[0], $whitelisted);
    if ($scan['success']) {
        // Check the blacklist
        $gallery['html'] = $scan['html'];
        $gallery['headers'] = $scan['headers'];
        $blacklisted = CheckBlacklistGallery($gallery, TRUE);
        // See if category allows this format
        $scan['bad_format'] = FALSE;
        $format = GetCategoryFormat($scan['format'], $categories[0]);
        if (!$format['allowed']) {
            $scan['bad_format'] = TRUE;
        }
        // Update gallery data
        $DB->Update('UPDATE `tx_galleries` SET ' . '`date_scanned`=?, ' . '`page_hash`=?, ' . '`format`=?, ' . '`gallery_ip`=?, ' . '`thumbnails`=?, ' . '`has_recip`=? ' . 'WHERE `gallery_id`=?', array(MYSQL_NOW, $scan['page_hash'], $scan['format'], $scan['gallery_ip'], $scan['thumbnails'], $scan['has_recip'], $gallery['gallery_id']));
    }
    ArrayHSC($scan);
    // Display the results
    include_once 'includes/galleries-quickscan.php';
}