Esempio n. 1
0
 private function fetchFunctionDescription($func)
 {
     $HTTP = new HTTP('php.net');
     $html = $HTTP->GET('/' . $this->getConfig('language') . '/' . $func);
     if ($html === false) {
         $this->reply('Timeout on contacting ' . $host);
         return;
     }
     if (preg_match('/<span class=\\"refname\\">(.*?)<\\/span> &mdash; <span class=\\"dc\\-title\\">(.*?)<\\/span>/si', $html, $match)) {
         $match[2] = str_replace(array("\n", "\r"), ' ', strip_tags($match[2]));
         preg_match('/<div class=\\"methodsynopsis dc\\-description\\">(.*?)<\\/div>/si', $html, $descmatch);
         $decl = isset($descmatch[1]) ? strip_tags($descmatch[1]) : $match[1];
         $decl = html_entity_decode(str_replace(array("\n", "\r"), ' ', $decl));
         while (strstr($decl, '  ')) {
             $decl = str_replace('  ', ' ', $decl);
         }
         $decl = str_replace($func, "" . $func . "", $decl);
         $output = $decl . ' - ' . html_entity_decode($match[2]) . ' ( http://php.net/' . $func . ' )';
         $this->reply(libString::isUTF8($output) ? $output : utf8_encode($output));
     } else {
         // if several possibilities
         $output = '';
         if (preg_match_all('/<a href=\\"\\/manual\\/[a-z]+\\/(?:.*?)\\.php\\">(?:<b>)?(.*?)(?:<\\/b>)?<\\/a><br/i', $html, $matches, PREG_SET_ORDER)) {
             if ($this->redirects++ < 2) {
                 $this->fetchFunctionDescription($matches[0][1]);
             } else {
                 $this->reply($this->notfoundtext . ' http://php.net/search.php?show=wholesite&pattern=' . $this->data['text']);
             }
             return;
         } else {
             $output = $this->notfoundtext . ' http://php.net/search.php?show=wholesite&pattern=' . $func;
         }
         $this->reply(libString::isUTF8($output) ? $output : utf8_encode($output));
     }
 }
Esempio n. 2
0
 private function getInfo()
 {
     $info = array();
     if (isset($this->splittedMessage['params'][1])) {
         $info['text'] = $this->splittedMessage['params'][1];
         if (!libString::isUTF8($info['text'])) {
             $info['text'] = utf8_encode($info['text']);
         }
         $info['text'] = trim($info['text']);
     }
     if (strtolower($this->splittedMessage['params'][0]) == strtolower($this->nick)) {
         $info['isQuery'] = true;
         $info['target'] = $this->splittedMessage['nick'];
     } else {
         $info['isQuery'] = false;
         $info['target'] = $this->splittedMessage['params'][0];
         $info['channel'] = $info['target'];
     }
     $info['prefix'] = $this->splittedMessage['prefix'];
     $info['host'] = $this->splittedMessage['host'];
     $info['nick'] = $this->splittedMessage['nick'];
     $info['user'] = $this->splittedMessage['user'];
     $info['nick'] = $this->splittedMessage['nick'];
     return $info;
 }
Esempio n. 3
0
 function sendMail($to, $subject, $template, $vars, $attachment = null)
 {
     require_once $this->CONFIG['phpmailer_path'];
     if (!file_exists('mail_templates/' . $template . '_plain.tpl') || !file_exists('mail_templates/' . $template . '_html.tpl')) {
         return false;
     }
     $smarty = $this->spawnSmarty();
     $smarty->template_dir = 'mail_templates';
     $smarty->compile_dir = 'smarty/templates_c/mail_templates';
     $smarty->cache_dir = 'smarty/cache/mail_templates';
     if (!is_dir('smarty/templates_c/mail_templates')) {
         mkdir('smarty/templates_c/mail_templates');
     }
     if (!is_dir('smarty/cache/mail_templates')) {
         mkdir('smarty/cache/mail_templates');
     }
     $check = false;
     foreach ($vars as $key => $value) {
         $smarty->assign($key, $value);
         if ($key == 'alt_content') {
             $check = true;
         }
     }
     if (!$check) {
         $vars['alt_content'] = strip_tags($vars['content']);
     }
     $smarty->assign('alt_content', $vars['alt_content']);
     $mail = new PHPMailer();
     $mail->CharSet = 'utf-8';
     $mail->From = $this->CONFIG['mail_from'];
     $mail->FromName = $this->CONFIG['mail_from_name'];
     $mail->AddAddress($to);
     if (isset($vars['reply-to'])) {
         list($reply_to) = explode("\n", $vars['reply-to']);
         $mail->AddReplyTo($reply_to);
     }
     if (isset($vars['bcc'])) {
         if (is_array($vars['bcc'])) {
             foreach ($vars['bcc'] as $bcc) {
                 $mail->AddBCC($bcc);
             }
         } else {
             list($bcc) = explode("\n", $vars['bcc']);
             $mail->AddBCC($bcc);
         }
     }
     $mail->isHTML(true);
     $mail->Subject = !libString::isUTF8($subject) ? utf8_encode($subject) : $subject;
     if (isset($attachment)) {
         $mail->addAttachment($attachment);
     }
     $body = $smarty->fetch($template . '_html.tpl');
     $alt_body = $smarty->fetch($template . '_plain.tpl');
     $mail->Body = !libString::isUTF8($body) ? utf8_encode($body) : $body;
     $mail->AltBody = !libString::isUTF8($alt_body) ? utf8_encode($alt_body) : $alt_body;
     if (!$mail->Send()) {
         return false;
     }
     return true;
 }