public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
tedkulp (author)
Fri Sep 28 18:59:24 -0700 2007
commit  2ac84f829ec8db7308df01104d5aec0b3fc7bc89
tree    0d65db8be1653e6cc427400e508c64011bda19e7
parent  87714706b395ca34e4677bc66bbda63b5088bcb1
cmsmadesimple-2-0 / admin / login.php
100644 121 lines (99 sloc) 3.239 kb
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
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy@users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#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.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#$Id$
 
$CMS_ADMIN_PAGE=1;
 
require_once('../include.php');
 
$error = '';
 
if (isset($_SESSION['logout_user_now']))
{
  unset($_SESSION['login_user_username']);
  unset($_SESSION['logout_user_now']);
  unset($_SESSION['cms_admin_username']);
  unset($_SESSION['cmsms_user_id']);
  CmsLogin::logout();
}
 
if (isset($_POST['logincancel']))
{
  //redirect(CmsConfig::get('root_url') . '/index.php', true);
}
 
$username = '';
if (isset($_POST['username'])) $username = CmsRequest::clean_value($_POST['username']);
 
if (isset($_POST['username']) && isset($_POST['password'])) {
 
  $password = '';
  if (isset($_POST['password'])) $password = $_POST['password'];
 
  if ($username != '' && $password != '' && isset($_POST['loginsubmit']))
  {
    if (CmsLogin::login($username, $password))
    {
      // redirect to upgrade if db_schema it's old
      $current_version = $CMS_SCHEMA_VERSION;
  
      $query = 'SELECT version from '.cms_db_prefix().'version';
      $row = cms_db()->GetRow($query);
      if ($row) $current_version = $row['version'];
 
      if ($current_version < $CMS_SCHEMA_VERSION)
      {
        CmsResponse::redirect(CmsConfig::get('root_url') . '/install/upgrade.php');
      }
      // end of version check
 
      if (isset($_SESSION['redirect_url']))
      {
        $tmp = $_SESSION['redirect_url'];
        unset($_SESSION['redirect_url']);
        CmsResponse::redirect($tmp);
      }
      else
      {
        redirect(CmsConfig::get('root_url') . '/' . CmsConfig::get('admin_dir') . '/index.php', true);
      }
    }
    else
    {
      $error .= lang('usernameincorrect');
    }
  }
  else
  {
    $error .= lang('usernameincorrect');
  }
}
 
CmsAdminTheme::start(true);
 
$themeObject = CmsAdminTheme::get_instance(true);
 
cmsms()->variables['admintheme'] =& $themeObject;
 
$smarty = cms_smarty();
 
$smarty->assign('base_url', CmsConfig::get('root_url') . '/' . CmsConfig::get('admin_dir') . '/');
$smarty->assign('username_text', lang('username'));
$smarty->assign('password_text', lang('password'));
$smarty->assign('logintitle_text', lang('logintitle'));
$smarty->assign('loginprompt_text', lang('loginprompt'));
 
$smarty->assign('submit_text', lang('submit'));
$smarty->assign('cancel_text', lang('cancel'));
 
$smarty->assign('username', $username);
$smarty->assign('error', $error);
 
$smarty->display($themeObject->theme_template_dir . 'login.tpl');
 
?>
 
<?php
if (CmsConfig::get('debug'))
{
  foreach ($gCms->errors as $globalerror)
  {
    echo $globalerror;
  }
}
# vim:ts=4 sw=4 noet
?>