Calling "php -f [file]" From Within Perl Seems Broken
I've recently decided to switch from compiled Apache/PHP to RPM's of
both and I'm having a problem I can't seem to solve. I have a Perl
script called php_include.cgi that parses a PHP file for inclusion. It
does this by running "php -f [php include file]" but unfortunately it
no longer works with the RPM:
----------
Security Alert! The PHP CGI cannot be accessed directly.
This PHP CGI binary was compiled with force-cgi-redirect enabled. This
means that a page will only be served up if the REDIRECT_STATUS CGI
variable is set, e.g. via an Apache Action directive.
For more information as to why this behaviour exists, see the manual
page for CGI security.
For more information about changing this behaviour or re-enabling this
webserver, consult the installation file that came with this
distribution, or visit the manual page.
----------
The RPM for PHP obviously compiles with --enable-force-cgi-redirect.
If I either set cgi.force_redirect = 0 in php.ini or set
$ENV{REDIRECT_STATUS}="200"; in my Perl script, this error goes away,
as expected.
The weird part is that I do something like this in my Perl:
print `/usr/bin/php -f /var/www/html/includes/footer.php`;
Which you would expect to parse and output footer.php. Oddly, it
prints the contents of php_include.cgi (the calling Perl script)
instead! If I run the exact same command in a shell (even as my apache
user) it works correctly. When called from the web, it displays the
Perl script, not the php.
I've confirmed this a bunch of different ways.
Yes, I know I could blame this on the RPM, but I'd like to move to a
"standardized" load if possible... Makes updates easier... Also, this
one's got my curiosity...
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
2>&1 Arg In Exec(perl.... + "sh: /perl Not Found Error" TIA For Help
I have the following line in a php file: $msg= exec("perl $scriptPath/insert.pl $d $u $t 2>&1", $returnVal); Can someone explain the "2>&1" argument? Second problem, this same line of code when run from the unix command line returns the following error: sh: /perl: No such file or directory I've verified that perl is located in /usr/bin/ /usr/bin is in the environment variable "PATH" all the directories from php program to the root and back down to usr/bin have 755 permissions. if I run the program (insert.pl) from the command line it works I've tried putting the following in both the php and perl programs: #!/usr/bin/perl #!/usr/bin
Echo "<!--#include File="top.html" -->";
I have a search script which returns a page of results, however I'd like the returned page to be in the same format as the rest of my site. To do this I've tried adding the HTML for my site to my PHP page with echo" " commands. This works for the plain HTML, but my regular pages also use SSI to do other stuff (some of them even execute other PHP scripts to generate tables of data etc). I've tried echo "<!--#include file="top.html" -->"; but it doesn't work as I get a parse error. My question is, how do I go about doing this properly? Is this possible at all? And if not have you guys got any suggestions to get around this?
Any File Size Limit In <PARAM Name="***" Value="***"> ?
I embed an applet in my php script which has a parameter providing an input file for the jar. Does this file has size limit? The code is as follows: <APPLET ARCHIVE="myapplet.jar" WIDTH=372 HEIGHT=360 VSPACE=0 HSPACE=0 ALIGN=middle> <?php echo "<PARAM NAME="data" VALUE="myfile.">";?> when "myfile" is beyond 15M, my applet cannot load sucessfully, but while this file is limited like 5M or 7M, it works well. Does anybody know is the reason caused by php script limit, applet mechanism, or by different browser?
Can I "include" A Perl Script With In Php Page?
I was trying to use "include" to execute a perl script in my pHP page. Instead, it just printed out the contents of the Perl script and didn't execute thes cript. Is there any kind of function which executes a script.. i know SSI has this.. does php? something like >> execute("cgi-bin/script.cgi"}
Bizarre Phantom Bug (Calling A PHP Script From An Apache "Action" Directive)
I am using an "Action" directive in my Apache configuration to map a certain file type (by means of AddType and AddHandler) to a PHP script. I wasn't sure if this would work, since the Apache docs say the Action directive is for mapping a handler name to a CGI script in particular. But it seemed to work at first. Then a mysterious bug arose: Sometimes it works perfectly, and other times the output is a totally blank page. It seems that if I haven't viewed a page for a while, it chooses to do one of these at random (though it is blank more often than not), and then it persists in the same behaviour until I reload it many times. (That is, usually a page appearing blank will eventually display if I reload it many times; however, only rarely will a correctly-displayed page regress to appearing blank after reloads.) Checking with `curl -i', it would appear to a client program that the request was perfectly successful: all the headers are there (with the correct content-type), it has an HTTP/1.1 200 OK line, and so on (and there's nothing unusual in the server's access or error logs), except Content-length is 0, and there is indeed no content at all after the two newlines. WTF?? Since when do computers behave non-deterministically? I should hope, if a program is not going to behave correctly, that it at least do so predictably and consistently. That would make debugging it much easier. But what am I to make of this Schrodinger's Bug? How do I even approach the debugging process? (Also, if anyone could suggest a workaround, an alternate method of having a PHP script handle files with a certain extension, then that would be just as welcome. Though I'd like to stay within mod_php, avoiding a CGI-based technique, because I'd prefer to not start a process every time these pages are requested.)
"Cannot Send Session Cookie ..." I Truely DON'T Output ANYTHING Before Calling Session_start()
there are many postings on this subject, I have read them put don't have an answer. I get these warnings: Cannot send session cookie - headers already sent in, but my php-scripts are okay. As you can see in the code and response below, I really don't output anything. = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = my PHP-Code #!/usr/bin/php <?php session_start(); if (!isset($_SESSION['content'])) { $_SESSION['content']=""; $_SESSION['task']=0; } session_regisyoter("content"); error_reporting (E_ALL); set_time_limit(0); ....
How Do I Do Something Like $color = ("red", "yellow", "blue")[$colornum]?
How do I take an index of a literal array, instead of a variable? That is, say I want to get the short name of a month. Can I do something like: $monthname = ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")[$month]; or do I always have to do: $blah = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $monthname = $blah[$month]; It seems a shame to have to create a variable specifically for this one-shot purpose.
Calling A Php Script Using Img Src ="random.php"
I have a small php script that calls a random image at the following page. http://www.2006ymcanationals.com/random.php IT WORKS IF I go directly to the above link. I am trying to call that in another page so that i get a random image the page is http://2006ymcanationals.com/index.php using <img src="random.php"> It is not working. I have tried using the full path to the "random.php". I have also tried naming the main page index.html and index.php. neither work. what am i missing? Searching these groups it looks like this should work.
Does PHP Have A Perl-like "print Qq"?
I'm a Perl programmer new to PHP. Anyone know if PHP has something like Perl's print qq? For you non-Perl programmers, it allows you to use quotes and all that stuff that normally needs a backslash without worrying about a parse error: print qq ~ I can type whatever "" I want more "text" @ ~;
Preventing Visitors Ability To "re-visit" A Page Via The "back Button"..
I have a rather complex registration/member sign up form.. which gets a little confused, when a visitor "backs" completely out of the form, then for whatever reason returns to the form. The form contains 'cancel' buttons, which naturally cancel the reg process and redirects them to the document just before they started. JS provides us with the "location.replace()" method, but I can't seem to find a way to coordinate the use of location.replace() with the posting of the form values. In short, I want to "replace" the first step of the form with the "second step". I think what's making this tricky, is that each step of the form are located within the "same" page (register.php). The document works like so: The first step is the "Member Agreement" when they click "agree" (submit) the system creates a new row in the temporary register table of the db. It then issues a registration cookie, which carries the row id, and session value. in addition (for those cookie impared users) we carry the row id and session value in hidden elements. So far, as long as the user continues through the process all is fine, but if they (for whatever reason) back all the way out, and click 'agree' again, the process fails. I guess I have to find a way to force a reload of the 1st step "if they've gone back" OR "replace()" the first step with the second, so as to prevent the user from going "back" to the 1st step of the register page.
Pagnation - Limit Number Of Pages Between "Previous" & "Next" Hyperlinks
Was hoping for some advice with a part of page navigation.... It works at the moment so there is a "Previous" & "Next" Hyperlink underneath the records. In between the Previous & Next links are the number of pages that there is of these records. e.g: Previous 1234 Next This is fine if there are only a few pages of records, but when there are hundreds of pages the numbers are listed and they take up half the web page with them. How can i make it so only limited 10 numbers of pages say appear between the "Previous" & "Next" Hyperlink and as you progress through the pages they are as do the next 10 numbers of pages? Code:
[regex] Stripping Out "name" And "value" Values Out Of Tags, Aaargh
Searched through the site, but couldn't find the right regex syntax I was looking for. the thing i want is, to extract with preg_match_all the given values in a tag... ex. $str = '<input type="text" name="name" value="value">' $pattern = some magic stuff I need to know preg_match_all($pattern, $str, $result); And in result I want to have the values text, name and value AND it's important that the order doesn't matter so structure of tags can be <input type =name= value=> or <input name= class= value= type=> etc, etc...
'Parse Error' Problem In "isset" And "empty"
I've been having some problems with a parse error that I can't figure out (PHP 4.3.11 on Solaris9). Sample code: <?php // getting strange parse errors on this class A { var $value; function A() { $this->value = 1; } function getValue() { return $this->value; } } $a = new A(); if (!empty($a->getValue())) { echo "success"; } else { echo "failure"; } ?> The result of this is: Parse error: parse error, unexpected '(', expecting ')' in /foo/public_html/parse_errors.php on line 15 I also get the same effect with "isset", however, testing with "is_null" or "is_int" produces the correct ("success"/"failure") result. Any ideas?
Multiple File Upload From Client Pc To Server Without Using <input Type="file"> Cont
I am working on a application which requires me to upload the contents of all the files from a particular folder in clent pc to the server. In my code i just want to mention the folder name which may contain any number of files.Folder name will always be fixed. I dont want to use <input type=file > control. Is there any way i can achieve this using FTP or any other way in PHP.Any help will be greatly appreciated.
How To Do PHP "require()" Or TCL "source" In Bash Script
I can't figure out how to explain this any better than this. In PHP we have a command "require()" that obtains a file and logically places it into another file. I cannot figure out how to do this in bash script as the requirement is necessary for a migration script to obtain the code from a .cfg file and then be able for the "parent" script to run the code it "imported" from the .cfg file, much like PHP's require() or TCL's "source". This is what I have so far and it fails: if [ -f ivc.cfg ]; then cat ivc.cfg fi Anyone really know bash script well please help, it's a barrier for me not to be able to get just this one piece working.
Error In Page When Checking Http_get_vars("myvar") And "myvar" Was Not Passed In URL String
PHP, coming from ASP coding if (HTTP_GET_VARS['b']==1){ print "Yes"; }else{ print "No"; } when "b" is not passed via (http://www.mydomain.com?b=1 an error occurs and the "NO" is printed but an error is printed too. How can I check for the value of "b" so that no error occurs if b is not passed?? example http=www.mydomain.com $myvar=HTTP_GET_VARS['b'] causes an error because "b" does not exist (ie. its not passed in the URL string. $myvar maybe evaluated as NULL or Empty but the error is printed in the page, anyway.
Getting The Remote File Path From <input Type="file">
I'm using a form to upload a file to save in a mySQL database, however I need to store the original file path on the clients (the user uploading the file) computer. The file path is shown in the field that selects the file, I just need to post it or save it in a session somehow.
Form "file" Field, Browse For Certain File Types.
I know I can't control the default browse when the user clicks browse next to a form file field. I.E *.pdf, *.jpg. Its just *.* - and I remember its something to do with security....but I cant remember the reasoning.
"copy()" Function Not Working With File Upload
Below is a multiple-file upload script. The form input part works ok. The variables $FileType, $FileName, $FileSize, $TempName, and $FileError work fine. But just after $FileError (which does not output an error message) the script just stops. The problem appears to be with the "copy()" function. I can simplify the script, make it just a single file upload script, use the variable $userfile for the first part of the "copy() function, and it uploads the file just fine. The problem is when I try to make it a multiple-file upload script like the one below - then the copy function won't work. I would appreciate if anyone could spot the problem. PHP Code: $Admin[UploadNum] = "10"; if($FileUpload) { for ($Number = 1; $Number <= $Admin[UploadNum]; $Number++){ if ($FileUpload) { $FileType = $_FILES["userfile"."$Number"]["type"]; $FileName = $_FILES["userfile"."$Number"]["name"]; $FileSize = $_FILES["userfile"."$Number"]["size"]; $TempName = $_FILES["userfile"."$Number"]["tmp_name"]; $FileError = $_FILES["userfile"."$Number"]["error"]; echo "File Type: $FileType<p>"; // $FileType prints out fine. echo "File Name: $FileName<p> "; // $FileName prints out fine. echo "File Size: $FileSize<p> "; // $FileSize prints out fine. echo "Temporary Name: $TempName<p> "; // $TempName prints out fine. echo "Error Message: $FileError<p> "; // Does not output error message - appears to work fine. // ------------ The script stops working right here ------------ if (copy ($_FILES['userfile'.'$Number']['name'], "users/".$_FILES["userfile"."$Number"]["name"]."")) { echo "Your file was successfully uploaded!<p> "; } else { echo "Your file could not be copied.<p> "; } } } unlink ($userfile); }else{ echo "<form action="$PHP_SELF" enctype="multipart/form-data" method="post"> "; for ($Number = 1; $Number <= $Admin[UploadNum]; $Number++){ echo "<input name="userfile"."$Number" type="file" size="25"> "; } echo "<input name="FileUpload" type="submit" value="Upload Files"></form> "; }
Value Of Variable Shown As "Array" When From Included File
I have this statement to find the latest date that a row was inserted ________ $entry=mysql_query("SELECT contact FROM board ORDER BY contact DESC LIMIT 1")or die ("Query failed:<br>$entry<br>Error: " . mysql_error()); while($myrow=mysql_fetch_array($entry)){ if (ISSET($myrow['contact'])){ $latest = date("d M y", ($myrow['contact']+50400)); } } ________ This reports the value for $latest correctly if the statement is in the document. However when the statement is in an included file the reported value for $latest is ... Array Where am I going wrong?
Include("....file.php") Doesn't Work (error 2039)
I have a problem with include. I am develloping a site www.mobiclips.net. I have placed the php files dealing with the gui, getting the pictures and the download all in seperate folders in the root. Now I want to include the header an db.php,which are in the root. I have to use something like this <?php include("....dbconnect.php")since I grouped all php related to each other in one map which itsel is in the map called PHP. It works fine on XP amd windows 2003, but it does not work on the webserver on linux. Notthing shows up. A few test showed that .. go up a level doesn't work. When I put Echo ERROR_ALL I get error 2039 ...
Validation Return Query? - Type="file"
When a user clicks submit on my form, it will return with a list of errors and will populate all the fields with the correct data that the user has already entered. ie.. <input name="contact_name" type="text" value="<?print $contact_name; ?>"> ... and so on throughout the form. This works fine except for when I try and populate a file textfield with the file the user has tried to upload. <input style="width:200px; " name="userfile" type="file" id="menu_textbox" value="<?print $target; ?>" /> I am not sure how to approach this. When the user hits submit and the form returns errors . . the files path will not be saved to the database. But as I dont know how to populate type="file" with the file the user already selected, when they hit submit again. obviously no file will be uploaded.
Coding "NEXT" And "PREVOIUS" Buttons
Hi I am stuck here. I am doing a form which dispalys details of client companies. My query includes this statement: .... WHERE CompanyName LIKE %$name% .... What I need is following: if a query returns more then one result I what to "flip" through result with NEXT and PREVIOUS buttons.
Mysql/php - "LIMIT" And "ORDER"
In the following fragment of code, I am querying a database that in order to display a list of films. The list is very long and I would like to offer the possbility to restrain the range of results showned by page keeping in mind that the user should be able to browse forward or backward data if applicable. I know that I have to add the LIMIT method in the MySQL query but I have a hard time figuring how not to get lost in setting it dynamically in the PHP script. Then I have a second question. Is there a more elegant / straightforward way to deal with the display order of the data (cf. $ot, $od and $oy)? Code:
Sticking "if" Or Changes Within A MySQL "where" Array?
I'm not exactly sure how to even ask the question, and I know my terminology is not good as I'm a SQL beginner, but, here goes. I need to find a way to make an if statement within an array...or, the "while" portion of a recordset. The best way I can ask is show what I mean. http://oscarguy.mechphisto.net/awardbrowse.php If you go there and select an award (like Best Picture), leave the year field alone, and select YES and submit, you'll see a lot of results. And I have HR's dividing each entry. What I need to do is group all the entries of the same year, or at least only put HR's between the blocks of years. So, I'd have all the entries for 2002, an HR, then all for 2001, an HR, etc. Here at the bottom I'll include my PHP code I'm using so far. But I have no idea where to even start looking for an answer...if it's even possible. If someone can just give me the name of the function or process or technique, then I can go Web/book searching myself...I just need a direction of where to go. PHP:------------------------------------------------------------------------ ------ $query_RS_award = "SELECT * FROM $award WHERE id != Ƈ' ORDER BY year DESC, w DESC"; //$query_RS_award = "SELECT * FROM $award WHERE year = "$year""; $RS_award = @mysql_query($query_RS_award, $connection) or die("Couldn't query: " . mysql_error()); $totalRows_RS1 = mysql_num_rows($RS_award); while ($row_RS_award = mysql_fetch_assoc($RS_award)) { $award_id = $row_RS_award['id']; $award_tblid = $row_RS_award['tblid']; $award_award = $row_RS_award['award']; $award_year = $row_RS_award['year']; $award_category = $row_RS_award['category']; $award_won = $row_RS_award['w']; $award_film = $row_RS_award['film']; $award_nominee = $row_RS_award['nominee']; $award_note = $row_RS_award['note']; if (!($award_category)) { $award_category = "n/a"; } else { $award_category = $award_category; } if ($award_won == "1") { $award_won = " - Award Winner"; } else { $award_won = ""; } $display_block_Award .= "YEAR: <span class='normalText12White'>$award_year</span><br>FILM: <span class='normalText12White'>$award_film</span><br>CATEGORY: <span class='normalText12White'>$award_category</span><br>NOMINEE: <span class='normalText12White'>$award_nominee</span><span class='normalText12BoldWhite'>$award_won</span><br><blockquote><span class='normalText12White'>$award_note</span></blockquote><hr>"; }
Cookies And "include" Or "require"
i'm having a problem with my setcookie() instructions. Although there are absolutely no html tags in front of them,for some reason PHP3 sends me back the message "oops...php3_SetCookie called after header has been sent"... I do however use two "require" calls, one to a file with a .php extension, and one to a file with an .inc extension. At the beginning of each files there's a Could the cookie failure and the include functions be related ? In my text, I have even wiped out any HTML tags such as "bold, paragraph, line break" tags, even in "echo" commands, but to no avail what am i doing wrong ?
FTP_login + $pass="" And $user=""
I use the following scrit in an Intranet with the user name = "" and the password = "" : <?php $ftp_server = "192.168.25.25"; $ftp_user = ""; $ftp_pass = ""; $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 at $ftp_user@$ftp_server "; } else { echo "Can't connect with $ftp_user "; } ?> I have the following message : Connected to 192.168.25.25 Warning: ftp_login(): 'USER': Invalid number of parameters in E:www est_ftp.php on line 26 I tried to : ftp_login($conn_id, "", "") but i have the same result...
Why Use "Stripslashes" And "Addslashes" Function
Can someone let me know why one would use strip slashes or add slashes functions. I know what they do but cannot see the exact use for them e.g. if i have a textfield and encase it in an stripslashes function, it will escape any back slashes etc...
Catching "File Name Too Long" Errors
Is there a way to redirect on "file name too long" errors? I'm using mod_rewrite to handle all unknown urls with an error page. That's not working for this error. Apparently the "file name too long" error occurs before mod_rewrite is invoked. Setting up an ErrorDocument is also ignored, even though it looks to the user (and listed in access.log) as a 403 error, it's not a normal 403 error.
Saving An Image From A "file" Form?
How do I recieve a picture from a form off a website and save it to a directory? I use the "file" form to allow the user to browse their local drive but how do I get the actual picture so I couild use it later?
How To Delete A "readonly" File In Windows?
Got the following problem: PHP has no problem with deleting an ordinary file, but when it is marked as "Read-Only", I get such an error: Warning: unlink(Z:/home/localhost/www/***.html) [function.unlink]: Permission denied in z:homelocalhostwwwoddik est.php on line 45.
"not A Valid JPEG File"
I am trying to upload an image to a server, but I get this warning: Warning: imagecreatefromjpeg(): 'filename' is not a valid JPEG file The error occurs when I am trying to create a thumbnail from the image. I can subsequently display the JPG image itself, but the thumbnail creation fails. I have tried this with hundreds of other images from the same source and they work fine. I have looked around on Google and it seems that others have had this same problem, but I have not been able to find a solution. Is this a PHP bug? Is there a workaround? Should I just trap the warning and tell the user (my users will upload their own images) that the file is not valid? They will surely question this, because seemingly every other image displayer has no trouble with it.
Reading A "live" Log File?
I have come across a situation where it would be useful to read new lines being added to a log file on the users system. I have never seen anything like this discussed before so was curious if anyone had any prior experience with something of this nature. I am familiar with reading and writing to text files but not in real-time constantly.
Writing "quotes" To A File...
I am currently working on right now requires me to output quotes into a text document. How could I go about outputting quotes? (If i add quotes it finds it to be part of the syntax..I have something similar to this: PHP Code:
File Uploading; "image/jpg"
I've created a file upload for images, and would like to duplicate one for other files that do not include images, with limitations (i.e., I don't want people uploading .exes, .ppts, etc). Is there a list of all of the file types and extensions? Y'know, like "image/jpg", "image/png", etc? The reason I'm asking is because I'm not sure what I should type before "/ext" ("movie/wmv"?), Word document ("word/doc"?), or other files.
Parse Errors With "case "action":
I want to call an action that is in a file called "configm.php" but I get a parse error on line 8. (the bit that goes 'case "add":') Code:
Purpose Of A ".inc" File?
If a file has a .inc extension, or if it has a .inc.php extension, is it treated differently by the php interpreter? Or is it just a convention? I've been calling my included files filename.php and it doesn't seem to hurt anything. Is it wrong to do that?
Removing " ^@ " From A File
I have a file on my Linux box that has this strange control character combination (^@) in it at the beginning of every line. I can only remove this from VI. I have tried using sed, tr, and others to remove it, but none work. How can I remove this control character sequence via PHP?? ^@^@ ^@^@ DPCA ALIASI ALIASN/N24 CLLI LSN RC APCA ^@^@ 208-000-000 ------- ----------- alias208000 bi403239 0 208-001-000 ^@^@ bi403240 0 208-002-000 ^@^@ cc403000 10 235-002-000 ^@^@ 235-243-002 ------- ----------- ----------- bn403131 0 235-007-000 ^@^@ bn403132 0 235-006-000 ^@^@ cc403000 2 235-002-000 ^@^@ 226-251-070 ------- ----------- vancbcxpgt0 bm403044 0 226-008-000
"No Input File Specified."
As an experiment I wrote a simple C program that invokes PHP using system(), but I'm getting an error "No input file specified.". What I do is: setenv ("REQUEST_METHOD", "GET", 1); setenv ("QUERY_STRING", "abc=123", 1); and then I invoke PHP thus: system "/usr/local/bin/php myfile.php < dummyfile > foo"; where dummyfile is either empty or just contains the line "abc=123". Yet, I get this error. No finnagling is fix it.
Strip "-" Out Of File Name?
How do I strip out the - in a file name and add a space in its place? example: 123-456.php I want it to print on a browser as: 123 456 echo "<a href="$PHP_SELF/articles/credit_repair/$filename" target="_BLANK">".substr($filename,0,strlen($filename)-4)."</a> | ";
How To Count "Hit" And "View"
I would like to know when a user logs in, he clicks Mike's E-mail. It will count one which mean "Hit". So that I will be able to know how many times users click Mike's E-mail. Like Sitepoint. When other users read other problems. Views will count 1. I would like to know how to do it. Could you explain with script?
|