1
0
mirror of https://e.coding.net/circlecloud/McAccount.git synced 2024-11-17 00:58:57 +00:00

fix MySQL error and fix message.php...

Signed-off-by: 502647092 <jtb1@163.com>
This commit is contained in:
502647092 2015-10-14 21:07:36 +08:00
parent af6a38d957
commit ec7a26a582
3 changed files with 36 additions and 37 deletions

View File

@ -24,10 +24,10 @@ class Amysql {
} }
static public function filter(&$array, $function) { static public function filter(&$array, $function) {
if (! is_array ( $array )) if (! is_array ( $array ))
Return $array = $function ( $array ); return $array = $function ( $array );
foreach ( $array as $key => $value ) foreach ( $array as $key => $value )
(is_array ( $value ) && $array [$key] = Amysql::filter ( $value, $function )) || $array [$key] = $function ( $value ); (is_array ( $value ) && $array [$key] = Amysql::filter ( $value, $function )) || $array [$key] = $function ( $value );
Return $array; return $array;
} }
} }
@ -165,7 +165,7 @@ class AmysqlController {
if (! isset ( $this->AmysqlClass [$ClassName] )) // 不存在类对象 if (! isset ( $this->AmysqlClass [$ClassName] )) // 不存在类对象
$this->AmysqlClass [$ClassName] = new $ClassName (); $this->AmysqlClass [$ClassName] = new $ClassName ();
Return $this->AmysqlClass [$ClassName]; return $this->AmysqlClass [$ClassName];
} }
Amysql::AmysqlNotice ( $file . ' 类文件不存在' ); Amysql::AmysqlNotice ( $file . ' 类文件不存在' );
@ -195,7 +195,7 @@ class AmysqlController {
$this->DB->DBConnect ( $this->DBConfig ); // 没连接就进行数据库连接 $this->DB->DBConnect ( $this->DBConfig ); // 没连接就进行数据库连接
$this->AmysqlModel [$ModelTag]->MysqlConnect = $this->DB->DBS [$ModelTag]; // 模型使用的数据库连接 $this->AmysqlModel [$ModelTag]->MysqlConnect = $this->DB->DBS [$ModelTag]; // 模型使用的数据库连接
} }
Return $this->AmysqlModel [$ModelTag]; return $this->AmysqlModel [$ModelTag];
} }
Amysql::AmysqlNotice ( $file . ' 模型文件不存在' ); Amysql::AmysqlNotice ( $file . ' 模型文件不存在' );
@ -211,7 +211,7 @@ class AmysqlController {
$file = str_replace ( _PathTag, DIRECTORY_SEPARATOR, $file ); $file = str_replace ( _PathTag, DIRECTORY_SEPARATOR, $file );
$file = _View . $file . '.php'; $file = _View . $file . '.php';
if (is_file ( $file )) if (is_file ( $file ))
Return file_get_contents ( $file ); return file_get_contents ( $file );
Amysql::AmysqlNotice ( $file . ' 数据文件不存在' ); Amysql::AmysqlNotice ( $file . ' 数据文件不存在' );
} }
@ -272,7 +272,7 @@ class AmysqlTemplates {
$file = str_replace ( _PathTag, DIRECTORY_SEPARATOR, $file ); $file = str_replace ( _PathTag, DIRECTORY_SEPARATOR, $file );
$file = _View . $file . '.php'; $file = _View . $file . '.php';
if (is_file ( $file )) if (is_file ( $file ))
Return include ($file); return include ($file);
Amysql::AmysqlNotice ( $file . ' 模板文件不存在' ); Amysql::AmysqlNotice ( $file . ' 模板文件不存在' );
} }
@ -306,17 +306,17 @@ class AmysqlModel {
public function _query($sql) { public function _query($sql) {
global $Config; global $Config;
if (! $this->MysqlConnect) if (! $this->MysqlConnect)
Return false; return false;
$this->QueryStatus = '(0)'; $this->QueryStatus = '(0)';
$this->Affected = 0; $this->Affected = 0;
if ($Config ['DebugSql']) if ($Config ['DebugSql'])
$this->SqlBug .= "\n" . '<!--DebugSql: ' . $sql . '-->' . "\n"; $this->SqlBug .= "\n" . '<!--DebugSql: ' . $sql . '-->' . "\n";
$result = mysql_query ( $sql, $this->MysqlConnect ); $result = mysql_query ( $sql, $this->MysqlConnect );
if (! $result) if (! $result)
Return false; return false;
$this->Affected = mysql_affected_rows (); $this->Affected = mysql_affected_rows ();
$this->QueryStatus = '(ok)'; $this->QueryStatus = '(ok)';
Return $result; return $result;
} }
/** /**
@ -329,7 +329,7 @@ class AmysqlModel {
public function _insert($table, $data) { public function _insert($table, $data) {
$this->InsertId = 0; $this->InsertId = 0;
if (! is_array ( $data ) || count ( $data ) == 0) if (! is_array ( $data ) || count ( $data ) == 0)
Return 0; return 0;
$field_arr = array (); $field_arr = array ();
foreach ( $data as $key => $val ) foreach ( $data as $key => $val )
@ -338,7 +338,7 @@ class AmysqlModel {
$sql = "INSERT INTO `$table` SET " . implode ( ',', $field_arr ); $sql = "INSERT INTO `$table` SET " . implode ( ',', $field_arr );
$this->_query ( $sql ); $this->_query ( $sql );
$this->InsertId = mysql_insert_id (); $this->InsertId = mysql_insert_id ();
Return $this->InsertId; return $this->InsertId;
} }
/** /**
@ -353,7 +353,7 @@ class AmysqlModel {
public function _update($table, $data, $where = '') { public function _update($table, $data, $where = '') {
$this->Affected = 0; $this->Affected = 0;
if (! is_array ( $data ) || count ( $data ) == 0) if (! is_array ( $data ) || count ( $data ) == 0)
Return 0; return 0;
$field_arr = array (); $field_arr = array ();
foreach ( $data as $key => $val ) foreach ( $data as $key => $val )
@ -361,7 +361,7 @@ class AmysqlModel {
$sql = "UPDATE `$table` SET " . implode ( ',', $field_arr ) . $where; $sql = "UPDATE `$table` SET " . implode ( ',', $field_arr ) . $where;
$this->_query ( $sql ); $this->_query ( $sql );
Return $this->Affected; return $this->Affected;
} }
/** /**
@ -374,11 +374,11 @@ class AmysqlModel {
public function _row($sql, $result_type = MYSQL_ASSOC) { public function _row($sql, $result_type = MYSQL_ASSOC) {
$result = $this->_query ( $sql ); $result = $this->_query ( $sql );
if (! $result) if (! $result)
Return false; return false;
$row = mysql_fetch_array ( $result, $result_type ); $row = mysql_fetch_array ( $result, $result_type );
$this->ResultSum = 1; $this->ResultSum = 1;
$this->_free ( $result ); $this->_free ( $result );
Return $row; return $row;
} }
/** /**
@ -391,7 +391,7 @@ class AmysqlModel {
public function _all($sql, $result_type = MYSQL_ASSOC) { public function _all($sql, $result_type = MYSQL_ASSOC) {
$result = $this->_query ( $sql ); $result = $this->_query ( $sql );
if (! $result) if (! $result)
Return false; return false;
$data = array (); $data = array ();
$this->ResultSum = 0; $this->ResultSum = 0;
while ( $row = mysql_fetch_array ( $result, $result_type ) ) { while ( $row = mysql_fetch_array ( $result, $result_type ) ) {
@ -399,7 +399,7 @@ class AmysqlModel {
++ $this->ResultSum; ++ $this->ResultSum;
} }
$this->_free ( $result ); $this->_free ( $result );
Return $data; return $data;
} }
/** /**
@ -411,8 +411,8 @@ class AmysqlModel {
public function _sum($sql) { public function _sum($sql) {
$result = $this->_query ( $sql ); $result = $this->_query ( $sql );
if (! $result) if (! $result)
Return false; return false;
Return mysql_num_rows ( $result ); return mysql_num_rows ( $result );
} }
/** /**
@ -421,7 +421,7 @@ class AmysqlModel {
* @param Object $rs * @param Object $rs
*/ */
public function _free($rs) { public function _free($rs) {
Return mysql_free_result ( $rs ); return mysql_free_result ( $rs );
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
class mail_model extends AmysqlModel { class mail_model extends AmysqlModel {
public function select($where) { public function select($where) {
$sql = "SELECT password, email FROM `authme` WHERE `username` = '" . $where; $sql = "SELECT email FROM `authme` WHERE `username` = '" . $where . "'";
return $this->_all ( $sql ); return $this->_all ( $sql );
} }
public function mail($mail, $verify, $user) { public function mail($mail, $verify, $user) {
@ -21,7 +21,7 @@ class mail_model extends AmysqlModel {
} }
} }
public function status($user) { public function status($user) {
$sql = "SELECT * FROM `mail` WHERE `user` = '" . $user; $sql = "SELECT * FROM `mail` WHERE `user` = '" . $user . "'";
return $this->_all ( $sql ); return $this->_all ( $sql );
} }
} }

View File

@ -45,7 +45,7 @@ if (empty ( $_SESSION ['username'] ))
<!-- navbar --> <!-- navbar -->
<div class="navbar navbar-inverse"> <div class="navbar navbar-inverse">
<div class="navbar-inner"> <div class="navbar-inner">
<a class="brand" href="index.php"><img src="img/logo.png" /></a> <a class="brand" href="<?=Url('index' , 'index')?>"><img src="View/public/img/logo.png" /></a>
<button type="button" class="btn btn-navbar" data-toggle="collapse" <button type="button" class="btn btn-navbar" data-toggle="collapse"
data-target=".nav-collapse"> data-target=".nav-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span <span class="icon-bar"></span> <span class="icon-bar"></span> <span
@ -102,7 +102,7 @@ if (empty ( $_SESSION ['username'] ))
</div> </div>
<div class="field-box"> <div class="field-box">
<label>邮箱地址:</label> <input class="span5 inline-input" id="mail" <label>邮箱地址:</label> <input class="span5 inline-input" id="mail"
type="text" value="" disabled="disabled" /> type="text" value="" disabled="disabled" /><p id="status"></p>
</div> </div>
<div class="field-box"> <div class="field-box">
<label>游戏币余额:</label> <input class="span5 inline-input" id="money" <label>游戏币余额:</label> <input class="span5 inline-input" id="money"
@ -123,7 +123,6 @@ if (empty ( $_SESSION ['username'] ))
<script type="text/javascript"> <script type="text/javascript">
select(); select();
status(); status();
var data = "user=<?=$_SESSION['username']?>"; var data = "user=<?=$_SESSION['username']?>";
function select(){ function select(){
$.ajax({ $.ajax({
@ -170,10 +169,10 @@ if (empty ( $_SESSION ['username'] ))
}) })
} }
window.onload = function(){ window.onload = function(){
var html = $('.status').html(); var html = $('#status').html();
//document.write(html); //document.write(html);
if(html.indexOf("尚未验证") !== -1){ if(html.indexOf("尚未验证") != -1){
$('.status').html($('.status').html()+ " <a href='<?=Url('index', 'mail')?>' onclick='display()'>点击这里进行验证</a>") $('#status').html($('#status').html()+ " <a href='<?=Url('index', 'mail')?>' onclick='display()'>点击这里进行验证</a>")
} }
} }
current(); current();