Exemple #1
0
function initialize()
{
    require_once "settings.php";
    $settings = $GLOBALS['settings'];
    # we define some preferences, later these could be
    # user specific or stored in a cookie or something
    $prefs = array('perpage' => 1000);
    if (isset($settings['prefs'])) {
        $prefs = array_merge($prefs, $settings['prefs']);
    }
    # if
    # helper functions for passed variables
    $req = new SpotReq();
    $req->initialize();
    # gather the current page
    $GLOBALS['site']['page'] = $req->getDef('page', 'index');
    if (array_search($GLOBALS['site']['page'], array('index', 'catsjson', 'getnzb', 'getspot')) === false) {
        $GLOBALS['site']['page'] = 'index';
    }
    # if
    # and put them in an encompassing site object
    $GLOBALS['site']['req'] = $req;
    $GLOBALS['site']['settings'] = $settings;
    $GLOBALS['site']['prefs'] = $prefs;
    $GLOBALS['site']['pagetitle'] = 'SpotWeb - ';
}
Exemple #2
0
			$db->addSpot($mappedSpot, $mappedSpot);
		} # while
		$db->commitTransaction();
		
		fclose($fp);
	} 
	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')) {
Exemple #3
0
 /**
  * Instantiate an Request object
  *
  * @param Services_Settings_Container $settings
  * @return SpotReq
  */
 private function getSpotReq(Services_Settings_Container $settings)
 {
     $req = new SpotReq();
     $req->initialize($settings);
     return $req;
 }
Exemple #4
0
}
# 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);
}
# if
$req = new SpotReq();
$req->initialize($settings);
# We willen alleen uitgevoerd worden door een user die dat mag als
# we via de browser aangeroepen worden. Via console halen we altijd
# het admin-account op
$spotUserSystem = new SpotUserSystem($db, $settings);
if (isset($_SERVER['SERVER_PROTOCOL'])) {
    # Vraag de API key op die de gebruiker opgegeven heeft
    $apiKey = $req->getDef('apikey', '');
    $userSession = $spotUserSystem->verifyApi($apiKey);
    if ($userSession == false || !$userSession['security']->allowed(SpotSecurity::spotsec_retrieve_spots, '')) {
        die("Access denied");
    }
    # if
} else {
    $userSession['user'] = $db->getUser(SPOTWEB_ADMIN_USERID);
    $userSession['security'] = new SpotSecurity($db, $settings, $userSession['user']);