-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.php
193 lines (153 loc) · 8.02 KB
/
util.php
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<?php
include 'config.php';
function upd_log($link, $query)
{
global $eol;
$result = mysqli_query($link, $query);
if (!$result) {
wlog("E!: ".mysqli_error($link).$eol.$query.$eol,true);
$result = -1;
}
else { $result = mysqli_affected_rows($link); }
return $result;
}
function ins($link, $query)
{
global $eol;
$result = mysqli_query($link, $query);
if (!$result) {
wlog("E!: ".mysqli_error($link).$eol.$query.$eol,true);
$result = -1;
}
else { $result = mysqli_insert_id($link); }
return $result;
}
function upd($link, $table_name, $id_name, $old_id, $new_id)
{
global $eol;
$query = "update `".$table_name."` set ow_id=".$new_id." where `".$id_name."` = ".$old_id;
$result = mysqli_query($link, $query);
if (!$result) {
wlog("E!: ".mysqli_error($link),true);
}
return $result;
}
function wlog($logstr, $onScreen = false) {
global $LOG_FILE_NAME;
global $eol;
$filename = $LOG_FILE_NAME;
$lfile = fopen($filename,'a+');
$logstr = PHP_EOL."[".date("Ymd H:i:s").'] '.$logstr;
fputs($lfile,$logstr);
fflush($lfile);
fclose($lfile);
if ($onScreen) {
echo $logstr.$eol;
}
}
function bbcode_to_html($bbtext){
$bbtags = array(
'[heading1]' => '<h1>','[/heading1]' => '</h1>',
'[heading2]' => '<h2>','[/heading2]' => '</h2>',
'[heading3]' => '<h3>','[/heading3]' => '</h3>',
'[h1]' => '<h1>','[/h1]' => '</h1>',
'[h2]' => '<h2>','[/h2]' => '</h2>',
'[h3]' => '<h3>','[/h3]' => '</h3>',
'[hide]' => '<span>','[/hide]' => '</span>',
'[sub]' => '<sub>','[/sub]' => '</sub>',
'[sup]' => '<sup>','[/sup]' => '</sup>',
'[s]' => '<s>','[/s]' => '</s>',
//' <!-- s -->' => '<s>','[/s]' => '</s>',
'[paragraph]' => '<p>','[/paragraph]' => '</p>',
'[para]' => '<p>','[/para]' => '</p>',
'[p]' => '<p>','[/p]' => '</p>',
'[left]' => '<p style="text-align:left;">','[/left]' => '</p>',
'[right]' => '<p style="text-align:right;">','[/right]' => '</p>',
'[center]' => '<p style="text-align:center;">','[/center]' => '</p>',
'[justify]' => '<p style="text-align:justify;">','[/justify]' => '</p>',
'[bold]' => '<span style="font-weight:bold;">','[/bold]' => '</span>',
'[italic]' => '<span style="font-weight:bold;">','[/italic]' => '</span>',
'[underline]' => '<span style="text-decoration:underline;">','[/underline]' => '</span>',
'[b]' => '<span style="font-weight:bold;">','[/b]' => '</span>',
'[i]' => '<span style="font-weight:bold;">','[/i]' => '</span>',
'[u]' => '<span style="text-decoration:underline;">','[/u]' => '</span>',
'[break]' => '<br>',
'[br]' => '<br>',
'[newline]' => '<br>',
'[nl]' => '<br>',
'[unordered_list]' => '<ul>','[/unordered_list]' => '</ul>',
'[ulist]' => '<ul>','[/ul]' => '</ul>',
'[list]' => '<ul>','[/list]' => '</ul>',
'[ul]' => '<ul>','[/ul]' => '</ul>',
'[ordered_list]' => '<ol>','[/ordered_list]' => '</ol>',
'[ol]' => '<ol>','[/ol]' => '</ol>',
'[list_item]' => '<li>','[/list_item]' => '</li>',
'[li]' => '<li>','[/li]' => '</li>',
'[*]' => '<li>','[/*]' => '</li>',
'[code]' => '<code>','[/code]' => '</code>',
'[preformatted]' => '<pre>','[/preformatted]' => '</pre>',
'[pre]' => '<pre>','[/pre]' => '</pre>',
);
$bbtext = str_ireplace(array_keys($bbtags), array_values($bbtags), $bbtext);
$bbextended = array(
"/\[url=https?:\/\/www\.youtube\.com\/watch\?v=(.*?)\](.*?)\[\/url\]/i" => "<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", // youtube
"/\https:\/\/www\.youtube\.com\/watch\?v=(.*?)\](.*?)/i" => "<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/$1\" frameborder=\"0\" allowfullscreen></iframe>", //youtube
"/\[youtube:(.*?)\]http:\/\/www\.youtube\.com\/watch\?v=(.*?)\[\/youtube(.*?)\]/i" => "<iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/$2\" frameborder=\"0\" allowfullscreen></iframe>", //youtube
"/\[imdb:(.*?)\](.*?)\[\/imdb:(.*?)\]/i" => "<a href=\"http://www.imdb.com/title/tt$2\ target=\"_blank\">IMDB Link</a><br>", //imdb
"/\[imdb\](.*?),(.*?)\[\/imdb\]/i" => "<a href=\"http://www.imdb.com/title/tt$1\" target=\"_blank\">IMDB Link</a><br><iframe width=\"420\" height=\"315\" src=\"//www.youtube.com/embed/$2\" frameborder=\"0\" allowfullscreen></iframe>", //imdb
"/\[quote\]\[cite\] (.*?):\[\/cite\](.*)\[\/quote\]/m" => "<blockquote class=\"ow_quote\"><span class=\"ow_quote_header\"><span class=\"ow_author\">Quote from <b>$1</b></span></span><span class=\"ow_quote_cont_wrap\"><span class=\"ow_quote_cont\">$2</span></span></blockquote>",
"/\[quote author=\"(.*?)\"\](.*?)\[\/quote\]/m" => "<blockquote class=\"ow_quote\"><span class=\"ow_quote_header\"><span class=\"ow_author\">Quote from <b>$1</b></span></span><span class=\"ow_quote_cont_wrap\"><span class=\"ow_quote_cont\">$2</span></span></blockquote>",
"/\[quote author=(.*?) link=(.*?)\](.*?)\[\/quote\]/m" => "<blockquote class=\"ow_quote\"><span class=\"ow_quote_header\"><span class=\"ow_author\">Quote from <b>$1</b></span></span><span class=\"ow_quote_cont_wrap\"><span class=\"ow_quote_cont\">$3</span></span></blockquote>",
"/<blockquote><cite>Posted By: (.*?)<\/cite>(.*?)<\/blockquote>/i" => "<blockquote class=\"ow_quote\"><span class=\"ow_quote_header\"><span class=\"ow_author\">Quote from <b>$1</b></span></span><span class=\"ow_quote_cont_wrap\"><span class=\"ow_quote_cont\">$2</span></span></blockquote>",
"/\[url](.*?)\[\/url\]/i" => "<a href=\"http://$1\" title=\"$1\" target=\"_blank\">$1</a>",
"/\[url=(.*?)\](.*?)\[\/url\]/i" => "<a href=\"$1\" title=\"$1\">$2</a>",
//"/\[color=white\](.*?)\[\/color\]/i" => "<span style=\"color:black\">$1</span>",
"/\[color=(.*?)\](.*?)\[\/color\]/i" => "<span style=\"color:$1\">$2</span>",
"/\[email=(.*?)\](.*?)\[\/email\]/i" => "<a href=\"mailto:$1\">$2</a>",
"/\[mail=(.*?)\](.*?)\[\/mail\]/i" => "<a href=\"mailto:$1\">$2</a>",
"/<img alt=\"(.*?)\" class=\"smiley\" src=\"(.*?)\"><\/img>/i" => " $1 ",
"/\[img\]([^[]*)\[\/img\]/i" => "<img src=\"$1\" alt=\" \" />",
"/\[image\]([^[]*)\[\/image\]/i" => "<img src=\"$1\" alt=\" \" />",
"/\[image_left\]([^[]*)\[\/image_left\]/i" => "<img src=\"$1\" alt=\" \" class=\"img_left\" />",
"/\[image_right\]([^[]*)\[\/image_right\]/i" => "<img src=\"$1\" alt=\" \" class=\"img_right\" />",
'/[\r\n]/i' => '<br />',
);
foreach($bbextended as $match=>$replacement){
$bbtext = preg_replace($match, $replacement, $bbtext);
}
// Modificari suplimentare la text:
/* Daca include:
+ [img]LINK[/img] --> <span><img style="padding:5px;max-width:100%" src="LINK" /></span>
+ [url=LINK][/url] --> <span class="ow_ws_link"><a rel="nofollow" href="LINK target="_blank">LINK</a></span>
+ [url=LINK]NAME[/url] --> <span class="ow_ws_link"><a rel="nofollow" href="LINK target="_blank">NAME</a></span>
+ [quote][cite]USER:[/cite]text[/quote]
+ [quote author=USER link=... date=...]text[/quote]
+ [quote author="USER" link=... date=...]text[/quote]
+ <blockquote><cite>Posted By: USER</cite>TEXT</blockquote>
+ <img alt=":P" class="smiley" src="/extensions/Smile/IPB2.2/tongue.gif"></img>
+ [imdb]0486946,zSvwmgWCJ2s[/imdb] --> http://www.imdb.com/title/tt0486946/, http://www.youtube.com/watch?v=zSvwmgWCJ2s
+ [b]TEXT[/b]
+ [u]TEXT[/u]
+ [i]TEXT[/i]
+ [s]TEXT[/s]
+ [color]TEXT[/color]
+ [sup][/sup]
+ [sub][/sub]
+ [ulist]
+ [*]
+ [/ulist]
+ [hide][/hide] -
+ [move][/move] -
+ [youtube:COD]YOUTUBE[/youtube] --> YOUTUBE
+ [url=http://www.youtube.com/watch?v=QrxPuk0JefA#]Camera falls from airplane and lands in pig pen--MUST WATCH END!![/url]
+ <iframe width="420" height="315" src="//www.youtube.com/embed/QrxPuk0JefA" frameborder="0" allowfullscreen></iframe>
+ */
return $bbtext;
}
function markOxWall($arr) {
//$markArray[] = array($modSettings['maxMsgID'], $user_info['id'], $topic);
foreach ($arr as $line) {
$ret = getValue($link, "SELECT markOxWall(".$line[1].", ".$line[2].", ".$line[0].")");
}
}
?>