Witam,
jak zrobic automatyczne tworzenie linkow al'a phpbb3 bo jakos nie moge nic wymyslic;
adres http://www.twojadomena.pl/index.php badz bez http:// albo www. aby zmienil sie w <a href="adres">adres</a>
pomozecie?
<?php function bbcode_autolink($str) { $lnk=$str[0]; $l = 15; } else { $l=15; } } return ' <a href="'.$str[0].'" target="_blank">'.$lnk.'</a>'; } //BBcode function bbcode($zmien) { return $zmien; } ?>
<?php class link_catcher{ var $message; function link_catcher($string) { $array = $this->catch_link($string); for($i=0; $i<count($array); $i++) { $array[$i][1] = $array[$i][0]; $url = $array[$i][0]; $db = new database; $db->dblink(); $tiny = $this->generate_tiny(5); $url = "http://".$url; $rec = $db->get_rec("tiny_url", "tiny, url, id", "url = '{$url}'"); if($rec->url == $url) { $array[$i][1] = root_domain."/url/".$rec->tiny; //updating an expire date $db->db_update("tiny_url","expires = {$expires}","id = {$rec->id}"); }else{ if ($rec = $db->get_rec("tiny_url", "id,tiny, expires", "tiny = '{$tiny}'")) { //update an existing record $db->db_update("tiny_url","url = '{$url}', expires = {$expires}","id = {$rec->id}"); }else{ //generating another tiny $tiny = $this->generate_tiny(5); } }else{ $id = $db->db_insert("tiny_url", "url, tiny, author_id, expires","'{$url}', '{$tiny}', {$_SESSION['user']->id}, {$expires} "); $i=0; while(!$id&&$i<100) { $tiny = $this->generate_tiny(5); $id = $db->db_insert("tiny_url", "url, tiny, author_id, expires","'{$url}', '{$tiny}', {$_SESSION['user']->id}, {$expires} "); $i++; } } $tiny_url = root_domain."/url/".$tiny ; $array[$i][1] = $tiny_url; } }else{ //urls witch are longer than 255 will be cut to the main domain. $domain = "http://".$short[1]."/"; $array[$i][1] = $domain; } //echo($string); // echo("robie {$i} tiny urla z: {$array[$i][0]} na: {$array[$i][1]}<br />{$string}"); } } //echo $this->message; /*echo("<pre>"); print_r($array); echo("</pre>");*/ } ?>
<?php function make_seed() { return ((float)$sec+(float)$usec) * 100000; } function make_clickable($string) { $res = "<a href=\"".$string."\" target=\"_blank\">".$string."</a>"; else $res = "<a href=\"http://".$string."\" target=\"_blank\">".$string."</a>"; return $res; } function generate_tiny($length) { $possible_characters = "abcdefghijkmnopqrstuvwxyz1234567890"; $string = ""; } return $string; } function catch_link($string) { preg_match_all("/(ftp://|http://|https://|www.|ftp.)(w+:{0,1}w*@)?(S+)(:[0-9]+)?(/|/([w#!:.?+=&%@!-/]))?/", $string, $array, PREG_SET_ORDER); $result = $array; return $result; } }; ?>