Jump to content

ababmxking

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Posts posted by ababmxking

  1. thanks for the help guys, but i couldnt figure out that strtotime function, so what im doing instead, and its less accurate. The could either get banned  for a little bit longer or get lucky and be banned for a little bit less. BUT they are being banned, so i honestly dont care. They can deal with it lol. They are lucky im even coding something like this for them, so we can have the option to ban them for a week instead of permanently.

     

    But what im doin is, just using hours, days and years. And im multiplying, dividing or whatever i need to do, to set the days to the right ban day, and year. So say they're getting banned for 6 months, what im doing is,

     

    $day = date(whatever letter it is to have 0-365 as a day);
    
            //for months
         $day += $banLength * 30.416;
    

     

    so it makes it so much easier for me to figure out how to do the un-ban automatically, and makes everything simple for me.

     

    If anybody wants to give some pointers feel free, im always open.

  2. Ok so the deal is, i want to setup a ban page (for my online PvP RPG). I want to give my staff the option to ban for X amount of hours, X amount of days, X amount of weeks, X amount of months or X amount of years. The way i'm doing it is like so.

     

    	$hour     = date(G);
    	$day      = date(j);	
    	$month    = date(m);
    	$year     = date(Y);
    	$week     = date(W);
    	$daycount = date(t);
    

     

    And then I add to day, month, hour, year, week, according to which option the staff member is trying to ban for.

     

    My problem is, say the day is the 31st, and its the 22nd hour in the day, and they ban for 3 hours, well i have to update the day, and if the updated day is greater than the day count, then i have to update month, week, etc. So far i've worked out quite a bit of the kinks, but i still have quite a few too. And the php for this alone is already 140 lines i think.

     

    Heres the full code ( its a bit messy and probably a little hard to understand)

    <?php
    if($_POST['submit']){
    $ban = $_POST['ban'];
    $amount = $_POST['amount'];
    
    	if(strlen($ban) == 0){
    		echo"Please enter a ban length";
    	}
    
    		else{
    	$hour     = date(G);
    	$day      = date(j);	
    	$month    = date(m);
    	$year     = date(Y);
    	$week     = date(W);
    	$daycount = date(t);
    		$testing = 1;
    		if($testing){
    			$hour = 24;
    			$day = $daycount;
    			$month = 12;
    			$week = 52;
    			}
    
    		$fullodate = "$month/$day/$year  $hour  $week";
    
    		switch($amount){
    			case 1:
    					if($ban >= 24){
    						$error = "You are trying to ban for 24 or more hours, please change the option to days";
    					}
    
    					else{
    						$hour = $ban + $hour;
    					}
    			break;
    
    			case 2:
    					if($ban >= 7){
    						$error = "You are trying to ban for 7 or more days, please change the option to weeks";
    					}
    
    					else{
    						$day = $day + $ban;
    					}
    			break;
    
    			case 3:
    					if($ban >= 4){
    						$error = "You are trying to ban for 4 or more weeks, please change the option to months";
    					}
    
    					else{
    						$week = $week + $ban;
    					}
    			break;
    
    			case 4:
    					if($ban >= 12){
    						$error = "You are trying to ban for 12 or more months, please change the option to years";
    					}
    
    					else{
    						$month = $month + $ban;
    					}
    			break;
    
    			case 5:
    					if(strlen($ban) > 2){
    						$error = "You are trying to ban for more that 99 years. There is no need to ban for longer than that. Change your length to 0 and it automatically do a permanent ban on the user.";
    					}
    
    					else{
    					$year = $year + $year2;
    					}
    			break;
    		}
    
    		for($i=0; $i <= 5; $i++){
    			if($hour > 24 && $hourset == 0){
    				$day = $day + 1;
    				$hour = $hour - 24;
    				$hourset == 1;
    			}
    
    			if($day > $daycount && $dayset == 0){
    				$month = $month + 1;
    				$day = $day - $daycount;
    				$dayset == 1;
    			}
    
    			if($week > 52 && $weekset == 0){
    				$year++;
    				$week = $week - 52;
    				$weekset == 1;
    			}
    
    			if($month > 12 && $monthset == 0){
    				$year = $year + 1;
    				$month = $month - 12;
    				$monthset == 1;
    			}
    
    			if($month == 1){
    				$week = 1;
    
    					if($day >= 7){
    						$week = $day /7;
    						$week = round($week);
    					}
    
    			}
    					if($amount == 4){
    						$week = $month * 4;
    					}
    
    						if($amount == 3){
    							$day = $day + $week * 7;
    								if($day > $daycount){
    									$month = $month +1;
    									$day = $day - $daycount;
    								}
    						}
    		}
    			if(strlen($error) == 0){
    			$fullmoddate = "$month/$day/$year  $hour $week";
    			}
    				else{
    					$fullmoddate = $error;
    				}
    
    		$return[0] = "$fullodate";
    		$return[1] = "$fullmoddate";
    						echo"$fullodate <br /> $fullmoddate <br />";
    
    		echo "<br /><br /> This is a test, something should come up after this. $return[0] and $return[1]";
    		}
    }
    
    ?>
    
    <html>
    <head>
    </head>
    
    <body>
    <script language="JavaScript">
    function onlyNumbers(evt)
    {
    var e = event || evt; // for trans-browser compatibility
    var charCode = e.which || e.keyCode;
    
    if (charCode > 31 && (charCode < 48 || charCode > 57))
    	return false;
    
    return true;
    
    }
    </script>
    
    <form method="POST" action="">
    <input type="text" name="ban" onKeypress="return onlyNumbers();" /> - 
    	<select name="amount">
    		<option value="1">Hours</option>
    		<option value="2">Days</option>
    		<option value="3">Weeks</option>
    		<option value="4">Months</option>
    		<option value="5">Years</option>
    	</select>	
    		<br />
    <input type="submit" value="Submit" name="submit" />
    </form>
    
    </body>
    </html>
    

     

    So im wondering if there is a more efficient way of doing this, or if i just need to keep on going and fix all the little bugs that come with it?

  3. Ok so I'm trying to make this form but its not working, I know it has something to do with the $body var. And when it does sent it doesn't show a sender e-mail or subject.

     

    <?
    include 'other/db_connect.php';
    
    $lostusername = $_POST['username'];
    $lostemail = $_POST['email'];
    
    
    if ($_POST['submit'] && empty($_POST['email'])){
    $error = "You either didn't enter an email or password. You must enter both for security reasons.";
    }
    	if ($_POST['submit'] && empty($_POST['username'])){
    $error = "You either didn't enter an email or password. You must enter both for security reasons.";
    }													 
    
    if($_POST['username'] && $_POST['email']){
    
    
    $lostpassword = mysql_query("SELECT `password` FROM `user` WHERE  `username` = '$lostusername' || 'email' = '$lostemail' LIMIT 1") or die(mysql_error());
    
    $num = mysql_num_rows( $lostpassword );
    $lostpassword2 = mysql_fetch_object( $lostpassword );
    
    if ( $num == '0' ){
    	$error = "Sorry but we could not find a match for the info you have entered.";
    }
    
    elseif ( $num == '1' ){
    	$error = "Your password has been sent!";
    	$Name = "Racing-Generation";
    $email = "NoReply@racing-generation.com"; //senders e-mail adress
    $recipient = $lostemail ; //recipient
    $mail_body = "Hello $lostusername, we understand it that you have lost your password. well dont worry about it. Here is your password below.
    
    Password: $lostpassword2 
    
    Thanks, 
    Racing-Generation
    
    
    Please DO NOT reply to this. This e-mail address is not attended to. We have other e-mails for you to contact us. "; //mail body
    $subject = "Your Password"; //subject
    $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
    
    ini_set('sendmail_from', 'me@domain.com'); 
    
    mail($recipient, $subject, $mail_body, $header); //mail command 
    }
    
    echo"$error";
    									  }
    
    									?>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Racing-Generation - Lost Password</title>
    <style type="text/css">
    <!--
    body {
    background-color:#3f0507;
    font-family: Verdana;
    font-size:12px;
    color:#FFF;
    }
    .row1 {
    font-size: xx-large;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-weight: bold;
    color: #FFF;
    }
    #form1 table {
    text-align: center;
    }
    #form1 table {
    text-align: left;
    }
    -->
    </style>
    </head>
    
    <body bgcolor="#3f0507">
    <form action="" method="post">
      <table width="70%" border="0" align="center" cellpadding="0" cellspacing="5">
        <tr>
          <td colspan="2" class="row1" align="center">Racing-Generation</td>
        </tr>
        <tr>
          <td colspan="2" ><hr align="center" width="80%" noshade="noshade" color="#FFFFFF" />
           <center>If you have lost your password then please enter one of the below. If you do not know your username then we are sorry but you will have to re-register and have an admin find your old account.</center></td>
        </tr>
        <tr>
          <td align="right">E-mail Address:</td>
          <td><input type="text" name="email" ></td>
        </tr>
        <tr>
          <td width="40%" align="right">Username:</td>
          <td><input type="text" name="username" ></td>
        </tr>
        <tr>
          <td width="40%"> </td>
          <td>
            <input type="submit" name="button" value="Submit" >
    
          </td>
        </tr>
        <tr>
          <td colspan="2" align="center"></td>
        </tr>
      </table>
    
      <br />
    </body>
    </html>
    
    

     

    there is the whole code. It has been awhile since I've done any kind of coding so i know there are some mess ups.

  4. well ya i spose. but what im trying to get at is, we have to make the form our site (as far as we understand it) and transfer all the information (ie. The Successful purchase link, the amount etc.) but we have no clue how to do this and havent found a single thing that would actually change the encrypted stuff so that the user cant just copy the form into a freehostia site using the encrypted link for successful payment and get free "Credits".

  5. its a paypal form with a link that sends them back to our game if payment was sent, and then the information is added into our db and the users claim there "Credits". This is for a text based rpg.

  6. Ok i know about SHA and md5 and stuff but as far as i know none of this will work for a paypal POST form, since the encrypted information would always be the same and using them wouldnt matter. So im asking, and yes ive serched this on the forum, google. And im still very new to php. so atleast just point me in the right direction.

     

    thanks,

    Carl

     

  7. Me and my friend are building a text based drag racing game. We are still building it but I would like some beta testing on the stuff we have up now. We had some problems with hacking (hacking users but not the cpanel.) but i think we got that worked out. Theres already quite a bit of features that are up right now but theres still 15 or so more that are going to be added. We are also working on a paypal donation. Once you pay you get credits to get extra stuff. That should be up within a couple days.

     

    If you don't understand the game please say so and i will explain it, since we dont have any kind of instructions on how to play the game since its still in beta mode we dont want to have to keep going back and changing it.

     

    Thanks,

    Carl

  8. ok well for some reason none of this is working, im just going to store the end dates "Days, Hours, Minutes and Seconds" separately in the db. and since i dont have that big of a user count right now ill worry about servers later on when i become a better coder.

     

    But thanks for all the help guys, I really appreciate it. If it wasn't for people like you guys willing to help me I don't think i would get much done.

  9. ok i have a text based game and were trying to incorporate a round feature (so it restarts every week) and i save the end date in the database and im trying to make a countdown (Ex Time left till rounds over: 4 Days, 3 Hours, 34 Minutes, and 43 Seconds.) But first I  need to be able to select the Day, Hour, Minute and Second in seperate querys from a datetime in the database.

  10. Ok i want to make a countdown but i need to be able to select the day, hour, minute, and second from a datetime with the dates entered as Y-d-m H:i:m.

     

    i tried both of these but neither work.

    $day = mysql_fetch_object(mysql_query("SELECT end DAY FROM roundslog WHERE ended='No' AND end>'$date2'"));

     

    And

     

    $day = mysql_fetch_object(mysql_query("SELECT DAY end FROM roundslog WHERE ended='No' AND end>'$date2'"));

     

     

  11. ok functions arent my thing idk how to read them most of the time.

     

    this is what i did and it just echos ago...

     

    $date2 = date('Y-m-d H:i:s');
    $dateee = mysql_fetch_object(mysql_query("SELECT * FROM roundslog WHERE ended='No' AND end>'$date2'"));
    
    if($ulvl == 5){
    $year = mysql_fetch_object(mysql_query("SELECT end YEAR FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $month = mysql_fetch_object(mysql_query("SELECT end MONTH FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $day = mysql_fetch_object(mysql_query("SELECT end DAY FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $hour = mysql_fetch_object(mysql_query("SELECT end HOUR FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $minute = mysql_fetch_object(mysql_query("SELECT end MINUTE FROM roundslog WHERE ended='No' AND end>'$date2'"));
    $seconds = mysql_fetch_object(mysql_query("SELECT end SECOND FROM roundslog WHERE ended='No' AND end>'$date2'"));
    }
    function log_days_ago($start_date, $end_date=NULL)
    {	
    	if($end_date == NULL) {
    		$end_date = strtotime('now');
    	}
    
    	$days = intval( ($end_date - $start_date) / 86400 );
    	$tmp = ($end_date - $start_date) % 86400;
    	$hours = intval($tmp / 3600);
    	$tmp = $tmp % 60;
    	$minutes = intval($tmp / 60);
    	$tmp = $tmp % 60;
    	$seconds = $tmp;
    
    	$diff = ($days == 0) ? "" : $days.' day(s) ';
    	$diff.= ($hours == 0) ? "" : $hours.' hours(s) ';
    	$diff.= ($minutes == 0) ? "" : $minutes.' minutes(s) ';
    	$diff.= 'ago..';
    
    	return $diff;
    }
    
    echo log_days_ago( strtotime('$date2'), strtotime('$dateee->end')  );
    

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