/** * Save an uploaded file to a new location. * * @param mixed name of $_FILE input or array of upload data * @param string new filename * @param string new directory * @param integer chmod mask * @return string full path to new file */ public static function save($file, $filename = NULL, $directory = NULL, $chmod = 0755) { // Load file data from FILES if not passed as array $file = is_array($file) ? $file : $_FILES[$file]; if ($filename === NULL) { // Use the default filename, with a timestamp pre-pended $filename = time() . $file['name']; } // Remove spaces from the filename $filename = preg_replace('/\\s+/', '_', $filename); if ($directory === NULL) { // Use the pre-configured upload directory $directory = WWW_ROOT . 'files/'; } // Make sure the directory ends with a slash $directory = rtrim($directory, '/') . '/'; if (!is_dir($directory)) { // Create the upload directory mkdir($directory, 0777, TRUE); } //if ( ! is_writable($directory)) //throw new exception; if (is_uploaded_file($file['tmp_name']) and move_uploaded_file($file['tmp_name'], $filename = $directory . $filename)) { if ($chmod !== FALSE) { // Set permissions on filename chmod($filename, $chmod); } //$all_file_name = array(FILE_INFO => $filename); // Return new file path return $filename; } return FALSE; }
function dump($var, $echo = true, $label = null, $strict = true) { $label = $label === null ? '' : rtrim($label) . ' '; if (!$strict) { if (ini_get('html_errors')) { $output = print_r($var, true); $output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>"; } else { $output = $label . " : " . print_r($var, true); } } else { ob_start(); var_dump($var); $output = ob_get_clean(); if (!extension_loaded('xdebug')) { $output = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $output); $output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES, "GB2312") . '</pre>'; } } if ($echo) { echo $output; return null; } else { return $output; } }
function convert_uudecode($string) { // Sanity check if (!is_scalar($string)) { user_error('convert_uuencode() expects parameter 1 to be string, ' . gettype($string) . ' given', E_USER_WARNING); return false; } if (strlen($string) < 8) { user_error('convert_uuencode() The given parameter is not a valid uuencoded string', E_USER_WARNING); return false; } $decoded = ''; foreach (explode("\n", $string) as $line) { $c = count($bytes = unpack('c*', substr(trim($line), 1))); while ($c % 4) { $bytes[++$c] = 0; } foreach (array_chunk($bytes, 4) as $b) { $b0 = $b[0] == 0x60 ? 0 : $b[0] - 0x20; $b1 = $b[1] == 0x60 ? 0 : $b[1] - 0x20; $b2 = $b[2] == 0x60 ? 0 : $b[2] - 0x20; $b3 = $b[3] == 0x60 ? 0 : $b[3] - 0x20; $b0 <<= 2; $b0 |= $b1 >> 4 & 0x3; $b1 <<= 4; $b1 |= $b2 >> 2 & 0xf; $b2 <<= 6; $b2 |= $b3 & 0x3f; $decoded .= pack('c*', $b0, $b1, $b2); } } return rtrim($decoded, ""); }
public function PostAction() { $evidencija_model = Mage::getModel('evidencija/evidencija'); $devices_model = Mage::getModel('evidencija/devices'); $post_name = $this->getRequest()->getPost('name'); $post_sn = $this->getRequest()->getPost('sn'); $post_supplier = $this->getRequest()->getPost('supplier'); $post_comment = $this->getRequest()->getPost('comment'); $post_warranty = $this->getRequest()->getPost('warranty'); $helper = Mage::helper('evidencija'); if (empty($post_sn[0])) { $this->redirectError('Morate uneti serijski broj !!!'); } else { // prepare data for customer table $evidencija_data = array('name' => $post_name, 'supplier' => $post_supplier, 'comment' => $post_comment, 'warranty' => $post_warranty); $evidencija_model->setData($evidencija_data)->save(); $evidencija_id = $evidencija_model->getEntityId(); foreach ($post_sn as $key => $post) { if (empty($post)) { continue; } // prepare data for device table $post = rtrim($post, "\r"); $post = rtrim($post, "\n"); $device_data = array('device_id' => $evidencija_id, 'serial' => $post); $devices_model->setData($device_data)->save(); } if ($devices_model->getEntityId()) { Mage::getSingleton('core/session')->addSuccess($this->__('Nov uredjaj je uspešno dodat u bazu')); } else { Mage::getSingleton('core/session')->addError($this->__('Došlo je do greške, obavesti Dodu !')); } $this->_redirectReferer(); } }
public function setUp() { $_SERVER['REDIRECT_STATUS'] = "200"; $_SERVER['HTTP_HOST'] = "slim"; $_SERVER['HTTP_CONNECTION'] = "keep-alive"; $_SERVER['HTTP_CACHE_CONTROL'] = "max-age=0"; $_SERVER['HTTP_ACCEPT'] = "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"; $_SERVER['HTTP_USER_AGENT'] = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3"; $_SERVER['HTTP_ACCEPT_ENCODING'] = "gzip,deflate,sdch"; $_SERVER['HTTP_ACCEPT_LANGUAGE'] = "en-US,en;q=0.8"; $_SERVER['HTTP_ACCEPT_CHARSET'] = "ISO-8859-1,utf-8;q=0.7,*;q=0.3"; $_SERVER['PATH'] = "/usr/bin:/bin:/usr/sbin:/sbin"; $_SERVER['SERVER_SIGNATURE'] = ""; $_SERVER['SERVER_SOFTWARE'] = "Apache"; $_SERVER['SERVER_NAME'] = "slim"; $_SERVER['SERVER_ADDR'] = "127.0.0.1"; $_SERVER['SERVER_PORT'] = "80"; $_SERVER['REMOTE_ADDR'] = "127.0.0.1"; $_SERVER['DOCUMENT_ROOT'] = rtrim(dirname(__FILE__), '/'); $_SERVER['SERVER_ADMIN'] = "*****@*****.**"; $_SERVER['SCRIPT_FILENAME'] = __FILE__; $_SERVER['REMOTE_PORT'] = "55426"; $_SERVER['REDIRECT_URL'] = "/"; $_SERVER['GATEWAY_INTERFACE'] = "CGI/1.1"; $_SERVER['SERVER_PROTOCOL'] = "HTTP/1.1"; $_SERVER['REQUEST_METHOD'] = "GET"; $_SERVER['QUERY_STRING'] = ""; $_SERVER['REQUEST_URI'] = "/"; $_SERVER['SCRIPT_NAME'] = basename(__FILE__); $_SERVER['PHP_SELF'] = '/' . basename(__FILE__); $_SERVER['REQUEST_TIME'] = "1285647051"; $_SERVER['argv'] = array(); $_SERVER['argc'] = 0; }
public static function run() { foreach (glob(app_path() . '/Http/Controllers/*.php') as $filename) { $file_parts = explode('/', $filename); $file = array_pop($file_parts); $file = rtrim($file, '.php'); if ($file == 'Controller') { continue; } $controllerName = 'App\\Http\\Controllers\\' . $file; $controller = new $controllerName(); if (isset($controller->exclude) && $controller->exclude === true) { continue; } $methods = []; $reflector = new \ReflectionClass($controller); foreach ($reflector->getMethods(\ReflectionMethod::IS_PUBLIC) as $rMethod) { // check whether method is explicitly defined in this class if ($rMethod->getDeclaringClass()->getName() == $reflector->getName()) { $methods[] = $rMethod->getName(); } } \Route::resource(strtolower(str_replace('Controller', '', $file)), $file, ['only' => $methods]); } }
/** * Constructor * * @param string $name * @param string $rname * @param integer $ttl * @param string $class */ function __construct($name, $value, $ttl = false, $class = "IN") { parent::__construct(); $this->Type = "TXT"; // Name if (($this->Validator->MatchesPattern($name, self::PAT_NON_FDQN) || $name == "@" || $name === "" || $this->Validator->IsDomain($name)) && !$this->Validator->IsIPAddress(rtrim($name, ".")) ) $this->Name = $name; else { self::RaiseWarning("'{$name}' is not a valid name for TXT record"); $this->Error = true; } if (strlen($value) > 255) { self::RaiseWarning("TXT record value cannot be longer than 65536 bytes"); $this->Error = true; } else $this->Value = $value; $this->TTL = $ttl; $this->Class = $class; }
/** * [index 管理员列表] * @return [type] [description] */ public function index() { if (IS_AJAX) { $draw = I('draw', 1, 'intval'); //排序设置 $mycolumns = I('mycolumns', ''); $myorder = I('order', ''); if (empty($myorder) || empty($mycolumns)) { $order = 'id desc'; } else { foreach ($myorder as $key => $v) { $order .= $mycolumns[$v['column']] . ' ' . $v['dir'] . ' ,'; } $order = rtrim($order, ','); } $db = D('UsersView'); $lists = $db->where(true)->order($order)->select(); foreach ($lists as $key => $v) { $lists[$key]['loginTime'] = $v['loginTime'] ? date('Y/m/d H:i:s', $v['loginTime']) : ''; $lists[$key]['loginIp'] = $v['loginIp'] ? long2ip($v['loginIp']) : ''; if ($v['status']) { $lists[$key]['status'] = '正常'; } else { $lists[$key]['status'] = '禁用'; } } $result['draw'] = $draw; $result['recordsTotal'] = $db->where(true)->count(); $result['recordsFiltered'] = $result['recordsTotal']; $result['data'] = $lists; $this->ajaxReturn($result); } else { $this->display(); } }
/** * Generate Class * * @param string $className * @return string * @throws \Magento\Framework\Exception * @throws \InvalidArgumentException */ public function generateClass($className) { // check if source class a generated entity $entity = null; $entityName = null; foreach ($this->_generatedEntities as $entityType => $generatorClass) { $entitySuffix = ucfirst($entityType); // if $className string ends on $entitySuffix substring if (strrpos($className, $entitySuffix) === strlen($className) - strlen($entitySuffix)) { $entity = $entityType; $entityName = rtrim(substr($className, 0, -1 * strlen($entitySuffix)), \Magento\Framework\Autoload\IncludePath::NS_SEPARATOR); break; } } if (!$entity || !$entityName) { return self::GENERATION_ERROR; } // check if file already exists $autoloader = $this->_autoloader; if ($autoloader::getFile($className)) { return self::GENERATION_SKIP; } if (!isset($this->_generatedEntities[$entity])) { throw new \InvalidArgumentException('Unknown generation entity.'); } $generatorClass = $this->_generatedEntities[$entity]; $generator = new $generatorClass($entityName, $className, $this->_ioObject); if (!$generator->generate()) { $errors = $generator->getErrors(); throw new \Magento\Framework\Exception(implode(' ', $errors)); } return self::GENERATION_SUCCESS; }
/** * getFullClassName() * * @param string $localClassName * @param string $classContextName */ public function getFullClassName($localClassName, $classContextName = null) { // find the ApplicationDirectory OR ModuleDirectory $currentResource = $this->_resource; do { $resourceName = $currentResource->getName(); if ($resourceName == 'ApplicationDirectory' || $resourceName == 'ModuleDirectory') { $containingResource = $currentResource; break; } } while ($currentResource instanceof Zend_Tool_Project_Profile_Resource && ($currentResource = $currentResource->getParentResource())); $fullClassName = ''; // go find the proper prefix if (isset($containingResource)) { if ($containingResource->getName() == 'ApplicationDirectory') { $prefix = $containingResource->getAttribute('classNamePrefix'); $fullClassName = $prefix; } elseif ($containingResource->getName() == 'ModuleDirectory') { $filter = new Zend_Filter_Word_DashToCamelCase(); $prefix = $filter->filter(ucfirst($containingResource->getAttribute('moduleName'))) . '_'; $fullClassName = $prefix; } } if ($classContextName) { $fullClassName .= rtrim($classContextName, '_') . '_'; } $fullClassName .= $localClassName; return $fullClassName; }
/** * 地图 */ public function init() { $siteconfigs = $this->siteconfigs; $seo_title = $siteconfigs['sitename']; $seo_keywords = $siteconfigs['seo_keywords']; $seo_description = $siteconfigs['seo_description']; $categorys = get_cache('category', 'content'); $hotcity = hotcity(0); $category_result = $this->db->get_list('category', array('modelid' => 3), '*', 0, 1000); $city = substr(rtrim($_SERVER["REQUEST_URI"], '/'), 5); if ($city == '') { $city = 'beijing'; } foreach ($categorys as $cid => $rs) { if ($rs['catdir'] == $city) { $cityid = $cid; set_cookie('cityname', $rs['name'], SYS_TIME + 86400 * 7); set_cookie('cityid', $cityid, SYS_TIME + 86400 * 7); $cityname = $rs['name']; break; } } $page = max(intval($GLOBALS['page']), 1); $urlrule = 'javascript:change_pagemap({$page});'; include T('content', 'map', TPLID); }
/** * Save settings. */ function execute() { $plugin =& $this->plugin; $journalId = $this->journalId; $plugin->updateSetting($journalId, 'phpmvUrl', rtrim($this->getData('phpmvUrl'), "/"), 'string'); $plugin->updateSetting($journalId, 'phpmvSiteId', $this->getData('phpmvSiteId'), 'int'); }
/** * Initializes the Jsb2 object. * * @param string $filename Path to manifest file * @param string $baseURL Base URL for HTML output * @param array $filter Which packages schould NOT be returned */ public function __construct($filename, $baseURL = "", $filter = array()) { $manifest = $this->getManifest($filename); $this->baseURL = rtrim($baseURL, '/') . '/'; $this->basePath = dirname($filename) . '/'; $this->registeredPackages = $this->getPackages($manifest, $filter); }
/** * 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; }
public function populate($where, $preserve = false) { $attach = ' WHERE '; $params = array(); foreach ($where as $key => $value) { $attach .= $key . ' = ? AND '; $params[] = $value; } $attach = rtrim($attach, 'AND '); $this->individualWhereClausule = $attach; $this->iwc_values = $params; if ($preserve) { $oldQ = $this->lastQuery; } $this->lastQuery = array('query' => 'SELECT * FROM ' . self::tablename() . $attach . ' LIMIT 1', 'values' => $params); $query = $this->makeQuery(!$preserve); if ($preserve) { $this->lastQuery = $oldQ; } $values = $query->fetch(PDO::FETCH_ASSOC); if (is_array($values)) { foreach ($values as $key => $value) { $this->{$key} = $value; } } else { $this->void = true; } }
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; }
/** * 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]; }
/** * load hphp lib */ function initialize_hphp() { if (!defined('app_libs')) { exit('Not found constant "app_libs".'); } require_once rtrim(app_libs, '/') . '/init/require.php'; }
public static function construct() { global $cookie_lifetime; $path = str_replace("index.php", "", $_SERVER['SCRIPT_FILENAME']); foreach (array("components", "plugins") as $folder) { if (strpos($_SERVER['SCRIPT_FILENAME'], $folder)) { $path = substr($_SERVER['SCRIPT_FILENAME'], 0, strpos($_SERVER['SCRIPT_FILENAME'], $folder)); break; } } if (file_exists($path . 'config.php')) { require_once $path . 'config.php'; } if (!defined('BASE_PATH')) { define('BASE_PATH', rtrim(str_replace("index.php", "", $_SERVER['SCRIPT_FILENAME']), "/")); } if (!defined('COMPONENTS')) { define('COMPONENTS', BASE_PATH . '/components'); } if (!defined('PLUGINS')) { define('PLUGINS', BASE_PATH . '/plugins'); } if (!defined('DATA')) { define('DATA', BASE_PATH . '/data'); } if (!defined('THEMES')) { define("THEMES", BASE_PATH . "/themes"); } if (!defined('THEME')) { define("THEME", "default"); } }
/** */ public function __construct($time = null) { $tz = new DateTimeZone('UTC'); try { parent::__construct($time, $tz); return; } catch (Exception $e) { } /* Bug #5717 - Check for UT vs. UTC. */ if (substr(rtrim($time), -3) === ' UT') { try { parent::__construct($time . 'C', $tz); return; } catch (Exception $e) { } } /* Bug #9847 - Catch paranthesized timezone information at end of date * string. */ $date = preg_replace("/\\s*\\([^\\)]+\\)\\s*\$/", '', $time, -1, $i); if ($i) { try { parent::__construct($date, $tz); return; } catch (Exception $e) { } } parent::__construct('@-1', $tz); }
public function perform($unconsumed_path) { //$this->setupAutoload(); $dispatcher = new Trails_Dispatcher($this->getPluginPath(), rtrim(PluginEngine::getLink($this, array(), null), '/'), 'show'); $dispatcher->plugin = $this; $dispatcher->dispatch($unconsumed_path); }
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; }
private function http2_request($method, $path, $params) { $url = $this->api . rtrim($path, '/') . '/'; if (!strcmp($method, "POST")) { $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST); $req->setHeader('Content-type: application/json'); if ($params) { $req->setBody(json_encode($params)); } } else { if (!strcmp($method, "GET")) { $req = new HTTP_Request2($url, HTTP_Request2::METHOD_GET); $url = $req->getUrl(); $url->setQueryVariables($params); } else { if (!strcmp($method, "DELETE")) { $req = new HTTP_Request2($url, HTTP_Request2::METHOD_DELETE); $url = $req->getUrl(); $url->setQueryVariables($params); } } } $req->setAdapter('curl'); $req->setConfig(array('timeout' => 30, 'ssl_verify_peer' => FALSE)); $req->setAuth($this->auth_id, $this->auth_token, HTTP_Request2::AUTH_BASIC); $req->setHeader(array('Connection' => 'close', 'User-Agent' => 'PHPPlivo')); $r = $req->send(); $status = $r->getStatus(); $body = $r->getbody(); $response = json_decode($body, true); return array("status" => $status, "response" => $response); }
/** * Constructor. * * @param callable|object $classLoader Passing an object is @deprecated since version 2.5 and support for it will be removed in 3.0 */ public function __construct($classLoader) { $this->wasFinder = is_object($classLoader) && method_exists($classLoader, 'findFile'); if ($this->wasFinder) { @trigger_error('The ' . __METHOD__ . ' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED); $this->classLoader = array($classLoader, 'loadClass'); $this->isFinder = true; } else { $this->classLoader = $classLoader; $this->isFinder = is_array($classLoader) && method_exists($classLoader[0], 'findFile'); } if (!isset(self::$caseCheck)) { $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), DIRECTORY_SEPARATOR); $i = strrpos($file, DIRECTORY_SEPARATOR); $dir = substr($file, 0, 1 + $i); $file = substr($file, 1 + $i); $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file); $test = realpath($dir . $test); if (false === $test || false === $i) { // filesystem is case sensitive self::$caseCheck = 0; } elseif (substr($test, -strlen($file)) === $file) { // filesystem is case insensitive and realpath() normalizes the case of characters self::$caseCheck = 1; } elseif (false !== stripos(PHP_OS, 'darwin')) { // on MacOSX, HFS+ is case insensitive but realpath() doesn't normalize the case of characters self::$caseCheck = 2; } else { // filesystem case checks failed, fallback to disabling them self::$caseCheck = 0; } } }
function parse($text) { # removes UTF-8 BOM and marker characters $text = preg_replace('{^\\xEF\\xBB\\xBF|\\x1A}', '', $text); # removes \r characters $text = str_replace("\r\n", "\n", $text); $text = str_replace("\r", "\n", $text); # replaces tabs with spaces $text = str_replace("\t", ' ', $text); # encodes escape sequences if (strpos($text, '\\') !== FALSE) { $escape_sequences = array('\\\\', '\\`', '\\*', '\\_', '\\{', '\\}', '\\[', '\\]', '\\(', '\\)', '\\>', '\\#', '\\+', '\\-', '\\.', '\\!'); foreach ($escape_sequences as $index => $escape_sequence) { if (strpos($text, $escape_sequence) !== FALSE) { $code = "" . '\\' . $index . ';'; $text = str_replace($escape_sequence, $code, $text); $this->escape_sequence_map[$code] = $escape_sequence; } } } # ~ $text = preg_replace('/\\n\\s*\\n/', "\n\n", $text); $text = trim($text, "\n"); $lines = explode("\n", $text); $text = $this->parse_block_elements($lines); # decodes escape sequences foreach ($this->escape_sequence_map as $code => $escape_sequence) { $text = str_replace($code, $escape_sequence[1], $text); } $text = rtrim($text, "\n"); return $text; }
/** * RETURN PAY HTML FORM * */ function onTP_GetHTML($vars) { $vars = $this->preFormatingData($vars); $plgPaymentEpaydkHelper = new plgPaymentEpaydkHelper(); // Split the name in first and last name $user = JFactory::getUser(); $nameParts = $user->name; // explode(' ', $user->name, 2); $firstName = $user->name; $lastName = $user->name; // Get the base URL without the path $rootURL = rtrim(JURI::base(), '/'); $subpathURL = JURI::base(true); if (!empty($subpathURL) && $subpathURL != '/') { $rootURL = substr($rootURL, 0, -1 * strlen($subpathURL)); } // Separate URL variable as it cannot be a part of the md5 checksum $url = $this->getPaymentURL(); $data = array('merchant' => $this->getMerchantID(), 'success' => $vars->return, 'cancel' => $vars->cancel_return, 'postback' => $vars->notify_url, 'orderid' => $vars->order_id, 'currency' => strtoupper($vars->currency_code), 'amount' => $vars->amount * 100, 'cardtypes' => implode(',', $this->params->get('cardtypes', array())), 'instantcapture' => '1', 'instantcallback' => '1', 'language' => $this->params->get('language', '0'), 'ordertext' => 'Order id' . ' - [ ' . $vars->order_id . ' ]', 'windowstate' => '3', 'ownreceipt' => '0', 'md5' => $this->params->get('secret', '')); if ($this->params->get('md5', 1)) { // Security hash - must be compiled from ALL inputs sent $data['md5'] = md5(implode('', $data)); } else { $data['md5'] = ''; } $data['actionURL'] = $url; // dont make md5 $data['submiturl'] = $vars->submiturl; // Set array as object for compatability $data = (object) $data; $html = $this->buildLayout($data); return $html; }
function db_table_create_sql($schema) { $pieces = explode('_', $schema['charset']); $charset = $pieces[0]; $engine = $schema['engine']; $schema['tablename'] = str_replace('ims_', $GLOBALS['_W']['config']['db']['tablepre'], $schema['tablename']); $sql = "CREATE TABLE IF NOT EXISTS `{$schema['tablename']}` (\n"; foreach ($schema['fields'] as $value) { $piece = _db_build_field_sql($value); $sql .= "`{$value['name']}` {$piece},\n"; } foreach ($schema['indexes'] as $value) { $fields = implode('`,`', $value['fields']); if ($value['type'] == 'index') { $sql .= "KEY `{$value['name']}` (`{$fields}`),\n"; } if ($value['type'] == 'unique') { $sql .= "UNIQUE KEY `{$value['name']}` (`{$fields}`),\n"; } if ($value['type'] == 'primary') { $sql .= "PRIMARY KEY (`{$fields}`),\n"; } } $sql = rtrim($sql); $sql = rtrim($sql, ','); $sql .= "\n) ENGINE={$engine} DEFAULT CHARSET={$charset};\n\n"; return $sql; }
/** * Get the path to the migration directory. * * @return string */ private function getPath() { if (!($path = $this->input->getOption('path'))) { $path = $this->nova['path'] . DS . 'Controllers'; } return rtrim($path, '/'); }
public function store($object) { if (!is_object($object)) { throw new Exception('Invalid Entity. Should be object'); } $table = $this->getTableName($object); $values = array(); $reflector = new ReflectionClass($object); foreach ($reflector->getProperties() as $prop) { $comment = $prop->getDocComment(); if (strpos($comment, '@primary') || strpos($comment, '@field')) { $values[$prop->getName()] = $prop->getValue($object); } } $keys = array_keys($values); if (is_null($object->id)) { $str = '`' . implode('`, `', $keys) . '`'; $str2 = ':' . implode(', :', $keys); $sql = "INSERT INTO {$table} ({$str}) VALUES ({$str2})"; $this->execute($sql, $values); $object->id = $this->lastInsertId(); } else { $str = ''; foreach ($keys as $k) { if ($k == 'id') { continue; } $str .= " {$k}=:{$k},"; } $str = rtrim($str, ','); $sql = "UPDATE {$table} SET {$str} WHERE id = :id"; $this->execute($sql, $values); } return $object; }
protected function __construct($config) { if (count($config["db"]) != 4) { throw new \Exception("Le nombre d'arguments n'est pas valable!"); } spl_autoload_register(array(__CLASS__, 'autoload')); self::$config = $config; self::$database = new Core\Db\ConnectPDO(self::$config["db"]); self::$baseUrl = rtrim(dirname($_SERVER['PHP_SELF']), '/.\\'); $route = isset($_GET["r"]) ? $_GET["r"] : $_SERVER["REQUEST_URI"]; $url = parse_url($route); $path = preg_replace('/^' . preg_quote(self::$baseUrl, '/') . '\\//', "", $url["path"]); $query = @$url["query"]; $method = $_SERVER['REQUEST_METHOD']; $request = new Core\Http\Request($method, $path, $query); $dispatcher = new Core\Http\Dispatcher(); try { $dispatcher->handle($request); } catch (Exception $e) { $code = '404'; header($_SERVER["SERVER_PROTOCOL"] . " " . $code); $request = new Core\Http\Request('GET', 'Site/error', 'code=' . $code . '&message=' . $e->getMessage()); $dispatcher->handle($request); } }