PHP - Rewritecond And Request Params...
Hi Guys
This may be a silly question. Apologies in advance.
Lets say I wanted to write a rewrite condition where I need to test both the query_string and the resquest_uri against the same regex. Is it possible to almost parametise these in one line?
e,g.
RewriteCond %{REQUEST_URI, QUERY_STRING} SOME-PATTERN etc. Similar TutorialsHi I don't understand this stuff and am trying to debug it to see. This function seems to return Resource id #1. I have added an echo at line 33. Not a big file but would like to understand what is happening behind. http://www.des-otoole.co.uk/streetangels/eapi.php Code: [Select] <?php //==================================== Simple PHP code sample ==========================================// /* * We recommend that you use port 5567 instead of port 80, but your * firewall will probably block access to this port (see FAQ for more * details): * $url = 'http://www.bulksms.co.uk:5567/eapi/submission/send_sms/2/2.0'; * * Please note that this is only for illustrative purposes, we strongly recommend that you use our comprehensive example */ $url = 'http://www.bulksms.co.uk/eapi/submission/send_sms/2/2.0'; $data = 'username=your_username&password=your_password&message='.urlencode('Testing SMS').'&msisdn=44123123123'; $response = do_post_request($url, $data); print $response; function do_post_request($url, $data, $optional_headers = null) { $params = array('http' => array ( 'method' => 'POST', 'content' => $data, )); if ($optional_headers !== null) { $params['http']['header'] = $optional_headers; } $ctx = stream_context_create($params); echo "$ctx, $url, $data"; exit; $fp = fopen($url, 'rb', false, $ctx); if (!$fp) { print "Problem with $url, Cannot connect\n"; } $response = @stream_get_contents($fp); if ($response === false) { print "Problem reading data from $url, No status returned\n"; } return $response; } ?> <html> <body> <? echo $ctx ?> </body> </html> Ta Desmond. Hi again again, I'm making a search, where I use BETWEEN, if I have et $maxPrice is 2147483647 and $minPrice is 0 - (result from var_dump()), when I then use it in PDO, it's like it get another 'maxPrice' because it only show results under "200000" in price, but if I define, a static value of 2.000.000 it gets all the results as it should, but not when doing it with params in PDO :/ I also do a var_dump() of the maxprice, after the PDO, and the value is still the same as above (the 2147483647), and I've been spending loong time now, trying to find out why! Maybe someone here can spot the error! http://codepad.org/VIsk0UI8 Thank you a lot! Doing something wrong, but don't see it. How should one retrieve a POST parameter? My $request->toArray()['html'] works, but I am sure it is not the "right way". <?php namespace App\DataPersister; use ApiPlatform\Core\DataPersister\DataPersisterInterface; use Symfony\Component\HttpFoundation\RequestStack; class ArchivePersister implements DataPersisterInterface { public function __construct(RequestStack $requestStack) { $request = $requestStack->getCurrentRequest(); syslog(LOG_ERR, '$request->getMethod(): '.$request->getMethod()); syslog(LOG_ERR, '$request->getContent(): '.$request->getContent()); syslog(LOG_ERR, '$request->request->get(html): '.$request->request->get('html')); syslog(LOG_ERR, '$request->query->get(html): '.$request->query->get('html')); syslog(LOG_ERR, '$request->get(html): '.$request->get('html')); syslog(LOG_ERR, '$request->toArray(): '.json_encode($request->toArray())); syslog(LOG_ERR, '$request->toArray()[html]: '.$request->toArray()['html']); } } output $request->getMethod(): POST $request->getContent(): {"project":"/projects/1","description":"","html":"<p>{{ project_name }}</p>"} $request->request->get(html): $request->query->get(html): $request->get(html): $request->toArray(): {"project":"\/projects\/1","description":"","html":"<p>{{ project_name }}<\/p>"} $request->toArray()[html]: <p>{{ project_name }}</p> Hi, I'm trying to make a header("Location: "); where I want, the url I'm currently on, without any ?id=1 etc, so I get /category/editCategory/ instead of /category/editCategory/?id=1 How can I do that, when I do $_SERVER, sometimes I see one called $_SERVER['REQUEST_URL'] (yep, URL, not URI) - which does exactly what I want, but it's only sometimes I have it :S Is there a nice way of doing it? Best regards, Lucas R. Hi all, I am trying to build a multidimensional array from values in a URL. For example: page.php?ind=123&loc=456&wt=789 needs to build the array like this: Code: [Select] Array ( [0] => Array ( [0] => 123 ) [1] => Array ( [0] => 456 ) [2] => Array ( [0] => 789 ) ) If one of these params is empty: page.php?ind=123&loc=&wt=789 I need the array to be Code: [Select] Array ( [0] => Array ( [0] => 123 ) [1] => Array ( [0] => 789 ) ) I am having some trouble wrapping my head around how to do this. I am using array_push to construct it, but i fear I may be missing something. There's a good change I am way off too . Any suggestions would be greatly appreciated. My code: <?php // get the id from the URL if (isset($_GET['ind'])) { $indId = $_GET['ind']; } if (isset($_GET['loc'])) { $locId = $_GET['loc']; } if (isset($_GET['wt'])) { $wtId = $_GET['wt']; } $searchArray = array(); if (!isset($_GET['ind'])) { empty($_GET['ind'); } else { array_push($searchArray, $ind); } if (!isset($_GET['loc'])) { empty($_GET['loc']); } else { array_push($searchArray, $loc); } if (isset($_GET['wt'])) { empty($_GET['wt']); } else { array_push($searchArray, $wt); } echo '<pre>'; print_r($searchArray); echo '</pre>'; ?> Hi Everyone First off I don't know PHP except the includes statement which I use regularly to make the site a little easier to update. But anyways am having an issue. I am trying to make a standard template page. On a prior site I had it set up this way with the code I will post below and it worked for me but I have tried to implement it on this site and am not having any luck. Few things on the code below. It was designed for another site. So what I need is as follows. The home page should bring up the default index.txt file. That has the home page info on it. Second the code below has a table in the coding as I required a table on my site so that is in the code but for this site don't need the table. There is also one image in the code. That too is no longer required. I will just leave these in place that way you can see the code I am working with so you can hopefully correct it to work for me as I am going nuts trying to get this to work. Also somewhere in the coding it seems maybe there is an open link tag as I did get this to work a little bit but for some reason when it was the TXT file information was also being made to be a link even though the txt file for time being only contains basic text no coding what so ever. Now what I need is as follows. Default home page TXT file loaded when home page loads. But the link below is what I was using for my site and when this was clicked it would load the TXT file for that page so the example link below would open up a members page that was associated with my message board I was using. Code: [Select] <a href="members.php?categories_file=Members">Forum Members Websites</a> that link would bring up file members.txt which was stored in the text folder Below is the code that in both cases was and is placed in the main window of the table I am using for layout. Last time this all worked perfectly but this time not sure why it refuses to load the page like it use to. Can anyways sort this code so it works fine for me. Thanks!! Dave Code: [Select] <?php if ($_GET['categories_file']) $fp = fopen("text/$categories_file.txt", "r") or die("Could not open $categories_file."); while (!feof($fp)) { $line = fgets($fp, 512); $categories[] = $line; } asort($categories) or die("Could not sort array."); $table_column_counter = 0; echo "<table border='0' cellpadding='0' cellspacing='0' width='90%'>"; foreach ($categories as $item) { if ($table_column_counter == 0) { echo "<tr>\r\n"; } $link = explode(",", $item); echo "<td><img src='images/green.gif' width='13' height='13'><a href='$link[1]' target='_blank'>".$link[0]."</a></td>"; if ($table_column_counter == 2) { echo "</tr>\r\n"; } $table_column_counter = $table_column_counter + 1; if ( $table_column_counter >= 2 ) { $table_column_counter = 0; } } ?> hi, can anyone please check my code it has an error Quote invalid content type for request: application/x-www-form-urlencoded Code: [Select] <?php $request = "<?xml version='1.0'?><request><br> <authentication><br> <username>username</username><br> <password>password</password><br> </authentication><br> <operation>getResellerProducts</operation><br> <params><br> <int>22</int><br> </params><br> </request></myXML> "; $url = "https://testapi.ssl.trustwave.com/3.0/"; // fake - obviosly! $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); // what to post curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $result = curl_exec($ch); curl_close($ch); print $result; ?> thanks! hello guys , can you guys see any errors in this code`? i cant seem to find it <?php $units_stats_1 = array(40, 35, 50); $units_stats_2 = array($units_stats_1[0] * 50%, $units_stats_1[1] * 100%, $units_stats_1[2] * 100%); echo $units_stats_2; ?> i allso tryed to do : echo $units_stats_2[0]; thanks I'm looking for a way to get the full url of the current page. something like $_SERVER['REQUEST_URI'] but the full thing. request uri doesn't work well for my situation, because my script is in a subdirectory of a domain. http://localhost/script. When I use request uri, it also includes "/script", which it should. Is there anyway to request the full URL? I working one paracel SOAP api and im totally crazy already. I need send that code: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://service.core.epmx.application.eestipost.ee/xsd"> <soapenv:Header/> <soapenv:Body> <xsd:businessToClientMsgRequest> <partner>KLIENDIKOOD</partner> <interchange msg_type="elsinfov1"> <header file_id="201805030022" sender_cd="KLIENDIKOOD"/> <item_list> <item service="PA"> <add_service> <option code="ST"/> <option code="SF"/> </add_service> <measures weight="1.000"/> <comment>testcomment</comment> <partnerId>12345</partnerId> <receiverAddressee> <person_name>TEST1</person_name> <mobile>55555555</mobile> <email>itest@test.ee</email> <address country="EE" offloadPostcode="96000"/> </receiverAddressee> <returnAddressee> <person_name>Sender name</person_name> <phone>55555555</phone> <mobile>55555555</mobile> <email>itest@test.lv</email> <address postcode="13811" deliverypoint="Tallinn" country="EE" street="Mahtra 7"/> </returnAddressee> </item> </item_list> </interchange> </xsd:businessToClientMsgRequest> </soapenv:Body> </soapenv:Envelope> If someone have no idea how create php script using SoapClient for that, then im happy to see result! :)
* What i tried is totally shit and didnt worked at all, so i better don't show my code :D Hi there I'm trying to get an answer for a soap request This is the info provided by the software house about the request: POST /myTest/Services.asmx HTTP/1.1 Host: 127.0.0.1 Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://------.--/myTest/Addons" <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <Addons xmlns="http://------.--/myTest/"> <hotelUnit>string</hotelUnit> <initialDate>dateTime</initialDate> <finalDate>dateTime</finalDate> <roomStays> <RoomStayOfPAX> <PaxPerRoom> <PAX xsi:nil="true" /> <PAX xsi:nil="true" /> </PaxPerRoom> <RoomType>string</RoomType> <Allotment> <Allotment>string</Allotment> </Allotment> </RoomStayOfPAX> <RoomStayOfPAX> <PaxPerRoom> <PAX xsi:nil="true" /> <PAX xsi:nil="true" /> </PaxPerRoom> <RoomType>string</RoomType> <Allotment> <Allotment>string</Allotment> </Allotment> </RoomStayOfPAX> </roomStays> <onlyFixedValue>boolean</onlyFixedValue> </Addons> </soap:Body> </soap:Envelope> I'm trying to use this code for the request passing the xml on $parameters $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$baseurl.$command); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_TIMEOUT,180); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, "$login:$password"); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $result = curl_exec($ch); if($result === false){ echo 'Curl error: ' . curl_error($ch); } else { //$result = simplexml_load_string($result); } curl_close($ch); return($result); But I get an invalid request. myTest is over a self signed ssl certificate and with basic authentication. Maybe the problem resides there or in the request itself. Anyone can help me with this ? Best regards. hey guys im tring to look for a good way of finding out if a ajax request is being performed on my page...now ive had a look about and found these two snippets.
Both seems to work fine...any suggestions on what one is best to use or even if there is a better way to do this would be helpful...thank you
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === "xmlhttprequest") { // is ajax } if (strpos($_SERVER['HTTP_ACCEPT'], 'application/json') !== false){ // is ajax } 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. Hello, I am using the send mail form, everything is sent to my mail except the country field, it is sending blank. Code: [Select] $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $email = $_REQUEST['email'] ; $country = $_REQUEST['country'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail( $to, $subject, $name."\n".$phone."\n".$email."\n".$country."\n".$message, $headers); How could it be fixed please? thanks I'm struggle to build an appropriately formatted URL request for a particular API (not really important which, but it's for Toodledo). The API documentation says: Quote Tasks are edited by POSTing a URL encoded JSON encoded array to the API. Each element in the array will be a task object. You only need to set the fields that you want to set. For efficiency, you should try to send only the fields that have changed. At this time it is not possible to post XML data to Toodledo. http://api.toodledo.com/2/tasks/edit.php?key=YourKey; tasks=[{"id"%3A"1234"%2C"title"%3A"My Task"}%2C{"id"%3A"1235"%2C"title"%3A"Another Task"%2C"star"%3A"1"}]; fields=folder,star I've tried about 100 different combinations of code like the following: $arr = array ('id'=>$id,'completed'=>1,'reschedule'=>1); $tasks = json_encode(array($arr)); $params = array('key'=> $this->key); $params['tasks'] = $tasks ; $params['fields'] = 'id,completed,reschedule' ; $url="http://api.toodledo.com/2/tasks/edit.php?".http_build_query($params) ; $response = file_get_contents($url); None seems to get me to a URL formatted like they ask. Can someone help me out? I'm tired of banging my head against the table. [Note... the fields I'm passing in single element of the $tasks array are different than in the example... but it's the format, not the content, that I can't get right] Thanks in advance! I am very confused at an example in a book I am reading called Beggining PHP regarding XML-RPC requests. I will write the code below: function send($remoteServer, $remotePort, $fullXMLRPCRequest) { $headers = ''; $data = ''; $socket = fsockopen($remoteServer, $remotePort); fwrite($socket, $fullXMLRPCRequest); while ($str = trim(fgets($socket))) { // why doesn't this exhaust the returned call?? $headers .= $str . "\n"; } while (!feof($socket)) { $data .= fgets($socket); } fclose($socket); return $data; } The question I have is notice how there are two while statements and they both access the same resource ($socket). So how can there be two while statements?? Wouldn't the first while statement exhaust the resource and there would be nothing on the second while statement? I hope this makes sense. It's sort of like saying while(x < 10) { //execute... ++x; } then another while statement while(x < 10) { //execute... ++x; } Well then wouldn't the second while statement not execute? I hope I made sense. Thanks for all the help in advance. Obviously knowing XML-RPC would help in answering this question, hopefully most of you are familiar with it. I am new to all this, so please help I want to create a request form, basically when I click onto a hyperlink on my web page I want it to call windows explorer with the following ftp;//test.co.uk (example), which will bring up the page and I can log in. Any help would be a much appreciated I am using the code below to query a url. It should return the response in xml bu all i get is a string back. $url = 'https://services.example.org/webservices/xget.php?ProductIDValue='.$_GET['pid'].'&ProductIDType=01&ONIXRecordFormat=03&ClientID='.$GLOBALS['user'].'&ClientPassword='.$GLOBALS['pass']; $r= new HttpRequest($url, HttpRequest::METH_GET); $r->send () ; echo $r->getResponseBody() ; 1. How can i get the response as xml 2. How can i display the response on my web page Thanks a lot for your help Hi, I am attempting to download a report from Bing Ads, and am having issues with the level of nesting on the SOAP request for the date, (specifically 'Time' = >....) Definitely appreciate the help! SOAP elements can be found at https://docs.microsoft.com/en-us/advertising/reporting-service/date?view=bingads-13 for date and https://docs.microsoft.com/en-us/advertising/reporting-service/reporttime?view=bingads-13 using CustomDateRangeStart and CustomDateRangeEnd $request = [ 'ReportRequest' => new SoapVar( [ 'Format' => 'Csv', 'ReportName' => 'Bing Keyword Performance Report', 'ReturnOnlyCompleteData' => false, 'Aggregation' => 'Daily', 'Sort' => ['SortColumn' => 'Clicks'], 'Sort' => ['SortOrder' => 'Ascending'], 'Scope' => [['AccountIds' => [...]], ['CampaignId' => null], ['AdGroupId' => [...]]], 'Time' => ['CustomDateRangeStart' => ['Date' => ['Day' => $startDay],['Month' => $startMonth],['Year' => $startYear]]], 'Time' => ['CustomDateRangeEnd' => ['Date' => ['Day' => $endDay],['Month' => $endMonth],['Year' => $endYear]]], 'Filter' => ['BidMatchType' => [$mt]], 'Keywords' => array($criteriaValue), 'Columns' => [ "TimePeriod", "Spend", "Clicks", "CurrentMaxCpc", "Impressions", "AverageCpc", "TopVsOther", "QualityScore", "CampaignStatus", "AdGroupStatus", "BidMatchType", "AdGroupName" ] ], SOAP_ENC_OBJECT, 'KeywordPerformanceReportRequest', "https://bingads.microsoft.com/Reporting/v13" )]; Edited March 8, 2020 by Mike1020 Added a link for ReportTime data object I currently have a mailing list that my boss uses, when he adds an email there is no 'sucess message' to let him know it has worked.
The mailing list just redirects back to the add subscribers page. I wondered if its possible to add a request so when he adds an email I can redirect the url to this:
?page=addemail&message=your email was added
and then echo $message where I want it to appear.
I have added $message = $_REQUEST['message']; to my page but nothing is happening. Can I not use request like this?
|