Jump to content

rtadams89

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by rtadams89

  1. Hello all. Let me start by saying I have searched for this, but have not found a satisfactory answer. Probably because I am unsure of exactly what to search for. I have a website with 10+ PHP pages. There are some functions that every page uses, some functions that a few of the pages use, and some functions that only get used on one page. Currently, all of these functions are in a file named "functions.php" which is 40KB in size. As the first line of all my content PHP pages, I have included <?require($_SERVER['DOCUMENT_ROOT'].'/includes/functions.php');?> to ensure these functions are available on each page. Is this appropriate? Would it be better to have separate function files which contain "groups" of related functions, and then only include those "groups" that are needed on the particular page? Does including one large function file on every page perform better than including several smaller files on some pages?
  2. It seems there has to be. I mean, it's making a request to the server. One which shows up in the logs, can be modified with mod rewrite, etc. I just don't know enough about PHP or web standards and protocols to figure it out.
  3. I'm wondering if there is anything I can use to get the URL of the page that is requesting the image.
  4. It appears that when embedded in a craigslist post using an <img> tag, the $_SERVER['HTTP_REFERER'] doesn't get set.
  5. That is what I am doing now. I was going to release this script for others to use, and I thought getting the post id and section automatically would make it more user friendly.
  6. Yes. I should have been more clear. I don't know how to get the url of the page into a variable. I've tried using the http referer variable, but that is always empty.
  7. I have no idea how to phrase this simply, so here is the long explanation. I wanted to track the number of people who view my ads posted on craigslist. Craigslist won't let you embed PHP, javascript, or any external files in the posts, except for images. SO here is what I did: I created a file named "hit.php" on my server. In my craigslsit post, i include: <img src="http://myserver.com/hit.php?id=1234"> When called, hit.php records the hit in a database and then uses a header(location) to redirect to a transparent gif file. The "id" parameter in the URL is the id of the post. This has to be hard coded into each craigslist post I make. I would instead like to pull the ID from the post URL automatically. For example, in the post http://phoenix.craigslist.com/sys/1234.html the id would be "1234". Is there a way to do this when the hit.php script is being called from an "<img>" tag?
  8. I do. Without it, the include.php page won't have anything to process. It doesn't work fine, that's the problem. The code I posted is a simplified example of what I am trying to do. In reality, the include.php file actually takes an e-mail address as in put, converts it to hex code, and outputs it in the form of a JavaScript document.write command. This is all so that when a robot views the source code of a page, it won't be able to pick out the mailto links and spam them.
  9. I have a php file named "include.php" which contains the following code: <?php echo $_GET['name']; ?> If I go to http://myserver.com/include.php?name=ryan I get a page that contains the text "ryan". I also have another page named "main.php" which has the following code: <?php echo "The name is: "; include ("http://myserver.com/include.php?name=ryan"); echo "."; ?> I would expect the output of this page to be "The name is ryan.". However, I get nothing. I'm pretty sure this is because I am using the include() function incorrectly. What function should I use?
  10. I added the following line to my .htaccess file: #Custom 404 for non existant .php files work around RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^[0-9a-zA-Z_/.-]+\.php$ http://www.asurfc.com/error.php?code=404 Everything now works as expected. Any reason the plain "errordocument" declaration wasn't working for non existent php files?
  11. Here is the .htaccess I have placed in my root directory: CheckSpelling off AddType x-mapp-php5 .php RewriteEngine On RewriteCond %{HTTP_HOST} !www.asurfc.com RewriteRule ^.*$ http://www.asurfc.com%{REQUEST_URI} [R] ErrorDocument 404 http://www.asurfc.com/404.php If a visitor goes to "http://asurfc.com/nowhere.html" or "http://asurfc.com/nowhere/nowhere.php", my custom 404 page gets displayed as expected. But, if a visitor goes to "http://asurfc.com/nowhere.php", my web host's default 404 page gets displayed. It seems my custom 404 page works every time except if the non-existent requested file is a php file in the root directory. Can someone explain why this is happening? PS: My web host is 1&1. You can see the problem I have for yourself by visiting the URLs I mentioned above.
  12. I tried that at first, but that wasn't working for me either. Not sure why, as I know it has before.
  13. Thanks for the reply. Unfortunately the referring page can't run PHP. However, your response got me going in the right direction. In the referring page, i used this JavaScript code: var str1, str2; str1 = location.href; str2 = str1.replace ("&", "andandand"); top.location.href = "http://asurfc.com/forum.php?iframe=" + str2; That just replaces "&" with "andandand". I used "andandand" to make sure I wouldn't have any problems if the URL already included a single "and". Then on my forum.php code, I returned the URL with this: <?php $iframe = str_replace("andandand" , "&" , $_GET['iframe']); if ($iframe == "") { $iframe = "./forum/"; } ?> which just replaces the "andandand" with "&". Thanks for the help!
  14. I have a page (forum.php) and on this page I have the following code: <?php $iframe = $_GET['iframe']; echo $iframe; ?> So when I go to forum.php?iframe=http://google.com, the page displays "http://google.com" as expected. The issue is, if I go to forum.php?iframe=http://somesite.com?a=1&b=2, then the forum.php page only displays "http://somesite.com?a=1". I've also tried forum.php?iframe="http://somesite.com?a=1&b=2", but even with quotes, the $_GET['iframe'] variable gets truncated at the first "&" sign. How can I get around this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.