Toon posts:

[PHP] Probleem......

Pagina: 1
Acties:
  • 41 views sinds 30-01-2008

Verwijderd

Topicstarter
Ik wil graag op mijn forum [spam] ook eDonkey links kunnen plaatsen, wat moet ik aanpassen zodat hij ook ed2k:// links accepteert zodat wanneer ik een url post bv. ed2k://file.download.com dat deze ook actief wordt wanneer ik dat nu doe, zet hij er automatisch http:// voor en dat wil ik niet.

Bedankt voor uw tijd alvast.
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    while (preg_match("/\\[url\](.+?)\\[\/url\]/si", $message, $matches)) {

        $searchfor = $matches[1];
        $replace = $searchfor;
        $replace = trim($replace);  // remove all leading and trailing whitespaces
        if (!stristr($replace,"http://")) {
            if (!stristr($replace,"https://")) {
                $replace = "http://".$replace;
            } else {
                $replace = stristr($replace,"https://");
            }
        } else {
            $replace = stristr($replace,"http://");
        }
        $message = str_replace("[url]".$searchfor."[/url]","{url}".$replace."{/url}",$message);
      $message = str_replace("[URL]".$searchfor."[/URL]","{URL}".$replace."{/URL}",$message);

 }

    $message = str_replace("{url}","[url]",$message);
    $message = str_replace("{/url}","[/url]",$message);
    $message = str_replace("{URL}","[URL]",$message);
    $message = str_replace("{/URL}","[/URL]",$message);

    while (preg_match("/\[url=(.+?)\](.+?)\\[\/url\]/si", $message, $matches)) {

        $searchfor = $matches[1];
        $replace = $searchfor;
        $replace = trim($replace);  // remove all leading and trailing whitespaces
        if (!stristr($replace,"http://")) {
            if (!stristr($replace,"https://")) {
                $replace = "http://".$replace;
            } else {
                $replace = stristr($replace,"https://");
            }
        } else {
            $replace = stristr($replace,"http://");
        }
        $message = str_replace("[url=".$searchfor."]".$matches[2]."[/url]","{url=".$replace."]".$matches[2]."{/url}",$message);
      $message = str_replace("[URL=".$searchfor."]".$matches[2]."[/URL]","{URL=".$replace."]".$matches[2]."{/URL}",$message);

    }

    $message = str_replace("{url=","[url=",$message);
    $message = str_replace("{/url}","[/url]",$message);
    $message = str_replace("{URL=","[URL=",$message);
    $message = str_replace("{/URL}","[/URL]",$message);

    // Now the [iurl]'s

    while (preg_match("/\\[iurl\](.+?)\\[\/iurl\]/si", $message, $matches)) {

        $searchfor = $matches[1];
        $replace = $searchfor;
        $replace = trim($replace);  // remove all leading and trailing whitespaces
        if (!stristr($replace,"http://")) {
            if (!stristr($replace,"https://")) {
                $replace = "http://".$replace;
            } else {
                $replace = stristr($replace,"https://");
            }
        } else {
            $replace = stristr($replace,"http://");
        }
        $message = str_replace("[iurl]".$searchfor."[/iurl]","{iurl}".$replace."{/iurl}",$message);
       $message = str_replace("[IURL]".$searchfor."[/IURL]","{IURL}".$replace."{/IURL}",$message);

    }

    $message = str_replace("{iurl}","[iurl]",$message);
    $message = str_replace("{/iurl}","[/iurl]",$message);
    $message = str_replace("{IURL}","[IURL]",$message);
    $message = str_replace("{/IURL}","[/IURL]",$message);

    while (preg_match("/\[iurl=(.+?)\](.+?)\\[\/iurl\]/si", $message, $matches)) {

        $searchfor = $matches[1];
        $replace = $searchfor;
        $replace = trim($replace);  // remove all leading and trailing whitespaces
        if (!stristr($replace,"http://")) {
            if (!stristr($replace,"https://")) {
                $replace = "http://".$replace;
            } else {
                $replace = stristr($replace,"https://");
            }
        } else {
            $replace = stristr($replace,"http://");
        }
        $message = str_replace("[iurl=".$searchfor."]".$matches[2]."[/iurl]","{iurl=".$replace."]".$matches[2]."{/iurl}",$message);
      $message = str_replace("[IURL=".$searchfor."]".$matches[2]."[/IURL]","{IURL=".$replace."]".$matches[2]."{/IURL}",$message);

    }

    $message = str_replace("{iurl=","[iurl=",$message);
    $message = str_replace("{/iurl}","[/iurl]",$message);
    $message = str_replace("{IURL=","[IURL=",$message);
    $message = str_replace("{/IURL}","[/IURL]",$message);

  • djc
  • Registratie: December 2001
  • Laatst online: 08-09-2025

djc

Maak een nieuwe UBB tag, [ed2k]blahblah[/ed2k] ofzow?

Rustacean


  • D2k
  • Registratie: Januari 2001
  • Laatst online: 31-08 10:19

D2k

leer php/regexen
zie: [topic=397053/1/100]

Doet iets met Cloud (MS/IBM)


Dit topic is gesloten.