private function changePassword()
 {
     $uid = $_SESSION['session']->getUserId();
     if ($this->errno !== 0 && $this->errno !== 1) {
         return;
     }
     if (!$this->checker->checkPassword($_POST['profilPassword'])) {
         $this->errno = 3;
         $this->error = 'Das angegebene Passwort ist nicht gültig.';
         return;
     }
     if ($_POST['profilPassword'] !== $_POST['profilPwdWdh']) {
         $this->errno = 4;
         $this->error = 'Die angegebenen Passwörter stimmen nicht überein.';
         return;
     }
     $this->errno = 0;
     $this->error = '';
     $hasher = new PasswordHash(8, false);
     $pwd = $hasher->HashPassword($_POST['profilPassword']);
     $db = Database::getDbObject();
     $stmt = $db->stmt_init();
     $stmt->prepare("UPDATE `users` SET `password` = ? WHERE `id` = ?;");
     $stmt->bind_param('si', $pwd, $uid);
     $success = $stmt->execute();
     if (!$success || $stmt->errno) {
         $this->errno = $stmt->errno;
         $this->error = 'Es ist ein Datenbankfehler aufgetreten. Bitte versuchen Sie es später noch einmal.';
     }
 }
Esempio n. 2
0
    public static function show()
    {
        $messages = new Messages();
        $reporter = new \Jelix\Installer\Reporter\Html($messages);
        $check = new Checker($reporter, $messages);
        $check->addDatabaseCheck(array('mysql', 'sqlite', 'pgsql'), false);
        header("Content-type:text/html;charset=UTF-8");
        ?>

<!DOCTYPE html>
<html lang="<?php 
        echo $check->messages->getLang();
        ?>
">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
    <title><?php 
        echo htmlspecialchars($check->messages->get('checker.title'));
        ?>
</title>
    <link type="text/css"  href="jelix/design/jelix.css" rel="stylesheet" />

</head><body >
    <h1 class="apptitle"><?php 
        echo htmlspecialchars($check->messages->get('checker.title'));
        ?>
</h1>

<?php 
        $check->run();
        ?>
</body>
</html>
<?php 
    }
Esempio n. 3
0
 /**
  * @param string $filename
  * @param Settings $settings
  * @return Result[]
  */
 public function checkFile($filename, Settings $settings = null)
 {
     if ($settings === null) {
         $settings = new Settings();
     }
     $content = $this->loadFile($filename);
     $checker = new Checker($settings);
     $results = $checker->check($content);
     $this->setFilePathToResults($results, $filename);
     return $results;
 }
Esempio n. 4
0
 public function testCheckingForCacheReturnsWritableState()
 {
     mkdir($root = '/tmp/' . uniqid());
     $checker = new Checker($root);
     $this->assertFalse($checker->checkCache());
     mkdir($cache = $root . '/cache');
     chmod($cache, 00);
     $this->assertFalse($checker->checkCache());
     chmod($cache, 0700);
     $this->assertTrue($checker->checkCache());
     rmdir($cache);
     rmdir($root);
 }
 /**
  * Constructor.
  *
  * @param AppInfo $appInfo
  *     See {@link getAppInfo()}
  * @param string $clientIdentifier
  *     See {@link getClientIdentifier()}
  * @param null|string $userLocale
  *     See {@link getUserLocale()}
  */
 function __construct($appInfo, $clientIdentifier, $userLocale = null)
 {
     AppInfo::checkArg("appInfo", $appInfo);
     Checker::argStringNonEmpty("clientIdentifier", $clientIdentifier);
     Checker::argStringNonEmptyOrNull("userLocale", $userLocale);
     $this->appInfo = $appInfo;
     $this->clientIdentifier = $clientIdentifier;
     $this->userLocale = $userLocale;
 }
Esempio n. 6
0
 public function __construct(array $data)
 {
     parent::__construct($data);
     $this->address = \App\Address::find($data['address']);
     switch ($data['object']) {
         case 'star':
             $this->centerObject = \App\Star::find($data['objectId']);
             break;
         case 'multi':
             $this->centerObject = \App\Baricenter::find($data['objectId']);
             break;
     }
 }
 /**
  * Returns cryptographically strong secure random bytes (as a PHP string).
  *
  * @param int $numBytes
  *    The number of bytes of random data to return.
  *
  * @return string
  */
 static function getRandomBytes($numBytes)
 {
     Checker::argIntPositive("numBytes", $numBytes);
     // openssl_random_pseudo_bytes had some issues prior to PHP 5.3.4
     if (function_exists('openssl_random_pseudo_bytes') && version_compare(PHP_VERSION, '5.3.4') >= 0) {
         $s = openssl_random_pseudo_bytes($numBytes, $isCryptoStrong);
         if ($isCryptoStrong) {
             return $s;
         }
     }
     if (function_exists('mcrypt_create_iv')) {
         return mcrypt_create_iv($numBytes);
     }
     // Hopefully the above two options cover all our users.  But if not, there are
     // other platform-specific options we could add.
     assert(False, "no suitable random number source available");
 }
Esempio n. 8
0
 private function addTransaction($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
 {
     if ($this->closed) {
         throw new \RuntimeException("Could not add the transaction. This batchRequest is closed.");
     }
     if ($this->isFull()) {
         throw new \RuntimeException('The transaction could not be added to the batch. It is full.');
     }
     if ($type == 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] != $this->total_txns) {
         throw new \RuntimeException("The transaction could not be added to the batch. The transaction type {$type} cannot be mixed with non-Account Updates.");
     } elseif ($type != 'accountUpdate' && $this->counts_and_amounts['accountUpdate']['count'] == $this->total_txns && $this->total_txns > 0) {
         throw new \RuntimeException("The transaction could not be added to the batch. The transaction type {$type} cannot be mixed with AccountUpdates.");
     }
     if (isset($hash_in['reportGroup'])) {
         $report_group = $hash_in['reportGroup'];
     } else {
         $conf = Obj2xml::getConfig(array());
         $report_group = $conf['reportGroup'];
     }
     Checker::choice($choice1);
     Checker::choice($choice2);
     $request = Obj2xml::transactionToXml($hash_out, $type, $report_group);
     if (file_put_contents($this->transaction_file, $request, FILE_APPEND) === FALSE) {
         throw new \RuntimeException("A transaction could not be written to the batch file at {$this->transaction_file}. Please check your privilege.");
     }
     $this->total_txns += 1;
 }
Esempio n. 9
0
<?php

require_once 'Checker.php';
define('APP_DIR', __DIR__);
echo 'Checking filesystem permissions:' . PHP_EOL;
$checker = new Checker(APP_DIR);
$checker->result($checker->checkCache(), 'Cache: ');
$checker->result($checker->checkLib(), 'Lib: ');
$checker->result($checker->checkLog(), 'Log: ');
$checker->result($checker->checkInstaller(), 'Installer removed: ');
Esempio n. 10
0
 /**
  * Test for check.
  *
  * @dataProvider checkerProvider
  */
 public function testAllLevels($subject, $codiceFiscaleToCheck, $omocodiaLevel, $expected)
 {
     $checker = new Checker($subject, array('codiceFiscaleToCheck' => $codiceFiscaleToCheck, 'omocodiaLevel' => $omocodiaLevel));
     $actual = $checker->check();
     $this->assertEquals($expected, $actual);
 }
 private function processRequest($hash_out, $hash_in, $type, $choice1 = null, $choice2 = null)
 {
     $hash_config = LitleOnlineRequest::overideconfig($hash_in);
     $hash = LitleOnlineRequest::getOptionalAttributes($hash_in, $hash_out);
     Checker::choice($choice1);
     Checker::choice($choice2);
     $request = Obj2xml::toXml($hash, $hash_config, $type);
     $litleOnlineResponse = $this->newXML->request($request, $hash_config, $this->useSimpleXml);
     return $litleOnlineResponse;
 }
Esempio n. 12
0
 /**
  * @internal
  *
  * @param string $argName
  * @param mixed $value
  * @throws \InvalidArgumentException
  */
 static function checkArgNonRoot($argName, $value)
 {
     Checker::argStringNonEmpty($argName, $value);
     $error = self::findErrorNonRoot($value);
     if ($error !== null) {
         throw new \InvalidArgumentException("'{$argName}': bad path: {$error}: " . Util::q($value));
     }
 }
Esempio n. 13
0
 /**
  * @param int $maxRetries
  *    The number of times to retry it the action if it fails with one of the transient
  *    API errors.  A value of 1 means we'll try the action once and if it fails, we
  *    will retry once.
  *
  * @param callable $action
  *    The the action you want to retry.
  *
  * @return mixed
  *    Whatever is returned by the $action callable.
  */
 static function runWithRetry($maxRetries, $action)
 {
     Checker::argNat("maxRetries", $maxRetries);
     $retryDelay = 1;
     $numRetries = 0;
     while (true) {
         try {
             return $action();
         } catch (Exception_NetworkIO $ex) {
             $savedEx = $ex;
         } catch (Exception_ServerError $ex) {
             $savedEx = $ex;
         } catch (Exception_RetryLater $ex) {
             $savedEx = $ex;
         }
         // We maxed out our retries.  Propagate the last exception we got.
         if ($numRetries >= $maxRetries) {
             throw $savedEx;
         }
         $numRetries++;
         sleep($retryDelay);
         $retryDelay *= 2;
         // Exponential back-off.
     }
     throw new \RuntimeException("unreachable");
 }
Esempio n. 14
0
 /**
  * Use this to check that a function argument is of type <code>AppInfo</code>
  *
  * @internal
  */
 static function checkArg($argName, $argValue)
 {
     if (!$argValue instanceof self) {
         Checker::throwError($argName, $argValue, __CLASS__);
     }
 }
Esempio n. 15
0
 public static function litleInternalRecurringRequestType($hash_in)
 {
     if (isset($hash_in)) {
         $hash_out = array("subscriptionId" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "subscriptionId")), "recurringTxnId" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "recurringTxnId")));
         return $hash_out;
     }
 }
 public static function recyclingRequestType($hash_in)
 {
     if (isset($hash_in)) {
         $hash_out = array("recycleBy" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "recycleBy")));
         return $hash_out;
     }
 }
Esempio n. 17
0
 function showCheckRes()
 {
     /* update last page */
     $_SESSION['LASTPAGE'] = substr($_SESSION['LASTPAGE'], 0, strripos($_SESSION['LASTPAGE'], "res"));
     $displaySysAdmin = new DisplaySysAdmin();
     $comp = loadvar("survey");
     $components = loadvar("components");
     if ($components == "") {
         return $displaySysAdmin->showCheck($displaySysAdmin->displayWarning(Language::messageToolsCompileSelectComponent()));
     }
     set_time_limit(0);
     $messages = array();
     $survey = new Survey($comp);
     $checker = new Checker($comp);
     $compiler = new Compiler($comp, getSurveyVersion($survey));
     $sectionmessages = array();
     $routingmessages = array();
     $variablemessages = array();
     $typemessages = array();
     $groupmessages = array();
     $surveymessages = array();
     if (inArray(SURVEY_COMPONENT_ROUTING, $components)) {
         $sections = $survey->getSections();
         foreach ($sections as $section) {
             $mess = $compiler->generateEngine($section->getSeid(), false);
             if (sizeof($mess) > 0) {
                 $routingmessages[$section->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_SECTION, $components)) {
         $sections = $survey->getSections();
         foreach ($sections as $section) {
             $mess = $checker->checkSection($section, true);
             if (sizeof($mess) > 0) {
                 $sectionmessages[$section->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_VARIABLE, $components)) {
         $vars = $survey->getVariableDescriptives();
         foreach ($vars as $var) {
             $mess = $checker->checkVariable($var, true);
             if (sizeof($mess) > 0) {
                 $variablemessages[$var->getName()] = $mess;
                 $errors = true;
             }
             $mess = $compiler->generateSetFills(array($var), false, false);
             if (sizeof($mess) > 0) {
                 //print_r($mess);
                 if (isset($variablemessages[$var->getName()])) {
                     $variablemessages[$var->getName()] = array_merge($variablemessages[$var->getName()], $mess);
                 } else {
                     $variablemessages[$var->getName()] = $mess;
                 }
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_TYPE, $components)) {
         $types = $survey->getTypes();
         foreach ($types as $type) {
             $mess = $checker->checkType($type, true);
             if (sizeof($mess) > 0) {
                 $typemessages[$type->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     if (inArray(SURVEY_COMPONENT_SETTING, $components)) {
         $mess = $checker->checkSurvey();
         if (sizeof($mess) > 0) {
             $surveymessages = $mess;
             $errors = true;
         }
     }
     if (inArray(SURVEY_COMPONENT_GROUP, $components)) {
         $groups = $survey->getGroups();
         foreach ($groups as $group) {
             $mess = $checker->checkGroup($group, true);
             if (sizeof($mess) > 0) {
                 $groupmessages[$group->getName()] = $mess;
                 $errors = true;
             }
         }
     }
     $messages = array(Language::labelSections() => $sectionmessages, Language::labelVariables() => $variablemessages, Language::labelTypes() => $typemessages, Language::labelGroups() => $groupmessages, Language::labelSettings() => $surveymessages, Language::LabelRouting() => $routingmessages);
     if ($errors) {
         $m = '<a data-keyboard="false" data-toggle="modal" data-target="#errorsModal">Show error(s)</a>';
         $content .= $displaySysAdmin->displayError(Language::messageToolsCheckNotOk() . " " . $m);
     } else {
         $content .= $displaySysAdmin->displaySuccess(Language::messageToolsCheckOk());
     }
     $text = "";
     //print_r($messages);
     foreach ($messages as $k => $v) {
         if (sizeof($v) == 0) {
             //$text .= $displaySysAdmin->displaySuccess(Language::messageToolsCheckOk());
         } else {
             $text .= "<h3>" . $k . "</h3>";
             foreach ($v as $name => $m) {
                 foreach ($m as $object => $errors) {
                     if (is_array($errors)) {
                         foreach ($errors as $n) {
                             if (trim($n) != "") {
                                 $text .= $displaySysAdmin->displayError($name . ": " . $n);
                             }
                         }
                     } else {
                         if (trim($errors) != "") {
                             $text .= $displaySysAdmin->displayError($name . ": " . $errors);
                         }
                     }
                 }
             }
         }
     }
     $content .= $displaySysAdmin->displayRoutingErrorModal($survey, $text);
     return $displaySysAdmin->showCheck($content);
 }
 function __construct($params, $element_check_callback)
 {
     $this->element_check_callback = $element_check_callback;
     parent::__construct($params);
 }
Esempio n. 19
0
 public function __construct(array $data)
 {
     parent::__construct($data);
     $this->address = \App\Address::find($data['address']);
     $this->checkStar();
 }
Esempio n. 20
0
 /**
  * Parse clear email address array
  *
  * @param string $email
  *
  * @return array
  */
 private function _parseEmailArray($email)
 {
     $to = explode(',', $email);
     $toArray = array();
     foreach ($to as $x) {
         $x = $this->_parseEmail($x);
         if (Checker::CheckEmail($x)) {
             $toArray[] = strtolower($x);
         }
     }
     return $toArray;
 }
Esempio n. 21
0
 /**
  * Return the last component of a path (the file or folder name).
  *
  * <code>
  * Path::getName("/Misc/Notes.txt") // "Notes.txt"
  * Path::getName("/Misc")           // "Misc"
  * Path::getName("/")               // null
  * </code>
  *
  * @param string $path
  *    The full path you want to get the last component of.
  *
  * @return null|string
  *    The last component of `$path` or `null` if the given
  *    `$path` was `"/"`.
  */
 static function getName($path)
 {
     Checker::argString("path", $path);
     if (\substr_compare($path, "/", 0, 1) !== 0) {
         throw new \InvalidArgumentException("'path' must start with \"/\"");
     }
     $l = strlen($path);
     if ($l === 1) {
         return null;
     }
     if ($path[$l - 1] === "/") {
         throw new \InvalidArgumentException("'path' must not end with \"/\"");
     }
     $lastSlash = strrpos($path, "/");
     return substr($path, $lastSlash + 1);
 }
 public static function mposType($hash_in)
 {
     if (isset($hash_in)) {
         $hash_out = array("ksn" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "ksn", 1028)), "formatId" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "formatId", 1028)), "encryptedTrack" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "encryptedTrack", 1028)), "track1Status" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "track1Status", 1028)), "track2Status" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "track2Status", 1028)));
         return $hash_out;
     }
 }
Esempio n. 23
0
 /**
  * Use this to check that a function argument is either `null` or of type
  * `AppInfo`.
  *
  * @internal
  */
 static function checkArgOrNull($argName, $argValue)
 {
     if ($argValue === null) {
         return;
     }
     if (!$argValue instanceof self) {
         Checker::throwError($argName, $argValue, __CLASS__);
     }
 }
 /**
  * Call this after the user has visited the authorize URL returned by {@link start()},
  * approved your app, was presented with an authorization code by Dropbox, and has copy/paste'd
  * that authorization code into your app.
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#oa2-token">/oauth2/token</a>.
  *
  * @param string $code
  *    The authorization code provided to the user by Dropbox.
  *
  * @return array
  *    A <code>list(string $accessToken, string $userId)</code>, where
  *    <code>$accessToken</code> can be used to construct a {@link Client} and
  *    <code>$userId</code> is the user ID of the user's Dropbox account.
  *
  * @throws Exception
  *    Thrown if there's an error getting the access token from Dropbox.
  */
 function finish($code)
 {
     Checker::argStringNonEmpty("code", $code);
     return $this->_finish($code, null);
 }
Esempio n. 25
0
 public function __construct(IArea $parent, $config = array())
 {
     parent::__construct($parent, $config);
     $this->setName($parent->getId());
 }
 public static function createAccountUpdate($hash_in)
 {
     $hash_out = array('orderId' => Checker::requiredField(XmlFields::returnArrayValue($hash_in, 'orderId')), 'id' => Checker::requiredField(XmlFields::returnArrayValue($hash_in, 'id')), 'card' => XmlFields::cardType(XmlFields::returnArrayValue($hash_in, 'card')), 'token' => XmlFields::cardTokenType(XmlFields::returnArrayValue($hash_in, 'token')));
     return $hash_out;
 }
Esempio n. 27
0
 /**
  * Perform an OAuth-2-authorized POST request to the Dropbox API.  Will automatically
  * fill in "User-Agent" and "locale" as well.
  *
  * @param string $host
  *    Either the "API" or "API content" hostname from {@link getHost()}.
  * @param string $path
  *    The "path" part of the URL.  For example, "/commit_chunked_upload".
  * @param array|null $params
  *    POST parameters.
  * @return HttpResponse
  *
  * @throws Exception
  */
 function doPost($host, $path, $params = null)
 {
     Checker::argString("host", $host);
     Checker::argString("path", $path);
     return RequestUtil::doPost($this->clientIdentifier, $this->accessToken, $this->userLocale, $host, $path, $params);
 }
Esempio n. 28
0
 public static function applePayType($hash_in)
 {
     if (isset($hash_in)) {
         $hash_out = array("data" => XmlFields::returnArrayValue($hash_in, "data"), "header" => Checker::requiredField(XmlFields::returnArrayValue($hash_in, "header")), "signature" => XmlFields::returnArrayValue($hash_in, "signature"), "version" => XmlFields::returnArrayValue($hash_in, "version"));
         return $hash_out;
     }
 }
Esempio n. 29
0
 public function __construct(array $composerJson, callable $success, callable $warning, callable $error)
 {
     parent::__construct($success, $warning, $error);
     $this->composerJson = $composerJson;
 }
Esempio n. 30
0
 /**
  * Call this after the user has visited the authorize URL ({@link start()}), approved your app,
  * and was redirected to your redirect URI.
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#oa2-token">/oauth2/token</a>.
  *
  * @param array $queryParams
  *    The query parameters on the GET request to your redirect URI.
  *
  * @return array
  *    A <code>list(string $accessToken, string $userId, string $urlState)</code>, where
  *    <code>$accessToken</code> can be used to construct a {@link Client}, <code>$userId</code>
  *    is the user ID of the user's Dropbox account, and <code>$urlState</code> is the
  *    value you originally passed in to {@link start()}.
  *
  * @throws Exception
  *    Thrown if there's an error getting the access token from Dropbox.
  * @throws WebAuthException_BadRequest
  * @throws WebAuthException_BadState
  * @throws WebAuthException_Csrf
  * @throws WebAuthException_NotApproved
  * @throws WebAuthException_Provider
  */
 function finish($queryParams)
 {
     Checker::argArray("queryParams", $queryParams);
     $csrfTokenFromSession = $this->csrfTokenStore->get();
     Checker::argStringOrNull("this->csrfTokenStore->get()", $csrfTokenFromSession);
     // Check well-formedness of request.
     if (!isset($queryParams['state'])) {
         throw new WebAuthException_BadRequest("Missing query parameter 'state'.");
     }
     $state = $queryParams['state'];
     Checker::argString("queryParams['state']", $state);
     $error = null;
     $errorDescription = null;
     if (isset($queryParams['error'])) {
         $error = $queryParams['error'];
         Checker::argString("queryParams['error']", $error);
         if (isset($queryParams['error_description'])) {
             $errorDescription = $queryParams['error_description'];
             Checker::argString("queryParams['error_description']", $errorDescription);
         }
     }
     $code = null;
     if (isset($queryParams['code'])) {
         $code = $queryParams['code'];
         Checker::argString("queryParams['code']", $code);
     }
     if ($code !== null && $error !== null) {
         throw new WebAuthException_BadRequest("Query parameters 'code' and 'error' are both set;" . " only one must be set.");
     }
     if ($code === null && $error === null) {
         throw new WebAuthException_BadRequest("Neither query parameter 'code' or 'error' is set.");
     }
     // Check CSRF token
     if ($csrfTokenFromSession === null) {
         throw new WebAuthException_BadState();
     }
     $splitPos = strpos($state, "|");
     if ($splitPos === false) {
         $givenCsrfToken = $state;
         $urlState = null;
     } else {
         $givenCsrfToken = substr($state, 0, $splitPos);
         $urlState = substr($state, $splitPos + 1);
     }
     if (!Security::stringEquals($csrfTokenFromSession, $givenCsrfToken)) {
         throw new WebAuthException_Csrf("Expected " . Util::q($csrfTokenFromSession) . ", got " . Util::q($givenCsrfToken) . ".");
     }
     $this->csrfTokenStore->clear();
     // Check for error identifier
     if ($error !== null) {
         if ($error === 'access_denied') {
             // When the user clicks "Deny".
             if ($errorDescription === null) {
                 throw new WebAuthException_NotApproved("No additional description from Dropbox.");
             } else {
                 throw new WebAuthException_NotApproved("Additional description from Dropbox: {$errorDescription}");
             }
         } else {
             // All other errors.
             $fullMessage = $error;
             if ($errorDescription !== null) {
                 $fullMessage .= ": ";
                 $fullMessage .= $errorDescription;
             }
             throw new WebAuthException_Provider($fullMessage);
         }
     }
     // If everything went ok, make the network call to get an access token.
     list($accessToken, $userId) = $this->_finish($code, $this->redirectUri);
     return array($accessToken, $userId, $urlState);
 }