Example #1
0
 function backfillGroup($nntp, $groupArr, $backfillDate = null)
 {
     $db = new DB();
     $binaries = new Binaries();
     $n = $this->n;
     $this->startGroup = microtime(true);
     echo 'Processing ' . $groupArr['name'] . $n;
     $data = $nntp->selectGroup($groupArr['name']);
     if (PEAR::isError($data)) {
         echo "Could not select group (bad name?): {$groupArr['name']}{$n}";
         return;
     }
     if ($backfillDate) {
         $targetpost = $this->daytopost($nntp, $groupArr['name'], dateToDays($backfillDate), TRUE);
     } else {
         $targetpost = $this->daytopost($nntp, $groupArr['name'], $groupArr['backfill_target'], TRUE);
     }
     //get targetpost based on days target
     if ($groupArr['first_record'] == 0 || $groupArr['backfill_target'] == 0) {
         echo "Group " . $groupArr['name'] . " has invalid numbers.  Have you run update on it?  Have you set the backfill days amount?{$n}";
         return;
     }
     echo "Group " . $data["group"] . ": server has " . $data['first'] . " - " . $data['last'] . ", or ~";
     echo (int) (($this->postdate($nntp, $data['last'], FALSE) - $this->postdate($nntp, $data['first'], FALSE)) / 86400);
     echo " days." . $n . "Local first = " . $groupArr['first_record'] . " (";
     echo (int) ((date('U') - $this->postdate($nntp, $groupArr['first_record'], FALSE)) / 86400);
     echo " days).  Backfill target of " . $groupArr['backfill_target'] . "days is post {$targetpost}.{$n}";
     if ($targetpost >= $groupArr['first_record']) {
         echo "Nothing to do, we already have the target post.{$n} {$n}";
         return "";
     }
     //get first and last part numbers from newsgroup
     if ($targetpost < $data['first']) {
         echo "WARNING: Backfill came back as before server's first.  Setting targetpost to server first.{$n}";
         echo "Skipping Group {$n}";
         return "";
     }
     //calculate total number of parts
     $total = $groupArr['first_record'] - $targetpost;
     $done = false;
     //set first and last, moving the window by maxxMssgs
     $last = $groupArr['first_record'] - 1;
     $first = $last - $binaries->messagebuffer + 1;
     //set initial "chunk"
     if ($targetpost > $first) {
         //just in case this is the last chunk we needed
         $first = $targetpost;
     }
     while ($done === false) {
         $binaries->startLoop = microtime(true);
         echo "Getting " . ($last - $first + 1) . " parts (" . ($first - $targetpost) . " in queue)" . $n;
         flush();
         $binaries->scan($nntp, $groupArr, $first, $last, 'backfill');
         $db->query(sprintf("UPDATE groups SET first_record = %s, last_updated = now() WHERE ID = %d", $db->escapeString($first), $groupArr['ID']));
         if ($first == $targetpost) {
             $done = true;
         } else {
             //Keep going: set new last, new first, check for last chunk.
             $last = $first - 1;
             $first = $last - $binaries->messagebuffer + 1;
             if ($targetpost > $first) {
                 $first = $targetpost;
             }
         }
     }
     $first_record_postdate = $this->postdate($nntp, $first, false);
     $db->query(sprintf("UPDATE groups SET first_record_postdate = FROM_UNIXTIME(" . $first_record_postdate . "), last_updated = now() WHERE ID = %d", $groupArr['ID']));
     //Set group's first postdate
     $timeGroup = number_format(microtime(true) - $this->startGroup, 2);
     echo "Group processed in {$timeGroup} seconds {$n}";
 }
Example #2
0
function getUploadedData()
{
    global $db, $prefix, $user_prefix, $moduleName, $admin_file;
    echo '<div id="manage-upload-container">';
    echo '<table id="gal-manage-uploads">' . PHP_EOL;
    echo '	<tr>' . PHP_EOL;
    echo '		<th id="th-pic">Picture</th>' . PHP_EOL;
    echo '		<th id="th-album">Album</th>' . PHP_EOL;
    echo '		<th id="th-date">Date</th>' . PHP_EOL;
    echo '		<th id="th-posted">Posted by</th>' . PHP_EOL;
    echo '	</tr>' . PHP_EOL;
    $count = 0;
    $result = $db->sql_query('SELECT * FROM ' . $prefix . '_igallery_temp ORDER BY picture_date,album_id ASC LIMIT 50 ;');
    while ($temp = $db->sql_fetchrow($result)) {
        $count++;
        $pictureId = intval($temp['picture_id']);
        $albumId = intval($temp['album_id']);
        $pictureTitle = $temp['picture_title'];
        $pictureFile = $temp['picture_file'];
        $pictureDate = intval($temp['picture_date']);
        $pictureUser = intval($temp['picture_userid']);
        $album = $db->sql_fetchrow($db->sql_query('SELECT album_title FROM ' . $prefix . '_igallery_albums WHERE album_id=\'' . $albumId . '\' LIMIT 1 ;'));
        $user = $db->sql_fetchrow($db->sql_query('SELECT username FROM ' . $user_prefix . '_users WHERE user_id=\'' . $pictureUser . '\' LIMIT 1 ;'));
        $viewImage = $admin_file . '.php?op=galPreviewUploaded&amp;file=' . $pictureFile;
        echo '	<tr>' . PHP_EOL;
        echo '		<td><input type="checkbox" name="tempId[]" value="' . $pictureId . '" />&nbsp;&nbsp;<a href="' . $viewImage . '" class="colorbox" target="_blank">' . $pictureTitle . '</a></td>' . PHP_EOL;
        echo '		<td><a href="modules.php?name=' . $moduleName . '&amp;op=showAlbum&amp;albumid=' . $albumId . '">' . $album['album_title'] . '</a></td>' . PHP_EOL;
        echo '		<td>' . dateToDays($pictureDate) . '</td>' . PHP_EOL;
        echo '		<td><a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username=' . $user['username'] . '">' . $user['username'] . '</a></td>' . PHP_EOL;
        echo '	</tr>' . PHP_EOL;
    }
    if ($count === 0) {
        echo '	<tr>' . PHP_EOL;
        echo '		<td colspan="4"><b>' . _IG_ADM_CURRENTLY_NO_QUEUE . '</b></td>' . PHP_EOL;
        echo '	</tr>' . PHP_EOL;
    }
    echo '</table>' . PHP_EOL;
    echo '</div>' . PHP_EOL;
}
Example #3
0
function galManageComments()
{
    global $db, $prefix, $user_prefix, $iConfig, $moduleName, $admin_file;
    $deleted = isset($_GET['deleted']) ? intval($_GET['deleted']) : 0;
    $updated = isset($_GET['updated']) ? intval($_GET['updated']) : 0;
    $inlineJS = '<script type="text/javascript">
			$(document).ready(function() {
				$(\'.ask\').click(function(e) {
					e.preventDefault();
					thisHref	= $(this).attr(\'href\');
					if($(this).next(\'div.question\').length <= 0)
						$(this).after(\'<div class="question">' . _IG_ADM_ARE_YOU_SURE . '<br/> <span class="yes">' . _YES . '</span><span class="cancel">' . _NO . '</span></div>\');
					$(\'.question\').animate({opacity: 1}, 300);
					$(\'.yes\').live(\'click\', function(){
						window.location = thisHref + \'confirm=1\';
					});
					$(\'.cancel\').live(\'click\', function(){
						$(this).parents(\'div.question\').fadeOut(300, function() {
							$(this).remove();
						});
					});
				});
			});
</script>';
    AddJSToHead('includes/jquery/jquery.js', 'file');
    AddJSToHead($inlineJS, 'inline');
    include 'header.php';
    galAdminMenu();
    if ($deleted == 1) {
        echo '<div class="warning">' . _IG_ADM_COMMENT_DELETED . '</div>' . PHP_EOL;
    } elseif ($deleted == 2) {
        echo '<div class="warning">' . _IG_ADM_COMMENT_DELETED_ERROR . '</div>' . PHP_EOL;
    }
    if ($updated == 1) {
        echo '<div class="warning">' . _IG_ADM_COMMENT_UPDATED . '</div>' . PHP_EOL;
    } elseif ($updated == 2) {
        echo '<div class="warning">' . _IG_ADM_COMMENT_UPDATED_ERROR . '</div>' . PHP_EOL;
    }
    echo '<div id="show-comments">' . PHP_EOL;
    echo '	<h2>' . _IG_ADM_MANAGECOMMENTS . '</h2>' . PHP_EOL;
    $result = $db->sql_query('SELECT * FROM ' . $prefix . '_igallery_comments ORDER BY comment_date DESC ;');
    while ($comment = $db->sql_fetchrow($result)) {
        $commentId = intval($comment['comment_id']);
        $userId = intval($comment['comment_userid']);
        $message = nl2br($comment['comment_data']);
        $date = $comment['comment_date'];
        $pictureId = $comment['comment_pictureid'];
        $usrInfo = $db->sql_fetchrow($db->sql_query('SELECT username, user_avatar FROM ' . $user_prefix . '_users WHERE user_id=' . $userId . ' LIMIT 1'));
        $posterName = $usrInfo['username'];
        $posterAvatar = $usrInfo['user_avatar'];
        $posterLink = 'modules.php?name=Your_Account&amp;op=userinfo&amp;username=' . $posterName . '';
        $thumbSrc = 'modules.php?name=' . $moduleName . '&amp;op=getThumb&amp;pictureid=' . $pictureId;
        if (!empty($posterAvatar) && !eregi('blank.gif', $posterAvatar)) {
            if (eregi('http://', $posterAvatar)) {
                $src = $posterAvatar;
            } else {
                $src = 'modules/Forums/images/avatars/' . $posterAvatar;
            }
        } else {
            $src = 'modules/' . $moduleName . '/images/no_avatar.png';
        }
        echo '<div class="comment-box">' . PHP_EOL;
        echo '<table style="width:100%;">' . PHP_EOL;
        echo '	<tr>' . PHP_EOL;
        echo '		<td class="show-comment-image">' . PHP_EOL;
        echo '			<a href="modules.php?name=' . $moduleName . '&amp;op=showPic&amp;pictureid=' . $pictureId . '"><img src="' . $thumbSrc . '" title="" alt="" /></a>' . PHP_EOL;
        echo '		</td>' . PHP_EOL;
        echo '		<td class="show-comment-info">' . PHP_EOL;
        echo '			<a href="' . $posterLink . '"><img class="comment-avatar" src="' . $src . '" alt="' . $posterName . '" title="' . $posterName . '" /></a>' . PHP_EOL;
        echo '			<span class="comment-poster"><a href="modules.php?name=Your_Account&amp;op=userinfo&amp;username=' . $posterName . '">' . $posterName . '</a></span>' . PHP_EOL;
        echo '			<span class="comment-date">' . dateToDays($date) . '</span>' . PHP_EOL;
        echo '			<span class="comment-admin">' . PHP_EOL;
        echo '				<a href="' . $admin_file . '.php?op=galDeleteComment&amp;id=' . $commentId . '&amp;" class="ask"><img class="icon-small" src="modules/' . $moduleName . '/images/edit-delete.png" title="' . _IG_ADM_DELETE_COMMENT . '" alt="" /></a>' . PHP_EOL;
        echo '				<a href="' . $admin_file . '.php?op=galEditComment&amp;id=' . $commentId . '"><img class="icon-small" src="modules/' . $moduleName . '/images/format-justify-fill.png" title="' . _IG_ADM_EDIT_COMMENT . '" alt="" /></a>' . PHP_EOL;
        echo '				<a href="modules.php?name=' . $moduleName . '&amp;op=showPic&amp;pictureid=' . $pictureId . '#show-comments"><img class="icon-small" src="modules/' . $moduleName . '/images/internet-group-chat.png" title="' . _IG_ADM_VIEW_COMMENT_THREAD . '" alt="" /></a>' . PHP_EOL;
        echo '			</span>' . PHP_EOL;
        echo '			<div class="comment">' . $message . '</div>' . PHP_EOL;
        echo '		</td>' . PHP_EOL;
        echo '	</tr>' . PHP_EOL;
        echo '</table>' . PHP_EOL;
        echo '</div>' . PHP_EOL;
    }
    echo '</div>' . PHP_EOL;
    CloseTable();
    include 'footer.php';
}