__construct() public method

public __construct ( )
Exemplo n.º 1
0
 function __construct()
 {
     /* Since parent constructors are not called implicitly if */
     /* the child class defines a constructor we simpley call it */
     /* here to inherit the parent's methods and bad habits. */
     parent::__construct();
 }
Exemplo n.º 2
0
 public function __construct($request, $origin)
 {
     $this->config = (include 'config.php');
     $this->initDB();
     $this->sanitizeHTTPParameters();
     parent::__construct($request);
 }
Exemplo n.º 3
0
 public function __construct($request)
 {
     parent::__construct($request);
     // Grab the uid from Webauth, API Key lookup, etc
     if (array_key_exists("WEBAUTH_USER", $_SERVER)) {
         $this->uid = htmlentities($_SERVER["WEBAUTH_USER"]);
         $this->webauth = true;
     } else {
         if ($this->api_key) {
             $this->uid = $this->_lookupUser($this->api_key);
             $this->webauth = false;
         } else {
             if (DEBUG) {
                 $this->uid = DEBUG_USER_UID;
                 $this->webauth = true;
             } else {
                 $this->uid = false;
                 $this->webauth = false;
             }
         }
     }
     // Check if the user is a drink admin
     if ($this->uid != false) {
         $this->admin = $this->_isAdmin($this->uid);
     }
 }
Exemplo n.º 4
0
 public function __construct()
 {
     parent::__construct(get_class(), 'robotpony-4.1');
     $this->root = realpath(dirname(__FILE__) . '/db/');
     $this->newest = $this->root . '/newest.json';
     $this->listing = $this->root . '/comics.json';
     // other startup here
 }
Exemplo n.º 5
0
 public function __construct()
 {
     parent::__construct(get_class(), 'robotpony-4.1');
     $this->root = realpath(dirname(__FILE__) . '/pages/') . '/';
     $this->inc = realpath(dirname(__FILE__) . '/lib/') . '/';
     Response::add_type_handler('text/plain', function ($dom) {
         print json_encode($dom);
     });
 }
Exemplo n.º 6
0
 function __construct()
 {
     parent::__construct();
     $this->ca = CAHandler::getCA($this->person);
     $perm = $this->person->mayRequestCertificate();
     if (!$perm->isPermissionGranted()) {
         $this->errorNotAuthorized($perm);
     }
 }
Exemplo n.º 7
0
 public function __construct($request)
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     $this->loadConfig();
     $this->initDB();
     $this->sanitizeHTTPParameters();
     parent::__construct($request);
 }
Exemplo n.º 8
0
 public function __construct($action, $params)
 {
     parent::__construct($action, $params);
     //check if the action is available for the resource
     if (!method_exists($this, $action)) {
         HTTP::response('404');
     }
     //call the action on the resource
     $this->{$action}($params);
 }
Exemplo n.º 9
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     // Abstracted out for example
     //@todo: should create apiKey class to provide functionality to create apiKey
     /* if (!array_key_exists('apiKey', $this->request)) {
            throw new Exception('No API Key provided');
        } else if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
            throw new Exception('Invalid API Key');
        }*/
 }
Exemplo n.º 10
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     //Check if token present in the header
     if (!array_key_exists('Token', $this->headers) && $request != 'get_token') {
         throw new Exception('No API Token provided');
     }
     //Authenticate Token
     if (!in_array($this->headers['Token'], $_SESSION) && $request != 'get_token') {
         throw new Exception('Expired or Invalid API Token');
     }
 }
Exemplo n.º 11
0
 public function __construct($request)
 {
     $this->loadConfig();
     $this->initDB();
     if ($this->isValidWorker() == false) {
         echo "Not valid worker";
         exit(1);
     } else {
         $this->insert("UPDATE Worker SET lastRequestTime = now() WHERE apiKey = {$this->apiKey}");
     }
     parent::__construct($request);
 }
Exemplo n.º 12
0
 public function __construct($request, $origin)
 {
     // call parent constructor
     parent::__construct($request);
     $Users = new Users();
     $PersonalEmail = new PersonalEmail();
     $GlobalEmail = new GlobalEmail();
     $Notifications = new Notifications();
     $this->Users = $Users;
     $this->PersonalEmail = $PersonalEmail;
     $this->GlobalEmail = $GlobalEmail;
     $this->Notifications = $Notifications;
 }
Exemplo n.º 13
0
 function __construct()
 {
     parent::__construct();
     $this->auth_dir = $this->get_output_dir('flickr/auth');
     $this->frobfile = $this->auth_dir . '/frob.txt';
     $this->tokenfile = $this->auth_dir . '/token.txt';
     // warning: stored in libapi data dir - should store locally, or set read permissions?
     if (file_exists($this->tokenfile)) {
         $this->token = file_get_contents($this->tokenfile);
     }
     if (!$this->token) {
         $this->get_token();
     }
 }
Exemplo n.º 14
0
 /**
  * Constructor: __construct
  * Call parent construct and connect to database
  */
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     try {
         $servername = "localhost";
         $username = "******";
         $password = "******";
         $myDB = "restapi-assignment";
         $this->conn = new PDO("mysql:host={$servername};dbname={$myDB}", $username, $password);
         $this->conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         echo json_encode(array('error' => $e->getMessage()));
     }
 }
Exemplo n.º 15
0
 public function __construct($configuration_file_name)
 {
     if (PHP_SAPI == 'cli') {
         global $argv;
         parent::__construct(API::FRONTEND_FASTCGI);
     } else {
         parent::__construct(API::FRONTEND_BASIC);
     }
     $this->initializeConfiguration($configuration_file_name);
     if (method_exists($this, 'routeMap')) {
         parent::registerCommonRequestHandler($this, 'initializeDynamicRouteTable');
     }
     // Left for compatibility
     $this->sd = $this->ats = $this;
 }
Exemplo n.º 16
0
 public function __construct($request)
 {
     parent::__construct($request);
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip_add = $_SERVER['HTTP_CLIENT_IP'];
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip_add = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } else {
         $ip_add = $_SERVER['REMOTE_ADDR'];
     }
     $this->ip_add = $ip_add;
     $this->origin = $origin;
     //test
     $this->net_scanner = new networkscanner($ip_add, 50550, 55555000);
 }
Exemplo n.º 17
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     // Abstracted out for example
     $APIKey = new Models\APIKey();
     $User = new Models\User();
     if (!array_key_exists('apiKey', $this->request)) {
         throw new Exception('No API Key provided');
     } elseif (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
         throw new Exception('Invalid API Key');
     } elseif (array_key_exists('token', $this->request) && !$User->get('token', $this->request['token'])) {
         throw new Exception('Invalid User Token');
     }
     $this->User = $User;
 }
Exemplo n.º 18
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     //Authentication
     // $APIKey = new Models\APIKey();
     // $User = new Models\User();
     // if (!array_key_exists('apiKey', $this->request)) {
     //     throw new Exception('No API Key provided');
     // } //else if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
     //     throw new Exception('Invalid API Key');
     // } else if (array_key_exists('token', $this->request) && !$User->get('token', $this->request['token'])) {
     //     throw new Exception('Invalid User Token');
     // }
     $this->User = true;
 }
Exemplo n.º 19
0
 /**
  * Constructeur de la classe Eggstar.
  * Vérifie la présence d'une clé d'API valide dans le cas où il ne s'agit pas d'une authentification.
  * De fait, on ne peut pas demander de clé d'API à quelqu'un qui cherche à s'authentifier.
  * @author Alban Truc
  * @param array $request Tableau contenant la requête.
  * @param array $origin Permet d'identifier l'origine de la requête, pour l'instant inutilisé.
  * @since 19/02/2014
  * @throws Exception
  */
 public function __construct($request, $origin)
 {
     //Pour s'assurer que les lourds fichiers ne dépassent pas la limitation de mémoire.
     ini_set("memory_limit", '0');
     //Appelle le constructeur de la classe API
     parent::__construct($request);
     if ($this->endpoint != 'users' || $this->endpoint == 'users' && $this->method != 'GET') {
         if (!array_key_exists('apiKey', $this->request)) {
             throw new Exception('No API Key provided');
         } else {
             if ($this->verifyKey($this->request['apiKey']) !== TRUE) {
                 throw new Exception('Invalid API Key');
             }
         }
     }
 }
Exemplo n.º 20
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     // Example of how to include users and keys. Need to make the models.
     // $APIKey = new Models\APIKey();
     // $User = new Models\User();
     // if (!array_key_exists('apiKey', $this->request)) {
     //   throw new Exception('No API Key provided');
     // } else if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
     //   throw new Exception('Invalid API Key');
     // } else if (array_key_exists('token', $this->request) &&
     //   !$User->get('token', $this->request['token'])) {
     //   throw new Exception('Invalid User Token');
     // }
     // $this->User = $User;
 }
Exemplo n.º 21
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     //$User = new User($request);
     // if (!array_key_exists('key', $this->request)) {
     //   throw new Exception('No API Key provided');
     // } else {
     //   $APIKey = new APIKey();
     //   $authresult = $APIKey->verifyKey($this->request['key'], $origin);
     //   if ( is_string($authresult) ) {
     //     throw new Exception('Authorization failed: '.$authresult);
     //   }
     //} else if (array_key_exists('token', $this->request) && !$User->get('token', $this->request['token'])) {
     //throw new Exception('Invalid User Token');
     //}
     //$this->User = $User;
 }
Exemplo n.º 22
0
 public function __construct($request_uri, $postData, $origin)
 {
     parent::__construct($request_uri, $postData);
     $this->db = new ConDB();
     // Abstracted out for example
     //        $APIKey = new Models/APIKey();
     //        $User = new Models/User();
     //
     //        if (!array_key_exists('apiKey', $this->request)) {
     //            throw new Exception('No API Key provided');
     //        } else if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
     //            throw new Exception('Invalid API Key');
     //        } else if (array_key_exists('token', $this->request) &&
     //                !$User->get('token', $this->request['token']))
     //            throw new Exception('Invalid User Token');
     //
     //        $this->User = $User;
 }
Exemplo n.º 23
0
 function __construct($request, $origin)
 {
     parent::__construct($request);
     $this->APIkey = "1234";
     $this->User = "******";
     if (!array_key_exists('apiKey', $this->request)) {
         throw new Exception('No API Key provided');
     } else {
         if ($this->request['apiKey'] != '1234') {
             throw new Exception("Invalid API key");
         } else {
             if (array_key_exists($token, $this->request) && 'User-Token-1234' != 'User-Token-12345') {
                 throw new Exception("Invalid User Token");
             }
         }
     }
     return $this->User;
 }
Exemplo n.º 24
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     $this->session = new SESSION($this->endpoint);
     switch ($this->endpoint) {
         case 'user':
             $this->action = new USER($this->endpoint);
             break;
         case 'module':
             $this->action = new MODULE($this->endpoint);
             break;
         case 'action':
             $this->action = new ACTION($this->endpoint);
             break;
         default:
             break;
     }
     //Bearer token validation, maybe
 }
Exemplo n.º 25
0
 public function __construct($request = null, $origin = null)
 {
     parent::__construct($request);
     // if not local check credentials
     if (!empty($_SESSION['localREST'])) {
         $APIKey = new API_Key();
         if (!array_key_exists('apiKey', $this->request)) {
             throw new Exception('No API Key provided');
         } else {
             if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
                 throw new Exception('Invalid API Key');
             } else {
                 if (array_key_exists('token', $this->request) && !$User->get('token', $this->request['token'])) {
                     throw new Exception('Invalid User Token');
                 }
             }
         }
     }
 }
Exemplo n.º 26
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     // Abstracted out for example
     $APIKey = new apiKey();
     $user = new neurologUser();
     switch (true) {
         case !array_key_exists('apiKey', $this->request):
             t_e('neurolog API: No API Key provided');
             throw new Exception('No API Key provided');
         case !$APIKey->verifyKey($this->request['apiKey'], $origin):
             t_e('neurolog API: Invalid API Key =' . $this->request['apiKey']);
             throw new Exception('Invalid API Key');
         case array_key_exists('token', $this->request) && !$user->verifyUserByHash($this->request['token']):
             t_e('neurolog API: Invalid User Token =' . $this->request['token']);
             throw new Exception('Invalid User Token');
         default:
             $this->user = $user;
     }
 }
Exemplo n.º 27
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     // Abstracted out for example
     $APIKey = new APIKey();
     $User = new User($this->verb);
     if (!array_key_exists('apiKey', $this->request)) {
         throw new Exception('No API Key provided');
     } else {
         if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
             throw new Exception('Invalid API Key');
         } else {
             if (array_key_exists('token', $this->request) && !$User->get('token', $this->request['token'])) {
                 throw new Exception('Invalid User Token');
             }
         }
     }
     $this->User = $User;
     $this->obj_db = new PichannelDatabase();
     $this->s_host_domain = $this->obj_db->getDomainName();
 }
Exemplo n.º 28
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     //$APIKey = new Models\APIKey();
     //$User = new Models\User();
     //if (!array_key_exists('apiKey', $this->request)) {
     //   throw new Exception('No API Key provided');
     //} else if (!$APIKey->verifyKey($this->request['apiKey'], $origin)) {
     //   throw new Exception('Invalid API Key');
     //} else if (array_key_exists('token', $this->request) &&
     //    !$User->get('token', $this->request['token'])) {
     // throw new Exception('Invalid User Token');
     //}
     //$this->User = $User;
     $this->fname = "";
     $this->lname = "";
     $this->email = "";
     $this->phone = "";
     $this->rideid = "";
     $this->ridedate = "";
     $this->ridetime = "";
 }
Exemplo n.º 29
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
 }
Exemplo n.º 30
0
 public function __construct($request, $origin)
 {
     parent::__construct($request);
     // Add authentication, model initialization, etc here
 }