Jump to content

doa24uk

Members
  • Posts

    102
  • Joined

  • Last visited

    Never

Everything posted by doa24uk

  1. Hi guys, I'm using Wordpress. Here is my .htaccess file # Use PHP5 Single php.ini as default AddHandler application/x-httpd-php5s .php # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress The problem is that I can't access any .php files & certain directly from within the wp-content/plugins directory eg. I can access the following http://mysite.com/wp-content/plugins/ http://mysite.com/wp-content/plugins/plugin-name/ http://mysite.com/wp-content/plugins/plugin-name/file.php but I can access http://mysite.com/wp-content/plugins/plugin-name/readme.txt http://mysite.com/wp-content/plugins/plugin-name/myImage.png Any ideas?
  2. Thanks, just expanding this slightly - that loop is actually within another loop..... $Target = "phrase 2" $textarea_array=array("phrase 1","phrase 2"); foreach ($textarea_array as $XQuery) { $html = "http://www.mysite.co.uk/search?api=" .$XQuery; $dom = new DOMDocument; @$dom->loadHTMLFile($html); $xpath = new DOMXPath($dom); $aTag = $xpath->query('//h3[@class="r"]/a'); foreach ($aTag as $val) { $arr[] = $val->getAttribute('href'); } foreach($arr as $key => $value) { if(stristr($value, $Target)) { $Position = $key; break; } else { $Position = "Not Found"; } } echo $XQuery; echo "-"; echo $Position; echo "<br><br>"; } What should be being output is phrase 1 - position of phrase 1 phrase 2 - position of phrase 2 What is actually being output is phrase 1 - position of phrase 1 phrase 2 - position of phrase 1 And I just can see why!?
  3. As you can see, the Target is 3.com and it IS in the array ... so why isn't this working?? It's continuously outputting Not Found :shrug: :wtf: <?php $Target="3.com"; $arr=array("http://1.com","http://2.com","http://www.3.com/whatever","http://4.com"); foreach($arr as $key => $value); { if(stristr($value, $Target)) { $Position = $key; } else { $Position = "Not Found"; } echo $Position; } ?>
  4. Hi guys, My script does the following: Takes a textarea input, cleans it & splits it into an array. 1 text area line = 1 array value. Open an HTML page with DOM and find the 'Target' on the page. Returns it's position. Here's what should be output: Text Area Line 1 - Position (of Text Area Line 1) Text Area Line 2 - Position (of Text Area Line 2) However what's actually being output is: Text Area Line 1 - Position (of Text Area Line 1) Text Area Line 2 - Position (of Text Area Line 1) Why is it holding on to the position variable? I think it's simply because my loops are in the wrong place. <?php // Get Textarea string and trim spaces & blank lines $textarea = $_POST['phrase']; $textarea = trim($textarea, " \r\n"); // Explode textarea on newlines to get individual search phrases $textarea_array = explode("\n", $textarea); // //Get site to look for (Target) & force removal of http:// & http://www. to be user friendly. // Removal is case insensitive. // $Target = $_POST['target']; function remove_http($Target = '') { return(str_ireplace(array('http://www.','http://'), '', $Target)); } $Target = remove_http($Target); // // //Main Foreach loop - takes each line of text area and searches URL for results. // // foreach ($textarea_array as $XQuery) { //Replace space ( ) with + to ensure compatibility in the next step $XQuery = str_replace(" ","+",$XQuery); $html = "http://www.mysite.co.uk/search?api=" .$XQuery ."&productvalid=1"; $dom = new DOMDocument; @$dom->loadHTMLFile($html); $xpath = new DOMXPath($dom); $aTag = $xpath->query('//h3[@class="r"]/a'); foreach ($aTag as $val) { $arr[] = $val->getAttribute('href'); } foreach($arr as $key => $value) { if(stristr($value, $Target)) { // // Result found, Position is the key + 1 (first array value is zero). // Then further define it to include the nice text, this'll make it easier to echo later. // $Position = $key + 1; // break; } else { // // Result not found, set $Position to not found. // $Position = "Not Found"; } } // // We're out of the loop, so tell the good people the results! // echo $XQuery; echo "-"; echo $Position; } ?>
  5. Solved .... For those looking for the same thing.... array_slice // Get Textarea string $textarea = $_POST['phrase']; // Explode textarea on newlines to get individual search phrases $textarea_array = explode("\n", $textarea); // Slice off the unwanted items // First value should be 0 (start of array) // Second value should be your upper limit (10 in my case) // Anything about the upper limit will be removed $ResultArray = array_slice($textarea_array, 0, 10);
  6. Just reposting won't help .... I've given you what you asked for ... is this correct or not?
  7. Is this what you need? <?php $Question = 'I-A'; echo "1(" . $Question . ")<br />"; echo "2(" . $Question . ")<br />"; echo "3(" . $Question . ")<br />"; echo "4(" . $Question . ")<br />"; echo "5(" . $Question . ")<br />"; ?>
  8. Hi guys, I've got a textarea input .... I'm aware that I can't count / restrict the lines only the characters ... plus I don't want to use JS (needs to be foolproof / JS un-enabled proof). The problem is that someone can submit as many lines as they wish. I want to set the max array size (array values) to say 50... I presume I'll have to count() the array and then somehow dump the 51st, 52nd, n... values in the array?
  9. Thanks! I finally went with this ... just incase someone else is looking for the same thing... $array = array( 'http://www.arau.org/ct_home.php','http://www.arau.org/','http://en.wikipedia.org/wiki/Arau'); foreach($array as $key => $value) { if(stristr($value, "arau.org")) { $partial_match_key = $key; break; } }
  10. Hi guys, My array is as follows: Array ( [0] => http://www.arau.org/ct_home.php [1] => http://www.arau.org/ [2] => http://en.wikipedia.org/wiki/Arau ) All I want to do is look for certain partial matches & output their position in the array. It shouldn't care about the other results ... just the first match Eg. $string_to_match = "arau.org" // If arau.org is found in array echo "Found at position 0"; I've looked at several array search options (in_array,stristr) etc. none seem to work...
  11. Hey guys, Lets say this is a portion of my HTML output page <ul> <li>Listing One</li> <li>Listing Two</li> <li>Listing Three</li> </ul> Here's my psuedo code for what I want to do. $text to find = "Listing Three"; if $text to find = found { echo Found in position 3. } else Sorry, text not found I do have a Javascript script that will number the results ... javascript:var%20p=document.getElementsByTagName('li');var%20j=1;function%20gc(){for(i=0;i<p.length;i++){if(p[i].className=='g'){p[i].innerHTML=j+'.%20'+p[i].innerHTML;j++;}};};gc(); But I've got no idea if I have to pre-number the results in PHP or if PHP can just find it straight off.....
  12. Hey guys, My two possibilities are to match either HTML\1.0 or HTML\1.1 I was using str_replace to just match one but now I believe I need preg_replace. $responsecode = str_replace("HTTP/1.1", "", $headers[0]); However I'm completely lost with the regex for this! Help!
  13. I am so tired lol! I had spaces in the URLs. Replaced spaces with +s and everythings working fine now. Thanks DoA
  14. Hi guys, Here's my script mysql_connect("localhost", "REMOVED", "REMOVED") or die(mysql_error()); mysql_select_db("REMOVED") or die(mysql_error()); // Get all Links $result = mysql_query("SELECT * FROM ping") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { // Send Pings now $title = $row['title']; $url = $row['url']; $offsiteurl = "http://offsitedomain.com/ping/?title=".$title."&blogurl=".$url."&chk_weblogscom=on"; echo $pingomatic; $handle = fopen($offsiteurl, "r") or die("Can't open file"); fclose($handle); It outputs the correct URL and then error's saying Can't open file ... It also says "HTTP wrapper does not support writeable connections" ... However if I hard code the URL into the fopen eg. fopen("http://google.com", "r") it works perfectly ??? All I want to do is create a bunch of URLs from my database & open them one at a time - surely it's simple stuff!!!
  15. I should be more specific. This will be run as a cron job therefore no user integration / visual output is required ... the script simply needs to open the URL to send the ping. I've found the following code that apparently works for classic ASP ... can anyone translate this to php?? function SendPing(byval strBlogName, byval strBlogUrl, byval strPageUrl, byval strFeedUrl) ‘ build ping XMLRPC call strData = “<?xml version=”"1.0″”?>” strData = strData & “<methodCall>” strData = strData & “<methodName>weblogUpdates.extendedPing</methodName>” strData = strData & “<params>” strData = strData & “<param>” strData = strData & “<value>” & strBlogName & “</value>” strData = strData & “</param>” strData = strData & “<param>” strData = strData & “<value>” & strBlogUrl & “</value>” strData = strData & “</param>” strData = strData & “<param>” strData = strData & “<value>” & strPageUrl & “</value>” strData = strData & “</param>” strData = strData & “<param>” strData = strData & “<value>” & strFeedUrl & “</value>” strData = strData & “</param>” strData = strData & “</params>” strData = strData & “</methodCall>” ‘ post to Pingomatic XMLRPC ping URL set objHttp = Server.CreateObject(”MSXML2.ServerXMLHTTP”) objHttp.open “POST”, “http://rpc.pingomatic.com/”, false objHttp.setRequestHeader “Content-Type”, “text/xml” objHttp.setRequestHeader “Content-Length”, len(strData) objHttp.Send strData ‘ check response if (objHttp.status = 200) then strReturn = objHttp.responseText end if ‘ release object set objHttp = nothing ‘ passback SendPing = strReturn end function strData = SendPing(”The Title Of Your Website”, “The URL of your website”, “The URL of the new article”, “The URL of your RSS feed”)
  16. Hi guys, I want to simulate opening a window & actually visiting a site for the following url. http://mysite.com/ping/?title=mytitle&blogurl=myurl&chk_weblogscom=on&chk_blogs=on Alternatively, you can use xml-rpc to send the details but I don't think that's possible with php is it?? This would mean dynamically creating an xml file from a mysql database ... and I don't think that's possible
  17. hi, The emails were getting through it's just the sender was appearing incorrectly. It turns out that if you try and send a php mail() from a real existing address on the SAME server then it doesn't lookup the MX record correctly & so defaults to the server mail() daemon... weird but I got round it by using 547849875498754389@yahoo.com
  18. Hi guys, Here's my code. Basically this sends a simple email & a script picks it up on the other end (the script has access to the inbox) and outputs the author. Obviously the author should ALWAYS be me@mysite.com with this script & it is .... maybe 3/10 times ... however the remaining 7 it defaults to a server allocated address - mysite@box975.myhost.com Why is it doing this? Am I trying to send too many emails in a short space of time?? $message = "A simple Email" mail( "yourname@example.com", "Email Subject", $message, "From: me@mysite.com" );
  19. Ok sorted, to anyone else who comes across this. The array needed trimming of extra characters & then it's good to go. //Define $url here as Link List [code=php:0] $url = $_POST["url"]; $file = file_get_contents($url); function getUrls($file) { $regex = '/https?\:\/\/rapidshare.com\/files\/[^\" ]+/i'; preg_match_all($regex, $file, $matches); return ($matches[0]); } $urls = getUrls($file); foreach($urls as $urls2) { $trimmed = trim($urls2); $list[] = $trimmed; } //remove dups from array here $clean = array_unique($list); foreach ($clean as $val) { echo $val . "<br />"; } Edit: Just noticed Salanthe's reply ... thanks - chose to trim instead since I'm not too hot on regex
  20. Thank you all. I understand why you don't simply want to give code away. If everyone did that then no-one would learn anything.... I've spent way to long on forums full of idiots to know that. So, I have noticed the above topic but since I would like (if possible) to stick with a script I have written & therefore understand, here's my crack at it., Problem is that when I echo the $array in the foreach loop, it spits out 'ArrayArrayArrayArray' etc. rather than the value. When I clean it and output it it obviously cleans all extra 'Array' lines and simply spits 'Array'. <?php //Define $url here as Link List $url = $_POST["url"]; // Caution, this URL contains NSFW material $file = file_get_contents($url); function getUrls($file) { $regex = '/https?\:\/\/rapidshare.com\/files\/[^\" ]+/i'; preg_match_all($regex, $file, $matches); return ($matches[0]); } $urls = getUrls($file); foreach($urls as $urls2) { $list[] = $urls; //echo $list; } //remove dups from array here $clean = array_unique($list); foreach ($clean as $val) { echo $val . "<br />\n"; } ?> The following code DOES spit the correct urls out, but it only removes one duplicate (ie. count goes from 3 -> 2) <?php //Define $url here as Link List $url = $_POST["url"]; // Caution, this URL contains NSFW material $file = file_get_contents($url); function getUrls($file) { $regex = '/https?\:\/\/rapidshare.com\/files\/[^\" ]+/i'; preg_match_all($regex, $file, $matches); return ($matches[0]); } $urls = getUrls($file); foreach($urls as $urls2) { $list[] = $urls2; // Change this from $urls to $urls2 } //remove dups from array here $clean = array_unique($list); foreach ($clean as $val) { echo $val . "<br />\n"; } ?>
  21. Sorry, could you show me how to integrate that with my script, please?
  22. Well that's still loading them twice (since their are two hyperlinks linking to one URL). Also, I want to eventually build this to visit any page and pick out links from http://rapidshare.com/files or http://whatever.com/file/whatever So I'd rather not be tied down in that respect.
  23. Thanks for that. I've taken your code and made it fit my needs. It's working OK apart from it's grabbing each URL 3 times .... so basically it's grabbing it from the href tag, the plain URL (which is also shown on the page) and another hyperlinked version. Is there any way to make it only grab the none linked version .... ie. the Plain text version?? Here's the code I'm using... <?php //Define $url here as Link List $url = "http://rapidshare.com/users/IZF0LP"; // Caution, this URL contains NSFW material $file = file_get_contents($url); function getUrls($file) { $regex = '/https?\:\/\/rapidshare.com\/files\/[^\" ]+/i'; preg_match_all($regex, $file, $matches); return ($matches[0]); } $urls = getUrls($file); foreach($urls as $url2) { echo $url2.'<br />'; } ?>
  24. Hi guys, What I need to do is take a page & extract all the URLs from the page & place them in an array. However I only need to grab certain URLS eg. site1.com site1.com/folder/thisfile.zip site2.com site2.com/some/folder/or/subfolder/1.mp3 site3.com but then leave out of the array site4.com site5.com/the/script/needs/to/be/able/to/grab/sub/folders/and/files/2.mp3 Here's the script I've got so far but this will grab ALL the links ... so I need to modify this & perhaps use an if or switch statement to check whether it's a link I actually want... <?php $string = '<a href="http://www.example.com">Example.com</a> has many links with examples <a href="http://www.example.net/file.php">links</a> to many sites and even urls without links like http://www.example.org just to fill the gaps and not to forget this one http://phpro.org/tutorials/Introduction-to-PHP-Regex.html which has a space after it. The script has been modifiied from its original so now it grabs ssl such as https://www.example.com/file.php also'; /** * * @get URLs from string (string maybe a url) * * @param string $string * * @return array * */ function getUrls($string) { $regex = '/https?\:\/\/[^\" ]+/i'; preg_match_all($regex, $string, $matches); return ($matches[0]); } $urls = getUrls($string); foreach($urls as $url) { echo $url.'<br />'; } ?>
×
×
  • 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.