Jump to content

bobthebullet990

Members
  • Posts

    12
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

bobthebullet990's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The script takes 10 minutes because it executes an external PERL script that - Erase flash (takes about 10seconds) - Flash firmware loader (takes about 15seconds) - Flash firmware stack (takes about 30seconds) - Merge PSData (takes about 10 seconds) Do the above for each connected device; there are 8 devices connected to the host machine. By the time the PERL script completes and returns its output (success/failure messages for each of the above for each device) the execution warning comes up. Not fussed about security because its a private password protected machine behind firewalls and proxy, used by 4 test engineers, I setup WAMP so it runs in offline mode (i.e. no external machine can query the webserver) so security is not an issue. Thanks for the php.ini stuff... I'll just write a message on the screen to warn it takes a long time to complete!
  2. Sorry, I'm not familiar with AJAX one bit! ...This thread got moved here, that was the first I'd ever heard of AJAX... did some background reading on it, sounds quite interesting, but considering I'm not a web programmer (don't really want to be either) I'm using PHP because its free and easy. What I'm looking to do is to have a HTML webpage (generated by php) that has a button "Start" on it, when the user clicks this start button, the php script does a shell_exec() command and runs a PERL script that I wrote to auto-configure test devices (at least 8 are connected to the host machine). Trouble is, the script takes about 5-10 minutes to complete, so every time I run the script from PHP I get: Fata Error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\php\config.php on line 167. Where the script has taken a long time to execute! Any ideas how I get around this?
  3. Hi guys, looking for some help... Bascially what I'm doing is: - Get data - Validate data - Create temporary config file - Run an external Perl Script using the php shell_exec command (requires the temp config file) - PROBLEM STAGE - Do something whilst script executes - Finished Trouble is, when I do this, when the script is running its output is invisible to the client machine (obviously as its running on the server)... However, the script takes about 10 minutes to complete and there is some usefull output from the Perl script that would benefit the user; currently I can only produce this output once the script completes, but in the meantime I'm left with a page that appears to be doing nothing whilst it waits for the script to complete! Can I either: - Generate a simple html page that displays a please wait graphic until the script completes - Route the output of the perl script to the client browser so they can see what is happening Many thanks in advance!
  4. only problem doing that is there are 24 input boxes on the page! ...Its a script to configure test devices... 1. user enters config data for 8 devices 2. user chooses a filename and hits submit 3. script validates input, if no errors, then give file to user to download 4. script finds invalid input and asks the user to either download incomplete config file (maybe there are some broken devices that don't need a config) or to go back and change some values if they made a mistake. The final bit is where I'm at, I've collected all the data and processed it, but now putting in step 3.5 where the script finds invalid data, then shows another button to continue anyway, as soon as that button is pressed I loose all data from the first button press! So yeah, could do it your way, but there must be a simpler way surely?
  5. Hi guys, I've tried pretty much everything I can think of without using cookies, even tried sessions, but they don't seem to work either! here's an example script I wrote to show my problem... <?php $input = 1; $myval = "none"; if (isset($_POST['test1'])) { $input=2; $myval="first"; $extra="extra";} if (isset($_POST['test2'])) { $input=3; $myval="second"; } ?> <html> <form name="1" action="" method="post"> <p>just press the button</p> <input type="text" name="in1" value="<?php echo $myval; ?>"> <?php if ($input==1) { ?><input type="submit" name="test1" value="test1"><?php } ?> <?php if ($input==2) { ?><input type="submit" name="test2" value="test2"><?php } ?> <?php if ($input==3) { ?><p>finished, myval is <?php echo $extra; } ?></p> </form> </html> OK, So my problem is that I have a fairly large script with various forms, all I want to be able to is to get php to remember the values stored in variables and not reset all variables when the script is re-loaded, if you run the above script, the variable "$extra" is forgotten by the time I want to use it, how can I get php to retain this value without using a database or cookies? Thanks...
  6. Sorry, in the above file, I've just noticed that I've left in a line that shouldn't be there... [Line 155] header ("Location: $filename"); Cheers.
  7. Many thanks, here's the full script as it stands... <!-- Author: Matt Conway --> <!-- Description: Simple page to create a config file used to configure the test system devices --> <html> <head> <title>Test System Config Tool</title> </head> <body> <?php $bauds = array('Select','9.6','14.4','19.2','38.4','57.6','115.2','230.4','460.8','921.6','1382.4'); // Retrieve Data if (isset($_REQUEST['submitConfig'])) { $submit = 1; // flag to see if submit button was pressed $isvalid = 1; // flag to see if the input data is valid or not $bdadd0 = $_REQUEST['BDADD0']; $bdadd1 = $_REQUEST['BDADD1']; $bdadd2 = $_REQUEST['BDADD2']; $bdadd3 = $_REQUEST['BDADD3']; $bdadd4 = $_REQUEST['BDADD4']; $bdadd5 = $_REQUEST['BDADD5']; $bdadd6 = $_REQUEST['BDADD6']; $bdadd7 = $_REQUEST['BDADD7']; $ftrim0 = dechex($_REQUEST['FTRIM0']); $ftrim1 = dechex($_REQUEST['FTRIM1']); $ftrim2 = dechex($_REQUEST['FTRIM2']); $ftrim3 = dechex($_REQUEST['FTRIM3']); $ftrim4 = dechex($_REQUEST['FTRIM4']); $ftrim5 = dechex($_REQUEST['FTRIM5']); $ftrim6 = dechex($_REQUEST['FTRIM6']); $ftrim7 = dechex($_REQUEST['FTRIM7']); $baudr0 = $_REQUEST['BAUDR0']; $baudr1 = $_REQUEST['BAUDR1']; $baudr2 = $_REQUEST['BAUDR2']; $baudr3 = $_REQUEST['BAUDR3']; $baudr4 = $_REQUEST['BAUDR4']; $baudr5 = $_REQUEST['BAUDR5']; $baudr6 = $_REQUEST['BAUDR6']; $baudr7 = $_REQUEST['BAUDR7']; $filename = $_REQUEST['FILENM']; // TODO - Validate the bluetooth addresses // TODO - Build the string to write in the file - for now, lets just use an example... $theConf = "0:0002 9CBD 005b 0002:115.2:001d\n1:0000 E478 005b 0002:115.2:001d"; // Create temporary file and offer the user to save it locally on their client machine $theFH = fopen($filename, 'w') or die("can't open file"); fwrite($theFH, $theConf); fclose($theFH); $configComplete = 1; } else { $submit=0; // submit button not pressed $configComplete = 0; // the config file is not complete } // Validate input data ?> <center> <h1>Test System Config Tool [under Construction]</h1> <?php if (!$configComplete) { ?> <form name="theform" method="post" action=""> <table> <tr> <td></td> <td><p>Bluetooth Address</p></td> <td></td> <td><p>Crystal Frequency</p></td> <td></td> <td><p>Baud Rate</p></td> </tr> <tr> <td><p>Device 0 --> [0002 5b]</p></td> <td><input type="text" name="BDADD0" value="<?php if ($submit) echo $bdadd0; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM0" value="<?php if ($submit) echo hexdec($ftrim0); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR0"><?php foreach ($bauds as $current) { if ($current==$baudr0) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 1 --> [0002 5b]</p></td> <td><input type="text" name="BDADD1" value="<?php if ($submit) echo $bdadd1; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM1" value="<?php if ($submit) echo hexdec($ftrim1); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR1"><?php foreach ($bauds as $current) { if ($current==$baudr1) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 2 --> [0002 5b]</p></td> <td><input type="text" name="BDADD2" value="<?php if ($submit) echo $bdadd2; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM2" value="<?php if ($submit) echo hexdec($ftrim2); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR2"><?php foreach ($bauds as $current) { if ($current==$baudr2) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 3 --> [0002 5b]</p></td> <td><input type="text" name="BDADD3" value="<?php if ($submit) echo $bdadd3; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM3" value="<?php if ($submit) echo hexdec($ftrim3); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR3"><?php foreach ($bauds as $current) { if ($current==$baudr3) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 4 --> [0002 5b]</p></td> <td><input type="text" name="BDADD4" value="<?php if ($submit) echo $bdadd4; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM4" value="<?php if ($submit) echo hexdec($ftrim4); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR4"><?php foreach ($bauds as $current) { if ($current==$baudr4) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 5 --> [0002 5b]</p></td> <td><input type="text" name="BDADD5" value="<?php if ($submit) echo $bdadd5; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM5" value="<?php if ($submit) echo hexdec($ftrim5); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR5"><?php foreach ($bauds as $current) { if ($current==$baudr5) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 6 --> [0002 5b]</p></td> <td><input type="text" name="BDADD6" value="<?php if ($submit) echo $bdadd6; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM6" value="<?php if ($submit) echo hexdec($ftrim6); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR6"><?php foreach ($bauds as $current) { if ($current==$baudr6) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> <tr> <td><p>Device 7 --> [0002 5b]</p></td> <td><input type="text" name="BDADD7" value="<?php if ($submit) echo $bdadd7; ?>"></td> <td><p> - </p></td> <td><input type="text" name="FTRIM7" value="<?php if ($submit) echo hexdec($ftrim7); ?>"></td> <td><p> - </p></td> <td><select name="BAUDR7"><?php foreach ($bauds as $current) { if ($current==$baudr7) { $selected = 'selected'; } else { $selected = ""; } echo "<option value=\"$current\" $selected>$current</option>"; } ?></select></td> </tr> </table> <br><br> <table> <tr> <td><p>Filename: </p></td> <td><input type="text" name="FILENM" value="<?php if ($submit) echo $filename; ?>"</td> <td><input type="submit" value="Save Config" name="submitConfig"></td> </tr> </table> </form> <!-- The config file has been written to file, so give the user the file to download --> <?php } else { header ("Location: $filename"); header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" ); header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" ); header ( "Pragma: no-cache" ); header ( "Content-type: text/plain" ); header ( "Content-Disposition: attachment; filename=$filename" ); header ( "Content-Length: ".strlen($theConf)); print $theConf; } ?> </center> </body> </html>
  8. Thanks for your reply, I've been playing around, but can't get it to work as I want... I have a variable [$theConf] which stores the file contents, an example of the file contents is... $theConf = "0:0002 9CBD 005b 0002:115.2:001d\n1:0000 E478 005b 0002:115.2:001d"; and then I create a file on the webserver [user enters the filename from a text input on the HTML form]... $theFH = fopen($filename, 'w') or die("can't open file"); fwrite($theFH, $theConf); fclose($theFH); Now I want to prompt the user to save the file to their computer... header ( "Expires: Mon, 1 Apr 1974 05:00:00 GMT" ); header ( "Last-Modified: " . gmdate("D,d M YH:i:s") . " GMT" ); header ( "Pragma: no-cache" ); header ( "Content-type: text/plain" ); header ( "Content-Disposition: attachment; filename=$filename" ); header ( "Content-Length: ".strlen($theConf)); print $theConf; I save the file to the computer and when I open it I see this... <!-- Author: Matt Conway --> <!-- Description: Simple page to create a config file used to configure the test system devices --> <html> <head> <title>Test System Config Tool</title> </head> <body> <center> <h1>Test System Config Tool [under Construction]</h1> 0:0002 9CBD 005b 0002:115.2:001d 1:0000 E478 005b 0002:115.2:001d </center> </body> </html> Which is obviously printing out all the HTML code for the page, on the webserver, if I open the temp.conf file I get the file that I want to give to the user...... 0:0002 9CBD 005b 0002:115.2:001d 1:0000 E478 005b 0002:115.2:001d Currently all I'm doing is just redirecting the browser to the file because this prints the file contents to the web browser which the user can copy and paste into a file, but thats a bit of a pain for the user! Is there a way I can do what I want to do?
  9. I understand how I create a file in php, this is proabably quite an obscure question! but here goes... I have a web page with a few text boxes on it and a submit button. The user enters values into the text boxes and clicks submit.... - The script validates the input data - The script creates a temporary file on the server (temp.conf) - I want to automatically give this file to the user to download after its been generated. Example use: - input valid data - click submit - data is validated and if valid I'm offered to save the file temp.conf somewhere on my local machine - finished.
  10. I want to image resize and save the resized image, not the original size image! I don't want to have 500kb images [1280x1024 and larger] clogging up my server!!!!!!!!! and then resize them in another script just to view it!!! ...to me, that just seems a waste of processing time and disc space! why resize an image every time when you can resize and save it at the resized size!!! ...Check out my test version of the page; running on WAMP direct fom my PC! ...hopefully you will understand where i am comming from!!! http://82-32-189-3.cable.ubr07.azte.blueyonder.co.uk/WWW/gallery.php
  11. Hi!!! Thanks for your time!!! ...I have created a php script that allows users to upload images to my webserver and then displays all images within the gallery! ...The thumbnails are resized proportionally, with a max size of 150x150px, however, i want to resize the main image if its larger than 500px to proportionally resize it to a size within 500x500px square! ...Is there no simple way to do this other than the way that i have done.... [code]         // CLEAR THE FILENAME - IN CASE OF MULTIPLE UPLOADS, DON'T WANT AN ERROR!         unset($thefilename);         // CHECK THAT THERE IS A FILE TO UPLOAD         if(!isset($_FILES) && isset($HTTP_POST_FILES)){           $_FILES = $HTTP_POST_FILES;         }         if(!isset($_FILES['fileToUpload'])){           $message .= "ERROR: The image entered was not found!<br>";         }         $thefilename = basename($_FILES['fileToUpload']['name']);         if(empty($thefilename)){           $message = "ERROR: The name of the file was not found.";         }         if(empty($error)) {           $imagePath = $uploadDir . $thefilename;           $result = @move_uploaded_file($_FILES['fileToUpload']['tmp_name'], $imagePath);             if(empty($result))             $message .= "ERROR: could not save the file!<br>";                     // CREATE IMAGE THUMBNAIL           $thumb = $thefilename;                     $handle = @imagecreatefromjpeg($imagePath);                     $x=imagesx($handle);           $y=imagesy($handle);                     if($x > $y){                                            $max = $x;                                      $min = $y;                                    }                                                    if($x <= $y){                                            $max = $y;                                      $min = $x;                                    }                                                          // $size_in_pixel : The maximum value (in pixels) that the thumbnail width or height is allowed.           $size_in_pixel = '150';                     // CREATE WIDTH AND HEIGHT VALUES FOR THE THUMBNAIL - PROPORTIONAL TO ORIGINAL WIDTH AND HEIGHT RATIO.           $rate = $max/$size_in_pixel;           $final_x = $x/$rate;           $final_y = $y/$rate;                         if($final_x > $x) {             $final_x = $x;             $final_y = $y;           }                       $final_x = ceil($final_x);           $final_y = ceil($final_y);                     $black_picture = imageCreatetruecolor($final_x,$final_y);           imagefill($black_picture,0,0,imagecolorallocate($black_picture, 255, 255, 255));           imagecopyresampled($black_picture, $handle, 0, 0, 0, 0,$final_x, $final_y, $x, $y);                     $thumbPath = $thumbDir.$thumb;                     if(!@imagejpeg($black_picture, $thumbPath, $size_in_pixel))             imagestring($black_picture, 1, $final_x-4, $final_y-8, ".", imagecolorallocate($black_picture,0,0,0));                                 // DELETE ALL TEMPORARY IMAGE DATA           imagedestroy($handle);           imagedestroy($black_picture);         } [/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.