/**
 * determines the langauge settings of the browser, details see here:
 * http://aktuell.de.selfhtml.org/artikel/php/httpsprache/
 */
function lang_getfrombrowser($allowed_languages, $default_language, $lang_variable = null, $strict_mode = true)
{
    // $_SERVER['HTTP_ACCEPT_LANGUAGE'] verwenden, wenn keine Sprachvariable mitgegeben wurde
    if ($lang_variable === null && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
        $lang_variable = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
    }
    // wurde irgendwelche Information mitgeschickt?
    if (empty($lang_variable)) {
        // Nein? => Standardsprache zurückgeben
        return $default_language;
    }
    // Den Header auftrennen
    $accepted_languages = preg_split('/,\\s*/', $lang_variable);
    // Die Standardwerte einstellen
    $current_lang = $default_language;
    $current_q = 0;
    // Nun alle mitgegebenen Sprachen abarbeiten
    foreach ($accepted_languages as $accepted_language) {
        // Alle Infos über diese Sprache rausholen
        $res = preg_match('/^([a-z]{1,8}(?:-[a-z]{1,8})*)' . '(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i', $accepted_language, $matches);
        // war die Syntax gültig?
        if (!$res) {
            // Nein? Dann ignorieren
            continue;
        }
        // Sprachcode holen und dann sofort in die Einzelteile trennen
        $lang_code = explode('-', $matches[1]);
        // Wurde eine Qualität mitgegeben?
        if (isset($matches[2])) {
            // die Qualität benutzen
            $lang_quality = (double) $matches[2];
        } else {
            // Kompabilitätsmodus: Qualität 1 annehmen
            $lang_quality = 1.0;
        }
        // Bis der Sprachcode leer ist...
        while (count($lang_code)) {
            // mal sehen, ob der Sprachcode angeboten wird
            if (in_array(strtolower(join('-', $lang_code)), $allowed_languages)) {
                // Qualität anschauen
                if ($lang_quality > $current_q) {
                    // diese Sprache verwenden
                    $current_lang = strtolower(join('-', $lang_code));
                    $current_q = $lang_quality;
                    // Hier die innere while-Schleife verlassen
                    break;
                }
            }
            // Wenn wir im strengen Modus sind, die Sprache nicht versuchen zu minimalisieren
            if ($strict_mode) {
                // innere While-Schleife aufbrechen
                break;
            }
            // den rechtesten Teil des Sprachcodes abschneiden
            array_pop($lang_code);
        }
    }
    // die gefundene Sprache zurückgeben
    return $current_lang;
}
 /**
  * Add facebook user
  */
 public function addUserFacebook($aVals, $iFacebookUserId, $sAccessToken)
 {
     if (!defined('PHPFOX_IS_FB_USER')) {
         define('PHPFOX_IS_FB_USER', true);
     }
     //get facebook setting
     $bFbConnect = Phpfox::getParam('facebook.enable_facebook_connect');
     if ($bFbConnect == false) {
         return false;
     } else {
         if (Phpfox::getService('accountapi.facebook')->checkUserFacebook($iFacebookUserId) == false) {
             if (Phpfox::getParam('user.disable_username_on_sign_up')) {
                 $aVals['user_name'] = Phpfox::getLib('parse.input')->cleanTitle($aVals['full_name']);
             }
             $aVals['country_iso'] = null;
             if (Phpfox::getParam('user.split_full_name')) {
                 $aNameSplit = preg_split('[ ]', $aVals['full_name']);
                 $aVals['first_name'] = $aNameSplit[0];
                 unset($aNameSplit[0]);
                 $aVals['last_name'] = implode(' ', $aNameSplit);
             }
             $iUserId = Phpfox::getService('user.process')->add($aVals);
             if ($iUserId === false) {
                 return false;
             } else {
                 Phpfox::getService('facebook.process')->addUser($iUserId, $iFacebookUserId);
                 //update fb profile image to db
                 $bCheck = Phpfox::getService('accountapi.facebook')->addImagePicture($sAccessToken, $iUserId);
             }
         }
     }
     return true;
 }
 /**
  * Escapes a string to be used as a shell argument.
  *
  * @param string $argument The argument that will be escaped
  *
  * @return string The escaped argument
  */
 public static function escapeArgument($argument)
 {
     //Fix for PHP bug #43784 escapeshellarg removes % from given string
     //Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
     //@see https://bugs.php.net/bug.php?id=43784
     //@see https://bugs.php.net/bug.php?id=49446
     if ('\\' === DIRECTORY_SEPARATOR) {
         if ('' === $argument) {
             return escapeshellarg($argument);
         }
         $escapedArgument = '';
         $quote = false;
         foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
             if ('"' === $part) {
                 $escapedArgument .= '\\"';
             } elseif (self::isSurroundedBy($part, '%')) {
                 // Avoid environment variable expansion
                 $escapedArgument .= '^%"' . substr($part, 1, -1) . '"^%';
             } else {
                 // escape trailing backslash
                 if ('\\' === substr($part, -1)) {
                     $part .= '\\';
                 }
                 $quote = true;
                 $escapedArgument .= $part;
             }
         }
         if ($quote) {
             $escapedArgument = '"' . $escapedArgument . '"';
         }
         return $escapedArgument;
     }
     return escapeshellarg($argument);
 }
 function getSuggestion($word)
 {
     if ($fh = fopen($this->tmpfile, "w")) {
         fwrite($fh, "!\n");
         fwrite($fh, "^{$word}\n");
         fclose($fh);
     } else {
         die("Error opening tmp file.");
     }
     $data = shell_exec($this->cmd);
     $returnData = array();
     $dataArr = preg_split("/\n/", $data, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($dataArr as $dstr) {
         $matches = array();
         // Skip this line.
         if (strpos($dstr, "@") === 0) {
             continue;
         }
         preg_match("/\\& .* .* .*: (.*)/i", $dstr, $matches);
         if (!empty($matches[1])) {
             // For some reason, the exec version seems to add commas?
             $returnData[] = str_replace(",", "", $matches[1]);
         }
     }
     return $returnData;
 }
Beispiel #5
0
 private function formatVueGridName()
 {
     $gridName = preg_split('/(?=[A-Z])/', $this->modelName);
     $gridName = implode('-', $gridName);
     $gridName = ltrim($gridName, '-');
     return $gridName = strtolower($gridName);
 }
 public static function compile($source, $path, $todir, $importdirs)
 {
     // call Less to compile
     $parser = new lessc();
     $parser->setImportDir(array_keys($importdirs));
     $parser->setPreserveComments(true);
     $output = $parser->compile($source);
     // update url
     $arr = preg_split(CANVASLess::$rsplitbegin . CANVASLess::$kfilepath . CANVASLess::$rsplitend, $output, -1, PREG_SPLIT_DELIM_CAPTURE);
     $output = '';
     $file = $relpath = '';
     $isfile = false;
     foreach ($arr as $s) {
         if ($isfile) {
             $isfile = false;
             $file = $s;
             $relpath = CANVASLess::relativePath($todir, dirname($file));
             $output .= "\n#" . CANVASLess::$kfilepath . "{content: \"{$file}\";}\n";
         } else {
             $output .= ($file ? CANVASPath::updateUrl($s, $relpath) : $s) . "\n\n";
             $isfile = true;
         }
     }
     return $output;
 }
 /**
  *
  * @param String $file
  * @throws \Exception
  */
 public function __construct($file)
 {
     $this->_position = 0;
     if (is_array($file) && strlen(rtrim($file[0], chr(10) . chr(13) . "\n" . "\r")) == 400) {
         $this->file = $file;
     } else {
         if (is_file($file) && file_exists($file)) {
             $this->file = file($file);
         } else {
             if (is_string($file)) {
                 $this->file = preg_split('/\\r\\n|\\r|\\n/', $file);
                 if (empty(last($this->file))) {
                     array_pop($this->file);
                 }
             } else {
                 throw new \Exception("Arquivo: não existe");
             }
         }
     }
     $this->isRetorno = substr($this->file[0], 0, 9) == '02RETORNO' ? true : false;
     if (!in_array(substr($this->file[0], 76, 3), array_keys($this->bancos))) {
         throw new \Exception(sprintf("Banco: %s, inválido", substr($this->file[0], 76, 3)));
     }
     $this->header = new Header();
     $this->trailer = new Trailer();
 }
Beispiel #8
0
 /**
  * Constructs the class with given parameters and reads object related data from the bitstream.
  *
  * The following options are currently recognized:
  *  o vorbisContext -- Indicates whether to expect comments to be in the context of a vorbis bitstream or not. This
  *    option can be used to parse vorbis comments in another formats, eg FLAC, that do not use for example the
  *    framing flags. Defaults to true.
  *
  * @param HausDesign_Io_Reader $reader The reader object.
  * @param Array          $options Array of options.
  */
 public function __construct($reader, $options = array())
 {
     if (!isset($options['vorbisContext']) || $options['vorbisContext']) {
         parent::__construct($reader);
     } else {
         $this->_reader = $reader;
     }
     $this->_vendor = $this->_reader->read($this->_reader->readUInt32LE());
     $userCommentListLength = $this->_reader->readUInt32LE();
     for ($i = 0; $i < $userCommentListLength; $i++) {
         list($name, $value) = preg_split('/=/', $this->_reader->read($this->_reader->readUInt32LE()), 2);
         if (!isset($this->_comments[strtoupper($name)])) {
             $this->_comments[strtoupper($name)] = array();
         }
         $this->_comments[strtoupper($name)][] = $value;
     }
     if (!isset($options['vorbisContext']) || $options['vorbisContext']) {
         $this->_framingFlag = $this->_reader->readUInt8() & 0x1;
         if ($this->_framingFlag == 0) {
             require_once 'HausDesign/Media/Vorbis/Exception.php';
             throw new HausDesign_Media_Vorbis_Exception('Undecodable Vorbis stream');
         }
         $this->_reader->skip($this->_packetSize - $this->_reader->getOffset() + 30);
     }
 }
Beispiel #9
0
 function parse_in($value)
 {
     $values = preg_split('/\\s+/', trim($value));
     switch (count($values)) {
         case 1:
             $v1 = $values[0];
             return array($v1, $v1, $v1, $v1);
         case 2:
             $v1 = $values[0];
             $v2 = $values[1];
             return array($v1, $v2, $v1, $v2);
         case 3:
             $v1 = $values[0];
             $v2 = $values[1];
             $v3 = $values[2];
             return array($v1, $v2, $v3, $v2);
         case 4:
             $v1 = $values[0];
             $v2 = $values[1];
             $v3 = $values[2];
             $v4 = $values[3];
             return array($v1, $v2, $v3, $v4);
         default:
             // We newer should get there, because 'padding' value can contain from 1 to 4 widths
             return array(0, 0, 0, 0);
     }
 }
 /**
  * getFileForPhotoWithScale function.
  * 
  * @access private
  * @param Models\Photo $photo
  * @param mixed $scale
  * @return [$file, $temp, $mtime]
  */
 private static function getFileForPhotoWithScale(Models\Photo $photo, $scale)
 {
     $extension = $photo->extension;
     $bucket = 'other';
     $path = '';
     if ($scale == 'photo') {
         if ($photo->get('modified')) {
             $path = '/' . $photo->get('id') . '_mod.' . $extension;
         } else {
             $bucket = 'photo';
             $path = rtrim('/' . ltrim($photo->get('path'), '/'), '/') . '/' . $photo->get('filename');
         }
     } elseif ($scale == 'scaled') {
         $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'scaledsize');
         $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}";
     } elseif ($scale == 'thumbnail') {
         $thumbSize = Models\Preferences::valueForModuleWithKey('CameraLife', 'thumbsize');
         $path = "/{$photo->get('id')}_{$thumbSize}.{$extension}";
     } elseif (is_numeric($scale)) {
         $valid = preg_split('/[, ]+/', Models\Preferences::valueForModuleWithKey('CameraLife', 'optionsizes'));
         if (!in_array($scale, $valid)) {
             throw new \Exception('This image size has not been allowed');
         }
         $path = "/{$photo->get('id')}_{$scale}.{$extension}";
     } else {
         throw new \Exception('Missing or bad size parameter');
     }
     $fileStore = Models\FileStore::fileStoreWithName($bucket);
     list($file, $temp, $mtime) = $fileStore->getFile($path);
     if (!$file) {
         $photo->generateThumbnail();
         list($file, $temp, $mtime) = $fileStore->getFile($path);
     }
     return [$file, $temp, $mtime];
 }
Beispiel #11
0
 private function init()
 {
     $this->Controller = $this->Request->attributes->get('_template')->get('controller');
     $this->Route = $this->Request->attributes->get('_route');
     list(, $this->Vendor, $this->Bundle, ) = preg_split('/(?=[A-Z])/', $this->Request->attributes->get('_template')->get('bundle'));
     $this->BundlePath = __DIR__ . '/../../' . $this->Bundle . 'Bundle';
 }
Beispiel #12
0
function api_get_canonical_id($id)
{
    $alias_file = ROOT . "/.htaliases";
    $canon = api_get_request_id($id);
    if ($id == "" || !file_exists($alias_file)) {
        return $canon;
    }
    $fd = fopen($alias_file, "r");
    if ($fd == FALSE) {
        return $canon;
    }
    while (!feof($fd)) {
        $line = fgets($fd, 1024);
        if (substr($line, 0, 1) == "#") {
            continue;
        }
        $match = preg_split('/( |\\t|\\r|\\n)+/', $line);
        if ($id == $match[0]) {
            $canon = $match[1];
            break;
        }
    }
    fclose($fd);
    return $canon;
}
Beispiel #13
0
 /**
  * @param  string $string
  * @return Diff[]
  */
 public function parse($string)
 {
     $lines = preg_split('(\\r\\n|\\r|\\n)', $string);
     $lineCount = count($lines);
     $diffs = array();
     $diff = null;
     $collected = array();
     for ($i = 0; $i < $lineCount; ++$i) {
         if (preg_match('(^---\\s+(?P<file>\\S+))', $lines[$i], $fromMatch) && preg_match('(^\\+\\+\\+\\s+(?P<file>\\S+))', $lines[$i + 1], $toMatch)) {
             if ($diff !== null) {
                 $this->parseFileDiff($diff, $collected);
                 $diffs[] = $diff;
                 $collected = array();
             }
             $diff = new Diff($fromMatch['file'], $toMatch['file']);
             ++$i;
         } else {
             if (preg_match('/^(?:diff --git |index [\\da-f\\.]+|[+-]{3} [ab])/', $lines[$i])) {
                 continue;
             }
             $collected[] = $lines[$i];
         }
     }
     if (count($collected) && $diff !== null) {
         $this->parseFileDiff($diff, $collected);
         $diffs[] = $diff;
     }
     return $diffs;
 }
Beispiel #14
0
 /**
  *
  */
 public function import($csv)
 {
     // convert to UTF-8
     $head = substr($csv, 0, 4096);
     $charset = rcube_charset::detect($head, RCUBE_CHARSET);
     $csv = rcube_charset::convert($csv, $charset);
     $head = '';
     $this->map = array();
     // Parse file
     foreach (preg_split("/[\r\n]+/", $csv) as $line) {
         $elements = $this->parse_line($line);
         if (empty($elements)) {
             continue;
         }
         // Parse header
         if (empty($this->map)) {
             $this->parse_header($elements);
             if (empty($this->map)) {
                 break;
             }
         } else {
             $this->csv_to_vcard($elements);
         }
     }
 }
Beispiel #15
0
 public function run(InputInterface $input, OutputInterface $output)
 {
     // extract real command name
     $tokens = preg_split('{\\s+}', $input->__toString());
     $args = array();
     foreach ($tokens as $token) {
         if ($token && $token[0] !== '-') {
             $args[] = $token;
             if (count($args) >= 2) {
                 break;
             }
         }
     }
     // show help for this command if no command was found
     if (count($args) < 2) {
         return parent::run($input, $output);
     }
     // change to global dir
     $config = Factory::createConfig();
     chdir($config->get('home'));
     $this->getIO()->writeError('<info>Changed current directory to ' . $config->get('home') . '</info>');
     // create new input without "global" command prefix
     $input = new StringInput(preg_replace('{\\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\\b}', '', $input->__toString(), 1));
     $this->getApplication()->resetComposer();
     return $this->getApplication()->run($input, $output);
 }
/**
 * http://www.php.net/manual/en/function.phpinfo.php
 * code at adspeed dot com
 * 09-Dec-2005 11:31
 * This function parses the phpinfo output to get details about a PHP module.
 */
function ckeditor_parse_php_info()
{
    ob_start();
    phpinfo(INFO_MODULES);
    $s = ob_get_contents();
    ob_end_clean();
    $s = strip_tags($s, '<h2><th><td>');
    $s = preg_replace('/<th[^>]*>([^<]+)<\\/th>/', "<info>\\1</info>", $s);
    $s = preg_replace('/<td[^>]*>([^<]+)<\\/td>/', "<info>\\1</info>", $s);
    $vTmp = preg_split('/(<h2>[^<]+<\\/h2>)/', $s, -1, PREG_SPLIT_DELIM_CAPTURE);
    $vModules = array();
    for ($i = 1; $i < count($vTmp); $i++) {
        if (preg_match('/<h2>([^<]+)<\\/h2>/', $vTmp[$i], $vMat)) {
            $vName = trim($vMat[1]);
            $vTmp2 = explode("\n", $vTmp[$i + 1]);
            foreach ($vTmp2 as $vOne) {
                $vPat = '<info>([^<]+)<\\/info>';
                $vPat3 = "/{$vPat}\\s*{$vPat}\\s*{$vPat}/";
                $vPat2 = "/{$vPat}\\s*{$vPat}/";
                if (preg_match($vPat3, $vOne, $vMat)) {
                    // 3cols
                    $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]), trim($vMat[3]));
                } elseif (preg_match($vPat2, $vOne, $vMat)) {
                    // 2cols
                    $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
                }
            }
        }
    }
    return $vModules;
}
Beispiel #17
0
 static function parse($args)
 {
     $method = strtolower(@$args[1]);
     $string = @$args[0];
     if (empty($string)) {
         return false;
     }
     if (!method_exists('kirbytext', $method)) {
         return $string;
     }
     $replace = array('(', ')');
     $string = str_replace($replace, '', $string);
     $attr = array_merge(self::$tags, self::$attr);
     $search = preg_split('!(' . implode('|', $attr) . '):!i', $string, false, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
     $result = array();
     $num = 0;
     foreach ($search as $key) {
         if (!isset($search[$num + 1])) {
             break;
         }
         $key = trim($search[$num]);
         $value = trim($search[$num + 1]);
         $result[$key] = $value;
         $num = $num + 2;
     }
     return self::$method($result);
 }
Beispiel #18
0
 /**
  * Filter
  *
  * @return void
  */
 public function filter()
 {
     /*
      * Variable qui contient la chaine de recherche
      */
     if (is_array($this->terms)) {
         $stringSearch = implode(' ', $this->terms);
     } else {
         $stringSearch = $this->terms;
     }
     /*
      * On divise en mots (séparé par des espace)
      */
     $words = preg_split('`\\s+`', $stringSearch, -1, PREG_SPLIT_NO_EMPTY);
     if (count($words) > 1) {
         array_unshift($words, $stringSearch);
     }
     $words = array_unique($words);
     $conds = [];
     foreach ($words as $index => $word) {
         foreach ($this->columns as $colName) {
             $cond = $this->queryBuilder->expr()->like($colName, ':word_' . ($index + 1));
             $this->queryBuilder->setParameter('word_' . ($index + 1), '%' . $word . '%');
             $conds[] = $cond;
         }
     }
     $this->queryBuilder->andWhere(implode(' OR ', $conds));
 }
Beispiel #19
0
 /**
  * {@inheritdoc}
  */
 public function parseResponse($data)
 {
     if ($data === '') {
         return array();
     }
     $info = array();
     $current = null;
     $infoLines = preg_split('/\\r?\\n/', $data);
     if (isset($infoLines[0]) && $infoLines[0][0] !== '#') {
         return parent::parseResponse($data);
     }
     foreach ($infoLines as $row) {
         if ($row === '') {
             continue;
         }
         if (preg_match('/^# (\\w+)$/', $row, $matches)) {
             $info[$matches[1]] = array();
             $current =& $info[$matches[1]];
             continue;
         }
         list($k, $v) = $this->parseRow($row);
         $current[$k] = $v;
     }
     return $info;
 }
Beispiel #20
0
 public function __construct($kirbytext, $name, $tag)
 {
     if (is_null($kirbytext)) {
         $kirbytext = new Kirbytext('');
     }
     $this->page = $kirbytext->field->page;
     $this->kirbytext = $kirbytext;
     $this->name = $name;
     $this->html = kirbytext::$tags[$name]['html'];
     // get a list with all attributes
     $attributes = isset(kirbytext::$tags[$name]['attr']) ? (array) kirbytext::$tags[$name]['attr'] : array();
     // add the name as first attribute
     array_unshift($attributes, $name);
     if (is_array($tag)) {
         foreach ($attributes as $key) {
             if (isset($tag[$key])) {
                 $this->attr[$key] = $tag[$key];
             }
         }
     } else {
         // extract all attributes
         $search = preg_split('!(' . implode('|', $attributes) . '):!i', $tag, false, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
         $num = 0;
         foreach ($search as $key) {
             if (!isset($search[$num + 1])) {
                 break;
             }
             $key = trim($search[$num]);
             $value = trim($search[$num + 1]);
             $this->attr[$key] = $value;
             $num = $num + 2;
         }
     }
 }
 function run_transaction($vars)
 {
     foreach ($vars as $kk => $vv) {
         $v = urlencode($vv);
         $k = urlencode($kk);
         $vars1[] = "{$k}={$v}";
     }
     $vars1 = join('&', $vars1);
     $ret = cc_core_get_url("https://4tknox.au.com/cgi-bin/themerchant.au.com/ecom/external2.pl", $vars1);
     $delim = "\n";
     $arr = preg_split("({$delim})", $ret);
     $res["RESULT_CODE"] = strtolower($arr[0]);
     if (@strpos($ret, "{$delim}.{$delim}") === false) {
         $res["RESPONSE_TEXT"] = $arr[1];
     } else {
         $ret = substr($ret, @strpos($ret, "{$delim}.{$delim}"));
         $ret = str_replace($delim, "&", $ret);
         parse_str($ret, $ret);
         $res["RESPONSE_TEXT"] = $ret["response_text"];
         $res["TXN_REF"] = $ret["txn_ref"];
         $res["RESPONSE_CODE"] = $ret["response_code"];
         $res["RESULT"] = $ret["result"];
     }
     //var_dump($res);
     return $res;
 }
Beispiel #22
0
 /**
  * @return email_liste as an array
  */
 public function explodeEmailsListe()
 {
     //var_dump($this->emails_liste)."<br>";
     $this->emails_liste = array_unique(preg_split("/[\\s,]+/", $this->emails_liste));
     //$this->emails_liste = preg_split("/[\s,]+/", $this->emails_liste);
     //var_dump($this->emails_liste)."<br>";
 }
Beispiel #23
0
 /**
  * Forge a new object based on a request.
  * @param  RequestInterface $request
  * @return Response
  */
 public static function forge(RequestInterface $request)
 {
     $headerSize = $request->getInfo(CURLINFO_HEADER_SIZE);
     $response = $request->getRawResponse();
     $content = strlen($response) === $headerSize ? '' : substr($response, $headerSize);
     $rawHeaders = rtrim(substr($response, 0, $headerSize));
     $headers = array();
     foreach (preg_split('/(\\r?\\n)/', $rawHeaders) as $header) {
         if ($header) {
             $headers[] = $header;
         } else {
             $headers = array();
         }
     }
     $headerBag = array();
     $info = $request->getInfo();
     $status = explode(' ', $headers[0]);
     $status = explode('/', $status[0]);
     unset($headers[0]);
     foreach ($headers as $header) {
         list($key, $value) = explode(': ', $header);
         $headerBag[trim($key)] = trim($value);
     }
     $response = new static($content, $info['http_code'], $headerBag);
     $response->setProtocolVersion($status[1]);
     $response->setCharset(substr(strstr($response->headers->get('Content-Type'), '='), 1));
     return $response;
 }
 public function check()
 {
     $checkFailed = '';
     $formValue = trim($this->gp[$this->formFieldName]);
     if (strlen($formValue) > 0) {
         $checkValue = $this->utilityFuncs->getSingle($this->settings['params'], 'words');
         if (!is_array($checkValue)) {
             $checkValue = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $checkValue);
         }
         $error = FALSE;
         $array = preg_split('//', $formValue, -1, PREG_SPLIT_NO_EMPTY);
         foreach ($array as $idx => $char) {
             if (!in_array($char, $checkValue)) {
                 $error = TRUE;
             }
         }
         if ($error) {
             //remove userfunc settings and only store comma seperated words
             $this->settings['params']['words'] = implode(',', $checkValue);
             unset($this->settings['params']['words.']);
             $checkFailed = $this->getCheckFailed();
         }
     }
     return $checkFailed;
 }
 /**
  * Call external Method
  *
  * @param \Smarty_Internal_Data $data
  * @param string                $name external method names
  * @param array                 $args argument array
  *
  * @return mixed
  * @throws SmartyException
  */
 public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
 {
     /* @var Smarty $data ->smarty */
     $smarty = isset($data->smarty) ? $data->smarty : $data;
     if (!isset($smarty->ext->{$name})) {
         $class = 'Smarty_Internal_Method_' . ucfirst($name);
         if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
             if (!isset($this->_property_info[$prop = $match[2]])) {
                 // convert camel case to underscored name
                 $this->resolvedProperties[$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE)));
                 $this->_property_info[$prop] = property_exists($data, $pn) ? 1 : ($data->_objType == 2 && property_exists($smarty, $pn) ? 2 : 0);
             }
             if ($this->_property_info[$prop]) {
                 $pn = $this->resolvedProperties[$prop];
                 if ($match[1] == 'get') {
                     return $this->_property_info[$prop] == 1 ? $data->{$pn} : $data->smarty->{$pn};
                 } else {
                     return $this->_property_info[$prop] == 1 ? $data->{$pn} = $args[0] : ($data->smarty->{$pn} = $args[0]);
                 }
             } elseif (!class_exists($class)) {
                 throw new SmartyException("property '{$pn}' does not exist.");
             }
         }
         if (class_exists($class)) {
             $callback = array($smarty->ext->{$name} = new $class(), $name);
         }
     } else {
         $callback = array($smarty->ext->{$name}, $name);
     }
     array_unshift($args, $data);
     if (isset($callback) && $callback[0]->objMap | $data->_objType) {
         return call_user_func_array($callback, $args);
     }
     return call_user_func_array(array(new Smarty_Internal_Undefined(), $name), $args);
 }
 function paginate($term = null, $paginateOptions = array())
 {
     $this->_controller->paginate = array('SearchIndex' => array_merge_recursive(array('conditions' => array(array('SearchIndex.active' => 1), 'or' => array(array('SearchIndex.published' => null), array('SearchIndex.published <= ' => date('Y-m-d H:i:s'))))), $paginateOptions));
     if (isset($this->_controller->request->params['named']['type']) && $this->_controller->request->params['named']['type'] != 'All') {
         $this->_controller->request->data['SearchIndex']['type'] = Sanitize::escape($this->_controller->request->params['named']['type']);
         $this->_controller->paginate['SearchIndex']['conditions']['model'] = $this->_controller->data['SearchIndex']['type'];
     }
     // Add term condition, and sorting
     if (!$term && isset($this->_controller->request->params['named']['term'])) {
         $term = $this->_controller->request->params['named']['term'];
     }
     if ($term) {
         $term = Sanitize::escape($term);
         $this->_controller->request->data['SearchIndex']['term'] = $term;
         $term = implode(' ', array_map(array($this, 'replace'), preg_split('/[\\s_]/', $term))) . '*';
         if ($this->like) {
             $this->_controller->paginate['SearchIndex']['conditions'][] = array('or' => array("MATCH(data) AGAINST('{$term}')", 'SearchIndex.data LIKE' => "%{$this->_controller->data['SearchIndex']['term']}%"));
         } else {
             $this->_controller->paginate['SearchIndex']['conditions'][] = "MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE)";
         }
         $this->_controller->paginate['SearchIndex']['fields'] = "*, MATCH(data) AGAINST('{$term}' IN BOOLEAN MODE) AS score";
         if (empty($this->_controller->paginate['SearchIndex']['order'])) {
             $this->_controller->paginate['SearchIndex']['order'] = "score DESC";
         }
     }
     return $this->_controller->paginate('SearchIndex');
 }
Beispiel #27
0
function parse_output(&$obj, &$parts, $i)
{
    $ctype = $obj->ctype_primary . '/' . $obj->ctype_secondary;
    switch ($ctype) {
        case 'text/plain':
            if (!empty($obj->disposition) && $obj->disposition == 'attachment') {
                $names = preg_split('/\\;/', $obj->headers["content-disposition"]);
                $names = preg_split('/\\=/', $names[1]);
                $aux['name'] = $names[1];
                $aux['content-type'] = $obj->headers["content-type"];
                $aux['part'] = $i;
                $parts['attachments'][] = $aux;
            } elseif (isset($obj->body)) {
                $parts['text'][] = $obj->body;
            }
            break;
        case 'text/html':
            if (!empty($obj->disposition) && $obj->disposition == 'attachment') {
                $names = preg_split('/\\;/', $obj->headers["content-disposition"]);
                $names = preg_split('/\\=/', $names[1]);
                $aux['name'] = $names[1];
                $aux['content-type'] = $obj->headers["content-type"];
                $aux['part'] = $i;
                $parts['attachments'][] = $aux;
            } elseif (isset($obj->body)) {
                $parts['html'][] = $obj->body;
            }
            break;
        default:
            break;
    }
}
	public function parse( $contents, $attributes ) {		
		$data = array( "headers" => array(), "rows" => array() );
		
		if ( !isset($attributes["separator"]) ) {
			return array( "error" => 'noseparator' );
		}
		if ( !isset(self::$separators[$attributes["separator"]]) ) {
			return array( "error" => array( 'invalidseparator', $attributes["separator"] ) );
		}
		
		$separator = self::$separators[$attributes["separator"]];
		
		$rows = array();
		foreach ( explode( "\n", $contents ) as $line ) {
			$rows[] = preg_split( $separator, $line );
		}
		
		if ( count($rows) <= 0 ) {
			return $data;
		}
		
		$data["headers"] = array_shift($rows); // the first line should be the header names
		
		foreach ( $rows as $row ) {
			$datarow = array();
			foreach ( $data["headers"] as $i => $header ) {
				if ( isset($row[$i]) ) {
					$datarow[$header] = $row[$i];
				}
			}
			$data["rows"][] = $datarow;
		}
		
		return $data;
	}
Beispiel #29
0
 function WriteHTML($html)
 {
     // Parseur HTML
     $html = str_replace("\n", ' ', $html);
     $a = preg_split('/<(.*)>/U', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
     foreach ($a as $i => $e) {
         if ($i % 2 == 0) {
             // Texte
             if ($this->HREF) {
                 $this->PutLink($this->HREF, $e);
             } else {
                 $this->Write(5, $e);
             }
         } else {
             // Balise
             if ($e[0] == '/') {
                 $this->CloseTag(strtoupper(substr($e, 1)));
             } else {
                 // Extraction des attributs
                 $a2 = explode(' ', $e);
                 $tag = strtoupper(array_shift($a2));
                 $attr = array();
                 foreach ($a2 as $v) {
                     if (preg_match('/([^=]*)=["\']?([^"\']*)/', $v, $a3)) {
                         $attr[strtoupper($a3[1])] = $a3[2];
                     }
                 }
                 $this->OpenTag($tag, $attr);
             }
         }
     }
 }