Jump to content

MadTechie

Staff Alumni
  • Posts

    9,409
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by MadTechie

  1. Yeah, your need to use cURL then, Here a function I wrote, for a basic login (was only for testing, but it works, I made a few tweak to run as a single function but it something to play with) <?php function Login() { $ch = curl_init('http://domain.com/users.php?act=login-d'); $ckfile = sys_get_temp_dir()."/CURLCOOKIE.txt"; curl_setopt ($ch, CURLOPT_COOKIEJAR, $ckfile); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); //Login curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'username'=>"My UserName", 'password'=>'My Password', 'login'=>'Login', 'remember'=>'0' ) ); curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec ($ch); return $output; } ?> Login() will return the HTML found, you need to update the URL $ch = curl_init('http://domain.com/users.php?act=login-d'); and Fields curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'username'=>"My UserName", 'password'=>'My Password', 'login'=>'Login', 'remember'=>'0' ) ); Just view source and read the form from the HTML and build the array above to suite Okay I think you have everything needed.. So i will wish you luck, any problems just ask EDIT: and welcome to PHP Freaks:p
  2. Okay cool, remember we have a RegEx section here (subsection of PHP Help), as for cURL (you might get away with file_get_contents, here's a very quick and simple example <?php //Get Data form this page (no login required so no cURL needed) $data = file_get_contents("http://www.phpfreaks.com/forums/index.php/topic,260169.0.html"); //$data is the same as viewing source, if you view this source your see "action=profile;u=47001" and "action=profile;u=84706" these are the links to our profiles //Find text in between action=profile;u={any number}'> get data until I see a < preg_match_all('/action=profile;u=\d+\'>([^<]*)</', $data, $Users); $Users = $Users[1]; //display or insert found data foreach($Users as $User) { //INSERT INTO DATABASE echo "$User\<br />\n"; } ?> EDIT: added some comments
  3. Why not have the image upload and the user details in the same form and then remove the "Reload the page again to view the thumbnail" code or include the added.php code
  4. well what do you mean by doesn't work ? what's $description set to ? also I would change strstr to stristr and str_replace to str_ireplace
  5. For someone who's "quite new to PHP", this may not be the easiest thing, cURL: To connect to another site your need to use cURL (or fsocket) this allows you to post values (ie Username and password). RegEx: To extract the details your probably want to use Regular Expressions, MySQL: To store the details a simple database ie MySQL would work well as you could do a simple search to check to see if you have the data already. Now, if you are writing this to scrape data from one site it shouldn't be too much trouble (note: check T&C's to check your not breaking the rules), but your need to really look at the planning if you want it to work for multiple sites
  6. if you want the links updated as well you might as well just update the $filename variable before hand! $filename = str_replace(" ","_",$filename); if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename ))
  7. Point taken, would be nice if people who use PHP actual learn PHP, it won't work.. because thats the syntax on how to use str_replace! you would use it like this.. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . str_replace(" ","_",$filename) ))
  8. on the filename you wish to change did you not write this code yourself ? // Upload the file to your specified path. if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $filename))
  9. I'm glade this is solved
  10. Well u.id isn't in that statement So MySQL shouldn't give any message about u.id
  11. change htmlentities( $code ); to echo htmlentities( $code );
  12. Can you post the latest code
  13. Goto the login form and view source, the action is the URL (of course your probably need to add the domain name) the fields will have names and values make sure the array has these, and that should be it
  14. If you say so.. theirs no way i could know thast with seeing the code!
  15. Thats the URL.. thats where your submitting too!
  16. it depends on the form.. read the html form, yoy use to login get the fields and action.. and add them to the array
  17. Maybe worth noting Whats the timeout for the script.. if each site took 1 second and you had 60 sites, but your timeout was 30 then the script will timeout, with that inmind it may be worth adding set_time_limit(0); Also $var = file_get_contents($address, $context); should probably be something like $var = file_get_contents($address, $context); $values[] = ($var===false)?false:true;
  18. Yes it is.. works for me Here's an idea maybe, if you give a little bit of useful information or here's an idea maybe post what you have and a description of what you want it to do and what it is or is not doing, you know considing we are spending time to help maybe a little bit of your time would be a valid investment
  19. add error_reporting(E_ALL); to the start
  20. $r->send() Sends the HTTP request. and Returns the received response as HttpMessage object. getBody() is an object that is returned that has the contents you could also do this $r->send(); echo $r->getResponseBody();
  21. try this <?php $url = 'my.site.com'; $username = 'username'; $password = 'password'; $login = new HttpRequest($url. "/Login", HttpRequest::METH_POST); //The array Keys are the post keys $post_data = array("Username"=>$username,"Password"=>$password); $login->addPostFields($post_data); try { echo $r->send()->getBody(); } catch (HttpException $ex) { echo $ex; } ?> EDIT:updated to fit what you have
  22. turn on error reporting, its probably timed out
  23. depending on how your code starts the maze.. you may want to change if(empty($_SESSION['pos'])) to if(!isset($_SESSION['pos'])) if your not setting before hand! I also this has moved a little out side the ranges of "design"
  24. Erm... that doesn't help me much!
×
×
  • 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.