Exemplo n.º 1
0
 public function createEvent($event_name, $event_date, $startTime, $endTime)
 {
     $eventName = InputValidator::validate_input($event_name);
     $error = "";
     if ($event_name == NULL) {
         $error .= "@1Event name cannot be empty! ";
     }
     if ($event_date == NULL) {
         $error .= "@2Event date must be specified correctly (YYYY-MM-DD)! ";
     }
     if ($startTime == NULL) {
         $error .= "@3Event start time must be specified correctly (HH:MM)! ";
     }
     if ($endTime == NULL) {
         $error .= "@4Event end time must be specified correctly (HH:MM)!";
     }
     if ($endTime != NULL && $startTime >= $endTime) {
         $error .= "@4Event end time cannot be before event start time!";
     }
     if ($event_name == NULL || $event_date == NULL || $startTime >= $endTime || $startTime == NULL || $endTime == NULL) {
         throw new Exception(trim($error));
     } else {
         //2. load all data
         $pm = new PersistenceEventRegistration();
         $rm = $pm->loadDataFromStore();
         //3 Add event
         $event = new Event($eventName, $event_date, $startTime, $endTime);
         $rm->addEvent($event);
         //4 Write all of the data
         $pm->writeDataToStore($rm);
     }
 }
Exemplo n.º 2
0
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->m_sGebruikersNaam = '';
     $this->m_sWachtwoord = '';
     $this->m_bLoggedIn = false;
     $this->m_aRechten = array();
     // controleer of gebruiker al is ingelogd
     $oValidator = InputValidator::instantiate();
     $oValidator->addValidation('gebruiker_id', InputValidator::SCOPE_SESSION, InputValidator::TYPE_INT, true);
     $oValidator->addValidation('gebruiker', InputValidator::SCOPE_SESSION, InputValidator::TYPE_STRING, true);
     $oValidator->addValidation('ingelogd', InputValidator::SCOPE_SESSION, InputValidator::TYPE_BOOLEAN, true);
     $oValidator->addValidation('rechten', InputValidator::SCOPE_SESSION, InputValidator::TYPE_ARRAY, true);
     if ($oValidator->ValidateAll() == InputValidator::RESULT_OK) {
         $this->m_nId = $oValidator->getValue('gebruiker_id', InputValidator::SCOPE_SESSION);
         if ($this->m_nId > 0) {
             $this->m_sGebruikersNaam = $oValidator->getValue('gebruiker', InputValidator::SCOPE_SESSION);
             $this->m_bLoggedIn = $oValidator->getValue('ingelogd', InputValidator::SCOPE_SESSION);
             $this->m_aRechten = $oValidator->getValue('rechten', InputValidator::SCOPE_SESSION);
             // haal de persoongegevens op
             $this->laadGegevens($this->m_nId);
         }
     }
     // leeg de lijst met validatie variabelen zodat validator schoon gebruik kan worden
     $oValidator->clearValidation();
 }
 /**
  * Returns the quantity unit.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @api
  * @param String $locale The localization.
  * @return String Gets the quantity unit.
  */
 public function getQuantityUnit($locale)
 {
     if (!InputValidator::isLocale($locale)) {
         return;
     }
     return !InputValidator::isEmptyArrayKey($this->quantityUnit, $locale) ? $this->quantityUnit[$locale] : null;
 }
Exemplo n.º 4
0
 /**
  * Activate specific FormatterTypes.
  *
  * @param FormatterType The FormatterType which should be added.
  * @since 0.2.0
  **/
 public function add($formatterType)
 {
     if (!InputValidator::isFormatterType($formatterType)) {
         return;
     }
     array_push($this->usedFormatters, $formatterType);
 }
Exemplo n.º 5
0
 /**
  * handlePagina	controleer of er inloggegevens zijn gepost, zo ja, log in en redirect naar homepage
  * @throws WebsiteException
  */
 public function handlePagina()
 {
     // standaard wordt dit scherm getoond
     $oResult = $this;
     if (Registry::exists('Bezoeker')) {
         $oGebruiker = Registry::get('Bezoeker');
     } else {
         // gebruiker moet al bestaan, dus fout
         throw new WebsiteException('Gebruiker object bestaat niet');
     }
     if (!$oGebruiker->isIngelogd()) {
         // gebruiker was nog niet ingelogd
         $oValidator = InputValidator::instantiate();
         $oValidator->addValidation('gebruiker', InputValidator::SCOPE_POST, InputValidator::TYPE_STRING, true);
         $oValidator->addValidation('wachtwoord', InputValidator::SCOPE_POST, InputValidator::TYPE_STRING, true);
         if ($oValidator->validateAll() == InputValidator::RESULT_OK) {
             // inloggegevens gepost
             if ($oGebruiker->login($oValidator->getValue('gebruiker', InputValidator::SCOPE_POST), $oValidator->getValue('wachtwoord', InputValidator::SCOPE_POST))) {
                 // login gelukt
                 $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::BEHEER);
             }
         }
     } else {
         // gebruiker was al eerder ingelogd, ga naar homepage
         $oResult = SchermGenerator::genereerSchermObject(SchermGenerator::BEHEER);
     }
     return $oResult;
 }
 /**
  * instantiate Deze method wordt gebruikt om het InputValidator object te instantieren
  * @return InputValidator Object
  */
 public static function instantiate()
 {
     if (self::$s_oInstance == null) {
         // er is nog geen instantie, creeer er een
         self::$s_oInstance = new InputValidator();
     }
     return self::$s_oInstance;
 }
 /**
  * Sets an occured error.
  *
  * @author David Pauli <*****@*****.**>
  * @param String $errorNumber The error number to set.
  * @return True if the error number is valid, false if not.
  * @since 0.1.2
  */
 private static function errorSet($errorNumber)
 {
     // if the parameter is empty or not a defined error number.
     if (InputValidator::isEmpty($errorNumber) || InputValidator::isEmptyArrayKey(self::$ERRORMESSAGES, $errorNumber)) {
         return false;
     }
     self::$ERROR = $errorNumber;
     return true;
 }
Exemplo n.º 8
0
 /**
  * This is the constructor of the Quantity object.
  *
  * @api
  * @author David Pauli <*****@*****.**>
  * @param mixed[] $quantityParameter The quantity parameter.
  * @since 0.2.0
  */
 public function __construct($quantityParameter)
 {
     if (InputValidator::isArray($quantityParameter)) {
         if (!InputValidator::isEmptyArrayKey($quantityParameter, "amount")) {
             $this->quantityAmount = $quantityParameter['amount'];
         }
         if (!InputValidator::isEmptyArrayKey($quantityParameter, "unit")) {
             $this->quantityUnit = $quantityParameter['unit'];
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Call this function to create a JSON string from a array.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @param mixed[] $array The array to make a JSON.
  * @return String The JSON string.
  */
 public static function createJSON($array)
 {
     if (!InputValidator::isArray($array)) {
         return null;
     }
     $result = json_encode($array);
     if (!InputValidator::isJSON($result)) {
         Logger::warning("There is an error with creating a JSON with the following array: <strong>" . json_last_error() . ": " . json_last_error_msg() . "</strong><br/>\n" . "<pre>" . $array . "</pre>");
         return null;
     }
     return $result;
 }
Exemplo n.º 10
0
 /**
  * Call this function with the JSON in parameter.
  *
  * @param String	$JSON	The JSON string to parse.
  * @return array	The array of the JSON element or null if there is an error.
  */
 public static function parseJSON($JSON)
 {
     if (!InputValidator::isJSON($JSON)) {
         return array();
     }
     $result = json_decode($JSON, true);
     if (!InputValidator::isArray($result)) {
         Logger::warning("There is an error with parsing the follwing JSON: <strong>" . json_last_error() . ": " . json_last_error_msg() . "</strong><br/>\n" . "<pre>" . $JSON . "</pre>");
         return array();
     }
     return $result;
 }
Exemplo n.º 11
0
 /**
  * This is the constructor of the price object.
  *
  * @api
  * @author David Pauli <*****@*****.**>
  * @since 0.0.0
  * @since 0.1.0 Add functionality to construct.
  * @param mixed[] $priceParamter The price parameter.
  */
 public function __construct($priceParameter)
 {
     if (InputValidator::isArray($priceParameter)) {
         if (!InputValidator::isEmptyArrayKey($priceParameter, "amount")) {
             $this->amount = $priceParameter['amount'];
         }
         if (!InputValidator::isEmptyArrayKey($priceParameter, "taxType")) {
             $this->taxType = $priceParameter['taxType'];
         }
         if (!InputValidator::isEmptyArrayKey($priceParameter, "currency")) {
             $this->currency = $priceParameter['currency'];
         }
     }
 }
Exemplo n.º 12
0
 /**
  * This is the constructor.
  *
  * @author David Pauli <*****@*****.**>
  * @param String[] $paymentMethodParameter The payment method in an array to construct.
  * @since 0.1.3
  */
 public function __construct($paymentMethodParameter)
 {
     // if parameter is no string
     if (!InputValidator::isArray($paymentMethodParameter)) {
         $this->errorSet("SM-1");
         Logger::error("ep6\\PaymentMethod\nThe parameter payment method paramater " . $paymentMethodParameter . " is no array.");
         return;
     }
     if (!InputValidator::isEmptyArrayKey($paymentMethodParameter, "id")) {
         $this->paymentMethodId = $paymentMethodParameter["id"];
     }
     if (!InputValidator::isEmptyArrayKey($paymentMethodParameter, "name")) {
         $this->name = $paymentMethodParameter["name"];
     }
 }
Exemplo n.º 13
0
 /**
  * Call this function with the JSON in parameter.
  *
  * @author David Pauli <*****@*****.**>
  * @param String $JSON The JSON string to parse.
  * @return mixed[] The array of the JSON element or null if there is an error.
  * @since 0.0.0
  * @since 0.1.2 Better the warnings.
  * @since 0.1.2 Add error reporting.
  */
 public static function parseJSON($JSON)
 {
     self::errorReset();
     if (!InputValidator::isJSON($JSON)) {
         Logger::warning("ep6\\JSONHandler\nJSON string (" . $JSON . ") is not valid.");
         self::errorSet("JSONH-1");
         return array();
     }
     $result = json_decode($JSON, true);
     if (!InputValidator::isArray($result)) {
         Logger::warning("ep6\\JSONHandler\nThere is an error with parsing the follwing JSON (" . $JSON . "): " . json_last_error() . ": " . json_last_error_msg());
         self::errorSet("JSONH-2");
         return array();
     }
     return $result;
 }
 /**
  * This is the constructor.
  *
  * @author David Pauli <*****@*****.**>
  * @param String[] $shippingMethodParameter The shipping method in an array to construct.
  * @since 0.1.3
  */
 public function __construct($shippingMethodParameter)
 {
     self::errorReset();
     // if parameter is no string
     if (!InputValidator::isArray($shippingMethodParameter)) {
         $this->errorSet("SM-1");
         Logger::error("ep6\\ShippingMethod\nThe shipping method parameter " . $shippingMethodParameter . " is no array.");
         return;
     }
     if (!InputValidator::isEmptyArrayKey($shippingMethodParameter, "id")) {
         $this->shippingMethodId = $shippingMethodParameter["id"];
     }
     if (!InputValidator::isEmptyArrayKey($shippingMethodParameter, "name")) {
         $this->name = $shippingMethodParameter["name"];
     }
 }
Exemplo n.º 15
0
 /**
  * This is the constructor of the Price object.
  *
  * @author David Pauli <*****@*****.**>
  * @param mixed[] $priceParamter The price parameter to create the Price object.
  * @since 0.0.0
  * @since 0.1.0 Add functionality to construct.
  * @since 0.1.1 Parse formatted attribute.
  */
 public function __construct($priceParameter)
 {
     if (InputValidator::isArray($priceParameter)) {
         if (!InputValidator::isEmptyArrayKey($priceParameter, "amount")) {
             $this->amount = $priceParameter['amount'];
         }
         if (!InputValidator::isEmptyArrayKey($priceParameter, "taxType") && ($priceParameter['taxType'] == PriceTaxModel::GROSS || $priceParameter['taxType'] == PriceTaxModel::NET)) {
             $this->taxType = $priceParameter['taxType'];
         }
         if (!InputValidator::isEmptyArrayKey($priceParameter, "currency")) {
             $this->currency = $priceParameter['currency'];
         }
         if (!InputValidator::isEmptyArrayKey($priceParameter, "formatted")) {
             $this->formatted = $priceParameter['formatted'];
         }
     }
 }
 public function options_save()
 {
     $option_keys = $this->option_keys();
     $this->options = $this->get_option();
     $iv = new InputValidator('POST');
     $iv->set_rules(self::NONCE_NAME, 'required');
     // Update options
     if (!is_wp_error($iv->input(self::NONCE_NAME)) && check_admin_referer(self::NONCE_ACTION, self::NONCE_NAME)) {
         // Get posted options
         $fields = array_keys($option_keys);
         foreach ($fields as $field) {
             switch ($field) {
                 case 'access_key':
                 case 'secret_key':
                     $iv->set_rules($field, array('trim', 'esc_html', 'required'));
                     break;
                 default:
                     $iv->set_rules($field, array('trim', 'esc_html'));
                     break;
             }
         }
         $options = $iv->input($fields);
         $err_message = '';
         foreach ($option_keys as $key => $field) {
             if (is_wp_error($options[$key])) {
                 $error_data = $options[$key];
                 $err = '';
                 foreach ($error_data->errors as $errors) {
                     foreach ($errors as $error) {
                         $err .= (!empty($err) ? '<br />' : '') . __('Error! : ', self::TEXT_DOMAIN);
                         $err .= sprintf(__(str_replace($key, '%s', $error), self::TEXT_DOMAIN), $field);
                     }
                 }
                 $err_message .= (!empty($err_message) ? '<br />' : '') . $err;
             }
             if (!isset($options[$key]) || is_wp_error($options[$key])) {
                 $options[$key] = '';
             }
         }
         if (self::$debug_mode && function_exists('dbgx_trace_var')) {
             dbgx_trace_var($options);
         }
         // Update options
         if ($this->options !== $options) {
             update_option(self::OPTION_KEY, $options);
             printf('<div id="message" class="updated fade"><p><strong>%s</strong></p></div>' . "\n", empty($err_message) ? __('Done!', self::TEXT_DOMAIN) : $err_message);
             $this->options = $options;
         }
         unset($options);
     }
 }
Exemplo n.º 17
0
 /**
  * handlePagina Handelt de gegeven pagina af
  * 
  * Deze methode controleert of de juiste invoer is gegeven en handelt de pagina verder af
  * Er wordt een gebruikerobject gemaakt dat de gegevens van de huidige gebruiker bevat.
  * @return void
  */
 public function handlePagina()
 {
     try {
         // vang alle fouten af
         // creeer een Gebruiker object
         $this->m_oGebruiker = new Gebruiker();
         // plaats de gebruiker in de Registry zodat andere objecten deze kunnen gebruiken
         Registry::add($this->m_oGebruiker, 'Bezoeker');
         // creeer de inputvalidator
         $oValidator = InputValidator::instantiate();
         $nResult = $oValidator->validate('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST, InputValidator::TYPE_INT, true);
         if ($nResult == InputValidator::RESULT_OK || $nResult == InputValidator::RESULT_CONVERTABLE) {
             // pagina bestaat in GET of POST
             $nPagina = intVal($oValidator->getValue('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST));
             // maak het juiste Scherm object aan
             $oScherm = SchermGenerator::genereerSchermObject($nPagina);
         } else {
             // geen pagina opgegeven, ga naar homepage
             $oScherm = SchermGenerator::genereerSchermObject(SchermGenerator::WELKOM);
         }
     } catch (Exception $e) {
         // iets is fout gegaan, log uit en toon homepage
         if (is_object($this->m_oGebruiker)) {
             $this->m_oGebruiker->logout();
         }
         // zet exception in de registry zodat de errorpage de info kan tonen
         Registry::add($e, 'Exception');
         $oScherm = SchermGenerator::genereerSchermObject(SchermGenerator::ERRORPAGE);
     }
     if (is_object($oScherm)) {
         // handel eventuele input af
         $oScherm = $oScherm->handlePagina();
         // bouw het scherm met de juiste informatie en toon het
         $oScherm->bouwScherm();
         $oScherm->toon();
     } else {
         // geen scherm object, heel erg fout.
         echo 'Er is geen scherm-object aangemaakt/of ontbreekt.';
     }
 }
Exemplo n.º 18
0
 /**
  * This is the constructor.
  *
  * This function extracts the date.
  *
  * @author David Pauli <*****@*****.**>
  * @param String $date The date to set (timestamp or strtotime allowed string).
  * @since 0.1.3
  * @since 0.2.1 Extend constructor to use also timestamps.
  */
 public function __construct($date)
 {
     // if parameter is no string
     if (InputValidator::isTimestamp($date)) {
         $timestamp = $date;
     } else {
         if (InputValidator::isString($date)) {
             // try to convert to a timestamp
             $timestamp = strtotime($date);
         } else {
             $this->errorSet("D-1");
             Logger::error("ep6\\Date\nThe parameter date " . $date . " is no string.");
             return;
         }
     }
     if (!$timestamp) {
         $this->errorSet("D-2");
         Logger::error("ep6\\Date\nThe parameter date " . $date . " is no valid date format.");
         return;
     }
     $this->timestamp = $timestamp;
 }
 /**
  * This function gets the product attributes.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @api
  * @param mixed[] $attribute The attribute in an array.
  */
 public function __construct($attribute)
 {
     if (!InputValidator::isEmptyArrayKey($attribute, "key")) {
         $this->internName = $attribute["key"];
     }
     if (!InputValidator::isEmptyArrayKey($attribute, "displayKey")) {
         $this->name = $attribute["displayKey"];
     }
     if (!InputValidator::isEmptyArrayKey($attribute, "singleValue")) {
         $this->oneValue = $attribute["singleValue"];
     }
     if (!InputValidator::isEmptyArrayKey($attribute, "type")) {
         $this->type = $attribute["type"];
     }
     if (!InputValidator::isEmptyArrayKey($attribute, "type") && !InputValidator::isArray($attribute["values"])) {
         foreach ($attribute["values"] as $key => $value) {
             if (!InputValidator::isEmptyArrayKey($value, "value") && !InputValidator::isEmptyArrayKey($value, "displayValue")) {
                 $this->values[$value["value"]] = $value["displayValue"];
             }
         }
     }
 }
Exemplo n.º 20
0
 public function createEvent($event_name, $event_date, $starttime, $endtime)
 {
     // 1. Validate Input
     $name = InputValidator::validate_input($event_name);
     // Reformat Input
     date('Y-m-d', strtotime($event_date));
     date('H:i', strtotime($starttime));
     date('H:i', strtotime($endtime));
     $error = "";
     // Check Validity
     if ($name == null || strlen(preg_replace('/\\s+/', '', $name)) == 0) {
         $error = $error . "@1Event name cannot be empty! ";
     }
     if (strtotime(preg_replace('/\\s+/', '', $event_date)) == false) {
         $error = $error . "@2Event date must be specified correctly (YYYY-MM-DD)! ";
     }
     if (strtotime(preg_replace('/\\s+/', '', $starttime)) == false) {
         $error = $error . "@3Event start time must be specified correctly (HH:MM)! ";
     }
     if (strtotime(preg_replace('/\\s+/', '', $endtime)) == false) {
         $error = $error . "@4Event end time must be specified correctly (HH:MM)!";
     }
     if (strtotime($endtime) < strtotime($starttime)) {
         $error = $error . "@4Event end time cannot be before event start time!";
     }
     if (strlen($error) == 0) {
         // 2. Load all of the data
         $pm = new PersistenceEventRegistration();
         $rm = $pm->loadDataFromStore();
         // 3. Add the new event
         $event = new Event($name, $event_date, $starttime, $endtime);
         $rm->addEvent($event);
         // 4. Write all of the data
         $pm->writeDataToStore($rm);
     } else {
         throw new Exception($error);
     }
 }
Exemplo n.º 21
0
 /**
  * Gets the default and possible locales of the shop.
  */
 private static function load()
 {
     // if request method is blocked
     if (!RESTClient::setRequestMethod("GET")) {
         return;
     }
     $content = JSONParser::parseJSON(RESTClient::send(self::RESTPATH));
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         return;
     }
     // if there is no default AND items element
     if (!array_key_exists("default", $content) || !array_key_exists("items", $content)) {
         Logger::error("Respond for " . self::RESTPATH . " can not be interpreted.");
         return;
     }
     // reset values
     self::resetValues();
     // save the default localization
     self::$DEFAULT = $content["default"];
     // parse the possible localizations
     self::$ITEMS = $content["items"];
 }
Exemplo n.º 22
0
 /**
  * constructor
  * Deze constructor controleert of de gebruiker is ingelogd, is dat het geval,
  * dan wordt het ingelogde menu gecreeerd. Als de gebruiker de rechten admin heeft,
  * wordt het adminmenu gecreeerd.
  * @param string $p_sTitel De getoonde titel op het scherm
  * @param array $p_aRechten array bevat alle benodigde rechten om deze pagina op te roepen. Een lege array 
  * @throws InsufficientRightsException
  */
 public function __construct($p_sTitel, $p_aRechten)
 {
     $this->m_sTitel = $p_sTitel;
     $this->m_sHTML = '';
     $this->m_aData = array();
     $this->m_aScripts = array();
     $this->m_oSmarty = null;
     $this->m_sTemplate = '';
     if (is_array($p_aRechten)) {
         $this->m_aBenodigdeRechten = $p_aRechten;
     } else {
         $this->m_aBenodigdeRechten = array(Gebruiker::TOEGANG_GEWEIGERD);
     }
     // genereer het menu aan de hand van de gebruikerrechten
     if (Registry::exists('Bezoeker')) {
         $this->m_oGebruiker = Registry::get('Bezoeker');
         if ($this->m_oGebruiker->isIngelogd()) {
             $oValidator = InputValidator::instantiate();
             $nPagina = intVal($oValidator->getValue('page', InputValidator::SCOPE_GET | InputValidator::SCOPE_POST));
             if ($nPagina >= MenuGenerator::BEHEER) {
                 $aRechten = $this->m_oGebruiker->__get('Rechten');
                 $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEHEER, $aRechten);
                 if (!$this->checkRechten()) {
                     // genereer een Exception zodat dit scherm nooit per ongeluk getoond kan worden
                     throw new OnvoldoendeRechtenException('Pagina ' . $p_sTitel);
                 }
             } else {
                 $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEZOEKER, array());
             }
         } else {
             $this->m_oMenu = MenuGenerator::genereerMenuObject(MenuGenerator::BEZOEKER, array());
         }
     } else {
         $this->m_oGebruiker = null;
     }
 }
Exemplo n.º 23
0
 /**
  * Loads the stock level.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @param float $step The step to change.
  */
 private function changeStockLevel($step)
 {
     // if parameter is wrong or GET is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::PUT) || !InputValidator::isFloat($step)) {
         return;
     }
     $postfields = array("changeStocklevel" => $step);
     $content = RESTClient::send(self::$RESTPATH . "/" . $this->productID . "/" . self::$RESTPATH_STOCKLEVEL, $postfields);
     // if respond is empty
     if (InputValidator::isEmpty($content) || InputValidator::isEmptyArrayKey($content, "stocklevel")) {
         return;
     }
     $this->stockLevel = (double) $content["stocklevel"];
     // update timestamp when make the next request
     $timestamp = (int) (microtime(true) * 1000);
     self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::NEXT_RESPONSE_WAIT_TIME;
 }
Exemplo n.º 24
0
 /**
  * This is the constructor.
  *
  * @author David Pauli <*****@*****.**>
  * @param String[] $addressParameter The array with information of the adddress.
  * @since 0.1.3
  */
 public function __construct($addressParameter)
 {
     self::errorReset();
     // if parameter is no array
     if (!InputValidator::isArray($addressParameter)) {
         self::errorSet("A-1");
         Logger::error("ep6\\Address\nThe address parameter " . $addressParameter . " is no array.");
         return;
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "birthday")) {
         $this->birthday = $addressParameter["birthday"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "city")) {
         $this->city = $addressParameter["city"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "company")) {
         $this->company = $addressParameter["company"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "country")) {
         $this->country = $addressParameter["country"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "emailAddress")) {
         $this->emailAddress = $addressParameter["emailAddress"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "firstName")) {
         $this->firstName = $addressParameter["firstName"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "lastName")) {
         $this->lastName = $addressParameter["lastName"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "salutation")) {
         $this->salutation = $addressParameter["salutation"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "state")) {
         $this->state = $addressParameter["state"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "street")) {
         $this->street = $addressParameter["street"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "streetDetails")) {
         $this->streetDetails = $addressParameter["streetDetails"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "title")) {
         $this->title = $addressParameter["title"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "vatId")) {
         $this->VATID = $addressParameter["vatId"];
     }
     if (!InputValidator::isEmptyArrayKey($addressParameter, "zipCode")) {
         $this->zipCode = $addressParameter["zipCode"];
     }
 }
 /**
  * This function gets the product images.
  *
  * @author David Pauli <*****@*****.**>
  * @param String $productID The product ID to get images.
  * @since 0.1.0
  * @since 0.1.1 Fix bug with nonsetted product URL and delete reload functionality.
  * @since 0.1.1 Use unstatic variables.
  * @since 0.1.2 Add error reporting.
  * @since 0.2.1 Implement REST client fixes.
  */
 private function load($productID)
 {
     // if parameter is wrong
     if (!InputValidator::isProductId($productID)) {
         $this->errorSet("PS-1");
         Logger::warning("ep6\\ProductSlideshow\nInvalid product ID " . $productId . " to load slideshow.");
         return;
     }
     // if GET is blocked
     if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) {
         $this->errorSet("RESTC-9");
         return;
     }
     RESTClient::send("products/" . $productID . "/" . self::RESTPATH);
     $content = RESTClient::getJSONContent();
     // if respond is empty
     if (InputValidator::isEmpty($content)) {
         $this->errorSet("PS-2");
         Logger::warning("ep6\\ProductSlideshow\nEmpty response while getting product slideshow.");
         return;
     }
     // if there is items
     if (InputValidator::isEmptyArrayKey($content, "items")) {
         $this->errorSet("PS-3");
         Logger::error("Respond for product slidehows can not be interpreted.");
         return;
     }
     // is there any images found: load the images.
     foreach ($content['items'] as $number => $image) {
         // parse every image size
         if (!InputValidator::isEmptyArrayKey($image, "sizes")) {
             $object = null;
             foreach ($image["sizes"] as $size) {
                 // if there is "url" and "classifier" set in the image
                 if (!InputValidator::isEmptyArrayKey($size, "url") && !InputValidator::isEmptyArrayKey($size, "classifier")) {
                     $object[$size["classifier"]] = $size["url"];
                 }
             }
             // if all needed sizes are available, save it
             if (!InputValidator::isEmptyArrayKey($object, "Thumbnail") && !InputValidator::isEmptyArrayKey($object, "Small") && !InputValidator::isEmptyArrayKey($object, "HotDeal") && !InputValidator::isEmptyArrayKey($object, "MediumSmall") && !InputValidator::isEmptyArrayKey($object, "Medium") && !InputValidator::isEmptyArrayKey($object, "MediumLarge") && !InputValidator::isEmptyArrayKey($object, "Large")) {
                 array_push($this->images, $object);
             }
         }
     }
 }
Exemplo n.º 26
0
    public function options_page()
    {
        $nonce_action = 'update_options';
        $nonce_name = '_wpnonce_update_options';
        $title = __($this->plugin_name . ' Options', self::TEXT_DOMAIN);
        $iv = new InputValidator('POST');
        $iv->set_rules($nonce_name, 'required');
        $iv->set_rules('static_url', array('trim', 'esc_html'));
        $iv->set_rules('static_dir', array('trim', 'esc_html'));
        $iv->set_rules('basic_usr', array('trim', 'esc_html'));
        $iv->set_rules('basic_pwd', array('trim', 'esc_html'));
        $iv->set_rules('timeout', 'numeric');
        // Update options
        if (!is_wp_error($iv->input($nonce_name)) && check_admin_referer($nonce_action, $nonce_name)) {
            // Get posted options
            $static_url = $iv->input('static_url');
            $static_dir = $iv->input('static_dir');
            $basic_usr = $iv->input('basic_usr');
            $basic_pwd = $iv->input('basic_pwd');
            $timeout = $iv->input('timeout');
            $basic_auth = $basic_usr && $basic_pwd ? base64_encode("{$basic_usr}:{$basic_pwd}") : false;
            // Update options
            update_option(self::OPTION_STATIC_URL, $static_url);
            update_option(self::OPTION_STATIC_DIR, $static_dir);
            update_option(self::OPTION_STATIC_BASIC, $basic_auth);
            update_option(self::OPTION_STATIC_TIMEOUT, $timeout);
            printf('<div id="message" class="updated fade"><p><strong>%s</strong></p></div>' . "\n", empty($err_message) ? __('Done!', self::TEXT_DOMAIN) : $err_message);
            $this->static_url = $static_url;
            $this->static_dir = $static_dir;
            $this->basic_auth = $basic_auth;
            $this->timeout = $timeout;
        }
        do_action('StaticPress::options_save');
        $basic_usr = $basic_pwd = '';
        if ($this->basic_auth) {
            list($basic_usr, $basic_pwd) = explode(':', base64_decode($this->basic_auth));
        }
        ?>
		<div class="wrap" id="<?php 
        echo self::OPTION_PAGE;
        ?>
-options">
		<?php 
        screen_icon(self::OPTION_PAGE . '-options');
        ?>
		<h2><?php 
        echo esc_html($title);
        ?>
</h2>
		<form method="post" action="<?php 
        echo $this->admin_action;
        ?>
">
		<?php 
        echo wp_nonce_field($nonce_action, $nonce_name, true, false) . "\n";
        ?>
		<table class="wp-list-table fixed"><tbody>
		<?php 
        $this->input_field('static_url', __('Static URL', self::TEXT_DOMAIN), $this->static_url);
        ?>
		<?php 
        $this->input_field('static_dir', __('Save DIR (Document root)', self::TEXT_DOMAIN), $this->static_dir);
        ?>
		<?php 
        $this->input_field('basic_usr', __('(OPTION) BASIC Auth User', self::TEXT_DOMAIN), $basic_usr);
        ?>
		<?php 
        $this->input_field('basic_pwd', __('(OPTION) BASIC Auth Password', self::TEXT_DOMAIN), $basic_pwd, 'password');
        ?>
		<?php 
        $this->input_field('timeout', __('(OPTION) Request Timeout', self::TEXT_DOMAIN), $this->timeout);
        ?>
		</tbody></table>
		<?php 
        submit_button();
        ?>
		</form>
		</div>
<?php 
        do_action('StaticPress::options_page');
    }
Exemplo n.º 27
0
 public function getApplicationInput()
 {
     $httpd_bin_found = OsUtils::findBinary(array('apachectl', 'apache2ctl'));
     if (!empty($httpd_bin_found)) {
         $httpd_bin_message = "The following apachectl script has been detected: {$httpd_bin_found}. Do you want to use this script to run your Kaltura application? Leave empty to use or provide a pathname to an alternative apachectl script on your server.";
         $httpd_error_message = "Invalid pathname for apachectl script, leave empty to use {$httpd_bin_found} or enter an alternative apachectl path";
     } else {
         $httpd_bin_message = "Installation could not automatically detect any apachectl script. Please provide a pathname to the apachectl script on your server.";
         $httpd_error_message = "Invalid pathname for apachectl script, please enter the apachectl pathname again";
     }
     $php_bin_found = OsUtils::findBinary('php');
     if (!empty($php_bin_found)) {
         $php_bin_message = "The following PHP binary has been detected: {$php_bin_found}. Do you want to use this script to run your Kaltura application? Leave empty to use or provide a pathname to an alternative PHP binary on your server.";
         $php_error_message = "Invalid pathname for PHP binary, leave empty to use {$php_bin_found} or enter an alternative PHP path";
     } else {
         $php_bin_message = "Installation could not automatically detect any PHP binary. Please provide a pathname to the PHP binary on your server.";
         $php_error_message = "Invalid pathname for PHP binary, please enter the PHP pathname again";
     }
     logMessage(L_USER, "Please provide the following information:");
     echo PHP_EOL;
     $this->getInput('HTTPD_BIN', $httpd_bin_message, $httpd_error_message, InputValidator::createFileValidator(), $httpd_bin_found);
     $this->getInput('PHP_BIN', $php_bin_message, $php_error_message, InputValidator::createFileValidator(), $php_bin_found);
     $this->getInput('BASE_DIR', "Full target directory path for Kaltura application (leave empty for /opt/kaltura)", "Target directory must be a valid directory path, please enter again", InputValidator::createDirectoryValidator(), '/opt/kaltura');
     $this->getInput('KALTURA_FULL_VIRTUAL_HOST_NAME', "Please enter the domain name/virtual hostname that will be used for the Kaltura server (without http://)", 'Must be a valid hostname or ip, please enter again', InputValidator::createHostValidator(), null);
     $this->getInput('ADMIN_CONSOLE_ADMIN_MAIL', "Your primary system administrator email address", "Email must be in a valid email format, please enter again", InputValidator::createEmailValidator(false), null);
     $this->getInput('ADMIN_CONSOLE_PASSWORD', "The password you want to set for your primary administrator", "Password should not be empty and should not contain whitespaces, please enter again", InputValidator::createNoWhitespaceValidator(), null);
     $this->getInput('DB1_HOST', "Database host (leave empty for 'localhost')", "Must be a valid hostname or ip, please enter again (leave empty for 'localhost')", InputValidator::createHostValidator(), 'localhost');
     $this->getInput('DB1_PORT', "Database port (leave empty for '3306')", "Must be a valid port (1-65535), please enter again (leave empty for '3306')", InputValidator::createRangeValidator(1, 65535), '3306');
     $this->set('DB1_NAME', 'kaltura');
     // currently we do not support getting the DB name from the user because of the DWH implementation
     $this->getInput('DB1_USER', "Database username (with create & write privileges)", "Database username cannot be empty, please enter again", InputValidator::createNonEmptyValidator(), null);
     $this->getInput('DB1_PASS', "Database password (leave empty for no password)", null, null, null);
     $this->getInput('XYMON_URL', "The URL to your xymon/hobbit monitoring location. Xymon is an optional installation. Leave empty to set manually later\nExamples:\nhttp://www.xymondomain.com/xymon/\nhttp://www.xymondomain.com/hobbit/", null, null, null);
     $this->saveInput();
 }
Exemplo n.º 28
0
 /**
  * This function checks whether a reload is needed.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @api
  */
 private static function reload()
 {
     $timestamp = (int) (microtime(true) * 1000);
     // if the value is empty
     if (!InputValidator::isEmpty(self::$DEFAULT) && !InputValidator::isEmpty(self::$ITEMS) && self::$NEXT_REQUEST_TIMESTAMP > $timestamp) {
         return;
     }
     self::load();
 }
Exemplo n.º 29
0
 /**
  * Returns a large image.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @since 0.1.1 Fix bug with returning image.
  * @api
  * @param int $image The image number to get
  * @return Image|null The large image.
  */
 public function getLargeImage($image)
 {
     if ($this->getCountImages() == 0 || !InputValidator::isRangedInt($image, 0, $this->getCountImages() - 1) || InputValidator::isEmptyArrayKey($this->images[$image], "Large")) {
         return null;
     }
     return $this->images[$image]["Large"];
 }
Exemplo n.º 30
0
 /**
  * This function checks whether a reload is needed.
  *
  * @author David Pauli <*****@*****.**>
  * @since 0.1.0
  * @since 0.1.1 Unstatic every attributes.
  */
 private function reload()
 {
     $timestamp = (int) (microtime(true) * 1000);
     // if the value is empty
     if (!InputValidator::isEmpty($this->NAME) && !InputValidator::isEmpty($this->NAVIGATIONCAPTION) && !InputValidator::isEmpty($this->DESCRIPTION) && $this->NEXT_REQUEST_TIMESTAMP > $timestamp) {
         return;
     }
     $this->load();
 }