Ejemplo n.º 1
0
 /**
  * ScheduleTest::testAddSchedule()
  * 
  * @return void
  */
 public function testAddSchedule()
 {
     $this->sample_schedule['code'] = $this->CODE;
     $this->sample_schedule['flightnum'] = $this->FLIGHTNUM;
     $ret = SchedulesData::addSchedule($this->sample_schedule);
     $this->assertTrue($ret, DB::error());
 }
Ejemplo n.º 2
0
	static function query($sql)
	{
		if(func_num_args()>1)	$sql = self::prepare($args = func_get_args());
		
		$st = microtime(true);
		$result = mysql_query($sql);
		if(mysql_error()) DB::error($sql);
		self::$affected_rows = mysql_affected_rows();
		self::$insert_id = mysql_insert_id();
		
		/*
		if(microtime(true) - $st > 1)
		{
			$_q = preg_replace('/[\d,]+/', 'N', $sql);
			$_uri = Request::escape( $_SERVER['REQUEST_URI'] );
			$_long_query = DB::prepare("insert into long_query (q,uri,st) values (?,?,?i)", $_q, $_uri, microtime(true)-$st);
			mysql_query($_long_query); // служедбный запрос, чтобы не сбил нам insert_id и affected_rows
		}
		*/
		
		// echo $sql."<br>\n";
		
		if(microtime(true)-$st>0.1 && $_SERVER['REMOTE_ADDR']=='93.125.42.170') $GLOBALS['queries'][] = Array("time"=>(microtime(true)-$st), "sql"=>$sql);
		
		return $result;
	}
Ejemplo n.º 3
0
 public function testSubmitPIREP()
 {
     echo '<h3>PIREP Checks</h3>';
     $data = array('pilotid' => 1, 'code' => 'VMA', 'flightnum' => '1352', 'depicao' => 'KORD', 'arricao' => 'KJFK', 'aircraft' => 10, 'flighttime' => '4.1', 'submitdate' => 'NOW()', 'fuelused' => '2800', 'source' => 'unittest', 'comment' => 'This is a test PIREP');
     $info = PIREPData::FileReport($data);
     $this->assertTrue($info, DB::error());
     $this->pirep_id = DB::$insert_id;
     $this->assertIsA($this->pirep_id, int);
     unset($data);
     echo '<br />';
 }
Ejemplo n.º 4
0
 /**
  * @param $where
  */
 public function remove($where)
 {
     // DELETE FROM {TABLE} WHERE ...
     $sql = "DELETE FROM `{$this->table}` WHERE 1=1";
     foreach ($where as $column => $value) {
         $sql .= " AND `{$column}` = '{$value}'";
     }
     $result = $this->db->query($sql);
     if ($result === false) {
         $this->db->error();
     }
 }
Ejemplo n.º 5
0
 /**
  * UserTest::testEditUserData()
  * 
  * @return void
  */
 public function testEditUserData()
 {
     $pilot = PilotData::getPilotByEmail('*****@*****.**');
     $this->assertObjectHasAttribute('pilotid', $pilot, 'PilotData::getPilotByEmail');
     # Check a save profile
     $save = PilotData::updateProfile($pilot->pilotid, array('email' => '*****@*****.**', 'location' => 'PK'));
     $this->assertTrue($save, DB::error());
     # Verify if data was written, and if it differs
     $changeset1 = PilotData::getPilotData($pilot->pilotid);
     $this->assertEquals('PK', $changeset1->location);
     unset($data);
 }
Ejemplo n.º 6
0
 function test_open()
 {
     // test a bad connection
     $this->assertFalse(DB::open($this->bad_conf));
     $this->assertEquals('could not find driver', DB::error());
     $this->assertEquals(0, DB::count());
     // test a master connection
     $this->assertTrue(DB::open($this->conf));
     $this->assertEquals(1, DB::count());
     // test a second connection
     $this->assertTrue(DB::open($this->conf2));
     $this->assertEquals(2, DB::count());
     unset(DB::$connections['slave_1']);
 }
Ejemplo n.º 7
0
 public function listTables()
 {
     $result = \DB::query("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")->result();
     if (\DB::error()) {
         return false;
     }
     $newTables = [];
     foreach ($result as $tables) {
         foreach ($tables as $tb => $table) {
             $newTables[] = $table;
         }
     }
     return $newTables;
 }
Ejemplo n.º 8
0
 public function install()
 {
     $ret = DB::CreateTable('comment', "id I AUTO KEY, text X(4000) NOTNULL, user_login_id I NOTNULL, parent I DEFAULT -1 NOTNULL, topic C(255) NOTNULL, created_on T NOTNULL");
     if ($ret === false) {
         print 'Invalid SQL query - Comment module install: ' . DB::error();
         return false;
     }
     $ret = DB::CreateTable('comment_report', "id I KEY, user_login_id I NOTNULL");
     if ($ret === false) {
         print 'Invalid SQL query - Comment module install: ' . DB::error();
         return false;
     }
     Base_ThemeCommon::install_default_theme('Utils/Comment');
     return true;
 }
Ejemplo n.º 9
0
 public function insertPost()
 {
     if (isset($this->id) && is_numeric($this->id)) {
         return false;
     }
     $this->tags = isset($this->tags) ? $this->cleanTags($this->tags) : '';
     $sql = 'insert into posts (title, body, created, author_id, tags) values(?, ?, now(), ?, ?)';
     Log::debug(__CLASS__ . ': Saving post: ' . $this->title);
     if (DB::q($sql, $this->title, $this->body, $this->author_id, $this->tags) && is_numeric($this->id = DB::getLastInsertId())) {
         Log::debug(__CLASS__ . ': Saved new post: ' . $this->id . ':' . $this->title);
         return $this->id;
     } else {
         Log::error(__CLASS__ . ': Could not save post: ' . DB::error());
         return false;
     }
 }
Ejemplo n.º 10
0
 /**
  * 卡片生成
  * @param $rule - 字符串 卡片生成规则
  * @param $num - 整数 卡片生成规则
  * $param $cardval - 数组 卡片的其他属性
  * @return 返回转义好的字符串
  * return:
  *        '-1' 规则不存在
  *        true 成功
  */
 function make($rule = '', $num = 1, $cardval = array())
 {
     global $_G;
     $this->rule = empty($rule) ? $this->set['rule'] : trim($rule);
     if (empty($this->rule)) {
         return -1;
     }
     $this->fail($num);
     $cardval['makeruid'] = $_G['uid'];
     $cardval['dateline'] = $_G['timestamp'];
     for ($i = 0; $i < $num; $i++) {
         //解析卡片随机规则生成卡片号码
         if ($this->checkrule($this->rule)) {
             $card = $this->rule;
             foreach ($this->rulereturn as $key => $val) {
                 $search = array();
                 foreach ($val as $skey => $sval) {
                     $search[] = '/' . $this->rulekey[$key] . '/';
                 }
                 $card = preg_replace($search, $val, $card, 1);
             }
         } else {
             return 0;
         }
         $cardval['id'] = $card;
         C::t('common_card')->insert($cardval, false, false, 'SILENT');
         if ($sqlerror = DB::error()) {
             if ($sqlerror == 1062) {
                 //存在重复卡片时,错误数累加
                 $this->fail++;
                 if ($this->failmin > $this->fail) {
                     $num++;
                 } else {
                     $num = $i - 1;
                 }
             }
             /* else {
             				DB::halt($sqlerror, $sql);
             			}*/
         } else {
             //成功后,将卡片放入卡片列表
             $this->succeed += intval(DB::affected_rows());
             $this->cardlist[] = $card;
         }
     }
     return true;
 }
Ejemplo n.º 11
0
 /**
  * 获取表查询数据
  * @param  string $table 表名
  * @param  string $field 表字段
  * @param  string $where where条件
  * @param  string $order order by条件	 
  * @return array  查询数据	
  */
 public function getdata($table, $field = '*', $where = '', $order = '')
 {
     global $_M;
     /*获取表格ajax传递的参数*/
     $length = $_M['form']['length'];
     //每页显示数量
     $start = $_M['form']['start'];
     //读取数据的起点
     $draw = $_M['form']['draw'];
     //累计执行次数,无作用但必须回传
     if ($_M['form']['tablepage'] && $start == 0 & $draw == 1) {
         $cook = explode("|", $_M['form']['tablepage']);
         $u = "{$_M['form']['n']},{$_M['form']['c']},{$_M['form']['a']}";
         if ($cook[1] == $u) {
             $start = $cook[0] * $_M['form']['length'];
         }
     }
     /*查询表*/
     if ($where) {
         $conds .= " WHERE {$where} ";
     }
     if ($order) {
         $conds .= " ORDER BY {$order} ";
     }
     //整理查询条件
     $query = "SELECT {$field} FROM {$table} {$conds} LIMIT {$start},{$length}";
     //mysql语句
     $array = DB::get_all($query);
     //执行查询,获得数组
     $error = DB::error();
     if ($error) {
         $this->error = $query . "<br />" . $error;
     } else {
         $this->error = '';
     }
     $total = DB::counter($table, $conds, '*');
     //获取总数量,计算总页数
     /*回传数组处理*/
     $this->rarray = array();
     $this->rarray['draw'] = $draw;
     //回传执行次数
     $this->rarray['recordsTotal'] = $total;
     //回传总数量
     $this->rarray['recordsFiltered'] = $total;
     //回传筛选过的总数量,暂无作用,但必须回传
     return $array;
 }
Ejemplo n.º 12
0
 function make($rule = '', $num = 1, $cardval = array())
 {
     global $_G;
     $this->rule = empty($rule) ? $this->set['rule'] : trim($rule);
     if (empty($this->rule)) {
         return -1;
     }
     $this->fail($num);
     if (is_array($cardval)) {
         foreach ($cardval as $key => $val) {
             $sqlkey .= ", {$key}";
             $sqlval .= ", '{$val}'";
         }
     }
     for ($i = 0; $i < $num; $i++) {
         if ($this->checkrule($this->rule)) {
             $card = $this->rule;
             foreach ($this->rulereturn as $key => $val) {
                 $search = array();
                 foreach ($val as $skey => $sval) {
                     $search[] = '/' . $this->rulekey[$key] . '/';
                 }
                 $card = preg_replace($search, $val, $card, 1);
             }
         } else {
             return 0;
         }
         $sql = "INSERT INTO " . DB::table('common_card') . " (id, makeruid, dateline {$sqlkey})VALUES('{$card}', '{$_G['uid']}', '{$_G['timestamp']}' {$sqlval})";
         DB::query($sql, 'SILENT');
         if ($sqlerror = DB::error()) {
             if (DB::errno() == 1062) {
                 $this->fail++;
                 if ($this->failmin > $this->fail) {
                     $num++;
                 } else {
                     $num = $i - 1;
                 }
             } else {
                 DB::halt($sqlerror, $sql);
             }
         } else {
             $this->succeed += intval(DB::affected_rows());
             $this->cardlist[] = $card;
         }
     }
     return true;
 }
Ejemplo n.º 13
0
 function __construct()
 {
     $this->doctype = isset($this->doctype) ? $this->doctype : strtolower(str_replace(__CLASS__, '', get_class($this)));
     $args = func_get_args();
     $this->query = array_shift($args);
     $this->parameters = $args;
     array_unshift($args, $this->getQuery());
     Log::debug(get_class($this) . ': Attempting to fetch list using query: ' . $this->getQuery());
     if ($results = call_user_func_array(array('DB', 'getAll'), $args)) {
         foreach ($results as $row) {
             $this->list[] = DBDoc::get($doctype, $row);
         }
         Log::debug(get_class($this) . ': Built list with ' . count($this->getList()) . ' items.');
     } else {
         Log::warning(get_class($this) . ': Created empty new ' . get_class($this) . ': looks like the query failed: ' . DB::error());
     }
 }
Ejemplo n.º 14
0
 public static function _construct()
 {
     // make sure the DB has already made a connection.
     if (is_object(DB::$DB) !== true) {
         DB::error('DBCINI', 'LIBTIT', __CLASS__);
     }
     // we have to check that the cache path exist and is writable.
     if (!($path = DB::$DB->cachedir)) {
         return DB::$DB->cache = false;
     }
     // add a trailing slash if needed
     $path = preg_replace("/(.+?)\\/*\$/", "\\1/", $path);
     if (!is_dir($path) || !is_writable($path)) {
         return DB::$DB->cache = false;
     }
     DB::$DB->cachedir = $path;
 }
Ejemplo n.º 15
0
 public static function send($type, $title = '', $message = '', $data = array())
 {
     self::$instance->data = array_merge(self::$instance->data, $data);
     if (!in_array($type, self::$instance->types)) {
         throw new MyException('Por favor passe um tipo conhecido para o JResponse');
     }
     if (SYS_MODO_DEVEL && $type == self::RESULT_F_FAIL) {
         $r['debug'] = DB::error();
     }
     $r['result'] = $type;
     //erro/fail/auth/permission
     $r['title'] = $title;
     $r['message'] = $message;
     $r['data'] = self::$instance->data;
     $r['errors'] = self::$instance->errors;
     header("Content-type: text/json");
     exit(json_encode($r));
 }
Ejemplo n.º 16
0
 function sqldumptablestruct($table)
 {
     //备分所有表
     global $_G;
     $createtable = DB::query("SHOW CREATE TABLE {$table}", 'SILENT');
     if (!DB::error()) {
         $tabledump = "DROP TABLE IF EXISTS {$table};\n";
     } else {
         return '';
     }
     $create = $this->db->fetch_row($createtable);
     if (strpos($table, '.') !== FALSE) {
         $tablename = substr($table, strpos($table, '.') + 1);
         $create[1] = str_replace("CREATE TABLE {$tablename}", 'CREATE TABLE ' . $table, $create[1]);
     }
     $tabledump .= $create[1];
     $tablestatus = DB::fetch_first("SHOW TABLE STATUS LIKE '{$table}'");
     $tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT={$tablestatus['Auto_increment']}" : '') . ";\n\n";
     return $tabledump;
 }
Ejemplo n.º 17
0
 function testEditUserData()
 {
     # Check a save profile
     $save = PilotData::SaveProfile($this->pilotid, '*****@*****.**', 'PK', '', '', true);
     $this->assertEqual(0, DB::errno());
     #unset($save);
     # Verify if data was written, and if it differs
     $changeset1 = PilotData::GetPilotData($this->pilotid);
     $this->assertNotEqual($changeset1, $this->pilot_data);
     $this->assertNotEqual($changeset1->retired, $this->pilot_data->retired);
     unset($data);
     # Change it back
     $save = PilotData::SaveProfile($this->pilotid, '*****@*****.**', 'US', '', '', false);
     $this->assertTrue($save, DB::error(), 'Reverting user data');
     unset($save);
     # And verify once more
     $changeset2 = PilotData::GetPilotData($this->pilotid);
     $this->assertNotEqual($changeset1, $changeset2);
     $this->assertNotEqual($changeset1->retired, $changeset2->retired);
     unset($changeset1);
     unset($changeset2);
     echo '<br />';
 }
Ejemplo n.º 18
0
    static function setUpBeforeClass()
    {
        DB::open(array('master' => true, 'driver' => 'sqlite', 'file' => ':memory:'));
        DB::$prefix = 'elefant_';
        $sql = sql_split('
			create table #prefix#webpage (
				id char(72) not null primary key,
				title char(72) not null,
				menu_title char(72) not null,
				window_title char(72) not null,
				access char(12) not null,
				layout char(48) not null,
				description text,
				keywords text,
				body text
			);
			insert into #prefix#webpage (id, title, menu_title, window_title, access, layout, description, keywords, body) values ("index", "Welcome to Elefant", "Home", "", "public", "default", "", "", \'<table><tbody><tr><td><h3>Congratulations!</h3>You have successfully installed Elefant, the refreshingly simple new PHP web framework and CMS.</td><td><h3>Getting Started</h3>To log in as an administrator and edit pages, write a blog post, or upload files, go to <a href="/admin">/admin</a>.</td><td><h3>Developers</h3>Documentation, source code and issue tracking can be found at <a href="http://github.com/jbroadway/elefant">github.com/jbroadway/elefant</a></td></tr></tbody></table>\');
		');
        foreach ($sql as $query) {
            if (!DB::execute($query)) {
                die(DB::error());
            }
        }
    }
Ejemplo n.º 19
0
			echo "<script>window.location.href='$url_rewrite';</script>script>";
		}
	}
}


if (isset($UserSession['ses_utoken']) && ($UserSession['ses_uid']))
{
	$menuID = $UserSession['ses_uhakakses'];
	
}
else
{
	
	$query = "SELECT menuID FROM tbl_user_menu WHERE menuAksesLogin = 0 AND menuStatus = 1";
	$result = $DBVAR->query($query) or die ($DBVAR->error());
	
	while ($data = $DBVAR->fetch_object($result))
	{
		$menuID[] = $data->menuID;
	}
	
	if (count($menuID) > 0)
	{
		$implode = implode(',',$menuID);
		$defaultSes = $SESSION->set_session(array('ses_name' => 'menu_without_login', 'ses_value' => $implode));	
	}
	else
	{
		$USERAUTH->show_warning('Sesi user gagal di set');
	}
Ejemplo n.º 20
0
 protected function PIREP_AddField()
 {
     if ($this->post->title == '') {
         echo 'No field name entered!';
         return;
     }
     $ret = PIREPData::AddField($this->post->title, $this->post->type, $this->post->options);
     if (DB::errno() != 0) {
         $this->set('message', 'There was an error saving the field: ' . DB::error());
         $this->render('core_error.tpl');
     } else {
         LogData::addLog(Auth::$userinfo->pilotid, 'Added PIREP field "' . $this->post->title . '"');
         $this->set('message', 'Added PIREP field "' . $this->post->title . '"');
         $this->render('core_success.tpl');
     }
 }
Ejemplo n.º 21
0
$page->layout = 'admin';
$cur = $this->installed('polls', $appconf['Admin']['version']);
if ($cur === true) {
    $page->title = 'Already installed';
    echo '<p><a href="/polls/admin">Continue</a></p>';
    return;
} elseif ($cur !== false) {
    header('Location: /' . $appconf['Admin']['upgrade']);
    exit;
}
$page->title = 'Installing App: Polls';
$conn = conf('Database', 'master');
$driver = $conn['driver'];
DB::beginTransaction();
$error = false;
$sqldata = sql_split(file_get_contents('apps/polls/conf/install_' . $driver . '.sql'));
foreach ($sqldata as $sql) {
    if (!DB::execute($sql)) {
        $error = DB::error();
        break;
    }
}
if ($error) {
    DB::rollback();
    @error_log('Error: polls/install - ' . $error);
    echo '<p>Install failed.</p>';
    return;
}
DB::commit();
echo '<p><a href="/polls/admin">Done.</a></p>';
$this->mark_installed('polls', $appconf['Admin']['version']);
Ejemplo n.º 22
0
function sqldumptablestruct($table)
{
    global $_G, $db, $excepttables;
    if (in_array($table, $excepttables)) {
        return;
    }
    $createtable = DB::query("SHOW CREATE TABLE {$table}", 'SILENT');
    if (!DB::error()) {
        $tabledump = "DROP TABLE IF EXISTS {$table};\n";
    } else {
        return '';
    }
    $create = $db->fetch_row($createtable);
    if (strpos($table, '.') !== FALSE) {
        $tablename = substr($table, strpos($table, '.') + 1);
        $create[1] = str_replace("CREATE TABLE {$tablename}", 'CREATE TABLE ' . $table, $create[1]);
    }
    $tabledump .= $create[1];
    if ($_GET['sqlcompat'] == 'MYSQL41' && $db->version() < '4.1') {
        $tabledump = preg_replace("/TYPE\\=(.+)/", "ENGINE=\\1 DEFAULT CHARSET=" . $dumpcharset, $tabledump);
    }
    if ($db->version() > '4.1' && $_GET['sqlcharset']) {
        $tabledump = preg_replace("/(DEFAULT)*\\s*CHARSET=.+/", "DEFAULT CHARSET=" . $_GET['sqlcharset'], $tabledump);
    }
    $tablestatus = DB::fetch_first("SHOW TABLE STATUS LIKE '{$table}'");
    $tabledump .= ($tablestatus['Auto_increment'] ? " AUTO_INCREMENT={$tablestatus['Auto_increment']}" : '') . ";\n\n";
    if ($_GET['sqlcompat'] == 'MYSQL40' && $db->version() >= '4.1' && $db->version() < '5.1') {
        if ($tablestatus['Auto_increment'] != '') {
            $temppos = strpos($tabledump, ',');
            $tabledump = substr($tabledump, 0, $temppos) . ' auto_increment' . substr($tabledump, $temppos);
        }
        if ($tablestatus['Engine'] == 'MEMORY') {
            $tabledump = str_replace('TYPE=MEMORY', 'TYPE=HEAP', $tabledump);
        }
    }
    return $tabledump;
}
Ejemplo n.º 23
0
    function show_error($type, $errormsg, $phpmsg = '')
    {
        global $_G;
        ob_end_clean();
        $gzip = getglobal('gzipcompress');
        ob_start($gzip ? 'ob_gzhandler' : null);
        $host = $_SERVER['HTTP_HOST'];
        $phpmsg = trim($phpmsg);
        $title = $type == 'db' ? 'Database' : 'System';
        echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
\t<title>{$host} - {$title} Error</title>
\t<meta http-equiv="Content-Type" content="text/html; charset={$_G['config']['output']['charset']}" />
\t<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
\t<style type="text/css">
\t<!--
\tbody { background-color: white; color: black; }
\t#container { width: 650px; }
\t#message   { width: 650px; color: black; background-color: #FFFFCC; }
\t#bodytitle { font: 13pt/15pt verdana, arial, sans-serif; height: 35px; vertical-align: top; }
\t.bodytext  { font: 8pt/11pt verdana, arial, sans-serif; }
\t.help  { font: 12px verdana, arial, sans-serif; color: red;}
\t.red  {color: red;}
\ta:link     { font: 8pt/11pt verdana, arial, sans-serif; color: red; }
\ta:visited  { font: 8pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
\t-->
\t</style>
</head>
<body>
<table cellpadding="1" cellspacing="5" id="container">
<tr>
\t<td id="bodytitle" width="100%">Discuz! {$title} Error </td>
</tr>
EOT;
        if ($type == 'db') {
            $helplink = "http://faq.comsenz.com/?type=mysql&dberrno=" . rawurlencode(DB::errno()) . "&dberror=" . rawurlencode(DB::error());
            echo <<<EOT
<tr>
\t<td class="bodytext">The database has encountered a problem. <a href="{$helplink}" target="_blank"><span class="red">Need Help?</span></a></td>
</tr>
EOT;
        } else {
            echo <<<EOT
<tr>
\t<td class="bodytext">Your request has encountered a problem. </td>
</tr>
EOT;
        }
        echo <<<EOT
<tr><td><hr size="1"/></td></tr>
<tr><td class="bodytext">Error messages: </td></tr>
<tr>
\t<td class="bodytext" id="message">
\t\t<ul> {$errormsg}</ul>
\t</td>
</tr>
EOT;
        if (!empty($phpmsg)) {
            echo <<<EOT
<tr><td class="bodytext">&nbsp;</td></tr>
<tr><td class="bodytext">Program messages: </td></tr>
<tr>
\t<td class="bodytext">
\t\t<ul> {$phpmsg} </ul>
\t</td>
</tr>
EOT;
        }
        $endmsg = lang('error', 'error_end_message', array('host' => $host));
        echo <<<EOT
<tr>
\t<td class="help"><br /><br />{$endmsg}</td>
</tr>
</table>
</body>
</html>
EOT;
        $exit && exit;
    }
Ejemplo n.º 24
0
    public static function show_error($type, $errormsg, $phpmsg = '', $typemsg = '')
    {
        global $_G;
        ob_end_clean();
        $gzip = getglobal('gzipcompress');
        ob_start($gzip ? 'ob_gzhandler' : null);
        $host = $_SERVER['HTTP_HOST'];
        $title = $type == 'db' ? 'Database' : 'System';
        //出错处理 改为记日志而不是直接输出到页面
        $messagesave = $host . '\\r' . $title . '\\r\\n' . $errormsg;
        !empty($phpmsg) && ($messagesave = $messagesave . '\\r\\n' . var_export($phpmsg, true));
        discuz_error::write_error_log($messagesave);
        header("Location: /");
        exit;
        echo <<<EOT
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
\t<title>{$host} - {$title} Error</title>
\t<meta http-equiv="Content-Type" content="text/html; charset={$_G['config']['output']['charset']}" />
\t<meta name="ROBOTS" content="NOINDEX,NOFOLLOW,NOARCHIVE" />
\t<style type="text/css">
\t<!--
\tbody { background-color: white; color: black; font: 9pt/11pt verdana, arial, sans-serif;}
\t#container { width: 1024px; }
\t#message   { width: 1024px; color: black; }

\t.red  {color: red;}
\ta:link     { font: 9pt/11pt verdana, arial, sans-serif; color: red; }
\ta:visited  { font: 9pt/11pt verdana, arial, sans-serif; color: #4e4e4e; }
\th1 { color: #FF0000; font: 18pt "Verdana"; margin-bottom: 0.5em;}
\t.bg1{ background-color: #FFFFCC;}
\t.bg2{ background-color: #EEEEEE;}
\t.table {background: #AAAAAA; font: 11pt Menlo,Consolas,"Lucida Console"}
\t.info {
\t    background: none repeat scroll 0 0 #F3F3F3;
\t    border: 0px solid #aaaaaa;
\t    border-radius: 10px 10px 10px 10px;
\t    color: #000000;
\t    font-size: 11pt;
\t    line-height: 160%;
\t    margin-bottom: 1em;
\t    padding: 1em;
\t}

\t.help {
\t    background: #F3F3F3;
\t    border-radius: 10px 10px 10px 10px;
\t    font: 12px verdana, arial, sans-serif;
\t    text-align: center;
\t    line-height: 160%;
\t    padding: 1em;
\t}

\t.sql {
\t    background: none repeat scroll 0 0 #FFFFCC;
\t    border: 1px solid #aaaaaa;
\t    color: #000000;
\t    font: arial, sans-serif;
\t    font-size: 9pt;
\t    line-height: 160%;
\t    margin-top: 1em;
\t    padding: 4px;
\t}
\t-->
\t</style>
</head>
<body>
<div id="container">
<h1>Discuz! {$title} Error</h1>
<div class='info'>{$errormsg}</div>


EOT;
        if (!empty($phpmsg)) {
            echo '<div class="info">';
            echo '<p><strong>PHP Debug</strong></p>';
            echo '<table cellpadding="5" cellspacing="1" width="100%" class="table">';
            if (is_array($phpmsg)) {
                echo '<tr class="bg2"><td>No.</td><td>File</td><td>Line</td><td>Code</td></tr>';
                foreach ($phpmsg as $k => $msg) {
                    $k++;
                    echo '<tr class="bg1">';
                    echo '<td>' . $k . '</td>';
                    echo '<td>' . $msg['file'] . '</td>';
                    echo '<td>' . $msg['line'] . '</td>';
                    echo '<td>' . $msg['function'] . '</td>';
                    echo '</tr>';
                }
            } else {
                echo '<tr><td><ul>' . $phpmsg . '</ul></td></tr>';
            }
            echo '</table></div>';
        }
        $helplink = '';
        if ($type == 'db') {
            $helplink = "http://faq.comsenz.com/?type=mysql&dberrno=" . rawurlencode(DB::errno()) . "&dberror=" . rawurlencode(str_replace(DB::object()->tablepre, '', DB::error()));
            $helplink = "<a href=\"{$helplink}\" target=\"_blank\"><span class=\"red\">Need Help?</span></a>";
        }
        $endmsg = lang('error', 'error_end_message', array('host' => $host));
        echo <<<EOT
<div class="help">{$endmsg}. {$helplink}</div>
</div>
</body>
</html>
EOT;
        $exit && exit;
    }
Ejemplo n.º 25
0
 /**
  * Perform a query
  *
  * @param unknown_type $query
  * @return boolean/int Returns true/false, or rows affected
  */
 public static function query($query)
 {
     self::$DB->throw_exceptions = self::$throw_exceptions;
     $ret = self::$DB->query($query);
     self::$error = self::$DB->error;
     self::$errno = self::$DB->errno;
     self::$rows_affected = self::$num_rows = self::$DB->num_rows;
     self::$insert_id = self::$DB->insert_id;
     self::$last_query = $query;
     // Log any erronious queries
     if (self::$DB->errno != 0) {
         self::write_debug();
     }
     return $ret;
     //self::$insert_id;
 }
Ejemplo n.º 26
0
$file = 'apps/' . $this->app . '/conf/upgrade_' . $base_version . '_' . $driver . '.sql';
if (file_exists ($file)) {
    // begin the transaction
    DB::beginTransaction ();

    // parse the database schema into individual queries
    $sql = sql_split (file_get_contents ($file));

    // execute each query in turn
    foreach ($sql as $query) {
        if (! DB::execute ($query)) {
            // show error and rollback on failures
            printf (
                '<p class="visible-notice">%s: %s</p><p>%s</p>',
                __ ('Error'),
                DB::error (),
                __ ('Install failed.')
            );
            DB::rollback ();
            return;
        }
    }

    // commit the transaction
    DB::commit ();
}

// add your upgrade logic here

echo '<p>' . __ ('Done.') . '</p>';
Ejemplo n.º 27
0
                 }
             }
         } else {
             if (!empty($oldcols[$key])) {
                 if (strtolower($value) != strtolower($oldcols[$key])) {
                     $updates[] = "CHANGE `{$key}` `{$key}` {$value}";
                 }
             } else {
                 $updates[] = "ADD `{$key}` {$value}";
             }
         }
     }
     if (!empty($updates)) {
         $usql = "ALTER TABLE " . DB::table($newtable) . " " . implode(', ', $updates);
         if (!DB::query($usql, 'SILENT')) {
             show_msg(lang('update', 'upgrade_table') . DB::table($newtable) . lang('update', 'sql_error') . ':<br><br><b>' . lang('update', 'sql_statement') . '</b>:<div style=\\"position:absolute;font-size:11px;font-family:verdana,arial;background:#EBEBEB;padding:0.5em;\\">' . dhtmlspecialchars($usql) . "</div><br><b>Error</b>: " . DB::error() . "<br><b>Errno.</b>: " . DB::errno());
         } else {
             $msg = lang('update', 'upgrade_table') . DB::table($newtable) . lang('update', 'completed');
         }
     } else {
         $msg = lang('update', 'check_table') . DB::table($newtable) . lang('update', 'skip_table');
     }
 }
 if ($specid) {
     $newtable = $spectable;
 }
 if (get_special_table_by_num($newtable, $specid + 1)) {
     $next = $theurl . '?step=sql&i=' . $_GET['i'] . '&specid=' . ($specid + 1);
 } else {
     $next = $theurl . '?step=sql&i=' . ($_GET['i'] + 1);
 }
Ejemplo n.º 28
0
 public function processExpense()
 {
     if ($this->post->name == '' || $this->post->cost == '') {
         $this->set('message', 'Name and cost must be entered');
         $this->render('core_error.tpl');
         return;
     }
     if (!is_numeric($this->post->cost)) {
         $this->set('message', 'Cost must be a numeric amount, no symbols');
         $this->render('core_error.tpl');
         return;
     }
     if ($this->post->action == 'addexpense') {
         # Make sure it doesn't exist
         if (FinanceData::GetExpenseByName($this->post->name)) {
             $this->set('message', 'Expense already exists!');
             $this->render('core_error.tpl');
             return;
         }
         $ret = FinanceData::AddExpense($this->post->name, $this->post->cost, $this->post->type);
         $this->set('message', 'The expense "' . $this->post->name . '" has been added');
         FinanceData::setExpensesforMonth(time());
         LogData::addLog(Auth::$userinfo->pilotid, 'Added expense "' . $this->post->name . '"');
     } elseif ($this->post->action == 'editexpense') {
         $ret = FinanceData::EditExpense($this->post->id, $this->post->name, $this->post->cost, $this->post->type);
         $this->set('message', 'The expense "' . $this->post->name . '" has been edited');
         FinanceData::setExpensesforMonth(time());
         LogData::addLog(Auth::$userinfo->pilotid, 'Edited expense "' . $this->post->name . '"');
     }
     if (!$ret) {
         $this->set('message', 'Error: ' . DB::error());
         $this->render('core_error.tpl');
         return;
     }
     $this->render('core_success.tpl');
 }
Ejemplo n.º 29
0
 /**
  * Write all of the SQL tables to the database
  * 
  * @return
  */
 public static function AddTables()
 {
     if (!DB::init($_POST['DBASE_TYPE'])) {
         self::$error = DB::$error;
         return false;
     }
     DB::set_caching(false);
     $ret = DB::connect($_POST['DBASE_USER'], $_POST['DBASE_PASS'], $_POST['DBASE_NAME'], $_POST['DBASE_SERVER']);
     if ($ret == false) {
         self::$error = DB::$error;
         return false;
     }
     if (!DB::select($_POST['DBASE_NAME'])) {
         self::$error = DB::$error;
         return false;
     }
     DB::$throw_exceptions = false;
     echo '<h2>Writing Tables...</h2>';
     $sqlLines = self::readSQLFile(SITE_ROOT . '/install/sql/install.sql', $_POST['TABLE_PREFIX']);
     foreach ($sqlLines as $sql) {
         DB::query($sql['sql']);
         if (DB::errno() != 0) {
             #echo 'failed - manually run this query: <br /><br />"'.$sql.'"';
             echo '<div id="error" style="text-align: left;">Writing "' . $sql['table'] . '" table... ';
             echo "<br /><br />" . DB::error();
             echo '</div>';
         }
     }
     echo "Wrote {$totalTables} tables<br />";
     echo '<h2>Populating Initial Data...</h2>';
     $sqlLines = self::readSQLFile(SITE_ROOT . '/install/fixtures/install.sql', $_POST['TABLE_PREFIX']);
     foreach ($sqlLines as $sql) {
         DB::query($sql['sql']);
         if (DB::errno() != 0) {
             echo '<div id="error" style="text-align: left;">Writing to "' . $sql['table'] . '" table... ';
             echo "<br /><br />" . DB::error();
             echo '</div>';
         }
     }
     return true;
 }
Ejemplo n.º 30
0
 protected function delete_schedule_post()
 {
     $schedule = SchedulesData::findSchedules(array('s.id' => $this->post->id));
     SchedulesData::DeleteSchedule($this->post->id);
     $params = array();
     if (DB::errno() != 0) {
         $params['status'] = 'There was an error deleting the schedule';
         $params['error'] = DB::error();
         echo json_encode($params);
         return;
     }
     $params['status'] = 'ok';
     echo json_encode($params);
     LogData::addLog(Auth::$userinfo->pilotid, 'Deleted schedule "' . $schedule->code . $schedule->flightnum . '"');
 }