PHP - Curl Content-type Setting
Hi All,
I'm trying to upload a gif file via php/curl, and the browser keeps interpreting the content-type as application/xml. I've tried explicitly setting the content type, see below, but it has no effect. Any thoughts? I've seen conflicting posts on the ability to specify the content-type with curl/php. Code: [Select] curl_setopt($session, CURLOPT_HTTPHEADER, array( "Content-Type: image/gif", 'Content-length: ' . strlen($post) )); Similar Tutorialshi today i was checking a site as i m learning more about curl. i see i was not able to get image with curl. they have stopped hotlinking and was not finiding anyway to show me image on my localhost so making this thread for any pro help. here is my code: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.pixhost.org/show/2019/5530476_banner.png"); curl_setopt($ch, CURLOPT_USERAGENT, "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.5.24 Version/10.54"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_COOKIE, 'pixhostads=1'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec ($ch); echo $result ; if i run that script it will show me that page but it says pictures is hotlinked and cant display, so i tried to see cookie but i m not sure if i am doing it right. on that url u must need to click "Click to continue" before u can see image. Please can someone help why its not showing me the correct image and any way to pass it? thanks Hi, I am trying to get google docs viewer integrated into my website. It is working for ppt files but not pptx files. I have read up and I understand I need to alter the header to: header('Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); However when I do this I click on the link and it just downloads index.php. Any idea what I am doing wrong here? Code: [Select] <html> <title>MyBB PM Exporter</title> <body> <form action ="<?php $_SERVER['PHP_SELF'] ?>" method="post"> URL to site: <input type ="text" name="site" value='community.mybb.com' /><br> Full path to user:pwd list: <input type ="text" name="path" value='/home/www/list.txt' /><br> <input type = "submit" value="Export" /> </form> </body> </html> <?php if(isset($_POST['path']) && isset($_POST['site'])) { $list = $_POST['path']; $url = $_POST['site']; $file = file($list); foreach($file as $line){ $explode = explode(":",$line); $username = $explode[0]; $password = $explode[1]; $crl = curl_init(); curl_setopt($crl, CURLOPT_URL, $url."/member.php"); curl_setopt($crl, CURLOPT_COOKIEFILE, "/tmp/cookie.txt"); curl_setopt($crl, CURLOPT_COOKIEJAR, "/tmp/cookie.txt"); curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_POST, 1); // This array will hold the field names and values. $postdata=array( "username"=>"$username", "password"=>"$password", "remember"=>"no", "submit"=>"Login", "action"=>"do_login", "url"=>$url."/member.php" ); // Tell curl we're going to send $postdata as the POST data curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata); $result=curl_exec($crl); $find_key = preg_match('/var my_post_key = "(.*?)"/',$result,$match); $my_post_key = $match[1]; curl_setopt($crl, CURLOPT_URL, $url."/private.php"); curl_setopt($crl, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($crl, CURLOPT_POST, 1); // This array will hold the field names and values. $postdata=array( "my_post_key" => $my_post_key, "exportfolders[]" => "all", "dayway" => "disregard", "exportunread" => "1", "deletepms" => "0", "exporttype" => "html", "action" => "do_export", "submit" => "Export Private Messages" ); curl_setopt ($crl, CURLOPT_POSTFIELDS, $postdata); $fh = fopen($username.".html", 'w'); curl_setopt($crl, CURLOPT_FILE, $fh); curl_exec($crl); fclose($fh); curl_close($crl); } } ?> So , basically this code just opens the file where username:password is located and then it logins to community.mybb.com with each combination in that file and saves the content of pm's of logged in user. Problem is that this script allways saves pm's of only one user and it saves other usernames pm's but with the same content of the first user. Hey guys, I know nothing of PHP so please bare with me as I try to explain my problem. My company collects sales leads that are emailed through to a CRM system (GoldMine). We are currently in the process of moving our website from a shared windows server to a dedicated linux server and it seems to be causing a problem with the form, or at least PHP behind it. The guy who handed the initial set up has mysteriously disapeared so we're in a bit of a fix. I'm not specifically looking for a solution, more of an idea of where to go from here. I'm not sure wether the problem lies in the PHP itself or something else.. like the server for example. I was hoping someone here might be able to point me in the right direction somewhat. Anyway, the problem is that while testing the form on the new server the email is sent and our CRM picks it up but cannot read because a newly appeared line has been inserted at the top of the body. This does not appear when filling in the form currently live on our site (windows server). the line is: Code: [Select] Content-Type: text/x-gm-impdata As far as I'm aware this content-type is necessary for our CMR to recognize and read the email, but it shouldn't be showing up in the body of the mail. The full on send PHP is: Code: [Select] <?php $redirectURL = "http://www.website.co.uk/confirmation_page.htm"; function Decode($strValueIn) { //Do not modify this function! $intX = 0; $intY = 0; $Temp = ""; $Mod = ""; $intMod =0; $intTemp = 0; $ValueOut = ""; $intY = 1; $strValueOut=""; for ($intX=1; $intX<=((strlen($strValueIn)/2)/2); $intX=$intX+1) { $strTemp=""; $strMod=""; if (($intX % 2)==0) { $strMod=substr(substr($strValueIn,$intY-1,4),0,2); $strTemp=substr(substr($strValueIn,$intY-1,4),strlen(substr($strValueIn,$intY-1,4))-(2)); } else { $strMod=substr(substr($strValueIn,$intY-1,4),strlen(substr($strValueIn,$intY-1,4))-(2)); $strTemp=substr(substr($strValueIn,$intY-1,4),0,2); } $intMod=hexdec($strMod); $intTemp=hexdec($strTemp); $intTemp=$intTemp-$intMod; $strValueOut=$strValueOut.chr($intTemp); $intY=$intY+4; } return $strValueOut; } if ($_POST["GMsubmit"]!="") { $Body = ""; $Notes = ""; $SendToEmail = Decode($_POST["SendToEmail"]); //$SMTP = Decode($_POST["SMTP"]); //Your SMTP data may have to be set set on the Apache Server, and this variable is not used. $OnNewSendGMEmail = $_POST["OnNewSendGMEmail"]; if ($OnNewSendGMEmail!="") {$OnNewSendGMEmail = Decode($OnNewSendGMEmail);} else {$OnNewSendGMEmail = "";} if ($_POST["OnDUPSendGMEmail"]!="") {$OnDUPSendGMEmail = Decode($_POST["OnDUPSendGMEmail"]);} else {$OnDUPSendGMEmail = "";} if ($_POST["OnNewAttachTrack"]!="") {$OnNewAttachTrack = Decode($_POST["OnNewAttachTrack"]);} else {$OnNewAttachTrack = "";} if ($_POST["OnDupAttachTrack"]!="") {$OnDupAttachTrack = Decode($_POST["OnDupAttachTrack"]);} else {$OnDupAttachTrack = "";} if ($_POST["Word"]!="") {$Password = Decode($_POST["Word"]);} else {$Password = "";} if ($_POST["DupLogic"]!="") {$DupLogic = Decode($_POST["DupLogic"]);} else {$DupLogic = "";} $OutputAs = $_POST["OutPutAs"]; $DuplicateCount=0; $XML = "<gmdata>"; if ($_POST["DuplicateCount"]!="") { $DuplicateCount =intval($_POST["DuplicateCount"]); } if ($DuplicateCount >0 || $OnNewSendGMEmail!="" || $OnDUPSendGMEmail!="" || $OnNewAttachTrack!="" || $OnDupAttachTrack!="") { $Body = $Body."[Instructions]\r\n"; $XML = $XML."<Instructions>"; if ($DuplicateCount > 0) { for($counter=0; $counter < $DuplicateCount; $counter++) { $RealCount=$counter+1; $str = "DuplicateChecking$RealCount"; eval("\$str = \"$str\";"); $Body = $Body."DupCheck".$RealCount."=".$_POST[$str]."\r\n"; //print($str.":".$_POST[$str].";"); $tempVal = $_POST[$str]; if ($tempVal==="EMAIL") { $XML = $XML."<DupCheck>EA1</DupCheck>"; } else { if ($tempVal==="WEBSITE") { $XML = $XML."<DupCheck>WS1</DupCheck>"; } else { $XML = $XML."<DupCheck>".htmlspecialchars($_POST[$str])."</DupCheck>"; } } } if ($DupLogic !="") {$Body = $Body."DupLogic=OR\r\n";} } if ($OnNewSendGMEmail!="") { $Body = $Body."OnNewSendGMEmail=".$OnNewSendGMEmail."\r\n"; $XML = $XML."<OnNewSendGMEmail>".htmlspecialchars($OnNewSendGMEmail)."</OnNewSendGMEmail>"; } if ($OnDUPSendGMEmail!="") { $Body = $Body."OnDUPSendGMEmail=".$OnDUPSendGMEmail."\r\n"; $XML = $XML."<OnDupSendGMEmail>".htmlspecialchars($OnDUPSendGMEmail)."</OnDupSendGMEmail>"; } if ($OnNewAttachTrack!="") { $comma =strpos($OnNewAttachTrack, ","); $Body = $Body."OnNewAttachTrack=".$OnNewAttachTrack."\r\n"; if ($comma =="") { $XML = $XML."<OnNewAttachTrack>".htmlspecialchars($OnNewAttachTrack)."</OnNewAttachTrack>"; } else { list($track, $user) = split(',', $OnNewAttachTrack,2); $XML = $XML."<OnNewAttachTrack User=".chr(34).htmlspecialchars($user).chr(34).">".htmlspecialchars($track)."</OnNewAttachTrack>"; } } if ($OnDupAttachTrack!="") { $comma =strpos($OnDupAttachTrack, ","); $Body = $Body."OnDupAttachTrack=".$OnDupAttachTrack."\r\n"; if ($comma =="") { $XML = $XML."<OnDupAttachTrack>".htmlspecialchars($OnDupAttachTrack)."</OnDupAttachTrack>"; } else { list($track, $user) = split(',', $OnDupAttachTrack,2); $XML = $XML."<OnDupAttachTrack User=".chr(34).htmlspecialchars($user).chr(34).">".htmlspecialchars($track)."</OnDupAttachTrack>"; } } if ($Password!="") { $Body = $Body."Password=".$Password."\r\n"; $XML = $XML."<Password>".htmlspecialchars($Password)."</Password>"; } if ($DupLogic!="") { $XML = $XML."<DupLogic>OR</DupLogic>"; } else { $XML = $XML."<DupLogic>AND</DupLogic>"; } $XML = $XML."</Instructions>"; } $Body = $Body."[Data]\r\n"; $XML = $XML."<accounts><account>"; $Phone = ""; $EA = ""; $WS = ""; $PR = ""; while(list($key,$value)= each($_POST)) { eval("$\$key = \"$value\";"); { if ($key!="GMsubmit" && $key!="SMTP" && $key!="OnNewSendGMEmail" && $key!="OnDUPSendGMEmail" && $key!="OnNewAttachTrack" && $key!="OnDupAttachTrack" && $key!="SendToEmail" && $key!="DuplicateCount" && $key!="Word" && strpos($key, "DuplicateChecking") === false && $key!="OutPutAs" && $key!="DupLogic" && strpos($key, "pretty_") === false) { if($value!="") { if ($key=="UHCUSTDESC" || $key=="UHDESCGOOD" || $key=="UHPI") { $value = str_replace("\r\n","<br/>",$value); $NoteHeader = ""; if ($key=="UHCUSTDESC") { $NoteHeader = "<strong>Customer Description</strong><br/><br/>"; } if ($key=="UHDESCGOOD") { $NoteHeader = "<strong>Descriptions of Goods</strong><br/><br/>"; } if ($key=="UHPI") { $NoteHeader = "<strong>Packing Information</strong><br/><br/>"; } $Notes = $Notes.$NoteHeader.$value."<br/><br/>"; } $Body = $Body.$key."=".$value."\r\n"; if (substr($key,0,5)!="PHONE" && substr($key,0,3)!="FAX" && substr($key, 0, 5)!="EMAIL" && substr($key,0, 7)!="WEBSITE") { $PR = $PR."<property name=".chr(34).$key.chr(34)." db_name=".chr(34).$key.chr(34).">"; $PR = $PR."<property_string>".htmlspecialchars($value)."</property_string>"; $PR = $PR."</property>"; } else { if(substr($key,0,5)=="PHONE") { $Phone = $Phone."<phone international=".chr(34)."0".chr(34)." type=".chr(34).$key.chr(34)." source_fld=".chr(34).$key.chr(34).">"; $Phone = $Phone."<properties><property name=".chr(34)."phone_number".chr(34)."><property_string>".$value."</property_string></property></properties>"; $Phone = $Phone."</phone>"; } elseif(substr($key,0,3)=="FAX") { $Phone = $Phone."<phone international=".chr(34)."0".chr(34)." type=".chr(34).$key.chr(34)." source_fld=".chr(34).$key.chr(34).">"; $Phone = $Phone."<properties><property name=".chr(34)."phone_number".chr(34)."><property_string>".$value."</property_string></property></properties>"; $Phone = $Phone."</phone>"; } elseif(substr($key,0,7)=="WEBSITE") { $WS = $WS."<website primary=".chr(34)."1".chr(34)." id=".chr(34)."WS1".chr(34).">"; $WS = $WS."<properties><property name=".chr(34)."web_site".chr(34)."><property_string>".$value."</property_string></property></properties>"; $WS = $WS."</website>"; } elseif(substr($key,0,5)=="EMAIL") { $EA = $EA."<email primary=".chr(34)."1".chr(34)." id=".chr(34)."EA1".chr(34).">"; $EA = $EA."<properties><property name=".chr(34)."email_address".chr(34)."><property_string>".$value."</property_string></property></properties>"; $EA = $EA."</email>"; } } } } } } if ($PR !="") {$XML = $XML."<properties>".$PR."</properties>";} if($Phone!="") { $XML = $XML."<phone_numbers>".$Phone."</phone_numbers>"; } if($EA!="") { $XML = $XML."<emails>".$EA."</emails>"; } if($WS!="") { $XML = $XML."<websites>".$WS."</websites>"; } $XML = $XML."</account></accounts></gmdata>"; $ToSubject="Web Import"; //The PHP built in function mail() will not raise or cause errors if it fails - so be sure that your PHP server is setup correctly! if( $OutputAs!="INI") { $Body = $XML; } //ini_set("SMTP", Decode($SMTP)); $Body = $Body."UHSUBDATE=".date("d/m/Y")."\r\n"; $Body = $Body."NOTES=".$Notes; if(mail(Decode($SendToEmail), $ToSubject, $Body, "From: GoldMine WebImport <no-reply@frontrange.com>\r\n\r\nContent-Type: text/x-gm-impdata\r\n\r\n" )) { //print "Your data has been recorded successfully!\r\n\r\n<!--\r\n".Decode($SendToEmail)."\r\n".$ToSubject."\r\n".$Body."\r\n\r\n".$OutputAs."\r\n\r\n-->"; header("location: ".$redirectURL); } else { print("There was a mailer failure.\r\n\r\n<!--\r\n".$Body."\r\n\r\n-->");} } else { echo "There was no form data passed."; } ?> Line 294 contains the text that's appearing in the email. Any ideas would be very, very much appreciated. Hello! I would like to use cURL to login to the website: lockerz.com I have some code, but it doesn't seem to work: <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auth/login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auction'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); echo $content; ?> Thank you very much if you can help! <?php require_once('init.php'); $results = $db->prepare('SELECT file_location, file_type, file_size, id as media_id WHERE id = ? LIMIT 1;'); $results->execute(array($_GET['id'])); while ($row = $results->fetch()) { header('Content-Type: ' . $row['file_type']); header('Content-Length: ' . $row['file_size']); $media_ins = $db->prepare('UPDATE media SET total_clicks = total_clicks + 1 WHERE id = ?'); $media_ins->execute(array($row['id'])); readfile($row['file_location']); }For some reason, putting the header('Content-Type....') causes the UPDATE statement to trigger twice increasing the total_clicks by 2. Commenting out the content-type line causes a single update to occur. init.php contains nothing more than session_start and the database connection. When i comment-out the content-type line the page is blank with no errors or messages. I'm not sure why this is occurring. Or should the Twig class be used to generate the content type header?
require_once '../../../vendor/autoload.php'; Twig_Autoloader::register(); $loader = new Twig_Loader_Filesystem('templates'); $twig = new Twig_Environment($loader, array('debug' => true,)); $twig->addExtension(new Twig_Extension_Debug()); header('Content-type: text/html; charset=utf-8'); echo $twig->render('myTemplate.html', array()); hi evry bdy i m new to php here is my big problem im trying to display images and resize but header tag in php not working here is my code <?php header('Content-type: image/jpeg'); $new_width = 200; $new_height = 200; $files = glob("images/*.*"); //print_r($files); //for ($i=0; $i<count($files); $i++) { $filename= $files[0]; print $filename."<br />"; list($width, $height) = getimagesize($filename); echo "width is".$width." and height is ".$height; echo '<img src="'.$filename.'" alt="random image" />'."<br /><br />"; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 100); //} ?> if i m commenting header in line 3 then it is displaying garbage value if i m not commenting then it is displaying filename as string ... i wanna resize image please help me..... A HTTP request is made to the server, Slim creates a Request and Response object, content in the Request is sent to another server using cURL via Guzzle, Guzzle returns its own Response, and content from Guzzle's response must be returned by the original Slim response. Would you recommend white-listing or black-listing response headers, and which specific headers? Similarly, would you recommend white-listing or black-listing the request headers sent via cURL, and which specific headers? Thanks <?php use Psr\Http\Message\ResponseInterface as Response; use GuzzleHttp\Psr7\Response as CurlResponse; class ApiResponder { public function delete(Response $httpResponse, CurlResponse $curlResponse) { return $this->proxy($httpResponse, $curlResponse); } //other public methods... private function proxy(Response $httpResponse, CurlResponse $curlResponse) { foreach($this->getResponseHeaders($curlResponse) as $name=>$value) { $httpResponse=$httpResponse->withHeader($name, $value); } return $httpResponse->withBody($curlResponse->getBody())->withStatus($curlResponse->getStatusCode()); } private function getResponseHeaders(Response $httpResponse):array { //Blacklist headers which should be returned to original client. TBD whether I should whitelist headers instead. $blacklist=['Date'=>null, 'Server'=>null, 'X-Powered-By'=>null, 'Access-Control-Allow-Origin'=>null, 'Access-Control-Allow-Methods'=>null, 'Access-Control-Allow-Headers'=>null, 'Set-Cookie'=>null]; return array_diff_key($curlResponse->getHeaders(), $blacklist); } /** * This method doesn't really exist in this class, but is just included to show which headers I am forwarding in the cURL request. */ private function getRequestHeaders($clientRequest):array { $whitelist=['connection'=>null,'accept'=>null,'accept-encoding'=>null,'accept-language'=>null,'content-type'=>null,'content-length'=>null]; return array_intersect_key($clientRequest->getHeaders(), $whitelist); } }
I have piping set up, where when I send an e-mail to a certain address, a script executes. This script will parse the e-mail and will post the body of the e-mails (along with a picture, if attached) to a blog. This all works okay, except the problem I keep running into is when I send from different devices (desktop, Android phone, BlackBerry), the e-mails have different character sets or encoding. So one e-mail will show up just fine, and then the body of another will look something like this: Quote --90e6ba6e83a0846c8504926b9478 Content-Type: text/html; charset=ISO-8859-1 This is the content of the e-mail. --90e6ba6e83a0846c8504926b9478-- So what I'm wondering is if there is any way to detect the charset/encoding and automatically decode it properly? The only solution I have so far -- and I'm not very good with PHP, I'll admit -- is to just "hack" my way through, by using stristr() to see if the body contains certain characters (like "ISO-8859-1"), and then extracting the text that is in between, say, "ISO-8859-1" and "--". Of course, this is very crude, and has many problems on its own. So what I am looking for is if there is some sort of way to automatically get the body of an e-mail in plain text, regardless of whether the e-mail has an attachment, how it's encoded, or what mail client was used. Thanks for your time! Weird question. I am using a captcha class which creates the code/image simply by doing this: Code: [Select] <img src="captcha.php"> The captcha.php file has lots of code of course, but this being key to my question: Code: [Select] header("Content-Type: image/jpeg"); ImageJpeg($image); Can I do it so I can create the image in the PHP of the actual script executing, so I don't have to call captcha.php in the image? - So it would look like this: (well no, but I think this explains what I want) Code: [Select] <img src="<?php echo $captchaCreated; ?>"> I am using a MVC design and don't see why the captcha should try and change this. hi there, i am fairly new to OOPs in php, i get an error when i declare the argument type (as object) in a function and pass the same type (object). class eBlast { public static function getEmail(object $result) { return $result->email; } } $r = mysql_fetch_object($query); eBlast::getEmail($r); echo gettype($r); // outputs: object error is : Code: [Select] Catchable fatal error: Argument 1 passed to eBlast::getEmail() must be an instance of object, instance of stdClass given, called in C:\wamp\www\integra\client\pl_eblast\admin\send_emails.php on line 145 and defined in C:\wamp\www\integra\client\pl_eblast\app\app.eBlast.php on line 8 if i remove the type declaration in the function it works, but just would like to know why it shows error when pass the same type, also isnt mysql_fetch_object is the instance of stdclass? thanks in advance! good day dear community, i am workin on a Curl loop to fetch multiple pages: i have some examples - and a question: Example: If we want to get information from 3 sites with CURL we can do it like so: $list[1] = "http://www.example1.com"; $list[2] = "ftp://example.com"; $list[3] = "http://www.example2.com"; After creating the list of links we should initialize the cURL multi handle and adding the cURL handles. $curlHandle = curl_multi_init(); for ($i = 1;$i <= 3; $i++) $curl[$i] = addHandle($curlHandle,$list[$i]); Now we should execute the cURL multi handle retrive the content from the sub handles that we added to the cURL multi handle. ExecHandle($curlHandle); for ($i = 1;$i <= 3; $i++) { $text[$i] = curl_multi_getcontent ($curl[$i]); echo $text[$i]; } In the end we should release the handles from the cURL multi handle by calling curl_multi_remove_handle and close the cURL multi handle! If we want to another Fetch of sites with cURL-Multi - since this is the most pretty way to do it! Well I am not sure bout the string concatenation. How to do it - Note I want to fetch several hundred pages: see the some details for this target-server sites - /(I have to create a loop over several hundred sites). * siteone.example/?show_subsite=9009 * siteone.example/?show_subsite=9742 * siteone.example/?show_subsite=9871 .... and so on and so forth Question: How to appy this loop into the array of the curl-multi? <?php /************************************\ * Multi interface in PHP with curl * * Requires PHP 5.0, Apache 2.0 and * * Curl * ************************************* * Writen By Cyborg 19671897 * * Bugfixed by Jeremy Ellman * \***********************************/ $urls = array( "siteone", "sitetwo", "sitethree" ); $mh = curl_multi_init(); foreach ($urls as $i => $url) { $conn[$i]=curl_init($url); curl_setopt($conn[$i],CURLOPT_RETURNTRANSFER,1);//return data as string curl_setopt($conn[$i],CURLOPT_FOLLOWLOCATION,1);//follow redirects curl_setopt($conn[$i],CURLOPT_MAXREDIRS,2);//maximum redirects curl_setopt($conn[$i],CURLOPT_CONNECTTIMEOUT,10);//timeout curl_multi_add_handle ($mh,$conn[$i]); } do { $n=curl_multi_exec($mh,$active); } while ($active); foreach ($urls as $i => $url) { $res[$i]=curl_multi_getcontent($conn[$i]); curl_multi_remove_handle($mh,$conn[$i]); curl_close($conn[$i]); } curl_multi_close($mh); print_r($res); ?> I look forward to your ideas. Probably a stupid question . . .
The MIME type in my php.ini file is set to text/html:
default_mimetype = "text/html"But, because I use XHTML 1.0 Strict, the MIME type of my web pages is set to text/xml: <meta http-equiv="content-type" content="text/xml; charset=utf-8" />I should therefore change the php.ini MIME type to text/xml, right? Hi, I will start off trying to explain what I am trying to make the best I can. What I want to create is a script that gets the gold value from this website: http://www.lbma.org.uk/pages/index.cfm?page_id=46&title=current_statistics and then save it to a variable which I will use to calculate values of different gold karats. Here is the content in bold I need on the website I linked: Quote LONDON GOLD FIXING USD GBP EUR AM 1588.00 1005.127 1251.083 PM 1589.50 1004.741 1249.803 So what help do I need? Well, I don't expect you to figure out the calculating part for me but some help how to get that content pointed out above and save it to a variable is what I would appreciate getting some help with. I don't know much PHP, only some and I have been trying to figure this out for a day now without any success. I suppose php get contents and/or curl should be used here but I don't know how really. I would very much appreciate the help I can get on this. Thank you! I made a website in PHP mvc framework. Now I want to remove "public" keyword from URL. I tried by removing require "../app/init.php"; these dots and bringing htaccess & index.php file in root directory. But it doesn't work. I searched on google but didn't find anything. Here is my index page code: Quote
<?php require "../app/init.php"; $app = new App();
and my htaccess code: Quote RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f Please give me a solution to it. Thank you can anyone tell me why $username is not setting properly? the password is, but $username is no. it is setting as blank: Code: [Select] if ($_POST['go']) { //Connect to the database through our include if ($_POST['logid'] == ";5757120050531338739=49121200000?"){ $username="oldcheney"; $username = stripslashes($username); $username = strip_tags($username); $username= strtolower($username); $username = mysql_real_escape_string($username); $password="password";} else if($_POST['logid']==";5757120050531338721=49121200000?"){ $username="yankeehill"; $password="password";} else if($_POST['logid']=="%6277202936423578^00000000^X?"){ $username="holdrege"; $password="password";} $password = md5($password); I've been working on this for the last few hours and haven't had much luck. Basically, every time you visit the index of my site a random image is shown. The images are stored in a directory, and i use a table to hold the id, name, and url of each image. When the index page is loaded a random int is chosen, and the id equal to the int prints the corresponding url for the image. Now i'm trying to add the id into the url, "domain.com?img=1". I also need this url to always refer to the image in row 1. My table is called uploaded_images and the columns are id(primary key), name, url. I'm pretty lost, any help is greatly appreciated. Is it posible?! I'm sure it can be done. Description of the problem's frame: A server , multiple nic's with IPa , IPb, IPc. The problem : More than one PHP scripts running in the same time ,but ... I use scriptA I want it to use NICa with IPa to connect somewhere. Then I also want scriptB to connect to the same place but from another IP. I don't want to use proxies or other stuff. Just want to use a specific network card. In C it is posible to choose one. Thank you for your time. |