PHP - What Php Script Can Transfer A Non Browser Api Onto A Browser?
I'd like to use an application that's not browser based, on Internet Explorer. I've read somewhere that this is possible with a PHP script, but which one? If you can get me on the right track, I'd really appreciate it. Cheers.
Similar TutorialsWell I am using easy php and I need to make a script that will open up a script in easy php in the web browser.. so like a script to open http://127.0.0.1:8888/script.php then sleep for x amount of time then open another script in the browser http://127.0.0.1:8888/script2.php Any help is appreciated Hello all, I'm new to PHP and to these forums and i'm having trouble with a little script I'm working on. I have to point out at the start that the script actually works, other than for the error I'm reporting. What it does, is lets the user upload an image to the server and creates a thumbnail imageof it in another folder. This works as intended. (I.e. the images gets uploaded and the thumbnail is created) The issue i'm having is when the work is completed successfully... If there's an error, I update a variable $msg with an error mesage. (File too large, or invalid filetype) If this is the case, the script will render the html code correctly, display the error, then redirect you using javascript after 4 seconds to the original page. No worries here, everything works so far. However, if there is no errors to report and the script is successfull, I update $msg to say "it worked"(or whatever) but instead of displaying the formatted webpage displaying the message, then redirecting after 4 seconds, all that happens is the html code is displayed instead. (If I cut and paste this code into a new htmlfile, it renders correctly.) Attached below is the php code which does all the work. (But not the main php file which calls it) Can someone please point me in the right direction as to what I'm doing wrong! lol (Again, I'm new here so a big hello from me!!!) Code: [Select] <?php print( "<html>\n"); print( " <head>\n"); print( " <title>Random banner and file upload</title>\n"); print( " <link rel=StyleSheet href=\"styles.css\" type=\"text/css\">\n"); print( " </head>\n"); print( " <body>\n" ); $file_upload = "true"; $filetype = $_FILES[ "file_up" ][ "type" ]; $file_name = $_FILES[ "file_up" ][ "name" ]; $startimage = $_FILES[ "file_up" ][ "tmp_name" ]; $largeimage = "images/uploads/$file_name"; $thumbimage = "images/uploadthumbs/thumb-$file_name"; $msg = " "; $invalidfilesize = "<p class='centeralign'>Your uploaded file size is more than 250KB so please reduce the file size and then upload.<br>Visit the help page to know how to reduce the file size.</p>\n"; $invalidfiletype = "<p class='centeralign'>Your uploaded file must be of PNG, JPG or GIF. Other file types are not allowed.</p>\n"; $successfullupload = "<p class='centeralign'>File uploaded successfully! :)</p>\n"; $failedupload = "<p class='centeralign'>File not uploaded successfully! :(</p>\n"; $notinstalled = "<p class='centeralign'>The requested function is not installed on this web server. :(</p>\n"; //If the image is larger than 1Mb, do not upload. if ( $_FILES[ "file_up" ][ "size" ] > 1048576 ) { $msg = $msg.$invalidfilesize; $file_upload="false"; } //If the image is an invalid file type, do not upload. if ( ! ( $filetype == "image/x-png" || $filetype == "image/pjpeg" || $filetype == "image/jpeg" || $filetype == "image/gif" ) ) { $msg = $msg.$invalidfiletype; $file_upload = "false"; } //Start the thumbnail generation. if( $file_upload == "true" ) { $n_width = 160; // Fix the width of the thumbnail images $n_height = 120; // Fix the height of the thumbnail imaage switch ( $filetype ) { case "image/x-png"; $FromFormat = "ImageCreateFromPNG"; $ToFormat = "ImagePNG"; break; case "image/jpeg"; $FromFormat = "ImageCreateFromJPEG"; $ToFormat = "ImageJPEG"; break; case "image/pjpeg"; $FromFormat = "ImageCreateFromJPEG"; $ToFormat = "ImageJPEG"; break; case "image/gif"; $FromFormat = "ImageCreateFromGIF"; $ToFormat = "ImageGIF"; break; } if ( function_exists( "$FromFormat" ) )// Generate the thumbnail. { $im = $FromFormat( $startimage ); $width = ImageSx( $im ); // Original picture width is stored $height = ImageSy( $im ); // Original picture height is stored $newimage = imagecreatetruecolor( $n_width, $n_height ); imageCopyResized( $newimage, $im, 0, 0, 0, 0, $n_width, $n_height, $width, $height ); Header( "Content-type: $filetype" ); $ToFormat( $newimage, $thumbimage ); } else { $msg = $msg.$notinstalled; }// Unable to generate the thumbnail. (GD library not installed on web server?) //Move the uploaded file to the correct place.. if( move_uploaded_file ( $startimage, $largeimage ) ) { $msg = $msg.$successfullupload; } else { $msg = $msg.$failedupload; }//Unable to move uploaded file. } Print( "$msg" ); print( " <script type=\"text/javascript\"><!--\n" ); print( " setTimeout('Redirect()',4000);\n" ); print( " function Redirect()\n" ); print( " {\n" ); print( " location.href = 'index.php';\n" ); print( " }// -->\n" ); print( " </script>\n" ); print( " </body>\n" ); print( "</html>\n" ); ?> I am trying to develop a browser interface for an embedded system. The code written so far consists of one HTML page and one PHP script. The HTML page creates a form containing a select widget and a submit button. When the submit button is pressed, the selected item is posted to the PHP script for processing. The PHP script does a MySQL query using the form data and generates HTML to display the query result in a table, which displays in a new Web page. All of this works fine. However... I need to change the HTML page to create the select widget choices using a the result of a query run when the HTML page gets displayed. I created a PHP script to do this, and included it in my HTML page in this manner: Code: [Select] <form action="procSomeForm.php" method="post"> <?php include "genSelectList.php"; ?> <input class="main" type="submit" name="submit[view]" value="View" style="width:70px"/> </form> When I tried this, the select didn't appear. I tried moving the <select> </select> out of the PHP script and placing them around the "include". The select now displayed but with no contents. After many failed attempts to resolve any errors in the script, I began to suspect that the browser was ignoring the include directive. I then reduced the problem to this trivial code: Code: [Select] <html> <head> <title>PHP Test</title> </head> <body> <?php include "tmp.php"; echo "<p>This message brought to you by PHP!</p>"; ?> </body> </html> The PHP script looks like this: Code: [Select] <?php echo "<p>Hello from tmp.php!</p>"; ?> My Web browser rendered the result as: Code: [Select] This message brought to you by PHP! ";?> The "hello" message in tmp.php wasn't displayed, and the the browser printed the last few characters of the embedded PHP statement as if they were simple text! I have tried this same experiment on two PCs with the same result. My development PC runs Debian 6.0 (Squeeze) in VMWare on top of WinXP; I access the Web pages locally from within VMWare using IceWeasel. My embedded PC also runs Debian 6.0; I access the Web pages from my WinXP box using Firefox. Interestingly, when I use IE8 to call up the trivial page from the embedded PC, it displays a blank page! Sorry for the long-winded setup to the problem, but I wanted to point out that generating a separate HTML page from a PHP script works; it appears that the issue is with putting PHP statements in an HTML page. Any help will be greatly appreciated - thanks in advance! Chris I'm working with a lightbox plugin to show images when thumbnails are clicked on. The plugin works by wrapping the thumbnail in an anchor tag that has the href as the direct path to the full-size image. This acts as a non-js fallback, so that if JS isn't present for whatever reason, the user still sees the image. When JS is enabled, the image is shown in the lighbox, resized to fit in the lightbox, which is a variable size depending on the browser.
I need to keep a record of the number of times that the image has been clicked on, as thumbnails will be ordered by the number of views. The problem of course is that I'm directly linking to the image, so I can't put a script on this page.
I've tried two things instead, neither of which worked:
1) Instead setting the target as the path to the image, I set it to a PHP script, then outputted the image in an <img/> tag. The problem was that the image is then not resized according to the size of the lighbox. So this is no good.
2) I set the target of the lightbox as a PHP script which recorded the viewing of the image, and redirected to the image page. This didn't work either, as the lightbox showed the data for the image (text) instead of the image itself.
So, I've hit a bit of a barrier. I'm wondering if I can set something up in my PHP settings that will automatically call a script when hitting images, or maybe something in an .htaccess file that will do the same, but I'm not aware of if this can be done, nor how to do it, and I haven't found anything yet with my googling. Does anyone have any thoughts?
Thanks.
Edited by haku, 26 August 2014 - 07:00 PM. im testing the following script and it wont send 1 2 3 until the script has finished executing. What can i do to flush the buffer after every echo statement?? <?php echo "1"; ob_flush();flush(); sleep(5); echo "2"; ob_flush();flush(); sleep(5); echo "3"; ob_flush();flush(); ?> I recently switched hosts to DreamHost, and even after a completely clean install of Codesort I'm getting these errors:
The top of the Codesort admin panel:
Deprecated: Assigning the return value of new by reference is deprecated in /home/fatedus/fatedus/loved/codesort/functions.php on line 35 WARNING: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/fatedus/fatedus/loved/codesort/functions.php:35) WARNING: Cannot modify header information - headers already sent by (output started at /home/fatedus/fatedus/loved/codesort/functions.php:35)And displayed on the codes page of my fanlistings is this, too: Deprecated: Assigning the return value of new by reference is deprecated in /home/fatedus/fatedus/loved/codesort/functions.php on line 35This is line 35 of the functions.php file: $instance =& new $object;Here is a link to the script for those unfamiliar with it: http://fanupdate.net/codesort.php Here's a link to one of my fanlisting pages where the error shows up: http://odin.fated.us/codes.php Also here is a screenshot of what the error looks like inside the Codesort admin panel: http://i.imgur.com/yDlT8d9.png Help would be really appreciated, this host move has been such a pain. ;c Hello,
I want to know how they keep the same url when page is changing, if you dont know what i mean try the link and check the browser when you wat happens when you click in a other link in the website.
( Website Link ( Normal Content ) ) http://geedmo.com/?item=LushSlider
Thanks in advance.
Hello PHPers, I need help regards obtaining the correct Host and IP address. Using all browsers except mozilla-firefox, I will received the correct IP address. But with Mozzilla-firefox I get the wrong Host and IP address back as 10.1.23.22 ..The code I have is $mj_ip = $_SERVER['REMOTE_ADDR']; $mj_host = gethostbyaddr($_SERVER['REMOTE_ADDR']); Cheers, HJ Hey there, I'm trying to set up a little ftp script to make it easier to upload files and add new folders for images and videos ect on a backend admin page however the following script just will not connect I keep getting the "Couldn't connect to 66.40.52.167" error so it's not even finding the server however when I put it into my browser it connects just fine, I've even pinged it and all works fine so I don't get it. $ftp_server = "66.40.52.167"; $ftp_user = "username"; $ftp_pass = "password"; $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); if (@ftp_login($conn_id, $ftp_user, $ftp_pass)) { echo "Connected as $ftp_user@$ftp_server\n"; } else { echo "Couldn't connect as $ftp_user\n"; } ftp_close($conn_id); Any ideas would be appreciated! I am trying to come up with a script that will detect whether the requesting user agent is a bot or a browser, as their are so many bots and scripts around i have decided to go with the latter so i need a list of browsers that may be used to do the following Quote $browser_array = array(list of browsers..................); if(!in_array($_SERVER['HTTP_USER_AGENT'], $browser_array)) { output text; } else { output html; } so basically i am now stuck without a complete list of user agents so if anyone knows where i can find a list it would be much appreciated Hi, I have tried a "Hello.php" to open in my web browser. It throws 404 file not found error. I am using Intranet. How to determine the web server I am using? Thanks. Is there a way so when someone loads your website that it forces them to load it in a different browser? Is there anything to worry if I see no SSL warning in my browser's address bar when I am in the logging credentials form?
I have done some searching and digging, but it seems everyone has their own ways of doing things, some more effective than others. I have a web design portfolio website, which uses a "coinslider" flash slideshow. It looks awesome in FF, but IE6/etc users cant view it properly. How can I create a PHP if/then to detect if they are using a sub-par browser, and display a more simple slideshow? That way it will work for all users, and those with Firefox and similar browsers can view the more interesting slideshow. Thanks. hello, this is part of my contact form code. When i click on the submit button i need the form to take me to the $success_message or the $failure_message instead of the top of the page. I know i can do it with # tag or # id normally. But I do not know how to apply it to the form. Code: [Select] //some text and stuff<tr> <td> <? if(!empty($success_message)) { echo "<center><font color='blue'><b>".$success_message."</b></font><br></p>"; } if(!empty($failure_message)) { echo "<center><font color='red'><b>".$failure_message."</b></font><br></p>"; } ?> <? if((empty($_POST)) || !empty($strError)) { echo "<table align= 'center' width='70%' style='border-top: 1px; border-right: 1px; border-left: 1px; border-bottom: 1px; border-color: black; border-style: solid;'>"; ?> <form action="<?php echo $PHP_SELF;?>" method="post"> <tr height='40'> <td> <font color="black"><B> First Name: </B></font> </td> <td><input type="text" size ="40" name="first_name" value="<? if(!empty($strError)) {echo cleaninput($_POST['first_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['first_name'])) echo $arrErrors['first_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Last Name: </B></font></td> <td><input type="text" size ="40" name="last_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['last_name']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['last_name'])) echo $arrErrors['last_name']; ?> </td> </tr> <tr height='40'> <td><font color="black"><B> Email Address: </B></font></td> <td><input type="text" size ="40" name="email_address" value="<? if(!empty($strError)) { echo cleaninput($_POST['email_address']);}?>" class="advertising-inputbox-style"/> <?php if (!empty($arrErrors['email_address'])) echo $arrErrors['email_address']; ?> </td> </tr> <tr height='35'> <td><font color="black"><B> Business Name: </B></font></td> <td><input type="text" size ="40" name="business_name" value="<? if(!empty($strError)) { echo cleaninput($_POST['business_name']);}?>" class="advertising-inputbox-style" /> <?php if (!empty($arrErrors['business_name'])) echo $arrErrors['business_name']; ?> </td> </tr> <tr> <td><font color="black"><B> Business Description: </B></font></td> <td ><textarea rows=7 cols=31 name="description" class="advertising-textarea-style"><? if(!empty($strError)) { echo cleaninput($_POST['description']);}?></textarea> <?php if (!empty($arrErrors['description'])) echo $arrErrors['description']; ?> </td> <tr height='35'> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </form> I'm planning on writing a library script holding pdf files which will serve the purpose as ebooks in which people could search and open. I don't know for sure, but doubt that you can open a pdf file and make it readable in php. I've noticed adobe reader has managed to do it, and what method do they use to do so? how would you code a map for a browser game like travian? i know how it works but i cant code that sort of stuff. ive got my database set up like this x y player 1 1 1 2 etc.... so i when you click an arrow it will got to the next square along. OK, I'm nearing the end of a very long chat project and I have one last hurdle to jump, I've saved this task to the near end because I thought it would be a problem as I have no idea what to do or where to start. The problem is exactly what is said in the subject title. I have looked into JavaScript options such as "onbeforeunload" but that is just BAD. The login is controlled by sessions, so when the user closes the browser, the session is ended, but data in the database says different, cookies are not an option I'm afraid. I've had an idea that if I create a special account (or a few) and always leave these accounts logged in, they can check if a user has been inactive for a certain period of time, and then run queries to change things, I know this sound odd but maybe I will not have to create these accounts but general accounts that people make will be able to do this for me, without them even knowing. Please help, any ideas, suggestions, logic or methods that you think will help will be great. Thanks. I got problem with one of my php page. Mozilla browser keeps on loading although it shows the page, i am not really sure which part is wrong. But i don't find any problem with other browsers lol. Can anyone help me please thanks in advance I'm not sure if JS or PHP is causing my browser to lock up when I access this page. I have a database of zipcodes ... approx. 70,000 of them. I have a php loop put them into a JS array. I then want JS to create a drop down with all the zip codes. On Chrome it completely doesn't work. On FF it will loop to about 64,000 and then give a warning that the script is taking too long. Reading up on google it seems that JS should be able to handle an array much bigger then mine... so what could be he problem? <script language="javascript"> function addOption(selectbox,text,value ) { var optn = document.createElement("OPTION"); optn.text = text; optn.value = value; selectbox.options.add(optn); } <?php //TESTING $con = mysql_connect("","",""); mysql_select_db("", $con); //END TESTING $data = mysql_query("SELECT postalCode FROM geo_city WHERE postalCode !='' ORDER BY postalCode ASC") or die(mysql_error()); echo 'function addOption_list(selectbox){ var zip = new Array("VOID"'; while($info = mysql_fetch_array($data)){ echo ',"'.$info['postalCode'].'"'; } echo ');'; ?> for (var i=0; i < zip.length;++i){ addOption(document.drop_list.zip_list, zip[i], zip[i]); } } </script> </head> <body onLoad="addOption_list()";> <FORM name="drop_list" action="" method="POST" > <SELECT NAME="zip_list"> <Option value="" >Zip Code list</option> </SELECT> </form> |