File: testPost.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (60 lines) | stat: -rwxr-xr-x 2,005 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
require_once "lib/SpotClassAutoload.php";
require_once "lib/SpotParser.php";
require_once "lib/SpotPosting.php";
require_once "lib/SpotCategories.php";
require_once "lib/SpotSigning.php";
require_once "lib/SpotSeclibToOpenSsl.php";
require_once "lib/SpotNntp.php";
require_once "NNTP/Protocol/Client.php";
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'] = '';
$spot['subcatc'] = '';
$spot['subcatd'] = 'd30|';
$spot['subcatz'] = 'z2|';
echo "Generating hash.." . PHP_EOL;
$spot['newmessageid'] = substr($spotSigning->makeExpensiveHash('<' . $spotSigning->makeRandomStr(15), '@spot.net>'), 1, -1);
echo "Hash generated.." . PHP_EOL;

$user = $spotUserSystem->getUser(USERID);
$user['privatekey'] = $db->getUserPrivateRsaKey($user['userid']);
echo "Posting spot... " . PHP_EOL;
var_dump($spotPosting->postSpot($user, $spot, 'tests/test.jpg', 'tests/test.nzb'));