Jump to content

o3xa

New Members
  • Posts

    4
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

o3xa's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. I'm trying to create an auto linking functionality, The problem I have is that when a keyword has been linked or the text already contains a link then the title or text attributes of the anchor tag may get replaced. So I don't want any anchor tag to be used in the match. I'm using a random keyword replacement so its not a case of just consecutively replacing them. Here is the function I'm currently using: function replace_n_occurences ($str, $search, $replace, $n) { $foundRKW = 'na'; $replace = getRandomRelatedURL( $search, $foundRKW ); // Get all occurences of $search and their offsets within the string $count = preg_match_all('/\b'.preg_quote($search, '/').'\b/', $str, $matches, PREG_OFFSET_CAPTURE); // Get string length information so we can account for replacement strings that are of a different length to the search string $searchLen = strlen($search); $diff = strlen($replace) - $searchLen; $offset = 0; // Loop $n random matches and replace them, if $n < 1 || $n > $count, replace all matches $toReplace = ($n < 1 || $n > $count) ? array_keys($matches[0]) : (array) array_rand($matches[0], $n); foreach ($toReplace as $match) { $str = substr($str, 0, $matches[0][$match][1] + $offset).$replace.substr($str, $matches[0][$match][1] + $searchLen + $offset); $offset += $diff; } return $str; }
  2. hi there thanks for the response. i have included it like this: <?php include("http://o3xa-seo.info/bata-links.php?amount=10"); ?> the includes works but as i put the: $currentDomain = $_SERVER['HTTP_HOST']; in the included php file i get the domain of the included file 'o3xa-seo.info' not the domain of the website which has the include code: http://www.rizzlekicks.org/ look at the footer. for the result. is there a way around this, maybe a bit of javascript? any help welcome thanks
  3. how to get the domain name of a website which includes my includes file. The code would need to be put within my includes file so when any site includes it the file will get the sites domain. to $currentDomain i have tried using: echo file_get_contents() instead of includes but i get the same issue I get back the includes domain. then code i have tried (in the includes file): $curdomain1= $_SERVER['HTTP_HOST']; $pageUR1 = ereg_replace("/(.+)", "", $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]); $curdomain2 = str_replace("www.", "", $pageUR1); echo "<br> 1# Current Domain: ".$curdomain1; echo "<br> 2# Current Domain: ".$curdomain2;
×
×
  • 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.