Beispiel #1
0
 public static function singleton(SpotDb $db, array $phpSettings)
 {
     if (self::$_instance === null) {
         self::$_instance = new SpotSettings($db);
         # maak de array met PHP settings beschikbaar in de klasse
         self::$_phpSettings = $phpSettings;
         # haal alle settings op, en prepareer die
         self::$_dbSettings = $db->getAllSettings();
         # en merge de settings met degene die we door krijgen
         self::$_settings = array_merge(self::$_dbSettings, self::$_phpSettings);
         # Override NNTP header/comments settings, als er geen aparte NNTP header/comments server is opgegeven, gebruik die van
         # de NZB server
         if (empty(self::$_settings['nntp_hdr']['host']) && !empty(self::$_settings['nntp_nzb'])) {
             self::$_settings['nntp_hdr'] = self::$_settings['nntp_nzb'];
         }
         # if
         # Hetzelfde voor de NNTP upload server
         if (empty(self::$_settings['nntp_post']['host']) && !empty(self::$_settings['nntp_nzb'])) {
             self::$_settings['nntp_post'] = self::$_settings['nntp_nzb'];
         }
         # if
     }
     # if
     return self::$_instance;
 }
 function render()
 {
     try {
         $db = new SpotDb($this->_settings['db']);
         $db->connect();
     } catch (Exception $x) {
         die("Unable to connect to database: " . $x->getMessage() . PHP_EOL);
     }
     # catch
     $_SESSION['last_visit'] = $db->getMaxMessageTime();
     echo "<xml><return>ok</return></xml>";
 }
Beispiel #3
0
	public static function singleton(SpotDb $db, array $settings) {
		if (self::$_instance === null) {
			self::$_instance = new SpotSettings($db);
			
			# haal alle settings op, en prepareer die 
			$dbSettings = $db->getAllSettings();

			# en merge de settings met degene die we door krijgen 
			self::$_settings = array_merge($settings, $dbSettings);
		} # if
		
		return self::$_instance;
	} # singleton
Beispiel #4
0
 public static function singleton(SpotDb $db, array $phpSettings)
 {
     if (self::$_instance === null) {
         self::$_instance = new SpotSettings($db);
         # maak de array met PHP settings beschikbaar in de klasse
         self::$_phpSettings = $phpSettings;
         # haal alle settings op, en prepareer die
         self::$_dbSettings = $db->getAllSettings();
         # en merge de settings met degene die we door krijgen
         self::$_settings = array_merge(self::$_phpSettings, self::$_dbSettings);
     }
     # if
     return self::$_instance;
 }
Beispiel #5
0
function openDb()
{
    extract($GLOBALS['site'], EXTR_REFS);
    # fireup the database
    try {
        $db = new SpotDb($settings['db']);
        $db->connect();
    } catch (Exception $x) {
        die('Unable to open database: ' . $x->getMessage());
    }
    # catch
    $GLOBALS['site']['db'] = $db;
    return $db;
}
Beispiel #6
0
 function __construct(SpotDb $db, SpotSettings $settings, array $user)
 {
     $this->_db = $db;
     $this->_user = $user;
     $this->_settings = $settings;
     $this->_permissions = $db->getPermissions($user['userid']);
 }
Beispiel #7
0
	catch(Exception $x) {
		die("Error importing data: " . $x->getMessage() . PHP_EOL);
	} # catch
	
	exit;
} # import

$req = new SpotReq();
$req->initialize();

if ($req->getDef('output', '') == 'xml') {
	echo "<xml>";
} # if

try {
	$db = new SpotDb($settings['db']);
	$db->connect();
} 
catch(Exception $x) {
	die("Unable to connect to database: " . $x->getMessage() . PHP_EOL);
} # catch

## Als we forceren om de "already running" check te bypassen, doe dat dan
if ((isset($argc)) && ($argc > 1) && ($argv[1] == '--force')) {
	$db->setRetrieverRunning($settings['nntp_hdr']['host'], false);
} # if

## Spots
try {

	$retriever = new SpotRetriever_Spots($settings['nntp_hdr'], 
Beispiel #8
0
 public function __construct(SpotDb $spotdb)
 {
     $this->_spotdb = $spotdb;
     $this->_dbcon = $spotdb->getDbHandle();
 }
Beispiel #9
0
function createSystem()
{
    global $settings;
    global $_testInstall_Ok;
    try {
        /*
         * The settings system is used to create a lot of output,
         * we swallow it all
         */
        ob_start();
        /*
         * Now create the database ...
         */
        $settings['db'] = $_SESSION['spotsettings']['db'];
        $spotUpgrader = new SpotUpgrader($settings['db'], $settings);
        $spotUpgrader->database();
        /*
         * and create all the different settings (only the default) ones
         */
        $spotUpgrader->settings();
        /*
         * Create the users
         */
        $spotUpgrader->users();
        /*
         * print all the output as HTML comment for debugging
         */
        $dbCreateOutput = ob_get_contents();
        ob_end_clean();
        /*
         * Now it is time to do something with
         * the information the user has given to us
         */
        $db = new SpotDb($_SESSION['spotsettings']['db']);
        $db->connect();
        /* 
         * add the database settings to the main settings array for now
         */
        $settings['db'] = $_SESSION['spotsettings']['db'];
        /* and create the database settings */
        $spotSettings = SpotSettings::singleton($db, $settings);
        /*
         * Update the NNTP settings in the databas
         */
        $spotSettings->set('nntp_nzb', $_SESSION['spotsettings']['nntp']['nzb']);
        $spotSettings->set('nntp_hdr', $_SESSION['spotsettings']['nntp']['hdr']);
        $spotSettings->set('nntp_post', $_SESSION['spotsettings']['nntp']['post']);
        /*
         * Create the given user
         */
        $spotUserSystem = new SpotUserSystem($db, $spotSettings);
        $spotUser = $_SESSION['spotsettings']['adminuser'];
        /*
         * Create a private/public key pair for this user
         */
        $spotSigning = Services_Signing_Base::newServiceSigning();
        $userKey = $spotSigning->createPrivateKey($spotSettings->get('openssl_cnf_path'));
        $spotUser['publickey'] = $userKey['public'];
        $spotUser['privatekey'] = $userKey['private'];
        /*
         * and actually add the user
         */
        $userId = $spotUserSystem->addUser($spotUser);
        # Change the administrators' account password to that of this created user
        $adminUser = $spotUserSystem->getUser(SPOTWEB_ADMIN_USERID);
        $adminUser['newpassword1'] = $spotUser['newpassword1'];
        $spotUserSystem->setUserPassword($adminUser);
        # update the settings with our system type and our admin id
        $spotSettings->set('custom_admin_userid', $userId);
        $spotSettings->set('systemtype', $spotUser['systemtype']);
        # Set the system type
        $spotUpgrader->resetSystemType($spotUser['systemtype']);
        /* 
         * Create the necessary database connection information
         */
        $dbConnectionString = '';
        switch ($_SESSION['spotsettings']['db']['engine']) {
            case 'mysql':
                $dbConnectionString .= "\$dbsettings['engine'] = 'mysql';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['host'] = '" . $_SESSION['spotsettings']['db']['host'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['dbname'] = '" . $_SESSION['spotsettings']['db']['dbname'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['user'] = '******'spotsettings']['db']['user'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['pass'] = '******'spotsettings']['db']['pass'] . "';" . PHP_EOL;
                break;
                # mysql
            # mysql
            case 'postgresql':
                $dbConnectionString .= "\$dbsettings['engine'] = 'pdo_pgsql';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['host'] = '" . $_SESSION['spotsettings']['db']['host'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['dbname'] = '" . $_SESSION['spotsettings']['db']['dbname'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['user'] = '******'spotsettings']['db']['user'] . "';" . PHP_EOL;
                $dbConnectionString .= "\$dbsettings['pass'] = '******'spotsettings']['db']['pass'] . "';" . PHP_EOL;
                break;
                # postgresql
        }
        # switch
        # Try to create the dbsettings.inc.php file for the user
        @file_put_contents("dbsettings.inc.php", "<?php" . PHP_EOL . $dbConnectionString);
        $createdDbSettings = file_exists("dbsettings.inc.php");
        ?>

			<table summary="PHP settings">
				<tr> <th colspan='2'> Installation succesful </th> </tr>
				<tr> <td colspan='2'> Spotweb has been installed succesfuly! </td> </tr>
				<tr> <td colspan='2'> &nbsp; </td> </tr>
<?php 
        if (!$createdDbSettings) {
            ?>
				<tr> 
						<td> &rarr; </td>
						<td> 
								You need to create a textfile with the database settings in it. Please copy & paste the below
							exactly in a file called <i>dbsettings.inc.php</i>.
							<pre><?php 
            echo "&lt;?php " . PHP_EOL . $dbConnectionString;
            ?>
							</pre>
				 		</td> 
				</tr>
<?php 
        }
        ?>
				<tr> 
						<td> &rarr; </td>
						<td> 
							Spotweb retrieves its information from the newsservers, this is called "retrieving" or retrieval of Spots.
							You need to schedule a retrieval job to run <i>retrieve.php</i> on a regular basis. The first time retrieval
							is run this can take up to several hours before completion.
				 		</td> 
				</tr>
			</table>

			<?php 
        echo '<!-- ' . $dbCreateOutput . ' -->';
    } catch (Exception $x) {
        ?>
			<div id='error'><?php 
        echo $x->getMessage();
        ?>
				<?php 
        echo $x->getTraceAsString();
        ?>
			<br /><br />
			</div>
	<?php 
    }
    # exception
}
Beispiel #10
0
<?php

require_once "settings.php";
require_once "lib/SpotDb.php";
try {
    $db = new SpotDb($settings['db']);
    $db->connect();
} catch (Exception $x) {
    die("Unable to connect to database: " . $x->getMessage() . PHP_EOL);
}
# catch
if (empty($_SESSION['last_visit'])) {
    if (!isset($_COOKIE['last_visit'])) {
        $_SESSION['last_visit'] = $db->getMaxMessageTime();
    } else {
        $_SESSION['last_visit'] = $_COOKIE['last_visit'];
    }
    # else
}
# if
// set cookie
setcookie('last_visit', $db->getMaxMessageTime(), time() + 86400 * $settings['cookie_expires'], '/', $settings['cookie_host']);
Beispiel #11
0
}
# if
require_once "lib/SpotClassAutoload.php";
require_once "settings.php";
require_once "lib/SpotTiming.php";
require_once "lib/exceptions/ParseSpotXmlException.php";
require_once "lib/exceptions/NntpException.php";
# disable timing, met alle queries die er draaien loopt dat  uit op een hele grote memory usage
SpotTiming::disable();
# in safe mode, max execution time cannot be set, warn the user
if (ini_get('safe_mode')) {
    echo "WARNING: PHP safemode is enabled, maximum execution cannot be reset! Turn off safemode if this causes problems" . PHP_EOL . PHP_EOL;
}
# if
try {
    $db = new SpotDb($settings['db']);
    $db->connect();
} catch (Exception $x) {
    die("Unable to connect to database: " . $x->getMessage() . PHP_EOL);
}
# catch
# Controleer dat we niet een schema upgrade verwachten
if (!$db->schemaValid()) {
    die("Database schema is gewijzigd, draai upgrade-db.php aub" . PHP_EOL);
}
# if
# Creer het settings object
$settings = SpotSettings::singleton($db, $settings);
# Controleer eerst of de settings versie nog wel geldig zijn
if (!$settings->settingsValid()) {
    die("Globale settings zijn gewijzigd, draai upgrade-db.php aub" . PHP_EOL);
Beispiel #12
0
/*
 * disable timing, all queries which are ran by retrieve this would make it use
 * large amounts of memory
 */
SpotTiming::disable();
# Initialize commandline arguments
SpotCommandline::initialize(array('force', 'debug', 'retro'), array('force' => false, 'debug' => false, 'retro' => false));
# Initialize translation to english
SpotTranslation::initialize('en_US');
# in safe mode, max execution time cannot be set, warn the user
if (ini_get('safe_mode')) {
    echo "WARNING: PHP safemode is enabled, maximum execution cannot be reset! Turn off safemode if this causes problems" . PHP_EOL . PHP_EOL;
}
# if
try {
    $db = new SpotDb($settings['db']);
    $db->connect();
} catch (DatabaseConnectionException $x) {
    die("Unable to connect to database: " . $x->getMessage() . PHP_EOL);
}
# catch
# Creer het settings object
$settings = SpotSettings::singleton($db, $settings);
# Controleer dat we niet een schema upgrade verwachten
if (!$settings->schemaValid()) {
    die("Database schema has been changed, please run upgrade-db.php" . PHP_EOL);
}
# if
# Controleer eerst of de settings versie nog wel geldig zijn
if (!$settings->settingsValid()) {
    die("Global settings have been changed, please run upgrade-db.php" . PHP_EOL);
Beispiel #13
0
require_once "lib/SpotCookie.php";
require_once "lib/page/SpotPage_index.php";
require_once "lib/page/SpotPage_getnzb.php";
require_once "lib/page/SpotPage_getnzbmobile.php";
require_once "lib/page/SpotPage_getspot.php";
require_once "lib/page/SpotPage_catsjson.php";
require_once "lib/page/SpotPage_erasedls.php";
require_once "lib/page/SpotPage_getimage.php";
require_once "lib/page/SpotPage_getspotmobile.php";
require_once "lib/page/SpotPage_markallasread.php";
require_once "lib/page/SpotPage_getimage.php";
require_once "lib/page/SpotPage_selecttemplate.php";
#- main() -#
try {
    # database object
    $db = new SpotDb($settings['db']);
    $db->connect();
    # helper functions for passed variables
    $req = new SpotReq();
    $req->initialize();
    $page = $req->getDef('page', 'index');
    if (array_search($page, array('index', 'catsjson', 'getnzb', 'getnzbmobile', 'getspotmobile', 'getspot', 'erasedls', 'markallasread', 'getimage', 'selecttemplate')) === false) {
        $page = 'index';
    }
    # if
    switch ($page) {
        case 'getspot':
            $page = new SpotPage_getspot($db, $settings, $settings['prefs'], $req->getDef('messageid', ''));
            $page->render();
            break;
            # getspot
Beispiel #14
0
if (ini_get('safe_mode')) {
    echo "WARNING: PHP safemode is enabled, maximum execution cannot be reset! Turn off safemode if this causes problems\r\n\r\n";
}
# if
if (!isset($settings['retrieve_increment'])) {
    echo "WARNING: Parameter retrieve_increment is missing in settings.php, please add and run again.";
    die;
}
$req = new SpotReq();
$req->initialize();
if ($req->getDef('output', '') == 'xml') {
    echo "<xml>";
}
# if
try {
    $db = new SpotDb($settings['db']);
    $db->connect();
} catch (Exception $x) {
    die("Unable to connect to database: " . $x->getMessage() . "\r\n");
}
# catch
## Als we forceren om de "already running" check te bypassen, doe dat dan
if ($argc > 1 && $argv[1] == '--force') {
    $db->setRetrieverRunning($settings['nntp_hdr']['host'], false);
}
# if
## Spots
try {
    $curMsg = $db->getMaxArticleId($settings['nntp_hdr']['host']);
    $retriever = new SpotRetriever_Spots($settings['nntp_hdr'], $db, $settings['rsa_keys'], $req->getDef('output', ''));
    $msgdata = $retriever->connect($settings['hdr_group']);
Beispiel #15
0
 function __construct(SpotDb $db, SpotSettings $settings, array $user, $ipaddr)
 {
     $this->_db = $db;
     $this->_user = $user;
     $this->_settings = $settings;
     $this->_failAudit = $settings->get('auditlevel') == SpotSecurity::spot_secaudit_failure;
     $this->_allAudit = $settings->get('auditlevel') == SpotSecurity::spot_secaudit_all;
     if ($this->_failAudit || $this->_allAudit) {
         $this->_spotAudit = new SpotAudit($db, $settings, $user, $ipaddr);
     }
     # if
     $this->_permissions = $db->getPermissions($user['userid']);
 }
Beispiel #16
0
<?php

error_reporting(E_ALL & ~8192 & ~E_USER_WARNING);
# 8192 == E_DEPRECATED maar PHP < 5.3 heeft die niet
require_once "lib/SpotClassAutoload.php";
#- main() -
require_once "settings.php";
# database object
$db = new SpotDb($settings['db']);
$db->connect();
$db->getDbHandle()->rawExec("DELETE FROM filters WHERE userid <> 1");
$userList = $db->listUsers("", 0, 9999999);
# loop through every user and fix it
foreach ($userList['list'] as $user) {
    if ($user['userid'] != 1) {
        $db->copyFilterList(1, $user['userid']);
    }
    # if
}
# foreach