PHP - Avoiding Http 403
I am trying to build an app which will scan a site multple times, the only problem is the 403 error, how do I get around this.
Searching seems to imply curl or user_agent, but can't get it working. Any suggestions? Thanks Similar TutorialsTrying to run a simple program that, when submitted, stores the username and password as cookies. When clicking Submit, I get the error "HTTP Error 405 - The HTTP verb used to access this page is not allowed". If the username and password fields are left blank when submitting it's suppose to give a message to enter a username and password, but, I still get that error message. HTML form: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Week 1 Project--Cookies</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <form action="cookie1.php" method="post"> <h2 align="center">Cookies</h2> <br /> <div> <p>Enter your username and password and click "Submit":</p><br /> <p>Username:<input type="text" name="username" size="20"></p> <p>Password:<input type="text" name="password" size="20"></p> </div> <br /> <div><input type="submit" name="submit" value="Submit" /></div> <br /> <div> <input type="reset" name="Reset" value="Start Over" /> </div> </form> </body> </html> PHP file: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>Cookie File</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <div> <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { setcookie('username', $_POST['username'], time() + 2592000); setcookie('password', $_POST['password'], time() + 2592000); } if(($_POST['username'] == "") || ($_POST['password'] == "")) { print "You must enter both a username and password. Press the Back button on your browser and try again."; } else if (isset($_COOKIE['username'])) { print "Welcome, " .$_COOKIE['username']; } ?> </div> </body> </html> When user submits data through a textarea input and he then refreshes the page, the data will be re-submitted and inserted into the database a second time. I used to avoid this with a header redirect, but this solution is not an option to me anymore, since I need to echo out in the header.php, which I have to put before the submission area. Another weak point with the header redirect solution is that the user could go a page back and then hit refresh. I'm wondering how are other sites avoiding resubmission? When you post a comment on YouTube it will simply freeze the submit button after you've posted, I'm guessing they have achieved that with JavaScript, is that solution recommended? And which type of other techniques are people generally using to avoid resubmission on page refresh? Excuse the beginner question. Though, how do you avoid the processing of HTML when text becomes inputted, without stripping away the tags, or trimming the text in any way, simply leaving it as is? As the title says, I have a .txt file with about 30,000+ lines of data presented in a pipe delimited list, which i'm parsing and inserting into my database. Problem is, my server seems to always time out every time I try to parse the whole file at once. I'm sure naturally it would work with out any timeout errors, but i'm ensuring the data is xss clean before it's being inserted and i'm doing that on about 15 items on each line, which means i'm calling the xss clean function over 450,000 times in one execution. So my friend suggested I break the files down maybe into each file having 5,000 lines of code, which would mean i'd generate about 6 files (if I had 30,000 lines of data). I've managed to code a script that breaks the main file into several files. Now what I want to do is pass each of those files to my parser method, but i'd like to do them one by one, rather than in one execution as I want to avoid the timeout error. Any ideas? If I have a web page located he www . company . com / how-to-repair-your-computer.html
And I decide to re-structure my website like this www . company . com / articles / how-to-repair-your-computer.html
How do I make sure that people don't search and end up at the old, now broken, link?
It seem inevitable that as a website grows, that you will want to re-organize things. What is the best way to make sure that anyone who searches or clicks on an old link - say from an email from a friend - doesn't get a 404 error?
Also, how do you avoid ruining a web pages rank on Google after you move things? (I think if the URL changes, Google makes you start all over as far as getting listed on page-1 and all of that?
Is this something I have to hande on my end, or is it a Google issue, or something else?
I've got a script where the client can upload pictures. The pictures are then resized, thumbnailed, and added to the database. In the process I'm trying to search the database for a duplicate file name and create a new name if necessary: Code: [Select] $userfile = 'userfile' . $i; $tmpLoc = $_FILES[$userfile]['tmp_name']; $name = $_FILES[$userfile]['name']; $error = $_FILES[$userfile]['error']; $type = $_FILES[$userfile]['type']; $temp = 'album' . $i; $album = $_POST[$temp]; if($error > 0) { echo "Error on $name: "; switch ($error) { case 1: echo "File exceeded upload_max_filesize"; break; case 2: echo "File exceeded max_file_size"; break; case 3: echo 'File only partially uploaded'; break; case 4: echo 'No file uploaded'; break; } echo "</div>"; exit; } // Check for name duplicates and deal with $query = "SELECT * FROM pictures WHERE src = $name"; $result = mysql_query($query); if($result) $dup = true; while($dup) { echo "Duplicate file name $name <br />"; $ext; if($type == 'image/gif') $ext = '.gif'; else if($type == 'image/jpeg') $ext = '.jpg'; else if($type == 'image/png') $ext = '.png'; else die("Error: Unsupported file type"); $x = 0; $name = $x . $ext; echo "Checking $name <br />"; $query = "SELECT * FROM pictures WHERE src = $name"; $result = mysql_query($query); if(!$result) { $dup = false; echo "File successfully renamed to $name to avoid duplicate <br />"; } $x++; } I don't get any errors of any sort, it just never enters the loop I have the following code:
$fp = fopen(“path_to_file”, ‘a’); flock($fp, LOCK_EX); fwrite($fp, $string); flock($fp, LOCK_UN); fclose($fp);If I try to lock the file in two different places at the same time, this will cause a race condition. How can I prevent this? I know in Java, for example, it has a concurrent library which contains reentrant lock, which basically tries to get the lock and if can't waits. What can I do in PHP? I have questions but I also have some good info to share about putting your software in the cloud. The situation: Some of you may have read about the nightmare stories. A developer had a infinite loop in his code that ran all night. This code did things inefficiently that devoured CPU in each iteration. This developer, greatly skilled, opened his email the next morning and saw a email bill from his cloud provider totaling for $75K. True story. Most cloud providers let you define CPU usage thresholds that, when breached, send you a warning but these thresholds, if I understand them, are per account. It would seem the claim that cloud resources are available in whatever amounts you need, CPU, disk space, enough RAM to never have to wait on a page faults, etc... the claim that the cloud provides you with infinitely elastic resources in an "all you can eat for one price" contract smells just a like a little like 💩 I did cloud development for many years with ServiceNow starting when it was a help desk and I watched it evolve into one of the best cloud development platforms out there. At one customer site I installed and managed it it out of the cloud and saw its insides and I can tell you its core code is not so terribly efficient. IMHO the cloud DOES take away 90% of a developer's worries about app performance.. If you call ServiceNow tech support and your problem is diagnosed as a performance issue with your code the first thing they will ask you is "did you follow the developer best practices"? They will politely say "sorry. Here's a link to them implying "fix your code". Questions: PHP Functions that devour CPU and where there is a better way? What PHP functions or code techniques waste CPU? I am using similar_text and it does the job but it is slow. Better way? What is the best way to measure CPU used by a PHP script or by a particular code module, defined as a set of related functions that fulfill a common purpose or by a single line of code? The purpose being to identify inefficient modules of code and improve them and even if the code is damn near perfect then at least can know what code modules are the most expensive. CPU killin users (and developers too), how can they be identified? I need to store data on cumulative CPU usage for any of the above and compare it with the free amount they give you and warn CPU hogs before they breach a threshold and generate $75K bills that were not in the plan. Any info you have on avoiding surprise $75K CPU bills from a cloud provider are welcome
It would seem the How do I only redirect the page when index.php is present? Hi All, I know it is a silly error but I am very new to PHP (only 2 days!!!) & unable to resolve this. I have seen a lot of resolutions online for example: 1) Copying the "php5isapi.dll" file to the PHP directory & under "Program Files" as well. 2) Copying the "favicon.ico" file etc etc Before I could elaborate the issue, please note that I am a Windows user - Windows XP (I know its not the best of the OS's to work with!!!) When initially I started getting the issue, I checked the "error.log" file under "C:\Program Files\Apache Software Foundation\Apache2.2\logs" & following is what I saw: ----------------------- [Sun Sep 18 14:13:25 2011] [notice] Server built: Sep 9 2011 10:26:10 [Sun Sep 18 14:13:25 2011] [notice] Parent: Created child process 4420 [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Child process is running [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Acquired the start mutex. [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Starting 64 worker threads. [Sun Sep 18 14:13:25 2011] [notice] Child 4420: Starting thread to listen on port 80. [Sun Sep 18 14:14:55 2011] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/favicon.ico [Sun Sep 18 14:21:37 2011] [notice] Server built: Sep 9 2011 10:26:10 [Sun Sep 18 14:21:37 2011] [notice] Parent: Created child process 7976 [Sun Sep 18 14:21:37 2011] [notice] Child 7976: Child process is running [Sun Sep 18 14:21:38 2011] [notice] Child 7976: Acquired the start mutex. [Sun Sep 18 14:21:38 2011] [notice] Child 4420: Released the start mutex [Sun Sep 18 14:21:38 2011] [notice] Child 7976: Starting 64 worker threads. [Sun Sep 18 14:21:39 2011] [notice] Child 4420: All worker threads have exited. [Sun Sep 18 14:21:39 2011] [notice] Child 4420: Child process is exiting [Sun Sep 18 14:21:39 2011] [notice] Child 7976: Starting thread to listen on port 80. [Sun Sep 18 14:21:52 2011] [error] [client 127.0.0.1] File does not exist: C:/Rahul/Personal/Web Development/favicon.ico ---------------------- Then I created an icon file and named it "favicon.ico" & placed it in the following destinations: 1) C:/Rahul/Personal/Web Development/ and 2) C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/ but to no avail But interestingly & surprisingly, the error.log file stopped giving any of the above error messages but I still get the HTTP Error. Following is the error message that I get on the browser: -------------------------- Server error The website encountered an error while retrieving http://localhost/Forms/insert%20data.php. It may be down for maintenance or configured incorrectly. Here are some suggestions: Reload this webpage later. HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. -------------------------- Now, just to let you know which php I am using, so, just to let you know, I just copied the html & php from http://www.w3schools.com/PHP/php_mysql_insert.asp. Following are they: HTML: ---------------------------- <html> <body> <form action="insert data.php" method="post"> Firstname: <input type="text" name="firstname" /> Lastname: <input type="text" name="lastname" /> Age: <input type="text" name="age" /> <input type="submit" /> </form> </body> </html> ----------------------------- PHP ----------------------------- <?php $con = mysql_connect("localhost","root","orange"); if (!$con) { die('Could not connect: ' . mysql_error()); } echo "Connection established"; mysql_select_db("my_db", $con); $sql="INSERT INTO Persons (FirstName, LastName, Age) VALUES ('$_POST['firstname']','$_POST['lastname']','$_POST['age']')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "1 record added with name: " $_POST[firstname] $_POST[lastname]; mysql_close($con) ?> ------------------------- I hope someone is able to help me in this & I guess I have mentioned everything I could to explain the error! Many thanks in advance! Rahul i have been searching for a solution for about a day already. can anyone help me on how to use the http functions (if thats what it is called) in php? http://www.php.net/manual/en/book.http.php like for example. i need to use the http_get() function but it returns Fatal error: Call to undefined function.. in the manual it says that i need to put php_http.dll on the ext dir and enable it in php ini like this.. extension=php_http.dll ..which i already did im working under.. windows xp sp3 php 5.3.1 thanks guys Hi. I am trying to extract the main url from a string.
For example.
I want to extract:
"http://google.com" from "http://google.com/search/pic.jpg"
"https://secure.co.uk" from "https://secure.co.uk/secure/secure.gif"
I am able to do this with this code, where $url is the url:
preg_match("http://(.*?)/", $url, $matches);
preg_match("https://(.*?)/", $url, $matches);
Is there away to consolidate this into one regex search? Or am I being picky?
Thanks!
Not sure if this is possible. What I am trying to do is remove a section of text a user posts. ie: go to this url: http://url.com or http://this.domain.org I already have it to strip they <a href="whatever but not sure if I can do the other. Any help would be appreciated. Thanks Hi, I don't know very much about php. I don't know any at all, actually. I play a game called Roblox where you get to use the programming languange, "Lua" to script your own games. What I am requesting has been done before on this game, but I only know Lua. I was also told PHP cURL is needed. Anyways, let me get to the point. I am essentially trying to create a system on my webserver (You can send HTTP Requests to external sites in this game via script) that will essentially log into an account on Roblox, to perform a task. My current idea would be to have the Lua script send a request to my webserver with an generated code that would access the username and password of my roblox account (Which would be on the webserver). It would then perform a task. Is this a good way to go about this? If not, I am open to suggestions. If you can find the time to actually help me set this up on my webserver, I would greatly appreciate it! I'm also sorry if this is the wrong place for this post, I'm new here. I am learning PHP using the book "Beginning PHP and MySQL 5 - From Novice to Professional", and I have come across a lesson in the book which I am stuck on. The lesson is on using the echo() statement. I've typed in the following code and saved it as a php file.... <?php $heavyweight = "Lennox Lewis"; $lightweight = "Floyd Mayweather"; echo &heavyweight, " and ", $lightweight, " are great fighters."; ?> My Apache and PHP is working fine as my other PHP files work properly. When I try and view the file it says... "The website encountered an error while retrieving http://localhost:8888/phpdocs/multiplestringsecho.php. It may be down for maintenance or configured incorrectly." and when I click on more information it says... "HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request." Any ideas? Have I done something wrong? Any help would be much appreciated. Just a quick question. I'm using the Live HTTP Headers add-on for Firefox that display all the HTTP headers etc. I'm writing an article on it and want to include a screenshot of it in action. Are there any headers that I should hide from the reader for security reasons? Thanks for any help. when i upload this code and refresh the page nothing shows up the only thing htat shows up is HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request. please helop Code: [Select] <?php $title = "Home"; ?> <?php require("styles/top.php"); ?> <?php if ($username){ echo "<table> </div></td> </tr> <tr> <td width="244" valign="top"><br /> <form id="form1" name="form1" method="post" action="search_results.php" style="margin-left:20px;"> <input name="var" type="text" class="size12" id="var" style="width:124px; background-color: #A4D1FF;" /> <input name="button" type="submit" class="size11" id="button" value="Search" /> </form> <br /> <div id="leftNav" style="margin-left:22px;"> <!-- Start tv --> <strong><font color="#FFFFFF"><span class="size16">TV</span></font></strong><br /> <a href="tv.php?c=tv&sc=cartoons">Cartoons <font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=news">News <font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=adventures">Adventures <font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=horror">Horror<font size="-3" color="#FFFFFF"></font></a><br /><a href="tv.php?c=tv&sc=Drama">Drama<font size="-3" color="#FFFFFF"></font></a><br><br /> //End TV --> // Start Videos --> <strong><font color="#FFFFFF"><span class="size16">Videos</span></font></strong><br /> <a href="videos.php?c=videoss&sc=children">Children <font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=music">Music<font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=comedy">Comedy<font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=youtubemovies">Youtube Movies <font size="-3" color="#FFFFFF"></font></a><br /><a href="videos.php?c=videos&sc=sports">Sports <font size="-3" color="#FFFFFF"></font></a><br /> <br> <!-- End videos--> <!-- Start Movies --> <strong><font color="#FFFFFF"><span class="size16">Movies</span></font></strong><br /> <a href="movies.php?c=movies&sc=comedy">Comedy <font size="-3" color="#FFFFFF"></font></a><br /> <a href="movies.php?c=movies&sc=action">Action <font size="-3" color="#FFFFFF"></font></a><br /><a href="movies.php?c=movies&sc=adventure">Adventures <font size="-3" color="#FFFFFF"></font></a> <a href="movies.php?c=movies&sc=horror">horror <font size="-3" color="#FFFFFF"></font></a><br /> <a href="movies.php?c=movies&sc=drama">Drama<font size="-3" color="#FFFFFF"></font></a><br /><br /> <br /> //End Movies </div> </table>"; } else echo "<h2><font color='red'>You must be logged view this Part.</font></h2>"; ?> <?php require("styles/bottom.php"); ?> Hi guys.. i am not very sure where to post about this issue but im giving a try and hope to get some ideeas where this might come maybe. So i have a small website with a members database.. the website itself it has SSL and works properly on a https connection. The problem comes when a member tries to access via http. Unfortunetaly on a page i have to keep it http due to some ads that i display there and dont work on https. If a member logs in and surfs the website via https everything is working perfectly.. but when he changes and tries to access via http he automatically gets logged out.. if he tries to login via http he also cant and gets an error with an invalid token. So basically i think my database cant connect when accessed by http.. Any of you ever encountered this issue ? Or maybe have some ideeas where this issue is coming from ?
Thanks and any ideea or help very appreciated I was just wondering if when I write a new function that uses AJAX should I use the same http request for my whole website or should I make seperate ones for each function? Also if you use the same one do you need to do anything to it once it has been used to set the ready status back to 0? Thanks I have tried to make a redirect like this: redir.php?page=http://****.com Code: [Select] <?php if(is_file($_GET['page'])){$page = $_GET['page'];} else{$page = "DEFAULT.php";} header("Location: ".$page); ?> But I only get: Quote Forbidden You don't have permission to access /redir.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. What should I do? Could it have something to do with encoding of special characters? Ordinary php scripts like Code: [Select] <?php echo "Hello"; ?> Works fine. |