Jump to content

nightkarnation

Members
  • Posts

    161
  • Joined

  • Last visited

Everything posted by nightkarnation

  1. The thing is that I need to do some automatic special features on different seconds...and I need to retrieve every single second in order to send these special features (from an outside application running every second through php).
  2. I have a dedicated server. I need to do this, to retrieve the server date every second. I know this would be easily fixed performing a calculation with just retrieving once the server date but I also need to know each second if there has been a new bid for any auction (its an auction site) Any suggestions? Thanks a lot!
  3. Hey Guys, I need some help and/or suggestions on how to apply the following: Simple Example Code: $result = mysql_query("SELECT Last_B_Time FROM MAIN WHERE Id = '$id'"); $cant = 0; while($row=mysql_fetch_array($result)) { echo "Last_B_Time$cant=$row[Last_B_Time]&"; $cant++; } I want this simple code/query and echo to be executed every second (not once), directly when test.php is opened. What is the best way to do this? Using a timer? Thanks a lot in advance!
  4. Hey Guys! I have a website in flash where some users can upload a jpg, jpeg image to my server and then approved or denied... The image is resized to 1000 x 1000 max (if its higher than those numbers) I am afraid that my script doesnt have any kind of protection to hacks like "virus.php.jpg" or any other type of attacks due to the lack of knowledge I have on this subject. I am a little bit lost as to what I could do to prevent some of these attacks... I would really appreciate some feedback and or basic lines of prevention code to prevent at least some basic attacks Heres my php code for the image upload: // Set local PHP vars from the POST vars sent from flash $Name = $_POST['Name']; $itemNumber = $_POST['imageType']; $filename = $_FILES['Filedata']['name']; $filetmpname = $_FILES['Filedata']['tmp_name']; $fileType = $_FILES["Filedata"]["type"]; $fileSizeMB = ($_FILES["Filedata"]["size"] / 1024 / 1000); list($filename, $extension) = explode('.', basename($_FILES['Filedata']['name'])); $filename = $Name; $target = $filename . $itemNumber . "." . $extension; // Place file on server, into the images folder move_uploaded_file($_FILES['Filedata']['tmp_name'], "../Winner_Images/".$target); ini_set("memory_limit","30M"); $source_pic = "../Winner_Images/".$target; $destination_pic = "../Winner_Images/".$target; $max_width = 1000; $max_height = 1000; $src = imagecreatefromjpeg($source_pic); list($width,$height)=getimagesize($source_pic); $x_ratio = $max_width / $width; $y_ratio = $max_height / $height; if( ($width <= $max_width) && ($height <= $max_height) ){ $tn_width = $width; $tn_height = $height; }elseif (($x_ratio * $height) < $max_height){ $tn_height = ceil($x_ratio * $height); $tn_width = $max_width; }else{ $tn_width = ceil($y_ratio * $width); $tn_height = $max_height; } $tmp=imagecreatetruecolor($tn_width,$tn_height); imagecopyresampled($tmp,$src,0,0,0,0,$tn_width, $tn_height,$width,$height); imagejpeg($tmp,$destination_pic,100); imagedestroy($src); imagedestroy($tmp); Thanks a lot in advance!! Cheers!
  5. Hey Guys! I am currently creating a website that will do pretty much what Swoopo does. I am creating the engine with Flash (Actionscript 3.0) + Php + Mysql. My question is the following: I know I need a dedicated server in order to handle the big amount of queries and have the queries process faster than they would with a shared server, right? I would like to have some suggestions on what kind of Dedicated Server I should be looking for and any specific tip to have faster queries. For example I was told that the Battery Backed-up unit, allows to activate write-caching and greatly speed disk access, which is needed for fast queries Is this true? Thanks a lot for any help and/or suggestions! Cheers!
  6. Thanks a lot for the kind help! LOCK TABLE helped a lot !
  7. Hello Guys, I would really appreciate some feedback on this one. Here's the basic simplified code for my bidding system site (querys for when a user sends a new valid bid): Its working fine but if 2 users send a bid at exactly the same precise moment (even same milliseconds), I have 2 problems (described below code, for better understanding) Please picture this code as if its happening 2 times at the same time (from 2 different users) $time = microtime(true) * 10000; $result = mysql_query("UPDATE `AUCTIONS` SET Current_Price = Current_Price + '$increase_price', Bids = Bids + 1, Bidder = '$bidder', Bidder_Time = '$bidder_time' WHERE PId = '$id'"); //grab the current price to save on bidding history DB if($result) { $resultPrice = mysql_query("SELECT Current_Price FROM AUCTIONS WHERE PId = '$id'"); while($row=mysql_fetch_array($resultPrice)) { $current_price = $row['Current_Price']; } if($resultPrice) { $result = mysql_query("INSERT INTO `BIDDING_HISTORY_DB` (Id, Bidder, Bidder_Time, Raw_Time, Ip, Type, Bid_Amount) VALUES ('$id', '$last_bidder', '$last_bidder_time', '$time', '$client_ip', '$credit_type', '$current_price')"); } } If 2 users bid at exactly the same SAME moment, its possible that on BIDDING_HISTORY_DB... I get the Bid_Amount field with the same value (when it should be always 1 number higher than the previous) ( Bid_Amount is coming from $current_price) $current_price grabs the new updated value from the AUCTIONS DB on the first query (Current_Price = Current_Price + '$increase_price'). So its impossible to have 2 values that are the same (at least I am not expecting that), but I realized that if the query from 2 users are being processed at the same time and the UPDATE AUCTIONS query is processed 2 times and AFTER THAT then the SELECT Current_Price FROM AUCTIONS WHERE PId = '$id' is processed on both bids...that is when the Current_Price is grabbed with the same value for both USERS!! Any ideas on how I can find a solution to this ??? The other problem is that I am knowing which bid was made (by which user) before/after because of the $time variable. But sometimes when 2 bids are made at the SAME precise time with the same milliseconds (yes it happens) ... this is when problems arise (because 1 user could have as Current_Price 10.11 and the other one 10.12 and then on DB the user with 10.12 could be shown as if he made the bid first, any ideas/suggestions on how I can find a solution to this?
  8. Awesome! Thanks a lot to all of you for your kind help! I changed to php5 and now works great.
  9. Please take a look at the following code (this would work if the statement was SELECT instead of UPDATE) But I need to grab the following: $result = mysql_query("UPDATE `AUCTIONS_MAIN` SET Current_Price = Current_Price + '$increase_price', Last_Bidder_Time = '$last_bidder_time' WHERE PId = '$id'"); //grab the new updated current price to save on different bidding history DB while($row=mysql_fetch_array($result)) { $current_price = $row['Current_Price']; } As you can see, I need to give the new Current_Price value to the $current_price variable. Obviously the while function is incorrect, I would really appreciate any ideas and/or suggestions on how I can grab this value. PS: I can't make a new query call with a select statement in order to know the new Current_Price. I need the direct updated value coming from the Update Statement, is this possible? Thanks a lot in advance!!
  10. Hey Guys, I have the following problem. I have a lot of users sending querys to my DB at the same time, and for example each time a user sends the query, a field with a number increases. Sometimes that number increases like this: 10.11, 10.12, 10.13, 10.15, 10.14 When it obviously should be: 10.11, 10.12, 10.13, 10.14, 10.15 Maybe (in this example) the query from 10.15 finished first (got inserted on DB) than the query from 10.14. My question is if there is some kind of function or line of code to have some kind of queue between the Querys...so if a query that is received first must finish and the the next can go ahead and query. Hope I am making myself clear, Looking forward any kind of help and/or suggestions. Thanks a lot in advance!
  11. Mark, Using it alone, I am getting: 2601.34 Could it be becuase I have php 4 instead of 5??? Thanks a lot!
  12. Thanks a lot for all your help! Markjoe I tried your code and I get a 4 value number... And based on that I tried: $time = time(); //for Raw_Time $timeSec = microtime(true)*10000; $time = $time . $timeSec; But instead of adding the value with 4 numbers after the time, I think its being added to the time result. Any ideas on how I can format this better than what I am doing?
  13. Yes I already tried that. Thanks a lot. The problem is that for example on my DB...the value from $time = time(); is being stored on a field called Raw_Time with Data Type int(32) And when I use $time = microtime(); I get on DB a 0 value... And I need the int type on the Raw_Time because I need to: ORDER BY `CLICKING_HISTORY`.`Raw_Time` DESC LIMIT 0 , 10 I apologize for not explaining this before. Looking forward for any suggestions or ideas. Thanks a lot in advance!
  14. Hey Guys. I have the following problem on mysql database: With php using $time = time(); I receive for example: 1302638294 I need something more accurate than this because sometimes I receive on my DB the same value (2 times) and it generates some conflicts due to the fact I am using this information to know which user sent some information, first, second, etc... Does anyone have any suggestions on how I can solve this problem? Thanks a lot in advance! Cheers.
  15. This is what I tried: $result = mysql_query("SELECT Last_User_Time FROM ATS_MAIN WHERE Id = '$id'"); while($row=mysql_fetch_array($result)) { $last_time = $row['Last_User_Time']; } $new_last_time = date('D M j H:i:s \G\M\TO Y',strtotime($last_time) + 30); echo $new_last_time;
  16. Ken! Thanks a lot for your help! I tried your code and I am getting the following date: Wed Dec 31 21:00:29 GMT-0300 1969 Any ideas why?? Thanks a lot! Cheers,
  17. Guys...I am not making myself clear and I apologize for that. $last_time already equals Thu Mar 10 18:33:48 GMT-0300 2011 I am grabbing $last_time with that value already from DB... I need now to add 30 seconds to $last_time that has that date... Based on what you guys tought me, I tried this line: $last_time = date($last_time,strtotime('+30 seconds')); It is working but the date format changed a bit and I need the format to be exactly the same only with the 30 seconds added. Thu Mar 10 18:33:48 GMT-0300 2011 (Already grabbed from server) Thu Mar 10 18:34:18 GMT-0300 2011 (Is my goal with script modification) Any ideas?? Thanks a lot !!
  18. Thanks a lot JcBones!! That works great!! but I have one more problem though and I really think you can fix this easily... $last_time already has the date as a value ($last_time already equals: Thu Mar 10 18:33:48 GMT-0300 2011) But now I need $last_time to +30 seconds... I tried: $last_time = date('$last_time',strtotime('+30 seconds')); But obviously is not working, any ideas and/or suggestions? Thanks a lot again!
  19. Hello Mahngiel First of all, thanks a lot for your kind help. I have googled php time and php date but couldnt find what I was looking for, I am trying to implement the line of code you gave me but I cant seem to get it to work... I tried the awful code below: $addtime = time() + ( 0* 0 * 0 * 30); echo "last_time=".$last_time + $addtime; $last_time = $last_time + $addtime; Obviously is not working, any ideas and/or suggestions? Thanks a lot in advance!
  20. Hey guys! I have the following doubt, I have a Date value and I want to add to that date 30 seconds plus. Example: $last_time = date('D M j H:i:s \G\M\TO Y'); //echo: Thu Mar 10 18:33:48 GMT-0300 2011 I need the following date: Thu Mar 10 18:33:48 GMT-0300 2011 to become: Thu Mar 10 18:34:18 GMT-0300 2011 This means that the retrieved Date now has 30 more seconds... Any ideas?? Looking forward to any help, Thanks a lot in advance, Cheers!
  21. Thanks a lot Jc, It works now! I have Version 4.4.9, could that be the reason?
  22. First of all, Thanks a lot guys for the help! Jcbones, that line of code is 95% correct to what I need, theres only one slight change, I am echoing the following: Fri Mar 4 18:10:25 e-0300 2011 and it should be: Fri Mar 4 18:10:25 GMT-0300 2011 Any ideas and/or suggestions? Thanks again! Cheers!
×
×
  • 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.