Changeset 179

Show
Ignore:
Timestamp:
10/21/08 01:46:24 (3 months ago)
Author:
drarok
Message:

* Initial test build of autonzb feature.

Location:
hellaworld/branches/autonzb
Files:
7 added
7 modified

Legend:

Unmodified
Added
Removed
  • hellaworld/branches/autonzb

    • Property svn:ignore
      •  

        old new  
        11config.php 
         2._* 
  • hellaworld/branches/autonzb/classes

    • Property svn:ignore set to
      ._*
  • hellaworld/branches/autonzb/index.php

    r172 r179  
    9898 
    9999                require_once 'classes/HellaController.php'; 
     100                 
     101                require_once('classes/xml-dataset.php'); 
     102                require_once('classes/atom-feed.php'); 
     103                require_once('classes/nzb-helper.php'); 
    100104 
    101105                if ($auth == 'exclusive' && !ipInRange($iprange, $_SERVER['REMOTE_ADDR'])) { 
     
    354358                        } 
    355359                } 
     360                 
     361                // Auto-NZB 
     362                if (array_key_exists('addfeed', $_GET)) {        
     363                        $dataset = new XML_Dataset('./feeds.xml'); 
     364                         
     365                        // Check we don't already have this feed... 
     366                        foreach ($dataset->feed as $feed) 
     367                                if ($feed->attributes()->url == $_GET['addfeed']) 
     368                                        throw new Exception('Feed already processed.'); 
     369                         
     370                        // Add the new feed! 
     371                        $atom = new Atom_Feed($_GET['addfeed']); 
     372                        $latest = reset($atom->entry); 
     373                        $parsed = nzb::parse($latest); 
     374                         
     375                        $feed = $dataset->addNode('feed', array('url' => $_GET['addfeed'])); 
     376                        $feed->addAttribute('name', $parsed->show); 
     377                        $feed->addAttribute('latest_episode', $parsed->episode); 
     378                        $dataset->save();                                        
     379                } 
    356380 
    357381        } catch (Exception $e) { 
  • hellaworld/branches/autonzb/js

    • Property svn:ignore set to
      ._*
  • hellaworld/branches/autonzb/style

    • Property svn:ignore set to
      ._*
  • hellaworld/branches/autonzb/templates

    • Property svn:ignore set to
      ._*
  • hellaworld/branches/autonzb/templates/default.php

    r170 r179  
    158158                <?php if (isset($config['showfinished']) && $config['showfinished']): ?><li><a accesskey="2" href="#fragment-2"><span><?php echo _('Finished Items'); ?></span></a></li><?php endif; ?> 
    159159                <li><a accesskey="3" href="#fragment-3"><span><?php echo _('Bookmarklet'); ?></span></a></li> 
     160                <li><a accesskey="4" href="#fragment-4"><span><?php echo _('NZB Feeds'); ?></span></a></li> 
    160161        </ul> 
    161162<div id="fragment-1"> 
     
    208209<p class="bkmark"><?php echo _("Right click on this link and bookmark it, or drag it to your bookmarks/favorites to create a Newzbin shortcut. Clicking on this shortcut when on a Newzbin article will add the NZB to HellaNZB's queue."); ?></p> 
    209210<p class="bkmark"><a href="javascript:c=location.href;if(c.match(/browse\/post\/\d+/)){location.href='<?php echo $protocol . '://' . htmlentities($_SERVER['HTTP_HOST']) . $self ?>?bookmarklet='+encodeURIComponent(c);}else{void(0);}"><?php echo _('Send to HellaWorld'); ?></a></p> 
    210 </div> 
     211<p class="bkmark"><a href="javascript:<?php 
     212$hw_url = $protocol.'://'.htmlentities($_SERVER['HTTP_HOST']).dirname($self); 
     213echo "var hw_url = '".$hw_url."'; var scriptElem = document.createElement('script');scriptElem.type = 'text/javascript';scriptElem.src = '".$hw_url."/js/autonzb.js';document.body.appendChild(scriptElem);void(0);"; ?>">NZB RSS to HellaWorld</a></p> 
     214</div> 
     215         
     216        <div id="fragment-4"> 
     217                <h2>NZB Feeds</h2> 
     218                <ul> 
     219<?php 
     220        if (! isset($dataset)) 
     221                $dataset = new XML_Dataset('./feeds.xml'); 
     222        if (count($dataset->feed) == 0) 
     223                echo '<li>There are no feeds to display.</li>', "\n"; 
     224        else 
     225                foreach ($dataset->feed as $feed) { 
     226                        $attrs = $feed->attributes(); 
     227                        echo sprintf('<li>%s (%s)</li>', $attrs->name, $attrs->latest_episode), "\n"; 
     228                } 
     229?> 
     230                </ul> 
     231        </div> 
    211232</div> 
    212233        </body>