-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
182 lines (163 loc) · 5.62 KB
/
functions.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
<?php
//Import Database Info
include('database.php');
//View Count
function viewed($id)
{
$row = mysql_fetch_array(mysql_query("SELECT views FROM posts WHERE id=$id"));
$views=$row[0]+1;
mysql_query("UPDATE posts SET views=$views WHERE id=$id");
}
//Get Site options informations
function get_detail($num,$type,$output)
{
if($type=='podax')
{
$podax = mysql_fetch_array(mysql_query("SELECT * FROM podax WHERE id=0"));
switch ($output) {
case 'echo':
echo $podax[$num];
break;
case 'return':
return $podax[$num];
break;
default:
return "Error";
break;
}
}
if($type=='options')
{
$options = mysql_fetch_array(mysql_query("SELECT * FROM options WHERE id=0"));
switch ($output) {
case 'echo':
echo $options[$num];
break;
case 'return':
return $options[$num];
break;
default:
return "Error";
break;
}
}
elseif ($type=='users')
{
$users = mysql_fetch_array(mysql_query("SELECT * FROM users WHERE id=1"));
switch ($output) {
case 'echo':
echo $users[$num];
break;
case 'return':
return $users[$num];
break;
default:
return "Error";
break;
}
}
elseif ($type=='info')
{
@$id=$_GET['id'];
if(!isset($id))
{
$row = mysql_fetch_array(mysql_query("SELECT * FROM posts ORDER BY id DESC LIMIT 1;"));
switch ($output) {
case 'echo':
echo $row[$num];
break;
case 'return':
return $row[$num];
break;
default:
return "Error";
break;
}
}
else
{
$row = mysql_fetch_array(mysql_query("SELECT * FROM posts WHERE id=$id"));
switch ($output) {
case 'echo':
echo $row[$num];
break;
case 'return':
return $row[$num];
break;
default:
return "Error";
break;
}
}
}
}
//View, Options and Ajax
if (isset($_GET['action']))
{@$action=$_GET['action'];}
else
{@$action=$_POST['action'];}
if ($action=="like")
{
$id=$_POST['id'];
$likes=$_POST['likes'];
$do=$_POST['do'];
if ($do=="like")
{$likes++;}
elseif ($do=="unlike")
{$likes;}
mysql_query("UPDATE posts SET like_count=$likes WHERE id=$id");
echo $likes;
}
elseif ($action=="play")
{
$id = $_POST['id'];
$row = mysql_fetch_array(mysql_query("SELECT play_count FROM posts WHERE id=$id"));
$play_count=$row[0]+1;
mysql_query("UPDATE posts SET play_count=$play_count WHERE id=$id");
echo $play_count;
}
elseif ($action=="download")
{
$id = $_GET['id'];
$file = $_GET['file'];
$row = mysql_fetch_array(mysql_query("SELECT dl_count FROM posts WHERE id=$id"));
$dl_count=$row[0]+1;
mysql_query("UPDATE posts SET dl_count=$dl_count WHERE id=$id");
header ("Content-type: octet/stream");
header ("Content-disposition: attachment; filename=".$file.";");
header ("Content-Length: ".filesize($file));
readfile($file);
exit;
}
//Get Size of Num
function get_size($link)
{
$rootaddr= $_SERVER["DOCUMENT_ROOT"]
. substr(substr(__FILE__, strlen(realpath($_SERVER['DOCUMENT_ROOT']))), 0, - strlen(basename(__FILE__)));
@$size=round(filesize($rootaddr.$link)/1000000,1);
if ($size)
{echo get_lang(3,'return') . " (" . $size . get_lang(13,'return') . ")";}
else
{echo "Error";}
}
//Get Language Info and Style
include("langs/".get_detail(6,'options','return').".php");
function get_rtl()
{if (get_detail(6,'options','return')=='fa-ir')
{echo '<link rel="stylesheet" type="text/css" href="styles/rtl.css">';}
}
//get archive links
function get_archive($withlast=NULL)
{
if ($withlast)
{$lastst=0;}
else
{$lastst=1;}
$temprow = mysql_fetch_array(mysql_query("SELECT id FROM posts ORDER BY id DESC LIMIT 1;"));
for ($i=$temprow[0]-$lastst;$i>=1;$i--)
{
$row = mysql_fetch_array(mysql_query("SELECT * FROM posts WHERE id=$i"));
echo '<li>' . '<a href="'.get_detail(3,'options','return').'index.php?id='. $row[0] .'"> '.get_lang(11,'return').' '. $row[0] .': '. $row[1] .'</a></li>';
}
}
?>