Jump to content

salvador2001

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

salvador2001's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Got two work arounds, wich doesnt solve the original problem but it is better than zip. My guess is that there must be something wrong with the coding, it doesnt accept images for some reason i cant figure out... Damn... But i am creative, i have placed a background image top left and that image says, now playing (bla bla) Under the print $ i have put a img tag with a image wich says that the server is off-line. This page i loaded into a iframe with solid dimensions. Now, when there is no server, its got nothing to print and the first it will show on the page is the offline image. When there is a server, the script will print out its collected data and the image underneath it will shift down due to the text that is printed. Automaticly you can see the background image wich says the server is running plus the printed data. I hope you understand what i did. The second workaround is a extra script, also loaded in a iframe which only shows map images. But i didnt have found a secondary script wich can do that job. Thanks for youre effords to help me, and if you got any clou, please let me know ! Thanks again !
  2. only the regular server info... ??? is the extra script in the right position ? it is just a thougt... [code<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>GameQ - Example script</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="refresh" content="9"> <style type="text/css"> * { font-size: 9pt; font-family: Verdana, sans-serif; } h1 { font-size: 9pt; } h2 { font-size: 10pt; } h3{ font-size:12px; font-weight:normal; margin:0; } table { border: 1px solid #000; background-color: #DDD; border-spacing:1px 1px; } table thead { font-weight: bold; background-color: #CCC; } table tr.uneven td { background-color:#FFF; } table td { padding: 5px 8px; } table tbody { background-color: #F9F9F9; } .note { color: #333; font-style:italic; } .key-always { color:red; font-weight:bold; } .key-normalise { color:red; } </style> </head> <body> <h2> </h2> <h1>24/7 Road to Jalalabad Robert Reed's House of A.I.D.S</h1> <h1>battlefield2</h1> <h3>Road To Jalalabad</h3> <h3>gpm_cq</h3> <h3></h3> <h3>69.12.98.120</h3>
  3. First of all, thanks that you ar willing to help me with this, i appreciate it very much ! Here is the code that is running at this moment: I correct a little type mismatch, and now it is showing nothing at all ! The error was in $map_image= array ( Originaly there was another string declared. ($map_plaatje..... ) <?php error_reporting(E_ALL); require_once 'GameQ.php'; // Define your servers, // see list.php for all supported games and identifiers. $servers = array( ' ' => array('bf2', '69.12.98.120', 29900), ); // Call the class, and add your servers. $gq = new GameQ(); $gq->addServers($servers); // You can optionally specify some settings $gq->setOption('timeout', 200); // You can optionally specify some output filters, // these will be applied to the results obtained. $gq->setFilter('normalise'); $gq->setFilter('sortplayers', 'gq_ping'); // Send requests, and parse the data $results = $gq->requestData(); // Some functions to print the results function print_results($results) { foreach ($results as $id => $data) { printf("<h2>%s</h2>\n", $id); print_table($data); } } function print_table($data) { $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type'); if (!$data['gq_online']) { printf(""); return; } print("<h1>$data[hostname]</h1>"); print("<h1>$data[gamename]</h1>"); print("<h3>$data[gq_mapname]</h3>"); print("<h3>$data[gq_gametype]</h3>"); print("<h3>$data[game_descr]</h3>"); print("<h3>$data[gq_address]</h3>"); $map_image= array ( 'zatar_wetlands' => 'zatar_wetlands.jpg', 'Road To Jalalabad' => 'road_to_jalalabad.jpg', ); // the code i inserted if(array_key_exisits($data['gq_mapname'], $map_image)) { $image = $map_image[$data['gq_mapname']]; } else { $image = 'noserver.jpg'; } echo '<img src="'.$image.'" />'; // End inserted code die(nl2br("Give us this output:\n".print_r($data, true))); foreach ($data as $key => $val) { if (is_array($val)) continue; $cls = empty($cls) ? ' class="uneven"' : ''; if (substr($key, 0, 3) == 'gq_') { $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise'; $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key); } printf("", $cls, $key, $val); } print(""); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>GameQ - Example script</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="refresh" content="9"> <style type="text/css"> * { font-size: 9pt; font-family: Verdana, sans-serif; } h1 { font-size: 9pt; } h2 { font-size: 10pt; } h3{ font-size:12px; font-weight:normal; margin:0; } table { border: 1px solid #000; background-color: #DDD; border-spacing:1px 1px; } table thead { font-weight: bold; background-color: #CCC; } table tr.uneven td { background-color:#FFF; } table td { padding: 5px 8px; } table tbody { background-color: #F9F9F9; } .note { color: #333; font-style:italic; } .key-always { color:red; font-weight:bold; } .key-normalise { color:red; } </style> </head> <body> <?php print_results($results); ?> </body> </html>
  4. I think you ment the source code of the website page ? Here it is: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>GameQ - Example script</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="refresh" content="9"> <style type="text/css"> * { font-size: 9pt; font-family: Verdana, sans-serif; } h1 { font-size: 9pt; } h2 { font-size: 10pt; } h3{ font-size:12px; font-weight:normal; margin:0; } table { border: 1px solid #000; background-color: #DDD; border-spacing:1px 1px; } table thead { font-weight: bold; background-color: #CCC; } table tr.uneven td { background-color:#FFF; } table td { padding: 5px 8px; } table tbody { background-color: #F9F9F9; } .note { color: #333; font-style:italic; } .key-always { color:red; font-weight:bold; } .key-normalise { color:red; } </style> </head> <body> <h2> </h2> <h1>24/7 Road to Jalalabad Robert Reed's House of A.I.D.S</h1><h1>battlefield2</h1><h3>Road To Jalalabad</h3><h3>gpm_cq</h3><h3></h3><h3>69.12.98.120</h3>
  5. I am not sure, my php experience is very poor. I tried but failed. Got any suggestions for this part ? please let me know. Thanks in advance.
  6. Hi, I tried it but i got no extra info than the usual things. (servername, type, map name and ip)
  7. else { $image = 'noserver.jpg'; } i think this is correct, i dont see an extra ' in it. But where should i put the printr command ?
  8. Hello, I am using a server status script from GameQ and it works fine. But i want to add some map pictures and i cant get it to work. I have added a little script into it, but somehow it wont work at all. I do hope someone can help me out on this, my knowledge of PHP is poor at this time. Here is the code, i have marked up the inserted part: <?php error_reporting(E_ALL); require_once 'GameQ.php'; // Define your servers, // see list.php for all supported games and identifiers. $servers = array( ' ' => array('bf2', '69.12.98.120', 29900), ); // Call the class, and add your servers. $gq = new GameQ(); $gq->addServers($servers); // You can optionally specify some settings $gq->setOption('timeout', 200); // You can optionally specify some output filters, // these will be applied to the results obtained. $gq->setFilter('normalise'); $gq->setFilter('sortplayers', 'gq_ping'); // Send requests, and parse the data $results = $gq->requestData(); // Some functions to print the results function print_results($results) { foreach ($results as $id => $data) { printf("<h2>%s</h2>\n", $id); print_table($data); } } function print_table($data) { $gqs = array('gq_online', 'gq_address', 'gq_port', 'gq_prot', 'gq_type'); if (!$data['gq_online']) { printf(""); return; } print("<h1>$data[hostname]</h1>"); print("<h1>$data[gamename]</h1>"); print("<h3>$data[gq_mapname]</h3>"); print("<h3>$data[gq_gametype]</h3>"); print("<h3>$data[game_descr]</h3>"); print("<h3>$data[gq_address]</h3>"); $map_plaatje = array ( 'zatar_wetlands' => 'zatar_wetlands.jpg', 'Road To Jalalabad' => 'road_to_jalalabad.jpg', ); // the code i inserted if(array_key_exisits($data['gq_mapname'], $map_image)) { $image = $map_image[$data['gq_mapname']]; } else { $image = 'noserver.jpg'; } echo '<img src="'.$image.'" />'; // End inserted code foreach ($data as $key => $val) { if (is_array($val)) continue; $cls = empty($cls) ? ' class="uneven"' : ''; if (substr($key, 0, 3) == 'gq_') { $kcls = (in_array($key, $gqs)) ? 'always' : 'normalise'; $key = sprintf("<span class=\"key-%s\">%s</span>", $kcls, $key); } printf("", $cls, $key, $val); } print(""); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>GameQ - Example script</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta http-equiv="refresh" content="9"> <style type="text/css"> * { font-size: 9pt; font-family: Verdana, sans-serif; } h1 { font-size: 9pt; } h2 { font-size: 10pt; } h3{ font-size:12px; font-weight:normal; margin:0; } table { border: 1px solid #000; background-color: #DDD; border-spacing:1px 1px; } table thead { font-weight: bold; background-color: #CCC; } table tr.uneven td { background-color:#FFF; } table td { padding: 5px 8px; } table tbody { background-color: #F9F9F9; } .note { color: #333; font-style:italic; } .key-always { color:red; font-weight:bold; } .key-normalise { color:red; } </style> </head> <body> <?php print_results($results); ?> </body> </html>
  9. Exuse me for the late reply, i was in hospital. Thanks allot, it works fine now !
  10. Hello, I want to change this script for admin use. What i want is that you dont have to browse for an image, but is set to the dir where the image to be uploaded is. For example www.mysite.com/folder Also, if possible, i want an auto sumit. The idea is that an admin can call this script on a admin section of the website (that is no problem at all) and that the image will be uploaded automaticly. Can anyone help me out ? Thanks in advance, Greetings, Jack <html> <form enctype="multipart/form-data" action="<?print $_SERVER['PHP_SELF']?>" method ="post"> <tr><td><input type = "hidden" name="MAX_FILE_SIZE" value = "102400"></td></tr> <tr><td>Select File: </td><td><input type = "file" name = "fupload"><t/d></tr> <tr><td><input type = "submit" value = "Upload!"></td></tr> </table> <?php //checking and uploading file----------------------------------------------------------- if (isset ($_FILES['fupload'])){ $filename = $_FILES['fupload']['name']; $randomdigit = rand(0000,9999);//create random digit $newfilename = $randomdigit.$filename;//make new file name with random digit //printing file information print "<table>"; print "<tr><td>Original Name:</td><td> ". $_FILES['fupload']['name']."</td></tr>"; print "<tr><td>New Name:</td><td> ".$newfilename."</td></tr>"; print "<tr><td>Size: </td><td>". $_FILES['fupload']['size']."</td></tr>"; print "<tr><td>Temp Name: </td><td>". $_FILES['fupload']['tmp_name']."</td></tr>"; print "<tr><td>Type: </td><td>". $_FILES['fupload']['type']. "</td></tr>"; print "<tr><td>Error: </td><td>". $_FILES['fupload']['error']. "</td></tr>"; print "</table>"; //checking the type of file, if it is image it will display it if ($_FILES['fupload']['type'] == "image/jpeg"){ $source = $_FILES['fupload']['tmp_name']; $target = "upload/".$_SESSION['username']."/".$newfilename; move_uploaded_file($source, $target); // or die ("Couldnt copy"); //displaying the image $imagesize = getImageSize($target); $imgstr = "<p><img width=\"$size[0]\" height=\"$size[1]\" "; $imgstr .= "src=\"$target\" alt=\"uploaded image\" ></p>"; $imagepath = $yoursite.$target; print $imgstr; print "The link to your image is: ".$yoursite.$target;//link to the image } } //------------------------------------------------------------------------------------- ?> </html>
  11. Ahh thanks !! I replaced it and deleted the form field wich handles the question wich size it should be and it works perfect. I had changed the form field and didnt saw the declaration above it, stupid... Greetings, Jack
  12. Hi, I am still a newbie at PHP and i am stuck. I found this script on the internet wich works fine but there is one thing i would change, but cant get it done. The problem with this upload and resize script is that i dont want the client to be able to edit the resize values. I would like to set it to 400 x 300. Can this be done ? i would be thankfull if someone can help me out here. <?php ini_set("memory_limit", "200000000"); // for large images so that we do not get "Allowed memory exhausted"?> <?php // upload the file if ((isset($_POST["submitted_form"])) && ($_POST["submitted_form"] == "image_upload_form")) { // file needs to be jpg,gif,bmp,x-png and 4 MB max if (($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg" || $_FILES["image_upload_box"]["type"] == "image/gif" || $_FILES["image_upload_box"]["type"] == "image/x-png") && ($_FILES["image_upload_box"]["size"] < 4000000)) { // some settings $max_upload_width = 2592; $max_upload_height = 1944; // if user chosed properly then scale down the image according to user preferances if(isset($_REQUEST['max_width_box']) and $_REQUEST['max_width_box']!='' and $_REQUEST['max_width_box']<=$max_upload_width){ $max_upload_width = $_REQUEST['max_width_box']; } if(isset($_REQUEST['max_height_box']) and $_REQUEST['max_height_box']!='' and $_REQUEST['max_height_box']<=$max_upload_height){ $max_upload_height = $_REQUEST['max_height_box']; } // if uploaded image was JPG/JPEG if($_FILES["image_upload_box"]["type"] == "image/jpeg" || $_FILES["image_upload_box"]["type"] == "image/pjpeg"){ $image_source = imagecreatefromjpeg($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was GIF if($_FILES["image_upload_box"]["type"] == "image/gif"){ $image_source = imagecreatefromgif($_FILES["image_upload_box"]["tmp_name"]); } // BMP doesn't seem to be supported so remove it form above image type test (reject bmps) // if uploaded image was BMP if($_FILES["image_upload_box"]["type"] == "image/bmp"){ $image_source = imagecreatefromwbmp($_FILES["image_upload_box"]["tmp_name"]); } // if uploaded image was PNG if($_FILES["image_upload_box"]["type"] == "image/x-png"){ $image_source = imagecreatefrompng($_FILES["image_upload_box"]["tmp_name"]); } $remote_file = "uploads/".$_FILES["image_upload_box"]["name"]; imagejpeg($image_source,$remote_file,100); chmod($remote_file,0644); // get width and height of original image list($image_width, $image_height) = getimagesize($remote_file); if($image_width>$max_upload_width || $image_height >$max_upload_height){ $proportions = $image_width/$image_height; if($image_width>$image_height){ $new_width = $max_upload_width; $new_height = round($max_upload_width/$proportions); } else{ $new_height = $max_upload_height; $new_width = round($max_upload_height*$proportions); } $new_image = imagecreatetruecolor($new_width , $new_height); $image_source = imagecreatefromjpeg($remote_file); imagecopyresampled($new_image, $image_source, 0, 0, 0, 0, $new_width, $new_height, $image_width, $image_height); imagejpeg($new_image,$remote_file,100); imagedestroy($new_image); } imagedestroy($image_source); header("Location: submit.php?upload_message=image uploaded&upload_message_type=success&show_image=".$_FILES["image_upload_box"]["name"]); exit; } else{ header("Location: submit.php?upload_message=make sure the file is jpg, gif or png and that is smaller than 4MB&upload_message_type=error"); exit; } } ?> <!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>Image Upload with resize</title> <style type="text/css"> <!-- body,td,th { font-family: Arial, Helvetica, sans-serif; color: #333333; font-size: 12px; } .upload_message_success { padding:4px; background-color:#009900; border:1px solid #006600; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } .upload_message_error { padding:4px; background-color:#CE0000; border:1px solid #990000; color:#FFFFFF; margin-top:10px; margin-bottom:10px; } --> </style></head> <body> <h1 style="margin-bottom: 0px">Submit an image</h1> <?php if(isset($_REQUEST['upload_message'])){?> <div class="upload_message_<?php echo $_REQUEST['upload_message_type'];?>"> <?php echo htmlentities($_REQUEST['upload_message']);?> </div> <?php }?> <form action="submit.php" method="post" enctype="multipart/form-data" name="image_upload_form" id="image_upload_form" style="margin-bottom:0px;"> <label>Image file, maximum 4MB. it can be jpg, gif, png:</label><br /> <input name="image_upload_box" type="file" id="image_upload_box" size="40" /> <input type="submit" name="submit" value="Upload image" /> <br /> <br /> <label>Scale down image? (2592 x 1944 px max):</label> <br /> <input name="max_width_box" type="text" id="max_width_box" value="400" size="4"> x <input name="max_height_box" type="text" id="max_height_box" value="300" size="4"> px. <br /> <input name="submitted_form" type="hidden" id="submitted_form" value="image_upload_form" /> </form> <?php if(isset($_REQUEST['show_image']) and $_REQUEST['xshow_image']!=''){?> <p> <img src="uploads/<?php echo $_REQUEST['xshow_image'];?>" /> </p> <?php }?> Greetings, Jack
  13. Hello, I have this script and its working fine, but there is one thing i would like to change. When the server wich i am scanning is not online (shutted down completely) it takes 30 seconds until it shows the offline status. I would like to decrease this to 2 to 5 seconds and let the script the server is down. Can anyone tell me what i have to do, please a bit specific because i have poor knowledgde. [code]<?php set_time_limit(0);    $s_port  = 12203;              // Serverport  $s_ip    = "82.217.212.106";  // Server-IP  $timeout = 2;   // CONN WRITE READ [1] $s_con  = fsockopen("udp://".$s_ip, $s_port,$errno, $errstr, $timeout);  // $s_con == false if fsockopen failed  if(!$s_con)      die(msg_server('Unable to connect with fsockopen [1];; '.$errstr));  // fwrite return false on write error, else it return how many bytes written  if(fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00))===FALSE) die(msg_server('Unable to write to $_con [1]'));  // fread return false on read error, else it return the read string  if(($ffb = fread($s_con,4))===FALSE)          die(msg_server('Unable to read from $_con after write. [1]'));  // stream_get_meta_data is same as socket_get_status  $meta_data = stream_get_meta_data($s_con);  if($meta_data["unread_bytes"]==0) die(msg_server('server DOWN'));  $beginnen = fread($s_con, $meta_data['unread_bytes']);  fclose($s_con);  $data = explode("\n", $beginnen);  // Serverinfo  // CONN WRITE READ [2]  $s_con = fsockopen("udp://".$s_ip, $s_port,$errno, $errstr, $timeout);  if(!$s_con) die(msg_server('Unable to connect with fsockopen [2];; '.$errstr));  if(fwrite($s_con, "ÿÿÿÿ". chr (0x02). "getstatus". chr (0x00))===FALSE) die(msg_server('Unable to write to $_con [2]'));  // bytes lezen en verbindingsopbouw  if(($ffb = fread($s_con,4))===FALSE) die(msg_server('Unable to read from $_con after write. [2]'));  $meta_data = stream_get_meta_data($s_con);  if($meta_data["unread_bytes"] == 0)      die(msg_server('No data, sorry. ('.$ffb.')'));  $beginnen = fread($s_con, $meta_data['unread_bytes']);  fclose($s_con);  msg_server('server ACTIVE');    function msg_server($server_status,$errmsg=''){      echo " <div class='scanner' id='hoofd'>   <div class='picture'><img src='sc-moh.gif' alt='1' /></div>   <div class='status'>$server_status</div> </div>";     } ?>[/code]
×
×
  • 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.