Capturing The Entire URL
Been playing around with capturing the entire URL. I dont have any problems
if it a file,
i.e. http://www.mydomain.com/somefile.php, I am running into problems with
this,
http://www.mydomain.com/test
This is what I use for "redirection" now (btw, it is IIS (Win2k) and PHP
4.3.2)
The test.mydomain.com is setup as a host header under IIS
$redirect = getenv("HTTP_HOST");
if ($redirect=="test.mydomain.com"){
header("Location:http://www.mydomain.com/modules.php?name=test");
}
The above code works fine. Redirects no problem.
However, I am trying to get this to do the same thing:
www.mydomain.com/test or www.mydomain.com/test/
and both would take you here:
http://www.mydomain.com/modules.php?name=test
I have tried every combination of the SERVER vars, but no luck.
I either generate a 404 or the test isn't part of the URL.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Capturing URL
I have a form that composes and sends me an e-mail. Within the message, I would like to dynamicaly include the URL which the form was completed in. It needs to be dynamic because I want to use this form on many different pages.
Getting The Entire URL
You know how someone submits a form, and it goes to process_form.php, and after processing, redirects it back to that page? How can I get the URL of my page, and after the person submits the form, take them back? For example: viewtopic.php?topic=32&post=4&id=33 Can I store that portion of my URL (along with all the variables)? (I have heard of $_SESSION['url'])
Capturing Input From A Form
I currently have a search form on my website. When you type something in, it redirects you to a page that displays the results. I would also like the users searches to get input into an access database at the same time. How would I do this?
Capturing Data From A Radiobox
I am a beginner to web design. I want to create a personality test for my site. Here is what I want ... I want my test to ask 4 pages worth of questions. I want some questions to be weighted more heavily than others I created some questions using HTML forms and radio boxes. How can I capture which option was selected?
Capturing $_REQUEST And Reusing It Later
I'm working on an authentication system in which it's possible that a user might be requested to log-in as a result of submitting a form if the inactivity timeout is exceeded. In order that they don't lose the information in the form I would like to capture this information ($_RESULT), serialise it and store it in their session. After they've successfully logged in I would like to retrieve this information and put it back in $_RESULT so the user can carry on with what they were doing. Is $_RESULT meant to be writable in this wayand is there any reason why this isn't a good idea?
Capturing Data From Another Php File
I'm trying to capture data that is created by launching a php file, for example the last 10 posts in a message forum. If last10.php is called directly in your browser you'll see hyperlinks to the last 10 posts. This file is located in /home/mydomain/last10.php . Now I'm trying to capture that data in a template in a CMS I'm using where you can launch php scripts. I'm just unsure how one can "run" last10.php and capture the stream into a variable and then include that variable to be outputted in another template. As long as I capture the stream, that variable can simply be placed in another template so I'm not so concerned about that. Now I'm familiar with includes and requires, but this doesn't really "launch" the file, it only includes the items so that you can use the variables from my understanding. The problem is that I need the whole stream from the last10.php to be captured into one variable that will then print out this html that was output. Learning this stuff is truly amazing... I hope to quit my day job. :)
Capturing Form Input
I will try to be short and to the point.(good Luck) I have a form written in HTML. I have a Mysql database. I am using a linux server and I would like to use php to write the following code: After the user inputs their name, address, email, phone, etc. in my html form. They will hit the submit button. I need for the information they entered to go into my database. I have looked now for about 12 hours and haven't been able to find an answer. I know I must be missing something since I've been to the w3 site, codewalkers, phpfreaks,php.net(?), and many more. If there is an easier way of doing this I would love to hear it. If somene could point me in the right direction I could stop banging my head and pulling my hair.
Capturing Substrings With Preg_match_all()
I'm experiencing a problem when trying to capture substrings with preg_match_all() from strings like "set('Hello','World')" using the following Regular Expression (PERL syntax): "/^set((?:'([^']+)'(?(?!)),))+)$/" The resulting matches array looks like this: Array ( [0] =Array ( [0] =set('Hello','World') ) [1] =Array ( [0] =World ) ) I wonder why "Hello" is not in the matches array. Did I do something wrong in my Regular Expression?
Capturing Windows Login Name
I know it is not possible to get Windows login name using PHP because it is a server-side script, but I dunno whether anyone has tried using JavaScript in conjuction with PHP to capture the login name and save it as a php variable. Here is the JScript I used to capture the windows login name:
Capturing The End Of A URL? Session Variable?...
I have a system where users log in, and then they can see a list of documents. There are 15 document names listed at a time, with "next"/"prev" buttons to navigate to the next/prev set of 15 document names. When they find the one that they want to edit, they click the "EDIT" link next to the document name, and it takes them to the fields to edit. All of this works just fine... When they've submitted their edits (or if they click a "Go Back" link on that update page), it takes them back to the default "documentList.php" page. I want to know if there is a way to (when they click the "EDIT" link on the document list page, maybe?) to capture all of the stuff after "documentList.php" in the URL (starting with the "?"). That way, instead of having them always go back to the first set of 15 records, I can have the "Go Back" link send them back to the last set of 15 records that they were viewing (that would have the record that they last clicked to edit)... If there's a different way from what I described above to approach my same end-result that I want, I'm open to that suggestion as well.
Capturing/using Results Of Query
I would like to display/capture/use the URL's that are displayed on a web page after making a query to a forum. What do I mean? I am part of a forum that uses vBulletin. One option is to display the forum topics that have had posts that day, i.e. active topics. Essentially, when you click on the link: http://www.somedomain.com/forum/search.php?do=getdaily the resultant page has a list of the active topics, highlighted as links. What i would like to do is capture/access that resultant page and use regular expressions to grab the URLs. I can do the RegEx but I cannot seem to capture that resultant page.
Capturing An Image Produced On The Fly
I have a script running on Server1 that creates an image, saves it, then loads it and sends it to the browser, then deletes the image from disk.....Server2 needs to have access to that image, and have the ability to manipulate the image. Server1's address would look something similar to http://128.23.23.23/file.php?name=picname Now what I need to do is access that image from Server2, and save it as a jpg. Code:
What Can Return The ENTIRE Url?
I'm looking for PHP equivalent to Javascript's location.href property. This returns the ENTIRE url (including any variables that might be submitted to a script). I've looked at phpinfo(), but I didn't see exactly what I am after. If the answer is the HTTP_POST_VARS variable, could someone please give me a simple example of how exactly this variable is to be used in code?
Capturing Data After Question Mark
On the first page I have: <a href="jobs4.php?id=$myrow[0]"> So on the next page I'd get: 'jobs4.php?id=1' On the next page how do I select from the database where id= the id that was passed through (in this case 1)?
Capturing Output Of Another Script As A String
I have a client who has decided to output the OO PHP/mySQL site I have made for them onto a cd. I realize that $html = include('somefile.php'); gets 1 for success as its return value. In what manner can I access my files so what would be output to the browser from 'someFile.php?id=1213' gets into $someVar as a string so I can write it to a static file for the CD?
Capturing User Leaving Site
What I was thinking is checking to see how much time has elapsed for a visitor session with no activity and if too much has passed (say 5 mins) then use that as a end of session time.
Capturing File Modification Times
I was just wondering if it was possible to capture a file's modification time before it is uploaded through a from post. For instance, I know you can get the name & type of file's orignal values as the file is being uploaded but is it possible to get the mod date?
Capturing Results Of A Form Submission
Is it possible, in PHP, to capture the resulting HTML of a submitted form returning from a server and incorporate that HTML into say a table, or some predefined layout? I am trying to incorporate the resulting HTML into a layout I have created in order to keep the look & feel of my site consistent, but the resulting page is a plain "cheesy" page.
Capturing Output From GPG Command In Shell...
I have finally sorted out that it was permissions that were preventing me from running the gpg commands I was trying to run and I can now run them. The problem is that I am having real trouble capturing the output from the commands I am running. Just to be clear; $output = shell_exec("ls -l"); echo $output; does echo to the browser what one would expect ( a long string containing the results of the command). Unfortunately, when I run this command: $output = shell_exec("/usr/local/bin/gpg --homedir /usr/home/manager/.gnupg -b test.xml"); and then I echo $output I get nothing out of the variable - I'm stumped. The command does work - I have run it on the server from the command line and it does sign the document by creating a detached signature (as I want it to do). Am I missing something?
How To Copy An Entire Array?
can I do this? You see, I want to pass my values in to another page, but you can imagine how it would be insane to try and copy each value in the array individually <A HREF="thepage.php?array[0]=$array[0]&array[1]=$array[1]... etc is there a way to compress an array into a single variable, and then decompress it like: Code: $compressedArray = compress(0, 10, $array); where 0 is the start index, and 10 is the end index then when I want to use it on the other page Code: for ($x=0; $x<=10; $x++){ $newArray[$x] = decompressMe($x, $compressedArray); } I'm sure that there must be some simple little thing like that.... I looked at the php manual, but couldn't really see anything like I'm talking about (or maybe I dont understand it )
Preventing Entire Db Download
I've collected some data and created a db. I am putting together a website allowing users to search the db with a search-query functionality. I am pretty much building a google-like engine, although the data is stored in a MySQL. If I use a GET form in the search page (which is what most engines do), then the query results are displayed in pages where the URL contains the query_string (example, www.blahblah.com/search.php?queryitem1=my1&queryitem2=my2+my3). So far so good, but in my case the data is of a local nature (say, a yellow page type of thing with some extras) and someone can basically pick the entire database by running a script like: wget www.blahblah.com/search.php?zip=00001 wget www.blahblah.com/search.php?zip=00002 .......... wget www.blahblah.com/search.php?zip=99999 This is something I would like to prevent. Could someone please offer their opinion on: 1. how to best go about it with a GET form? 2. Is it indeed doable with a POST form in the search page (as opposed to a GET form)? 3. I've read that the main advantage of a GET vs POST form is that someone can bookmark a search results page (eg. www.blahblah.com/search.php?zip=12356) if it the form is GET. Any other advantages/disadvantages that i am missing?
Passing An Entire Array In PHP
I saw a previous post about sending arrays but did not quite understand the answers. The problem is that I would like to pass an entire array as a hidden input field from one php script to another. I've simplified the code where form1.php calls form2.php when "Go" is hit: form1.php ========= <html> <head> <title>Form 1</title> </head> <body> <h1>Form 1</h1> <form action="form2.php" method=post> <? $record[0]="One"; $record[1]="Two"; printf("<input type=hidden name="record[]" value="%s">",$record); ?> <input type=submit value="Go"> </form> </body> </html> form2.php ========= <html> <head> <title>Form 2</title> </head> <body> <h1>Form 2</h1> <? $record=$_POST['record']; printf("$record[0]=%s",$record[0]); printf("$record[1]=%s",$record[1]); ?> </body> </html> The result is: Form 2 Array=Array= How do I fix this?
Copying Entire Directories
I need to copy all of the files from one directory to another. This has to happen on the fly. The files that are being copied are actually templates for another site that will be created. I have seen the example on php.net under the fopen section but it doesnt work.
One File Throughout Entire Site?
I would like to have a file header.php used throughout my entire website. When I do this however it does not work 100% For example the file maybe in /home/header.php with 10 hrefs for the site. Then if a inc() in /home/dir1/dir2/ uses the file it will of course link wrong. For example Code: <a href="dir1/"> If this is in the header file in the /home dir then when the file in /dir2 uses it of course teh link will look like this to the broswer Code: http://www.domain.com/dir1/dir2/dir1/ of course this is not what I want. Everytime I make a change I'm having to make it to over a 100 files so I would like this one file to be used throughout the entire site.
Any Way To Upload Entire Folder?
I'm currently working on a little program that will allow different departments within where I work to upload videos (like training videos or safety videos) and then keep track of who watches them. My guess is that I'll do most of the uploading myself, but I wanted to make it such that I can give anyone access to the upload script so they could do it themselves. Anyway, we (at the office) all agreed that Flash is the best format for security and ease of distribution. We went out and got a program that will allow conversion of video files to flash and also allow them to have a nice table of contents and controls. The biggest problem is that for the TOC and controls to work on the flash videos, the program creates a friggin mess of files that all relate to each other... and this screws up my 'easy' upload idea. There's no way for this program to create a nice single .swf or .fla that has all the controls and TOC built in, at least not that I've found. :( Is there any way, other than zipping up a directory and writing an unzipper for the server side, to allow a user to specify a directory where the video resides and just up the whole thing intact? If not, I suppose I'll have to settle for the single .flv file that is created and dump the controls and TOC... though that's part of the reason we bought this converter program. I'm trying to write it in such a way that it will also play mpegs and avi files down the road if that's what the department has, but to start out we're asking that they send us the movie file so we can convert it to flash.
Capturing User Login Information Of Windows
I want develop the intranet site with seamless authentication. Is there any way to capture only the user name who has logged in the windows machine. Iam using PHP 5.0 MySQL and IIS Server. I have tried with $_SERVER['LOGON_USER'] but its returning nothing.
Problem With Preg_match With Capturing And Back-reference
I'm trying to detect and extract a quoted portion of a string. The quote chars may be the usual quote, the "single" quote (apostrophe) or the back-tick quote. For example: $vl = "My O'Name"; if (preg_match ( '/(["'`])([^1]*)/' ) , $vl , $x ) { // found it } The first parenthesized expression will capture the leading quote (whatever it is). The second *SHOULD* capture everything up to, but not including, the matching trailing quote. What I get is $x[1] contains the quote (as expected), but $x[2] is everything up to AND INCLUDING the trailing quote.
Capturing PERL Script Output Into PHP Variable
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: ------------------------------------- test3.pl ------------------------------------- print "PERL Hello from Perl! (plain print)<br> "; print STDERR "PERL This is text sent to STDERR<br> "; $output="PERL Some output:<br> "; for ($i=0; $i<5; $i++) { print STDOUT "PERL $i: This is text sent to STDOUT<br> "; $output .= "PERL line $i of output---<br> "; } print $output; exit; ------------------------------------- passthru3.php ------------------------------------- <? $command = "/usr/local/bin/perl"; $pgm = "test3.pl"; print "PHP: Before passthru, in PHP...<br> "; $result=passthru("$command $pgm your_variable"); print "PHP: After passthru, result=($result)<br> "; ?> ------------------------------------- OUTPUT: ------------------------------------- PHP: Before passthru, in PHP... PERL Hello from Perl! (plain print) PERL 0: This is text sent to STDOUT PERL 1: This is text sent to STDOUT PERL 2: This is text sent to STDOUT PERL 3: This is text sent to STDOUT PERL 4: This is text sent to STDOUT PERL Some output: PERL line 0 of output--- PERL line 1 of output--- PERL line 2 of output--- PERL line 3 of output--- PERL line 4 of output--- PHP: After passthru, result=()
Capturing Print Output Of Function To Variable
I have a function, say: function printTable($Variables) { ?> <table> <tr><td>Your name is</td></tr> <tr><td> <?php print $Name; print "</td></tr></table>"; } (Obviously not my exact function, but a simple one to demonstrate my needs... The function I have inherited is much bigger with much mixed php and html like the example) It is currently used to print the same data table on many pages. I have been asked to have the system send this data table by email, so what I want to do is run the function, but send the output of the function to a variable, in the same way that print_r($arr,1) will return the output instead of printing it.
Capturing Chinese/Korean Characters In A Form?
I am new to PHP and have been asked to create an HTMl form that captures data onto a text file. I have that working fine. I now need to capture Chinese/Korean characters from this same form and onto a text file. How do I do this? Is it possible to have one form that can capture US Alphabet and Chinese/Korean characters?
Copy Entire Contents Of A Folder To Another
Situation: I am creating a folder based on input from a form and then creating an images folder underneath that -- that works great and I can read and write to the newly created folders AS LONG AS IT IS ONE FILE AT A TIME!!! What I would like to do: I would like to copy the contents of an entire folder over to one of the newly created folders ALL AT ONCE -- or in a loop -- which is what I am trying to do but keep getting denied. My code as it is now: if ($handle = opendir("$sourcedir")) { echo "Directory handle: $handle<br><br>"; echo "Files:<br><br>"; while (false !== ($files = readdir($handle))) { if ($files != "." && $files != "..") { if (!copy($files, $imagepath)) { echo "failed to copy $files into $imagepath<br><br>"; } } } closedir($handle); } all of the variables are working fine... it goes through the loop just fine -- I know this because it prints out the error for every file in the folder... it just won't copy the files over to the new folder while in this loop. Here is the beginning of the error messages: Directory handle: Resource id #2 Files: failed to copy step_c1.gif into /htdocs/www/schemes/adfasa/images failed to copy step_b1.gif into /htdocs/www/schemes/adfasa/images failed to copy step_a1.gif into /htdocs/www/schemes/adfasa/images by the way: adfasa is the folder name brought in by the form and images is the folder I create underneath it. Is this something that is possible to do in a loop? If so, what is wrong with this one. If not, how is something like this done? Of course since I know the files that are in the folder I want to copy from I could just go ahead and copy them ONE by ONE but that doesn't seem to be very efficient.
Including Files From Entire Directory
I have this little news script that stores each entry into a seperate file into monthandyear/day, month date, year hour-minutes-seconds AM/PM so if it was Sunday, March 9, 2003 11:39 PM then the script would store the new entry in the folder named "March2003" and in a file called "Sunday, March 9, 2003 11-39-00 PM" now, the problem i have is i want to have an archive of all my news entries by month, so how do i get the contents of all the march entries displayed onto one page in order of date and time?
Http Authenticate Entire Site
we are validating users in several different sections (each section is in it's own directory..ex. the download section is in /downloads) using http authentication. when a user authenticates in one section they can roam freely in that directory without having to authenticate again. for some reason however, when i change to a different directory and then run a phpinfo(), both $PHP_AUTH_USER and $PHP_AUTH_PW are gone, meaning the user will have to authenticate again. the user can go back to the first directory again and they are still authenticated within that directory. i would like the users to only have to authenticate once for the entire site, but scince there are areas of the site that do not require validation i don't want to make them authenticate until they have to.
Viewing Entire HTTP Header ?
is there a way in code to view the entire HTTP Header? Many of the variables in $_SERVER have much of the header, as do some of the apache functions, but none seem to have a way to show the body that was sent with the request. any suggestions for how i would go about doing this? It's mostly for documentation and instructional purposes, but i'd like to see the results without having to construct them by hand and telnet'ing into port 80 all the time ....
Pass The Entire Array Through A Form.
Im working with an array in my php script and need to pass the entire array through a form. Here is the script. Take a look and tell me if you can see my mistake. I create a dynamic entry screen that has multiple values that I would like to update and want to place them all into an array to update them. At the mo no values are being posted at all. Code:
Can You Send An Entire Webpage Via Email Using PHP?
If you go to File >> Send > Page via email it will send a snap shot of the current page you are looking at via email. can this be done via PHP (or another means) so that I can create a script that will email a webpage automatically to a chosen person?
Sending Entire Web Page To Email
Is it possible to send an entire web page to an email using mailto:person@blah.com function, with what has been typed in the text boxes. And if so what would the code look like.
Optimizing Dynamic Php Code (entire Site)
my web site seems to load rather slow because it accesses the db several times and there is a lot of code (because of features). i was wondering how i could optimize/cache this so that the query is only executed once (until i modify the actual code). any ideas?
Export Entire Site And Save As HTML
I feel as though I will be covering ground that others have posted, but I have searched and not found much at all. Basically, my site is in PHP/mysql, but before I go online I want to save 95% of the site's output as HTML (basically everything but the search pages). This will be around 4,000 pages. Is there a way I can get PHP to save the output that a scirpt generates as a separate HTML file? What I would like to do is build this feature into my admin menu. Thus, when I make a change to the database, I can pull up the individual record, and click on a button that says "rebuild html pages".
Using Just One Entry Point For An Entire Dynamic Site
I'm thinking of an architecture for a medium-complexity dynamic site as follows: - I use one php file, say a.php as the entry point for the entire site. PATH_INFO allows me to pass information to my script by using URLs like http://mysite.com/a.php/user1000 or http://mysite.com/a.php/images/10.gif and perform the appropriate action by calling the appropriate function (which may reside in an included php file) - I use apache's url rewriting to redirect urls like http://mysite.com/page25 to a.php b adding the script name - http://mysite.com/a.php/page25 - Using Smarty to control the actual HTML output. This seems to me like a sound and obvious way to do things (and also rarely done) so my questions are: - Has anyone on this group tried to do or done something like this before, using one entry point for the entire site for maximum control? - If so, what do you think are the pros and cons or this approach?
Entire Query String As Script Variable
How would I pull the query string of an URL into my PHP script for use as a variable inside the script? For example - URL is http://www.mydomain.com/hub.php?ref...bob&lname=smith In my hub.php script, I want to set a variable $foo = "ref=affiliate1&fname=bob&lname=smith"; (or whatever the actual query string happens to be)
PHP Http Authentication - Cannot Secure Entire Directories?
I've been trying out HTTP authentication with PHP (yes I've read the Zend tutorial, searched the forum, and read the manual). Things seem to work great. However I have noticed that is does not work like a .htaccess file would. Only the PHP script which sends the headers will check for anything. No very useful for blocking out a whole directory tree. I wanted to move away from just using a .htaccess so that I could authenticate the passwords over a MySQL database. The current setup has an index.php in the directory that is to be protected. It checks for password, then initializes a session and forwards the user to the protected section. Each script in the protected section checks if valid session exists, and if not, forwards back to the main index.php to HTTP authenticate again. This seems to work fine except I'm afraid of one day forgetting to check for the session or people accessing non PHP files that are in the protected directory. My question is, is there a way to combine PHP based http authentication with a .htaccess file? Or somehow have an entire directory be authenticated through one script. And the other concern is that if I do have the entire directory protected and go through that one PHP script somehow, wouldn't it have to check the l/p with MySQL every time they accessed any file?
Regular Expression Detecting Entire Page
I am making a flat file, static HTML search engine for a site. I downloaded a script from the net and have been working with it for my needs. Everything was working OK with a few test Lorem Ipsum pages. But the moment I try to search real data, fit hits the shan. The script uses a regular expression to search through the files. And for most of these files, the regular expression doesnt seem to pick up the matches as it should, and for lack of a match, it outputs the entire html page as a hit. The search word is on the page somewhere, but it still outputs the entire page. Allow me --------8<---------------------------- if(preg_match_all("/((sS*){0,3})($keyword) ((s?S*){0,3})/i", $portion, $match, PREG_SET_ORDER)); { if(!$limit_extracts) $number=count($match); else $number=$limit_extracts; for ($h=0;$h<$number;$h++){ // no limit if (!empty($match[$h][3])) $text = sprintf("... %s<font class='keyword'>%s</font>%s ...", $match[$h][1], $match[$h][3], $match[$h][4]); else{ //print_r($match); } } } --------8<---------------------------- There's the regex that looks through $portion, which is the strip_tags version of the file's contents. And if I echo $portion right before that line, I see the stripped code. However, when I get to the line where it checks $match[$h][3] for the keyword that was searched for, it craps out. Not 100% of the time, but most of the time. Im trying to figure out details about these html pages, to no avail. So as a result of failing that empty test, the entire html page is dumped out as a search result. Not being a regex expert, Ive had a hell of time troubleshooting. But I feel the problem lies in there. Something with the regex not finding the keyword correctly, or something.
Part Of The Script To Refresh With Out Refreshing The Entire ?
I am have a script, and in that script I have a section that pulls information from a database. I also have a drop down box that allows the user to slect which category they want the data to be pulled from. As of now, the way I have it, after they make a selection, the entire page gets refreshed and the new category is loaded. How can I make it that only that section of the script gets refreshed?
Capturing Redirect URLs And Final Landing URL Using Snoopy Or CURL
I'm trying to capture redirect urls and the final landing url when I read a page through snoopy or cURL. So for example if i read http://www.example.com (1) which redirects to http*://www.example.com (2) and which inturn redirects to http*://www.example.com (3), I wana be able to capture all the URLs in the middle and the final landing url.
Match Regular Expressions In A Webpage, Not The Entire Source
In order to check availability, I want to visit many different pages from a database and try and match the regular expressions 'out of stock' or 'unavailable' or 'sold out' etc. If found, the product will be flagged as unavailable. I tried using fopen() and preg_match() but the problem is, if the reg. expression is present in javascript or in comments, the item gets wrongly flagged. Is there a way of taking what appears on the users screen, after parsing the page, and looking at it as a string I suppose ?
|