Esempio n. 1
0
 public static function display($args)
 {
     cc_admin_include('cc-users.php');
     Users::bootstrap();
     if (Users::isValid()) {
         //var_dump(self::$plugin->pluginPublicDir());
         cc_redirect(self::$plugin->pluginPublicDir() . "browser/");
     } else {
         cc_redirect(TH_PUB_ROOT);
     }
 }
Esempio n. 2
0
 public static function display()
 {
     if (!is_numeric($_GET['id'])) {
         cc_redirect(Admin::link('users'));
     }
     if ($_POST['cc_form'] == 'edit-group') {
         $id = $_GET['id'];
         $previous = (array) unserialize(urldecode($_POST['previous']));
         $group = $_POST['group'];
         $permissions = (array) $_POST['permissions'];
         $new = array_merge($previous, $permissions);
         foreach ($new as $k => $v) {
             if ($v == "1") {
                 $new[$k] = true;
             }
             if (!array_key_exists($k, $permissions)) {
                 $new[$k] = false;
             }
         }
         if (DB::update('users', array('name', 'data'), array($group, serialize(filter('admin_edit_group_data', array('permissions' => $new)))), array('users_id = ?', $id))) {
             $message = Message::success(__('admin', 'group-information-updated'));
         } else {
             $message = Message::error(__('admin', 'database-error'));
         }
     }
     $p = Permissions::getAll();
     $g = new Group((int) $_GET['id']);
     $p_form = new Form('');
     $p_form->setCC_Form('edit-group');
     $p_form->startFieldset(__('admin', 'group-information'));
     $p_form->addInput(__('admin', 'group-name'), 'text', 'group', $g->getName());
     $p_form->endFieldset();
     $p_form->addHTML(sprintf("<h3>%s</h3>", __('admin', 'permissions')));
     $p_table = new Table('permissions');
     $p_table->addHeader(array('Name', 'Allowed'));
     foreach ($p as $k => $v) {
         $previous[$v['name']] = $g->isAllowed($v['name']);
         $p_table->addRow(array(__('permissions', $v['name']), sprintf('<input type="checkbox" name="permissions[%s]"%svalue="1"/>', $v['name'], $g->isAllowed($v['name']) ? ' checked="checked"' : '')));
     }
     $p_form->addHidden('previous', urlencode(serialize($previous)));
     $p_form->addHTML($p_table->html());
     $p_form->addSubmit('', 'save-permissions', __('admin', 'save-changes'));
     return array(sprintf('%s: %s', __('admin', 'edit-group'), $g->getName()), $message . $p_form->html());
 }
Esempio n. 3
0
 public static function display()
 {
     $id = $_GET['id'];
     if (!is_numeric($id)) {
         $r = self::invalidIdError();
         i18n::restore();
         cc_redirect(Admin::link('content'));
         return array('Error', $r);
     }
     $pageInfo = Database::select('content', '*', array('content_id = ?', $id));
     $row = $pageInfo->fetch(PDO::FETCH_ASSOC);
     if (!$row) {
         $r = self::invalidIdError();
         i18n::restore();
         cc_redirect(Admin::link('content'));
         return $r;
     }
     $row['settings'] = unserialize($row['settings']);
     self::$row = $row;
     return Content::nodeDisplay('edit_display', $row['type'], $row);
 }
Esempio n. 4
0
 public static function display()
 {
     if (array_key_exists('action', $_GET) && !empty($_GET['name'])) {
         if ($_GET['action'] == 'disable') {
             DB::update('plugins', array('active' => '0'), null, array('name = ?', $_GET['name']));
         }
         if ($_GET['action'] == 'enable') {
             $smt = DB::select('plugins', '*', array('name = ?', $_GET['name']));
             $row = $smt->fetch(PDO::FETCH_ASSOC);
             if ($row === false) {
                 DB::insert('plugins', array('name' => $_GET['name'], 'info' => serialize(array()), 'active' => '1'));
             } else {
                 DB::update('plugins', array('active' => '1'), null, array('name = ?', $_GET['name']));
             }
         }
         cc_redirect(Admin::link('plugins'));
     }
     $arr = array();
     $r = sprintf("\n\t\t\t<table id='plugins-table' cellspacing='0' cellpadding='0'>\n\t\t\t\t<thead>\n\t\t\t\t\t<th>%s</th><th>%s</th><th class='en-di-col'> </th>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>", __('admin', 'plugin-name'), __('admin', 'plugin-desc'));
     foreach (Plugins::getBootedInfo() as $val) {
         $arr[] = array(array($val['name'], $val['dir'], $val['name'], $val['desc'], $val['author'], $val['version']), true);
         $arr2[] = $val['dir'];
     }
     foreach (Plugins::getActiveInfo() as $val) {
         if (array_search($val['dir'], $arr2) === false) {
             $arr[] = array(array($val['name'], $val['dir'], $val['name'], $val['desc'], $val['author'], $val['version']), false);
         }
     }
     usort($arr, 'PluginAdminPage::pluginSort');
     foreach ($arr as $val) {
         if ($val[1] == true) {
             $r .= sprintf("<tr class='enabled'><td>%s %s<span class='byline'>by %s</span></td><td>%s</td><td>%s (<a href='%s'>%s</a>)</td></tr>", $val[0][2], $val[0][5], $val[0][4], $val[0][3], __('admin', 'currently-enabled'), Admin::link('plugins', array('action' => 'disable', 'name' => $val[0][1])), __('admin', 'disable'));
         } else {
             $r .= sprintf("<tr class='disabled'><td>%s %s<span class='byline'>by %s</span></td><td>%s</td><td>%s (<a href='%s'>%s</a>)</td></tr>", $val[0][2], $val[0][5], $val[0][4], $val[0][3], __('admin', 'currently-disabled'), Admin::link('plugins', array('action' => 'enable', 'name' => $val[0][1])), __('admin', 'enable'));
         }
     }
     $r .= "</tbody></table>";
     return array(__('admin', 'plugins'), $r);
 }
Esempio n. 5
0
 public static function display()
 {
     $type = $_GET['type'];
     $types = Content::contentTypes();
     if (array_key_exists($type, $types) === false && array_key_exists($_POST['type'], $types) === false) {
         $opt_list = array();
         foreach ($types as $single_type => $class) {
             $opt_list[$single_type] = call_user_func($class . '::name');
         }
         $form = new Form('self', 'post', 'add_node_1');
         $form->addSelectList(__('admin', 'content-type'), 'type', $opt_list, true, 'page');
         $form->addSubmit('', 'continue', __('admin', 'continue'));
         return array(__('admin', 'add-page'), $form->endAndGetHTML());
     }
     if (!$type && $_POST['type']) {
         if (array_key_exists('continue', $_POST)) {
             cc_redirect(Admin::link($_GET['page'], array('type' => $_POST['type'])));
         } else {
             return;
         }
     }
     AdminSidebar::registerForPage('content/create-page', 'EditPage::fileUploadBlock');
     return Content::nodeDisplay('create_display', $type, array());
 }
Esempio n. 6
0
 public static function loginHandle()
 {
     if (check_post('cc_login_uname', 'cc_login_passwd', 'cc_login_login')) {
         // for security, we don't want session fixation :(
         session_regenerate_id();
         $_SESSION['uname'] = $_POST['cc_login_uname'];
         $_SESSION['pword'] = hash('whirlpool', $_POST['cc_login_passwd']);
         $_SESSION['last_ip'] = $_SERVER['REMOTE_ADDR'];
         $_SESSION['last_user_agent'] = $_SERVER['HTTP_USER_AGENT'];
         if (self::checkSession()) {
             //var_dump(TH_PUB_ADMIN);exit();
             if ($_POST['cc_login_remember'] == "yes") {
                 $host = $_SERVER['HTTP_HOST'];
                 if (substr($host, 0, 4) == "www.") {
                     $host = substr($host, 3);
                 }
                 setcookie('ln', self::packCookie(), time() + 60 * 60 * 24 * 30 * 12);
             }
             cc_redirect(TH_PUB_ADMIN, true);
         } else {
             Filters::bind('post_output_login', 'Users::outputError');
         }
     }
 }
Esempio n. 7
0
// forms
cc_core_include('cc-forms.php');
cc_core_include('cc-table.php');
cc_core_include('cc-icons.php');
cc_core_include('cc-image.php');
cc_core_include('cc-uploadify.php');
// utf-8 utils
cc_core_include('cc-utf8.php');
// loggin utils
cc_core_include('cc-log.php');
// include redirection utils
cc_core_include('cc-redirect.php');
// have we installed yet? this checks if $database and $timezone are set in the CC_CONFIG file.
define('INSTALLED', isset($database) && isset($timezone));
if (!INSTALLED) {
    cc_redirect('cc-admin/install/', true);
}
// the all important db abstraction layer
cc_core_include('cc-database.php');
// get the validation methods
cc_core_include('cc-validate.php');
// setup settings manager
cc_core_include('cc-settings.php');
// i18n is important!
cc_core_include('cc-i18n.php');
cc_core_include('cc-editors.php');
cc_core_include('cc-users.php');
// setup plugin architecture
cc_core_include('cc-plugins.php');
// let some things run (pulling settings, etc) before we go on to pull the page info
plugin('system_ready');
Esempio n. 8
0
 /**
  * Logs the user out.
  */
 public static function logout()
 {
     Users::logout();
     cc_redirect(TH_PUB_ROOT);
     exit;
 }
Esempio n. 9
0
 public static function display()
 {
     $id = $_GET['id'];
     if (!is_numeric($id)) {
         i18n::restore();
         cc_redirect(Admin::link('users'));
         return 'redirected.';
     }
     $messages = "";
     if ($_POST['cc_form'] === 'edit-user') {
         $username = $_POST['name'];
         $password = $_POST['password'];
         $cpassword = $_POST['confirm-password'];
         $group = $_POST['group'];
         if ($password != $cpassword) {
             $messages .= Message::error(__('admin', 'passwords-dont-match'));
         } else {
             $result = Database::select('users', '*', array('users_id = ?', $id));
             $row = $result->fetch(PDO::FETCH_ASSOC);
             $result = Database::select('users', '*', array('name = ?', $username));
             if (!empty($result)) {
                 $userRow = $result->fetch(PDO::FETCH_ASSOC);
             } else {
                 $result = false;
             }
             if ($result && $userRow['name'] == $username && $id != $userRow['id']) {
                 $messages .= Message::error(__('admin', 'username-in-use'));
             } else {
                 if (!empty($password) && !empty($cpassword) && $password == $cpassword) {
                     $hash = hash('whirlpool', $password);
                 } else {
                     $hash = $row['value'];
                 }
                 $data = unserialize($row['data']);
                 $result = Database::update('users', array('name' => filter('admin_edit_user_username', $username), 'value' => $hash, 'type' => 'user', 'group' => filter('admin_edit_group', $group), 'data' => serialize(filter('admin_edit_user_data', $data))), null, array('id = ?', $id));
                 if ($result === 1) {
                     $messages .= Message::success(__('admin', 'user-updated'));
                 }
             }
         }
     }
     $result = Database::select('users', '*', array('users_id = ?', $id));
     if (empty($result)) {
         i18n::restore();
         cc_redirect(Admin::link('users'));
     }
     self::$row = $result->fetch(PDO::FETCH_ASSOC);
     $form = new Form('self', 'post', 'edit-user');
     $groups = Users::allGroups();
     foreach ($groups as $key => $value) {
         $groups[$value->getId()] = $value->getName();
     }
     $form->startFieldset(__("admin", 'user-information'));
     $form->addInput(__('admin', 'username'), 'text', 'name', self::get('name'));
     $form->addInput(__('admin', 'password'), 'password', 'password');
     $form->addInput(__('admin', 'confirm-password'), 'password', 'confirm-password');
     $form->addSelectList(__('admin', 'group'), 'group', $groups, true, self::get('group'));
     plugin('admin_edit_user_custom_fields', array(&$form));
     $form->addSubmit('', 'edit-user', __('admin', 'edit-user'));
     $form->endFieldset();
     plugin('admin_edit_user_custom_fieldset', array(&$form));
     $form = $form->endAndGetHTML();
     return array(sprintf("%s: %s", __('admin', 'edit-user'), self::get('name')), $messages . $form);
 }