Example #1
0
 public function indexAction()
 {
     $this->view->Title = "Quản lý nhóm thành viên";
     $this->view->headTitle($this->view->Title);
     //Assign create form
     $condition = array();
     if ($this->getRequest()->getParam('keyword')) {
         $condition['name LIKE ?'] = "%{$this->getRequest()->getParam('keyword')}%";
     }
     $this->view->Group = Groups::getAll($condition);
 }
Example #2
0
    public function buildGroupTable()
    {
        if (!defined('SHOW_RPG') || SHOW_RPG != 'checked') {
            return;
        }
        print '<div class="row-fluid">
				<div class="box span12">
					<div class="box-header well" data-original-title>
						<h2><i class="icon-th"></i> Releases per Group</h2>
						<div class="box-icon">

							<a href="#" class="btn btn-minimize btn-round"><i class="icon-chevron-up"></i></a>
													</div>
					</div>
					<div class="box-content">';
        echo '<table class="table table-striped table-bordered bootstrap-datatable datatable">
							  <thead>
								  <tr>
									  <th>Group</th>
									  <th>Releases</th>
								  </tr>
							  </thead>
							  <tbody>';
        $group = new Groups();
        # get all the groups
        $allgroups = $group->getAll();
        $pdo = new Settings();
        foreach ($allgroups as $group) {
            $sql = sprintf("select count(id) as num from releases where groupid = %s", $group['id']);
            $res = $pdo->queryOneRow($sql);
            if ($res["num"] > 0) {
                echo '<tr>';
                echo '<td>';
                echo $group['name'];
                echo '</td>';
                echo '<td class="right">';
                echo $res["num"];
                echo '</td>';
                echo '</tr>';
            }
        }
        echo '</tbody>
						 </table>  ';
        print '</div></div></div>';
    }
Example #3
0
<?php

require_once WWW_DIR . "/lib/groups.php";
$groups = new Groups();
if (!$users->isLoggedIn()) {
    $page->show403();
}
$grouplist = $groups->getAll();
$page->smarty->assign('results', $grouplist);
$page->meta_title = "Browse Groups";
$page->meta_keywords = "browse,groups,description,details";
$page->meta_description = "Browse groups";
$page->content = $page->smarty->fetch('browsegroup.tpl');
$page->render();
 public function fetchTestBinaries($groupname, $numarticles, $clearexistingbins)
 {
     $db = new DB();
     $nntp = new Nntp();
     $binaries = new Binaries();
     $groups = new Groups();
     $ret = array();
     if ($clearexistingbins == true) {
         $db->exec('truncate releaseregextesting');
     }
     $nntp->doConnect();
     $groupsToFetch = array();
     if (preg_match('/^[a-z]{2,3}(\\.[a-z0-9\\-]+)+$/', $groupname)) {
         $groupsToFetch[] = array('name' => $groupname);
     } elseif ($groupname === 0) {
         $groupsToFetch = $groups->getAll();
     } else {
         $newsgroups = $nntp->getGroups();
         foreach ($newsgroups as $ngroup) {
             if (preg_match('/' . $groupname . '/', $ngroup['group'])) {
                 $groupsToFetch[] = array('name' => $ngroup['group']);
             }
         }
     }
     foreach ($groupsToFetch as $groupArr) {
         $group = $groupArr['name'];
         $data = $nntp->selectGroup($group);
         if ($nntp->isError($data)) {
             $ret[] = "Could not select group (doesnt exist on USP): {$group}";
             continue;
         } else {
             $rangeStart = $data['last'] - $numarticles;
             $rangeEnd = $groupEnd = $data['last'];
             $rangeTotal = $rangeEnd - $rangeStart;
             $done = false;
             while ($done === false) {
                 if ($rangeTotal > $binaries->messagebuffer) {
                     if ($rangeStart + $binaries->messagebuffer > $groupEnd) {
                         $rangeEnd = $groupEnd;
                     } else {
                         $rangeEnd = $rangeStart + $binaries->messagebuffer;
                     }
                 }
                 if ($binaries->compressedHeaders) {
                     $msgs = $nntp->getXOverview($rangeStart . "-" . $rangeEnd, true, false);
                 } else {
                     $msgs = $nntp->getOverview($rangeStart . "-" . $rangeEnd, true, false);
                 }
                 if ($nntp->isError($msgs)) {
                     $ret[] = "Error {$msgs->code}: {$msgs->message} on " . $group;
                     continue 2;
                 }
                 $headers = array();
                 if (is_array($msgs)) {
                     //loop headers, figure out parts
                     foreach ($msgs as $msg) {
                         if (!isset($msg['Number'])) {
                             continue;
                         }
                         $msgPart = $msgTotalParts = 0;
                         $pattern = '|\\((\\d+)[\\/](\\d+)\\)|i';
                         preg_match_all($pattern, $msg['Subject'], $matches, PREG_PATTERN_ORDER);
                         $matchcnt = sizeof($matches[0]);
                         for ($i = 0; $i < $matchcnt; $i++) {
                             //not (int)'d here because of the preg_replace later on
                             $msgPart = $matches[1][$i];
                             $msgTotalParts = $matches[2][$i];
                         }
                         if (!isset($msg['Subject']) || $matchcnt == 0) {
                             // not a binary post most likely.. continue
                             continue;
                         }
                         if ((int) $msgPart > 0 && (int) $msgTotalParts > 0) {
                             $subject = utf8_encode(trim(preg_replace('|\\(' . $msgPart . '[\\/]' . $msgTotalParts . '\\)|i', '', $msg['Subject'])));
                             if (!isset($headers[$subject])) {
                                 $headers[$subject]['Subject'] = $subject;
                                 $headers[$subject]['From'] = $msg['From'];
                                 $headers[$subject]['Date'] = strtotime($msg['Date']);
                                 $headers[$subject]['Message-ID'] = $msg['Message-ID'];
                                 $headers[$subject]['Size'] = $msg['Bytes'];
                             } else {
                                 $headers[$subject]['Size'] += $msg['Bytes'];
                             }
                         }
                     }
                     unset($msgs);
                     if (isset($headers) && count($headers)) {
                         $groupRegexes = $this->getForGroup($group);
                         $binSetData = array();
                         foreach ($headers as $subject => $data) {
                             $binData = array('name' => $subject, 'fromname' => $data['From'], 'date' => $data['Date'], 'binaryhash' => md5($subject . $data['From'] . $group), 'groupname' => $group, 'regexID' => "null", 'categoryID' => "null", 'reqID' => "null", 'blacklistID' => 0, 'size' => $data['Size'], 'relname' => "null", 'relpart' => "null", 'reltotalpart' => "null");
                             //Filter binaries based on black/white list
                             if ($binaries->isBlackListed($data, $group)) {
                                 //binary is blacklisted
                                 $binData['blacklistID'] = 1;
                             }
                             //Apply Regexes
                             $regexMatches = array();
                             foreach ($groupRegexes as $groupRegex) {
                                 $regexCheck = $this->performMatch($groupRegex, $subject, $data['From']);
                                 if ($regexCheck !== false) {
                                     $regexMatches = $regexCheck;
                                     $binData['regexID'] = $regexCheck['regexID'];
                                     $binData['categoryID'] = $regexCheck['regcatid'];
                                     $binData['reqID'] = empty($regexCheck['reqID']) ? "null" : $regexCheck['reqID'];
                                     $binData['relname'] = $regexCheck['name'];
                                     break;
                                 }
                             }
                             $binSetData[] = $binData;
                         }
                         //insert 500 bins at a time
                         $binChunks = array_chunk($binSetData, 500);
                         foreach ($binChunks as $binChunk) {
                             foreach ($binChunk as $chunk) {
                                 $binParams[] = sprintf("(%s, %s, FROM_UNIXTIME(%s), %s, %s, %s, %s, %s, %d, %d, now())", $db->escapeString($chunk['name']), $db->escapeString($chunk['fromname']), $db->escapeString($chunk['date']), $db->escapeString($chunk['binaryhash']), $db->escapeString($chunk['groupname']), $chunk['regexID'], $chunk['categoryID'], $chunk['reqID'], $chunk['blacklistID'], $chunk['size']);
                             }
                             $binSql = "INSERT IGNORE INTO releaseregextesting (name, fromname, date, binaryhash, groupname, regexID, categoryID, reqID, blacklistID, size, dateadded) VALUES " . implode(', ', $binParams);
                             //echo $binSql;
                             $db->exec($binSql);
                         }
                         $ret[] = "Fetched " . number_format($numarticles) . " articles from " . $group;
                     } else {
                         $ret[] = "No headers found on " . $group;
                         continue;
                     }
                 } else {
                     $ret[] = "Can't get parts from server (msgs not array) on " . $group;
                     continue;
                 }
                 if ($rangeEnd == $groupEnd) {
                     $done = true;
                 }
                 $rangeStart = $rangeEnd + 1;
             }
         }
     }
     $nntp->doQuit();
     return $ret;
 }
require_once "config.php";
require_once WWW_DIR . "/lib/adminpage.php";
require_once WWW_DIR . "/lib/releaseregex.php";
require_once WWW_DIR . "/lib/groups.php";
require_once WWW_DIR . "/lib/category.php";
require_once WWW_DIR . "/lib/nntp.php";
$page = new AdminPage();
$reg = new ReleaseRegex();
$groups = new Groups();
$cat = new Category();
$id = 0;
// set the current action
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
$numarticlesdefault = 20000;
$groupList = $groups->getAll();
array_unshift($groupList, array('ID' => 0, 'name' => 'All Groups'));
$gid = $gnames = array();
$groupname = isset($_REQUEST['groupname']) && !empty($_REQUEST['groupname']) ? $_REQUEST['groupname'] : '';
$groupID = isset($_REQUEST['groupID']) ? $_REQUEST['groupID'] : '0';
$regex = isset($_REQUEST['regex']) && !empty($_REQUEST['regex']) ? $_REQUEST['regex'] : '/^(?P<name>.*)$/i';
$poster = isset($_REQUEST['poster']) && !empty($_REQUEST['poster']) ? $_REQUEST['poster'] : '';
$unreleased = isset($_REQUEST['unreleased']) ? $_REQUEST['unreleased'] : '';
$matchagainstbins = isset($_REQUEST['matchagainstbins']) ? $_REQUEST['matchagainstbins'] : '';
$numarticles = isset($_REQUEST['numarticles']) && !empty($_REQUEST['numarticles']) ? $_REQUEST['numarticles'] : $numarticlesdefault;
$clearexistingbins = isset($_REQUEST['clearexistingbins']) ? true : false;
foreach ($groupList as $grp) {
    $gid[$grp["ID"]] = $grp["ID"];
    $gnames[$grp["ID"]] = $grp["name"];
}
$group = $groupname;
 /**
  * List groups
  *
  * @access public
  * @param void
  * @return null
  */
 function groups()
 {
     if (!logged_user()->isCompanyAdmin(owner_company())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     tpl_assign('groups', Groups::getAll());
 }
<?php

require_once WWW_DIR . "/lib/groups.php";
$groups = new Groups();
if (!$users->isLoggedIn()) {
    $page->show403();
}
$ordering = array('updated_desc', 'updated_asc', 'name_desc', 'name_asc', 'releases_desc', 'releases_asc', 'description_desc', 'description_asc');
foreach ($ordering as $ordertype) {
    $page->smarty->assign('orderby' . $ordertype, WWW_TOP . "/browsegroup?ob=" . $ordertype);
}
$orderby = isset($_REQUEST["ob"]) && in_array($_REQUEST['ob'], $ordering) ? $_REQUEST["ob"] : '';
$grouplist = $groups->getAll($orderby);
$page->smarty->assign('results', $grouplist);
$page->meta_title = "Browse Groups";
$page->meta_keywords = "browse,groups,description,details";
$page->meta_description = "Browse groups";
$page->content = $page->smarty->fetch('browsegroup.tpl');
$page->render();