Jump to content

soma56

Members
  • Posts

    185
  • Joined

  • Last visited

    Never

Everything posted by soma56

  1. I'm familiar with sending and receiving cookies through cURL... <?php /* STEP 1. let’s create a cookie file */ $ckfile = tempnam ("/tmp", "CURLCOOKIE"); /* STEP 2. visit the homepage to set the cookie properly */ $ch = curl_init ("http://somedomain.com/"); curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec ($ch); /* STEP 3. visit cookiepage.php */ $ch = curl_init ("http://somedomain.com/cookiepage.php"); curl_setopt ($ch, CURLOPT_COOKIEFILE, $ckfile); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec ($ch); /* here you can do whatever you want with $output */ ?> I would like to know if someone can point me to a tutorial and/or more information where this can be done through a proxy? I searched Google and couldn't find anything.
  2. I have a very basic script. It's a cURL script used to grab the contents of a webpage. I'm attempting to connect through a proxy. The most frequent error message I'm receiving is related to a timeout... CURLE_OPERATION_TIMEDOUT (28) After a few hours of trying different things I decided to try a different server. I instantly noticed a huge difference. The script was working correctly through a proxy on SERVER 2. While I did have 'some success' on SERVER 1 I found the results to be slow and inconsistent. Here is a simplified version of the cURL script: <?PHP ignore_user_abort(true); set_time_limit(0); //Proxy Sources $proxypage = file('newproxies.php'); //Assign Page to Download $BIGG = "www.example.com"; //Proxy Sources $proxypage = file('newproxies.php'); $rand_goodproxy = array_rand($proxypage, 2); $goodproxy = $proxypage[$rand_goodproxy[0]] . "\n"; //Variable for User Agent $agent = "My Agent"; ?> <?PHP if(!function_exists('DownloadBIGG')){ function DownloadBIGG($BIGG){ //Globalize variables global $goodproxy, $proxypage, $BIGG, $agent; // is curl installed? if (!function_exists('curl_init')){ die('CURL is not installed!'); } //Start Output Buffer ob_start(); // create a new curl resource $ch = curl_init(); // set URL to download curl_setopt($ch, CURLOPT_URL, $URL); // set referer: curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com/"); // user agent: curl_setopt($ch, CURLOPT_USERAGENT, "$agent"); curl_setopt($ch, CURLOPT_PROXY, "$goodproxy"); //Proxy Tunnel? curl_setopt($ch, curlopt_httpproxytunnel, 1); //curl_setopt ($ch, CURLOPT_HTTPGET, true); // remove header? 0 = yes, 1 = no curl_setopt($ch, CURLOPT_HEADER, false); // should curl return or print the data? true = return, false = print curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // sets how long CURL will run before it gives up curl_setopt($ch, CURLOPT_TIMEOUT, 30); // sets how long CURL will wait to even connect curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); // download the given URL, and return output $DLBIGG = curl_exec($ch); //get information $info = curl_getinfo($ch); flush(); ob_flush(); // print output echo "<br />cURL error number:" .curl_errno($ch); echo "<br />cURL error:" . curl_error($ch); echo "<br />cURL info:"; print_r($info); echo str_pad(" Loaded … ",; sleep(1); flush(); ob_end_flush(); echo $DLBIGG; usleep(100000); curl_close($ch); } }//end if !function does not exist global $info, $firstproxy; $DLBIGG = DownloadBIGG($BIGG); ?> Given that trying the script on another server (SERVER 2) led to success with respect to connecting to a proxy I have a strong suspicion that this has something to do with the server configuration. I should point out that the server that I'm having issues with (SERVER 1) is a VPS with over a gig of ram. SERVER 1 The server that is not responding quickly and otherwise timing out: PHP Version 5.2.9 SERVER 2 Responding quickly through the script and returning the page through a proxy: PHP Version 4.4.9 I'd be more then happy to post the "phpinfo();" information for both servers. I'm wondering if there is an obvious setting that I should be adjusting or looking at in terms of the PHP configuration for the server I'm having issues with. Any help would be greatly appreciated.
  3. I have several fields in a database in which some could be blank. I'd like to echo out 'Not Assigned' if that's the case. Based on my limited experience with PHP this is the way I'm going about it: if ($tech == "") { $tech = "Not Assigned"; } if ($crew == "") { $crew = "Not Assigned"; } if ($number == "") { $number = "Not Assigned"; } I'm pretty certain there is a way to simply place all of the variables into an array to determine if they are empty or not - Followed by changing the variable to 'Not Assigned' one time rather then repeating code over and over again. The way I'm doing it will work, however, something tells me there is a much more efficient way.
  4. Brilliant. Thanks guys/girls. I ended up simply placing them into a new array and then called the first 5 values for the DB. foreach($_POST['service'] as $service) { $services[] = $service; } And then for the php/mysql insert it was simply a matter of using $service[0], $service[1], etc. It doesn't matter if they're blank or not - however if all 5 are selected then this will place them in an array and subsequently into the database. Thanks Again!
  5. I have a table that I must be populated based on a check box selection. The maximum selection is 5, however, there are more then 10 choices. For example: Here is a choice of 10 different (checkbox) options that the user can select from: 1. Coke 2. Root Beer 3. Pepsi 4. Dr. Pepper 5. Sprite 6. 7up 7. Cream Soda 8. Club Soda 9. Water 10. Milk I've already managed to limit the users selection to only 5. My issue is determining which of the checkboxese were actually selected so that I can correctly place them in my database. The first thing to do is create variables from all the checkboxes: $coke = $_POST['coke']; $rootbeer = $_POST['rootbeer']; $pepsi = $_POST['pepsi']; $drpepper = $_POST['drpepper']; etc. etc. Now that I have all 10 selections as variables from a submitted form how can I determine which ones are empty (or which ones have values) so that I can then save them to the database respectively?
  6. I'm going through one of those moments where everything logically looks like it should work but it isn't. I have a textarea box that is posting text that contains quotes. The quotes are slipping through my filters. By all accounts should the following code grab any instance of a quotation mark in the manner that I have described? strpos($string,'"') || $string == '"' Note: the above code contains a " between two single quotes.
  7. Does/can php reconize quotations beyond the simple example I have below: $quote = "\""; if(strstr($test, $quote)){ echo "quote found"; } I'd like to detect any instance of a quote. Should I be including html such as " and/or other html quote symbols? Or does the simple example I have above suffice?
  8. Thanks guys. Ironically there is not hyphens - I just renamed everything to present a simply and logical example for everyone to see. In any event you got me thinking about trimming the whitespace which led to the discovery of a solution. Instead of exploding the array with '\n' I tried '\r' which magically solved the problem
  9. I know this works and that's why I'm puzzled. I'm bringing in data from a textarea and trying to compare it. index.php <form name"fruit-farm" action="fruit-check.php" method="POST"> <textarea name="fruit-list"> Apples Bananas Oranges Pickles Hamburgers Grapes </textarea> <input type"submit" name="submit" value="Check The Fruit"> </form> fruit-check.php if (isset($_POST['submit'])) { //Bring in the data $fruit-list = explode("\n", $_POST['fruit-list']); //Search for Hamburgers $hamburgers = "Hamburgers"; if (in_array($hamburgers,$fruit-list)){ echo "That is not a fruit"; } } What's puzzling me is that it's not working. It must be something blantently obvious. It has something to do with the '$fruit-list' array and how it is being brought into the form. It posts fine. The reason I think this is the case is because if I simply create an array that is identical to the form coming in it works: if (isset($_POST['Submit'])) { //Bring in the data $fruit-list = explode("\n", $_POST['fruit-list']); //Search for Hamburgers $hamburders = "Hamburgers"; $fruit-list = array('Apples', 'Bananas', 'Oranges', 'Pickles', 'Hamburgers', 'Grapes); if (in_array($hamburders,$fruit-list)){ echo "That is not a fruit"; } } When I 'print_r' both arrays they both look identical. What is wrong and/or different with the way I'm bringing in the textarea that's causing this not to work?
  10. Thank you. I'm sure that will work fine. I appreciate your time.
  11. Yes, I suppose I could. I was trying to avoid it. Here's the traditional logic: > Browse and upload file to server > Grab contents from uploaded file This is what I want to do: > Browse and upload contents of file to textarea Is this possible?
  12. I hope someone can help me out with this. What I would like to do is import a text file dircetly to a text area. I can't seem to find any examples on this (Yes I did search Google). I know how to upload but I'm not interested in storing files on the server - but rather just importing them directly to a textarea. Can anyone point me in the right direction? I can upload: <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> I can read: $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') But I'm not interested in either of these as they are unnecessary steps (or are they?). Is there not a way to simply browse/import a text file directly to a textarea (or anywhere for that matter) without having to actually save the file to the server? Something like this: <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" value="Upload File" /> </form> //uploader.php if (isset($_POST['submit'])) { $content = $_POST['"grab the contents of the file"']; echo "<textarea>"; echo $content; echo "</textarea>"; }
  13. Thanks. I understand now. I suppose there is no easy way to do with $_POST? I have several dozen pages to revise now...
  14. I'm trying to figure out a way to post data directly to a URL. For example: <?php if (isset($_POST["pass"]) && ($_POST["pass"]=="$password")) { echo "You did it"; ?> <?php } else { echo "<form method=\"post\"><p align=\"left\">"; echo "<input name=\"pass\" type=\"text\" size=\"25\" maxlength=\"40\"><input value=\"Enter Pass\" type=\"submit\"></form>"; exit; } ?> Let's assume $password is 'password'. Why can't I simply pass the information through the URL to access the page with something like this: http://mypage.com/the-same-page.php?pass=password
  15. For anyone curious on whether or not I solved this issue: I decided to explore the Google Adwords API. You have to jump through a few hoops to set up an account and an API token, however, the keyword tool that google offers simply can't be compared to any other (IMO). You can use PHP to connect to the API (which is where I'm at 'at' this point).
  16. Thanks man. My head is spinning. I believe it's hard coded in Javascript. I'm going to try a few things and I'll post my 'success code', if I figure it out, here. In the mean time more suggestions are welcome.
  17. Well this is a tricky one for me. The script I've created is able to upload images to a server. The server, which I have no control over, generates a random name. It uses Javascript and flash. As a result the links to these images are not within the source code. I suppose the question is, is there a way to still grab these links? I'm familiar with cURL and I was thinking about using something like (CURLOPT_FOLLOWLOCATION) but I'm wondering if that would just look at the source code for links as well? Has anyone had this problem before?
  18. After a few months of bumping into the same pages within Google's Adwords API I've given up trying to figure out how to use their keyword tool on my website. I simply can't figure out how to get a token as a means of using their Keyword Suggestion tool. Support is terrible and I'd have better chances smuggling diamonds throughout 30 major airports. I've also searched the web. While there seems to be plenty of scripts and ways to create keyword clouds based on existing text there isn't anything that offers 'suggestions'. I've created a script that is able to use the actual 'Google Suggests' function. When you type - it auto-types possibilities - but these results are too similar for my purposes. I've also created a meta tag scrape which, can be useful, but it's format-dependent. And if some websites don't have comma's between there keywords and/or decide to you semi-colons (for whatever reason) then things go funny. The results are also so-so. All that being said: In the world of PHP is there a script (or way) to generate 'NEW' keyword suggestions based on one keyword/keyword phrase?
×
×
  • 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.