Ejemplo n.º 1
0
 /**
  * หน้าส่งอีเมล์
  * สมาชิกส่งจดหมายถึงสมาชิก และ แอดมิน
  *
  * @param Request $request
  * @return object
  */
 public function render(Request $request)
 {
     // สมาชิก
     if ($login = Login::isMember()) {
         // ค่าที่ส่งมา
         $to = strtolower($request->get('to')->filter('0-9a-zA-Z'));
         if (preg_match('/^[0-9]+$/', $to)) {
             $reciever = \Index\Sendmail\Model::getUser($to);
             $to = '';
             foreach ($reciever as $id => $item) {
                 $to_msg = empty($item['name']) ? $item['email'] : $item['name'];
                 $to = $id;
             }
         } elseif ($to == 'admin') {
             $to_msg = self::$cfg->member_status[1];
         } else {
             $to = '';
         }
         if ($to != '') {
             // antispam
             $antispam = new Antispam();
             // ข้อมูลส่งกลับ
             $index = (object) array('topic' => Language::replace('Send a message to the :name', array(':name' => $to_msg)), 'keywords' => self::$cfg->web_title, 'description' => self::$cfg->web_description, 'module' => 'sendmail');
             $template = Template::create('member', 'member', 'sendmail');
             $template->add(array('/{TOPIC}/' => $index->topic, '/{ANTISPAM}/' => $antispam->getId(), '/{ANTISPAMVAL}/' => Login::isAdmin() ? $antispam->getValue() : '', '/{RECIEVER}/' => $to_msg, '/{SENDER}/' => $login['email'], '/{RECIEVERID}/' => $to));
             $index->detail = $template->render();
             // breadcrumbs
             $index->canonical = WEB_URL . 'index.php?module=sendmail&to=' . $to;
             Gcms::$view->addBreadcrumb($index->canonical, $index->topic);
             return $index;
         }
     }
     // ไม่สามารถส่งอีเมล์ได้
     $message = Language::get('Unable to send e-mail, Because you can not send e-mail to yourself or can not find the email address of the recipient.');
     return createClass('Index\\PageNotFound\\Controller')->init($request, 'member', $message);
 }
Ejemplo n.º 2
0
 /**
  * ฟังก์ชั่นตรวจสอบความถูกต้องของ Anti Spam
  */
 public function antispam()
 {
     // referer, session
     if (self::$request->initSession() && self::$request->isReferer()) {
         $antispam = new Antispam(self::$request->post('id')->toString());
         if (!$antispam->valid(self::$request->post('value')->toString())) {
             echo Language::replace('Incorrect :name', array(':name' => Language::get('Antispam')));
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * Generated from @assert ('You want to :action', array(':action' => 'delete')) [==] 'You want to delete'.
  *
  * @covers Kotchasan\Language::replace
  */
 public function testReplace()
 {
     $this->assertEquals('You want to delete', \Kotchasan\Language::replace('You want to :action', array(':action' => 'delete')));
 }
Ejemplo n.º 4
0
 /**
  * ฟังก์ชั่น HTML highlighter
  * ทำ highlight ข้อความส่วนที่เป็นโค้ด
  * จัดการแปลง BBCode
  * แปลงข้อความ http เป็นลิงค์
  *
  * @param string $detail ข้อความ
  * @param boolean $canview true จะแสดงข้อความเตือน 'ยังไม่ได้เข้าระบบ' หากไม่ได้เข้าระบบ สำหรับส่วนที่อยู่ในกรอบ code
  * @return string คืนค่าข้อความ
  */
 public static function highlighter($detail, $canview)
 {
     $patt[] = '/\\[(\\/)?(i|dfn|b|strong|u|em|ins|del|sub|sup|small|big|ul|ol|li)\\]/isu';
     $replace[] = '<\\1\\2>';
     $patt[] = '/\\[color=([#a-z0-9]+)\\]/isu';
     $replace[] = '<span style="color:\\1">';
     $patt[] = '/\\[size=([0-9]+)(px|pt|em|\\%)\\]/isu';
     $replace[] = '<span style="font-size:\\1\\2">';
     $patt[] = '/\\[\\/(color|size)\\]/isu';
     $replace[] = '</span>';
     $patt[] = '/\\[img\\](.*)\\[\\/img\\]/U';
     $replace[] = '<figure><img src="\\1" alt=""></figure>';
     $patt[] = '/\\[url\\](.*)\\[\\/url\\]/U';
     $replace[] = '<a href="\\1" target="_blank" rel="nofollow">\\1</a>';
     $patt[] = '/\\[url=(ftp|http)(s)?:\\/\\/(.*)\\](.*)\\[\\/url\\]/U';
     $replace[] = '<a href="\\1\\2://\\3" target="_blank" rel="nofollow">\\4</a>';
     $patt[] = '/\\[url=(\\/)?(.*)\\](.*)\\[\\/url\\]/U';
     $replace[] = '<a href="' . WEB_URL . '\\2" target="_blank" rel="nofollow">\\3</a>';
     $patt[] = '/(\\[code=([a-z]{1,})\\](.*?)\\[\\/code\\])/uis';
     $replace[] = $canview ? '<code class="content-code \\2">\\3[/code]' : '<code class="content-code">' . Language::get('Can not view this content') . '[/code]';
     $patt[] = '/(\\[code\\](.*?)\\[\\/code\\])/uis';
     $replace[] = $canview ? '<code class="content-code">\\2[/code]' : '<code class="content-code">' . Language::get('Can not view this content') . '[/code]';
     $patt[] = '/(&lt;\\?(.*?)\\?&gt;)/uism';
     $replace[] = '<span class=php>\\1</span>';
     $patt[] = '/(&lt;%(.*?)%&gt;)/uism';
     $replace[] = '<span class=asp>\\1</span>';
     $patt[] = '/(&lt;(script|style)(&gt;|\\s(.*?)&gt;)(.*?)&lt;\\/\\2&gt;)/uis';
     $replace[] = '<span class=\\2>\\1</span>';
     $patt[] = '/(&lt;[\\/]?([a-z]+)(.*?)&gt;)/isu';
     $replace[] = '<span class=html>\\1</span>';
     $patt[] = '/(\\/\\*(.*?)\\*\\/)/uis';
     $replace[] = '<span class=comment>\\1</span>';
     $patt[] = '#(^|[^:])(//)([^<\\r\\n\\]]+)#sum';
     $replace[] = '\\1<span class=comment>\\2\\3</span>';
     $patt[] = '/(&lt;!--(.*?)--&gt;)/uis';
     $replace[] = '<span class=comment>\\1</span>';
     $patt[] = '/\\[\\/code\\]/usi';
     $replace[] = '</code>';
     $patt[] = '/\\[\\/quote\\]/usi';
     $replace[] = '</blockquote>';
     $patt[] = '/\\[quote( q=[0-9]+)?\\]/usi';
     $replace[] = '<blockquote><b>' . Language::replace('Quotations by :name', array(':name' => Language::get('Topic'))) . '</b>';
     $patt[] = '/\\[quote r=([0-9]+)\\]/usi';
     $replace[] = '<blockquote><b>' . Language::replace('Quotations by :name', array(':name' => Language::get('Comment'))) . ' <em>#\\1</em></b>';
     $patt[] = '/\\[google\\](.*?)\\[\\/google\\]/usi';
     $replace[] = '<a class="googlesearch" href="http://www.google.co.th/search?q=\\1&amp;&meta=lr%3Dlang_th" target="_blank" rel="nofollow">\\1</a>';
     $patt[] = '/([^["]]|\\r|\\n|\\s|\\t|^)(https?:\\/\\/([^\\s<>\\"\']+))/';
     $replace[] = '\\1<a href="\\2" target="_blank" rel="nofollow">\\2</a>';
     $patt[] = '/\\[youtube\\]([a-z0-9-_]+)\\[\\/youtube\\]/i';
     $replace[] = '<div class="youtube"><iframe src="//www.youtube.com/embed/\\1?wmode=transparent"></iframe></div>';
     return preg_replace($patt, $replace, $detail);
 }