Jump to content

zgkhoo

Members
  • Posts

    507
  • Joined

  • Last visited

    Never

Posts posted by zgkhoo

  1. wat i want is...when user abnormal terminate..then it still will display the error msg(althought it already terminated)

    and now also when the system is display the success msg but seem not at the same time with the commit action..

    (is it cause by slow speed of my computer)?

     

    the query is performing faster than the display in the page.....which sometime already commit..but havent display it on the page yet.

  2. <?php
    session_start();
    $session[counter]=0;//got problem with viarable should $_SESSION
    $lock='F';
    ob_start();
    echo "Your IP=".$_SERVER['REMOTE_ADDR']; //display ip
    
    
    
    
    include 'config.php';
    include 'opendb.php';
    
    
    
    
    
    if(isset($_POST['Login'])){ 
    
    /*$today = Now('Y-m-d H:i:s');
    echo "today".$today;
    exit;
    */
    
    $ip=$_SERVER['REMOTE_ADDR'];
    //$currdate=date('Y-m-d H:i:s'); //current date n tm
    //echo "currdate".$currdate."<br>";
    //$cdate=date('Y-m-d');// current date
    //echo "<br>cdate".$cdate;
    
    $ipquery  = "SELECT * FROM ip where ipaddress='$ip' AND logindate=DATE(NOW()) AND ipstatus='Fail' ORDER BY ipID";
    $ipresult = mysql_query($ipquery);
    $num=mysql_num_rows($ipresult); 
    echo "num".$num;
    if($num>=5){
    $lock='T';
    }
    
    $username=$_POST[username];
    $password=$_POST[password];
    
    
    $query  = "SELECT * FROM person where username='$username' ORDER BY UserID";
    $result = mysql_query($query);
    $totalrows=mysql_num_rows($result); 
    
    if ($lock!='T'){
    
    if ($totalrows!=0){// valid user name
           while($row = mysql_fetch_array($result,MYSQL_ASSOC)){//getting user rec
        	 //unable to use echo here->error
          	if($row['Acctstatus']=='Active'){
         	 
           		if($password==$row['Password']){
           	    
           	
           			$restore=0;
           			mysql_query("UPDATE Person SET Trackuser = '$restore' 
                	where username='$username'");
        			session_start();
        			if ($row[Level]=='User'){  //if login is user
        			
           				$_SESSION['loginname']=$username;
           				//$_SESSION['user_ic']=$row['ic'];
           				$_SESSION['UserID']=$row['UserID'];
           				//unset($_SESSION['login_try']);
           				
           				header('Location: ./EN/menu/userenter.php');
           			}
           			else{                       //if login is admin
           				$_SESSION['loginname']=$username;
           				//$_SESSION['user_ic']=$row['ic'];
           				if($_SESSION['LANG']=="EN"){
           					//unset($_SESSION['login_try']);	  	 
           			        header('Location: ./EN/menu/adminenter.php');
           				}
           				else{
           					unset($_SESSION['login_try']);	 
           					header('Location: ./CH/menu/adminenter.php');
           					}
           		     }
             		//keep track of ip address
           				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
    	 				$totalrows=mysql_num_rows($dbresult); 
    	 				if($totalrows==0){
    	 					$lastip="1001";
    	 				}
    	 				else{
         					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
           	
           	 					$lastip=$row["LatestIp"];
           	    
          					}
         					$lastip++;
    	 				}
           				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
    				VALUES('$lastip','$ip','$username',DATE(NOW()),NOW(),'Success')";
    				mysql_query($sql,$con);
    				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
    		    //end of keep track of ip address
             		include 'closedb.php'; // when the rec found, stop searching by close db
    
           }
           else{//user enter the wrong password for the correct user name
           		
           
       	 		$failtm=$row["Trackuser"];
       	 		
       	 		$failtm++;
           		mysql_query("UPDATE Person SET Trackuser = '$failtm' 
                where username='$username'");
           		
           		if($failtm==5){// inform user his acct will b suspended
           			
    
    			$status='Lock';
    			mysql_query("UPDATE Person SET Acctstatus = '$status' 
                	where username='$username'");
    			echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>You Are Unauthorized User! Your Account Will Be Suspended!</font></td></tr></table></center>";
    			//keep track of ip address
           			$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
    	 			$totalrows=mysql_num_rows($dbresult); 
    
    	 			if($totalrows==0){
    	 				$lastip="1001";
    	 			}
    	 			else{
         				while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
           	
           	 				$lastip=$row["LatestIp"];
           	    
          				}
         				$lastip++;
    	 			}
           			$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
    			VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
    			mysql_query($sql,$con);
    			mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
    		    //end of keep track of ip address	
    			header('Refresh:5;url=index.php');
    			exit;			
           		    }
           				//keep track of ip address, 4 user acct not yet being locked
           				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
    	 				$totalrows=mysql_num_rows($dbresult); 
    
    	 				if($totalrows==0){
    	 					$lastip="1001";
    	 				}
    	 				else{
         					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
           	
           	 					$lastip=$row["LatestIp"];
           	    
          					}
         					$lastip++;
    	 				}
           				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
    				VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
    				mysql_query($sql,$con);
    				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
    		       //end of keep track of ip address	
           	echo "<META HTTP-EQUIV='refresh' content='0;URL=index.php'>";
            exit;
           		
           }//else of incorrect password for the user
          }//end of if acctstatus=active
          else{ //user acct locked
           	  echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>Your Account Have Been Locked! Please Contact Admin For Activation.</font></td></tr></table></center>";
           	  			//keep track of ip address
           				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
    	 				$totalrows=mysql_num_rows($dbresult); 
    
    	 				if($totalrows==0){
    	 					$lastip="1001";
    	 				}
    	 				else{
         					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
           	
           	 					$lastip=$row["LatestIp"];
           	    
          					}
         					$lastip++;
    	 				}
           				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
    				VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
    				mysql_query($sql,$con);
    				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
    		    	//end of keep track of ip address
          	  header('Refresh:5;url=index.php');
           	  exit;
          }
        }//end of while
       }// end of valid user name
    
    else{//invalid username
    //echo "y";
    /*$_SESSION['login_try']++;
    if($_SESSION['login_try']==5){
    	//to follow up->keep track of the user ip address so that next tm in the signin function'll check for the ip address
    	//echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>You Are Unauthorized User!!!</font></td></tr></table></center>";
    	$_SESSION['lock']='T';
    
    }*/
    				//keep track of ip address
           				$dbresult = mysql_query("SELECT * FROM ip order by IpID") or die('Query failed: ' . mysql_error());
    	 				$totalrows=mysql_num_rows($dbresult); 
    
    	 				if($totalrows==0){
    	 					$lastip="1001";
    	 				}
    	 				else{
         					while($row = mysql_fetch_array($dbresult,MYSQL_ASSOC)){
           	
           	 					$lastip=$row["LatestIp"];
           	    
          					}
         					$lastip++;
    	 				}
           				$sql="INSERT INTO ip(IpID,Ipaddress,Loginuser,Logindate,Logintm,Ipstatus)
    				VALUES('$lastip','$ip','Null',DATE(NOW()),NOW(),'Fail')";
    				mysql_query($sql,$con);
    				mysql_query("UPDATE ip SET LatestIp='$lastip'") or die(mysql_error());
    		    	//end of keep track of ip address
    echo "<META HTTP-EQUIV='refresh' content='0;URL=index.php'>";
    exit;
    }
    
    }
    
    
    else{ // lock=T
    
    //powerful acct used by developer to login to admin menu, no lock for it 
    /*if ($username=='Sys_Developer'){
    	if($password=='A7A8'){
    		session_start();
    		$_SESSION['loginname']=$username;
        		header('Location: adminenter.php');
    	}
    
        }
    else{*/
    //	echo "lock".$_SESSION['lock'];
    	echo "<center><table><tr><td bgcolor=#FFCC00><font color=#CC0000>You Are Unauthorized User!Your IP Address Has Been Keep Tracked!</font></td></tr></table></center>";
    	header('Refresh:5;url=index.php');
     	exit;
    //}
    }
    
    
    
    }//end of isset login
    
    
    if(isset($_POST['loginbyid'])){ 
    echo "</br>login here";
    $_SESSION['UserID']=$_POST['loginid'];
    header('Location: ./EN/menu/userenter.php');
    
    
    }
    
    
    
    
    
    echo "
    <table border=0 width=100%>
    <tr>
    <td align=middle bgcolor=orange>
    Company Logo
    </td>
    <td bgcolor=yellow>
    
    
    <table border =0 bgcolor=orange width=100%>
    <tr>
    <td align=middle>
    <h5>Term and condition</h5>
    </td>
    <td>
    <h5>Rules</h5>
    </td>
    <td>
    <h5>Regulation</h5>
    </td>
    <td>
    <h5>Payment</h5>
    </td>
    <td>
    <h5>Language</h5>
    </td>
    </tr>
    </table>
    
    </td>
    <td bgcolor=yellow>
    <table border =0 bgcolor=orange width=100%>
    <tr>
    <td>
    <select name=language onChange=document.location = this.value + '.php'>
    <option value=english>English</option>
    <option value=chinese>Chinese</option>
    </select>
    
    
    </td>
    </tr>
    </table>
    
    
    
    
    
    
    </td>
    </tr>
    <tr>
    <td width=20% bgcolor=yellow>
    
    
    
    <form action=index.php method=post>
    <table border=1>
    <tr>
    <td bgcolor=orange>
    <h5>Username</h5>
    </td>
    <td>
    <input type=text name=username>
    </td>
    </tr>
    <tr>
    <td bgcolor=orange>
    <h5>Password</h5>
    </td>
    <td>
    <input type=text name=password>
    </td>
    </tr>
    <tr>
    <td bgcolor=orange>
    <h5>Validation Picture</h5>
    </td>
    <td width=177> 
    <input type=image name=securityimage img src=../../CaptchaSecurityImages.php/>
    </td>
    </tr>
    <tr>
    <td bgcolor=orange>
    <h5>Validation Code</h5>
    </td>
    <td>
    <input type=text name=validation>
    </td>
    </tr>
    <tr>
    <td bgcolor=orange>
    </td>
    <td>
    <input type=submit name='Login' value=login>
    </td>
    </tr>
    
    
    </table>
    
    </form>
    
    
    <a href=./EN/menu/adminenter.php>admin menu</a>
    <a href=./EN/menu/userenter.php>user menu</a>
    <a href=install_db.php>Install DB</a>
    <a href=db.php>View DB</a>
    </h4>
    </form>
    </br>
    <h5>
    <a href=./EN/register/register.php>Sign Up</a>
    </h5>
    </center>
    
    <center>
    <form action=index.php method=post>
    </br>
    <font>Login directly by id</font>
    </br>
    <input type=text name=loginid>
    </br>
    <input type=submit name=loginbyid value=Login>
    </form>
    </center>
    
    
    </td>
    <td  bgcolor=yellow>
    
    
    
    
    <img src=/PIC/RO111_main_24.jpg width=540 height=400>
    
    
    </td>
    <td bgcolor=yellow width=15%>
    
    
    <table border =1 width=6>
    <tr>
    <td>
    <img src=PIC/01.gif>
    </td>
    </tr>
    <tr>
    <td>
    <img src=PIC/02.gif>
    </td>
    </tr>
    <tr>
    <td>
    <img src=PIC/03.gif>
    </td>
    </tr>
    <tr>
    <td>
    <img src=PIC/04.gif>
    </td>
    </tr>
    <tr>
    <td>
    <img src=PIC/05.gif>
    </td>
    </tr>
    <tr>
    <td>
    <img src=PIC/06.gif>
    </td>
    </tr>
    
    </table>
    
    
    </td>
    <table width=100%>
    <tr width=100%>
    <td width=100%>
    
    
    <table border=0 bgcolor=orange width=100%>
    <tr>
    <td>
    <h5>
    Copyright � Sports Bookie Online, Inc. All rights reserved.
    </h5>
    </td>
    <td>
    <h5>Privacy Policy</h5>
    </td>
    <td>
    <h5>Banking</h5>
    </td>
    <td>
    <h5>Paying Method</h5>
    </td>
    <td>
    <h5>Jobs</h5>
    </td>
    <td>
    <img src=PIC/small01.gif>
    </td>
    
    </tr>
    </table>
    
    
    </td>
    </tr>
    </table>
    ";
    
    
    ?>
    
    <select id="language" name="language" onChange="do_it();">
    <option value="english">English</option>
    <option value="chinese">Chinese</option>
    </select>
    

     

    weird..not respond at all after i select the language...

     

  3. <?php
    include '../../../config.php';
    include '../../../opendb.php';
    
    include '../adminmain.php';
    include '../../../pyramidfunction2.php';
    
    
    mysql_query("BEGIN");
    
    
    //insert admin card module!!!!!!!!!!!!!
    
    if(isset($_POST['insertadmincard'])){
    //store admin card into gamecard table
    	$result=mysql_query("SELECT * from rate ORDER BY RID");
    
    
    	//while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
    	$lastcardserial=findcurrentserial();
    
    	for($i=0,$count=$_POST['admincardnum'];$i<$count;$i++) {
    	$lastcardserial+=1;
    
    	$ID="Admin".($lastcardserial-1000);
    	$sql="INSERT INTO gamecard(Serialnum,Serial,Ownerid)
                  VALUES
        ('$ID','$lastcardserial','AdminCard')";
    	mysql_query($sql);
    	mysql_query("UPDATE gamecard SET LatestSerial='$lastcardserial'") or die(mysql_error());
    
    	//$pyrtable=findpyramid($ID);
    	$prytable=$_POST['assotable'];
    	echo "</br>prytable=".$_POST['assotable'];
    
    	addpyramidcard($ID,$_POST['assotable']);
        	  		    
        	setpyramidbonus($ID,$_POST['assotable']);
    
    
    	}
    
    		     
    
    
    
    }
    
    function findcurrentserial(){
    $result=mysql_query("SELECT Serial from gamecard ORDER BY Serial DESC LIMIT 1 LOCK IN SHARE MODE");
    
    	if(mysql_num_rows($result)==0){
    		return 1001;
    
    	}
    
    
    
    while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ 
    	$serial=$row[serial];
    
    
    }
    return $serial;
    
    
    
    
    
    
    
    
    }
    
    
    mysql_query("COMMIT");
    //echo "</br>successful added";
    
    if (false == ($var = @mysql_query("COMMIT"))) {
       // error..
      echo 'There was an error: ' . mysql_error() . '.';
    }
    else {
       //success
      echo 'Success: ' . $var . '.';
    }
    
    
    
    
    
    
    include '../../../closedb.php';
    
    
    
    
    
    
    
    ?>
    
    
    
    <html>
    <head>
    <link rel="stylesheet" type="text/css" href="style.css"/>
    </head> 
    
    
    <form name='insertadmincard' action='admincard.php' method=post>
    <table border="3">
    <tr>
    <td>Number of Admin card to be insert into pyramid公司卡数目</td>
    <td><input type="text" name=admincardnum></td>
    </tr>
    <tr>
    <td>Select which pyramid table to be insert选择输入的金字塔</td>
    
    
                    <td><select name=assotable>
                    <?php
                    include '../../../config.php';
                    include '../../../opendb.php';
                    
                    $result2 = mysql_query("SELECT * FROM pyramidT") or die('Query failed: ' . mysql_error());
                    while($row2 = mysql_fetch_array($result2,MYSQL_ASSOC)){
    
                     if($row[AssoTable]==$row2[TableName]){
                     echo "<option value=$row2[TableName] selected='selected'>$row2[TableName]</option>";
                     }//end if
                     else{
                     	echo "<option value=$row2[TableName]>$row2[TableName]</option>";                 	
                     }//end else
                                      
                     }//end while
                     include '.../../../closedb.php';
                     ?>
                     </select>
                     </td>
    </tr>
    <tr>
    
    <td><input type="submit" name='insertadmincard' value='insert'><td>
    </tr>
    </table>
    </form>
    
    
    </html>
    

  4. <?php
    mysql_query("COMMIT");
                                                             <------abnormal terminate at here....
    if (false == ($var = @mysql_query("COMMIT"))) {
       // error..
      echo 'There was an error: ' . mysql_error() . '.';
    }
    else {
       //success
      echo 'Success: ' . $var . '.';
    }

     

    wat if abnormal terminate at the point show above? will it still running the following line which showing success or failure msg? since the program already terminated(stopped at the point) at the point

  5. mysql_query("COMMIT");
    echo "</br>successful added";

    tested with abnormal termination ..and found sometime ...the system already commit but doesnt display the successful msg....(maybe my abnormal termination taken after commit and before display successful msg.

    how to make commit and success msg ....appear together?

     

    and another question..does rollback keyword needed..since...no commit...and the system wont save the last transaction..

     

  6. $sql = "CREATE TABLE pyrmain
    
    
    		(
    		PID integer(10),
    		Serialnum varchar(10),
    		UplineSerial varchar(10),
    		UplinePID integer(10),
    		Downleft integer(10),
    		LeftSerial varchar(10),
    		Downright integer(10),
    		RightSerial varchar(10),
    		RowNum integer(10),
    		ColumnPosi integer(10),
    		ColumnTotal integer(10),
    		DownlineAmount integer(10),
    		Initial varchar(10),
    		ActivateTime datetime,
    		Status varchar(10),
    		UserID varchar(10),
    		ExpiredDate datetime,
    		CreateDate datetime,
    		Golden varchar(10),
    
    		Primary Key (PID)    	    
    		)engine=innodb";

     

    how to duplicate the primary key and the engine  as well?

    thanks

  7. If you terminate the mysql connection without committing, the transaction will be rolled back.

     

    Think about it from mysql's view .. it doesn't know if your transaction is complete until you say "commit".  So if you stop without saying "commit", it is better for it to abandon all changes than to possibly commit partial changes.

     

    If the changes conflict with each other, then usually one script will get an error, the other will complete normally.  If the changes do not conflict, both scripts will succeed.

     

    If you commit for one user, it will not commit another user's transaction.

     

    how mysql differential user? using BEGIN and COMMIT?

    BEGIN meant start a new connection?

     

     

    mysql_query('BEGIN TRANSACTION_NAME'); 

    do i need to put in TRANSACTION_NAME? wat if i didnt put transaction name?

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.