Esempio n. 1
0
function _utf8($a, $e = false)
{
    if (is_array($a)) {
        foreach ($a as $k => $v) {
            $a[$k] = _utf8($v, $e);
        }
    } else {
        if ($e !== false) {
            $a = utf8_encode($a);
        } else {
            $a = utf8_decode($a);
        }
    }
    return $a;
}
Esempio n. 2
0
 function send()
 {
     global $core, $user;
     // Escape all quotes, else the eval will fail.
     $this->msg = str_replace("'", "\\'", $this->msg);
     $this->msg = preg_replace('#\\{([a-z0-9\\-_]*?)\\}#is', "' . \$\\1 . '", $this->msg);
     // Set vars
     reset($this->vars);
     while (list($key, $val) = each($this->vars)) {
         ${$key} = $val;
     }
     eval("\$this->msg = '{$this->msg}';");
     // Clear vars
     foreach ($this->vars as $key => $val) {
         unset(${$key});
     }
     // We now try and pull a subject from the email body ... if it exists,
     // do this here because the subject may contain a variable
     $drop_header = '';
     $match = array();
     if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match)) {
         $this->subject = trim($match[2]) != '' ? trim($match[2]) : ($this->subject != '' ? $this->subject : 'No Subject');
         $drop_header .= '[\\r\\n]*?' . preg_quote($match[1], '#');
     } else {
         $this->subject = $this->subject != '' ? $this->subject : 'No Subject';
     }
     if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match)) {
         $this->encoding = trim($match[2]) != '' ? trim($match[2]) : _lang('ENCODING');
         $drop_header .= '[\\r\\n]*?' . preg_quote($match[1], '#');
     } else {
         $this->encoding = _lang('ENCODING');
     }
     if ($drop_header != '') {
         $this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
     }
     $to = $this->addresses['to'];
     $cc = isset($this->addresses['cc']) && count($this->addresses['cc']) ? implode(', ', $this->addresses['cc']) : '';
     $bcc = isset($this->addresses['bcc']) && count($this->addresses['bcc']) ? implode(', ', $this->addresses['bcc']) : '';
     // Build header
     $this->extra_headers = ($this->reply_to != '' ? "Reply-to: {$this->reply_to}\n" : '') . ($this->from != '' ? "From: {$this->from}\n" : "From: " . $core->v('default_email') . "\n") . "Return-Path: " . $core->v('default_email') . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . get_host() . ">\nMIME-Version: 1.0\nContent-type: text/" . $this->eformat . "; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 2\nX-MSMail-Priority: High\n" . $this->extra_headers . ($cc != '' ? "Cc: {$cc}\n" : '') . ($bcc != '' ? "Bcc: {$bcc}\n" : '');
     // Send message ... removed $this->encode() from subject for time being
     $empty_to_header = $to == '' ? true : false;
     $to = $to == '' ? 'Undisclosed-recipients:;' : $to;
     if ($this->htmle) {
         $this->msg = entity_decode($this->msg);
     }
     if ($core->v('mail_use_smtp')) {
         require_once XFS . 'core/class.phpmailer.php';
         $mail = new PHPMailer(true);
         $mail->IsSMTP();
         try {
             $mail->SMTPDebug = 0;
             $mail->Host = 'ssl://smtp.gmail.com:465';
             $mail->Port = 465;
             $mail->Username = $core->v('mail_ticket_login');
             $mail->Password = $core->v('mail_ticket_key');
             $mail->SMTPAuth = TRUE;
             $mail->AddAddress($to);
             if ($this->reply_to != '') {
                 $mail->AddReplyTo($this->reply_to);
             }
             if (isset($this->addresses['cc']) && count($this->addresses['cc'])) {
                 foreach ($this->addresses['cc'] as $row) {
                     $mail->AddCC($row);
                 }
             }
             if (isset($this->addresses['bcc']) && count($this->addresses['bcc'])) {
                 foreach ($this->addresses['bcc'] as $row) {
                     $mail->AddBCC($row);
                 }
             }
             $mail->SetFrom($this->from);
             $mail->Subject = _utf8($this->subject);
             $this->msg = _utf8($this->msg);
             $mail->MsgHTML(str_replace("\n", '<br />', $this->msg));
             $mail->AltBody = $this->msg;
             $mail->Send();
             return true;
         } catch (phpmailerException $e) {
             echo $e->errorMessage();
             //Pretty error messages from PHPMailer
         } catch (Exception $e) {
             echo $e->getMessage();
             //Boring error messages from anything else!
         }
         return;
     }
     $result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers, "-f{$core->v('default_email')}");
     // Did it work?
     if (!$result) {
         trigger_error('Failed sending email :: PHP :: ' . $result);
     }
     return true;
 }
Esempio n. 3
0
function _fatal($code = 404, $errfile = '', $errline = '', $errmsg = '', $errno = 0)
{
    global $core, $file, $warning;
    sql_close();
    // TODO: Check if is ghost request.
    $warning = '<b>%s</b>: in file <b>%s</b> on line <b>%s</b>: <b>%s</b><br>';
    switch ($code) {
        case 504:
        case 505:
            echo sprintf($warning, 'PHP Notice', $errfile, $errline, $errmsg);
            break;
        case 506:
            exit('USER_ERROR: ' . $errmsg);
            break;
        default:
            $error_path = XFS . XHTM . _tbrowser() . '/warnings/%s.htm';
            $sql_message = 'SQL ERROR @ %s # %s<br /><br />' . "\n" . ' %s<br /><br />' . "\n";
            if ($errno) {
                $code .= '-' . $errno;
            }
            $filepath = sprintf($error_path, $code . (is_ghost() ? '-ghost' : ''));
            if (!@file_exists($filepath)) {
                $filepath = sprintf($error_path, 'default');
            }
            $v_host = get_protocol() . get_host();
            // SQL error
            if ($code == 507) {
                $sql_time = date('r');
                $sql_format = str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;&nbsp;'), $errmsg['sql']);
                $sql_message = sprintf($sql_message, get_host(), $sql_time, _page());
                if (!empty($errmsg['message'])) {
                    $sql_message .= $errmsg['message'] . '<br /><br />' . "\n";
                }
                $sql_message .= $sql_format;
                $errmsg = '';
                if (!is_remote()) {
                    $errmsg = '<br /><br />' . $sql_message;
                }
                $sql_message = _utf8($sql_message);
                if (!($report_to = $file->read(XFS . XCOR . 'store/server_admin'))) {
                    $report_to = array(v_server('SERVER_ADMIN'));
                }
                // Send report to server admins @ XFS.XCOR . store/server_admin
                if (count($report_to)) {
                    /*
                    $core->email->init($report_to[0]);
                    $core->email->subject('PHP/SQL error @ ' . get_host());
                    $core->email->message($sql_message);
                    $core->email->send($report_to);
                    */
                    echo $sql_message;
                    exit;
                }
            }
            $v_self = v_server('PHP_SELF');
            $replace = array('{ERROR_LINE}' => $errline, '{ERROR_FILE}' => $errfile, '{ERROR_MSG}' => $errmsg, '{HTTP_HOST}' => $v_host . str_replace(basename($v_self), '', $v_self), '{REQUEST_URL}' => v_server('REQUEST_URI'), '{REQUEST_METHOD}' => v_server('REQUEST_METHOD'));
            $header_code = array('0' => '404 Not Found', '507' => '501 Internal Error', '405' => '405 Method Not Allowed');
            if (!isset($header_code[$code])) {
                $code = 0;
            }
            header('HTTP/1.1 ' . $header_code[$code]);
            echo str_replace(array_keys($replace), array_values($replace), implode('', @file($filepath)));
            exit;
            break;
    }
    return false;
}
Esempio n. 4
0
function _fatal($code = 404, $errfile = '', $errline = '', $errmsg = '', $errno = 0)
{
    sql_close();
    switch ($code) {
        case 504:
            echo '<b>PHP Notice</b>: in file <b>' . $errfile . '</b> on line <b>' . $errline . '</b>: <b>' . $errmsg . '</b><br>';
            break;
        case 505:
            echo '<b>Another Error</b>: in file <b>' . basename($errfile) . '</b> on line <b>' . $errline . '</b>: <b>' . $errmsg . '</b><br>';
            break;
        case 506:
            exit('USER_ERROR: ' . $errmsg);
            break;
        default:
            $error_path = './style/http-error/%s.htm';
            switch ($errno) {
                case 2:
                    $filepath = sprintf($error_path, 'no' . $errno);
                    break;
                default:
                    $filepath = sprintf($error_path, $code . (is_ghost() ? '-ghost' : ''));
                    break;
            }
            if (!@file_exists($filepath)) {
                $filepath = sprintf($error_path, 'default');
            }
            $v_host = get_protocol() . get_host();
            // SQL error
            if ($code == 507) {
                if (!($report_to = get_file('./base/server_admin'))) {
                    $report_to = array(v_server('SERVER_ADMIN'));
                }
                $sql_time = @date('r');
                $sql_format = str_replace(array("\n", "\t"), array('<br />', '&nbsp;&nbsp;&nbsp;'), $errmsg['sql']);
                $sql_message = 'SQL ERROR @ ' . get_host() . ' # ' . $sql_time . '<br /><br />' . "\n";
                $sql_message .= _page() . '<br /><br />' . "\n";
                if (f($errmsg['message'])) {
                    $sql_message .= $errmsg['message'] . '<br /><br />' . "\n";
                }
                $sql_message .= $sql_format;
                $errmsg = '';
                if (!is_remote()) {
                    $errmsg = '<br><br>' . $sql_message;
                }
                $sql_message = _utf8($sql_message);
                // Send report to server admins
                // Email addresses can be configured @ ./base/server_admin
                if (count($report_to)) {
                    require_once XFS . 'core/class.phpmailer.php';
                    $mail = new PHPMailer();
                    $mail->SetFrom($report_to[0]);
                    foreach ($report_to as $i => $row) {
                        $ff = !$i ? 'Address' : 'CC';
                        $mail->{'Add' . $ff}($row);
                    }
                    $mail->Subject = 'PHP/SQL error @ ' . get_host();
                    $mail->MsgHTML($sql_message);
                    $mail->AltBody = $sql_message;
                    $mail->Send();
                }
            }
            $v_self = v_server('PHP_SELF');
            $replace = array('{ERROR_LINE}' => $errline, '{ERROR_FILE}' => $errfile, '{ERROR_MSG}' => $errmsg, '{HTTP_HOST}' => $v_host . str_replace(basename($v_self), '', $v_self), '{REQUEST_URL}' => v_server('REQUEST_URI'), '{REQUEST_METHOD}' => v_server('REQUEST_METHOD'));
            $header_code = array('0' => '404 Not Found', '507' => '501 Internal Error', '405' => '405 Method Not Allowed');
            if (!isset($header_code[$code])) {
                $code = 0;
            }
            header('HTTP/1.1 ' . $header_code[$code]);
            echo str_replace(array_keys($replace), array_values($replace), implode('', @file($filepath)));
            exit;
            break;
    }
    return false;
}
Esempio n. 5
0
	#=======================================================
  	#$query =  "SELECT sum(G.PA) as count, P.Troll FROM `MZ_Glandouille` as G INNER JOIN `MZ_Profil` as P ON (P.TiD=G.TiD) WHERE (G.TimeStamp>'$OutOfDate')group By G.TiD order by count desc";
	$nData = @MySQL_NUM_ROWS($result13);
	if ($nData>0) {  
	   	$fame=mysql_result($result13,0,"Troll");
	   	$count=mysql_result($result13,0,"count");
	 	fputs($fd, _utf8("<TR valign=top><TD></TD><TD>Le plus gros glandouilleur:&nbsp;</TD><TD><B>$fame</B> <I>(avec <B>$count</B> PA dépensés)</I></TD></TR>"));
	 	for ($i=1; $i<$nData; $i++) { #gestion des égalités
		   	$counti=mysql_result($result13,$i,"count");
		   	if ($count==$counti) {
			   	$fame=mysql_result($result13,$i,"Troll");
			 	fputs($fd, _utf8("<TR><TD></TD><TD></TD><TD><B>$fame</B> <I>(ex-aequo)</I></TD></TR>"));
		   	} else { $i=$nData ; } # on sort
	 	}
	}
	fputs($fd, _utf8("</TABLE>"));
	fclose($fd);
  }
  # Affichage du fichier de STATistiques
  $fd=fopen("$STATfile", "r");
  while (!feof($fd)) echo fgets($fd);
  fclose($fd);
	
#***** Les data perso
	if (!empty($_SESSION['login'])) { #Recupération de l'ID de Session
	//if (isset($TiD)) {
		$TiD=$_SESSION['login'] ;
	    $mysql=_sqlconnect();	# -------------- Ouverture DB  

	  	$query =  "SELECT Troll FROM `MZ_Profil` WHERE (TiD=$TiD)";
		$result1 = @MySQL_QUERY($query);
Esempio n. 6
0
    protected function _ticket_home()
    {
        global $user, $core;
        if (!$core->v('cron_enabled')) {
            return $this->e('CRON_DISABLED');
        }
        foreach (w('mail pop3 emailer htmlparser') as $row) {
            require_once XFS . 'core/' . $row . '.php';
        }
        $pop3 = new pop3();
        if (!$pop3->connect($core->v('mail_server'), $core->v('mail_port'))) {
            return $this->e('MAIL_NO_CONNECT');
        }
        if (!($total_mail = $pop3->login('recent:' . $core->v('mail_ticket_login'), $core->v('mail_ticket_key')))) {
            return $this->e('MAIL_NEW_MAIL');
        }
        //
        $mail = new _mail();
        $emailer = new emailer();
        //
        if (!($blacklist = $core->cache_load('ticket_blacklist'))) {
            $sql = 'SELECT *
				FROM _tickets_blacklist
				ORDER BY list_id';
            $blacklist = $core->cache_store(_rowset($sql, 'list_address', 'list_id'));
        }
        if (!($ticket_status = $core->cache_load('ticket_status_default'))) {
            $sql = 'SELECT status_id
				FROM _tickets_status
				WHERE status_default = 1';
            $ticket_status = $core->cache_store(_field($sql, 'status_id', 0));
        }
        $sql = 'SELECT group_id, group_email
			FROM _groups
			ORDER BY group_email';
        $groups = _rowset($sql, 'group_email', 'group_id');
        $sql = 'SELECT group_email, group_name
			FROM _groups
			ORDER BY group_email';
        $groups_name = _rowset($sql, 'group_email', 'group_name');
        $sql = 'SELECT gg.group_email, m.user_email
			FROM _groups gg, _groups_members g, _members m
			WHERE g.member_mod = ?
				AND g.member_uid = m.user_id
				AND gg.group_id = g.member_group
			ORDER BY m.user_email';
        $groups_mods = _rowset(sql_filter($sql, 1), 'group_email', 'user_email', true);
        foreach ($groups as $a_group_email => $a_group_id) {
            if (!isset($groups_mods[$a_group_email])) {
                $groups_mods[$a_group_email] = w();
            }
        }
        $sql = 'SELECT s.a_assoc, s.a_value
			FROM _members_fields f, _members_store s
			WHERE s.a_field = f.field_id
				AND f.field_alias LIKE ?
			ORDER BY s.a_value';
        $email_alt = _rowset(sql_filter($sql, 'email%'), 'a_value', 'a_assoc');
        // Pre mail process
        $recv = w();
        $now = time();
        $line_orig = array('&nbsp;');
        $line_repl = array(' ');
        $_v = w('from from_d to ticket subject body date mod ip spam blacklist reply other');
        $_c = w('normal reply other blacklist spam', 0);
        for ($i = 1; $i <= $total_mail; $i++) {
            foreach ($_v as $row) {
                ${'recv_' . $row} = 0;
            }
            $s_header = $mail->parse_header(split("\r\n", implode('', $pop3->top($i))));
            $recv_from = $mail->parse_address($s_header['from']);
            if (isset($blacklist[$recv_from])) {
                $recv_blacklist = 1;
            }
            if ($recv_from == $core->v('mail_ticket_login')) {
                $recv_blacklist = 1;
            }
            _dvar($s_header['to'], '');
            _dvar($s_header['cc'], '');
            if (f($s_header['cc'])) {
                $s_header['to'] .= (f($s_header['to']) ? ', ' : '') . $s_header['cc'];
            }
            $to_part = array_map('trim', explode(strpos($s_header['to'], ',') ? ',' : ';', $s_header['to']));
            foreach ($to_part as $row) {
                if (strpos($row, '<') !== false) {
                    $row = preg_replace('#.*?<(.*?)>#is', '\\1', $row);
                }
                if (isset($blacklist[$row])) {
                    $recv_blacklist = 1;
                } else {
                    $recv_blacklist = 0;
                    $row_first = array_key(explode('@', $row), 0);
                    if (isset($groups[$row_first])) {
                        $recv_to = $row_first;
                    }
                }
            }
            if (strstr($s_header['to'], _lang('MAIL_TO_UNKNOWN')) !== false) {
                $recv_to = array_key(explode('@', $core->v('mail_ticket_login')), 0);
            }
            if (!$recv_to) {
                $recv_blacklist = 1;
            }
            if (!$recv_blacklist) {
                $recv_subject = htmlencode(trim($s_header['subject']));
                if (preg_match('#\\[\\#(.*?)\\]#is', $recv_subject, $p_subject)) {
                    $sql = 'SELECT ticket_id
						FROM _tickets
						WHERE ticket_code = ?';
                    if ($recv_subject_d = _fieldrow(sql_filter($sql, $p_subject[1]))) {
                        $recv_ticket = $recv_subject_d['ticket_id'];
                        $recv_reply = $p_subject[1];
                        $recv_subject = substr(strrchr($recv_subject, ']'), 3);
                    }
                }
                if ($recv_to . '@' . $core->v('domain') == $recv_from && $recv_from == $core->v('mail_ticket_login') && $recv_reply) {
                    $recv_blacklist = 1;
                }
            }
            if (!$recv_blacklist) {
                if (isset($email_alt[$recv_from])) {
                    $sql_field = 'id';
                    $sql_value = $email_alt[$recv_from];
                } else {
                    $sql_field = 'username';
                    $sql_value = array_key(explode('@', $recv_from), 0);
                }
                $sql = 'SELECT user_id, user_username, user_firstname, user_lastname
					FROM _members
					WHERE user_?? = ?';
                if ($recv_from_d = _fieldrow(sql_filter($sql, $sql_field, $sql_value))) {
                    $recv_from_d = serialize(array_row($recv_from_d));
                } else {
                    $recv_other = 1;
                }
                $d_body = $mail->body($s_header, $pop3->fbody($i), true);
                $recv_date = $mail->parse_date($s_header['date']);
                $recv_ip = $mail->parse_ip($s_header['received']);
                if (isset($groups_email[$recv_to])) {
                    $recv_mod = $groups_email[$recv_to];
                }
                if ($recv_date > $now || $recv_date < $now - 86400) {
                    $recv_date = $now;
                }
                if (isset($d_body['text-plain']) && f($d_body['text-plain'])) {
                    $recv_body = trim($d_body['text-plain']);
                } elseif (isset($d_body['text-html']) && f($d_body['text-html'])) {
                    $htm_text = w();
                    $tag_open = false;
                    $parser = new HtmlParser($d_body['text-html']);
                    while ($parser->parse()) {
                        $line = trim(str_replace($line_orig, $line_repl, $parser->iNodeValue));
                        if ($tag_open || strpos($line, '<') !== false) {
                            $tag_open = !$tag_open;
                            continue;
                        }
                        if ($parser->iNodeName == 'Text' && f($line)) {
                            $htm_text[] = preg_replace("/(\r\n){1}/", ' ', $line);
                        }
                    }
                    $recv_body = implode("\n", $htm_text);
                }
                if (f($recv_body)) {
                    $recv_body = htmlencode(_utf8($recv_body));
                }
                if (!f($recv_body)) {
                    $recv_blacklist = 1;
                }
            }
            $recv[$i] = w();
            foreach ($_v as $row) {
                $recv[$i][$row] = ${'recv_' . $row};
            }
        }
        foreach ($recv as $i => $row) {
            if ($row['spam'] || $row['blacklist']) {
                $pop3->delete($i);
                $row_key = $row['spam'] ? 'spam' : 'blacklist';
                $_c[$row_key]++;
                continue;
            }
            // Send mail to group admin
            if ($row['other']) {
                $_c['other']++;
                if (count($groups_mods[$row['to']])) {
                    foreach ($groups_mods[$row['to']] as $i => $mod_email) {
                        $email_func = !$i ? 'email_address' : 'cc';
                        $emailer->{$email_func}($mod_email);
                    }
                    $emailer->from($row['from']);
                    $emailer->replyto($row['from']);
                    $emailer->set_subject(entity_decode($row['subject']));
                    $emailer->use_template('ticket_other');
                    $emailer->set_decode(true);
                    $emailer->assign_vars(array('SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body'])));
                    $emailer->send();
                    $emailer->reset();
                }
                $pop3->delete($i);
                continue;
            }
            $row['code'] = $row['reply'] ? $row['reply'] : substr(md5(unique_id()), 0, 8);
            $row['from_d'] = unserialize($row['from_d']);
            $row['group_id'] = $groups[$row['to']];
            $row['msubject'] = entity_decode(sprintf('%s [#%s]: %s', $groups_name[$row['to']], $row['code'], $row['subject']));
            $row['mbody'] = explode("\n", $row['body']);
            //
            $body_const = w();
            foreach ($row['mbody'] as $part_i => $part_row) {
                if (isset($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i - 1]) && f($row['mbody'][$part_i])) {
                    $row['mbody'][$part_i] = "\n" . $part_row;
                }
            }
            $row['body'] = implode("\n", $row['mbody']);
            $v_mail = array('USERNAME' => $row['from_d']['user_username'], 'FULLNAME' => entity_decode(_fullname($row['from_d'])), 'SUBJECT' => entity_decode($row['subject']), 'MESSAGE' => entity_decode($row['body']), 'TICKET_URL' => _link('ticket', array('x1' => 'view', 'code' => $row['code'])));
            if (!$row['reply']) {
                $_c['normal']++;
                $sql_insert = array('parent' => 0, 'cat' => 1, 'group' => $row['group_id'], 'title' => _subject($row['subject']), 'text' => _prepare($row['body']), 'code' => $row['code'], 'contact' => $row['from_d']['user_id'], 'aby' => 0, 'status' => $ticket_status, 'start' => $row['date'], 'lastreply' => $row['date'], 'end' => 0, 'ip' => $row['ip']);
                $sql = 'INSERT INTO _tickets' . _build_array('INSERT', prefix('ticket', $sql_insert));
                _sql($sql);
                // Send mail to user
                $emailer->email_address($row['from']);
                $emailer->from($row['to'] . '@' . $core->v('domain'));
                $emailer->set_subject($row['msubject']);
                $emailer->use_template('ticket_' . $row['to']);
                $emailer->set_decode(true);
                $emailer->assign_vars($v_mail);
                $emailer->send();
                $emailer->reset();
                // > Send mail to group admin
                if (count($groups_mods[$row['to']])) {
                    foreach ($groups_mods[$row['to']] as $i => $mod_email) {
                        $address_func = !$i ? 'email_address' : 'cc';
                        $emailer->{$address_func}($mod_email);
                    }
                    $emailer->from($row['to'] . '@' . $core->v('domain'));
                    $emailer->set_subject($row['msubject']);
                    $emailer->use_template('ticket_' . ($row['reply'] ? 'reply' : 'tech'));
                    $emailer->set_decode(true);
                    $emailer->assign_vars($v_mail);
                    $emailer->send();
                    $emailer->reset();
                }
            } else {
                $_c['reply']++;
                $sql_insert = array('ticket_id' => $row['ticket'], 'user_id' => $row['from_d']['user_id'], 'note_text' => htmlencode($row['body']), 'note_time' => $row['date'], 'note_cc' => 1);
                $sql = 'INSERT INTO _tickets_notes' . _build_array('INSERT', $sql_insert);
                _sql($sql);
                $sql = 'UPDATE _tickets SET ticket_lastreply = ?
					WHERE ticket_id = ?';
                _sql(sql_filter($sql, $row['date'], $row['ticket']));
                // Send mail to group members || user
                $sql = 'SELECT *
					FROM _tickets_assign a, _members m
					WHERE a.assign_ticket = ?
						AND a.user_id = m.user_id
						AND m.user_username NOT IN (?)';
                $tech = _rowset(sql_filter($sql, $row['ticket'], $row['from_d']['user_username']));
                if ($row['mod'] != $row['from_d']['user_username']) {
                    $tech[] = $row['mod'];
                }
                if (count($tech)) {
                    foreach ($tech as $tech_i => $tech_row) {
                        $m_method = !$tech_i ? 'email_address' : 'cc';
                        $emailer->{$m_method}($tech_row . '@' . $core->v('domain'));
                    }
                    $emailer->from($row['to'] . '@' . $core->v('domain'));
                    $emailer->use_template('ticket_reply');
                    $emailer->set_subject($row['msubject']);
                    $emailer->set_decode(true);
                    $emailer->assign_vars($v_mail);
                    $emailer->send();
                    $emailer->reset();
                }
            }
            // Delete mail from server
            $pop3->delete($i);
        }
        // Quit server
        $pop3->quit();
        $ret = '';
        foreach ($_c as $k => $v) {
            $ret .= "\n" . $k . ' = ' . $v . '<br />';
        }
        return $this->e($ret);
    }
Esempio n. 7
0
    public function run($mod = false)
    {
        global $bio, $core, $file, $warning;
        if (!($rewrite = enable_rewrite())) {
            $warning->now('Enable mod_rewrite on Apache.');
        }
        require_once XFS . XCOR . 'modules.php';
        if ($mod === false) {
            $mod = request_var('module', '');
        }
        $mod = !empty($mod) ? $mod : 'home';
        if (!($_module = $core->cache->load('module_' . str_replace('/', '_', $mod)))) {
            $sql = 'SELECT *
				FROM _modules
				WHERE module_alias = ?';
            if (!($_module = $core->cache->store(sql_fieldrow(sql_filter($sql, $mod))))) {
                $warning->now('no_module');
            }
        }
        $_module->module_path = XFS . XMOD . $_module->module_path . $_module->module_basename;
        if (!@file_exists($_module->module_path)) {
            $warning->now('no_path: ' . $_module->module_path);
        }
        @(require_once $_module->module_path);
        $_object = '__' . $mod;
        if (!class_exists($_object)) {
            $warning->now();
        }
        $module = new $_object();
        $module->m($mod);
        if (@method_exists($module, 'install')) {
            $module->_install();
        }
        if (!defined('ULIB')) {
            define('ULIB', _link() . str_replace(w('../ ./'), '', LIB));
        }
        if (empty($this->input)) {
            $_input = array();
            if ($arg = request_var('args', '')) {
                foreach (explode('.', $arg) as $str_pair) {
                    $pair = explode(':', $str_pair);
                    if (isset($pair[0]) && isset($pair[1]) && !empty($pair[0])) {
                        $this->input[$pair[0]] = $pair[1];
                    }
                }
            }
            if (isset($_POST) && count($_POST)) {
                $_POST = _utf8($_POST);
                $this->input = array_merge($this->input, $_POST);
            }
        }
        $module->levels($this->input);
        if (!method_exists($module, $module->x(1))) {
            $warning->now();
        }
        if ($module->auth() && (!$module->x(1) || !in_array($module->x(1), $module->exclude))) {
            $module->signin();
        }
        //
        // All verifications passed, so start session for the request
        $bio->start(true);
        $bio->setup();
        if (!$module->auth_access() && $module->auth()) {
            $warning->now();
        }
        $module->navigation('home', '', '');
        $module->navigation($module->m(), '');
        if ($module->x(1) != 'home' && @method_exists($module, 'init')) {
            $module->init();
        }
        hook(array($module, $module->x(1)));
        if (!$module->_template()) {
            $module->_template($mod);
        }
        //
        // Output template
        $page_module = 'MODULE_' . $mod;
        if ($bio->is_lang($page_module)) {
            $module->page_title($page_module);
        }
        $browser_upgrade = false;
        if (!$core->v('skip_browser_detect') && ($list_browser = $file->read(XFS . XCOR . 'store/need_browser'))) {
            $browser_list = w();
            foreach ($list_browser as $row) {
                $e = explode(' :: ', $row);
                $browser_list[$e[0]] = $e[1];
            }
            foreach ($browser_list as $browser => $version) {
                if (_browser($browser) && _browser($browser, $version)) {
                    v_style(array('visual' => ULIB . LIB_VISUAL));
                    $module->_template('browsers');
                    $browser_upgrade = true;
                }
            }
        }
        $sv = array('X1' => $module->x(1), 'X2' => $module->x(2), 'NAVIGATION' => $module->get_navigation(), 'BROWSER_UPGRADE' => $browser_upgrade);
        _layout($module->_template(), $module->page_title(), $sv);
    }
Esempio n. 8
0
function request_var($var_name, $default = false, $multibyte = false) {
	if (REQC) {
		global $config;

		if ((strpos($var_name, $config['cookie_name']) !== false) && isset($_COOKIE[$var_name])) {
			$_REQUEST[$var_name] = $_COOKIE[$var_name];
		}
	}

	// Parse $_FILES format, (files:name)
	if (preg_match('#files:([a-z0-9_]+)#i', $var_name, $var_part)) {
		if (!isset($_FILES[$var_part[1]])) {
			return false;
		}

		$_REQUEST[$var_part[1]] = $_FILES[$var_part[1]];
		$var_name = $var_part[1];
		$default = array('' => '');
	}

	if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name]))) {
		return (is_array($default)) ? w() : $default;
	}

	$var = $_REQUEST[$var_name];
	if (!is_array($default)) {
		$type = gettype($default);
		_utf8($var);
	} else {
		list($key_type, $type) = each($default);
		$type = gettype($type);
		$key_type = gettype($key_type);
	}

	if (is_array($var)) {
		$_var = $var;
		$var = w();

		foreach ($_var as $k => $v) {
			if (is_array($v)) {
				foreach ($v as $_k => $_v) {
					set_var($k, $k, $key_type);
					set_var($_k, $_k, $key_type);
					set_var($var[$k][$_k], $_v, $type, $multibyte);
				}
			} else {
				set_var($k, $k, $key_type);
				set_var($var[$k], $v, $type, $multibyte);
			}
		}
	} else {
		set_var($var, $var, $type, $multibyte);
	}

	return $var;
}
Esempio n. 9
0
function _xfs($mod = false, $wdir = false, $warg = false)
{
	global $user, $style;
	
	include_once(XFS . 'core/modules.php');
	
	if ($mod === false)
	{
		$mod = request_var('module', '');
	}
	$mod = (!empty($mod)) ? $mod : 'home';
	
	$mod_dir = './base/_' . $mod;
	$p_dir = ($wdir === false && @file_exists($mod_dir) && is_dir($mod_dir)) ? true : false;
	
	if (!$p_dir)
	{
		$mod_dir = './base/_' . (($wdir !== false) ? $wdir . '/_' : '') . $mod;
		
		$mod_path = $mod_dir . '.php';
		$mod_class = '__' . $mod;
		
		if (!@file_exists($mod_path))
		{
			_fatal();
		}
		include_once($mod_path);
		
		if (!class_exists($mod_class))
		{
			_fatal();
		}
		$module = new $mod_class();
	}
	
	if ($warg === false)
	{
		$warg = array();
		$arg = request_var('args', '');
		if (!empty($arg))
		{
			foreach (explode('.', $arg) as $v)
			{
				$el = explode(':', $v);
				if (isset($el[0]) && isset($el[1]) && !empty($el[0]))
				{
					$warg[$el[0]] = $el[1];
				}
			}
		}
		
		if (isset($_POST) && count($_POST))
		{
			$_POST = _utf8($_POST);
			$warg = array_merge($warg, $_POST);
		}
	}
	
	if ($p_dir)
	{
		_xfs(((isset($warg['x1'])) ? $warg['x1'] : ''), $mod, $warg);
	}
	else
	{
		if (isset($module->auth) && $module->auth)
		{
			$v_auth_exclude = (isset($module->auth_exclude) && (isset($warg['x1']) && in_array($warg['x1'], $module->auth_exclude))) ? true : false;
			if (!$v_auth_exclude)
			{
				_login();
			}
		}
		
		$warg_x = 0;
		foreach ($warg as $warg_k => $warg_v)
		{
			if (preg_match('/x\d+/i', $warg_k))
			{
				$warg_x = str_replace('x', '', $warg_k);
			}
		}
		
		if ($wdir !== false)
		{
			for ($i = 0; $i < $warg_x; $i++)
			{
				$warg['x' . ($i + 1)] = (isset($warg['x' + ($i + 2)])) ? $warg['x' + ($i + 2)] : '';
			}
		}
	}
	
	date_default_timezone_set('America/Guatemala');
	
	$module->arg = $warg;
	$module->xlevel();
	if (!method_exists($module, $module->level['x1']))
	{
		_fatal();
	}
	
	// Session start
	$user->start(true);
	$user->setup();
	
	if (!$module->auth_access($user->data))
	{
		_fatal();
	}
	
	if (!defined('LIB')) define('LIB', '../space/');
	
	if (!defined('LIBD')) define('LIBD', _link() . str_replace('../', '', LIB));
	
	$module->module = $mod;
	
	if (@method_exists($module, 'install'))
	{
		$module->install();
	}
	
	$module->navigation('home', '', '');
	$module->navigation($module->module, '');
	
	$module->{$module->level['x1']}();
	
	if (empty($module->template))
	{
		$module->template = $mod;
	}
	
	if (@file_exists('./base/tree'))
	{
		$menu = array_map('trim', @file('./base/tree'));
		foreach ($menu as $i => $row)
		{
			if (!$i) $style->assign_block_vars('tree', array());
			
			$row = trim($row);
			$row_level = strripos($row, '*') + 1;
			preg_match('#^\*{0,} (.*?) <(.*?)>$#i', $row, $row_key);
			
			$row_mod = array(dvar(array_key(explode('/', $row_key[2]), 1), 'index'));
			
			if ($row_level > 1) $row_mod[] = array_key(explode(':', array_key(explode('.', array_key(explode('/', $row_key[2]), 2)), 0)), 1);
			
			$row_auth = implode('_', $row_mod);
			if (!$user->auth_get($row_auth)) continue;
			
			$row_style = '.row' . (($row_level == 1) ? '' : '.sub' . ($row_level - 1));
			$style->assign_block_vars('tree' . $row_style, array(
				'V_NAME' => trim(str_replace('*', '', $row_key[1])),
				'V_LINK' => _link() . substr($row_key[2], 1))
			);
		}
	}
	
	//
	// Output template
	$page_smodule = 'CONTROL_' . strtoupper($mod);
	if (is_lang($page_smodule))
	{
		$module->page_title($page_smodule);
	}
	
	$sv = array(
		'MODE' => $module->level['x1'],
		'MANAGE' => $module->level['x2'],
		'NAVIGATION' => $module->get_navigation()
	);
	_layout($module->template, $module->page_title(), $sv);
}
Esempio n. 10
0
 * PDF ÆÄÀÏ »ý¼º
 *------------------------------------------------------------------------*/
$pdf = new PDFTable();
$pdf->SetCreator("DigitalEMC");
$pdf->SetAuthor($_SESSION["MemID"]);
$pdf->SetTitle("Quotation/Invoice Form");
$pdf->SetSubject($entry["doc_num"]);
$pdf->SetMargins(15, 15);
$pdf->AddFont('nanum', '', 'FONT00.TTF', true);
$pdf->SetDrawColor(0, 0, 0);
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('nanum', '', 24);
$pdf->AddPage();
$title_width = 80;
$pdf->SetX((210 - $title_width) / 2);
$pdf->SetLineWidth(0.5);
$pdf->Cell($title_width, 13, _utf8($title), 'B', 1, 'C');
$pdf->Ln(6);
$pdf->SetLineWidth(0.1);
$pdf->SetPadding(2);
$pdf->SetSpacing(2);
$pdf->SetFont('nanum', '', 12, true);
$pdf->htmltable(_utf8($table1));
$pdf->Ln(6);
$pdf->SetFont('nanum', '', 10, true);
$pdf->htmltable(_utf8($table2));
$pdf->htmltable(_utf8($table3));
$pdf->htmltable(_utf8($table4));
$pdf->htmltable(_utf8($table5));
//$pdf->Output("pdf/{$PDF_File}","F");
$pdf->Output("doc.pdf", "I");