Ejemplo n.º 1
1
    public static function createSettingsFile($dbHostname, $dbName, $dbUsername, $dbPassword, $tablePrefix)
    {
        $encryptionSalt = Utils::generateRandomAlphanumericStr("DDD");
        $dbUsername = Utils::sanitize($dbUsername);
        $dbPassword = Utils::sanitize($dbPassword);
        $tablePrefix = Utils::sanitize($tablePrefix);
        $content = <<<END
<?php

\$dbHostname     = '{$dbHostname}';
\$dbName         = '{$dbName}';
\$dbUsername     = '******';
\$dbPassword     = '******';
\$dbTablePrefix  = '{$tablePrefix}';
\$encryptionSalt = '{$encryptionSalt}';
END;
        $file = __DIR__ . "/../../settings.php";
        $handle = @fopen($file, "w");
        if ($handle) {
            fwrite($handle, $content);
            fclose($handle);
            return array(true, "");
        }
        // no such luck! we couldn't create the file on the server. The user will need to do it manually
        return array(false, $content);
    }
Ejemplo n.º 2
0
 private static function fillTemplate($template, $countryCode)
 {
     $bic = self::generateBic($countryCode);
     $bicPos = 0;
     $unsigned = '';
     $len = strlen($template);
     $uppercaseTemplate = strtoupper($template);
     for ($i = 0; $i < $len; $i++) {
         $c = $template[$i];
         if ($uppercaseTemplate[$i] === $c) {
             $unsigned .= $c;
             continue;
         }
         if ($c === 'i') {
             $unsigned .= $bic[$bicPos++];
             continue;
         }
         if ($c === 'k') {
             $unsigned .= '_';
             continue;
         }
         $unsigned .= Utils::generateRandomAlphanumericStr('x');
     }
     return self::recalculateChecksum($unsigned);
 }
Ejemplo n.º 3
0
    public static function createSettingsFile($dbHostname, $dbName, $dbUsername, $dbPassword, $tablePrefix)
    {
        $encryptionSalt = Utils::generateRandomAlphanumericStr("DDD");
        $dbUsername = Utils::sanitize($dbUsername);
        $dbPassword = Utils::sanitize($dbPassword);
        $tablePrefix = Utils::sanitize($tablePrefix);
        $content = <<<END
<?php

\$dbHostname     = '{$dbHostname}';
\$dbName         = '{$dbName}';
\$dbUsername     = '******';
\$dbPassword     = '******';
\$dbTablePrefix  = '{$tablePrefix}';
\$encryptionSalt = '{$encryptionSalt}';
END;
        $file = __DIR__ . "/../../settings.php";
        $handle = @fopen($file, "w+");
        if ($handle) {
            fwrite($handle, $content);
            fclose($handle);
        }
        // now check the file exists, and if it DOES, contains the right stuff
        if (is_readable($file)) {
            $result = self::validateSettingsFile($file);
            if ($result["success"]) {
                return array(true, "");
            } else {
                return array(false, $result["error"]);
            }
        }
        // no such luck! we couldn't create the file on the server. The user will need to do it manually. Return
        // the
        return array(false, $content);
    }
Ejemplo n.º 4
0
 public function generate($generator, $generationContextData)
 {
     $formats = explode("|", $generationContextData["generationOptions"]);
     $chosenFormat = $formats[0];
     if (count($formats) > 1) {
         $chosenFormat = $formats[mt_rand(0, count($formats) - 1)];
     }
     $val = Utils::generateRandomAlphanumericStr($chosenFormat);
     return array("display" => $val);
 }
Ejemplo n.º 5
0
 public function generate($generator, $generationContextData)
 {
     $phoneStr = Utils::generateRandomAlphanumericStr($generationContextData["generationOptions"]);
     $formats = explode("|", $phoneStr);
     $chosenFormat = $formats[0];
     $numFormats = count($formats);
     if ($numFormats > 1) {
         $chosenFormat = $formats[mt_rand(0, $numFormats - 1)];
     }
     return array("display" => $chosenFormat);
 }
Ejemplo n.º 6
0
 public function generate($generator, $generationContextData)
 {
     $placeholderStr = "HHHHHHHH-HHHH-HHHH-HHHH-HHHHHHHHHHHH";
     $guid = Utils::generateRandomAlphanumericStr($placeholderStr);
     // pretty sodding unlikely, but just in case!
     while (in_array($guid, $this->generatedGUIDs)) {
         $guid = Utils::generateRandomAlphanumericStr($placeholderStr);
     }
     $this->generatedGUIDs[] = $guid;
     return array("display" => $guid);
 }
Ejemplo n.º 7
0
 public static function resetPassword($email)
 {
     $prefix = Core::getDbTablePrefix();
     $email = Utils::sanitize($email);
     $response = Core::$db->query("\n\t\t\tSELECT * \n\t\t\tFROM {$prefix}user_accounts\n\t\t\tWHERE email = '{$email}'\n\t\t\tLIMIT 1\n\t\t");
     if (!$response["success"]) {
         return;
     }
     $L = Core::$language->getCurrentLanguageStrings();
     $data = mysqli_fetch_assoc($response["results"]);
     if (empty($data)) {
         return array("success" => false, "message" => $L["user_not_found"]);
     }
     $randPassword = Utils::generateRandomAlphanumericStr("CXCXCX");
     // now attempt to send the email
     try {
         $emailContent = preg_replace("/%1/", $randPassword, $L["password_reset_email_content1"]);
         $emailContent .= "\n\n" . $L["password_reset_email_content2"];
         $emailSent = Emails::sendEmail(array("recipient" => $email, "subject" => $L["reset_password"], "content" => $emailContent));
         $encryptionSalt = Core::getEncryptionSalt();
         $encryptedPassword = crypt($randPassword, $encryptionSalt);
         $response = Core::$db->query("\n\t\t\t\tUPDATE {$prefix}user_accounts\n\t\t\t\tSET password = '******'\n\t\t\t\tWHERE email = '{$email}'\n\t\t\t\tLIMIT 1\n\t\t\t");
         if ($response && $emailSent) {
             if ($response["success"]) {
                 return array("success" => true, "message" => $L["password_reset_complete"]);
             }
         } else {
             return array("success" => false, "message" => $L["email_not_sent"]);
         }
     } catch (Exception $e) {
         return array("success" => false, "message" => $L["email_not_sent"]);
     }
 }
Ejemplo n.º 8
0
 private function convert($countrySlug, $regionShort = "")
 {
     $zipInfo = $this->zipFormats[$countrySlug];
     $result = "";
     if ($zipInfo["isAdvanced"]) {
         // if the country plugin defined a custom zip format for this region, use it
         if (!empty($regionShort) && !empty($zipInfo["regionSpecificFormat"]) && array_key_exists($regionShort, $zipInfo["regionSpecificFormat"])) {
             $customFormat = isset($zipInfo["regionSpecificFormat"][$regionShort]["format"]) ? $zipInfo["regionSpecificFormat"][$regionShort]["format"] : "";
             $replacements = isset($zipInfo["regionSpecificFormat"][$regionShort]["replacements"]) ? $zipInfo["regionSpecificFormat"][$regionShort]["replacements"] : "";
         }
         $customFormat = !empty($customFormat) ? $customFormat : $zipInfo["format"];
         $replacements = !empty($replacements) ? $replacements : $zipInfo["replacements"];
         // now iterate over $customFormat and do whatever replacements have been specified
         $customFormatLen = strlen($customFormat);
         for ($i = 0; $i < $customFormatLen; $i++) {
             if (array_key_exists($customFormat[$i], $replacements)) {
                 $replacementKey = $replacements[$customFormat[$i]];
                 $randChar = $replacementKey[mt_rand(0, strlen($replacementKey) - 1)];
                 $result .= $randChar;
             } else {
                 $result .= $customFormat[$i];
             }
         }
     } else {
         $formats = explode("|", $zipInfo["format"]);
         $numFormats = count($formats);
         if ($numFormats == 1) {
             $format = $formats[0];
         } else {
             $format = $formats[mt_rand(0, $numFormats - 1)];
         }
         $result = Utils::generateRandomAlphanumericStr($format);
     }
     return $result;
 }
 /**
  * Assumption: the area code is in a single block of A's.
  * @param $desiredFormat
  * @param $areaCodes
  * @return mixed|string
  */
 private function replaceRandomAreaCode($desiredFormat, $areaCodes)
 {
     // if the desired format doesn't contain an area code, shut down the party
     if (!strstr($desiredFormat, "A")) {
         return $desiredFormat;
     }
     $str = "";
     if (!empty($areaCodes)) {
         $areaCode = $areaCodes[mt_rand(0, count($areaCodes) - 1)];
         $str = preg_replace("/A+/", $areaCode, $desiredFormat);
     } else {
         preg_match("/A+/", $desiredFormat, $matches);
         $areaCodeLength = strlen($matches[0]);
         $replacement = substr("Xxxxxxxxxxxxxxxx", 0, $areaCodeLength);
         $str = preg_replace("/A+/", Utils::generateRandomAlphanumericStr($replacement), $desiredFormat);
     }
     return $str;
 }
Ejemplo n.º 10
0
<?php

require_once "library.php";
Core::init("installation");
// if the script is already installed, redirect them to the index page.
if (Core::checkIsInstalled()) {
    header("location: index.php");
    exit;
}
$currentPage = 1;
if (Core::checkSettingsFileExists()) {
    $currentPage = 3;
    if (Settings::getSetting("installationStepComplete_Core") == "yes") {
        $currentPage = 4;
    }
}
$params = array();
$params["theme"] = Core::getDefaultTheme();
$params["randomPassword"] = Utils::generateRandomAlphanumericStr("CVxxCxV");
$params["tablePrefix"] = Core::getDbTablePrefix();
$params["currentPage"] = $currentPage;
Templates::displayPage("resources/templates/install.tpl", $params);
 private function convert($str)
 {
     $formats = explode("|", $str);
     if (count($formats) == 1) {
         $format = $formats[0];
     } else {
         $format = $formats[rand(0, count($formats) - 1)];
     }
     return Utils::generateRandomAlphanumericStr($format);
 }