Esempio n. 1
0
 /**
  * undocumented function
  *
  * @param string $file 
  * @return void
  * @access public
  */
 function import($file)
 {
     $source = file_get_contents($file);
     $xml = new Xml($source);
     $result = $xml->toArray();
     $result = $result['Xmlarchive']['Fileset']['File'];
     if (empty($result)) {
         return false;
     }
     $count = 0;
     foreach ($result as $smiley) {
         $name = $smiley['filename'];
         $content = $smiley['content'];
         $content = preg_replace('/\\s/', '', $content);
         $content = base64_decode($content);
         $filePath = SMILEY_PATH . $name;
         if (file_exists($filePath)) {
             continue;
         }
         $this->create(array('code' => ':' . r('.gif', '', $name) . ':', 'filename' => $name));
         $this->save();
         $f = fopen($filePath, 'w+');
         fwrite($f, $content);
         fclose($f);
         $count++;
     }
     return $count;
 }
 function r($url)
 {
     if (!Configure::read('App.baseUrl')) {
         return $url;
     }
     return r('/index.php', '', $url);
 }
Esempio n. 3
0
 static function env($key)
 {
     if (isset($_SERVER[$key])) {
         return $_SERVER[$key];
     } else {
         if (isset($_ENV[$key])) {
             return $_ENV[$key];
         } else {
             if (getenv($key) !== false) {
                 return getenv($key);
             }
         }
     }
     if ($key == 'DOCUMENT_ROOT') {
         $offset = 0;
         if (!strpos(NServer::env('SCRIPT_NAME'), '.php')) {
             $offset = 4;
         }
         return substr(NServer::env('SCRIPT_FILENAME'), 0, strlen(NServer::env('SCRIPT_FILENAME')) - (strlen(NServer::env('SCRIPT_NAME')) + $offset));
     }
     if ($key == 'PHP_SELF') {
         return r(NServer::env('DOCUMENT_ROOT'), '', NServer::env('SCRIPT_FILENAME'));
     }
     return null;
 }
Esempio n. 4
0
 public function testUserRegex()
 {
     $r = new RouterTestWrapper();
     $r->get(r('|/|'), function () {
     });
     $this->assertEquals('|/|', $r->routes['GET'][0]->regex());
 }
Esempio n. 5
0
 /**
  * Renmove HTML inutil ou com problemas
  *
  * @return String formatada com HTML removido
  */
 function replace($strContent = null)
 {
     $strSiteUrl = 'http://' . $this->siteurl;
     $arrProcura = array("<FONT COLOR=\"000000\">", '</FONT>', '<font FACE=Tahoma color=\'#CC0000\' size=2>', '</font>', '<FONT COLOR="5F9F9F">Entregue', '<td> Entregue </td>', '<FONT COLOR="007FFF">Saiu para entrega', '<td> Aguardando retirada </td>', 'Conferido', '<td> Encaminhado </td>', 'Postado', '<td> Destinatário ausente </td>', 'FISCALIZACAO/CUSTOMS', 'FISCALIZAÇÃO/CUSTOMS', 'Liberado pela alfândega', 'CTCI SAO PAULO (GEARA)', 'CTCI SAO PAULO (GEEXP)', 'OBJ RETIDO - VER AUTENTICIDADE MARCA', 'Recebido/Brasil', 'TRIBUTADO', 'Por favor, entre em contato conosco clicando <a href="http://www.correios.com.br/servicos/falecomoscorreios/default.cfm">aqui</a>.');
     $arrTroca = array(' ', ' ', ' ', ' ', '<span class="entregue">Entregue</span>', '<td><span class="entregue">Entregue</span></td>', '<span class="saiu">Saiu para entrega</span>', '<td><span class="saiu">Saiu para entrega</span></td>', '<span class="conferido">Conferido</span>', '<td><span class="encaminhado">Encaminhado</span></td>', '<span class="postado">Postado</span>', '<td><span class="ausente">Destinatário ausente</span></td>', '<a href="' . $strSiteUrl . '/fiscalizacao-ou-customs" class="informacao">FISCALIZACAO/CUSTOMS</a>', '<a href="' . $strSiteUrl . '/fiscalizacao-ou-customs" class="informacao">FISCALIZACAO/CUSTOMS</a>', '<a href="' . $strSiteUrl . '/liberado-pela-alfandega" class="informacao">Liberado pela alfândega</a>', '<a href="' . $strSiteUrl . '/o-que-e-ctci" class="informacao">CTCI SAO PAULO (GEARA)</a>', '<span class="informacao">CTCI SAO PAULO (GEEXP)</span>', '<a href="' . $strSiteUrl . '/objeto-retido" class="informacao">OBJ RETIDO - VER AUTENTICIDADE MARCA</a>', '<a href="' . $strSiteUrl . '/recebido-no-brasil" class="informacao">Recebido/Brasil</a>', '<a href="' . $strSiteUrl . '/tributado" class="informacao">TRIBUTADO</a>', '<span class="problema"><a href="http://www.correios.com.br/servicos/falecomoscorreios/default.cfm">Por favor, entre em contato conosco clicando aqui</a>.</span>');
     return r($arrProcura, $arrTroca, preg_replace('/\\s{2,}/', '', $strContent));
 }
Esempio n. 6
0
 /**
  *
  */
 public static function get_ip($i_asLong = false)
 {
     static $env_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR');
     static $ip = null;
     $skip_ips = r(self::PROXY_IPS);
     if ($ip) {
         return $i_asLong ? ip2long($ip) : $ip;
     }
     foreach ($env_keys as $key) {
         if (!($val = @$_SERVER[$key])) {
             continue;
         }
         if (strcasecmp($val, 'unknown') == 0) {
             continue;
         }
         list($first) = explode(',', $val);
         $first = trim($first);
         if (preg_match('/^(\\d{1,3}\\.){3,3}\\d{1,3}$/', $first)) {
             if (in_array($first, $skip_ips)) {
                 continue;
             }
             $ip = $first;
             return $i_asLong ? ip2long($ip) : $ip;
         }
     }
     return null;
 }
Esempio n. 7
0
 function read($dir = null, $recursive = false)
 {
     $notes = array();
     $path = CORE_PATH . APP_PATH . $dir;
     $folder = new Folder(APP_PATH . $dir);
     $fold = $recursive ? $folder->findRecursive('.*\\.php') : $folder->find('.*\\.php');
     foreach ($fold as $file) {
         $file = $recursive ? $file : $path . $file;
         $file_path = r(CORE_PATH . APP_PATH, '', $file);
         $handle = new File($file_path);
         $content = $handle->read();
         $lines = explode(PHP_EOL, $content);
         //$lines = file($file);
         $ln = 1;
         if (!empty($lines)) {
             foreach ($lines as $line) {
                 if ((is_null($this->type) || $this->type == 'TODO') && preg_match("/[#\\*\\/\\/]\\s*TODO\\s*(.*)/", $line, $match)) {
                     $this->notes[$file_path]['TODO'][$ln] = $match[1];
                 }
                 if ((is_null($this->type) || $this->type == 'OPTIMIZE') && preg_match("/[#\\*\\/\\/]\\s*OPTIMIZE|OPTIMISE\\s*(.*)/", $line, $match)) {
                     $this->notes[$file_path]['OPTIMIZE'][$ln] = $match[1];
                 }
                 if ((is_null($this->type) || $this->type == 'FIXME') && preg_match("/[#\\*\\/\\/]\\s*FIXME|BUG\\s*(.*)/", $line, $match)) {
                     $this->notes[$file_path]['FIXME'][$ln] = $match[1];
                 }
                 $ln++;
             }
         }
     }
     return $this->notes;
 }
 private function array_to_xml($array, $container = 'response', $is_root = true)
 {
     if (!is_array($array)) {
         return array_to_xml(array($array));
     }
     $xml = '';
     if ($is_root) {
         $xml .= '<?xml version="1.0" encoding="utf-8"?>';
         $xml .= "<{$container}>";
     }
     foreach ($array as $key => $value) {
         // make sure key is a string
         $elem = $key;
         if (!is_string($key) && !empty($container)) {
             $elem = $container;
         }
         $xml .= "<{$elem}>";
         if (is_array($value)) {
             if (array_keys($value) !== array_keys(array_keys($value))) {
                 $xml .= array_to_xml($value, '', false);
             } else {
                 $xml .= array_to_xml($value, r('/s$/', '', $elem), false);
             }
         } else {
             $xml .= htmlspecialchars($value, ENT_COMPAT, 'ISO-8859-1') != $value ? "<![CDATA[{$value}]]>" : $value;
         }
         $xml .= "</{$elem}>";
     }
     if ($is_root) {
         $xml .= "</{$container}>";
     }
     return preg_replace('/[\\x00-\\x1F\\x7F]/', '', $xml);
 }
Esempio n. 9
0
 /**
  * Embeds a github gist
  *
  * @param string $url Gist url: i.e. https://gist.github.com/2924148
  * @param string $file The name of a particular file from the gist, which should displayed only.
  * @return string
  */
 public static function gist($url, $file = null)
 {
     // url for the script file
     $url = $url . '.js' . r(!is_null($file), '?file=' . $file);
     // load the gist
     return html::tag('script', '', array('src' => $url));
 }
Esempio n. 10
0
 function css($key)
 {
     //return;
     $out = '';
     $file = glob(CSS . $key . '_*.css');
     $out .= $this->Html->Css(r('.css', '', basename($file[count($file) - 1])));
     return $out;
 }
Esempio n. 11
0
 function cleanTags($value)
 {
     $value = rtrim(preg_replace('/,+/', ',', r(' ', ',', trim($value))), ',') . ',';
     if ($value == ',') {
         $value = '';
     }
     return $value;
 }
Esempio n. 12
0
 public function loginBeforeContinue()
 {
     if (!s()->user->id) {
         Core_Application::getInstance()->breakDispacher();
         $this->getView()->disableLayout();
         r('/');
     }
 }
Esempio n. 13
0
 public function oauth()
 {
     if (isset($this->params['url']['code'])) {
         $code = $this->params['url']['code'];
     }
     SlSession::write('Api.facebook.accessToken', r('access_token=', '', $this->Facebook->graph("oauth/access_token", array('client_id' => SlConfigure::read('Api.facebook.appId'), 'redirect_uri' => Sl::url(true), 'client_secret' => SlConfigure::read('Api.facebook.secret'), 'code' => $code, 'decode' => false))));
     $this->redirect(SlConfigure::read('Api.facebook.oauthSuccess'));
 }
Esempio n. 14
0
/**
 * Created by PhpStorm.
 * User: raynald
 * Date: 2/5/15
 * Time: 9:44 PM
 */
function r($a)
{
    if ($a < 2) {
        echo "{$a}<br>";
        r($a + 1);
    }
    echo "{$a}" . ' hello<br>';
}
Esempio n. 15
0
 /**
  * Kill Now
  */
 public function fatal($msg)
 {
     if ($this->error_reporting) {
         $this->fatal_errors[] = $msg . @r(debug_backtrace());
     }
     $this->count++;
     exit;
 }
Esempio n. 16
0
 function afterFind($result)
 {
     if (!isset($result[0]['Album'])) {
         return $result;
     }
     for ($i = 0; $i < count($result); $i++) {
         if (array_key_exists('description', $result[$i]['Album'])) {
             $description = $result[$i]['Album']['description'];
             if (empty($description)) {
                 $result[$i]['Album']['description_clean'] = __('This album does not have a description.', true);
             } else {
                 $result[$i]['Album']['description_clean'] = $description;
             }
         }
         if (isset($result[$i]['Album']['tags'])) {
             $result[$i]['Album']['tags'] = trim(r(',', ' ', $result[$i]['Album']['tags']));
         }
         if (array_key_exists('aTn', $result[$i]['Album']) && empty($result[$i]['Album']['aTn'])) {
             $first = array();
             if ($result[$i]['Album']['smart']) {
                 if (!empty($result[$i]['Album']['smart_query'])) {
                     list($conditions, $order, $limit) = $this->smartConditions(unserialize($result[$i]['Album']['smart_query']), null);
                     if (!is_null($conditions)) {
                         $conditions .= " AND (is_video = 0 OR lg_preview_id > 0)";
                         $members = $this->Image->find('all', array('conditions' => $conditions, 'limit' => 1, 'order' => $order, 'recursive' => -1));
                         foreach ($members as $image) {
                             if ($image['Image']['is_video']) {
                                 if (!empty($image['Image']['lg_preview'])) {
                                     list($src, $x, $y) = explode(':', $image['Image']['lg_preview']);
                                     $result[$i]['Album']['aTn'] = "{$src}:{$image['Image']['aid']}:{$x}:{$y}";
                                     $result[$i]['Album']['preview_sub'] = $image['Image']['lg_preview_id'];
                                     break;
                                 }
                             } else {
                                 $first = $image;
                                 break;
                             }
                         }
                     }
                 }
             } else {
                 $first = $this->Image->find('first', array('conditions' => array('aid' => $result[$i]['Album']['id'], 'is_video' => 0), 'order' => 'seq ASC, active DESC', 'recursive' => -1));
             }
             if (!empty($first)) {
                 $anchor = unserialize($first['Image']['anchor']);
                 if (empty($anchor)) {
                     $x = $y = 50;
                 } else {
                     $x = $anchor['x'];
                     $y = $anchor['y'];
                 }
                 $result[$i]['Album']['aTn'] = $first['Image']['src'] . ':' . $first['Image']['aid'] . ':' . $x . ':' . $y;
                 $result[$i]['Album']['preview_sub'] = $first['Image']['id'];
             }
         }
     }
     return $result;
 }
Esempio n. 17
0
 function __construct()
 {
     if (Configure::read('Moonlight.use_html')) {
         foreach ($this->tags as $tag => $html) {
             //				$this->tags[$tag] = preg_replace('#\s*\%s/>#','>',$html);
             $this->tags[$tag] = r('/>', '>', $html);
         }
     }
 }
Esempio n. 18
0
 /**
  * @param Twig_Environment $env
  * @param array $context
  * @return string
  */
 function refFunction(Twig_Environment $env, array $context)
 {
     if (!$env->isDebug()) {
         return '';
     }
     ob_start();
     r(2 === func_num_args() ? $context : array_slice(func_get_args(), 2));
     return ob_get_clean();
 }
Esempio n. 19
0
 function loginAction()
 {
     $op = $this->getInputParameter('op');
     if ($op) {
         $uname = r('username');
         $pwd = r('password');
         Ofh_Ps_User::checkUserLogin($uname, $pwd);
     }
 }
Esempio n. 20
0
 /**
  * This is the constructor for our AppHelper class that we use to make all helper output html 4.01
  * compatible markup.
  *
  * @return AppHelper
  */
 function __construct()
 {
     // Loop through all tags in this helper
     // Replace all xhtml style tag closings with html 4.01 strict compatible ones
     if (defined('MOONLIGHT_USE_HTML') && MOONLIGHT_USE_HTML) {
         foreach ($this->tags as $tag => $html) {
             $this->tags[$tag] = r('/>', '>', $html);
         }
     }
 }
Esempio n. 21
0
function main()
{
    $arr = build();
    r(isset($arr["A"]));
    r(isset($arr["AX"]));
    r(isset($arr["B"]["A"]));
    r(isset($arr["X"]["A"]));
    r(isset($arr["B"]["X"]));
    r(isset($arr["X"]["X"]));
    r(isset($arr["X"]["X"]["X"]));
}
Esempio n. 22
0
 function afterFind($results)
 {
     if (isset($results[0]['Image']['tags'])) {
         for ($i = 0; $i < count($results); $i++) {
             if (!empty($results[$i]['Image']['tags'])) {
                 $results[$i]['Image']['tags'] = trim(r(',', ' ', $results[$i]['Image']['tags']));
             }
         }
     }
     return $results;
 }
Esempio n. 23
0
 function __main()
 {
     echo '测试sa ';
     echo '<br/>';
     // echo '<hr/>';
     // $path =\gi\core\Router::getUriPath();
     echo 'r<hr/>';
     var_dump('r?:' . r('act', $res, 0));
     var_dump('res:' . $res);
     var_dump(c('db_name'));
 }
Esempio n. 24
0
 /**
  * undocumented function
  *
  * @param string $txt 
  * @param string $smileys 
  * @return void
  * @access public
  */
 function parse($txt, $smileys)
 {
     if (empty($smileys) || empty($txt)) {
         return $txt;
     }
     foreach ($smileys as $code => $img) {
         $img = '<img src="/files/plugins/smileys/' . $img . '" />';
         $txt = r($code, $img, $txt);
     }
     return $txt;
 }
Esempio n. 25
0
 /**
  * undocumented function
  *
  * @return void
  * @access public
  */
 function beforeSave()
 {
     $this->themes = isset($this->data[__CLASS__]['themes']) ? $this->data[__CLASS__]['themes'] : false;
     $monetaryFields = array('cost', 'targeted_income');
     foreach ($monetaryFields as $field) {
         if (isset($this->data[__CLASS__][$field])) {
             $this->data[__CLASS__][$field] = (double) r(',', '.', $this->data[__CLASS__][$field]);
         }
     }
     return true;
 }
Esempio n. 26
0
 function _date($format, $date, $tz = true)
 {
     setlocale(LC_TIME, explode(',', __('[#Set the locale to use for date translations. (http://php.net/setlocale) You can specify as many locales as you like and Director will use the first available from your list. Example: es_MX,es_ES,es_AR#]en_US', true)));
     if (strpos($date, '-') !== false) {
         $date = strtotime($date);
     }
     if ($tz) {
         @($offset = $_COOKIE['dir_time_zone']);
         $date = $date + $offset;
     }
     return r('  ', ' ', strftime($format, $date));
 }
Esempio n. 27
0
function myClearCache($pattern)
{
    App::import('Core', 'Folder');
    $folder = new Folder(CACHE . 'views');
    $files = $folder->find('.*' . $pattern . '.*');
    if (!empty($files)) {
        foreach ($files as $file) {
            $file = r('.php', '', $file);
            clearCache($file);
        }
    }
}
Esempio n. 28
0
 /**
  * undocumented function
  *
  * todo: encryption
  *
  * @return void
  * @access public
  */
 function main()
 {
     $this->out('Calculating reports ..');
     $reports = $this->Report->find('all');
     if (empty($reports)) {
         $this->out('Found 0 reports. Exiting.');
         exit(1);
     }
     $Pgp = Common::getComponent('Pgp');
     foreach ($reports as $report) {
         $this->out('Processing report "' . $report['Report']['title'] . '" ..');
         $conditions = array('ReportsUser.report_id' => $report['Report']['id']);
         $frequency = $report['Report']['frequency'];
         switch ($frequency) {
             case 'daily':
                 $date = date('Y-m-d H:i', strtotime('-1 day'));
                 break;
             case 'weekly':
                 $date = date('Y-m-d H:i', strtotime('-1 week'));
                 break;
             case 'yearly':
                 $date = date('Y-m-d H:i', strtotime('-1 year'));
                 break;
         }
         // $conditions[] = "DATE_FORMAT(ReportsUser.last_sent, '%Y-%m-%d %H:%i') = '" . $date . "'";
         $users = $this->ReportsUser->find('all', array('conditions' => $conditions, 'contain' => array('User'), 'order' => array('ReportsUser.created' => 'asc')));
         $this->out('Found ' . count($users) . ' user(s) that need a report');
         if (empty($users)) {
             continue;
         }
         $name = ucfirst($report['Report']['frequency']) . ' Report "' . $report['Report']['title'] . '"';
         foreach ($users as $user) {
             $officeId = $user['User']['office_id'];
             $query = $report['Report']['query'];
             $query = r('%condition', 'AND Gift.office_id = "' . $officeId . '"', $query);
             $results = $this->Transaction->query($query);
             $content = $this->parseTemplate($report['Report']['view'], $results);
             $attachment = $Pgp->encrypt(array('msg' => $content, 'recipient' => $user['User']['login']));
             if (!$attachment) {
                 $this->out('There was a problem encrypting the report for ' . $user['User']['login']);
             }
             $this->ReportsUser->set(array('id' => $user['ReportsUser']['id'], 'last_sent' => date('Y-m-d H:i:s')));
             $this->ReportsUser->save();
             if (!Common::isDevelopment()) {
                 $options = array('mail' => array('to' => $user['User']['login'], 'subject' => $name, 'attachments' => array($attachment)), 'vars' => compact('content'));
                 Mailer::deliver('report', $options);
                 $this->out('Sent ' . $name . ' to ' . $user['User']['login']);
             }
             $Pgp->flush();
         }
     }
 }
Esempio n. 29
0
 private function pickTextFile($lang)
 {
     $file = $this->getFile($lang);
     if (File::exists($file)) {
         include $file;
         $page = (string) r();
         $texts = $texts[$page];
         $general_texts = $general;
         $current_texts = array_merge($texts, $general_texts);
         return $current_texts;
     }
     return false;
 }
 public function actionGridChange($id)
 {
     /** @var BackendModel $model */
     $model = $this->owner->findModel($id);
     $model->load(r()->post());
     $return = [];
     if ($model->save()) {
         $return = ['result' => 1, 'message' => t('Data saved')];
     } else {
         throw new Exception(500, t('Data not saved'));
     }
     return Json::encode($return);
 }