/**
  * Constructor creates the necessary variables needed later on.
  *
  * @ignore
  * @access private
  */
 function __construct()
 {
     $s = new Sites();
     $this->site = $s->get();
     $this->nzb = new Nzb();
     $this->indexes = array("releases", "releasefiles", "releasenfo", "nzbs", "predb");
 }
Example #2
0
 function PostProcess($echooutput = false)
 {
     $this->echooutput = $echooutput;
     $s = new Sites();
     $this->site = $s->get();
     $this->mediafileregex = 'AVI|VOB|MKV|MP4|TS|WMV|MOV|M4V|F4V|MPG|MPEG';
 }
Example #3
0
 function Movie($echooutput = false)
 {
     $this->echooutput = $echooutput;
     $s = new Sites();
     $site = $s->get();
     $this->apikey = $site->tmdbkey;
     $this->imgSavePath = WWW_DIR . 'covers/movies/';
 }
Example #4
0
 function BasePage()
 {
     @session_start();
     if (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) {
         foreach ($_GET as $k => $v) {
             $_GET[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_POST as $k => $v) {
             $_POST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_REQUEST as $k => $v) {
             $_REQUEST[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
         foreach ($_COOKIE as $k => $v) {
             $_COOKIE[$k] = is_array($v) ? array_map("stripslashes", $v) : stripslashes($v);
         }
     }
     // set site variable
     $s = new Sites();
     $this->site = $s->get();
     $this->smarty = new Smarty();
     $this->smarty->template_dir = WWW_DIR . 'views/templates/' . $this->template_dir;
     $this->smarty->compile_dir = SMARTY_DIR . 'templates_c/';
     $this->smarty->config_dir = SMARTY_DIR . 'configs/';
     $this->smarty->cache_dir = SMARTY_DIR . 'cache/';
     $this->smarty->error_reporting = E_ALL - E_NOTICE;
     $this->smarty->assign('site', $this->site);
     $this->smarty->assign('page', $this);
     if (isset($_SERVER["SERVER_NAME"])) {
         $this->serverurl = (isset($_SERVER["HTTPS"]) ? "https://" : "http://") . $_SERVER["SERVER_NAME"] . ($_SERVER["SERVER_PORT"] != "80" ? ":" . $_SERVER["SERVER_PORT"] : "") . WWW_TOP . '/';
         $this->smarty->assign('serverroot', $this->serverurl);
     }
     $this->page = isset($_GET['page']) ? $_GET['page'] : 'content';
     $users = new Users();
     if ($users->isLoggedIn()) {
         $this->userdata = $users->getById($users->currentUserId());
         $this->userdata["categoryexclusions"] = $users->getCategoryExclusion($users->currentUserId());
         //update lastlogin every 15 mins
         if (strtotime($this->userdata['now']) - 900 > strtotime($this->userdata['lastlogin'])) {
             $users->updateSiteAccessed($this->userdata['ID']);
         }
         $this->smarty->assign('userdata', $this->userdata);
         $this->smarty->assign('loggedin', "true");
         $sab = new SABnzbd($this);
         if ($sab->integrated !== false && $sab->url != '' && $sab->apikey != '') {
             $this->smarty->assign('sabintegrated', $sab->integrated);
             $this->smarty->assign('sabapikeytype', $sab->apikeytype);
         }
         if ($this->userdata["role"] == Users::ROLE_ADMIN) {
             $this->smarty->assign('isadmin', "true");
         }
         $this->floodCheck(true, $this->userdata["role"]);
     } else {
         $this->smarty->assign('isadmin', "false");
         $this->smarty->assign('loggedin', "false");
         $this->floodCheck(false, "");
     }
 }
 /**
  * Default constructor.
  */
 function PostProcess($echooutput = false)
 {
     $this->echooutput = $echooutput;
     $s = new Sites();
     $this->site = $s->get();
     $this->mediafileregex = 'AVI|VOB|MKV|MP4|TS|WMV|MOV|M4V|F4V|MPG|MPEG|M2TS';
     $this->audiofileregex = 'MP3|AAC|OGG';
     $this->mp3SavePath = WWW_DIR . 'covers/audio/';
 }
Example #6
0
 function Music($echooutput = false)
 {
     $this->echooutput = $echooutput;
     $s = new Sites();
     $site = $s->get();
     $this->pubkey = $site->amazonpubkey;
     $this->privkey = $site->amazonprivkey;
     $this->imgSavePath = WWW_DIR . 'covers/music/';
 }
 /**
  * Default constructor.
  */
 function Book($echooutput = false)
 {
     $this->echooutput = $echooutput;
     $s = new Sites();
     $site = $s->get();
     $this->pubkey = $site->amazonpubkey;
     $this->privkey = $site->amazonprivkey;
     $this->asstag = $site->amazonassociatetag;
     $this->imgSavePath = WWW_DIR . 'covers/book/';
 }
Example #8
0
 /**
  * Retrieves and stores current rankings for the keyword.
  *
  * @return null
  */
 public function update_rankings()
 {
     $db = DB::connect();
     $site = Sites::get(array('id' => $this->site_id));
     $rank = Scroogle::get_ranking($this->text, $site->domain);
     $q = "INSERT INTO keyword_rank (site_id, search_engine_id, keyword_id, created_at, rank)" . " VALUES ({$site->id}, 1, {$this->id}, NOW(), {$rank})";
     $db->exec($q);
     $rank = Yahoo::get_ranking($this->text, $site->domain);
     $q = "INSERT INTO keyword_rank (site_id, search_engine_id, keyword_id, created_at, rank)" . " VALUES ({$site->id}, 2, {$this->id}, NOW(), {$rank})";
     $db->exec($q);
 }
Example #9
0
 public function addComment($id, $text, $userid, $host)
 {
     $db = new DB();
     $site = new Sites();
     $s = $site->get();
     if ($s->storeuserips != "1") {
         $host = "";
     }
     $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (`releaseID`, \t`text`, \t`userID`, \t`createddate`, \t`host`\t)\t\n\t\t\t\t\t\tVALUES (%d, \t%s, \t%d, \tnow(), \t%s\t)", $id, $db->escapeString($text), $userid, $db->escapeString($host)));
     $this->updateReleaseCommentCount($id);
     return $comid;
 }
 /**
  * Builds a full path to the nzb file on disk. nzbs are stored in a subdir of their first char.
  */
 function getNZBPath($releaseGuid, $sitenzbpath = "", $createIfDoesntExist = false)
 {
     if ($sitenzbpath == "") {
         $s = new Sites();
         $site = $s->get();
         $sitenzbpath = $site->nzbpath;
     }
     $nzbpath = $sitenzbpath . substr($releaseGuid, 0, 1) . "/";
     if ($createIfDoesntExist && !file_exists($nzbpath)) {
         mkdir($nzbpath);
     }
     return $nzbpath . $releaseGuid . ".nzb.gz";
 }
Example #11
0
 function AdminPage()
 {
     $this->template_dir = 'admin';
     parent::BasePage();
     $users = new Users();
     if (!$users->isLoggedIn() || !isset($this->userdata["role"]) || $this->userdata["role"] != Users::ROLE_ADMIN) {
         $this->show403(true);
     }
     // set site variable
     $s = new Sites();
     $this->site = $s->get();
     $this->smarty->assign('site', $this->site);
 }
Example #12
0
 function Binaries()
 {
     $this->n = "\n";
     $s = new Sites();
     $site = $s->get();
     $this->compressedHeaders = $site->compressedheaders == "1" ? true : false;
     $this->messagebuffer = !empty($site->maxmssgs) ? $site->maxmssgs : 20000;
     $this->NewGroupScanByDays = $site->newgroupscanmethod == "1" ? true : false;
     $this->NewGroupMsgsToScan = !empty($site->newgroupmsgstoscan) ? $site->newgroupmsgstoscan : 50000;
     $this->NewGroupDaysToScan = !empty($site->newgroupdaystoscan) ? $site->newgroupdaystoscan : 3;
     $this->blackList = array();
     //cache of our black/white list
     $this->message = array();
 }
 function doConnect($retries = 5, $throw = False, $overridecompression = false)
 {
     if ($this->_isConnected()) {
         return true;
     }
     $s = new Sites();
     $site = $s->get();
     $this->compressedHeaders = $site->compressedheaders == "1" ? true : false;
     $enc = false;
     if (defined("NNTP_SSLENABLED") && NNTP_SSLENABLED == true) {
         $enc = 'ssl';
     }
     while ($retries >= 1) {
         $retries--;
         $enc = false;
         if (defined("NNTP_SSLENABLED") && NNTP_SSLENABLED == true) {
             $enc = 'ssl';
         }
         $ret = $this->connect(NNTP_SERVER, $enc, NNTP_PORT);
         if ($this->isError($ret)) {
             $err = "Cannot connect to server " . NNTP_SERVER . (!$enc ? " (nonssl) " : "(ssl) ") . ": " . $ret->getMessage();
             echo $err;
             if ($retries < 1 && $throw) {
                 throw new NNTPException($err);
             }
             continue;
         }
         if (!defined(NNTP_USERNAME) && NNTP_USERNAME != "") {
             $ret2 = $this->authenticate(NNTP_USERNAME, NNTP_PASSWORD);
             if ($this->isError($ret2)) {
                 $err = "Cannot authenticate to server " . NNTP_SERVER . (!$enc ? " (nonssl) " : " (ssl) ") . " - " . NNTP_USERNAME . " (" . $ret2->getMessage() . ")";
                 echo $err;
                 if ($retries < 1 && $throw) {
                     throw new NNTPException($err);
                 }
                 continue;
             }
         }
         if ($this->compressedHeaders && !$overridecompression) {
             $response = $this->_sendCommand('XFEATURE COMPRESS GZIP');
             if ($this->isError($response) || $response != 290) {
                 //echo "NNTP: XFeature not supported.\n";
             } else {
                 $this->enableXFCompression();
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Default constructor.
  */
 function Parsing($echoonly = false, $limited = true, $verbose = false)
 {
     $this->echoonly = $echoonly;
     $this->limited = $limited;
     $this->verbose = $verbose;
     $this->releasestocheck = 0;
     $this->numupdated = 0;
     $this->numcleaned = 0;
     $this->numnuked = 0;
     $this->nummiscd = 0;
     $this->nfosprocessed = 0;
     $this->parsprocessed = 0;
     $this->releasefilesprocessed = 0;
     $this->cleanup = array('nuke' => array(), 'misc' => array());
     $s = new Sites();
     $this->site = $s->get();
 }
Example #15
0
 function Page()
 {
     parent::BasePage();
     $this->page = isset($_GET['page']) ? $_GET['page'] : 'content';
     // set site variable
     $s = new Sites();
     $this->site = $s->get();
     $this->smarty->assign('site', $this->site);
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents();
     $menu = new Menu();
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category();
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
Example #16
0
require_once WWW_DIR . "/lib/site.php";
$page = new AdminPage();
$sites = new Sites();
$id = 0;
// set the current action
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
switch ($action) {
    case 'submit':
        $site = $sites->update($_POST);
        $returnid = $site->id;
        header("Location:" . WWW_TOP . "/site-edit.php?id=" . $returnid);
        break;
    case 'view':
    default:
        $page->title = "Site Edit";
        $site = $sites->get();
        $page->smarty->assign('fsite', $site);
        break;
}
$page->smarty->assign('yesno_ids', array(1, 0));
$page->smarty->assign('yesno_names', array('Yes', 'No'));
$page->smarty->assign('menupos_ids', array(1, 2));
$page->smarty->assign('menupos_names', array('Left', 'Top'));
$page->smarty->assign('newgroupscan_names', array('Days', 'Posts'));
$page->smarty->assign('registerstatus_ids', array(Sites::REGISTER_STATUS_OPEN, Sites::REGISTER_STATUS_INVITE, Sites::REGISTER_STATUS_CLOSED));
$page->smarty->assign('registerstatus_names', array('Open', 'Invite', 'Closed'));
$page->smarty->assign('passworded_ids', array(0, 1, 2));
$page->smarty->assign('passworded_names', array('Dont show passworded or potentially passworded', 'Dont show passworded', 'Show everything'));
$themelist = array();
$themelist[] = "/";
$themes = scandir(WWW_DIR . "/views/themes");
Example #17
0
            $mailingMgr = new MailingMgr();
            $mailing = $mailingMgr->getMailing($pageID);
            $mailingInfo = $mailing->get();
            $preselected = $mailingInfo["TEMPLATEID"];
        } else {
            $pageMgr = new PageMgr($siteID);
            $page = $pageMgr->getPage($pageID);
            $pageInfo = $page->get();
            $preselected = $pageInfo["TEMPLATEID"];
        }
    }
    if ($action == 'choosefolder') {
        // Check if folders are available
        $templateMgr = new Templates();
        $siteMgr = new Sites();
        $siteinfo = $siteMgr->get($siteID);
        $templatesTree = $templateMgr->getList();
        $hasNoFolders = true;
        foreach ($templatesTree as $templatesTreeItem) {
            if ($templatesTreeItem['LEVEL'] > 1) {
                if ($templatesTreeItem['FOLDER'] == 1) {
                    $hasNoFolders = false;
                }
            }
        }
        $smarty->assign("hasNoFolders", $hasNoFolders);
    }
}
$smarty->assign("site", $siteID);
$smarty->assign("preselected", $preselected);
$smarty->assign("action", $action);
 /**
  * Get nzpre data from usenet and parse.
  */
 public function nzpreUpdate()
 {
     require_once WWW_DIR . "/lib/nntp.php";
     $s = new Sites();
     $site = $s->get();
     if (empty($site->nzpregroup) || empty($site->nzpresubject) || empty($site->nzpreposter) || empty($site->nzprefield) || empty($site->nzprekey)) {
         return false;
     }
     if ($this->echooutput) {
         echo "Predb   : Checking for new pre data ";
     }
     $db = new DB();
     $nntp = new Nntp();
     if (!$nntp->doConnect()) {
         echo "Failed to get NNTP connection\n";
         return false;
     }
     $ret = $groupData = $nntp->selectGroup($site->nzpregroup);
     if ($nntp->isError($ret)) {
         echo "Predb   : Error " . $ret->getMessage() . "\n";
         return false;
     }
     $ret = $groupMsgs = $nntp->getOverview($groupData['last'] - (!empty($site->nzprearticles) ? $site->nzprearticles : 500) . '-' . $groupData['last']);
     if ($nntp->isError($ret)) {
         echo "Predb   : Error " . $ret->getMessage() . "\n";
         return false;
     }
     $added_updated = 0;
     $nzprekey = $site->nzprekey;
     while (strlen($nzprekey) < 1024) {
         $nzprekey = $nzprekey . $nzprekey;
     }
     $cnt = !empty($site->nzprearticles) ? $site->nzprearticles : 500;
     foreach ($groupMsgs as $groupMsg) {
         if ($cnt % 50 == 0 && $cnt != 0 && $this->echooutput) {
             echo $cnt . "..";
         }
         $cnt--;
         if (preg_match('/^' . $site->nzpresubject . '$/', $groupMsg['Subject']) && preg_match('/^' . $site->nzpreposter . '$/', $groupMsg['From'])) {
             $ret = $msgHeader = $nntp->getHeader($groupMsg['Message-ID']);
             if ($nntp->isError($ret)) {
                 continue;
             }
             for ($i = 0; $i < count($msgHeader); $i++) {
                 if (preg_match('/^' . $site->nzprefield . ': /', $msgHeader[$i])) {
                     if ($nzpreParse = $this->nzpreParse(str_replace($site->nzprefield . ': ', '', $msgHeader[$i]), $nzprekey)) {
                         if ($this->updatePreDB($db, $nzpreParse)) {
                             $added_updated++;
                         }
                     }
                     break;
                 }
             }
         }
     }
     $nntp->disconnect();
     if ($this->echooutput) {
         echo "\nPredb   : Added/Updated " . $added_updated . " records\n";
     }
 }
function getUrl($url, $method = 'get', $postdata = '', $enctype = '', $proxyaddress = '', $proxytype = '', $proxyuserpwd = '', $language = '')
{
    $ch = curl_init();
    if (strtolower($method) == 'post') {
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Firefox/24.0');
    if ($enctype != '') {
        curl_setopt($ch, CURLOPT_ENCODING, $enctype);
    }
    if ($proxyaddress == '' && $proxytype == '' && $proxyuserpwd == '') {
        $s = new Sites();
        $site = $s->get();
        $proxyaddress = $site->curlproxyaddress;
        $proxytype = $site->curlproxytype;
        $proxyuserpwd = $site->curlproxyuserpwd;
    }
    if ($proxyaddress != '' && $proxytype != '') {
        curl_setopt($ch, CURLOPT_PROXY, $proxyaddress);
        curl_setopt($ch, CURLOPT_PROXYTYPE, constant('CURLPROXY_' . $proxytype));
    }
    if ($proxyuserpwd != '') {
        curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyuserpwd);
    }
    if ($language != '') {
        switch (strtolower($language)) {
            case 'de':
                $lang = 'de-de,de';
                break;
            case 'en':
                $lang = 'en-us,en';
                break;
            case 'es':
                $lang = 'es-es,es';
                break;
            case 'fr':
                $lang = 'fr-fr,fr';
                break;
            case 'it':
                $lang = 'it';
                break;
            case 'nl':
                $lang = 'nl';
                break;
            case 'pt':
                $lang = 'pt';
                break;
            case 'sv':
                $lang = 'sv-sv,sv';
                break;
            default:
                $lang = 'en-us,en-gb,en';
                break;
        }
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Language: ' . $lang));
    }
    $buffer = curl_exec($ch);
    $err = curl_errno($ch);
    curl_close($ch);
    return $err == 0 ? $buffer : false;
}
Example #20
0
 public function login($uid, $host = "", $remember = "")
 {
     $_SESSION['uid'] = $uid;
     $site = new Sites();
     $s = $site->get();
     if ($s->storeuserips != "1") {
         $host = '';
     }
     $this->updateSiteAccessed($uid, $host);
     if ($remember == 1) {
         $this->setCookies($uid);
     }
 }
Example #21
0
 /**
  * Creates a Site object with PageRank and subpages
  *
  * @param array $paramarray Array of parameters
  *
  * @return Site object
  */
 public static function create($paramarray)
 {
     $db = DB::connect();
     $domain = parse_url($paramarray['url'], PHP_URL_HOST);
     if (self::exists($domain)) {
         trigger_error(sprintf('The domain %s already exists.', $domain), E_USER_ERROR);
         return false;
     }
     $pagerank = Google::get_pagerank($domain);
     $db->exec("INSERT INTO site VALUES('', '{$domain}', '{$pagerank}')");
     // return an instance of the created site
     $id = $db->query('SELECT id FROM site ORDER BY id DESC LIMIT 1')->fetchColumn();
     $site = Sites::get(array('id' => $id));
     $site->refresh_pages();
     $site->update_page_statistics();
     return $site;
 }
            }
        }
        if ($error == "") {
            $site = $ret;
            $returnid = $site->id;
            header("Location:" . WWW_TOP . "/site-edit.php?id=" . $returnid);
        } else {
            $page->smarty->assign('error', $error);
            $site = $sites->row2Object($_POST);
            $page->smarty->assign('fsite', $site);
        }
        break;
    case 'view':
    default:
        $page->title = "Site Edit";
        $site = $sites->get(true);
        $page->smarty->assign('fsite', $site);
        break;
}
$page->smarty->assign('yesno_ids', array(1, 0));
$page->smarty->assign('yesno_names', array('Yes', 'No'));
$page->smarty->assign('passwd_ids', array(2, 1, 0));
$page->smarty->assign('passwd_names', array('Deep (requires unrar)', 'Shallow', 'None'));
$page->smarty->assign('sabintegrationtype_ids', array(SABnzbd::INTEGRATION_TYPE_USER, SABnzbd::INTEGRATION_TYPE_SITEWIDE, SABnzbd::INTEGRATION_TYPE_NONE));
$page->smarty->assign('sabintegrationtype_names', array('User', 'Site-wide', 'None (Off)'));
$page->smarty->assign('sabapikeytype_ids', array(SABnzbd::API_TYPE_NZB, SABnzbd::API_TYPE_FULL));
$page->smarty->assign('sabapikeytype_names', array('Nzb Api Key', 'Full Api Key'));
$page->smarty->assign('sabpriority_ids', array(SABnzbd::PRIORITY_FORCE, SABnzbd::PRIORITY_HIGH, SABnzbd::PRIORITY_NORMAL, SABnzbd::PRIORITY_LOW));
$page->smarty->assign('sabpriority_names', array('Force', 'High', 'Normal', 'Low'));
$page->smarty->assign('curlproxytype_names', array('', 'HTTP', 'SOCKS5'));
$page->smarty->assign('newgroupscan_names', array('Days', 'Posts'));
Example #23
0
header('Content-type: text/xml');
$tmpUser = new User(sUserMgr()->getCurrentUserID());
$tmpUserInfo = $tmpUser->get();
$adminAllowed = $tmpUser->checkPermission('RPAGES');
if (!$adminAllowed) {
    $adminAllowed = $tmpUser->checkPermission('RTEMPLATES');
}
if ($adminAllowed) {
    $site = $this->request->parameters['site'];
    if ($site == 'mailing') {
        $mailingMgr = new MailingMgr();
        $templateRoot = $mailingMgr->getTemplateRoot();
    } else {
        $site = (int) $site;
        $siteMgr = new Sites();
        $siteinfo = $siteMgr->get($site);
        if ($siteinfo['TEMPLATEROOT']) {
            $templateRoot = $siteinfo['TEMPLATEROOT'];
        }
    }
    $templateMgr = new Templates();
    $newpage = (int) $this->request->parameters['page'];
    $action = $this->request->parameters['action'];
    if ($action == 'choose') {
        $noclick = 'noclick';
    } else {
        $noclick = '';
    }
    $onlyFolders = false;
    if ($this->page == 'templatefolders_tree_nodes') {
        $onlyFolders = true;
    $statusmsgs[] = addmsg("Amazon shared key in use. Not using your own Amazon API key will result in failed amazon lookups.", "http://newznab.readthedocs.org/en/latest/faq/");
}
if ($page->site->rawretentiondays > 10) {
    $statusmsgs[] = addmsg("Binary header retention is set at " . $page->site->rawretentiondays . ". Having this value any higher than 2 can cause the database to grow very large.", "site-edit.php");
}
if ($page->site->newznabID == "") {
    $statusmsgs[] = addmsg("Newznab ID missing. You have not entered a newznab ID, and will not be using the latest matching regex's.", "http://www.newznab.com/chat.html", "exclamation");
}
//
// database patches uptodate
//
$s = new Sites();
if (!property_exists($page->site, "dbversion")) {
    $db = new DB();
    $db->queryInsert('INSERT INTO site (setting, value, updateddate ) VALUES (\'dbversion\', \'$Rev: 2248 $\', now())');
    $page->site = $s->get();
}
if (!preg_match("/\\d+/", $page->site->dbversion, $matches)) {
    $statusmsgs[] = addmsg("Bad database version. " . $page->site->dbversion . " cannot be parsed.", "http://newznab.readthedocs.org/en/latest/install/#updating", "exclamation");
}
$patches = $s->getUnappliedPatches($page->site);
$patches = array_map("basename", $patches);
if (count($patches) > 0) {
    $statusmsgs[] = addmsg("Database out of date. Ensure all database patches in /db/patch/0.2.3/ are ran by using the script misc/update_scripts/update_database_version.php<br/><small>" . implode("<br/>", $patches) . "</small>", "http://newznab.readthedocs.org/en/latest/install/#updating", "exclamation");
}
$page->smarty->assign('statusmsgs', $statusmsgs);
$page->content = $page->smarty->fetch('index.tpl');
$page->render();
function addmsg($msg, $url = "", $icon = "")
{
    return array('msg' => $msg, 'url' => $url, 'icon' => $icon == "" ? "information" : $icon);
 /**
  * Add a releasecomment row.
  */
 public function addComment($id, $gid, $text, $userid, $host)
 {
     if (strlen(trim($text)) == 0) {
         return false;
     }
     $db = new DB();
     $site = new Sites();
     $s = $site->get();
     if ($s->storeuserips != "1") {
         $host = "";
     }
     $comid = $db->queryInsert(sprintf("INSERT INTO releasecomment (releaseID, gid, text, userID, createddate, host) VALUES (%d, %s, %s, %d, now(), %s)", $id, $db->escapeString($gid), $db->escapeString($text), $userid, $db->escapeString($host)));
     $this->updateReleaseCommentCount($gid);
     return $comid;
 }
Example #26
0
            $siteMgr->setDefaultTemplate($objectID, $defaulttemplate);
            $siteMgr->setTemplateRoot($objectID, $templateroot);
            $jsQueue->add($objectID, HISTORYTYPE_SITE, 'OBJECT_CHANGE', sGuiUS(), 'site', NULL, NULL, $objectID . '-site', 'name', $name);
            $jsQueue->add($objectID, HISTORYTYPE_SITE, 'OBJECT_CHANGE', sGuiUS(), 'page', NULL, NULL, $objectID . '-site', 'name', $name);
            $jsQueue->add($objectID, HISTORYTYPE_SITE, 'OBJECT_CHANGE', sGuiUS(), 'site', NULL, NULL, $objectID . '-site', 'pname', $pname);
            // Re-sort the list
            $koala->queueScript('if (Koala.windows[Koala.windows[\'' . $wid . '\'].boundWindow].sortList) Koala.windows[Koala.windows[\'' . $wid . '\'].boundWindow].sortList();');
            $jsQueue->add($objectID, HISTORYTYPE_SITE, 'REFRESH_WINDOW', sGuiUS(), 'name');
            // Fade all green fields
            $koala->queueScript("Koala.yg_fadeFields(\$('" . $wid . "'), 'input.changed');");
            $jsQueue->add($objectID, HISTORYTYPE_SITE, 'UNHIGHLIGHT_SITE', sGuiUS(), 'name');
        }
        break;
    case 'siteSelectNode':
        $node = $this->params['node'];
        $wid = $this->params['wid'];
        $koala->callJSFunction('Koala.yg_enable', 'tree_btn_delete', 'btn-' . $wid, 'tree_btn');
        break;
    case 'siteCalcPname':
        // Get window-ID
        $winID = $data[1]['winID'];
        // Split ObjectID and SiteID
        $siteId = explode('-', $this->reponsedata['name']->yg_id);
        $siteId = $siteId[0];
        $siteInfo = $siteMgr->get($siteId);
        if (strlen(trim($siteInfo['PNAME'])) == 0) {
            $PName = $siteMgr->calcPName($siteId, '', $this->reponsedata['name']->value);
            $koala->queueScript('$(\'' . $winID . '_site_pname\').value=\'' . $PName . '\';Koala.yg_setEdited( $(\'' . $winID . '_site_pname\') );');
        }
        break;
}
Example #27
0
 public function display_site_delete()
 {
     $site = Sites::get(array('id' => $_GET['id']));
     if (!isset($_GET['confirm']) || $_GET['confirm'] != "yes") {
         $this->template->site = $site;
         $this->template->display('delete.php');
     } else {
         $site->delete();
         header("HTTP/1.1 301 Moved Permanently");
         header("Location: /");
         exit;
     }
 }
 /**
  * Writes a zip file of an array of release guids directly to the stream
  */
 public function getZipped($guids)
 {
     $s = new Sites();
     $nzb = new NZB();
     $site = $s->get();
     $zipfile = new zipfile();
     foreach ($guids as $guid) {
         $nzbpath = $nzb->getNZBPath($guid, $site->nzbpath);
         if (file_exists($nzbpath)) {
             ob_start();
             @readgzfile($nzbpath);
             $nzbfile = ob_get_contents();
             ob_end_clean();
             $filename = $guid;
             $r = $this->getByGuid($guid);
             if ($r) {
                 $filename = $r["searchname"];
             }
             $zipfile->addFile($nzbfile, $filename . ".nzb");
         }
     }
     return $zipfile->file();
 }
 /**
  * Issue a request to the anidb API.
  */
 public function AniDBAPI($anidbID)
 {
     $s = new Sites();
     $site = $s->get();
     $db = new DB();
     $timeBetweenRequests = 10;
     //seconds, not sure how aggressive we can be with anidb.
     if ($site->anidb_banned) {
         $anidb_banned_diff = $db->queryOneRow("SELECT TIMESTAMPDIFF(HOUR,updateddate, NOW()) AS hours FROM site WHERE setting='anidb_banned'");
         if ($anidb_banned_diff['hours'] < 24) {
             echo "AniDB   : Banned from AniDB, " . (24 - $anidb_banned_diff['hours']) . " hours left to wait to try again...\n";
             return false;
         } else {
             $db->exec("update site SET `value` = '0', `updateddate` = NOW() WHERE `setting` = 'anidb_banned'");
         }
     }
     //to comply with flooding rule.
     echo "AniDB   : Requesting data from AniDB in ";
     for ($i = $timeBetweenRequests; $i > 0; $i--) {
         echo $i . ".";
         sleep(1);
     }
     echo "\n";
     $apiUrl = 'http://api.anidb.net:9001/httpapi?request=anime&client=' . self::CLIENT . '&clientver=' . self::CLIENTVER . '&protover=1&aid=' . $anidbID;
     $apiresponse = getUrl($apiUrl, '', '', 'gzip');
     if (!$apiresponse) {
         echo "AniDB   : Error getting response.\n";
         return false;
     } else {
         if (preg_match('/error.*Banned.*error/', $apiresponse, $valid)) {
             $db->exec("update site SET `value` = '1', `updateddate` = NOW() WHERE `setting` = 'anidb_banned'");
             echo "AniDB   : Banned reply from AniDB. Waiting 24 hours until retrying.";
             return false;
         } else {
             if (!preg_match('/anime id="\\d+"/', $apiresponse, $valid)) {
                 echo "AniDB   : No 'anime id' field found in response.\n";
                 return false;
             }
         }
     }
     preg_match('/<title xml:lang="en" type="official">([^<]+)<\\/title>/', $apiresponse, $safeTitle);
     if (!$safeTitle) {
         preg_match('/<title xml:lang="x-jat" type="main">([^<]+)<\\/title>/', $apiresponse, $safeTitle);
     }
     $apiresponse = preg_replace('/<title xml:lang="(?!en\\").*/', '', $apiresponse);
     $AniDBAPIXML = new SimpleXMLElement($apiresponse);
     if (!$AniDBAPIXML) {
         return false;
     }
     if ($AniDBAPIXML->relatedanime) {
         foreach ($AniDBAPIXML->relatedanime as $related) {
             $relatedArray[] = (string) $related->anime;
         }
     }
     if ($AniDBAPIXML->creators->name) {
         foreach ($AniDBAPIXML->creators->name as $creator) {
             $creatorsArray[] = (string) $creator;
         }
     }
     if ($AniDBAPIXML->categories->category) {
         foreach ($AniDBAPIXML->categories->category as $category) {
             $categoriesArray[] = (string) $category->name;
         }
     }
     if ($AniDBAPIXML->characters->character) {
         foreach ($AniDBAPIXML->characters->character as $character) {
             $charactersArray[] = (string) $character->name;
         }
     }
     foreach ($AniDBAPIXML->episodes->episode as $episode) {
         $epnosArray[] = (string) $episode->epno;
         $airdatesArray[] = (string) $episode->airdate;
         $episodetitlesArray[] = $episode->title[0];
     }
     $AniDBAPIArray = array('anidbID' => $anidbID, 'title' => $safeTitle[1], 'type' => (string) $AniDBAPIXML->type[0], 'startdate' => (string) $AniDBAPIXML->startdate[0], 'enddate' => (string) $AniDBAPIXML->enddate[0], 'related' => isset($relatedArray) ? implode($relatedArray, '|') : '', 'creators' => isset($creatorsArray) ? implode($creatorsArray, '|') : '', 'description' => (string) $AniDBAPIXML->description, 'rating' => (string) $AniDBAPIXML->ratings->permanent ? (string) $AniDBAPIXML->ratings->permanent : (string) $AniDBAPIXML->ratings->temporary, 'picture' => (string) $AniDBAPIXML->picture[0], 'categories' => isset($categoriesArray) ? implode($categoriesArray, '|') : '', 'characters' => isset($charactersArray) ? implode($charactersArray, '|') : '', 'epnos' => implode($epnosArray, '|'), 'airdates' => $airdatesArray ? implode($airdatesArray, '|') : '', 'episodetitles' => implode($episodetitlesArray, '|'));
     return $AniDBAPIArray;
 }
Example #30
0
 public function updateUpcoming()
 {
     $s = new Sites();
     $site = $s->get();
     if (isset($site->rottentomatokey)) {
         $rt = new RottenTomato($site->rottentomatokey);
         $ret = $rt->getBoxOffice();
         if ($ret != "") {
             $this->updateInsUpcoming('rottentomato', Movie::SRC_BOXOFFICE, $ret);
         }
         $ret = $rt->getInTheaters();
         if ($ret != "") {
             $this->updateInsUpcoming('rottentomato', Movie::SRC_INTHEATRE, $ret);
         }
         $ret = $rt->getOpening();
         if ($ret != "") {
             $this->updateInsUpcoming('rottentomato', Movie::SRC_OPENING, $ret);
         }
         $ret = $rt->getUpcoming();
         if ($ret != "") {
             $this->updateInsUpcoming('rottentomato', Movie::SRC_UPCOMING, $ret);
         }
         $ret = $rt->getDVDReleases();
         if ($ret != "") {
             $this->updateInsUpcoming('rottentomato', Movie::SRC_DVD, $ret);
         }
     }
 }