Пример #1
0
 public function post_discovery($reftime = Null, $retries = 3)
 {
     $reftime_local = $reftime;
     $article = Null;
     $rc = new ReleaseComments();
     $us = new Users();
     if ($reftime_local === Null) {
         // Fetch local time
         $reftime_local = $this->utc2local();
     }
     // some error checking....
     if (!$this->_can_broadcast) {
         // Broadcasting not possible
         return false;
     }
     // Generate keys if one doesn't exist
     if (!($this->_ssl_prvkey && $this->_ssl_pubkey)) {
         if ($this->keygen(false, true) === false) {
             return false;
         }
     }
     // Get Discovery Private Key
     $prvkey = $this->decompstr($this->_ssl_auto_prvkey);
     if (!$prvkey) {
         // This is a serious problem because the hard-coded discovery
         // key should always decrypt!
         return false;
     }
     printf("Spotnab : Broadcast ...");
     // Fetch some date ranges
     $last_month = date("Y-m-d", strtotime(date("Y-m-d", time()) . " - 30 day"));
     $last_year = date('Y-m-d', strtotime(date("Y-m-d", time()) . " - 365 day"));
     // Header
     $message = ['site' => ['id' => md5($this->_pdo->getSetting('siteseed')), 'users' => $us->getCount()], 'posts' => ['user' => $this->_post_user, 'email' => $this->_post_email, 'group' => $this->_post_group, 'privacy' => $this->_post_privacy, 'public_key' => $this->compstr($this->_ssl_pubkey)], 'comments' => ['past_month' => $rc->getCommentCount($last_month, true), 'past_year' => $rc->getCommentCount($last_year, true), 'total' => $rc->getCommentCount(Null, true)], 'postdate_utc' => $this->local2utc($reftime_local)];
     // DEBUG Post
     //print_r($message);
     //die();
     // Encode Message so it can be posted
     $article = $this->encodePost($message, $reftime_local, false, $prvkey, Null, true, SpotNab::FETCH_DISCOVERY_TYPE, SpotNab::AUTODISCOVER_POST_USER, SpotNab::AUTODISCOVER_POST_EMAIL, SpotNab::AUTODISCOVER_POST_GROUP);
     // DEBUG Post
     //print_r($article);
     //die();
     if ($article === false) {
         echo "Failed.\n";
         return false;
     }
     // Post message
     if ($this->_postArticle($article, $retries)) {
         // Post is good; update database
         //echo "Done.\n";
         return true;
     }
     echo "Failed.\n";
     return false;
 }
<?php

require_once "config.php";
require_once WWW_DIR . "/lib/adminpage.php";
require_once WWW_DIR . "/lib/releasecomments.php";
$page = new AdminPage();
$releases = new ReleaseComments();
$page->title = "Comments List";
$commentcount = $releases->getCommentCount();
$offset = isset($_REQUEST["offset"]) ? $_REQUEST["offset"] : 0;
$page->smarty->assign('pagertotalitems', $commentcount);
$page->smarty->assign('pageroffset', $offset);
$page->smarty->assign('pageritemsperpage', ITEMS_PER_PAGE);
$page->smarty->assign('pagerquerybase', WWW_TOP . "/comments-list.php?offset=");
$pager = $page->smarty->fetch("pager.tpl");
$page->smarty->assign('pager', $pager);
$commentslist = $releases->getCommentsRange($offset, ITEMS_PER_PAGE);
$page->smarty->assign('commentslist', $commentslist);
$page->content = $page->smarty->fetch('comments-list.tpl');
$page->render();