Finds a snippet begining with the data passed
@param {stdClass} $data Data passed from ActionScript
@return {array} Standard response base
323089
public function findSnippetAutoComplete($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
        
            return $response;
        }
        
        
        //Lookup snippets
        $snippets=Snippet::get()->filter('Title:StartsWith', Convert::raw2sql($data->pattern))->limit(20);
        
        
        $response['status']='HELO';
        $response['data']=$this->overviewList($snippets);
        
        return $response;
    }
1215831
public function get(array $data=null)
	{
		if ( $this->check() ){
			if ( \is_null($this->content) ){
				$this->content = file_get_contents($this->file);
			}
			if ( empty($this->content) ){
				return '';
			}
			if ( $this->checkers ){
			  $st = '';
			  foreach ( $this->checkers as $chk ){
			    $st .= file_get_contents($chk);
        }
        $this->content = $st.$this->content;
      }
      switch ( $this->ext ){
        case 'js':
          // Language variables inclusions in the javascript files
          if ( !empty($this->lang_file) ){
            $tmp = json_decode(file_get_contents($this->lang_file), true);
            $path = $this->plugin ? substr($this->path, \strlen($this->plugin) + 1) : $this->path;
            //die(var_dump(count($tmp), 'components/'.$this->path.'/'.$this->path, $tmp));
            if ( $translations = $tmp['mvc/'.$path] ?? ($tmp['components/'.$path] ?? null) ){
              $json = json_encode($translations);
              $tmp = <<<JAVASCRIPT
(data) => {
  bbn.fn.autoExtend("lng", $json)
};
JAVASCRIPT;
              $this->content = $tmp.$this->content;
            }
            unset($tmp, $translations);
          }
					return $this->content;
        case 'coffee':
					return $this->content;
        case 'css':
					return $this->content;
        case 'less':
			    $less = new \lessc();
          return $less->compile($this->content);
        case 'scss':
          $scss = new \Leafo\ScssPhp\Compiler();
					return $scss->compile($this->content);
				case 'html':
					return empty($data) ? $this->content : bbn\tpl::render($this->content, $data);
        case 'php':
          $dir = getcwd();
          chdir(dirname($this->file));
          $r = bbn\mvc::include_php_view($this->file, $this->content, $data ?: []);
          chdir($dir);
          return $r;
      }
		}
		return false;
	}
333905
public function found(array $data): Response
    {
        $this->response->setBody(json_encode(['data' => $data]));
        return $this->response;
    }
1181437
function(data) {
        this.features = [];
        this.styles   = {};
        this.fetched  = {};

        // Set default options 
        var options = {
            depth: 0,
            styleBaseUrl: this.styleBaseUrl
        };

        return this.parseData(data, options);
    }
268066
public function addSnippetToPackage($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        
        $package=SnippetPackage::get()->byID(intval($data->packageID));
        if(!empty($package) && $package!==false && $package->ID!=0) {
            $snippet=Snippet::get()->byID(intval($data->snippetID));
            if(!empty($snippet) && $snippet!==false && $snippet->ID!=0) {
                $package->Snippets()->add($snippet);
                
                
                $response['status']='HELO';
            }else {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.SNIPPET_NOT_FOUND', '_Snippet not found');
            }
            
            $response['status']='HELO';
        }else {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PACKAGE_NOT_FOUND', '_Package not found');
        }
        
        
        return $response;
    }
742056
public function get($data)
    {
        if (isset($data['url']) && ! empty($data['url'])) {
            $result = @file_get_contents($data['url']);
        }
        
        return isset($result) ? $result : null;
    }
494562
public function saveSnippet($data) {
        $response=CodeBank_ClientAPI::responseBase();
        
        //Ensure logged in
        if(!Permission::check('CODE_BANK_ACCESS')) {
            $response['status']='EROR';
            $response['message']=_t('CodeBankAPI.PERMISSION_DENINED', '_Permission Denied');
            
            return $response;
        }
        
        
        try {
            $snippet=Snippet::get()->byID(intval($data->id));
            if(!empty($snippet) && $snippet!==false && $snippet->ID!=0) {
                $snippet->Title=$data->title;
                $snippet->Description=$data->description;
                $snippet->Text=$data->code;
                $snippet->Tags=$data->tags;
                
                //Ensure we're not assigning to another hidden language
                if($snippet->LanguageID!=$data->language) {
                    $lang=SnippetLanguage::get()->byID(intval($data->language));
                    if(!empty($lang) && $lang!==false && $lang->ID>0) {
                        if($lang->Hidden) {
                            $response['status']='EROR';
                            $response['message']=_t('CodeBankAPI.LANGUAGE_HIDDEN', '_You cannot assign this snippet to a hidden language');
                            
                            return $response;
                        }
                    }else {
                        throw new Exception('Language not found');
                    }
                }
                
                $snippet->LanguageID=$data->language;
                $snippet->LastEditorID=Member::currentUserID();
                $snippet->PackageID=$data->packageID;
                $snippet->write();
                
                
                $response['status']='HELO';
            }else {
                $response['status']='EROR';
                $response['message']=_t('CodeBankAPI.SNIPPET_NOT_FOUND', '_Snippet not found');
            }
        }catch(Exception $e) {
            $response['status']="EROR";
            $response['message']="Internal Server error occured";
        }
        
        
        return $response;
    }
785212
public function findBy($data)
    {
        $qb = $this->repository->createQueryBuilder('p');
        $qb->select('p');
        $qb->where('p.queue = :queue');
        $qb->setParameter('queue', $this->name);

        $field = (isset($data['field'])) ? $data['field'] : 'message';

        if (isset($data['search']) && $data['search'] !== null) {
            $qb->andWhere('p.' . $field . ' LIKE :contains');
            $qb->setParameter('contains', '%' . $data['search'] . '%');
        }

        if (isset($data['from']) && $data['from'] !== null && isset($data['to']) && $data['to'] !== null) {
            $qb->andWhere('p.created BETWEEN :from AND :to');
            $qb->setParameter('from', $data['from']);
            $qb->setParameter('to', $data['to']);
        } 

        return $qb->getQuery();
    }
1189005
public function init($data = null)
    {
        $this->meta = array();

        $data = explode('*', (string)$data);

        // ...skip unilateral untagged server responses
        for ($i=0, $len=count($data); $i<$len; $i++) {
            $data_item = &$data[$i];
            if (preg_match('/^ SORT/i', $data_item)) {
                // valid response, initialize raw_data for is_error()
                $this->raw_data = '';
                $data_item = substr($data_item, 5);
                break;
            }
            else if (preg_match('/^ (E?SEARCH)/i', $data_item, $m)) {
                // valid response, initialize raw_data for is_error()
                $this->raw_data = '';
                $data_item = substr($data_item, strlen($m[0]));

                if (strtoupper($m[1]) == 'ESEARCH') {
                    $data_item = trim($data_item);
                    // remove MODSEQ response
                    if (preg_match('/\(MODSEQ ([0-9]+)\)$/i', $data_item, $m)) {
                        $data_item = substr($data_item, 0, -strlen($m[0]));
                        $this->params['MODSEQ'] = $m[1];
                    }
                    // remove TAG response part
                    if (preg_match('/^\(TAG ["a-z0-9]+\)\s*/i', $data_item, $m)) {
                        $data_item = substr($data_item, strlen($m[0]));
                    }
                    // remove UID
                    $data_item = preg_replace('/^UID\s*/i', '', $data_item);

                    // ESEARCH parameters
                    while (preg_match('/^([a-z]+) ([0-9:,]+)\s*/i', $data_item, $m)) {
                        $param = strtoupper($m[1]);
                        $value = $m[2];

                        $this->params[$param] = $value;
                        $data_item = substr($data_item, strlen($m[0]));

                        if (in_array($param, array('COUNT', 'MIN', 'MAX'))) {
                            $this->meta[strtolower($param)] = (int) $value;
                        }
                    }

// @TODO: Implement compression using compressMessageSet() in __sleep() and __wakeup() ?
// @TODO: work with compressed result?!
                    if (isset($this->params['ALL'])) {
                        $data_item = implode(self::SEPARATOR_ELEMENT,
                            rcube_imap_generic::uncompressMessageSet($this->params['ALL']));
                    }
                }

                break;
            }

            unset($data[$i]);
        }

        $data = array_filter($data);

        if (empty($data)) {
            return;
        }

        $data = array_shift($data);
        $data = trim($data);
        $data = preg_replace('/[\r\n]/', '', $data);
        $data = preg_replace('/\s+/', ' ', $data);

        $this->raw_data = $data;
    }
280651
public function htmlReport($data=[])
    {
        // Forcefully remove headers that might have been set by some
        // templates, controllers or plugins when rendering pages.
        header_remove();
        $root = dirname(__DIR__);
        $data['styles'] = file_get_contents($root . '/assets/report.css');
        $data['script'] = file_get_contents($root . '/assets/report.js');
        $body = Tpl::load(__DIR__ . '/report.php', $data);
        return new Response($body, 'html', $data['error'] ? 500 : 200);
    }
811679
public function process($data)
    {
        $self = $this;
        $environment = $this->parser->getEnvironment();

        $span = $this->escape($data);

        // Emphasis
        $span = preg_replace_callback('/\*\*(.+)\*\*/mUsi', function ($matches) use ($self) {
          return $self->strongEmphasis($matches[1]);
        }, $span);
        $span = preg_replace_callback('/\*(.+)\*/mUsi', function ($matches) use ($self) {
          return $self->emphasis($matches[1]);
        }, $span);

        // Nbsp
        $span = preg_replace('/~/', $this->nbsp(), $span);

        // Replacing variables
        $span = preg_replace_callback('/\|(.+)\|/mUsi', function($match) use ($environment) {
            return $environment->getVariable($match[1]);
        }, $span);

        // Adding brs when a space is at the end of a line
        $span = preg_replace('/ \n/', $this->br(), $span);

        return $span;
    }
1204160
protected function get_final_create_data($data) {
        foreach (self::$validfields as $field) {
            if (!isset($data[$field]) && isset($this->defaults[$field])) {
                $data[$field] = $this->defaults[$field];
            }
        }
        $data['shortname'] = $this->shortname;
        return $data;
    }
105379
private static function wringer($data)
    {
        if (is_object($data)) {
            if ($data instanceof \BootPress\Blog\Twig\Object) {
                $data = $data->properties + $data->methods;
            } elseif ($data instanceof \BootPress\Blog\Twig\Page) {
                $data = $data->html + $data->methods;
            } else {
                $data = get_class($data).' Object';
            }
        }
        if (is_array($data)) {
            $cloner = array();
            foreach ($data as $key => $value) {
                $cloner[$key] = self::wringer($value);
            }

            return $cloner;
        }
        if (is_string($data)) {
            $data = str_replace(array("\r", "\n", "\t"), array('\\r', '\\n', '\\t'), $data);
        }

        return $data;
    }
681101
public function parse($data)
    {
        $this->table();
        $this->images();
        $this->text();
        $this->html();

        // Replace everything that has been found
        foreach ($this->matches as $key => $val) {
            $data = preg_replace_callback($key, $val, $data);
        }

        // Replace line-breaks
        return preg_replace_callback("/\n\r?/", function () {
            return '<br />';
        }, $data
        );
    }
303067
public function getAfterSaveRoute($data) {
        if ($currentItem = $this->menu->getCurrent()) {
            $controller = $this->_getParam('controller');
            $url        = null;

            if ($data instanceof \Zend_Controller_Request_Abstract) {
                $refData = $data;
            } elseif (is_array($data)) {
                $refData = $this->getModel()->getKeyRef($data) + $data;
            } else {
                throw new \Gems_Exception_Coding('The variable $data must be an array or a ' . 'Zend_Controller_Request_Abstract object.');
            }

            if ($parentItem = $currentItem->getParent()) {
                if ($parentItem instanceof \Gems_Menu_SubMenuItem) {
                    $controller = $parentItem->get('controller');
                }
            }

            // Look for allowed show
            if ($menuItem = $this->menu->find(array('controller' => $controller, 'action' => 'show', 'allowed' => true))) {
                $url = $menuItem->toRouteUrl($refData);
            }

            if (null === $url) {
                // Look for allowed index
                if ($menuItem = $this->menu->find(array('controller' => $controller, 'action' => 'index', 'allowed' => true))) {
                    $url = $menuItem->toRouteUrl($refData);
                }
            }

            if ((null === $url) && ($parentItem instanceof \Gems_Menu_SubMenuItem)) {
                // Still nothing? Try parent item.
                $url = $parentItem->toRouteUrl($refData);
            }

            if (null !== $url) {
                return $url;
            }
        }
        return false;
    }
855328
private function filterData(array $data)
    {
        $pattern = '/^' . str_replace('%', '.*', trim($this->likeExpr, "'")) . '$/';
        $newData = [];

        foreach ($data as $row) {
            if (preg_match($pattern, $row['Name'])) {
                $newData[] = $row;
            }
        }

        return $newData;
    }
1154879
private function getResponse($data) {
    /* Convert the array with data to a request string. */
    $query = http_build_query($data);

    /* Set up array with options for the context used by file_get_contents(). */
    $opts = array(
      'http'=>array(
        'method'  => 'GET',
        'timeout' => $this->_serverTimeout,
        'header'  => "Accept-language: en\r\n" .
                     "User-Agent: phpSec (http://phpseclib.com)\r\n"
      )
    );

    /* Create context. Allowing us to specify User-Agent. */
    $context = stream_context_create($opts);

    /* Try to get response from Yubico server. */
    $attempts = 0;
    $response = false;
    while($response === false && $attempts < $this->_numServers) {
      /* select a Yubico API server. */
      $server = array_rand($this->_servers);
      $response = @file_get_contents($this->_servers[$server].'?'.$query, null, $context);
      $attempts++;
    }

    if($response === false) {
      /* Could not make request. */
      return false;
    }

    /* Parse response and create an array with the data. */
    $lines = explode("\r\n", $response);
     foreach($lines as $line) {
       if(trim($line) != '') {
         list($key, $val) = explode("=", $line, 2);
         $rdata[$key] = trim($val);
       }
    }

    /* All done. */
    return $rdata;
  }