コード例 #1
1
    /**
     * {@inheritdoc}
     */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $class_name = ltrim($input->getArgument('class_name'), '\\');
        $namespace_root = $input->getArgument('namespace_root_path');
        $match = [];
        preg_match('/([a-zA-Z0-9_]+\\\\[a-zA-Z0-9_]+)\\\\(.+)/', $class_name, $match);
        if ($match) {
            $root_namespace = $match[1];
            $rest_fqcn = $match[2];
            $proxy_filename = $namespace_root . '/ProxyClass/' . str_replace('\\', '/', $rest_fqcn) . '.php';
            $proxy_class_name = $root_namespace . '\\ProxyClass\\' . $rest_fqcn;
            $proxy_class_string = $this->proxyBuilder->build($class_name);
            $file_string = <<<EOF
<?php
// @codingStandardsIgnoreFile

/**
 * This file was generated via php core/scripts/generate-proxy-class.php '{$class_name}' "{$namespace_root}".
 */
{{ proxy_class_string }}
EOF;
            $file_string = str_replace(['{{ proxy_class_name }}', '{{ proxy_class_string }}'], [$proxy_class_name, $proxy_class_string], $file_string);
            mkdir(dirname($proxy_filename), 0775, TRUE);
            file_put_contents($proxy_filename, $file_string);
            $output->writeln(sprintf('Proxy of class %s written to %s', $class_name, $proxy_filename));
        }
    }
コード例 #2
0
 /**
  * Add a View instance to the Collector
  *
  * @param \Illuminate\View\View $view
  */
 public function addView(View $view)
 {
     $name = $view->getName();
     $path = $view->getPath();
     if (!is_object($path)) {
         if ($path) {
             $path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
         }
         if (substr($path, -10) == '.blade.php') {
             $type = 'blade';
         } else {
             $type = pathinfo($path, PATHINFO_EXTENSION);
         }
     } else {
         $type = get_class($view);
         $path = '';
     }
     if (!$this->collect_data) {
         $params = array_keys($view->getData());
     } else {
         $data = array();
         foreach ($view->getData() as $key => $value) {
             $data[$key] = $this->exporter->exportValue($value);
         }
         $params = $data;
     }
     $this->templates[] = array('name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type);
 }
コード例 #3
0
ファイル: helpers.php プロジェクト: benhanks040888/rmyrfl
 /**
  * Get the URL to uploads_path folder
  *
  * @param  string  $path
  * @param  bool    $secure
  * @return string
  */
 function uploads_path($upload)
 {
     if (file_exists(public_path() . 'uploads/' . $upload)) {
         return 'no image broh';
     }
     return public_path() . '/uploads/' . ltrim($upload, '/');
 }
コード例 #4
0
 private function convertToBytes($memoryLimit)
 {
     if ('-1' === $memoryLimit) {
         return -1;
     }
     $memoryLimit = strtolower($memoryLimit);
     $max = strtolower(ltrim($memoryLimit, '+'));
     if (0 === strpos($max, '0x')) {
         $max = intval($max, 16);
     } elseif (0 === strpos($max, '0')) {
         $max = intval($max, 8);
     } else {
         $max = intval($max);
     }
     switch (substr($memoryLimit, -1)) {
         case 't':
             $max *= 1024;
         case 'g':
             $max *= 1024;
         case 'm':
             $max *= 1024;
         case 'k':
             $max *= 1024;
     }
     return $max;
 }
コード例 #5
0
ファイル: CoreLog.php プロジェクト: ErosZy/CSF
 public function __construct()
 {
     $logPath = CoreHelper::loadConfig("log_path", "config");
     $logFileExtension = CoreHelper::loadConfig("log_file_extension", "config");
     $logThreshold = CoreHelper::loadConfig("log_threshold", "config");
     $logDateFormat = CoreHelper::loadConfig("log_date_format", "config");
     $logFilePermissions = CoreHelper::loadConfig("log_file_permissions", "config");
     $this->_log_path = $logPath !== '' ? $logPath : APPPATH . 'logs/';
     $this->_file_ext = isset($logFileExtension) && $logFileExtension !== '' ? ltrim($logFileExtension, '.') : 'php';
     file_exists($this->_log_path) || mkdir($this->_log_path, 0755, true);
     if (!is_dir($this->_log_path) || !CoreHelper::isWriteable($this->_log_path)) {
         $this->_enabled = false;
     }
     if (is_numeric($logThreshold)) {
         $this->_threshold = (int) $logThreshold;
     } elseif (is_array($logThreshold)) {
         $this->_threshold = 0;
         $this->_threshold_array = array_flip($logThreshold);
     }
     if (!empty($logDateFormat)) {
         $this->_date_fmt = $logDateFormat;
     }
     if (!empty($logFilePermissions) && is_int($logFilePermissions)) {
         $this->_file_permissions = $logFilePermissions;
     }
 }
コード例 #6
0
ファイル: seo_locale.php プロジェクト: JoniWeiss/JoniWebGirl
 static function load_request($allow)
 {
     $uri = getRequestURI();
     $parts = explode('?', $uri);
     $uri = $parts[0];
     $path = ltrim(substr($uri, strlen(WEBPATH) + 1), '/');
     if (empty($path)) {
         return $allow;
     } else {
         $rest = strpos($path, '/');
         if ($rest === false) {
             if (strpos($path, '?') === 0) {
                 // only a parameter string
                 return $allow;
             }
             $l = $path;
         } else {
             $l = substr($path, 0, $rest);
         }
     }
     $locale = validateLocale($l, 'seo_locale');
     if ($locale) {
         // set the language cookie and redirect to the "base" url
         zp_setCookie('dynamic_locale', $locale);
         $uri = pathurlencode(preg_replace('|/' . $l . '[/$]|', '/', $uri));
         if (isset($parts[1])) {
             $uri .= '?' . $parts[1];
         }
         header("HTTP/1.0 302 Found");
         header("Status: 302 Found");
         header('Location: ' . $uri);
         exitZP();
     }
     return $allow;
 }
コード例 #7
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];
 }
コード例 #8
0
 private function formatVueGridName()
 {
     $gridName = preg_split('/(?=[A-Z])/', $this->modelName);
     $gridName = implode('-', $gridName);
     $gridName = ltrim($gridName, '-');
     return $gridName = strtolower($gridName);
 }
コード例 #9
0
 /**
  *
  * @param string $value
  * @return string
  */
 protected function getFilePath($value)
 {
     if (null !== $this->rawValue) {
         $value = $this->rawValue;
     }
     return $this->internalBasePath . '/' . ltrim($value, '/');
 }
コード例 #10
0
ファイル: function.php プロジェクト: stonepeng/b2c
/**
 * 组装路径。整理路径包括:
 * <ol>
 * <li>整理目录分隔符为标准形式。</li>
 * <li>连接多段路径,清理多余的目录分隔符。</li>
 * <li>空的或无效的路径段将被忽略。</li>
 * </ol>
 * @param string $_ 可变参数,要组装的路径段。
 * @return string 返回组装后的路径,空路径返回 null。
 * @example path('/www', 'sites', 'www.example.com', 'index.php'); // 结果:/www/sites/www.example.com/index.php
 */
function path($_)
{
    $ps = array();
    $n = func_num_args();
    for ($i = 0; $i < $n; $i++) {
        $p = func_get_arg($i);
        if (is_object($p) && method_exists($p, '__toString')) {
            $p = "{$p}";
        }
        if (!is_scalar($p)) {
            continue;
        }
        $p = str_replace(DSC, DS, $p);
        if ($n > 1) {
            if ($i > 0 && $i + 1 < $n) {
                $p = trim($p, DS);
            } else {
                if ($i === 0) {
                    $p = rtrim($p, DS);
                } else {
                    $p = ltrim($p, DS);
                }
            }
        }
        if (strlen($p) < 1) {
            continue;
        }
        $ps[] = $p;
    }
    return implode(DS, $ps);
}
コード例 #11
0
	public function process(Vtiger_Request $request)
	{
		$qualifiedModuleName = $request->getModule(false);
		$moduleModel = Settings_Vtiger_CompanyDetails_Model::getInstance();
		$status = false;

		if ($request->get('organizationname')) {
			$saveLogo = $status = true;
			if (!empty($_FILES['logo']['name'])) {
				$logoDetails = $_FILES['logo'];
				$fileType = explode('/', $logoDetails['type']);
				$fileType = $fileType[1];

				if (!$logoDetails['size'] || !in_array($fileType, Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
					$saveLogo = false;
				}

				//mime type check 
				$mimeType = Vtiger_Functions::getMimeContentType($logoDetails['tmp_name']);
				$mimeTypeContents = explode('/', $mimeType);
				if (!$logoDetails['size'] || $mimeTypeContents[0] != 'image' || !in_array($mimeTypeContents[1], Settings_Vtiger_CompanyDetails_Model::$logoSupportedFormats)) {
					$saveLogo = false;
				}

				// Check for php code injection
				$imageContents = file_get_contents($_FILES["logo"]["tmp_name"]);
				if (preg_match('/(<\?php?(.*?))/i', $imageContents) == 1) {
					$saveLogo = false;
				}
				if ($saveLogo) {
					$moduleModel->saveLogo();
				}
			} else {
				$saveLogo = true;
			}
			$fields = $moduleModel->getFields();
			foreach ($fields as $fieldName => $fieldType) {
				$fieldValue = $request->get($fieldName);
				if ($fieldName === 'logoname') {
					if (!empty($logoDetails['name'])) {
						$fieldValue = ltrim(basename(" " . $logoDetails['name']));
					} else {
						$fieldValue = $moduleModel->get($fieldName);
					}
				}
				$moduleModel->set($fieldName, $fieldValue);
			}
			$moduleModel->save();
		}

		$reloadUrl = $moduleModel->getIndexViewUrl();
		if ($saveLogo && $status) {
			
		} else if (!$saveLogo) {
			$reloadUrl .= '&error=LBL_INVALID_IMAGE';
		} else {
			$reloadUrl = $moduleModel->getEditViewUrl() . '&error=LBL_FIELDS_INFO_IS_EMPTY';
		}
		header('Location: ' . $reloadUrl);
	}
コード例 #12
0
ファイル: Report.php プロジェクト: Evil1991/PrestaShop-1.4
 /**
  * Returns report collection name.
  *
  * @return  string
  */
 protected function getCollectionName()
 {
     if (null !== $this->name) {
         return sprintf('%s/%s', parent::getCollectionName(), ltrim($this->name, '/'));
     }
     return parent::getCollectionName();
 }
コード例 #13
0
 /**
  * Returns the path relative to the root.
  *
  * @param  string $path
  * @return string
  */
 protected function getRelativePath($path)
 {
     if (0 === strpos($path, App::path())) {
         $path = ltrim(str_replace('\\', '/', substr($path, strlen(App::path()))), '/');
     }
     return $path;
 }
コード例 #14
0
ファイル: Url.php プロジェクト: emilymwang8/cms
 /**
  * 拼接URL
  * @param $uri 可以传入Controller名称
  * @param string $type
  * @param array $params
  * @param bool $toLower 是否需要将uri换成小写
  * @return string
  */
 public static function build_query_url($uri, $params = array(), $toLower = true, $type = "")
 {
     $class_name = ereg_replace('Controller$', '', $uri);
     $arr = explode("_", $class_name);
     if ($toLower) {
         $uri = strtolower(implode("/", $arr));
     } else {
         $uri = implode("/", $arr);
     }
     if (empty($type) && BASE_URI_PRI) {
         $resUri = "/" . BASE_URI_PRI . "/" . ltrim($uri, "/");
     } elseif (empty($type)) {
         $resUri = "/" . ltrim($uri, "/");
     } else {
         $url_type = APF::get_instance()->get_config("domain_type");
         if ($url_type[$type]) {
             $resUri = "/" . $url_type[$type] . "/" . ltrim($uri, "/");
         } else {
             $resUri = "/" . ltrim($uri, "/");
         }
     }
     if (!empty($params) && is_array($params)) {
         $resUri .= "?" . http_build_query($params);
     }
     $base_domain = APF::get_instance()->get_config('base_domain');
     return self::get_protocol_name() . "://" . $base_domain . $resUri;
 }
コード例 #15
0
ファイル: wizard.php プロジェクト: Satariall/izurit
 function CWizardBase($wizardName, $package)
 {
     $this->wizardName = $wizardName;
     $this->package = $package;
     $this->wizardSteps = array();
     $this->currentStepID = null;
     $this->firstStepID = null;
     $this->nextButtonID = "StepNext";
     $this->prevButtonID = "StepPrevious";
     $this->finishButtonID = "StepFinish";
     $this->cancelButtonID = "StepCancel";
     $this->nextStepHiddenID = "NextStepID";
     $this->prevStepHiddenID = "PreviousStepID";
     $this->finishStepHiddenID = "FinishStepID";
     $this->cancelStepHiddenID = "CancelStepID";
     $this->currentStepHiddenID = "CurrentStepID";
     $this->variablePrefix = "__wiz_";
     $this->formName = "__wizard_form";
     $this->formActionScript = "/" . ltrim($_SERVER["REQUEST_URI"], "/");
     $this->returnOutput = false;
     $this->defaultVars = array();
     $this->arTemplates = array();
     $this->defaultTemplate = null;
     $this->useAdminTemplate = true;
 }
コード例 #16
0
 private function cleanData($dirtData)
 {
     $dirtData = str_replace("&nbsp;", "", $dirtData);
     $dirtData = ltrim($dirtData);
     $dirtData = rtrim($dirtData);
     return trim($dirtData);
 }
コード例 #17
0
 public function itemList($options = [])
 {
     $session = Yii::$app->session;
     $moduleId = Yii::$app->controller->module->id;
     if (isset($options['sub-directory'])) {
         $session->set($moduleId, ['path' => '/' . ltrim($options['sub-directory'], '/')]);
     }
     //$session->remove($moduleId);
     $dir = $this->routes->uploadDir . $session->get($moduleId)['path'];
     if (is_dir($dir)) {
         //echo $dir;
         $files = \yii\helpers\FileHelper::findFiles($dir, ['recursive' => false]);
         $files_r = [];
         if (!isset($options['show-directory']) || intval($options['show-directory']) === 1) {
             foreach (glob($dir . '/*', GLOB_ONLYDIR) as $filename) {
                 $files_r[] = $filename;
             }
         }
         foreach ($files as $value) {
             $files_r[] = str_replace('\\', '/', $value);
         }
     } else {
         $message = 'Path ' . $session->get($moduleId)['path'] . ' not found!.';
         $session->remove($moduleId);
         throw new \yii\web\HttpException(500, $message);
     }
     return $files_r;
 }
コード例 #18
0
ファイル: Session.php プロジェクト: clee03/metal
 public function init()
 {
     /** @var Uri $uri */
     $uri = $this->grav['uri'];
     $config = $this->grav['config'];
     $is_admin = false;
     $session_timeout = $config->get('system.session.timeout', 1800);
     $session_path = $config->get('system.session.path', '/' . ltrim($uri->rootUrl(false), '/'));
     // Activate admin if we're inside the admin path.
     if ($config->get('plugins.admin.enabled')) {
         $route = $config->get('plugins.admin.route');
         $base = '/' . trim($route, '/');
         if (substr($uri->route(), 0, strlen($base)) == $base) {
             $session_timeout = $config->get('plugins.admin.session.timeout', 1800);
             $is_admin = true;
         }
     }
     if ($config->get('system.session.enabled') || $is_admin) {
         // Define session service.
         parent::__construct($session_timeout, $session_path);
         $unique_identifier = GRAV_ROOT;
         $this->setName($config->get('system.session.name', 'grav_site') . '-' . substr(md5($unique_identifier), 0, 7) . ($is_admin ? '-admin' : ''));
         $this->start();
         setcookie(session_name(), session_id(), time() + $session_timeout, $session_path);
     }
 }
コード例 #19
0
 private static function parseParameters($text)
 {
     $text = preg_replace('/[\\x{00a0}\\x{200b}]+/u', ' ', $text);
     if (!preg_match_all(static::$argumentsRegex, $text, $matches, PREG_SET_ORDER)) {
         return ltrim($text) ? array(ltrim($text) => null) : array();
     }
     $parameters = array();
     foreach ($matches as $match) {
         if (!empty($match[1])) {
             $parameters[strtolower($match[1])] = stripcslashes($match[2]);
         } elseif (!empty($match[3])) {
             $parameters[strtolower($match[3])] = stripcslashes($match[4]);
         } elseif (!empty($match[5])) {
             $parameters[strtolower($match[5])] = stripcslashes($match[6]);
         } elseif (isset($match[7]) && strlen($match[7])) {
             $parameters[stripcslashes($match[7])] = null;
         } elseif (isset($match[8])) {
             $parameters[stripcslashes($match[8])] = null;
         }
     }
     foreach ($parameters as $key => $value) {
         if (false !== strpos($value, '<') && 1 !== preg_match('/^[^<]*+(?:<[^>]*+>[^<]*+)*+$/', $value)) {
             $parameters[$key] = '';
         }
     }
     return $parameters;
 }
コード例 #20
0
ファイル: FinderController.php プロジェクト: 4nxiety/pagekit
 /**
  * @Request({"path"})
  */
 public function indexAction($path)
 {
     if (!($dir = $this->getPath())) {
         return $this->error(__('Invalid path.'));
     }
     if (!is_dir($dir) || '-' === ($mode = $this->getMode($dir))) {
         throw new ForbiddenException(__('Permission denied.'));
     }
     $data = array_fill_keys(['items'], []);
     $data['mode'] = $mode;
     $finder = App::finder();
     $finder->sort(function ($a, $b) {
         return $b->getRealpath() > $a->getRealpath() ? -1 : 1;
     });
     foreach ($finder->depth(0)->in($dir) as $file) {
         if ('-' === ($mode = $this->getMode($file->getPathname()))) {
             continue;
         }
         $info = ['name' => $file->getFilename(), 'mime' => 'application/' . ($file->isDir() ? 'folder' : 'file'), 'path' => $this->normalizePath($path . '/' . $file->getFilename()), 'url' => ltrim(App::url()->getStatic($file->getPathname(), [], 'base'), '/'), 'writable' => $mode == 'w'];
         if (!$file->isDir()) {
             $info = array_merge($info, ['size' => $this->formatFileSize($file->getSize()), 'lastmodified' => date(\DateTime::ISO8601, $file->getMTime())]);
         }
         $data['items'][] = $info;
     }
     return $data;
 }
コード例 #21
0
/**
 * Set of functions used with the relation and pdf feature
 */
function PMA_transformation_getOptions($string)
{
    $transform_options = array();
    /* Parse options */
    for ($nextToken = strtok($string, ','); $nextToken !== false; $nextToken = strtok(',')) {
        $trimmed = trim($nextToken);
        if ($trimmed[0] == '\'' && $trimmed[strlen($trimmed) - 1] == '\'') {
            $transform_options[] = substr($trimmed, 1, -1);
        } else {
            if ($trimmed[0] == '\'') {
                $trimmed = ltrim($nextToken);
                while ($nextToken !== false) {
                    $nextToken = strtok(',');
                    $trimmed .= $nextToken;
                    $rtrimmed = rtrim($trimmed);
                    if ($rtrimmed[strlen($rtrimmed) - 1] == '\'') {
                        break;
                    }
                }
                $transform_options[] = substr($rtrimmed, 1, -1);
            } else {
                $transform_options[] = $nextToken;
            }
        }
    }
    // strip possible slashes to behave like documentation says
    $result = array();
    foreach ($transform_options as $val) {
        $result[] = stripslashes($val);
    }
    return $result;
}
コード例 #22
0
 public function getClassMetadata($class)
 {
     $class = ltrim($class, '\\');
     if (!isset($this->loadedClasses[$class])) {
         if ($this->cache !== null && $this->cache->has($class)) {
             $this->loadedClasses[$class] = $this->cache->read($class);
         } else {
             $metadata = new ClassMetadata($class);
             // Include constraints from the parent class
             if ($parent = $metadata->getReflectionClass()->getParentClass()) {
                 $metadata->mergeConstraints($this->getClassMetadata($parent->getName()));
             }
             // Include constraints from all implemented interfaces
             foreach ($metadata->getReflectionClass()->getInterfaces() as $interface) {
                 $metadata->mergeConstraints($this->getClassMetadata($interface->getName()));
             }
             $this->loader->loadClassMetadata($metadata);
             $this->loadedClasses[$class] = $metadata;
             if ($this->cache !== null) {
                 $this->cache->write($metadata);
             }
         }
     }
     return $this->loadedClasses[$class];
 }
コード例 #23
0
ファイル: Dispatcher.php プロジェクト: krisanalfa/viloveul
 /**
  * dispatch.
  *
  * @param   string request
  */
 public function dispatch($request_uri, $url_suffix = null)
 {
     // Make sure the request is started using slash
     $request = '/' . ltrim($request_uri, '/');
     if (!empty($url_suffix) && '/' != $request) {
         $len = strlen($request);
         $last = substr($request, $len - 1, 1);
         if ('/' != $last) {
             $request = preg_replace('#' . $url_suffix . '$#i', '', $request);
         }
     }
     foreach ($this->routes as $pattern => $target) {
         if (preg_match('#^' . $pattern . '$#i', $request, $matches)) {
             if (is_string($target)) {
                 $request = preg_replace('#^' . $pattern . '$#i', $target, $request);
                 continue;
             } elseif (is_object($target) && method_exists($target, '__invoke')) {
                 $param_string = implode('/', array_slice($matches, 1));
                 $this->promote(function ($args = array()) use($target) {
                     return call_user_func_array($target, $args);
                 }, $this->segmentToArray($param_string));
                 return true;
             }
         }
     }
     return $this->validate($request);
 }
コード例 #24
0
ファイル: ApacheMod.php プロジェクト: jelix/fakeserverconf
 public function setHttpRequest($url, $method = 'get', $body = '', $bodyContentType = 'application/x-www-form-urlencoded')
 {
     parent::setHttpRequest($url, $method, $body, $bodyContentType);
     if (isset($_SERVER['PATH_INFO'])) {
         $_SERVER['PATH_TRANSLATED'] = $_SERVER["DOCUMENT_ROOT"] . ltrim($_SERVER['PATH_INFO'], '/');
     }
 }
 public function processRequest()
 {
     // No CSRF for SendGrid.
     $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
     $request = $this->getRequest();
     $user = $request->getUser();
     $raw_headers = $request->getStr('headers');
     $raw_headers = explode("\n", rtrim($raw_headers));
     $raw_dict = array();
     foreach (array_filter($raw_headers) as $header) {
         list($name, $value) = explode(':', $header, 2);
         $raw_dict[$name] = ltrim($value);
     }
     $headers = array('to' => $request->getStr('to'), 'from' => $request->getStr('from'), 'subject' => $request->getStr('subject')) + $raw_dict;
     $received = new PhabricatorMetaMTAReceivedMail();
     $received->setHeaders($headers);
     $received->setBodies(array('text' => $request->getStr('text'), 'html' => $request->getStr('from')));
     $file_phids = array();
     foreach ($_FILES as $file_raw) {
         try {
             $file = PhabricatorFile::newFromPHPUpload($file_raw, array('authorPHID' => $user->getPHID()));
             $file_phids[] = $file->getPHID();
         } catch (Exception $ex) {
             phlog($ex);
         }
     }
     $received->setAttachments($file_phids);
     $received->save();
     $received->processReceivedMail();
     $response = new AphrontWebpageResponse();
     $response->setContent("Got it! Thanks, SendGrid!\n");
     return $response;
 }
コード例 #26
0
 private function _genericReplacements()
 {
     $this->_doc_content = strip_tags($this->_doc_content);
     $this->_doc_content = ltrim(rtrim($this->_doc_content));
     $this->_doc_content = mb_strtolower($this->_doc_content, $this->_charset);
     // Remove dots between chars (for things like urls)
     $this->_doc_content = $this->_my_preg_replace("/([a-z]{1})[\\.]+([a-z]{1})/", "\$1\$2", $this->_doc_content);
     // ? Remove all html entities
     // $this->_doc_content = $this->_my_preg_replace("/&[#|a-z|0-9]+;/", " ", $this->_doc_content);
     // Decode all html entities
     $this->_doc_content = html_entity_decode($this->_doc_content, ENT_COMPAT, $this->_charset);
     // Replace multiple spaces chars with just one space
     $this->_doc_content = $this->_my_preg_replace("/[\\s|\t|\n|\r]+/", " ", $this->_doc_content);
     // Remove dots, dashes and spaces between digits
     $this->_doc_content = $this->_my_preg_replace("/([0-9]{1})[\\.|\\s|\\-]+([0-9]{1})/", "\$1\$2", $this->_doc_content);
     // Remove spaces after sentences and replace multiple dots with just one dot
     $this->_doc_content = $this->_my_preg_replace("/[\\.]+ /", ".", $this->_doc_content);
     // The same for sentences ending with question marks
     $this->_doc_content = $this->_my_preg_replace("/[\\?]+ /", ".", $this->_doc_content);
     // The same for "!"
     $this->_doc_content = $this->_my_preg_replace("/[\\!]+ /", ".", $this->_doc_content);
     // Remove all non-alphanumeric characters except for spaces and dots
     //        $this->_doc_content = $this->_my_preg_replace("/[^a-z|&#1072;-&#1103;|^\.|^\d|^\s|^@]+/i", "", $this->_doc_content);
     return $this;
 }
コード例 #27
0
ファイル: RobotLoader.php プロジェクト: nella/ActiveMapper
 /**
  * Handles autoloading of classes or interfaces.
  * @param  string
  * @return void
  */
 public function tryLoad($type)
 {
     $type = ltrim(strtolower($type), '\\');
     // PHP namespace bug #49143
     if (isset($this->list[$type])) {
         if ($this->list[$type] !== FALSE) {
             LimitedScope::load($this->list[$type][0]);
             self::$count++;
         }
     } else {
         $this->list[$type] = FALSE;
         if ($this->autoRebuild === NULL) {
             $this->autoRebuild = !$this->isProduction();
         }
         if ($this->autoRebuild) {
             if ($this->rebuilded) {
                 $this->getCache()->save($this->getKey(), $this->list);
             } else {
                 $this->rebuild();
             }
         }
         if ($this->list[$type] !== FALSE) {
             LimitedScope::load($this->list[$type][0]);
             self::$count++;
         }
     }
 }
コード例 #28
0
ファイル: cron.php プロジェクト: Ignite-IT/enolaphp
 /**
  * Analiza los parametros y devuelvo los parametros ordenados para su posterior uso
  * El primer parametros es el index.php, el segundo es el nombre (clase) del cron y despues puede ser el metodo a ejecutar
  * y luego son todos parametros de entrada al Cron correspondiente. 
  * @param type $params
  * @return array[array]
  */
 private function analyzeParameters($params)
 {
     //Va a contener todos los parametros sin los guiones "-" iniciales
     $realParams = array();
     //Va a contener los parametros reales. Los no usados por el framework
     $cleanParams = array();
     $indActual = 0;
     foreach ($params as $value) {
         //Le quito los guiones iniciales a todos
         $value = ltrim($value, '-');
         //Analizo si debo guardar en cleanParams
         if ($indActual == 2 && substr($value, 0, 1) == '?') {
             //Le quito el "?"
             $value = substr($value, 1);
         } else {
             if ($indActual >= 2) {
                 //Guardo los parametros que no usa el framework
                 $cleanParams[] = $value;
             }
         }
         //Guardo a todos en realParams
         $realParams[] = $value;
         //Aumento el indice
         $indActual++;
     }
     return array("real" => $realParams, "clean" => $cleanParams);
 }
コード例 #29
0
 protected function _parse_params($p)
 {
     $params = array();
     preg_match_all('~\\w+\\s*=|(([\'"]).*?(?<!\\\\)\\2|\\S+)~s', $p, $m, PREG_SET_ORDER);
     $lastkey = '';
     foreach ($m as $v) {
         if (trim($v[0]) === '') {
             continue;
         }
         if (sizeof($v) == 1) {
             $lastkey = ltrim(rtrim($v[0], " =\t"));
             continue;
         }
         if ($lastkey === '') {
             $params[] = $v[0];
         } else {
             $params[$lastkey] = $v[0];
         }
         $lastkey = '';
     }
     if ($this->use_stat) {
         $this->stat['numparams'] += sizeof($params);
     }
     return $params;
 }
コード例 #30
0
 function extractObject($v)
 {
     if (function_exists('json_decode')) {
         return array(json_decode($v, 1), '');
     }
     $r = array();
     /* sub-object */
     if ($sub_r = $this->x('\\{', $v)) {
         $v = $sub_r[1];
         while ((list($sub_r, $v) = $this->extractEntry($v)) && $sub_r) {
             $r[$sub_r['key']] = $sub_r['value'];
         }
         if ($sub_r = $this->x('\\}', $v)) {
             $v = $sub_r[1];
         }
     } elseif ($sub_r = $this->x('\\[', $v)) {
         $v = $sub_r[1];
         while ((list($sub_r, $v) = $this->extractObject($v)) && $sub_r) {
             $r[] = $sub_r;
             $v = ltrim($v, ',');
         }
         if ($sub_r = $this->x('\\]', $v)) {
             $v = $sub_r[1];
         }
     } elseif ((list($sub_r, $v) = $this->extractValue($v)) && $sub_r !== false) {
         $r = $sub_r;
     }
     return array($r, $v);
 }