Jump to content

pointing problem..


zgkhoo

Recommended Posts

<?php
session_start();
?>

</html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<div id="bodyarea" style="padding: 1ex 0px 2ex 0px;">
</div>
<!--</html>-->


<?php


include '../../config.php';
include '../../opendb.php';


$cardnum=$_SESSION["cardnum"];
$initial=$_SESSION["initial"];
$active_len=$_SESSION["active_len"];
$active_type=$_SESSION["active_type"];
$point=$_SESSION["point"];
$createdate=$_SESSION["create_date"];
$expirydate=$_SESSION["expiry_date"];
//echo "Card Card Card Card Card".$_SESSION["initial"];

function generatePassword ($length,$type)
{
   $password = "";

  
  if ($type=='Character(Big Letter)'){//3
  	$possible="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  }
  else{//3
  	if($type=='Character(Small Letter)'){//2
  		$possible="abcdefghijklmnopqrstuvwxyz";
  	}//2
  	else{//2
  		if ($type=='Number'){//1
  			$possible="0123456789";
  		}//1
  		else{//1
  			$possible = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
  		}//1
  	}//2
  }//3
    
  // set up a counter
  $i = 0; 
    
  // add random characters to $password until $length is reached
  while ($i < $length) { 

    // pick a random character from the possible ones
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
        
    // we don't want this character if it's already in the password
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }//end of while

  // done!
  return $password;
}


$con = mysql_connect("localhost","root","");
if (!$con){
  die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);



$sql = "CREATE TABLE gamecard
(

Serialnum varchar(13),
Serial varchar(13),
Initial varchar(13),
Activatecode varchar(13),
Ownerid varchar(13), 
Status varchar(13),
Downleft varchar(13),
Downright varchar(13),
Upline varchar(13),
Expireddate date,
Createdate datetime,
Point varchar(13),
Golden varchar(13)

)";
mysql_query($sql,$con);


$result = mysql_query("SELECT * FROM gamecard") or die('Query failed: ' . mysql_error());

while($row = mysql_fetch_array($result,MYSQL_ASSOC)){
	$serial=$row["Serial"];
//	echo "serial=".$serial;
};
$serial++; //serial num for the newly added card
echo "new serial".$serial;
if($serial==1)
$serial=$serial+1000;


//$cardnum=$_POST['cardnum'];
$count=0;

echo"<center><table border=1><tr><td>Serial Number</td><td>Activate Code</td><td>Point</td><td>Created Date</td><td>Expiry Date</td></tr>";

while ($count<$cardnum) {//generate activate_code for each new card added

$randompass=generatePassword($active_len,$active_type);
$_SESSION["generatepass"]=$randompass;

echo "serial".$serial;

$actualserial=$serial-1000;
echo"actual serial".$actualserial;
$serialstr=strval($actualserial);
echo "serial str".$serialstr;
$seriallength=strlen($serialstr);
echo "serial length".$seriallength;

if ($seriallength<=3){
if($seriallength==1)
	$serialpart="000".$actualserial;
else{
	if($seriallength==2)
		$serialpart="00".$actualserial;
	else{
		$serialpart="0".$actualserial;
	//	echo "add 0".$seriallength;
	}
}
}
else{
$serialpart=$actualserial;
//echo "=>4";
}

$serialnum=$initial.$serialpart;
$_SESSION["activatenum"]=$serialnum;


$card_arr[$count][0]=$serialnum;
$card_arr[$count][1]=$serial;
$card_arr[$count][2]=$initial;
$card_arr[$count][3]=$randompass;
$card_arr[$count][4]=$expirydate;
$card_arr[$count][5]=$createdate;
$card_arr[$count][6]=$point;


echo"<tr><td>$serialnum</td><td>$randompass</td><td>$point</td><td>$createdate</td><td>$expirydate</td></tr>";



$count++;
$serial++;


}//end of while $count<$cardnum

$_SESSION["card_arr"]=$card_arr;



?>

<center><table><tr><td>
<form name="form1" method="post" action="insertcard.php">
<input type="hidden" name="posted" value="true">
<input type="submit" name="Submit" value="Confirm">
</form>
</td>
</tr>
</table>
</center>
</html>

Link to comment
https://forums.phpfreaks.com/topic/75764-pointing-problem/#findComment-383438
Share on other sites

function generatePassword ($length,$type)
{
   $password = "";

  
  if ($type=='Character(Big Letter)'){//3
  	$possible="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  }
  else{//3
  	if($type=='Character(Small Letter)'){//2
  		$possible="abcdefghijklmnopqrstuvwxyz";
  	}//2
  	else{//2
  		if ($type=='Number'){//1
  			$possible="0123456789";
  		}//1
  		else{//1
  			$possible = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
  		}//1
  	}//2
  }//3
    
  // set up a counter
  $i = 0; 
    
  // add random characters to $password until $length is reached
  while ($i < $length) { 

    // pick a random character from the possible ones
    $char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
        
    // we don't want this character if it's already in the password
    if (!strstr($password, $char)) { 
      $password .= $char;
      $i++;
    }

  }//end of while

  // done!
  return $password;
}

is it possible hang by this function again??  :o

Link to comment
https://forums.phpfreaks.com/topic/75764-pointing-problem/#findComment-383473
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.