protected function query($cmd, $type = SDBBase::Select)
 {
     global $s_runconf;
     $sql = $this->parse($cmd);
     if (DEBUG) {
         $t1 = get_microtime();
         $res = $this->run_query($sql, $type);
         $this->last_affected = $type != SDBBase::Select ? $res['affected'] : $res['selected'];
         $t2 = get_microtime();
         if ($res['error']) {
             dwrite("**Failed [** {$sql} **] {$res['error']}**", S_ERROR);
         } else {
             $dt = $t2 - $t1;
             $s_runconf->set('time.sql.query', $s_runconf->get('time.sql.query') + $dt);
             $rows_str = $type != SDBBase::Select ? $res['affected'] . ' rows affected' : $res['selected'] . ' rows selected';
             dwrite("**Success [** {$sql} **] {$rows_str}** (" . number_format($dt, 8) . ")", $dt < 0.1 ? S_SUCCESS : S_ACCENT);
         }
     } else {
         $res = $this->run_query($sql, $type);
         $this->last_affected = $type != SDBBase::Select ? $res['affected'] : $res['selected'];
     }
     return $res['result'];
 }
示例#2
0
                    } else {
                        if ($typeid == 4) {
                            if (in_array(strtolower(file_ext($flash_src)), array('jpg', 'jpeg', 'png', 'gif', 'bmp'))) {
                                $typeid = 3;
                                $image_src = $flash_src;
                            }
                        }
                    }
                }
                ob_start();
                include template($template, $module);
                $data = ob_get_contents();
                ob_clean();
                file_put($filename, '<!--' . $totime . '-->' . $data);
                if ($typeid > 1) {
                    $data = 'document.write(\'' . dwrite($data) . '\');';
                    file_put(DT_ROOT . '/file/script/A' . $p['pid'] . '.js', $data);
                }
            } else {
                file_del($filename);
                if ($typeid > 1) {
                    if ($p['code']) {
                        file_put(DT_ROOT . '/file/script/A' . $p['pid'] . '.js', $p['code']);
                    } else {
                        file_del(DT_ROOT . '/file/script/A' . $p['pid'] . '.js');
                    }
                }
            }
        }
    }
}
 protected function send_raw()
 {
     if (!SEmail::validate_email($this->from_email)) {
         return 'Invalid "From" email';
     }
     if (!SEmail::validate_email($this->to)) {
         return 'Invalid "To" email';
     }
     $from = $this->make_from();
     $hdr = 'From: ' . $from . "\r\n";
     $hdr .= 'Return-Path: ' . $this->from_email . "\r\n";
     $hdr .= 'Errors-To: ' . $this->from_email . "\r\n";
     if ($this->html_email) {
         $hdr .= "MIME-Version: 1.0\r\n";
     }
     foreach ($this->headers as $key => $val) {
         $hdr .= $this->santize_string($key) . ': ' . $this->santize_string($val) . "\r\n";
     }
     if (!count($this->attachments)) {
         if ($this->html_email) {
             $hdr .= 'Content-Type: text/html; charset=' . $this->charset . "\r\n";
         }
         $body = $this->body;
     } else {
         $str = $this->body;
         foreach ($this->attachments as $att) {
             $str .= $att->content;
         }
         $boundary = $this->generate_boundary($str);
         $hdr .= 'Content-Type: multipart/mixed; boundary="' . $boundary . '"' . "\r\n";
         $attachs = '';
         foreach ($this->attachments as $att) {
             if (strpos($att->mime_type, '/') === false) {
                 throw new Exception('Invalid MIME type of the attachment.');
             }
             $attachs .= "--{$boundary}\r\n";
             $attachs .= 'Content-Type: ' . $att->mime_type;
             if ($att->content_name != '') {
                 $attachs .= '; name="' . $att->content_name . '"';
             }
             $attachs .= "\r\n";
             $attachs .= "Content-Transfer-Encoding: base64\r\n";
             if ($att->file_name != '') {
                 $attachs .= 'Content-Disposition: attachment; filename="' . $att->file_name . '"' . "\r\n";
             }
             if ($att->content_id != '') {
                 $attachs .= 'Content-ID: <' . $att->content_id . ">\r\n";
             }
             $attachs .= "\r\n";
             $attachs .= chunk_split(base64_encode($att->content)) . "\r\n";
         }
         $body = "--{$boundary}\r\n";
         $body .= "Content-type: text/html; charset=" . $this->charset . "\r\n\r\n";
         $body .= $this->body . "\r\n" . $attachs;
         $body .= "--{$boundary}--\r\n";
     }
     if (DEBUG) {
         $msg = "**SendMail to \"{$this->to}\" with subject \"{$this->subject}\"**";
         if (!conf('mail.send')) {
             $msg .= ' !!(Sending email is disabled)!!';
         }
         dwrite($msg);
         dwrite_msg('Headers', $hdr);
         dwrite_msg('Body', $body);
     }
     if (conf('mail.send')) {
         switch (conf('mail.type')) {
             case 'mail':
                 return $this->send_mail_mail($from, $this->to, $this->subject, $hdr, $body);
             case 'smtp':
                 return $this->send_mail_smtp($this->from_email, $from, $this->to, $this->subject, $hdr, $body);
             case 'sendmail':
                 return $this->send_mail_sendmail($from, $this->to, $this->subject, $hdr, $body);
             default:
                 throw new Exception('Unknown mailer type (' . conf('mail.type') . ')');
         }
     }
     return '';
 }
 protected function output_result($res)
 {
     global $s_runconf;
     $nw = get_microtime();
     $this->output_headers();
     echo $res;
     if (DEBUG) {
         dwrite('**[Page processing end]**');
         dwrite('Page processing takes: ' . number_format($nw - $this->_start_time, 8));
         dwrite('SQL parsing takes: ' . number_format($s_runconf->get('time.sql.parse'), 8));
         dwrite('SQL queries takes: ' . number_format($s_runconf->get('time.sql.query'), 8));
         dwrite('Templates takes: ' . number_format($s_runconf->get('time.template'), 8) . ' (approx, including template loading)');
         $debuglog_str = dflush_str();
         if (LOG_DEBUG_INFO) {
             _log("[[ Page info ]]\n\n{$debuglog_str}\n\n");
         }
         if ($this->content_type == 'text/html' && SHOW_DEBUG_INFO) {
             echo '<div style="z-index:99999;position:absolute;top:0;left:0;font-size:10px;font-family:Tahoma;font-weight:bold;background-color:#000;color:#FFF;cursor:pointer;cursor:hand;"';
             echo ' onclick="var s=document.getElementById(\'__s_debug__\').style;s.display=s.display==\'\'?\'none\':\'\';return false;">#</div>';
             echo '<div id="__s_debug__" style="z-index:99999;position:absolute;top:15px;left:10px;border:1px solid #888;background-color:#FFF;overflow:auto;width:800px;height:300px;display:none;">';
             echo '<pre style="text-align:left;padding:5px;margin:0;" class="s-debug">';
             echo get_debuglog_html($debuglog_str);
             echo '</pre></div>';
         }
     }
 }
function dwrite_msg($str, $msg, $type = S_NORMAL)
{
    if (!DEBUG) {
        return;
    }
    dwrite($str, $type, $msg);
}
示例#6
0
<?php

/*
	[Destoon B2B System] Copyright (c) 2008-2015 www.destoon.com
	This is NOT a freeware, use is subject to license.txt
*/
$_SERVER['REQUEST_URI'] = '';
require '../common.inc.php';
header("Content-type:text/javascript");
check_referer() or exit('document.write("Invalid Referer");');
$tag = isset($auth) ? decrypt($auth) : '';
$tag or exit('document.write("Invalid Parameter");');
is_file(DT_ROOT . '/file/script/0' . md5($tag) . '.js') or exit('document.write("Invalid Script");');
$tag = strip_sql($tag);
foreach (array($DT_PRE, '#', '$', '%', '&amp;', 'table', 'fields', 'password', 'payword', 'debug') as $v) {
    strpos($tag, $v) === false or exit('document.write("Invalid Tag");');
}
ob_start();
tag($tag);
$data = ob_get_contents();
ob_clean();
echo 'document.write(\'' . dwrite($data ? $data : 'No Data') . '\');';
示例#7
0
 $one = isset($one) && $one ? 1 : 0;
 if (!isset($num)) {
     $num = 100;
     cache_clear_ad(1);
     $result = $db->query("SELECT * FROM {$DT_PRE}ad_place WHERE ads=0 AND code<>''");
     $totime = $DT_TIME + 86400 * 365 * 10;
     while ($r = $db->fetch_array($result)) {
         if ($r['typeid'] > 5) {
             $filename = 'ad_' . $r['moduleid'] . '_d' . $r['typeid'] . '.htm';
         } else {
             $filename = 'ad_' . $r['pid'] . '_d0.htm';
         }
         $data = '<!--' . $totime . '-->' . $r['code'];
         file_put(DT_CACHE . '/htm/' . $filename, $data);
         if ($r['typeid'] > 1 && $r['typeid'] < 6) {
             $data = 'document.write(\'' . dwrite($r['code']) . '\');';
             file_put(DT_ROOT . '/file/script/A' . $r['pid'] . '.js', $data);
         }
     }
 }
 if (!isset($fid)) {
     $r = $db->get_one("SELECT min(aid) AS fid FROM {$DT_PRE}ad");
     $fid = $r['fid'] ? $r['fid'] : 0;
 }
 isset($sid) or $sid = $fid;
 if (!isset($tid)) {
     $r = $db->get_one("SELECT max(aid) AS tid FROM {$DT_PRE}ad");
     $tid = $r['tid'] ? $r['tid'] : 0;
 }
 $_moduleid = $moduleid;
 if ($fid <= $tid) {
    error('Magic found');
}
if ($index < 1) {
    $index = 1;
    dwrite('Index out of bound (less than 1)', S_ERROR);
}
if ($index > 9) {
    $index = 9;
    dwrite('Index out of bound (more than 9)', S_ERROR);
}
for ($i = 1; $i <= 9; $i++) {
    if ($i == $index) {
        echo "[{$i}]";
    } else {
        if (inGET('gimmedebug')) {
            echo '&nbsp;<a href="?index=' . $i . '&amp;gimmedebug=1">' . $i . '</a>&nbsp;';
        } else {
            echo '&nbsp;<a href="?index=' . $i . '">' . $i . '</a>&nbsp;';
        }
    }
}
?>
	:.</strong>
<?php 
dwrite('[End]');
if (DEBUG) {
    echo_debug();
}
?>
</body>
</html>
 public function get_one($cmd)
 {
     $res = $this->query($cmd);
     if ($res === false) {
         return null;
     }
     if ($res === true) {
         if (DEBUG) {
             dwrite("**\"{$cmd->command}\"** is not a SELECT query", S_ERROR);
         }
         return null;
     }
     if ($row = mysql_fetch_assoc($res)) {
         $fld = first_value($row);
     } else {
         $fld = null;
     }
     mysql_free_result($res);
     return $fld;
 }
 public function process($filename)
 {
     global $s_runconf;
     if (DEBUG) {
         $sql_t = $s_runconf->get('time.sql.parse') + $s_runconf->get('time.sql.query');
         $st = get_microtime();
         $nested = $s_runconf->get('tpl.nested', array());
         $nested[] = 0;
         $s_runconf->set('tpl.nested', $nested);
     }
     $funcname = $this->generate_funcname($filename);
     if (!function_exists($funcname)) {
         if (!file_exists($filename)) {
             throw new Exception("Template \"{$filename}\" doesn't exists");
         }
         $dir = substr(dirname($filename), strlen(BASE));
         $rdir = conf('cache.path') . 'templates/' . $dir;
         if ($rdir != '' && !is_dir($rdir)) {
             make_directory($rdir);
         }
         if (substr($rdir, -1) != '/') {
             $rdir .= '/';
         }
         $rname = $rdir . basename($filename) . '.php';
         $mt = filemtime($filename);
         $mk = true;
         if (!file_exists($rname) || filemtime($rname) < $mt) {
             dwrite('Parsing template "' . $rname . '"', S_ACCENT);
             $parsed = $this->parse(file_get_contents($filename), $funcname);
             if ($fp = @fopen($rname, 'wb')) {
                 fwrite($fp, '<' . '?' . 'php' . "\n" . $parsed);
                 // closing php tag is not necessary
                 fclose($fp);
                 chmod($rname, 0555 + 0111);
             } else {
                 dwrite("Can't write template to \"{$rname}\"", S_ERROR);
             }
             eval($parsed);
         } else {
             dwrite('Loading template "' . $rname . '"', S_ACCENT);
             require $rname;
         }
     }
     if (DEBUG) {
         $res = call_user_func($funcname, $this, $this->vars);
         $dt = get_microtime() - $st - ($s_runconf->get('time.sql.parse') + $s_runconf->get('time.sql.query') - $sql_t);
         $nested = $s_runconf->get('tpl.nested');
         $curr = array_splice($nested, count($nested) - 1);
         $rdt = $dt - $curr[0];
         if (count($nested)) {
             $nested[count($nested) - 1] += $dt;
         }
         $s_runconf->set('tpl.nested', $nested);
         $s_runconf->set('time.template', $s_runconf->get('time.template') + $rdt);
         return $res;
     } else {
         return call_user_func($funcname, $this, $this->vars);
     }
 }