public function actionValidName()
 {
     $record = Infrastructure::model()->findByAttributes(array('Name' => $_REQUEST['infraname']));
     $count = count($record);
     if ($count === 0) {
         $output = true;
     } else {
         $output = false;
     }
     echo json_encode($output);
 }
<?php

require_once __DIR__ . "/../bootstrap.php";
require_once __DIR__ . "/AddUtils.php";
/* AddNGIs.php: Loads a list of infrastructures from an XML file and inserts them into
 * the doctrine prototype.
 * XML format is the xml input production status format.
 */
$infrastructureFileName = __DIR__ . "/" . $GLOBALS['dataDir'] . "/Infrastructures.xml";
$infs = simplexml_load_file($infrastructureFileName);
foreach ($infs as $xmlInf) {
    $doctrineInf = new Infrastructure();
    $name = "";
    foreach ($xmlInf as $key => $value) {
        if ($key == "name") {
            $name = (string) $value;
        }
    }
    $doctrineInf->setName($name);
    $entityManager->persist($doctrineInf);
}
$entityManager->flush();
Exemple #3
0
 /**
  * Alias of {@link Infrastructure}\utf8PercentEncode().
  * @param string $encodeSet Regular expression (PCRE) pattern matching exactly one UTF-8 character.
  * @param string $codePoint Exactly one UTF-8 character.
  * @return string
  */
 public static function utf8PercentEncode($encodeSet, $codePoint)
 {
     return Infrastructure::utf8PercentEncode($encodeSet, $codePoint);
 }
Exemple #4
0
 /**
  * Percent encode UTF-8 string, using an encode set.
  * @param string $encodeSet Regular expression (PCRE) pattern matching exactly one UTF-8 character.
  * @param string $codePoints A UTF-8 string.
  * @return string
  */
 private static function percentEncodeCodePoints($encodeSet, $codePoints)
 {
     return preg_replace_callback($encodeSet, function ($matches) {
         $result = rawurlencode($matches[0]);
         if ($result[0] !== '%') {
             $result = Infrastructure::percentEncode($matches[0]);
         }
         return $result;
     }, $codePoints);
 }
Exemple #5
0
 /**
  * The host parser.
  * @link https://url.spec.whatwg.org/#concept-host-parser URL Standard
  * @param string $input A UTF-8 string.
  * @param boolean $unicodeFlag If true, can return a domain containing non-ASCII characters.
  * @return string|integer|float|integer[]
  *      If host is IPv4 address, returns a 32-bit unsigned integer (an integer or float).
  *      If host is IPv6 address, returns an array of a 16-bit unsigned integer.
  */
 public static function parseHost($input, $unicodeFlag = false)
 {
     $inputString = (string) $input;
     if ($inputString === '') {
         $result = false;
     } elseif ($inputString[0] === '[') {
         $result = substr($inputString, -1) !== ']' ? false : self::parseIPv6(substr($inputString, 1, -1));
     } else {
         $domain = Infrastructure::percentDecode($input);
         $asciiDomain = self::domainToASCII($domain);
         if ($asciiDomain === false || strpbrk($asciiDomain, "\t\n\r #%/:?@[\\]") !== false) {
             $result = false;
         } else {
             $ipv4Host = self::parseIPv4($asciiDomain);
             $result = is_string($ipv4Host) ? $unicodeFlag ? self::domainToUnicode($ipv4Host) : $ipv4Host : $ipv4Host;
         }
     }
     return $result;
 }