Jump to content

Goose87

Members
  • Posts

    113
  • Joined

  • Last visited

    Never

Everything posted by Goose87

  1. Is it just me or is the code below wrong? $owner = $_SESSION['id']); Remove the bracket and maybe that would help. Like Magnetica said: Just try a print and see if a value comes out. If it does, then the query might be wrong, if it doesn't, then there's something wrong earlier on..
  2. Could anyone look at my code and help me out with this one? Thanks a lot
  3. Ok... my current code that I'm using from a script is below. I haven't managed to add a resizing feature yet. I also modified it to only accept PNGs because it caused problems when displaying it ( I had a file that was $userID.jpg and $userID.jpg and it didn't know which one to show ) I solved the resize problem by just forcing the image, when being displayed, to be fixed to height 200 and width 150. This obviously causes resizing problems, but I'm assuming the users can deal with that problem, as I don't really know what I am doing... <?php include("includes/header.php"); echo "<p class='h1'>Upload an image</p>"; echo "<span class='content_text'>"; //define a maxim size for the uploaded images in Kb define ("MAX_SIZE","30"); //This function reads the extension of the file. It is used to determine if the file is an image by checking the extension. function getExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext; } //This variable is used as a flag. The value is initialized with 0 (meaning no error found) //and it will be changed to 1 if an errro occures. //If the error occures the file will not be uploaded. $errors=0; //checks if the form has been submitted if(isset($_POST['Submit'])) { //reads the name of the file the user submitted for uploading $image=$_FILES['image']['name']; //if it is not empty if ($image) { //get the original name of the file from the clients machine $filename = stripslashes($_FILES['image']['name']); //get the extension of the file in a lower case format $extension = getExtension($filename); $extension = strtolower($extension); //if it is not a known extension, we will suppose it is an error and will not upload the file, //otherwise we will do more tests if (($extension != "png")) { //print error message echo "<p class='h2'>Your image must be in PNG format.</p>"; $errors=1; } else { //get the size of the image in bytes //$_FILES['image']['tmp_name'] is the temporary filename of the file //in which the uploaded file was stored on the server $size=filesize($_FILES['image']['tmp_name']); //compare the size with the maxim size we defined and print error if bigger if ($size > MAX_SIZE*1024) { echo "<p class='h2'>You have exceeded the size limit!</p>"; $errors=1; } //we will give an unique name, for example the time in unix time format $image_name=$user_id.'.'.$extension; //the new name will be containing the full path where will be stored (images folder) $newname="images/profile_avatar/".$image_name; //we verify if the image has been uploaded, and print error instead $copied = copy($_FILES['image']['tmp_name'], $newname); if (!$copied) { echo "<p class='h2'>Copy unsuccessfull!</p>"; $errors=1; include("includes/footer.php"); }}}} //If no errors registred, print the success message if(isset($_POST['Submit']) && !$errors) { @mysql_query("xxxxx"); // HERE I ADDED A QUERY TO SET A VALUE IN THE DB TO 1 TO LET THE PROFILE PAGE KNOW THERE IS AN IMAGE THERE.. echo "<p class='h1'>File Uploaded Successfully!</p>"; include("includes/footer.php"); } ?> <div align='center'> <table width='400'> <tr class='bg1'> <td> <form name="newad" method="post" enctype="multipart/form-data" action=""> <table> <tr><td><input type="file" name="image"></td></tr> <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr> </table> </form> </td> </tr> </table> How does that look? Any advice?
  4. Ok, before anyone gets angry because I'm typing a question that has 1 million posts on the web about, I am posting because I am merely confused.. Every single website I look at uses different methods and has strange functions I am not aware of. I will explain what I need and why I am struggling to do it: Users on my website have a profile. On that profile I would like an image (in the future maybe a number of images) and I would like to let me users upload images to be shown there. I need the following: - Image upload (or entering of url for image on somewhere like imageshack.us for example..) - File verification - Image resizing - Saving of file using the user's ID so it can easily be referred to Every single script I have seen either confuses me, or I have no idea how to edit it to get what I want. I am also extremely worried about the security. That's why I'm thinking letting the users enter a URL to an image uploading website might be a good idea. That way, I can just link to the url. I have yet to find a tutorial on this though. Any help is appreciated. I am not asking for you to do it for me, I merely need a good push in the right direction. Many thanks in advance, Goose.
  5. Im not sure if I made my first post clear or not. First off: if you think there is no money in online text-based games you are completely wrong. One of the people I have been "following" is now making over $80000 a month and was in the national papers for hitting £1,000,000 profit.. I also have a NUMBER of other people who are making healthy £100,000+ a year with their online games.. My game is tiny and it's making me a small sum every year already. Second point: I am not a complete newbie. I have already made my own game. It works. However, I need to get some specific areas that people would recommend becoming pro in. 6 months isn't a long time if you're not working hard. I will be working 10+ hours a day on this, so I know I can learn a lot.. a heck of a lot, as I already have a good understanding of PHP. Regarding the business plan: That is already thought out in my head. I know my aims for my BUSINESS side. I have investors and potential investors lined up in my venture, that isn't a problem. My problem is the languages that you would recommend. I am not going to look into flash. I have no skills in graphical stuff, so I'm not going to waste my time doing any of that. What I want to know is: What are the most crucial languages you would recommend learning that will open up my flexibility with web design. As stated before, I can already code html, css, php, mysql. I have some javascript on my site, but I'm not very good. Would you recommend the following and think it's a good idea: Read a number of books to improve syntax knowledge of php to a "pro" level (stupid wording, but basically get a lot better at PHP). Also look into javascript, mysql, database structure, optimising websites and databases.. How does all that sound to you guys? Is there anything you'd recommend like AJAX or anything similar? Anything you learnt and you thought was priceless?
  6. Dear all, I am posting here to receive some feedback from people who are interested in giving me some information and guidance. I started learning how to code back in June 2007. I worked very hard at PHP and MySQL. I had some basic HTML knowledge at the time.. but I studied hard and have got to a pretty good level with PHP. I built my own online-game which I am still working on today (as I am still a student). I am considering taking a gap-year after I finish my degree (in June this year) and I would like the following information from people: If I spent 6 months studying hard and then 6 months of working on websites to create my dream game development business.. what languages would you recommend learning? I do not have huge skills in graphics design and I have had to outsource my css/html layout design to a third party.. so what would you recommend learning? I want to create high quality, text-based role playing browser games. I already have one, but I want a number of them.. so what do you think? At the moment, I am considering improving my php skills to a very high level, then improving my mysql and database structure skills.. I will also look into more CSS and JavaScript. What is the best use of my time and how would you recommend doing it? I was thinking of buying about 15-20 text-books and going through those for 6 months. I'd then spend 6 months putting that knowledge into practice. If you could all respond with a detailed reply and give as much information as possible I would be extremely grateful. Thanks in advance for your help and assistance. Goose.
  7. don't i have to buy flash to do that? I've done no work with flash ever.. i'm just a self-taught php/mysql developer.. so i haven't had the opportunity to branch off in different directions yet.. could you give me some info and push me in the right direction for that please? i'd be extremely greatful.
  8. Dear all, I am writing this message as I have looked on the internet but my searches have been fruitless. A user of my online game has asked me if I can add a sound notification to a timer that ticks down once every 5 mins or so (when they are playing). This means they could use another browser and it would let them know they can do another action. I have absolutely no knowledge on this area, so if someone could give me some reference material or push me in the right direction, I would be very grateful. Thanks in advance, Goose.
  9. There are two problems: 1) What if the person doesn't add an image shack url? What if they add a www.blahblah.com/powned.exe or whatever.. i don't know what they could add, as I haven't studied this area.. 2) I have NO idea about validation.. It's the other area I've failed in and I've had to had help with aspect.. even though I can code a game lol. When it comes to text validation with all the {4-2} stuff and /*)(){} I get confused.. Could someone help me out and comment it possibly for me? I'd be so grateful if you did.. Many thanks, Goose.
  10. Maybe I need url validation for this? I will have a post form to submit the data into the database.. so maybe I just need to validate it.. Anyone have any good code to validate images from say.. www.imageshack.us for example?
  11. Hi all, I have been looking around on the internet and I've only found one script that's any good and it appears to have no security related to it. I am looking for a script that can let the user submit a url to display a picture (in my case, a profile picture). The profile page will then pull up the picture from the url and display it when the page is loaded. My current method works quite simply: The user can enter the url into the DB with a simple form. The db then pulls that url out and displays it in the following way: <img src='$url' height='200' width='150' alt='Avatar'> Basically like that. It works fine... but.. I'm worried about the following few problems: How can I stop various problems like people using links that are not image files. Also, there might be other methods for people to manipulate the url method and cause huge problems. If anyone can make me aware of it (and help with some code) as I am not very good with verification php, especially when it gets complicated! Thanks in advance, Goose.
  12. Maybe it's a feature I should just forget about? That did cross my mind, but as it's just one query.. i didn't think it would be that bad.. meh.. to be honest, i will look into the code to do it, but I won't implement it. It's just not what I need for that feature I think.. Thanks anyways all.
  13. Dear all, I apologise for my serious lack of knowledge in this area.. and i'm pretty sure that you can't use php, but i just need advice + some support if that's possible. I have recently added a chat feature to my website. It currently displays on every page in the title bar. It displays 30 rows of chat and updates every time the page is changed or refreshed. I would like the mysql query that collects the latest messages to update every 5-10 seconds if that's possible.. or ideally... update when there is a new post.. that would be perfect.. Can someone point me in the right direction. Or ideally, help me out with this. Many thanks in advance. Goose.
  14. Thanks for the response. I have a couple more questions on this matter though.. 1) I have a session variable for the id of the user when they are logged into my website and a session for the username. Should I create another session for the forums that they are viewing, then if they log out (or the session ends) I have to reallocate that same forum session back to that user, correct? 2) You said I have to store the ID of the session in the database. I need some clarification on what exactly you mean by this. I wasn't aware that sessions could have IDs and that you could store just an ID and it would keep the values you store in them. 3) My array knowledge is rather poor, so I will have to read up on it.. but I have to store something like $array = array ($post1, $post2, $post3, $post4); correct? Then I have to explode the array to get those values and then add to them when I want to add more posts that they have read? 4) You said "session id cookie". Does that mean I need to store a cookie on their computer, and have a session related to that cookie?? I also don't use cookies, I just use sessions on my website.
  15. for #1 I understand that you can have a "viewed" in the database field, but there might be 1000 users that want to view it, how to I distinguish between the users? That's why I was thinking I would need to create a table for "post id", "user id", "viewed", but I'm pretty sure that is very inefficient.. Regarding storing the session.. what do you mean by store the id of the session into the DB, store the values of that session? You lost me a little bit there.. for #2 Ah ok, that's an interesting idea with the loop function and using an array. That makes the scalability a little easier, but still slow. Any other ideas for that one? (your idea is still a vaste improvement on mine! ) What makes you say php rand isn't completely random? I know they say computers can't produce a truly "random" value, or is there something actually wrong with it? Thanks for the response
  16. Dear all, I have the following two questions, something which has been bugging me for a while and I can't resolve them on my own. Some outside input would be grately appreciated: 1) Showing users which posts are unread and new in forums. I want to create an in-game forum (not a free external one). Everything works except showing people which posts are new and they haven't read, i.e. when you all wanted to see this one, you could see it in orange, when someone else replies, the other people then see a new post. So far I can easily show a new post with a time variable, simple, however... if someone reads a new post, I need it to go back to normal text, because they've read it. The only method I can think of at the moment is to have a table storing which posts people have read, but I know that's the worst idea ever created by a code Some advice on this would be happily accepted 2) This is a little bit harder to explain, but lets say I have 10 options. I am then having a rand(1,100) created to find the value. At the moment I have: if($rand>0 and $rand<20){ do something } if($rand==99){ do something } for 20% chance ofsomething happening and 1% chance of someting happening. This is very annoying to code, and VERY hard to scale up, especially if you want to add more things to the equation. If someone could please give me some input into this problem, I would also be extremely grateful. Many thanks in advance, I really appreciate the time you're spending to read this/help me. Goose.
  17. Could anyone else give me some insight into this please? Which bits do I need to change? thanks
  18. Ok, I have read some information about that..but it says that the max font can be put as 5, the font I have is too small, so how do I make it bigger? Could you also confirm if I only have to change the parameters for the top-left and bottom-right part to make the clicking area bigger? Will this make the grid inside bigger too? Can someone point me at which lines I need to edit, I want to get this right first time and done quickly, as I've spent so much time on this previously with no results. Many thanks, Goose.
  19. Hey everyone, I have a script that validates the users that use my website with a box displaying 9 numbers. They have to click the number that is displayed at the top with the "Click 9" for example, and they have to click 9 in the list. The problem I have is that the script was given to me by a friend, and I can't work out how to make the boxes/text bigger. I have fiddled before and the results have been fruitless.. If someone could post back to me with the areas I need to change, and what I have to change, I would be extremely grateful. the first page is below: <?php ////////////////////////////////////////////////////////////// ///////////////////////////////////////////// if($_SESSION['validated'] == 1) { //changed the = with == echo "<meta http-equiv=\"refresh\" content=\"0;URL=$destination.php\">"; exit(); } //buffer ob_start('ob_gzhandler'); // if submit if ($_POST[x]){ // posted $x = $_POST[x]; $y = $_POST[y]; // decode and round number $aa = round(base64_decode($_SESSION['afloat'])); // x&y coords $xc[1] = ($x >= 1) && ($x <= 17); $xc[2] = ($x >= 18) && ($x <= 36); $xc[3] = ($x >= 37) && ($x <= 53); if (($y >= 18) && ($y <= 35)){$ab = $aa;} elseif (($y >= 36) && ($y <= 51)){$ab = $aa - 3;} else {$ab = $aa - 6;} //demo ERROR message below $mess = "ERROR"; // if ($xc[$ab]){ // submit your form //demo SUCCESS message below $mess = "SUCCESS"; } //demo alert message below if($mess=='SUCCESS'){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=$destination.php\">"; exit(); } if($mess=='ERROR'){ echo "<meta http-equiv=\"refresh\" content=\"0;URL=validate_$destination.php?msg=error\">"; } ob_end_flush(); exit; } $afloat = base64_encode(" " . $num1 = rand(1, . "." . $num2 = rand(100,999) . " "); // rectangle y coord $aler = "> 18"; // create random image $_SESSION[igif] = "image_grid.php?a=" . $afloat . ""; $_SESSION['afloat'] = $afloat; ?> <html> <head> <style type="text/css"> /* click image */ .cd { width: 54px; height: 69px; background-image: url(<?=$_SESSION[igif];?>); background-repeat: no-repeat; position: relative; left:<?=rand(-100,100);?>px; bottom:<?=rand(25,25);?>px; z-index: 2; } </style> <script language="JavaScript"> // submit form func function submitform() { // if box coord submit else rectangle coord alert // Do not edit javascript below this line. you can edit the alert message if (document.xycoords.y.value <?=$aler;?>) { document.xycoords.submit(); } else { alert("Click number in square identicale to number in rectangle to submit."); } } // image x&y value function xycoord(event) { imagex = event.offsetX?(event.offsetX):event.pageX-document.getElementById("coord").offsetLeft; document.xycoords.x.value = imagex; imagey = event.offsetY?(event.offsetY):event.pageY-document.getElementById("coord").offsetTop; document.xycoords.y.value = imagey; } </script> <div align="center"><form name="xycoords" action="<?=$_SERVER['PHP_SELF']; ?>" method="post"> <table summary="" border="0"> <tr> <!-- include hidden form input: x >>>>>--><input type="hidden" name="x" /><!-- include hidden form input: y >>>>>--><input type="hidden" name="y" /> <td><span class="h1">Verify yourself</span></td> </tr> </table> </form><!-- This line >>>> <div id="coord" onclick="submitform(xycoord(event))" class="cd"></div> >>> Must be outside of form tags <form></form> to work in FF, NS and Opera >>>> --> <p><br></p><div id="coord" class="cd" onclick="submitform(xycoord(event))"></div> </div> <div align="center"> <?php if($_GET['msg']=="error"){ $msg="<span class='error'>Incorrect Choice. Please click the right number</span>"; echo "$msg"; } ?> </div> </body> </html> <? ob_end_flush();?> The second script which is included in this file is: <?php //buffer ob_start('ob_gzhandler'); session_start(); //DEC 67 //get a, decode and round // $a = $_GET['a']; if ($a == $_SESSION['afloat']){ $aa = round(base64_decode($a)) - 1; $im = imagecreatetruecolor (54, 69); //DEC 79 //random numbers // $myn = array(1, 2, 3, 4, 5, 6, 7, 8, 9); $rn = array_rand($myn, 9); $string1 = "" . $myn[$rn[0]] . " " . $myn[$rn[1]] . " " . $myn[$rn[2]] . ""; $string2 = "" . $myn[$rn[3]] . " " . $myn[$rn[4]] . " " . $myn[$rn[5]] . ""; $string3 = "" . $myn[$rn[6]] . " " . $myn[$rn[7]] . " " . $myn[$rn[8]] . ""; $mynum = "" . $string1 . " " . $string2 . " " . $string3 . ""; //DEC 68 DEC 69 DEC 66 DEC 89 DEC 82 //string, random click number and line coord $na = 17; $nb = 54; $nc = 0; $nd = 54; $ab = explode(" ", $mynum); $mystring = "Click $ab[$aa]"; //random image color // $change = rand(1,9); $lime = imagecolorallocate($im,0,255,0); $yellow = imagecolorallocate($im,255,255,0); $white = imagecolorallocate($im,255,255,255); $lgray = imagecolorallocate($im,206,206,206); $gray = imagecolorallocate($im,115,115,115); $black = imagecolorallocate($im,0,0,0); $green = imagecolorallocate($im,1,107,0); $grc = " $lime $yellow $white $lgray $yellow $white $gray $black $green"; $rc = explode(" ", $grc); $bgc = $rc[$change]; //DEC 72 //line & number colors // $bc = imagecolorallocate ($im, 0, 0, 0); $rd = imagecolorallocate ($im, 255, 0, 0); $wh = imagecolorallocate ($im, 255, 255, 255); //DEC 73 //if color = this change line & number color // if (($change > 3) && ($change < 7)) { $bc = $rd;} elseif ($change > 6) { $bc = $wh;} //DEC 67 //fill image color // imagefilledrectangle ($im, 0, 0, 54, 69, $bgc); imagerectangle ($im, 0, 0, 53, 68, $bc); //DEC 75 //vertical lines // for($i=$na;$i<=$nb;$i+=19) imageline($im,$i,17,$i,(69)-2,$bc); // Horizontal Lines for($i=$na;$i<=$nb;$i+=17) imageline($im,2,$i,(54)-2,$i,$bc); //DEC 69 //image string // imagestring ( $im, 5, 5, 18,$string1, $bc); imagestring ( $im, 5, 5, 35,$string2, $bc); imagestring ( $im, 5, 5, 52,$string3, $bc); imagestring ($im, 3, 2, 3, "$mystring", $bc); //DEC 89 //header content // header("Content-Type: image/gif"); //DEC 48 //send image // imagegif($im); //DEC 55 //destroy image // imagedestroy($im); } //flush ob_end_flush(); ?> Thank you in advance everyone Goose.
  20. Ah ok, I see what you mean that my statement was quite broad and too vague to give a detailed response. The website I run is a game. The users have to click a button once every 5 minutes for some activities, and I want to stop the user being able to do that. It isn't a problem if it's more than once every 15 minutes, but it's every 5 minutes that's a problem. It also isn't a problem if the user goes to a different page and comes back, what I am trying to stop is auto-refreshers. If the user is there, it's fine, but I don't want the people to be able to press the submit button, then wait 5 minutes, and press f5 (or an auto-refresher doing that), I just want them to press the same button again. The problem with a session in that respect is that I don't have a problem if they are on the same page and do it again, I have a problem if they submit the form again without refreshing. I think the following MIGHT work: The user submits the form. A value is stored in the database. If they were to press f5, the form submitted would be the same value as the value stored in the form, thus causing an error. If they were to press the button that is on the same page 5 mins later, the link would be new, thus removing all problems. I'm really tired at the moment, so I can't think properly, but I feel that there is a loophole to that method somehow..
  21. I need to stop users on my website refreshing the page. I know a website that has a number in the url and calls that the refresh code, but I have tried to replicate it and have failed.. I couldn't get the same two values to go across the script. Could someone please give me some sort of indication of the way to do it, as I REALLY need this feature on my website as soon as possible... Thanks in advance! Goose.
  22. I haven't tested it, but an idea.. Add the: if(isset..... just before the include on the first script. This way it pulls the data from the first page, and can then use it in the sideadmin_t2.php as it's below that. Hope that helps. Goose.
  23. Dear all, I have the following script, but there is a problem that I am not sure how to resolve. Someone looked at this before and mentioned that the reason it didn't display straight away was because the timer minuses one second, and then displays. This looks very unprofessional. If someone could help me out and adjust the script to show the timer instantly as the page loads, I would be extremely grateful. If you could mention which bit you adjusted too, I would appreciate it as I want to learn. Thank you to all in advance, James <script type = "text/javascript"> var timeInSecs = null; var ticker = null; function startTimer(secs){ timeInSecs = parseInt(secs); ticker = setInterval( "tick( )", 1000 ); } function tick() { var secs = timeInSecs; if (secs > 0) { --timeInSecs; } else { clearInterval( ticker ); } var hours = Math.floor( secs / 3600); secs %= 3600; var mins = Math.floor( secs / 60 ); secs %= 60; var pretty = ( (hours < 10 ) ? "0" : "" ) + hours + ":" + ( (mins < 10) ? "0" : "" ) + mins + ":" + ( (secs < 10) ? "0" : "" ) + secs; document.getElementById("countdown").innerHTML = pretty; } startTimer(<?php echo "$timer"; ?>); </script>
  24. Brilliant, that works Thanks a lot for helping me with that I can now release my new login script!
  25. Dear all, I have a problem with a login script I am improving. At the moment I am using a type='submit' button with CSS styling, but I want to change this and add an image. I found on the internet that you can have type='image', but I can't get the button to submit. It just loads up the action='login.php'. The code I am using is: <form method='post' action='login.php' name='auto_login'> <input type='text' size='20' maxlength='20' name='username' class='textfield2' value='username'> <input type='password' size='20' maxlength='20' name='password' class='textfield2' value='password'> <input type="image" src="images/login_button.jpg" value="Submit" alt="Submit" name="top_submit" /> </form> Then when I want to see if the button is pressed I have: if(isset($_POST['top_submit'])){ echo "BUTTON PRESSED"; } but the text never appears. Does anyone have any ideas? As I am pretty stuck on this Thanks in advance to everyone who helps me.
×
×
  • 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.