Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
36 kaklik 1
<?php
2
 
3
/*************************************************************
4
*  TorrentFlux - PHP Torrent Manager
5
*  www.torrentflux.com
6
**************************************************************/
7
/*
8
    This file is part of TorrentFlux.
9
 
10
    TorrentFlux is free software; you can redistribute it and/or modify
11
    it under the terms of the GNU General Public License as published by
12
    the Free Software Foundation; either version 2 of the License, or
13
    (at your option) any later version.
14
 
15
    TorrentFlux is distributed in the hope that it will be useful,
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
19
 
20
    You should have received a copy of the GNU General Public License
21
    along with TorrentFlux; if not, write to the Free Software
22
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
*/
24
 
25
include_once("config.php");
26
include_once("functions.php");
27
 
28
//****************************************************************************
29
// showIndex -- main view
30
function showIndex()
31
{
32
    global $cfg, $db;
33
 
34
    $hideChecked = "";
35
 
36
    if ($cfg["hide_offline"] == 1)
37
    {
38
        $hideChecked = "checked";
39
    }
40
 
41
    DisplayHead($cfg["user"]."'s "._PROFILE);
42
 
43
    echo "<div align=\"center\">";
44
    echo "<table border=1 bordercolor=\"".$cfg["table_admin_border"]."\" cellpadding=\"2\" cellspacing=\"0\" width=\"760\">";
45
    echo "<tr><td colspan=6 bgcolor=\"".$cfg["table_data_bg"]."\" background=\"themes/".$cfg["theme"]."/images/bar.gif\">";
46
    echo "<img src=\"images/properties.png\" width=18 height=13 border=0>&nbsp;&nbsp;<font class=\"title\">".$cfg["user"]."'s "._PROFILE."</font>";
47
    echo "</td></tr><tr><td align=\"center\">";
48
 
49
    $total_activity = GetActivityCount();
50
 
51
    $sql= "SELECT user_id, hits, last_visit, time_created, user_level FROM tf_users WHERE user_id=".$db->qstr($cfg["user"]);
52
    list($user_id, $hits, $last_visit, $time_created, $user_level) = $db->GetRow($sql);
53
 
54
    $user_type = _NORMALUSER;
55
    if (IsAdmin())
56
    {
57
        $user_type = _ADMINISTRATOR;
58
    }
59
    if (IsSuperAdmin())
60
    {
61
        $user_type = _SUPERADMIN;
62
    }
63
 
64
 
65
    $user_activity = GetActivityCount($cfg["user"]);
66
 
67
    if ($user_activity == 0)
68
    {
69
        $user_percent = 0;
70
    }
71
    else
72
    {
73
        $user_percent = number_format(($user_activity/$total_activity)*100);
74
    }
75
 
76
?>
77
 
78
    <table width="100%" border="0" cellpadding="3" cellspacing="0">
79
    <tr>
80
        <td width="50%" bgcolor="<?php echo $cfg["table_data_bg"] ?>" valign="top">
81
 
82
        <div align="center">
83
        <table border="0" cellpadding="0" cellspacing="0">
84
        <tr>
85
            <td align="right"><?php echo _JOINED ?>:&nbsp;</td>
86
            <td><strong><?php echo date(_DATETIMEFORMAT, $time_created) ?></strong></td>
87
        </tr>
88
        <tr>
89
            <td colspan="2" align="center">&nbsp;</td>
90
        </tr>
91
        <tr>
92
            <td align="right"><?php echo _UPLOADPARTICIPATION ?>:&nbsp;</td>
93
            <td>
94
                <table width="200" border="0" cellpadding="0" cellspacing="0">
95
                <tr>
96
                    <td background="themes/<?php echo $cfg["theme"] ?>/images/proglass.gif" width="<?php echo $user_percent*2 ?>"><img src="images/blank.gif" width="1" height="12" border="0"></td>
97
                    <td background="themes/<?php echo $cfg["theme"] ?>/images/noglass.gif" width="<?php echo (200 - ($user_percent*2)) ?>"><img src="images/blank.gif" width="1" height="12" border="0"></td>
98
                </tr>
99
                </table>
100
            </td>
101
        </tr>
102
        <tr>
103
            <td align="right"><?php echo _UPLOADS ?>:&nbsp;</td>
104
            <td><strong><?php echo $user_activity ?></strong></td>
105
        </tr>
106
        <tr>
107
            <td align="right"><?php echo _PERCENTPARTICIPATION ?>:&nbsp;</td>
108
            <td><strong><?php echo $user_percent ?>%</strong></td>
109
        </tr>
110
        <tr>
111
            <td colspan="2" align="center"><div align="center" class="tiny">(<?php echo _PARTICIPATIONSTATEMENT. " ".$cfg['days_to_keep']." "._DAYS ?>)</div><br></td>
112
        </tr>
113
        <tr>
114
            <td align="right"><?php echo _TOTALPAGEVIEWS ?>:&nbsp;</td>
115
            <td><strong><?php echo $hits ?></strong></td>
116
        </tr>
117
        <tr>
118
            <td align="right"><?php echo _USERTYPE ?>:&nbsp;</td>
119
            <td><strong><?php echo $user_type ?></strong></td>
120
        </tr>
121
        <tr>
122
            <td colspan="2" align="center">
123
                <table>
124
                    <tr>
125
                        <td align="center">
126
                            <BR />[ <a href="?op=showCookies">Cookie Management</a> ]
127
                        </td>
128
                    </tr>
129
                </table>
130
            </td>
131
        </tr>
132
        </table>
133
        </div>
134
 
135
        </td>
136
        <td valign="top">
137
        <div align="center">
138
        <table cellpadding="5" cellspacing="0" border="0">
139
        <form name="theForm" action="profile.php?op=updateProfile" method="post" onsubmit="return validateProfile()">
140
        <tr>
141
            <td align="right"><?php echo _USER ?>:</td>
142
            <td>
143
            <input readonly="true" type="Text" value="<?php echo $cfg["user"] ?>" size="15">
144
            </td>
145
        </tr>
146
        <tr>
147
            <td align="right"><?php echo _NEWPASSWORD ?>:</td>
148
            <td>
149
            <input name="pass1" type="Password" value="" size="15">
150
            </td>
151
        </tr>
152
        <tr>
153
            <td align="right"><?php echo _CONFIRMPASSWORD ?>:</td>
154
            <td>
155
            <input name="pass2" type="Password" value="" size="15">
156
            </td>
157
        </tr>
158
        <tr>
159
            <td align="right"><?php echo _THEME ?>:</td>
160
            <td>
161
            <select name="theme">
162
<?php
163
    $arThemes = GetThemes();
164
    for($inx = 0; $inx < sizeof($arThemes); $inx++)
165
    {
166
        $selected = "";
167
        if ($cfg["theme"] == $arThemes[$inx])
168
        {
169
            $selected = "selected";
170
        }
171
        echo "<option value=\"".$arThemes[$inx]."\" ".$selected.">".$arThemes[$inx]."</option>";
172
    }
173
?>
174
            </select>
175
            </td>
176
        </tr>
177
                <tr>
178
            <td align="right"><?php echo _LANGUAGE ?>:</td>
179
            <td>
180
            <select name="language">
181
<?php
182
    $arLanguage = GetLanguages();
183
    for($inx = 0; $inx < sizeof($arLanguage); $inx++)
184
    {
185
        $selected = "";
186
        if ($cfg["language_file"] == $arLanguage[$inx])
187
        {
188
            $selected = "selected";
189
        }
190
        echo "<option value=\"".$arLanguage[$inx]."\" ".$selected.">".GetLanguageFromFile($arLanguage[$inx])."</option>";
191
    }
192
?>
193
            </select>
194
            </td>
195
        </tr>
196
        <tr>
197
            <td colspan="2">
198
            <input name="hideOffline" type="Checkbox" value="1" <?php echo $hideChecked ?>> <?php echo _HIDEOFFLINEUSERS ?><br>
199
            </td>
200
        </tr>
201
        <tr>
202
            <td align="center" colspan="2">
203
            <input type="Submit" value="<?php echo _UPDATE ?>">
204
            </td>
205
        </tr>
206
        </form>
207
        </table>
208
        </div>
209
        </td>
210
    </tr>
211
    </table>
212
 
213
 
214
    <script language="JavaScript">
215
    function validateProfile()
216
    {
217
        var msg = ""
218
        if (theForm.pass1.value != "" || theForm.pass2.value != "")
219
        {
220
            if (theForm.pass1.value.length <= 5 || theForm.pass2.value.length <= 5)
221
            {
222
                msg = msg + "* <?php echo _PASSWORDLENGTH ?>\n";
223
                theForm.pass1.focus();
224
            }
225
            if (theForm.pass1.value != theForm.pass2.value)
226
            {
227
                msg = msg + "* <?php echo _PASSWORDNOTMATCH ?>\n";
228
                theForm.pass1.value = "";
229
                theForm.pass2.value = "";
230
                theForm.pass1.focus();
231
            }
232
        }
233
 
234
        if (msg != "")
235
        {
236
            alert("<?php echo _PLEASECHECKFOLLOWING ?>:\n\n" + msg);
237
            return false;
238
        }
239
        else
240
        {
241
            return true;
242
        }
243
    }
244
    </script>
245
 
246
<?php
247
    echo "</td></tr>";
248
    echo "</table></div><br><br>";
249
 
250
    DisplayFoot();
251
}
252
 
253
 
254
//****************************************************************************
255
// updateProfile -- update profile
256
function updateProfile($pass1, $pass2, $hideOffline, $theme, $language)
257
{
258
    Global $cfg;
259
 
260
    if ($pass1 != "")
261
    {
262
        $_SESSION['user'] = md5($cfg["pagetitle"]);
263
    }
264
 
265
    UpdateUserProfile($cfg["user"], $pass1, $hideOffline, $theme, $language);
266
 
267
    DisplayHead($cfg["user"]."'s "._PROFILE);
268
 
269
    echo "<div align=\"center\">";
270
    echo "<table border=1 bordercolor=\"".$cfg["table_admin_border"]."\" cellpadding=\"2\" cellspacing=\"0\" bgcolor=\"".$cfg["table_data_bg"]."\" width=\"760\">";
271
    echo "<tr><td colspan=6 background=\"themes/".$cfg["theme"]."/images/bar.gif\">";
272
    echo "<img src=\"images/properties.png\" width=18 height=13 border=0>&nbsp;&nbsp;<font class=\"title\">".$cfg["user"]."'s "._PROFILE."</font>";
273
    echo "</td></tr><tr><td align=\"center\">";
274
?>
275
    <br>
276
    <?php echo _PROFILEUPDATEDFOR." ".$cfg["user"] ?>
277
    <br><br>
278
<?php
279
    echo "</td></tr>";
280
    echo "</table></div><br><br>";
281
 
282
    DisplayFoot();
283
}
284
 
285
 
286
//****************************************************************************
287
// ShowCookies -- show cookies for user
288
function ShowCookies()
289
{
290
    global $cfg, $db;
291
    DisplayHead($cfg["user"] . "'s "._PROFILE);
292
 
293
    $cid = $_GET["cid"]; // Cookie ID
294
 
295
    // Used for when editing a cookie
296
    $hostvalue = $datavalue = "";
297
    if( !empty( $cid ) )
298
    {
299
        // Get cookie information from database
300
        $cookie = getCookie( $cid );
301
        $hostvalue = " value=\"" . $cookie['host'] . "\"";
302
        $datavalue = " value=\"" . $cookie['data'] . "\"";
303
    }
304
 
305
?>
306
<SCRIPT LANGUAGE="JavaScript">
307
    <!-- Begin
308
    function popUp(name_file) 
309
    {
310
        window.open (name_file,'help','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=800,height=600')
311
    }
312
    // End -->
313
</script>
314
<div align="center">[<a href="?">Return to Profile</a>]</div>
315
<br />
316
<div align="center">
317
    <form action="?op=<?php echo ( !empty( $cid ) ) ? "modCookie" : "addCookie"; ?>"" method="post">
318
    <input type="hidden" name="cid" value="<?php echo $cid;?>" />
319
    <table border="1" bordercolor="<?php echo $cfg["table_admin_border"];?>" cellpadding="2" cellspacing="0" bgcolor="<?php echo $cfg["table_data_bg"];?>">
320
        <tr>
321
            <td colspan="3" bgcolor="<?php echo $cfg["table_header_bg"];?>" background="themes/<? echo $cfg["theme"] ?>/images/bar.gif">
322
                <img src="images/properties.png" width=18 height=13 border=0 align="absbottom">&nbsp;<font class="title">Cookie Management</font>
323
            </td>
324
        </tr>
325
        <tr>
326
            <td width="80" align="right">&nbsp;Host:</td>
327
            <td>
328
                <input type="Text" size="50" maxlength="255" name="host"<?php echo $hostvalue;?>><BR />
329
            </td>
330
            <td>
331
                www.host.com
332
            </td>
333
        </tr>
334
        <tr>
335
            <td width="80" align="right">&nbsp;Data:</td>
336
            <td>
337
                <input type="Text" size="50" maxlength="255" name="data"<?php echo $datavalue;?>><BR />
338
            </td>
339
            <td>
340
                uid=123456;pass=a1b2c3d4e5f6g7h8i9j1
341
            </td>
342
        </tr>
343
        <tr>
344
            <td>&nbsp;</td>
345
            <td colspan="2">
346
                <input type="Submit" value="<?php echo ( !empty( $cid ) ) ? _UPDATE : "Add"; ?>">
347
            </td>
348
        </tr>
349
<?php
350
    // We are editing a cookie, so have a link back to cookie list
351
    if( !empty( $cid ) )
352
    {
353
?>
354
        <tr>
355
            <td colspan="3">
356
                <center>[ <a href="?op=editCookies">back</a> ]</center>
357
            </td>
358
        </tr>
359
<?php
360
    }
361
    else
362
    {
363
?>
364
        <tr>
365
            <td colspan="3">
366
                <table border="1" bordercolor="<?php echo $cfg["table_admin_border"];?>" cellpadding="2" cellspacing="0" bgcolor="<?php echo $cfg["table_data_bg"];?>" width="100%">
367
                    <tr>
368
                        <td style="font-weight: bold; padding-left: 3px;" width="50">Action</td>
369
                        <td style="font-weight: bold; padding-left: 3px;">Host</td>
370
                        <td style="font-weight: bold; padding-left: 3px;">Data</td>
371
                    </tr>
372
<?php
373
        // Output the list of cookies in the database
374
        $sql = "SELECT c.cid, c.host, c.data FROM tf_cookies AS c, tf_users AS u WHERE u.uid=c.uid AND u.user_id='" . $cfg["user"] . "'";
375
        $dat = $db->GetAll( $sql );
376
        if( empty( $dat ) )
377
        {
378
?>
379
                <tr>
380
                    <td colspan="3">No cookie entries exist.</td>
381
                </tr>
382
<?php
383
        }
384
        else
385
        {
386
            foreach( $dat as $cookie )
387
            {
388
?>
389
                    <tr>
390
                        <td>
391
                            <a href="?op=deleteCookie&cid=<?php echo $cookie["cid"];?>"><img src="images/delete_on.gif" width=16 height=16 border=0 title="<?php echo _DELETE . " " . $cookie["host"]; ?>" align="absmiddle"></a>
392
                            <a href="?op=editCookies&cid=<?php echo $cookie["cid"];?>"><img src="images/properties.png" width=18 height=13 border=0 title="<?php echo _EDIT . " " . $cookie["host"]; ?>" align="absmiddle"></a>
393
                        </td>
394
                        <td><?php echo $cookie["host"];?></td>
395
                        <td><?php echo $cookie["data"];?></td>
396
                    </tr>
397
<?php
398
            }
399
        }
400
?>
401
                </table>
402
            </td>
403
        </tr>
404
<?php    
405
    }
406
?>
407
        <tr>
408
            <td colspan="3">
409
                <br>
410
                <div align="center">
411
                <A HREF="javascript:popUp('cookiehelp.php')">How to get cookie information....</A>
412
                </div>
413
            </td>
414
        </tr>
415
        </table>
416
        </form>
417
    </div>
418
    <br />
419
    <br />
420
    <br />
421
<?php
422
    DisplayFoot();
423
}
424
 
425
//****************************************************************************
426
// addCookie -- adding a Cookie Host Information
427
//****************************************************************************
428
function addCookie( $newCookie )
429
{
430
    if( !empty( $newCookie ) )
431
    {
432
        global $cfg; 
433
        AddCookieInfo( $newCookie );
434
        AuditAction( $cfg["constants"]["admin"], "New Cookie: " . $newCookie["host"] . " | " . $newCookie["data"] );
435
    }
436
    header( "location: profile.php?op=showCookies" );
437
}
438
 
439
//****************************************************************************
440
// deleteCookie -- delete a Cookie Host Information
441
//****************************************************************************
442
function deleteCookie($cid)
443
{
444
    global $cfg;
445
    $cookie = getCookie( $cid );
446
    deleteCookieInfo( $cid );
447
    AuditAction( $cfg["constants"]["admin"], _DELETE . " Cookie: " . $cookie["host"] );
448
    header( "location: profile.php?op=showCookies" );
449
}
450
 
451
//****************************************************************************
452
// modCookie -- edit a Cookie Host Information
453
//****************************************************************************
454
function modCookie($cid,$newCookie)
455
{
456
    global $cfg;
457
    modCookieInfo($cid,$newCookie);
458
    AuditAction($cfg["constants"]["admin"], "Modified Cookie: ".$newCookie["host"]." | ".$newCookie["data"]);
459
    header("location: profile.php?op=showCookies");
460
}
461
 
462
//****************************************************************************
463
//****************************************************************************
464
//****************************************************************************
465
//****************************************************************************
466
// TRAFFIC CONTROLER
467
$op = getRequestVar('op');
468
 
469
switch ($op)
470
{
471
 
472
    default:
473
        showIndex();
474
        exit;
475
    break;
476
 
477
    case "updateProfile":
478
        $pass1 = getRequestVar('pass1');
479
        $pass2 = getRequestVar('pass2');
480
        $hideOffline = getRequestVar('hideOffline');
481
        $theme = getRequestVar('theme');
482
        $language = getRequestVar('language');
483
 
484
        updateProfile($pass1, $pass2, $hideOffline, $theme, $language);
485
    break;
486
 
487
    // Show main Cookie Management
488
    case "showCookies": 
489
    case "editCookies":
490
        showCookies();
491
    break;
492
 
493
    // Add a new cookie to user
494
    case "addCookie":
495
        $newCookie["host"] = getRequestVar('host');
496
        $newCookie["data"] = getRequestVar('data');
497
        addCookie( $newCookie );
498
    break;
499
 
500
    // Modify an existing cookie from user
501
    case "modCookie":
502
        $newCookie["host"] = getRequestVar( 'host' );
503
        $newCookie["data"] = getRequestVar( 'data' );
504
        $cid = getRequestVar( 'cid' );
505
        modCookie( $cid, $newCookie );
506
    break;
507
 
508
    // Delete selected cookie from user
509
    case "deleteCookie":
510
        $cid = $_GET["cid"];
511
        deleteCookie( $cid );
512
    break;
513
 
514
}
515
//****************************************************************************
516
//****************************************************************************
517
//****************************************************************************
518
//****************************************************************************
519
 
520
?>