コード例 #1
0
ファイル: SpotPage_reportpost.php プロジェクト: niel/spotweb
 function render()
 {
     $formMessages = array('errors' => array(), 'info' => array());
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_report_spam, '');
     # Sportparser is nodig voor het escapen van de random string
     $spotParser = new SpotParser();
     # spot signing is nodig voor het RSA signen van de spot en dergelijke
     $spotSigning = Services_Signing_Base::newServiceSigning();
     # creeer een default report
     $report = array('body' => 'This is SPAM!', 'inreplyto' => $this->_inReplyTo, 'newmessageid' => '', 'randomstr' => '');
     # reportpost verzoek was standaard niet geprobeerd
     $postResult = array();
     # zet de page title
     $this->_pageTitle = "report: report spot";
     /* 
      * bring the forms' action into the local scope for 
      * easier access
      */
     $formAction = $this->_reportForm['action'];
     # Make sure the anonymous user and reserved usernames cannot post content
     $spotUser = new SpotUserSystem($this->_db, $this->_settings);
     if (!$spotUser->allowedToPost($this->_currentSession['user'])) {
         $postResult = array('result' => 'notloggedin');
         $formAction = '';
     }
     # if
     if ($formAction == 'post') {
         # Notificatiesysteem initialiseren
         $spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $this->_currentSession);
         # zorg er voor dat alle variables ingevuld zijn
         $report = array_merge($report, $this->_reportForm);
         # vraag de users' privatekey op
         $this->_currentSession['user']['privatekey'] = $this->_db->getUserPrivateRsaKey($this->_currentSession['user']['userid']);
         # het messageid krijgen we met <>'s, maar we werken
         # in spotweb altijd zonder, dus die strippen we
         $report['newmessageid'] = substr($report['newmessageid'], 1, -1);
         # valideer of we dit report kunnen posten, en zo ja, doe dat dan
         $spotPosting = new SpotPosting($this->_db, $this->_settings);
         $formMessages['errors'] = $spotPosting->reportSpotAsSpam($this->_currentSession['user'], $report);
         if (empty($formMessages['errors'])) {
             $postResult = array('result' => 'success');
             # en verstuur een notificatie
             $spotsNotifications->sendReportPosted($report['inreplyto']);
         } else {
             $postResult = array('result' => 'failure');
         }
         # else
     }
     # if
     #- display stuff -#
     $this->template('spamreport', array('postreportform' => $report, 'formmessages' => $formMessages, 'postresult' => $postResult));
 }
コード例 #2
0
 function render()
 {
     $formMessages = array('errors' => array(), 'info' => array());
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_post_comment, '');
     # Sportparser is nodig voor het escapen van de random string
     $spotParser = new SpotParser();
     # spot signing is nodig voor het RSA signen van de spot en dergelijke
     $spotSigning = new SpotSigning();
     # creeer een default comment zodat het form altijd
     # de waardes van het form kan renderen
     $comment = array('body' => '', 'rating' => 0, 'inreplyto' => $this->_inReplyTo, 'newmessageid' => '', 'randomstr' => '');
     # postcomment verzoek was standaard niet geprobeerd
     $postResult = array();
     # zet de page title
     $this->_pageTitle = "spot: post comment";
     # Als de user niet ingelogged is, dan heeft dit geen zin
     if ($this->_currentSession['user']['userid'] == SPOTWEB_ANONYMOUS_USERID) {
         $postResult = array('result' => 'notloggedin');
         unset($this->_commentForm['submit']);
     }
     # if
     # Zorg er voor dat reserved usernames geen comments kunnen posten
     $spotUser = new SpotUserSystem($this->_db, $this->_settings);
     if (!$spotUser->validUsername($this->_currentSession['user']['username'])) {
         $postResult = array('result' => 'notloggedin');
         unset($this->_commentForm['submit']);
     }
     # if
     if (isset($this->_commentForm['submit'])) {
         # submit unsetten we altijd
         unset($this->_commentForm['submit']);
         # zorg er voor dat alle variables ingevuld zijn
         $comment = array_merge($comment, $this->_commentForm);
         # vraag de users' privatekey op
         $this->_currentSession['user']['privatekey'] = $spotUser->getUserPrivateRsaKey($this->_currentSession['user']['userid']);
         # het messageid krijgen we met <>'s, maar we werken
         # in spotweb altijd zonder, dus die strippen we
         $comment['newmessageid'] = substr($comment['newmessageid'], 1, -1);
         # valideer of we deze comment kunnen posten, en zo ja, doe dat dan
         $spotPosting = new SpotPosting($this->_db, $this->_settings);
         $formMessages['errors'] = $spotPosting->postComment($this->_currentSession['user'], $comment);
         if (empty($formMessages['errors'])) {
             $postResult = array('result' => 'success', 'user' => $this->_currentSession['user']['username'], 'userid' => $spotSigning->calculateUserid($this->_currentSession['user']['publickey']), 'rating' => $comment['rating'], 'body' => $comment['body']);
         } else {
             $postResult = array('result' => 'failure');
         }
         # else
     }
     # if
     #- display stuff -#
     $this->template('postcomment', array('postcommentform' => $comment, 'formmessages' => $formMessages, 'postresult' => $postResult));
 }
コード例 #3
0
 function render()
 {
     $formMessages = array('errors' => array(), 'info' => array());
     # Controleer de users' rechten
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_post_spot, '');
     # Sportparser is nodig voor het escapen van de random string
     $spotParser = new SpotParser();
     # spot signing is nodig voor het RSA signen van de spot en dergelijke
     $spotSigning = new SpotSigning();
     # creeer een default spot zodat het form altijd
     # de waardes van het form kan renderen
     $spot = array('title' => '', 'body' => '', 'category' => 0, 'subcatz' => '', 'subcatlist' => '', 'tag' => '', 'website' => '', 'newmessageid' => '', 'randomstr' => '');
     # postspot verzoek was standaard niet geprobeerd
     $postResult = array();
     # zet de page title
     $this->_pageTitle = "spot: post";
     # Als de user niet ingelogged is, dan heeft dit geen zin
     if ($this->_currentSession['user']['userid'] == SPOTWEB_ANONYMOUS_USERID) {
         $postResult = array('result' => 'notloggedin');
         unset($this->_spotForm['submit']);
     }
     # if
     # Zorg er voor dat reserved usernames geen spots kunnen posten
     $spotUser = new SpotUserSystem($this->_db, $this->_settings);
     if (!$spotUser->validUsername($this->_currentSession['user']['username'])) {
         $postResult = array('result' => 'notloggedin');
         unset($this->_spotForm['submit']);
     }
     # if
     # If user tried to submit, validate the file uploads
     if (isset($this->_spotForm['submit'])) {
         # Make sure an NZB file was provided
         if (!isset($_FILES['newspotform']) || $_FILES['newspotform']['error']['nzbfile'] != UPLOAD_ERR_OK) {
             $formMessages['errors'][] = array('postspot_invalidnzb', '(none given)');
             $postResult = array('result' => 'failure');
             // $xml = file_get_contents($_FILES['filterimport']['tmp_name']);
             unset($this->_spotForm['submit']);
         }
         # if
         # Make sure an imgae file was provided
         if (!isset($_FILES['newspotform']) || $_FILES['newspotform']['error']['imagefile'] != UPLOAD_ERR_OK) {
             $formMessages['errors'][] = array('postspot_imageinvalid', '(none given)');
             $postResult = array('result' => 'failure');
             // $xml = file_get_contents($_FILES['filterimport']['tmp_name']);
             unset($this->_spotForm['submit']);
         }
         # if
     }
     # if
     if (isset($this->_spotForm['submit'])) {
         # Notificatiesysteem initialiseren
         $spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $this->_currentSession);
         # submit unsetten we altijd
         unset($this->_spotForm['submit']);
         # De subcatz wordt per hoofdcategory doorgegeven, merge die naar 1
         # subcatz
         $spot['subcatz'] = isset($this->_spotForm['subcatz' . $this->_spotForm['category']]) ? $this->_spotForm['subcatz' . $this->_spotForm['category']] : '';
         # zorg er voor dat alle variables ingevuld zijn
         $spot = array_merge($spot, $this->_spotForm);
         # vraag de users' privatekey op
         $this->_currentSession['user']['privatekey'] = $spotUser->getUserPrivateRsaKey($this->_currentSession['user']['userid']);
         # het messageid krijgen we met <>'s, maar we werken
         # in spotweb altijd zonder, dus die strippen we
         $spot['newmessageid'] = substr($spot['newmessageid'], 1, -1);
         # valideer of we deze spot kunnen posten, en zo ja, doe dat dan
         $spotPosting = new SpotPosting($this->_db, $this->_settings);
         $formMessages['errors'] = $spotPosting->postSpot($this->_currentSession['user'], $spot, $_FILES['newspotform']['tmp_name']['imagefile'], $_FILES['newspotform']['tmp_name']['nzbfile']);
         if (empty($formMessages['errors'])) {
             $postResult = array('result' => 'success', 'user' => $this->_currentSession['user']['username'], 'userid' => $spotSigning->calculateUserid($this->_currentSession['user']['publickey']), 'body' => $spot['body']);
             # en verstuur een notificatie
             $spotsNotifications->sendSpotPosted($spot);
         } else {
             $postResult = array('result' => 'failure');
         }
         # else
     }
     # if
     #- display stuff -#
     $this->template('newspot', array('postspotform' => $spot, 'formmessages' => $formMessages, 'postresult' => $postResult));
 }
コード例 #4
0
ファイル: SpotPage_postcomment.php プロジェクト: niel/spotweb
 function render()
 {
     $formMessages = array('errors' => array(), 'info' => array());
     # Validate proper permissions
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_post_comment, '');
     # Sportparser is nodig voor het escapen van de random string
     $spotParser = new SpotParser();
     # spot signing is nodig voor het RSA signen van de spot en dergelijke
     $spotSigning = Services_Signing_Base::newServiceSigning();
     # creeer een default comment zodat het form altijd
     # de waardes van het form kan renderen
     $comment = array('body' => '', 'rating' => 0, 'inreplyto' => $this->_inReplyTo, 'newmessageid' => '', 'randomstr' => '');
     # postcomment verzoek was standaard niet geprobeerd
     $postResult = array();
     # zet de page title
     $this->_pageTitle = "spot: post comment";
     /* 
      * bring the forms' action into the local scope for 
      * easier access
      */
     $formAction = $this->_commentForm['action'];
     # Make sure the anonymous user and reserved usernames cannot post content
     $spotUser = new SpotUserSystem($this->_db, $this->_settings);
     if (!$spotUser->allowedToPost($this->_currentSession['user'])) {
         $postResult = array('result' => 'notloggedin');
         $formAction = '';
     }
     # if
     if ($formAction == 'post') {
         # zorg er voor dat alle variables ingevuld zijn
         $comment = array_merge($comment, $this->_commentForm);
         # vraag de users' privatekey op
         $this->_currentSession['user']['privatekey'] = $spotUser->getUserPrivateRsaKey($this->_currentSession['user']['userid']);
         # het messageid krijgen we met <>'s, maar we werken
         # in spotweb altijd zonder, dus die strippen we
         $comment['newmessageid'] = substr($comment['newmessageid'], 1, -1);
         # valideer of we deze comment kunnen posten, en zo ja, doe dat dan
         $spotPosting = new SpotPosting($this->_db, $this->_settings);
         $formMessages['errors'] = $spotPosting->postComment($this->_currentSession['user'], $comment);
         if (empty($formMessages['errors'])) {
             /* Format the body so we can have smilies and stuff be shown in the template */
             $tmpBody = $this->_tplHelper->formatContent($comment['body']);
             /* Try to create the avatar */
             if (!empty($this->_currentSession['user']['avatar'])) {
                 $comment['user-avatar'] = $this->_currentSession['user']['avatar'];
             } else {
                 $spotSigning = Services_Signing_Base::newServiceSigning();
                 $tmpKey = $spotSigning->getPublicKey($this->_currentSession['user']['privatekey']);
                 $comment['user-key'] = $tmpKey['publickey'];
             }
             # else
             $commentImage = $this->_tplHelper->makeCommenterImageUrl($comment);
             /* and return the result to the system */
             $postResult = array('result' => 'success', 'user' => $this->_currentSession['user']['username'], 'spotterid' => $spotSigning->calculateSpotterId($this->_currentSession['user']['publickey']), 'rating' => $comment['rating'], 'body' => $tmpBody, 'commentimage' => $commentImage);
         } else {
             $postResult = array('result' => 'failure');
         }
         # else
     }
     # if
     #- display stuff -#
     $this->template('postcomment', array('postcommentform' => $comment, 'formmessages' => $formMessages, 'postresult' => $postResult));
 }
コード例 #5
0
ファイル: testPost.php プロジェクト: Ernie69/spotweb
require_once "NNTP/Client.php";
require_once "lib/exceptions/CustomException.php";
require_once "lib/exceptions/NntpException.php";
require_once "lib/SpotSecurity.php";
require_once "lib/SpotTiming.php";
require_once "settings.php";
require_once "lib/SpotDb.php";
define('USERID', 30);
/* -------------------------------------------------------------------- */
echo "Included PHP classes... " . PHP_EOL;
$db = new SpotDb($settings['db']);
$db->connect();
echo "Connected to the database.." . PHP_EOL;
$spotSettings = SpotSettings::singleton($db, $settings);
$spotSigning = new SpotSigning();
$spotPosting = new SpotPosting($db, $spotSettings);
$spotUserSystem = new SpotUserSystem($db, $spotSettings);
echo "Initialized classes.." . PHP_EOL;
$spot['category'] = 0;
$spot['website'] = 'http://www.moviemeter.nl/film/69912';
$spot['body'] = 'Hierbij een cover van de film Colombiana.

Met dank aan de originele poster van deze cover';
$spot['poster'] = 'Spotweb Test User';
$spot['tag'] = '';
$spot['key'] = 7;
$spot['title'] = 'Colombiana cover (SWtest2)';
echo "Spot Title will be: " . $spot['title'] . PHP_EOL;
$spot['category'] = 0;
$spot["subcata"] = "a5|";
$spot['subcatb'] = '';
コード例 #6
0
ファイル: SpotPage_postspot.php プロジェクト: niel/spotweb
 function render()
 {
     $formMessages = array('errors' => array(), 'info' => array());
     # Validate proper permissions
     $this->_spotSec->fatalPermCheck(SpotSecurity::spotsec_post_spot, '');
     # Sportparser is nodig voor het escapen van de random string
     $spotParser = new SpotParser();
     # spot signing is nodig voor het RSA signen van de spot en dergelijke
     $spotSigning = Services_Signing_Base::newServiceSigning();
     # creeer een default spot zodat het form altijd
     # de waardes van het form kan renderen
     $spot = array('title' => '', 'body' => '', 'category' => 0, 'subcata' => '', 'subcatb' => array(), 'subcatc' => array(), 'subcatd' => array(), 'subcatz' => '', 'tag' => '', 'website' => '', 'newmessageid' => '', 'randomstr' => '');
     # postspot verzoek was standaard niet geprobeerd
     $postResult = array();
     /* 
      * bring the forms' action into the local scope for 
      * easier access
      */
     $formAction = $this->_spotForm['action'];
     # zet de page title
     $this->_pageTitle = "spot: post";
     # Make sure the anonymous user and reserved usernames cannot post content
     $spotUser = new SpotUserSystem($this->_db, $this->_settings);
     if (!$spotUser->allowedToPost($this->_currentSession['user'])) {
         $postResult = array('result' => 'notloggedin');
         $formAction = '';
     }
     # if
     # zorg er voor dat alle variables ingevuld zijn
     $spot = array_merge($spot, $this->_spotForm);
     # If user tried to submit, validate the file uploads
     if ($formAction == 'post') {
         # Make sure an NZB file was provided
         if (!isset($_FILES['newspotform']) || $_FILES['newspotform']['error']['nzbfile'] != UPLOAD_ERR_OK) {
             $formMessages['errors'][] = _('Please select NZB file');
             $postResult = array('result' => 'failure');
             $formAction = '';
         }
         # if
         # Make sure an imgae file was provided
         if (!isset($_FILES['newspotform']) || $_FILES['newspotform']['error']['imagefile'] != UPLOAD_ERR_OK) {
             $formMessages['errors'][] = _('Please select a picture');
             $postResult = array('result' => 'failure');
             $formAction = '';
         }
         # if
         # Make sure the subcategorie are in the proper format
         if (is_array($spot['subcata']) || is_array($spot['subcatz']) || !is_array($spot['subcatb']) || !is_array($spot['subcatc']) || !is_array($spot['subcatd'])) {
             $formMessages['errors'][] = _('Invalid subcategories given ');
             $postResult = array('result' => 'failure');
             $formAction = '';
         }
         # if
     }
     # if
     if ($formAction == 'post') {
         # Notificatiesysteem initialiseren
         $spotsNotifications = new SpotNotifications($this->_db, $this->_settings, $this->_currentSession);
         # en creer een grote lijst met spots
         $spot['subcatlist'] = array_merge(array($spot['subcata']), $spot['subcatb'], $spot['subcatc'], $spot['subcatd']);
         # vraag de users' privatekey op
         $this->_currentSession['user']['privatekey'] = $spotUser->getUserPrivateRsaKey($this->_currentSession['user']['userid']);
         # het messageid krijgen we met <>'s, maar we werken
         # in spotweb altijd zonder, dus die strippen we
         $spot['newmessageid'] = substr($spot['newmessageid'], 1, -1);
         # valideer of we deze spot kunnen posten, en zo ja, doe dat dan
         $spotPosting = new SpotPosting($this->_db, $this->_settings);
         $formMessages['errors'] = $spotPosting->postSpot($this->_currentSession['user'], $spot, $_FILES['newspotform']['tmp_name']['imagefile'], $_FILES['newspotform']['tmp_name']['nzbfile']);
         if (empty($formMessages['errors'])) {
             $postResult = array('result' => 'success', 'user' => $this->_currentSession['user']['username'], 'spotterid' => $spotSigning->calculateSpotterId($this->_currentSession['user']['publickey']), 'body' => $spot['body']);
             $formMessages['info'][] = _('Spot has been successfully uploaded. It can take some time before it is shown');
             # en verstuur een notificatie
             $spotsNotifications->sendSpotPosted($spot);
         } else {
             $postResult = array('result' => 'failure');
         }
         # else
     }
     # if
     #- display stuff -#
     $this->template('newspot', array('postspotform' => $spot, 'formmessages' => $formMessages, 'postresult' => $postResult));
 }