function tearDown()
  {
    parent :: tearDown();

    $user =& user :: instance();
    $user->logout();
  }
  function run(&$filter_chain, &$request, &$response) 
  {
    debug :: add_timing_point('locale filter started');
    
    if(!$node = map_request_to_node($request))
    {
    	define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID);
    	define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID);
    	
    	$locale =& locale :: instance();    	
    	$locale->setlocale();
    	
      $filter_chain->next();
      return;
    }
          
    if($object_locale_id = site_object :: get_locale_by_id($node['object_id']))
    	define('CONTENT_LOCALE_ID', $object_locale_id);
    else
      define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID);
    
    $user = user :: instance();
    if($user_locale_id = $user->get_locale_id())
    	define('MANAGEMENT_LOCALE_ID', $user_locale_id);
    else
      define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID);
              
    debug :: add_timing_point('locale filter finished');

  	$locale =& locale :: instance();    	
  	$locale->setlocale();
    
    $filter_chain->next();
  }   
 function _login_user($id, $groups)
 {
 	$user =& user :: instance();
 	
 	$user->_set_id($id);
 	$user->_set_groups($groups);  	
 }  
Ejemplo n.º 4
0
 function tearDown()
 {
     $this->_clean_up();
     $user =& user::instance();
     $user->logout();
     $this->object->tally();
 }
Ejemplo n.º 5
0
 function write($log_file_data, $string)
 {
     $log_dir = $log_file_data[0];
     $log_name = $log_file_data[1];
     $file_name = $log_dir . $log_name;
     if (!is_dir($log_dir)) {
         fs::mkdir($log_dir, 0775, true);
     }
     $oldumask = @umask(0);
     $file_existed = @file_exists($file_name);
     $log_file = @fopen($file_name, 'a');
     if ($log_file) {
         $time = strftime("%b %d %Y %H:%M:%S", strtotime('now'));
         $notice = '[ ' . $time . " ]\n";
         $user =& user::instance();
         if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
             $notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] ';
         }
         $notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n";
         @fwrite($log_file, $notice);
         @fclose($log_file);
         if (!$file_existed) {
             @chmod($file_name, 0664);
         }
         @umask($oldumask);
         $result = true;
     } else {
         @umask($oldumask);
         $result = false;
         debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false);
     }
     return $result;
 }
 function _valid_perform(&$request, &$response)
 {
     $login = $this->dataspace->get('login');
     $password = $this->dataspace->get('password');
     $locale_id = $this->dataspace->get('locale_id');
     $autologin = $this->dataspace->get('autologin');
     $user_object =& site_object_factory::create($this->user_object_class_name);
     if ($user_object->login($login, $password, $locale_id)) {
         if ($autologin) {
             $user =& user::instance();
             $user->configure_autologin();
         }
         $request->set_status(REQUEST_STATUS_FORM_SUBMITTED);
         if ($redirect = $this->dataspace->get('redirect')) {
             $this->_login_redirect($redirect, $response);
             return;
         } elseif (isset($_SERVER['HTTP_REFERER']) && strpos(strtolower($_SERVER['HTTP_REFERER']), '/root/login') === false) {
             $response->redirect($_SERVER['HTTP_REFERER']);
             return;
         } else {
             $response->redirect('/');
             return;
         }
     }
     $request->set_status(REQUEST_STATUS_FAILURE);
 }
Ejemplo n.º 7
0
 function _login_to_chat($nickname)
 {
     $db =& db_factory::instance();
     $time = time();
     $sql = "SELECT id, nickname FROM chat_user";
     $db->sql_exec($sql);
     $chat_users = $db->get_array('id');
     $user =& user::instance();
     if ($user->is_logged_in()) {
         foreach ($chat_users as $data) {
             if ($data['nickname'] == $nickname) {
                 session::set('chat_user_id', $data['id']);
                 $sql = "UPDATE chat_user \r\n\t\t\t\t\t\t\t\t\tSET time={$time},\r\n\t\t\t\t\t\t\t\t\thost= '{$_SERVER['REMOTE_ADDR']}',\r\n\t\t\t\t\t\t\t\t\tdeleted=0\r\n\t\t\t\t\t\t\t\t  WHERE id={$data['id']}";
                 $db->sql_exec($sql);
                 return $data['id'];
             }
         }
     } else {
         foreach ($chat_users as $data) {
             if ($data['nickname'] == $nickname) {
                 return false;
             }
         }
     }
     $sql = "INSERT INTO chat_user (nickname, time, host, deleted) \r\n\t\t\t\t\t  values ('{$nickname}', {$time}, '{$_SERVER['REMOTE_ADDR']}', 0)";
     $db->sql_exec($sql);
     $id = $db->get_sql_insert_id();
     chat_user::_set_session_chat_user_id($id);
     return true;
 }
 function _init_dataspace()
 {
     $data['identifier'] = md5(rand());
     $user =& user::instance();
     $data['sender'] = $user->get_login();
     $data['sender_email'] = $user->get_email();
     $this->dataspace->import($data);
 }
 function _update_log($node_id, $action, $status_code)
 {
     $ip_register =& $this->_get_ip_register();
     $referer_register =& $this->_get_referer_register();
     $uri_register =& $this->_get_uri_register();
     $user =& user::instance();
     $this->db->sql_insert('sys_stat_log', array('ip' => $ip_register->get_client_ip(), 'time' => $this->get_register_time_stamp(), 'node_id' => $node_id, 'stat_referer_id' => $referer_register->get_referer_page_id(), 'stat_uri_id' => $uri_register->get_uri_id(), 'user_id' => $user->get_id(), 'session_id' => session_id(), 'action' => $action, 'status' => $status_code));
 }
  function _changing_own_password()
  {
    $object_data = $this->_load_object_data();

    $user =& user :: instance();

    return ($object_data['id'] == $user->get_id()) ? true : false;
  }
Ejemplo n.º 11
0
 function test_user_in_groups()
 {
     $user =& user::instance();
     $user->login('vasa', 1);
     $this->assertTrue($user->is_in_groups(array(0 => 'members', 'admins')));
     $this->assertFalse($user->is_in_groups(array(0 => 'members', 'operators')));
     $this->assertFalse($user->is_in_groups(array(0 => 'members')));
     $this->assertTrue($user->is_in_groups(array(0 => 'visitors')));
 }
 function _init_dataspace()
 {
     $user =& user::instance();
     if (!$user->is_logged_in()) {
         return;
     }
     $data = array('name' => $user->get_name() . ' ' . $user->get_lastname(), 'email' => $user->get_email());
     $this->dataspace->import($data);
 }
 function _valid_perform()
 {
     $locale_id = $this->dataspace->get('locale_id');
     if (!locale::is_valid_locale_id($locale_id)) {
         return new close_popup_response(RESPONSE_STATUS_FAILURE);
     }
     $user =& user::instance();
     $user->set_locale_id($locale_id);
     return new close_popup_response(RESPONSE_STATUS_SUCCESS);
 }
 function _init_dataspace(&$request)
 {
     parent::_init_dataspace($request);
     $data = $this->dataspace->export();
     $user =& user::instance();
     if (empty($data['comment_author'])) {
         $data['comment_author'] = $user->get_login();
     }
     if (empty($data['comment_author_email'])) {
         $data['comment_author_email'] = $user->get_email();
     }
     $this->dataspace->import($data);
 }
Ejemplo n.º 15
0
 function run(&$filter_chain, &$request, &$response)
 {
     debug::add_timing_point('jip filter started');
     $fetcher =& fetcher::instance();
     $fetcher->set_jip_status(false);
     $user =& user::instance();
     if ($user->is_logged_in()) {
         $ini =& get_ini('jip_groups.ini');
         if ($user->is_in_groups(array_keys($ini->get_group('groups')))) {
             $fetcher->set_jip_status(true);
         }
     }
     debug::add_timing_point('jip filter done');
     $filter_chain->next();
 }
 function _valid_perform(&$request, &$response)
 {
     $locale_id = $this->dataspace->get('locale_id');
     if ($request->has_attribute('popup')) {
         $response->write(close_popup_response($request));
     } elseif (isset($_SERVER['HTTP_REFERER'])) {
         $response->redirect($_SERVER['HTTP_REFERER']);
     } else {
         $response->redirect('/');
     }
     if (!locale::is_valid_locale_id($locale_id)) {
         $request->set_status(REQUEST_STATUS_FAILURE);
     }
     $user =& user::instance();
     $user->set_locale_id($locale_id);
     $request->set_status(REQUEST_STATUS_SUCCESS);
 }
Ejemplo n.º 17
0
 function login($login, $password)
 {
     $this->_delete_cookie();
     $user_ip = ip::encode_ip(sys::client_ip());
     $sid = md5(uniqid($user_ip));
     session::set('phpbb_sid', $sid);
     $user =& user::instance();
     $phpbb_user_data = array();
     $phpbb_user_data['session_user_id'] = $user->get_id();
     $phpbb_user_data['session_id'] = $sid;
     $phpbb_user_data['session_ip'] = $user_ip;
     $phpbb_user_data['session_logged_in'] = 1;
     $phpbb_user_data['session_start'] = time();
     $phpbb_user_data['session_time'] = time();
     $db_table =& db_table_factory::create('phpbb_sessions');
     return $db_table->insert($phpbb_user_data);
 }
Ejemplo n.º 18
0
    if (defined("ERROR_DOCUMENT_404")) {
        reload(ERROR_DOCUMENT_404);
    } else {
        header("HTTP/1.1 404 Not found");
    }
    exit;
}
if (isset($node['only_parent_found']) && $node['only_parent_found']) {
    if (isset($_REQUEST['action'])) {
        $params = '?action=' . $_REQUEST['action'];
    }
    $tree = tree::instance();
    reload($tree->get_path_to_node($node) . $params);
    exit;
}
$user =& user::instance();
if (($object_data =& fetch_one_by_node_id($node['id'], false)) === false) {
    if (!$user->is_logged_in()) {
        $tree = tree::instance();
        $response = new response();
        $stats_register->register(-1, '', $response->get_status());
        $response = new response();
        $stats_register->register(-1, 'redirect', $response->get_status());
        reload('/root/login?redirect=' . $tree->get_path_to_node($node));
        exit;
    } else {
        debug::write_error('content object not allowed or retrieved', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__);
        ob_end_clean();
        if (debug::is_console_enabled()) {
            echo debug::parse_html_console();
        }
 function run(&$filter_chain, &$request, &$response)
 {
     $user =& user::instance();
     $user->try_autologin();
     $filter_chain->next();
 }
Ejemplo n.º 20
0
function _session_write($session_id, $value)
{
  $db =& db_factory :: instance();

  $user =& user :: instance();

  $user_id = $user->get_id();

  $db->sql_select('sys_session', 'session_id', array('session_id' => $session_id));

  if($db->fetch_row())
    $db->sql_update('sys_session',
                    array(
                       'last_activity_time'=> time(),
                       'session_data' => "{$value}",
                       'user_id' => "{$user_id}"),
                    array(
                       'session_id' => "{$session_id}"));
  else
    $db->sql_insert('sys_session',
                      array(
                        'last_activity_time' => time(),
                        'session_data' => "{$value}",
                        'user_id' => "{$user_id}",
                        'session_id' => "{$session_id}"));
}
Ejemplo n.º 21
0
 function _send_mail($description, $verbosity_level)
 {
     $title = '';
     $headers = array();
     switch ($verbosity_level) {
         case DEBUG_LEVEL_NOTICE:
             $title .= ' debug notice';
             $headers['X-Priority'] = '0 (Low)';
             break;
         case DEBUG_LEVEL_WARNING:
             $title .= ' debug warning';
             break;
         case DEBUG_LEVEL_ERROR:
             $title .= ' debug error';
             $headers['X-Priority'] = '1 (High)';
             break;
         case DEBUG_TIMING_POINT:
             $title .= ' timig point';
             break;
     }
     $message = '';
     $user =& user::instance();
     if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
         $message .= "user id:\t" . "{$user_id}\n" . "login:\t\t" . $user->get_login() . "\n" . "e-mail:\t\t" . $user->get_email() . "\n";
     }
     $message .= "ip:\t\t" . sys::client_ip() . "\n" . "request:\t" . REQUEST_URI . "\n" . "description:\n" . $description;
     send_plain_mail(array(DEVELOPER_EMAIL), $_SERVER['SERVER_ADMIN'] . '<' . $_SERVER['HTTP_HOST'] . '> ', $title, $message, $headers);
 }
  function count_accessible_children($node)
  {
    $id = $this->_get_id_lazy($node);

    $user =& user :: instance();

    $this->_use_cache_key(array('count_accessible_children',
                                $id,
                                $user->get_id(),
                                $user->get_groups()),
                          CACHE_REGISTRY_TREE_ACCESSIBLE_GROUP);

    return $this->_cache_callback('count_accessible_children', array($node));
  }
Ejemplo n.º 23
0
 function _send_mail($debug_info)
 {
     include_once LIMB_DIR . '/core/lib/mail/mail.inc.php';
     $title = '';
     $description = debug::_parse_text_debug_info($debug_info);
     $verbosity_level = $debug_info['level'];
     switch ($verbosity_level) {
         case DEBUG_LEVEL_NOTICE:
             $title .= ' debug notice';
             break;
         case DEBUG_LEVEL_WARNING:
             $title .= ' debug warning';
             break;
         case DEBUG_LEVEL_ERROR:
             $title .= ' debug error';
             break;
         case DEBUG_TIMING_POINT:
             $title .= ' timig point';
             break;
     }
     $message = '';
     $user =& user::instance();
     if (($user_id = $user->get_id()) != DEFAULT_USER_ID) {
         $message .= "user id:\t" . "{$user_id}\n" . "login:\t\t" . $user->get_login() . "\n" . "e-mail:\t\t" . $user->get_email() . "\n";
     }
     $message .= "ip:\t\t" . sys::client_ip() . "\n" . "request:\t" . $_SERVER['REQUEST_URI'] . "\n" . "description:\n" . $description;
     if (sys::exec_mode() == 'cli') {
         send_plain_mail(array(DEVELOPER_EMAIL), 'cli', $title, $message);
     } else {
         send_plain_mail(array(DEVELOPER_EMAIL), $_SERVER['SERVER_ADMIN'] . '<' . $_SERVER['HTTP_HOST'] . '> ', $title, $message);
     }
 }
  function _check_sys_site_object_record()
  {
    $user =& user :: instance();

    $this->db->sql_select('sys_site_object', '*', 'id=' . $this->object->get_id());
    $record = $this->db->fetch_row();
    $this->assertEqual($record['identifier'], $this->object->get_identifier());
    $this->assertEqual($record['title'], $this->object->get_title());
    $this->assertEqual($record['current_version'], $this->object->get_version());
    $this->assertFalse(!$record['class_id']);
    $this->assertEqual($record['creator_id'], $user->get_id());
    $this->assertTrue((time() - $record['created_date']) <= 60, 'create time is not valid');
    $this->assertTrue((time() - $record['modified_date']) <= 60, 'modified time is not valid');
  }
	function get_accessor_ids()
	{
		$accessor_ids = array();
		
		$user =& user :: instance();
		
		if(($user_id = $user->get_id()) != DEFAULT_USER_ID)
			$accessor_ids[] = $user_id;
			
		foreach(array_keys($user->get_groups()) as $group_id)	
			$accessor_ids[] = $group_id;
		
		return $accessor_ids;	
	}
  function _check_sys_object_version_record()
	{
		$conditions['object_id'] = $this->object->get_id();
		$conditions['version'] = $this->object->get_version();
		
  	$this->db->sql_select('sys_object_version', '*', $conditions);
  	$record = $this->db->fetch_row();
  	
  	$user =& user :: instance();
  	
  	$this->assertEqual($record['object_id'], $this->object->get_id());
  	$this->assertEqual($record['version'], $this->object->get_version());
  	$this->assertEqual($record['creator_id'], $user->get_id());
	}	
 function &_get_user()
 {
     return user::instance();
 }
 function _create_version_record()
 {
     $version_db_table =& db_table_factory::instance('sys_object_version');
     $time = time();
     $user =& user::instance();
     $data['object_id'] = $this->get_id();
     $data['version'] = $this->get_version();
     $data['created_date'] = $time;
     $data['modified_date'] = $time;
     $data['creator_id'] = $user->get_id();
     $version_db_table->insert($data);
     return true;
 }
Ejemplo n.º 29
0
 function logout()
 {
     $user =& user::instance();
     return $user->logout();
 }
Ejemplo n.º 30
0
  function _create_site_object_record()
  {
    $this->set_attribute('version', 1);

    $user =& user :: instance();

    $data['identifier'] = $this->get_identifier();
    $data['title'] = $this->get_title();
    $data['class_id'] = $this->get_class_id();
    $data['current_version'] = $this->get_version();
    $data['creator_id'] = $user->get_id();
    $data['status'] = $this->get_attribute('status', 0);
    $data['controller_id'] = $this->get_attribute('controller_id');

    $created_date = $this->get_attribute('created_date', 0);
    $modified_date = $this->get_attribute('modified_date', 0);
    $time = time();

    if(!$created_date)
      $data['created_date'] = $time;
    else
      $data['created_date'] = $created_date;

    if(!$modified_date)
      $data['modified_date'] = $time;
    else
      $data['modified_date'] = $modified_date;

    if ($this->get_attribute('locale_id'))
      $data['locale_id'] = $this->get_attribute('locale_id');
    else
      $data['locale_id'] = $this->_get_parent_locale_id();

    $sys_site_object_db_table =& db_table_factory :: instance('sys_site_object');

    $sys_site_object_db_table->insert($data);

    return $sys_site_object_db_table->get_last_insert_id();
  }