C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webboard\admin\update.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
<?php
/* $Id: update.php,v 1.2 2002/11/06 22:44:12 pbaecher Exp $ */
/*
          phpInstaller - PHP Script Installer
        ==============================================
            (c) 2002 by
               Paul Baecher         <paul@thewall.de>

          This  program is  free  software;  you can
          redistribute it and/or modify it under the
          terms of the GNU General Public License as
          published by the Free Software Foundation;
          either  version 2 of  the License,  or (at
          your option) any later version.

        ==============================================
*/
require('install_functions.php');

include 
'../inc/config.inc.php';

mysql_connect($mysql_h, $mysql_u, $mysql_p);
mysql_select_db($mysql_db);

if( !
$pref )
{
    
$pref = 'thwb_';
}

$r_registry = thwb_query("SELECT keyvalue FROM $pref"."registry WHERE keyname='version'");
list(
$version) = mysql_fetch_row($r_registry);
$version = (float)($version);

if( 
$version < 2.8 )
{
    
$r_user = thwb_query("SELECT userpassword FROM $pref"."user WHERE username='$l_username' AND userlevel=1");
}
else
{
    
$r_user = thwb_query("SELECT userpassword FROM $pref"."user WHERE username='$l_username' AND userisadmin=1");
}
if( 
mysql_num_rows($r_user) )
{
    
$user = mysql_fetch_array($r_user);
    if( 
$user['userpassword'] != md5($l_userpassword) )
    {
        
$action = 'login';
    }
}
else
{
    
$action = 'login';
}

switch(
$action)
{
    case 
'login':
        
p_header();
        
p_loginform();
        
p_footer('welcome');
        break;

    case 
'startupdate':
        include 
$scriptname;
        
$update = new CUpdate;

        
$update->Prefix = $pref;
        if( !
$update->AllowUpdate() )
        {
            
p_errormsg(lng('error'),
                
lng('cantexec'));
        }
        
        if( 
$update->RunUpdate() )
        {
            
p_errormsg(lng('error'),
                
$update->GetError());
        }
        else
        {
            
p_errormsg(lng('updatesuccess'),
                
lng('updatesuccesstxt'));
        }
        
        break;

    case 
'update':
        
$scriptname = 'updates/'.$scriptname;
        if( !
file_exists($scriptname) || !$scriptname )
        {
            
p_errormsg(lng('error'), lng('notfound'));
        }
        else
        {
            include 
$scriptname;
            
            
$update = new CUpdate;
            
            
$update->Prefix = $pref;
            if( 
$update->UpdaterVer > $cfg['updater_ver'] )
            {
                
p_errormsg(lng('error'), lng('tooold'));
            }
            else
            {
                
p_header();
                
p_updateinfo($update);
                
p_footer('startupdate', array(
                    
'scriptname' => $scriptname,
                    
'l_username' => $l_username,
                    
'l_userpassword' => $l_userpassword
                
));
            }
        }
        break;

    case 
'welcome':
    default:
        
$a_file = array();
        
$dp = opendir('updates/'); 
        while( 
$file = readdir($dp) )
        {
            if( 
substr($file, -7, 7) == '.update' )
            {
                
$a_file[] = $file;
            }
        }

        
natsort($a_file);
        
p_header();
        
p_updatewelcome($a_file);
        
p_footer('update', array(
            
'l_username' => $l_username,
            
'l_userpassword' => $l_userpassword
        
));
        break;
}
?>