/**
 * 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
}
Example #2
5
File: Word.php Project: pumi11/aau
 /**
  * @throws \PhpOffice\PhpWord\Exception\Exception
  * Создание word для юр вопросов
  */
 public static function ur_questions($row)
 {
     $user = User::findOne(\Yii::$app->user->identity->id);
     $file = \Yii::$app->basePath . '/temp/ur_questions/' . $row['qid'] . '.docx';
     $template = \Yii::$app->basePath . '/temp/ur_questions/Template.docx';
     $templateProcessor = new \PhpOffice\PhpWord\TemplateProcessor($template);
     // Variables on different parts of document
     $row['question'] = str_replace("\n", "<w:br/>", $row['question']);
     //Для пробелов
     $templateProcessor->setValue('vopros', $row['question']);
     $templateProcessor->setValue('date', date("d.m.Y"));
     $templateProcessor->setValue('ur_name', $row['uname']);
     $templateProcessor->setValue('ur_ruk', $row['contact_face']);
     $templateProcessor->setValue('ur_phone', $row['contact_phone']);
     $templateProcessor->setValue('ur_mail', $row['contact_mail']);
     $templateProcessor->setValue('ur_region', $row['rname']);
     //$templateProcessor->setValue('serverName', realpath(__DIR__)); // On header
     $templateProcessor->saveAs($file);
     $qf = explode("|", $row['qfiles']);
     if (!isset($qf[0])) {
         $qf[0] = $qf;
     }
     $mail = \Yii::$app->mail->compose('ur_questions', ['uname' => $row['uname'], 'username' => $user['username'], 'mail' => $user['mail']])->setFrom([\Yii::$app->params['infoEmail'] => 'СоюзФарма'])->setTo(\Yii::$app->params['uristEmail'])->setSubject('Юридический вопрос')->attach($file);
     foreach ($qf as $q) {
         if ($q != "") {
             $mail->attach($q);
         }
     }
     $mail->send();
     // if($templateProcessor->saveAs('results/Sample_07_TemplateCloneRow.docx')) {
     //      return true;
     //  }else{
     //    return false;
     // }
 }
Example #3
3
 public function partial($partial, $__time = false, $params = null, $group = 'kumbia.partials')
 {
     //        if (PRODUCTION && $__time && !Cache::driver()->start($__time, $partial, $group)) {
     //            return;
     //        }
     //Verificando el partials en el dir app
     $__file = $this->viewPath . "/_shared/partials/{$partial}.phtml";
     //        if (!is_file($__file)) {
     //            //Verificando el partials en el dir core
     //            $__file = CORE_PATH . "views/partials/$partial.phtml";
     //        }
     if ($params) {
         if (is_string($params)) {
             $params = Util::getParams(explode(',', $params));
         }
         // carga los parametros en el scope
         extract($params, EXTR_OVERWRITE);
     }
     // carga la vista parcial
     if (!(include $__file)) {
         throw new \Exception('Vista Parcial "' . $__file . '" no se encontro');
     }
     // se guarda en la cache de ser requerido
     //        if (PRODUCTION && $__time) {
     //            Cache::driver()->end();
     //        }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param Closure|\Closure $next
  * @param $permissions
  * @return mixed
  * @internal param $roles
  * @internal param null|string $guard
  */
 public function handle(Request $request, Closure $next, $permissions)
 {
     if (Auth::guest() || !$request->user()->can(explode('|', $permissions))) {
         abort(403);
     }
     return $next($request);
 }
Example #5
1
 public function partialName($user_id)
 {
     $name = $this->findByAttributes(['user_id' => $user_id])->row_array();
     $lastname = explode(' ', $name['family_name']);
     $partialName = $name['given_name'] . ' ' . $lastname[count($lastname) - 1];
     return $partialName;
 }
 /**
  * 'beforeMethod' event handles. This event handles intercepts GET requests ending
  * with ?export
  *
  * @param string $method
  * @param string $uri
  * @return bool
  */
 public function beforeMethod($method, $uri)
 {
     if ($method != 'GET') {
         return;
     }
     if ($this->server->httpRequest->getQueryString() != 'export') {
         return;
     }
     // splitting uri
     list($uri) = explode('?', $uri, 2);
     $node = $this->server->tree->getNodeForPath($uri);
     if (!$node instanceof IAddressBook) {
         return;
     }
     // Checking ACL, if available.
     if ($aclPlugin = $this->server->getPlugin('acl')) {
         $aclPlugin->checkPrivileges($uri, '{DAV:}read');
     }
     $this->server->httpResponse->setHeader('Content-Type', 'text/directory');
     $this->server->httpResponse->sendStatus(200);
     $nodes = $this->server->getPropertiesForPath($uri, array('{' . Plugin::NS_CARDDAV . '}address-data'), 1);
     $this->server->httpResponse->sendBody($this->generateVCF($nodes));
     // Returning false to break the event chain
     return false;
 }
 function addnew()
 {
     if ($_POST) {
         $image = $_FILES['logo'];
         $image_name = $image['name'];
         $image_tmp = $image['tmp_name'];
         $image_size = $image['size'];
         $error = $image['error'];
         $file_ext = explode('.', $image_name);
         $file_ext = strtolower(end($file_ext));
         $allowed_ext = array('jpg', 'jpeg', 'bmp', 'png', 'gif');
         $file_on_server = '';
         if (in_array($file_ext, $allowed_ext)) {
             if ($error === 0) {
                 if ($image_size < 3145728) {
                     $file_on_server = uniqid() . '.' . $file_ext;
                     $destination = './brand_img/' . $file_on_server;
                     move_uploaded_file($image_tmp, $destination);
                 }
             }
         }
         $values = array('name' => $this->input->post('name'), 'description' => $this->input->post('desc'), 'logo' => $file_on_server, 'is_active' => 1);
         if ($this->brand->create($values)) {
             $this->session->set_flashdata('message', 'New Brand added successfully');
         } else {
             $this->session->set_flashdata('errormessage', 'Oops! Something went wrong!!');
         }
         redirect(base_url() . 'brands/');
     }
     $this->load->helper('form');
     $this->load->view('includes/header', array('title' => 'Add Brand'));
     $this->load->view('brand/new_brand');
     $this->load->view('includes/footer');
 }
 /**
  * Return a OpenSeadragon image viewer for the provided files.
  * 
  * @param File|array $files A File record or an array of File records.
  * @param int $width The width of the image viewer in pixels.
  * @param int $height The height of the image viewer in pixels.
  * @return string|null
  */
 public function openseadragon($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     // Filter out invalid images.
     $images = array();
     $imageNames = array();
     foreach ($files as $file) {
         // A valid image must be a File record.
         if (!$file instanceof File) {
             continue;
         }
         // A valid image must have a supported extension.
         $extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
         if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
             continue;
         }
         $images[] = $file;
         $imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
     }
     // Return if there are no valid images.
     if (!$images) {
         return;
     }
     return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
 }
Example #9
1
 public function setUp(PDO $pdo, $sql)
 {
     $sql = explode(';', trim($sql));
     foreach ($sql as $query) {
         $pdo->exec(trim($query));
     }
 }
Example #10
1
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $view = $this->entity;
     $form['#prefix'] = '<div id="views-preview-wrapper" class="views-admin clearfix">';
     $form['#suffix'] = '</div>';
     $form['#id'] = 'views-ui-preview-form';
     $form_state->disableCache();
     $form['controls']['#attributes'] = array('class' => array('clearfix'));
     $form['controls']['title'] = array('#prefix' => '<h2 class="view-preview-form__title">', '#markup' => $this->t('Preview'), '#suffix' => '</h2>');
     // Add a checkbox controlling whether or not this display auto-previews.
     $form['controls']['live_preview'] = array('#type' => 'checkbox', '#id' => 'edit-displays-live-preview', '#title' => $this->t('Auto preview'), '#default_value' => \Drupal::config('views.settings')->get('ui.always_live_preview'));
     // Add the arguments textfield
     $form['controls']['view_args'] = array('#type' => 'textfield', '#title' => $this->t('Preview with contextual filters:'), '#description' => $this->t('Separate contextual filter values with a "/". For example, %example.', array('%example' => '40/12/10')), '#id' => 'preview-args');
     $args = array();
     if (!$form_state->isValueEmpty('view_args')) {
         $args = explode('/', $form_state->getValue('view_args'));
     }
     $user_input = $form_state->getUserInput();
     if ($form_state->get('show_preview') || !empty($user_input['js'])) {
         $form['preview'] = array('#weight' => 110, '#theme_wrappers' => array('container'), '#attributes' => array('id' => 'views-live-preview'), 'preview' => $view->renderPreview($this->displayID, $args));
     }
     $uri = $view->urlInfo('preview-form');
     $uri->setRouteParameter('display_id', $this->displayID);
     $form['#action'] = $uri->toString();
     return $form;
 }
Example #11
1
 /**
  * @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;
 }
Example #12
1
 function get_exif($file)
 {
     if (!function_exists('exif_read_data')) {
         return false;
     }
     $exif = @exif_read_data($file, "IFD0");
     if ($exif === false) {
         return false;
     }
     $exif_info = exif_read_data($file, NULL, true);
     $exif_arr = $this->supported_exif();
     $new_exif = array();
     foreach ($exif_arr as $k => $v) {
         $arr = explode('.', $v);
         if (isset($exif_info[$arr[0]])) {
             if (isset($exif_info[$arr[0]][$arr[1]])) {
                 $new_exif[$k] = $exif_info[$arr[0]][$arr[1]];
             } else {
                 $new_exif[$k] = false;
             }
         } else {
             $new_exif[$k] = false;
         }
         if ($k == 'Software' && !empty($new_exif['Software'])) {
             $new_exif['Software'] = preg_replace('/([^a-zA-Z0-9_\\-,\\.\\:&#@!\\(\\)\\s]+)/i', '', $new_exif['Software']);
         }
     }
     return $new_exif;
 }
Example #13
1
 /**
  * Fetch Links
  *
  * Fetches a set of links corresponding to an OpenURL
  *
  * @param string $openURL openURL (url-encoded)
  *
  * @return string         raw XML returned by resolver
  * @access public
  */
 public function fetchLinks($openURL)
 {
     // Unfortunately the EZB-API only allows OpenURL V0.1 and
     // breaks when sending a non expected parameter (like an ISBN).
     // So we do have to 'downgrade' the OpenURL-String from V1.0 to V0.1
     // and exclude all parameters that are not compliant with the EZB.
     // Parse OpenURL into associative array:
     $tmp = explode('&', $openURL);
     $parsed = array();
     foreach ($tmp as $current) {
         $tmp2 = explode('=', $current, 2);
         $parsed[$tmp2[0]] = $tmp2[1];
     }
     // Downgrade 1.0 to 0.1
     if ($parsed['ctx_ver'] == 'Z39.88-2004') {
         $openURL = $this->_downgradeOpenUrl($parsed);
     }
     // make the request IP-based to allow automatic
     // indication on institution level
     $openURL .= '&pid=client_ip%3D' . $_SERVER['REMOTE_ADDR'];
     // Make the call to the EZB and load results
     $url = $this->_baseUrl . '?' . $openURL;
     $feed = file_get_contents($url);
     return $feed;
 }
Example #14
1
 public function generate_cookie()
 {
     $characters = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0';
     $characters_array = explode(',', $characters);
     shuffle($characters_array);
     return implode('', $characters_array);
 }
 public function __construct()
 {
     $this->load_gapi_data();
     // hook into post updater
     add_action('social_metrics_data_sync', array($this, 'sync_data'), 10, 2);
     // Display notices on plugin page
     add_action('admin_notices', array($this, 'notices'));
     if ($_POST && $_GET['section'] == 'gapi') {
         // Multisite mode
         if (isset($_POST['multisite_mode'])) {
             $this->set_multisite_mode($_POST['multisite_mode']);
         }
         // GAPI Credentials
         if (isset($_POST['gapi_client_id'])) {
             $this->data['gapi_client_id'] = $_POST['gapi_client_id'];
         }
         if (isset($_POST['gapi_client_secret'])) {
             $this->data['gapi_client_secret'] = $_POST['gapi_client_secret'];
         }
         if (isset($_POST['gapi_developer_key'])) {
             $this->data['gapi_developer_key'] = $_POST['gapi_developer_key'];
         }
         // Profile selection
         if (isset($_POST['gapi_profile_id'])) {
             $elems = explode(',', $_POST['gapi_profile_id'], 2);
             $this->data['gapi_profile_id'] = $elems[0];
             $this->data['gapi_profile_name'] = $elems[1];
         }
         // Save to DB
         $this->update_gapi_data();
     }
 }
Example #16
0
 /**
  * Set $mType and $mValue based on parsed value of $subpage.
  * @param string $subpage
  */
 function setParameter($subpage)
 {
     // parse $subpage to pull out the parts
     $parts = explode('/', $subpage, 2);
     $this->mType = count($parts) > 0 ? $parts[0] : null;
     $this->mValue = count($parts) > 1 ? $parts[1] : null;
 }
Example #17
0
 protected function getValidatorFromClass($class)
 {
     $className = get_class($class);
     $validatorClassName = app()['config']['laracruds']['validators-path'] . '\\' . explode("\\", $className)[1] . app()['config']['laracruds']['validators-sufix'];
     $validatorClass = new $validatorClassName($class);
     return $validatorClass;
 }
Example #18
0
 /**
  * Tests invalid data.
  */
 public function testInvalidDates()
 {
     $composer = new Composer();
     // Invalid date/time parts
     $units = array('second' => array(-1, 61, '-1', '61'), 'minute' => array(-1, 61, '-1', '61'), 'hour' => array(-1, 24, '-1', '24'), 'day' => array(0, 32, '0', '32'), 'month' => array(0, 13, '0', '13'), 'year' => array(1901, 2038, '1901', '2038'));
     foreach ($units as $unit => $tests) {
         foreach ($tests as $test) {
             try {
                 $composer->{'set' . ucfirst($unit)}($test);
             } catch (\Exception $e) {
                 $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
                 $this->assertSame(constant('\\Jyxo\\Time\\ComposerException::' . strtoupper($unit)), $e->getCode(), sprintf('Failed test for unit %s and value %s.', $unit, $test));
             }
         }
     }
     // Incomplete date
     try {
         $date = $composer->getTime();
     } catch (\Exception $e) {
         $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
         $this->assertSame(ComposerException::NOT_COMPLETE, $e->getCode());
     }
     // Invalid dates
     $tests = array('2002-04-31', '2003-02-29', '2004-02-30', '2005-06-31', '2006-09-31', '2007-11-31');
     foreach ($tests as $test) {
         try {
             list($year, $month, $day) = explode('-', $test);
             $composer->setDay($day)->setMonth($month)->setYear($year);
             $time = $composer->getTime();
         } catch (\Exception $e) {
             $this->assertInstanceOf('\\Jyxo\\Time\\ComposerException', $e);
             $this->assertSame(ComposerException::INVALID, $e->getCode(), sprintf('Failed test for %s.', $test));
         }
     }
 }
Example #19
0
 public function index()
 {
     $this->load->model('design/layout');
     $this->load->model('catalog/category');
     $this->load->model('catalog/product');
     $this->load->model('catalog/information');
     if (isset($this->request->get['route'])) {
         $route = (string) $this->request->get['route'];
     } else {
         $route = 'common/home';
     }
     $layout_id = 0;
     if ($route == 'product/category' && isset($this->request->get['path'])) {
         $path = explode('_', (string) $this->request->get['path']);
         $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path));
     }
     if ($route == 'product/product' && isset($this->request->get['product_id'])) {
         $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']);
     }
     if ($route == 'information/information' && isset($this->request->get['information_id'])) {
         $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']);
     }
     if (!$layout_id) {
         $layout_id = $this->model_design_layout->getLayout($route);
     }
     if (!$layout_id) {
         $layout_id = $this->config->get('config_layout_id');
     }
     $module_data = array();
     $this->load->model('setting/extension');
     $extensions = $this->model_setting_extension->getExtensions('module');
     foreach ($extensions as $extension) {
         $modules = $this->config->get($extension['code'] . '_module');
         if ($modules) {
             foreach ($modules as $module) {
                 if ($module['layout_id'] == $layout_id && $module['position'] == 'header_top' && $module['status']) {
                     $module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']);
                 }
             }
         }
     }
     $sort_order = array();
     foreach ($module_data as $key => $value) {
         $sort_order[$key] = $value['sort_order'];
     }
     array_multisort($sort_order, SORT_ASC, $module_data);
     $this->data['modules'] = array();
     foreach ($module_data as $module) {
         $module = $this->getChild('module/' . $module['code'], $module['setting']);
         if ($module) {
             $this->data['modules'][] = $module;
         }
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_top.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/common/header_top.tpl';
     } else {
         $this->template = 'default/template/common/header_top.tpl';
     }
     $this->render();
 }
Example #20
0
 /**
  * Returns a list of Sabre\DAV\Locks\LockInfo objects
  *
  * This method should return all the locks for a particular uri, including
  * locks that might be set on a parent uri.
  *
  * If returnChildLocks is set to true, this method should also look for
  * any locks in the subtree of the uri for locks.
  *
  * @param string $uri
  * @param bool $returnChildLocks
  * @return array
  */
 function getLocks($uri, $returnChildLocks)
 {
     $lockList = [];
     $currentPath = '';
     foreach (explode('/', $uri) as $uriPart) {
         // weird algorithm that can probably be improved, but we're traversing the path top down
         if ($currentPath) {
             $currentPath .= '/';
         }
         $currentPath .= $uriPart;
         $uriLocks = $this->getData($currentPath);
         foreach ($uriLocks as $uriLock) {
             // Unless we're on the leaf of the uri-tree we should ignore locks with depth 0
             if ($uri == $currentPath || $uriLock->depth != 0) {
                 $uriLock->uri = $currentPath;
                 $lockList[] = $uriLock;
             }
         }
     }
     // Checking if we can remove any of these locks
     foreach ($lockList as $k => $lock) {
         if (time() > $lock->timeout + $lock->created) {
             unset($lockList[$k]);
         }
     }
     return $lockList;
 }
 private function createResponse(RequestInterface $request, array $options, $stream, $startTime)
 {
     $hdrs = $this->lastHeaders;
     $this->lastHeaders = [];
     $parts = explode(' ', array_shift($hdrs), 3);
     $ver = explode('/', $parts[0])[1];
     $status = $parts[1];
     $reason = isset($parts[2]) ? $parts[2] : null;
     $headers = \GuzzleHttp\headers_from_lines($hdrs);
     list($stream, $headers) = $this->checkDecode($options, $headers, $stream);
     $stream = Psr7\stream_for($stream);
     $sink = $this->createSink($stream, $options);
     $response = new Psr7\Response($status, $headers, $sink, $ver, $reason);
     if (isset($options['on_headers'])) {
         try {
             $options['on_headers']($response);
         } catch (\Exception $e) {
             $msg = 'An error was encountered during the on_headers event';
             $ex = new RequestException($msg, $request, $response, $e);
             return new RejectedPromise($ex);
         }
     }
     if ($sink !== $stream) {
         $this->drain($stream, $sink);
     }
     $this->invokeStats($options, $request, $startTime, $response, null);
     return new FulfilledPromise($response);
 }
Example #22
0
function imprimirUsuarios()
{
    $userQuery = ParseUser::query();
    $userQuery->notEqualTo("username", "tUKgzMsZ09LbLIIdwSZyIH1PVcu24aEcMpxcWH4A");
    $results = $userQuery->find();
    #Cuantos resultados recibio de la base de datos de parse
    //echo "Successfully retrieved " . count($results) . " scores.<br>";
    // Do something with the returned ParseObject values
    for ($i = 0; $i < count($results); $i++) {
        $object = $results[$i];
        //echo $object->getObjectId() . ' - ' . $object->get('username');
        $_strUsuario = $object->get('username');
        $_strUsuarioTO = $object->getObjectId();
        $arraynombre = explode('&', $_strUsuario);
        echo "<tr>";
        echo "<td>" . $arraynombre[1] . "</td>";
        echo "<form action='' method='POST' >";
        echo "<td align='right'> <input type='text' value='Mensaje' name='send'>" . "</td>";
        echo "<td> <input type='submit' value='Enviar Mensaje' name='enviar_Push'>" . "</td>";
        echo "</tr>";
        echo "<input type='hidden' value={$_strUsuario} name='nombreUsuario'>";
        echo "</form> ";
        /*
         echo '<'.'input type='.'"submit"'. 'value="'. $object->get('username').'"';
         echo "<input type='hidden' value=$costo  name='costo'>";
         echo "<br>";
        */
    }
}
 /**
  * @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);
     }
 }
Example #24
0
 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;
 }
Example #25
0
 public function checkView($appealId)
 {
     $appealData = app::get('sysrate')->model('appeal')->getRow('*', ['appeal_id' => $appealId]);
     if (!$appealData) {
         return '审核的申诉不存在';
     }
     if ($appealData['evidence_pic']) {
         $appealData['evidence_pic'] = explode(',', $appealData['evidence_pic']);
     }
     if ($appealData['appeal_log']['evidence_pic']) {
         $appealData['appeal_log']['evidence_pic'] = explode(',', $appealData['appeal_log']['evidence_pic']);
     }
     $pagedata['appealData'] = $appealData;
     $rateData = app::get('sysrate')->model('traderate')->getRow('tid,oid,result,content,rate_pic,created_time', ['rate_id' => $appealData['rate_id'], 'disabled' => [0, 1]]);
     if ($rateData['rate_pic']) {
         $rateData['rate_pic'] = explode(',', $rateData['rate_pic']);
     }
     $pagedata['rateData'] = $rateData;
     // 订单状态标示对应表
     $this->tradeStatus = array('WAIT_BUYER_PAY' => '已下单等待付款', 'WAIT_SELLER_SEND_GOODS' => '已付款等待发货', 'WAIT_BUYER_CONFIRM_GOODS' => '已发货等待确认收货', 'TRADE_FINISHED' => '已完成', 'TRADE_CLOSED' => '已关闭', 'TRADE_CLOSED_BY_SYSTEM' => '已关闭');
     $params = array('tid' => $rateData['tid'], 'oid' => $rateData['oid'], 'fields' => 'tid,user_id,created_time,consign_time,status,shop_id,orders.bn,orders.sendnum,orders.num,orders.price,orders.total_fee,orders.oid,orders.title,orders.item_id');
     $trade = app::get('sysrate')->rpcCall('trade.get', $params);
     $trade['status_des'] = $this->tradeStatus[$trade['status']];
     $pagedata['trade'] = $trade;
     $pagedata['appeal_id'] = $appealId;
     return $this->page('sysrate/appeal/check.html', $pagedata);
 }
 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;
 }
Example #27
0
 function display($map, $values, $type = 'discount')
 {
     $id = $type . '_' . $map;
     $js = 'window.hikashop.ready( function(){ updateSubscription(\'' . $id . '\'); });';
     if (!HIKASHOP_PHP5) {
         $doc =& JFactory::getDocument();
     } else {
         $doc = JFactory::getDocument();
     }
     $doc->addScriptDeclaration($js);
     if (empty($values)) {
         $values = 'none';
     }
     $choiceValue = $values == 'none' ? $values : 'special';
     $return = JHTML::_('hikaselect.radiolist', $this->choice, "choice_" . $id, 'onchange="updateSubscription(\'' . $id . '\');"', 'value', 'text', $choiceValue);
     $return .= '<input type="hidden" name="data[' . $type . '][' . $map . ']" id="hidden_' . $id . '" value="' . $values . '"/>';
     $valuesArray = explode(',', $values);
     $listAccess = '<div style="display:none" id="div_' . $id . '"><table>';
     foreach ($this->groups as $oneGroup) {
         $listAccess .= '<tr><td>';
         if (version_compare(JVERSION, '1.6.0', '>=') || !in_array($oneGroup->value, array(29, 30))) {
             $listAccess .= '<input type="radio" onchange="updateSubscription(\'' . $id . '\');" value="' . $oneGroup->value . '" ' . (in_array($oneGroup->value, $valuesArray) ? 'checked' : '') . ' name="special_' . $id . '" id="special_' . $id . '_' . $oneGroup->value . '"/>';
         }
         $listAccess .= '</td><td><label for="special_' . $id . '_' . $oneGroup->value . '">' . $oneGroup->text . '</label></td></tr>';
     }
     $listAccess .= '</table></div>';
     $return .= $listAccess;
     return $return;
 }
 /**
  * Converts entity labels for entity reference fields to entity ids.
  *
  * @param string $entity_type
  *   The type of the entity being processed.
  * @param string $entity_bundle
  *   The bundle of the entity being processed.
  * @param array $values
  *   An array of field values keyed by field name.
  *
  * @return array
  *   The processed field values.
  *
  * @throws \Exception
  *   Thrown when no entity with the given label has been found.
  */
 public function convertEntityReferencesValues($entity_type, $entity_bundle, $values)
 {
     $definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type, $entity_bundle);
     foreach ($definitions as $name => $definition) {
         if ($definition->getType() != 'entity_reference' || !array_key_exists($name, $values) || !strlen($values[$name])) {
             continue;
         }
         // Retrieve the entity type and bundles that can be referenced.
         $settings = $definition->getSettings();
         $target_entity_type = $settings['target_type'];
         $target_entity_bundles = $settings['handler_settings']['target_bundles'];
         // Multi-value fields are separated by comma.
         $labels = explode(', ', $values[$name]);
         $values[$name] = [];
         foreach ($labels as $label) {
             $id = $this->getEntityIdByLabel($label, $target_entity_type, $target_entity_bundles);
             $bundles = implode(',', $target_entity_bundles);
             if (!$id) {
                 throw new \Exception("Entity with label '{$label}' could not be found for '{$target_entity_type} ({$bundles})' to fill field '{$name}'.");
             }
             $values[$name][] = $id;
         }
     }
     return $values;
 }
 public function run(&$parms)
 {
     //安装时不执行
     if (defined('BIND_MODULE') && BIND_MODULE === 'Install') {
         return;
     }
     $data = S('global_hooks');
     if (!$data) {
         $hooks = M('Hooks', "common_")->getField('name,addons');
         foreach ($hooks as $key => $value) {
             if ($value) {
                 $map['status'] = 1;
                 $names = explode(',', $value);
                 $map['name'] = array('IN', $names);
                 $data = M('Addons', "common_")->where($map)->getField('id,name');
                 if ($data) {
                     $addons = array_intersect($names, $data);
                     Hook::add($key, array_map('get_addon_class', $addons));
                 }
             }
         }
         S('global_hooks', Hook::get());
     } else {
         Hook::import($data, false);
     }
 }
Example #30
-15
 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');
 }