/** * Expand an IPv6 Address * * This will take an IPv6 address written in short form and expand it to include all zeros. * * @param string $addr A valid IPv6 address * @return string The expanded notation IPv6 address */ function inet6_expand($addr) { /* Check if there are segments missing, insert if necessary */ if (strpos($addr, '::') !== false) { $part = explode('::', $addr); $part[0] = explode(':', $part[0]); $part[1] = explode(':', $part[1]); $missing = array(); for ($i = 0; $i < 8 - (count($part[0]) + count($part[1])); $i++) { array_push($missing, '0000'); } $missing = array_merge($part[0], $missing); $part = array_merge($missing, $part[1]); } else { $part = explode(":", $addr); } // if .. else /* Pad each segment until it has 4 digits */ foreach ($part as &$p) { while (strlen($p) < 4) { $p = '0' . $p; } } // foreach unset($p); /* Join segments */ $result = implode(':', $part); /* Quick check to make sure the length is as expected */ if (strlen($result) == 39) { return $result; } else { return false; } // if .. else }
/** * @param mixed $in */ public function __construct($in = null) { $fields = array('to', 'cc', 'bcc', 'message', 'body', 'subject'); if (is_string($in)) { if (($pos = strpos($in, '?')) !== false) { parse_str(substr($in, $pos + 1), $this->args); $this->args['to'] = substr($in, 0, $pos); } else { $this->args['to'] = $in; } } elseif ($in instanceof Horde_Variables) { foreach ($fields as $val) { if (isset($in->{$val})) { $this->args[$val] = $in->{$val}; } } } elseif (is_array($in)) { $this->args = $in; } if (isset($this->args['to']) && strpos($this->args['to'], 'mailto:') === 0) { $mailto = @parse_url($this->args['to']); if (is_array($mailto)) { $this->args['to'] = isset($mailto['path']) ? $mailto['path'] : ''; if (!empty($mailto['query'])) { parse_str($mailto['query'], $vals); foreach ($fields as $val) { if (isset($vals[$val])) { $this->args[$val] = $vals[$val]; } } } } } }
public function set($var, $value = null) { // parse variable name extract($this->_parse($var)); if (!empty($name)) { // set default hash to method if ($hash == 'default') { $hash = 'method'; } // set a array value ? if (strpos($name, '.') !== false) { $parts = explode('.', $name); $name = array_shift($parts); $array =& $this->_call(array($this->_class, 'getVar'), array($name, array(), $hash, 'array')); $val =& $array; foreach ($parts as $i => $part) { if (!isset($array[$part])) { $array[$part] = array(); } if (isset($parts[$i + 1])) { $array =& $array[$part]; } else { $array[$part] = $value; } } $value = $val; } $this->_call(array($this->_class, 'setVar'), array($name, $value, $hash)); } return $this; }
public function __call($s_method_name, $arr_arguments) { if (!method_exists($this, $s_method_name)) { // если еще не имлементировали $s_match = ""; $s_method_prefix = ''; $s_method_base = ''; $arr_matches = array(); $bSucc = preg_match("/[A-Z_]/", $s_method_name, $arr_matches); if ($bSucc) { $s_match = $arr_matches[0]; $i_match = strpos($s_method_name, $s_match); $s_method_prefix = substr($s_method_name, 0, $i_match) . "/"; $s_method_base = substr($s_method_name, 0, $i_match + ($s_match === "_" ? 1 : 0)); } $s_class_enter = "__" . $s_method_name; // метод, общий для всех режимов if (!class_exists($s_class_enter)) { $s_entermethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . ".lib.php"; $this->__loadLib($s_entermethod_lib); $this->__implement($s_class_enter); } $s_class_mode = "__" . $s_method_name . "_"; // метод, выбираемый в зависимости от режима if (!class_exists($s_class_mode)) { $s_modemethod_lib = "methods/" . $s_method_prefix . "__" . $s_method_name . "_" . cmsController::getInstance()->getCurrentMode() . ".lib.php"; $this->__loadLib($s_modemethod_lib); $this->__implement($s_class_mode); } } return parent::__call($s_method_name, $arr_arguments); }
/** * Performs payment module specific configuration validation * * @param string &$errorMessage - error message when return result is not true * * @return bool - true if configuration is valid, false otherwise * * */ function moduleValidateConfiguration(&$errorMessage) { global $providerConf; $commomResult = commonValidateConfiguration($errorMessage); if (!$commomResult) { return false; } if (strlen(trim($providerConf['Param_sid'])) == 0) { $errorMessage = '\'Account number\' field is empty'; return false; } if (!in_array($providerConf['Param_pay_method'], array('CC', 'CK'))) { $errorMessage = '\'Pay method\' field has incorrect value'; return false; } if (strlen(trim($providerConf['Param_secret_word'])) == 0) { $errorMessage = '\'Secret word\' field is empty'; return false; } if (strlen(trim($providerConf['Param_secret_word'])) > 16 || strpos($providerConf['Param_secret_word'], ' ') !== false) { $errorMessage = '\'Secret word\' field has incorrect value'; return false; } return true; }
/** * @param $name * @param array $params * @return string */ public function registerScript($name, $params) { $out = ''; if (!isset($this->modx->loadedjscripts[$name])) { $src = $params['src']; $remote = strpos($src, "http") !== false; if (!$remote) { $src = $this->modx->config['site_url'] . $src; if (!$this->fs->checkFile($params['src'])) { $this->modx->logEvent(0, 3, 'Cannot load ' . $src, 'Assets helper'); return false; } } $type = isset($params['type']) ? $params['type'] : end(explode('.', $src)); if ($type == 'js') { $out = '<script type="text/javascript" src="' . $src . '"></script>'; } else { $out = '<link rel="stylesheet" type="text/css" href="' . $src . '">'; } $this->modx->loadedjscripts[$name] = $params; } else { $out = false; } return $out; }
function quoteFromDir($dir) { $amount = 0; $index = 0; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (strpos($file, ".dat") != false) { $len = strlen($file); if (substr($file, $len - 4) == ".dat") { $number = $this->getNumberOfQuotes($dir . "/" . $file); $amount += $number; $quotes[$index] = $amount; $files[$index] = $file; $index++; } } } srand((double) microtime() * 1000000); $index = rand(0, $amount); $i = 0; while ($quotes[$i] < $index) { $i++; } return $this->getRandomQuote($dir . "/" . $files[$i]); } return -1; }
public function executeConsole(AgaviRequestDataHolder $request_data) { $migration_description = $request_data->getParameter('description'); $migration_timestamp = date('YmdHis'); $migration_slug = StringToolkit::asSnakeCase(trim($request_data->getParameter('name', 'default'))); $migration_name = StringToolkit::asStudlyCaps($migration_slug); $migration_dir = $this->getAttribute('migration_dir'); // Bit of a hack to build namespace if (!preg_match('#.+/app/(?:modules|migration)/(\\w+_?)(?:$|/.+)#', $migration_dir, $matches)) { throw new RuntimeError(sprintf('Could not find namespace info in path %s', $migration_dir)); } $namespace_parts = explode('_', $matches[1]); if (count($namespace_parts) == 1) { // @todo app migration - introduce a project root namespace setting $namespace_parts = ['Your', 'Application']; } // And a hack to determine the technology namespace $target = $request_data->getParameter('target'); if (strpos($target, 'event_source')) { $technology = 'CouchDb'; } elseif (strpos($target, 'view_store')) { $technology = 'Elasticsearch'; } else { $technology = 'RabbitMq'; } $migration_filepath = sprintf('%1$s%2$s%3$s_%4$s%2$s%4$s.php', $migration_dir, DIRECTORY_SEPARATOR, $migration_timestamp, $migration_slug); $twig_renderer = TwigRenderer::create(['template_paths' => [__DIR__]]); $twig_renderer->renderToFile($technology . 'Migration.tpl.twig', $migration_filepath, ['name' => $migration_name, 'timestamp' => $migration_timestamp, 'description' => $migration_description, 'folder' => $migration_dir, 'filepath' => $migration_filepath, 'vendor_prefix' => $namespace_parts[0], 'package_prefix' => $namespace_parts[1], 'technology' => $technology, 'project_prefix' => AgaviConfig::get('core.project_prefix')]); return $this->cliMessage('-> migration template was created here:' . PHP_EOL . $migration_filepath . PHP_EOL); }
function getstr($string, $length, $in_slashes = 0, $out_slashes = 0, $bbcode = 0, $html = 0) { global $_G; $string = trim($string); $sppos = strpos($string, chr(0) . chr(0) . chr(0)); if ($sppos !== false) { $string = substr($string, 0, $sppos); } if ($in_slashes) { $string = dstripslashes($string); } $string = preg_replace("/\\[hide=?\\d*\\](.*?)\\[\\/hide\\]/is", '', $string); if ($html < 0) { $string = preg_replace("/(\\<[^\\<]*\\>|\r|\n|\\s|\\[.+?\\])/is", ' ', $string); } elseif ($html == 0) { $string = dhtmlspecialchars($string); } if ($length) { $string = cutstr($string, $length); } if ($bbcode) { require_once DISCUZ_ROOT . './source/class/class_bbcode.php'; $bb =& bbcode::instance(); $string = $bb->bbcode2html($string, $bbcode); } if ($out_slashes) { $string = daddslashes($string); } return trim($string); }
/** * getUser * * read User by ID * id, int: id (required) * * @return User */ public function getUser($id) { // parse inputs $resourcePath = "/user_get_two_read1"; $resourcePath = str_replace("{format}", "json", $resourcePath); $method = "GET"; $queryParams = array(); $headerParams = array(); $formParams = array(); $headerParams['Accept'] = '*/*'; $headerParams['Content-Type'] = 'application/json'; // query params if ($id !== null) { $queryParams['id'] = $this->apiClient->toQueryValue($id); } $body = $body ?: $formParams; if (strpos($headerParams['Content-Type'], "application/x-www-form-urlencoded") > -1) { $body = http_build_query($body); } // make the API Call $response = $this->apiClient->callAPI($resourcePath, $method, $queryParams, $body, $headerParams); if (!$response) { return null; } $responseObject = $this->apiClient->deserialize($response, 'User'); return $responseObject; }
/** * Returns a class name with namespaces removed. * * @param string $className * * @return string */ public function getRelativeClass($className) { if (strpos($className, '\\') !== false) { $className = substr($className, strrpos($className, '\\') + 1); } return $className; }
/** * @param mixed $value * @param AbstractPlatform $platform * * @return string * @throws \InvalidArgumentException */ public function convertToDatabaseValue($value, AbstractPlatform $platform) { if (empty($value)) { return ''; } if ($value instanceof \stdClass) { $value = get_object_vars($value); } if (!is_array($value)) { throw new \InvalidArgumentException("Hstore value must be off array or \\stdClass."); } $hstoreString = ''; foreach ($value as $k => $v) { if (!is_string($v) && !is_numeric($v) && !is_bool($v)) { throw new \InvalidArgumentException("Cannot save 'nested arrays' into hstore."); } $v = trim($v); if (!is_numeric($v) && false !== strpos($v, ' ')) { $v = sprintf('"%s"', $v); } $hstoreString .= "{$k} => {$v}," . "\n"; } $hstoreString = substr(trim($hstoreString), 0, -1) . "\n"; return $hstoreString; }
/** * Iterator function. Returns a rowset if called without parameter, * the fields contents if a field is specified or FALSE to indicate * no more rows are available. * * @param string field default NULL * @return var */ public function next($field = NULL) { if (!is_resource($this->handle) || FALSE === ($row = mssql_fetch_assoc($this->handle))) { return FALSE; } foreach ($row as $key => $value) { if (NULL === $value || !isset($this->fields[$key])) { continue; } switch ($this->fields[$key]) { case 'datetime': $row[$key] = Date::fromString($value, $this->tz); break; case 'numeric': if (FALSE !== strpos($value, '.')) { settype($row[$key], 'double'); break; } // Fallthrough intentional case 'int': if ($value <= LONG_MAX && $value >= LONG_MIN) { settype($row[$key], 'integer'); } else { settype($row[$key], 'double'); } break; } } if ($field) { return $row[$field]; } else { return $row; } }
function CreateVideoGallery() { $InsVideoGallery = ''; for ($z = 0; $z < count($this->_prodvideos); $z++) { if ($this->_prodvideos[$z]['videotype'] == 1 && $this->_prodvideos[$z]['isdownloaded'] == 2) { $filename = $this->_prodvideos[$z]['systemvideofile']; } else { $filename = $this->_prodvideos[$z]['videofile']; } if (strpos($filename, 'http://') !== false) { $VideoLink = $filename; } else { $VideoLink = $GLOBALS['ShopPath'] . '/' . GetConfig('InstallVideoDirectory') . '/' . $filename; } $InsVideoGallery .= '<tr> <td> <a style="color:#CCCCCC" href="javascript:loadInsVideo(\'' . $VideoLink . '\');" title="Video ' . ($z + 1) . '"> Video' . ($z + 1) . ' </a> </td> </tr>'; if ($z == 0) { //$FirstInsVideo = $GLOBALS['ShopPath'].'/'.GetConfig('InstallVideoDirectory').'/'.$filename; $FirstInsVideo = $VideoLink; $GLOBALS['FirstInsVideo'] = 'loadInsVideo(\'' . $FirstInsVideo . '\')'; } } $GLOBALS['InsVideoGallery'] = $InsVideoGallery; // }
public function __get($name) { // if there is a _ in the name, there is a filter at the end if (strpos($name, '_') !== false) { // pick off the last _'d piece preg_match('/^(.*)_([^_]+)$/', $name, $matches); list($junk, $name, $filter) = $matches; // so that we don't break every info value that has a _ in it, only _out is an acceptable filter name if ($filter != 'out') { // put it back together $name = $name . '_' . $filter; // turn off the filter $filter = false; } } else { $filter = false; } // get the value by calling our parent function directly $value = parent::__get($name); // apply the main filter so values can be altered regardless of any _filter $value = Plugins::filter("post_info_{$name}", $value); // if there is a filter, apply that specific one too if ($filter) { $value = Plugins::filter("post_info_{$name}_{$filter}", $value); } return $value; }
static function setMessage($file, $name) { jimport('joomla.filesystem.file'); $file = str_replace('\\', '/', $file); if (strpos($file, '/administrator') === 0) { $file = str_replace('/administrator', JPATH_ADMINISTRATOR, $file); } else { $file = JPATH_SITE . '/' . $file; } $file = str_replace('//', '/', $file); $file_alt = preg_replace('#(com|mod)_([a-z-_]+\\.)#', '\\2', $file); if (!JFile::exists($file) && !JFile::exists($file_alt)) { $msg = JText::sprintf('NN_THIS_EXTENSION_NEEDS_THE_MAIN_EXTENSION_TO_FUNCTION', JText::_($name)); $message_set = 0; $messageQueue = JFactory::getApplication()->getMessageQueue(); foreach ($messageQueue as $queue_message) { if ($queue_message['type'] == 'error' && $queue_message['message'] == $msg) { $message_set = 1; break; } } if (!$message_set) { JFactory::getApplication()->enqueueMessage($msg, 'error'); } } }
/** * {@inheritdoc} */ public function find($ip, $url, $limit, $method) { $file = $this->getIndexFilename(); if (!file_exists($file)) { return array(); } $file = fopen($file, 'r'); fseek($file, 0, SEEK_END); $result = array(); while ($limit > 0) { $line = $this->readLineFromFile($file); if (false === $line) { break; } if ($line === '') { continue; } list($csvToken, $csvIp, $csvMethod, $csvUrl, $csvTime, $csvParent) = str_getcsv($line); if ($ip && false === strpos($csvIp, $ip) || $url && false === strpos($csvUrl, $url) || $method && false === strpos($csvMethod, $method)) { continue; } $result[$csvToken] = array('token' => $csvToken, 'ip' => $csvIp, 'method' => $csvMethod, 'url' => $csvUrl, 'time' => $csvTime, 'parent' => $csvParent); --$limit; } fclose($file); return array_values($result); }
/** * Check non english character in DB * @group jobdesc */ public function testAdd() { print "\n" . __METHOD__ . ' '; $this->_rootLogin(); $description = 'очень длинное UTF8 описание задания'; // add new record $this->request->setPost(array('form1' => 1, 'name_job' => 'job.name.test.1', 'short_desc' => 'short description ' . $description, 'description' => "PHPUnit test {$description}\njob description\n", 'retention_period' => '3 years')); $this->request->setMethod('POST'); $this->dispatch('wbjobdesc/add'); $this->logBody($this->response->outputBody()); // debug log $this->assertController('wbjobdesc'); $this->assertAction('add'); // check $this->resetRequest(); $this->resetResponse(); $this->dispatch('wbjobdesc/index'); $this->logBody($this->response->outputBody(), 'a'); // debug log $this->assertModule('default'); $this->assertController('wbjobdesc'); $this->assertAction('index'); $this->assertNotQueryContentRegex('table', self::ZF_pattern); // Zend Framework $pos = strpos($this->response->outputBody(), $description); // $this->assertQueryContentContains('td', $description); if ($pos === false) { $this->assertTrue(FALSE, "string '" . $description . '" not found'); } }
public function createCommand(TaskInfo $taskInfo) { $task = new Command($taskInfo->getName()); $task->setDescription($taskInfo->getDescription()); $task->setHelp($taskInfo->getHelp()); $args = $taskInfo->getArguments(); foreach ($args as $name => $val) { $description = $taskInfo->getArgumentDescription($name); if ($val === TaskInfo::PARAM_IS_REQUIRED) { $task->addArgument($name, InputArgument::REQUIRED, $description); } elseif (is_array($val)) { $task->addArgument($name, InputArgument::IS_ARRAY, $description, $val); } else { $task->addArgument($name, InputArgument::OPTIONAL, $description, $val); } } $opts = $taskInfo->getOptions(); foreach ($opts as $name => $val) { $description = $taskInfo->getOptionDescription($name); $fullName = $name; $shortcut = ''; if (strpos($name, '|')) { list($fullName, $shortcut) = explode('|', $name, 2); } if (is_bool($val)) { $task->addOption($fullName, $shortcut, InputOption::VALUE_NONE, $description); } else { $task->addOption($fullName, $shortcut, InputOption::VALUE_OPTIONAL, $description, $val); } } return $task; }
public function lostpasswordAction() { $username = $this->_getParam("username"); if ($username) { $user = User::getByName($username); if (!$user instanceof User) { $this->view->error = "user unknown"; } else { if ($user->isActive()) { if ($user->getEmail()) { $token = Pimcore_Tool_Authentication::generateToken($username, $user->getPassword(), MCRYPT_TRIPLEDES, MCRYPT_MODE_ECB); $protocol = "http://"; if (strpos(strtolower($_SERVER["SERVER_PROTOCOL"]), "https") === 0) { $protocol = "https://"; } $uri = $protocol . $_SERVER['SERVER_NAME']; $loginUrl = $uri . "/admin/login/login/?username="******"&token=" . $token; try { $mail = Pimcore_Tool::getMail(array($user->getEmail()), "Pimcore lost password service"); $mail->setBodyText("Login to pimcore and change your password using the following link. This temporary login link will expire in 30 minutes: \r\n\r\n" . $loginUrl); $mail->send(); $this->view->success = true; } catch (Exception $e) { $this->view->error = "could not send email"; } } else { $this->view->error = "user has no email address"; } } else { $this->view->error = "user inactive"; } } } }
/** * Parse a string for embed codes. * * @param string $content The text to parse. * @param string $base_url The base URL. Ignored. * @param string $default_link_text Default link text. Ignored. * @return array An array of new blcLinkInstance objects. The objects will include info about the embeds found, but not about the corresponding container entity. */ function parse($content, $base_url = '', $default_link_text = '') { $instances = array(); //Find likely-looking <embed> elements $embeds = $this->extract_embeds($content); foreach ($embeds as $embed) { //Do we know how to handle this embed? (first-pass verification) if (strpos($embed['attributes']['src'], $this->url_search_string) === false) { continue; } //Get the original URL of the embedded object (may perform more complex verification) $url = $this->link_url_from_src($embed['attributes']['src']); if (empty($url)) { continue; } //Create a new link instance. $instance = new blcLinkInstance(); $instance->set_parser($this); $instance->raw_url = $embed['embed_code']; $instance->link_text = '[' . $this->short_title . ']'; $link_obj = new blcLink($url); //Creates or loads the link $instance->set_link($link_obj); $instances[] = $instance; } return $instances; }
protected function stripComments($JSONreturnString) { if (strpos($JSONreturnString, "/*") !== false) { $JSONreturnString = substr($JSONreturnString, strpos($JSONreturnString, "*/") + 2); } return substr($JSONreturnString, strpos($JSONreturnString, "{")); }
function _find_outer_brackets($content, &$matches) { $count = 0; $first = strpos($content, '['); if ($first !== FALSE) { $length = strlen($content); $brace_count = 0; $brace_start = -1; for ($i = $first; $i < $length; $i++) { if ($content[$i] == '[') { if ($brace_count == 0) { $brace_start = $i + 1; } $brace_count++; } if ($content[$i] == ']') { if ($brace_count > 0) { $brace_count--; if ($brace_count == 0) { $matches[] = substr($content, $brace_start, $i - $brace_start); $count++; } } } } } return $count; }
/** * Add a link to the backups page to the plugin action links. * * @param array $links * @param string $file * * @return array $links */ function plugin_action_link($links, $file) { if (false !== strpos($file, HMBKP_PLUGIN_SLUG)) { array_push($links, '<a href="' . esc_url(HMBKP_ADMIN_URL) . '">' . __('Backups', 'backupwordpress') . '</a>'); } return $links; }
/** * @param \PHP_CodeSniffer_File $phpCsFile * @param int $stackPointer * * @return void */ public function process(\PHP_CodeSniffer_File $phpCsFile, $stackPointer) { $tokens = $phpCsFile->getTokens(); $docBlockEndIndex = $this->findRelatedDocBlock($phpCsFile, $stackPointer); if (!$docBlockEndIndex) { return; } $docBlockStartIndex = $tokens[$docBlockEndIndex]['comment_opener']; for ($i = $docBlockStartIndex + 1; $i < $docBlockEndIndex; $i++) { if ($tokens[$i]['type'] !== 'T_DOC_COMMENT_TAG') { continue; } if (!in_array($tokens[$i]['content'], ['@return'])) { continue; } $classNameIndex = $i + 2; if ($tokens[$classNameIndex]['type'] !== 'T_DOC_COMMENT_STRING') { continue; } $content = $tokens[$classNameIndex]['content']; $appendix = ''; $spaceIndex = strpos($content, ' '); if ($spaceIndex) { $appendix = substr($content, $spaceIndex); $content = substr($content, 0, $spaceIndex); } if (empty($content)) { continue; } $parts = explode('|', $content); $this->fixParts($phpCsFile, $classNameIndex, $parts, $appendix); } }
/** * Sends an HTTP request. * * @param RequestInterface $request Request to send. * @param array $options Request transfer options. * * @return PromiseInterface */ public function __invoke(RequestInterface $request, array $options) { // Sleep if there is a delay specified. if (isset($options['delay'])) { usleep($options['delay'] * 1000); } $startTime = isset($options['on_stats']) ? microtime(true) : null; try { // Does not support the expect header. $request = $request->withoutHeader('Expect'); // Append a content-length header if body size is zero to match // cURL's behavior. if (0 === $request->getBody()->getSize()) { $request = $request->withHeader('Content-Length', 0); } return $this->createResponse($request, $options, $this->createStream($request, $options), $startTime); } catch (\InvalidArgumentException $e) { throw $e; } catch (\Exception $e) { // Determine if the error was a networking error. $message = $e->getMessage(); // This list can probably get more comprehensive. if (strpos($message, 'getaddrinfo') || strpos($message, 'Connection refused') || strpos($message, "couldn't connect to host")) { $e = new ConnectException($e->getMessage(), $request, $e); } $e = RequestException::wrapException($request, $e); $this->invokeStats($options, $request, $startTime, null, $e); return new RejectedPromise($e); } }
/** * Factory method to return a preconfigured Zend_Service_StrikeIron_* * instance. * * @param null|string $options Service options * @return object Zend_Service_StrikeIron_* instance * @throws Zend_Service_StrikeIron_Exception */ public function getService($options = array()) { $class = isset($options['class']) ? $options['class'] : 'Base'; unset($options['class']); if (strpos($class, '_') === false) { $class = "Zend_Service_StrikeIron_{$class}"; } try { if (!class_exists($class)) { // require_once 'Zend/Loader.php'; @Zend_Loader::loadClass($class); } if (!class_exists($class, false)) { throw new Exception('Class file not found'); } } catch (Exception $e) { $msg = "Service '{$class}' could not be loaded: " . $e->getMessage(); /** * @see Zend_Service_StrikeIron_Exception */ // require_once 'Zend/Service/StrikeIron/Exception.php'; throw new Zend_Service_StrikeIron_Exception($msg, $e->getCode(), $e); } // instantiate and return the service $service = new $class(array_merge($this->_options, $options)); return $service; }
/** * Constructs a Drush alias for an environment. Used to supply * organizational Drush aliases not provided by the API. * * @param Environment $environment Environment to create an alias for * @return string * @throws TerminusException */ private function constructAlias($environment) { $site_name = $environment->site->get('name'); $site_id = $environment->site->get('id'); $env_id = $environment->get('id'); $db_bindings = $environment->bindings->getByType('dbserver'); $hostnames = array_keys((array) $environment->getHostnames()); if (empty($hostnames) || empty($db_bindings)) { throw new TerminusException('No hostname entry for {site}.{env}', ['site' => $site_name, 'env' => $env_id], 1); } $db_binding = array_shift($db_bindings); $uri = array_shift($hostnames); $db_pass = $db_binding->get('password'); $db_port = $db_binding->get('port'); if (strpos(TERMINUS_HOST, 'onebox') !== false) { $remote_user = "******"; $remote_host = TERMINUS_HOST; $db_url = "mysql://*****:*****@{$remote_host}:{$db_port}"; $db_url .= '/pantheon'; } else { $remote_user = "******"; $remote_host = "appserver.{$env_id}.{$site_id}.drush.in"; $db_url = "mysql://*****:*****@dbserver.{$environment}.{$site_id}"; $db_url .= ".drush.in:{$db_port}/pantheon"; } $output = "array(\n 'uri' => {$uri},\n 'db-url' => {$db_url},\n 'db-allows-remote' => true,\n 'remote-host' => {$remote_host},\n 'remote-user' => {$remote_user},\n 'ssh-options' => '-p 2222 -o \"AddressFamily inet\"',\n 'path-aliases' => array(\n '%files' => 'code/sites/default/files',\n '%drush-script' => 'drush',\n ),\n );"; return $output; }
function procesar() { toba::logger_ws()->debug('Servicio Llamado: ' . $this->info['basica']['item']); toba::logger_ws()->set_checkpoint(); set_error_handler('toba_logger_ws::manejador_errores_recuperables', E_ALL); $this->validar_componente(); //-- Pide los datos para construir el componente, WSF no soporta entregar objetos creados $clave = array(); $clave['proyecto'] = $this->info['objetos'][0]['objeto_proyecto']; $clave['componente'] = $this->info['objetos'][0]['objeto']; list($tipo, $clase, $datos) = toba_constructor::get_runtime_clase_y_datos($clave, $this->info['objetos'][0]['clase'], false); agregar_dir_include_path(toba_dir() . '/php/3ros/wsf'); $opciones_extension = toba_servicio_web::_get_opciones($this->info['basica']['item'], $clase); $wsdl = strpos($_SERVER['REQUEST_URI'], "?wsdl") !== false; $sufijo = 'op__'; $metodos = array(); $reflexion = new ReflectionClass($clase); foreach ($reflexion->getMethods() as $metodo) { if (strpos($metodo->name, $sufijo) === 0) { $servicio = substr($metodo->name, strlen($sufijo)); $prefijo = $wsdl ? '' : '_'; $metodos[$servicio] = $prefijo . $metodo->name; } } $opciones = array(); $opciones['serviceName'] = $this->info['basica']['item']; $opciones['classes'][$clase]['operations'] = $metodos; $opciones = array_merge($opciones, $opciones_extension); $this->log->debug("Opciones del servidor: " . var_export($opciones, true), 'toba'); $opciones['classes'][$clase]['args'] = array($datos); toba::logger_ws()->set_checkpoint(); $service = new WSService($opciones); $service->reply(); $this->log->debug("Fin de servicio web", 'toba'); }
function onls() { $logdir = UC_ROOT . 'data/logs/'; $dir = opendir($logdir); $logs = $loglist = array(); while ($entry = readdir($dir)) { if (is_file($logdir . $entry) && strpos($entry, '.php') !== FALSE) { $logs = array_merge($logs, file($logdir . $entry)); } } closedir($dir); $logs = array_reverse($logs); foreach ($logs as $k => $v) { if (count($v = explode("\t", $v)) > 1) { $v[3] = $this->date($v[3]); $v[4] = $this->lang[$v[4]]; $loglist[$k] = $v; } } $page = max(1, intval($_GET['page'])); $start = ($page - 1) * UC_PPP; $num = count($loglist); $multipage = $this->page($num, UC_PPP, $page, 'admin.php?m=log&a=ls'); $loglist = array_slice($loglist, $start, UC_PPP); $this->view->assign('loglist', $loglist); $this->view->assign('multipage', $multipage); $this->view->display('admin_log'); }