Format Result Text Using Passthru Of System
I tried to use the Passthru and System function to resolve some whois
information.
echo passthru('whois 62.69.168.12') .'<br>'
-or-
$whois = system('whois 62.69.168.12', $retval);
It works fine, but all the result text is at one line. How can i format this
output correctly ?
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Exec, Shell_exec, System, And Passthru Not Working At All
Can't get these commands to work! The following page simply doesn't finish loading ( Waiting... Opening... :-( ) <?php echo system("dir"); ?> The same for <?php echo exec("dir"); ?> or <?php echo shell_exec("dir"); ?>, etc... I'm running Apache 2.0.55 & PHP 5.0.5 with Zend Optimizer v2.5.10 on windows XP SP2.
Format Table With PHP Result
I have to create some kind of dynamic page, logic is next: i have integer in variable and i need to create certain number of fields based on that int. example $variable = 6 and I need to have table with 6 fields, 4 in one row and 2 in second....my problem is how to do that, how to get new <tr> when number in bigger than 4.
Format Number And Text
I want to format my id's in a sertan way however i am not sure how t approatch this problem. i want to write a function that formats a 0 to D000000. However i alsow wat to be eable to convert them back from D000000 to 0 to make calculations with it. For exaple adding 1 to create D100000.
Allow A User To Format Text...
I want to allow a page on me website to send an email to someone, but allow them the freedom to add images/format text etc. Is there a way this can be done using php, or is there an already existing php extension that will let me do this?
Format Text File After Fopen
I use “fopen” to access the text file (this is working fine). Then I want to format the results. I tried “fgets” but there is a “return” after each entry in the text file. "fgets" thinks this is a new record and puts the data on the next line. How can I bypass the "returns" and use the file as is. Example of the text file: Sold_To_Name............: XXXX XXXX Ship_To_Name............: ZZZZZZZZZ Sold_To_Address.........: XXXX XXXX Ship_To_Address.........: ZZZZZZZZZ Sold_To_City............: XXXXX Ship_To_City............: ZZZZZZZ Sold_To_State...........: XX Sold_To_Zip.............: XXXXX Ship_To_State...........: ZZ Ship_To_Zip.............: ZZZZZ Sold_To_Phone_Number....: XXXXXXXXXX Ship_To_Phone_Number....: ZZZZZZZZZZ This is how I would like to format text: Sold to XXXX XXXX XXXX XXXX XXXXX XX XXXXX XXX-XXX-XXXX Ship to ZZZZZZZZZ ZZZZZZZZZ ZZZZZZZ ZZ ZZZZZ ZZZ-ZZZ-ZZZZ This my current programing:
Function To Format Text As Html?
Is there a function in PHP that will format text in basic HTML automatically for you? I'm pulling an article piece of text from MySQL and on display, it doesn't break at paragraphs. I know the returns are there, because when I browse the data in PHPMyAdmin, the text is broken into paraphraphs. I'd rather not insert html into the text in MySQL as I may use this text for other purposes like print. Is there and html tag that I'm missing that would do this besides <pre>?
Mail() Plain Text Vs. Html Format
I have been testing the mail() code below using MS Outlook and Outlook Express and a hotmail account and the details sent are always in "plain text" format, which results in the information being nicely aligned (incidentally the e-mail contains order confirmation with lots of columns). However, my customer came back to me this morning to tell me that all is not well ! And rightly enough, when I looked at the snapshot he sent me he is receiving it in "html" format. What am I doing wrong ? Keeping in mind that I am a PHP greenhorn ... Can anyone help. Thanks in advance ! $headers = "From: info@somecompany.com "; $headers.= "X-Sender: <info@somecompany.com> "; $headers.= "X-Mailer: PHP "; $headers.= "X-Priority: 1 "; $headers.= "Return-Path: "."<info@somecompany.com> "; $headers.= "cc: info@anothercompany.com "; $headers.= "bcc: me@mycompany.com "; $headers.= "MIME-Version: 1.0 "; $headers.= "Content-type: text/plain; charset=iso-8859-1 "; if(@mail($to,$re,$msg,$headers)) { // tell them all was sent fine } else { // give an error message }
Suggestion Needed On Data Storage Format In Text File
The project I am developing doesn't involves database. I want to parse the mailbox file (.mbx) and store the summary in the text file for fast retrieval and display of information in the Inbox page. The sugegsted format are as: #1 ID [4 bytes]: Subject [100 bytes]: To Address[100 bytes]: From Address[100 bytes]...etc... #2 Instead of preassining fixed size to variable (as actual data may be much less or can grew to more), we can store the values continuously, seperated by some unique seperator (#|#, *#*, ...) 1324#|#Hi, How are you#|#me@google.com#|#you@google.com#|# ... and so on Which of these will be the efficeint one (as there will be frequent insert/delete/update of the individual information, eg. set message as read ..., delete message ..., new message ...) Also please suggest on how to determine the variable size (100 bytes as in #1), and assign the size to the variable accordingly and read it (differentiate multiple variables) when required.
Select Specific Snippet Of Text, Replace With A Database Result
I'm having some problems trying to do something; I just can't think of a way to do it. Basically, I want to search for a specific snippet of text in a body of text, then replace it with the requested database result with some thrown in HTML. Users will be able to type the following (or something along these lines, depending on what works best): [image=12345]Insert caption here[/image] Then I need it to search for the requested image in the appropriate table and return the image's url (for an example, let's say the table is called "images", and the columns required are "imageid" and "imageurl". Code:
Passthru()
Anyone know why i'm getting an "unable to fork [datafile] " error using the passthru function. Tried it on txt files and grafix, and both types give error.
Passthru
Warning: passthru() has been disabled for security reasons in ... how can I change my php.ini file (php4/apache/winxp server) to enable this function? How can I best work around if I can't use this function?
Help With Passthru And Wmic...
I'm trying to get this to work. <?php echo passthru('wmic cpu get loadpercentage'); ?> and just output to the browser... It looks like cmd.exe hangs when it tries to execute the command. The IUSR_ account has access to both the cmd.exe and wmic files. I have also tried copying the wmic files to the C:php dir, and to the directory the web app is running from.
Passthru & Exec
I have a script which uses passthru to execute a shell script. This shell script then (at some point in its running) executes a php script. When executing the shell script from the command line everything works fine. When using passthru, however, I get the following error when it gets to the point where it tries to execute the 2nd php script: Code: Status: 404 X-Powered-By: PHP/4.4.2 Content-type: text/html No input file specified. 255 I'm hosted on Dreamhost with php 4.4.2.
Safe Mode And Passthru
I seem to be getting some inconsistent results when using passthru() in safe mode. They appear to be related to the fact that passthru should treat all command arguments as one single argument when safe mode is on. Everything works just fine on my MacOS X webserver ( Apache 1.3.29 with PHP 4.3.6 ). But on my Linux Enterprise 3.0 production server (running Apache 2.0.46 with PHP 4.3.2) things are different. Here are the argument(s) that passthru hands to my command when safe mode is off: rrdtool args: graph - --start -3600 --end N --width 300 --height 75 --lower-limit 0 --rigid --title BaBarCM2 Grid Load last hour --vertical-label Load/Procs DEF:load_one=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/load_one.rrd:sum:AVERAGE DEF:proc_run=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/proc_run.rrd:sum:AVERAGE DEF:cpu_num=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_num.rrd:sum:AVERAGE DEF:num_nodes=/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_num.rrd:num:AVERAGE AREA:load_one#CCCCCC:1-min Load LINE2:num_nodes#00FF00:Nodes LINE2:cpu_num#FF0000:CPUs LINE2:proc_run#0000FF:Running Processes And this is what passthru hands to my command when safe mode is on: rrdtool args: graph - --start -3600 --end N --width 300 --height 75 --lower-limit 0 --rigid --title 'BaBarCM2 Grid Load last hour' --vertical-label 'Load/Procs' DEF:'load_one'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/load_one.rrd':'sum':AVERAGE DEF:'proc_run'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/proc_run.rrd':'sum':AVERAGE DEF:'cpu_num'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_num.rrd':'sum':AVERAGE DEF:'num_nodes'='/u2/ganglia/rrds/BaBarCM2/__SummaryInfo__/cpu_num.rrd':'num':AVERAGE AREA:'load_one'#CCCCCC:Ƈ-min Load' LINE2:'num_nodes'#00FF00:'Nodes' LINE2:'cpu_num'#FF0000:'CPUs' LINE2:'proc_run'#0000FF:'Running Processes' The quotes are still there. Why am I not getting consistent behaviour on both platforms? Is this a bug in php 4.3.2 or 4.3.6?
Passthru(ls -alr) And Opendir - At The Same Time
I'm able to print a directory with opendir, but currently the files are in random order. My goal is to determine a way to use passthru (or some similar function... exex or system maybe) to sort the directory prior to listing it on the screen. I want to use open dir so I can make a link to the files (otherwise a simple <pre></pre> output would do nicely).
Cannot Get Exec() Or Passthru() To Work?
I cannnot seem to get exec() or passthru() to execute a perl script; here's the code snippet: if ($debug) { echo "username1 = ".$username1."<br>"; echo "dbname = ".$dbname."<br>"; echo "SESSION[dbname] = ".$_SESSION['dbname']."<br>"; echo "Output file = ".$outputfile."<br>"; echo "Project name = ".$projectname."<br>"; echo "Study name = ".$studyname."<br>"; echo "The command to be run is: ".$cmd."<br>"; } // Run the command! exec($cmd,$myoutput,$rtnvar); echo "rtnvar = ".$rtnvar."<br>"; foreach ($myoutput as $line) { echo $line."<br>"; } Which produces the results: username1 = rick dbname = cgb_lab_data SESSION[dbname] = cgb_lab_data Output file = myoutput Project name = IBS11_1103 Study name = IBS 11 The command to be run is: perl /home/caseyr/projects/LIMSScripts/3100DataIO/mk3100plt.pl -n 'IBS 11' -b 1103 -o myoutput -p IBS11_1103 -i S rtnvar = 13 The command looks perfectly legit, and will run at the command line if I cut and paste it. I do not understand the return value of 13. I can get a simple perl script that takes no arguments to run ok; so I think this has something to do with the arguments. I've used escapeshellarg() to no avail. I've always tried the same with system() and the backtick operator --
Passthru + Auto Generated Headers
I'm slightly confused with the passthru() command. The program I call writes html headers itself. However, passthru() makes apache sending some generated headers first. There's no fault with spaches in the code etc, I think. Here's an simplified example: $ cat /www/example.php <? passthru("cat /tmp/output"); ?> $ cat /tmp/output Content-Type: text/html <HTML><HEAD></HEAD>Message</BODY></HTML> $ curl -i "http://localhost/example.php" HTTP/1.1 200 OK Date: Sat, 16 Jul 2005 14:47:29 GMT Server: Apache/2.0.54 (Unix) mod_ssl/2.0.54 OpenSSL/0.9.7d DAV/2 PHP/5.1.0b3 X-Powered-By: PHP/5.1.0b3 Content-Length: 66 Content-Type: text/html Content-Type: text/html <HTML><HEAD></HEAD>Message</BODY></HTML>
Exec, Passthru Disabled So How To Call C++ .exe File?
I am at my wit's end trying to get information out of Streamline.net's support dept about my problem. They reply quickly enough, but seem to try and give out the least possible amount of info each time. The transcript so far is reproduced for your amusement below. To summarise: I've put up a Sudoku-solving program called Sudoku.exe. I want to call it in a php script to solve a puzzle and output the solution. It works fine with Apache/php on my own machine, but it seems Streamline.net disable exec, passthru etc. They eventually say, cryptically: ' CGI executables are supported, however this is very different from executing a program from within a PHP script'. So how would I call my Sudoko.exe file? The 'dialog': My last question seems to have been 'fixed' before being answered, so I'll have another go. I'm trying to call an .exe file on the server but get an 'unable to fork' error message. I have Apache/php installed locally and it works fine. Do you have to turn on 'cmd.exe' permissions or something? Try it yourself at: Warning: passthru(): Unable to fork [Sudoku.exe (argument...)] in (.php file...) It's the same with exec() as well. We do not support passthru or exec functions. So how would I call my Sudoku.exe program from a php script? I do not want 'scripting help', I just want to use some of the functions that you offer as a host and which I have paid for. As I have said what I am trying to do works perfectly on my machine, so it must be a question of something you have to enable your end. What do you mean you don't support passthru or exec? They are both standard php commands. . You asked "how would I call my Sudoku.exe program from a php script?" clearly this is asking us how you can use scripting? Certain functions are disabled in PHP for security reasons. Which functions are 'disabled in PHP for security reasons' ? You can find this out with the inbuilt php function phpinfo() Could you tell me where on the page that phpinfo() produces these functions are listed? For example, passthru() does not appear to be on the page. . search for "disable_functions" on that page. disable_functions lists 'no value'. So again, could you tell me where I can find the list of standard php functions which you have disabled? Please can you provide a link to your phpinfo file so we can investigate this further. We had previously checked this on a linux server, which showed the functions that have been disabled. We've passed this on to an engineer to investigate further. For your information the following are disabled: shell_exec,exec,system,passthru,popen Your knowledge base says: Q. Are CGI (Common Gateway Interface) executables supported? A. Yes these are supported on either the Windows and Linux servers But you are telling me that the only php functions which can call my executable are disabled. Will you clarify once and for all if I can call my exe file or not. I AM NOT ASKING FOR SCRIPTING HELP, I have books about that. I just want to know if I can do ON YOUR SERVER what you say I can do, and if not why not.
System(); Command Not Working On Remote System. Windows.
My server is a windows machine, on the same domain as python(also a windows machine). Apache is running as a service as an administrator. This is a test only environment to whom it may concern(I hate people telling me how insecure my system is) I'm just trying to run: $last_line = exec('dir pythonc$', $retval, $g); print_r($retval); echo '<br>'.$g.'<br>'; echo '$last_line= '.$last_line.'<br>'; Which outputs: Array ( ) 1 $last_line= The command from the command line works fine. And apache can access directories that only administrators can access on the local machine.
Displaying Result 1-8, Then Result 9-17 Etc.
I dispaly the results from the database like this. <? while ($row = mysql_fetch_array($prod_result)) { $small = $row[0]; echo"<td align=center><img src="produkter/hardware/decks/$small"></strong></td>";}?> But if there are more than 8 results, I wnat to dispaly the first 8 on one page, then the next 8 on the next page...How can this be done?
Nesting Result Loops Within Result Loops Possible?
I'm looping through a query, and inside the while result output, I am trying to loop through a second query (created from the 1st query's row results). I have checked that both queries return info. I can see that the 1st while result output works fine, but when I get to the inner while result output, it never returns any rows (nothing in the while loop evaluates). So, IS it possible to nest one query's output loop within another, or am I doing something wrong?
Quickly Adding Text To A Mysql Text Field That Is NOT Empty
Is there a way to insert text into a mysql text field that already has text into it; without having first to extract the existing data and append the new text to that string variable and then insert the new string. Basically i'm looking for a way to do it with a single query not 2 (one being a select to gather existing data).
Gaining Access To How MySql Parses Text For Full Text
I want to gain access to the function or process MySql uses to parse words and phrases for Full Text searching. Here is an example. If the user inputs... Milan in history MySql will search for milan, history, and milan history. Is there a way to extract just the combination of terms MySql uses to search the db without the stop words? Stop words are automatically eliminated from the search request unless the user encloses a phrase in quotes. What I am trying to do is develop a script to highlight found search terms and phrases. I can explode a phrase into single words but if I do that the stop words would be included in the array. If there is some way of getting into the parsed words or phrases MySql Full Text actually uses to search, I can use each of those combinations as a keyword in my highlighting script. This request is about searching for the code or any code related to the questions involved.
Text Area Not Accepting Large Amounts Of Text
I have a form where teachers enter homework assignments and they are then stored in a MYSQL database and retrieved elsewhere. I have been using "get" with the form. The code is simple: <textarea name="array[assignment]" cols="60" rows="10" id="array[assignment]"></textarea> It does allow post of 100 words, etc. Stuff that teachers normally submit. What's happening is that it won't allow very large posts (over 300 words maybe? ) Not sure what the cut off is. When you press submit it won't go, or there is an error where it won't submit. Is there a limit for text fields? Since the fields scroll, I didn't think that having only 60 rows was any type of real limit, I though you could put in as much as needed. But then all of it ends up in the address bar, so there must be a limit of some sort.
Read And Display Japanese Text From Text File
I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with the same problem. The plan was to make a script to read and display japanese text. I will use it for making a japanese proverb script and for a japanese language study script. Method : I wrote a simple kanji text file (saved with UTF-8 encoding) I wrote a simple PHP script to display the file contents (saved with UTF-8 encoding) I specified the content-type header for the HTML page : <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> *** All files have the same encoding. *** UTF-8 supports japanese characters. and it works! this is my PHP (and HTML) script : <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>PHP : Japanese Text File Read : Exercise 1</title> </head> <body> <?php $filename="japanese.txt"; //open file $fp = fopen($filename,'r'); //loop through each line in the file while($line=fgets($fp)) { //output current text file line print $line."<br>"; } //close file handle fclose($fp); ?> </body> </html> I know it's a very simple script, for testing purposes only. It displays the contents of the japanese text file line by line. The key was to save all files in the same encoding (I used UTF-8) and to specify the encoding / charset in the HTML header (<meta http-equiv="Content-Type" content="text/html; charset=utf-8">)
Exec(curl --proxy ....) Or Passthru(curl --proxy....)
I am trying to do some proxy stuff , I am able to retrieve the page but not able to catch the return , what I am doing is passthru("curl --proxy 195.115.142.120:80 xyz.com"); or exec("curl --proxy 195.115.142.120:80 xyz.com"); It throws the results (displays the xyz.com) to my page but I want to catch that in a variable like $variable=passthru("curl --proxy 195.115.142.120:80 xyz.com"); or $variable=(some php fucntion)("curl --proxy 195.115.142.120:80 xyz.com"); echo $variable , should give me the page.
Append Text At End Of Existing Text On Same Line
I'm working on a part of my web site that uploads images, then writes the name of the image to a text file. The upload part works fine. The part that writes the name of the image to the text file works fine. What I'm trying to do is, after all the files have been uploaded and all of the image names have been written to the WriteTo.txt file, append a written description of the picture at the end of the picture name. In other words, after a user uploads their pictures to the server I want to direct them to a page where they can label each of the pictures using a form. PHP Code:
Adding Text To Text Window With A Button
I have made an admin section of a site, What i want to do i have buttons under that have "BOLD" "center" and when clicked it adds <b></b> tags to the text area etc etc.. if the text area was called "message" how would i going about coding the images / buttons to add the code?
PHP - Using Mail() And Unicode Text - Text Gets Disturbed
I have the following problem. On a website there's a (simple) feedback form. This is used also by Polish visitors who (of course) type Polish text using special characters. However, when I receive the text in my mailbox, all special characters have been turned into mess...... For example: "wspólprace" is turned into "współprace". It seems PHP is handling the Unicode-8 strings quite well (when I 'echo' the strings on the site, I see the text correctly), until the point that it is send by using mail(). Is this a server configuration issue? Or something else? How can I get my text to remain in Unicode? I have this problem both on my testserver (Apache 1.3.28, PHP 4.3.2 on Windows XP) as on my providers server (Apache under Linux).
Remove Text Header In Text File
I have been having trouble removeing two header lines at the top of my txt file. You will see in my code the different things I have tried but with no luck. Below I posted my script and data. I am doing a few other things in my script as you will notice but this is the only thing I am having troble with. Code:
Parsing Text - Capture Text Between Two Tags
I want to have text in files, such as {body} {/body} and then be able to open that file and grab all of the data inbetween those tags. I could open the file and go through it until I see the {body} tag and then store data until I reach {/body} but that is a bad way to do it.
Text Returned From DB Gets Cutoff When Placed In A Text Field
I have a string that contains an apostrophe or a quotation mark, stored in a DB. I can retrieve the data, and display it properly (for editing) in a textarea, but when I try to put the string in a text field, it get's cut off right before the questionable character. For example: $string_in_database = "John's car." -displays correctly here <textarea><?php print $string_in_database ?></textarea> and displays this - John's car. -gets cutoff here <input type='text' value=''<?php print $string_in_database ?>' /> and displays this - John I've tried adding slashes and stripping slashes and I just can't figure out what I need to do.
Keep Text In Text Boxes After Form Is Rewritten
I'm trying to make a form that does the following: (1) the user answers a question by typing in a text box (2) a response is then written below the form, saying whether the answer is right or wrong and, perhaps making a comment of some kind (3) the user's answer remains visible in the original text box I've managed to write some code that does the first two things, but despite many attempts and much searching for code examples, I've failed to find a way of getting the answer to reappear in the text box when the page is rewritten. This is my code:
GIF Format
Is it safe to write scripts that support the GIF format because ive been reading some stuff about this and it's got me thinking Can anyone tell us what's the standpoint regarding PHP developers and writing scripts that support the GIF format.
SQL Last Result
When querying and doing a loop I want to specify that the last result of the loop does not include a horizontal line. How would I do this?
Format Numbers With PHP
Hi!! I want to display a number with a monetary number. Ex. US$12,345.87 is there a function a something way to do this? Yes , I know that I can do but if it ready why invent the wheel again!!!
Date Format ...
I have dates with this format 1 9 99 00:00:00 I want to transform it in yyyy-mm-dd how can I do with php ?
Integer Format
I have some mysql field like qua integer (7). How can I display this field in screen like this 50,000.- ? I try to use printf($qua,"%5d) but it don't work... Thank
Save In UTF-8 Format
Did you succeed in solving the UTF-8 format problem regarding saving a text string in PHP for loading in Flash MX? What to do in the PHP file and do I have to do something in Flash MX?
Help On Date Format
I have this page where user select month day and year from a drop down list and when the user pass it to selectdate2.php it will be as treated one variable in a date format yyyy-mm-dd. any suggestion? this is the first page named selectdate.php <select size="1" name="month"> <option>01</option> <option>12</option> </select> <select size="1" name="day"> <option>01</option> <option>31</option> </select> <select size="1" name="year"> <option>2000</option> <option>2003</option> </select>
Date Format
I have a script running (with great effort and help from the group) that displays a date from a database and the amount of days to that date. I would like to change the date into a more "human" format. The date now displays: 2002-12-08 I would like to change it to: Sunday, December 08th Is this a property of mktime()?
|