Check if the application is actually enabled

This commit is contained in:
Bart Visscher 2011-09-30 23:05:10 +02:00
parent ddd3599899
commit f4782a7690
57 changed files with 80 additions and 4 deletions

View File

@ -20,6 +20,7 @@
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
OC_Util::checkAppEnabled('admin_export');
if (isset($_POST['admin_export'])) {
$root = OC::$SERVERROOT . "/";
$zip = new ZipArchive();

View File

@ -25,6 +25,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
require_once('bookmarksHelper.php');

View File

@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){

View File

@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$params=array(
htmlspecialchars_decode($_GET["url"]),

View File

@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$CONFIG_DBTYPE = OC_Config::getValue( "dbtype", "sqlite" );
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){

View File

@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
// $metadata = array();

View File

@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$query = OC_DB::prepare("
UPDATE *PREFIX*bookmarks

View File

@ -28,6 +28,7 @@ require_once('../../../lib/base.php');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('bookmarks');
$params=array(OC_User::getUser());
$CONFIG_DBTYPE = OC_Config::getValue( 'dbtype', 'sqlite' );

View File

@ -25,6 +25,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('bookmarks');
OC_App::setActiveNavigationEntry( 'bookmarks_index' );

View File

@ -10,6 +10,7 @@ require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['calendarid'];
OC_Calendar_Calendar::setCalendarActive($calendarid, $_POST['active']);
$cal = OC_Calendar_Calendar::findCalendar($calendarid);

View File

@ -10,6 +10,7 @@ require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$currentview = $_GET["v"];
OC_Preferences::setValue(OC_USER::getUser(), "calendar", "currentview", $currentview);
?>

View File

@ -11,6 +11,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$output = new OC_TEMPLATE("calendar", "part.choosecalendar");
$output -> printpage();
?>

View File

@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$userid = OC_User::getUser();
$calendarid = OC_Calendar_Calendar::addCalendar($userid, $_POST['name'], $_POST['description'], 'VEVENT,VTODO,VJOURNAL', null, 0, $_POST['color']);

View File

@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$cal = $_POST["calendarid"];
$calendar = OC_Calendar_Calendar::findCalendar($cal);

View File

@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$id = $_POST['id'];
$data = OC_Calendar_Object::find($id);

View File

@ -11,6 +11,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$calendar = OC_Calendar_Calendar::findCalendar($_GET['calendarid']);
$tmpl = new OC_Template("calendar", "part.editcalendar");
$tmpl->assign('new', false);

View File

@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){

View File

@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);

View File

@ -10,6 +10,7 @@ require_once ("../../../lib/base.php");
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser(), 1);
$events = array();

View File

@ -11,6 +11,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$calendar = array(
'id' => 'new',
'displayname' => 'Test',

View File

@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die("<script type=\"text/javascript\">document.location = oc_webroot;</script>");
}
OC_JSON::checkAppEnabled('calendar');
$errarr = OC_Calendar_Object::validateRequest($_POST);
if($errarr){

View File

@ -13,6 +13,7 @@ $l10n = new OC_L10N('calendar');
if(!OC_USER::isLoggedIn()) {
die('<script type="text/javascript">document.location = oc_webroot;</script>');
}
OC_JSON::checkAppEnabled('calendar');
$calendar_options = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
$category_options = OC_Calendar_Object::getCategoryOptions($l10n);

View File

@ -13,6 +13,7 @@ $l=new OC_L10N('calendar');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
// Get data
if( isset( $_POST['timezone'] ) ){

View File

@ -12,6 +12,7 @@ $l10n = new OC_L10N('calendar');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('calendar');
$calendarid = $_POST['id'];
OC_Calendar_Calendar::editCalendar($calendarid, $_POST['name'], $_POST['description'], null, null, null, $_POST['color']);

View File

@ -10,6 +10,7 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
OC_Util::checkAppEnabled('calendar');
// Backends
$authBackend = new OC_Connector_Sabre_Auth();

View File

@ -8,6 +8,7 @@
require_once ("../../lib/base.php");
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
$cal = $_GET["calid"];
$calendar = OC_Calendar_Calendar::findCalendar($cal);
if($calendar["userid"] != OC_User::getUser()){

View File

@ -8,6 +8,7 @@
require_once ('../../lib/base.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('calendar');
// Create default calendar ...
$calendars = OC_Calendar_Calendar::allCalendars(OC_User::getUser());
if( count($calendars) == 0){

View File

@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$addressbook = OC_Contacts_Addressbook::find( $aid );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){

View File

@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){

View File

@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$addressbook = OC_Contacts_Addressbook::find( $id );
if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){

View File

@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){

View File

@ -31,6 +31,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){

View File

@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );

View File

@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){

View File

@ -27,6 +27,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
$tmpl = new OC_Template('contacts','part.addcardform');

View File

@ -28,6 +28,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){

View File

@ -29,6 +29,7 @@ $l10n = new OC_L10N('contacts');
// Check if we are a user
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('contacts');
$card = OC_Contacts_VCard::find( $id );
if( $card === false ){

View File

@ -24,6 +24,7 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
OC_Util::checkAppEnabled('contacts');
// Backends
$authBackend = new OC_Connector_Sabre_Auth();

View File

@ -29,6 +29,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('contacts');
// Check if the user has an addressbook
$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());

View File

@ -22,6 +22,7 @@
// Init owncloud
require_once('../../lib/base.php');
OC_Util::checkAppEnabled('contacts');
$id = $_GET['id'];

View File

@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$userDirectory = "/".OC_User::getUser()."/files";

View File

@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$source = "/".OC_User::getUser()."/files".$_GET['source'];

View File

@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$userDirectory = "/".OC_User::getUser()."/files";

View File

@ -2,6 +2,7 @@
$RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('files_sharing');
require_once('../lib_share.php');
$source = "/".OC_User::getUser()."/files".$_GET['source'];

View File

@ -4,6 +4,7 @@ $RUNTIME_NOAPPS = true;
require_once('../../../lib/base.php');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('files_sharing');
$users = array();
$ocusers = OC_User::getUsers();

View File

@ -3,6 +3,7 @@ $RUNTIME_NOAPPS=true; //no need to load the apps
$RUNTIME_NOSETUPFS=true; //don't setup the fs yet
require_once '../../lib/base.php';
OC_JSON::checkAppEnabled('files_sharing');
require_once 'lib_share.php';
//get the path of the shared file

View File

@ -24,6 +24,7 @@ require_once('../../lib/base.php');
require_once('lib_share.php');
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('files_sharing');
OC_App::setActiveNavigationEntry("files_sharing_list");

View File

@ -27,6 +27,7 @@ header('Content-type: text/html; charset=UTF-8') ;
$RUNTIME_NOAPPS=true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('media');
require_once('../lib_collection.php');
require_once('../lib_scanner.php');

View File

@ -28,6 +28,7 @@ $RUNTIME_NOAPPS=true;
$RUNTIME_NOSETUPFS=true;
require_once('../../../lib/base.php');
OC_JSON::checkAppEnabled('media');
if(defined("DEBUG") && DEBUG) {error_log($_GET['autoupdate']);}
$autoUpdate=(isset($_GET['autoupdate']) and $_GET['autoupdate']=='true');

View File

@ -26,6 +26,7 @@ require_once('../../lib/base.php');
// Check if we are a user
OC_Util::checkLoggedIn();
OC_Util::checkAppEnabled('media');
require_once('lib_collection.php');
require_once('lib_scanner.php');

View File

@ -23,6 +23,7 @@
require_once('../../../lib/base.php');
OC_Util::checkAppEnabled('media');
require_once('../lib_collection.php');
require_once('../lib_ampache.php');

View File

@ -24,6 +24,7 @@
$_POST=$_GET; //debug
require_once('../../lib/base.php');
OC_JSON::checkAppEnabled('media');
require_once('lib_collection.php');
$user=isset($_POST['user'])?$_POST['user']:'';

View File

@ -30,6 +30,7 @@
$RUNTIME_NOSETUPFS = true;
require_once('../../lib/base.php');
OC_Util::checkAppEnabled('unhosted');
require_once('Sabre/autoload.php');
require_once('lib_unhosted.php');
require_once('oauth_ro_auth.php');

View File

@ -37,6 +37,7 @@ if($USERNAME=='' and isset($_SERVER['PHP_AUTH_USER'])){
$RUNTIME_NOAPPS=true;
$RUNTIME_NOAPPS=false;
require_once '../../lib/base.php';
OC_Util::checkAppEnabled('user_openid');
if(!OC_User::userExists($USERNAME)){
if(defined("DEBUG") && DEBUG) {error_log($USERNAME.' doesn\'t exist');}

View File

@ -19,6 +19,17 @@ class OC_JSON{
}
}
/**
* Check if the app is enabled, send json error msg if not
*/
public static function checkAppEnabled($app){
if( !OC_App::isEnabled($app)){
$l = new OC_L10N('core');
self::error(array( 'data' => array( 'message' => $l->t('Application is not enabled') )));
exit();
}
}
/**
* Check if the user is logged in, send json error msg if not
*/

View File

@ -276,6 +276,16 @@ class OC_Util {
}
/**
* Check if the app is enabled, send json error msg if not
*/
public static function checkAppEnabled($app){
if( !OC_App::isEnabled($app)){
header( 'Location: '.OC_Helper::linkTo( '', 'index.php' , true));
exit();
}
}
/**
* Check if the user is logged in, redirects to home if not
*/

View File

@ -6,6 +6,7 @@ require_once('../../lib/base.php');
$l=new OC_L10N('settings');
OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('user_openid');
// Get data
if( isset( $_POST['identity'] ) ){