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)) { dir::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"; if ($user_id = user::get_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 error($description, $error_place = '', $params = array()) { if (defined('DEVELOPER_ENVIROMENT')) { trigger_error('error', E_USER_WARNING); echo $description . '<br>' . $error_place . '<br><pre>'; print_r($params); echo '</pre>'; } debug::write_error($description, $error_place, $params); rollback_user_transaction(); if (debug::is_console_enabled()) { echo debug::parse_html_console(); } else { $message = ''; if ($user_id = user::get_id()) { $message .= "user id:\t{$user_id}\nlogin:\t\t" . user::get_login() . "\ne-mail:\t\t" . user::get_email() . "\n"; } $message .= "ip:\t\t" . sys::client_ip() . "\nrequest:\t" . REQUEST_URI . "\nerror:\t\t{$title}\ndescription:\t{$msg}"; $mail = new mime_mail(); $mail->set_body($message); $mail->build_message(); $mail->send('developer', DEVELOPER_EMAIL, '', WEBSITE_EMAIL, $_SERVER['HTTP_HOST'] . ' internal error!'); } ob_end_flush(); exit; }
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(); $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 test_login_true() { $this->assertTrue(user::login('vasa', '1')); $this->assertTrue(user::login('sasa', '1')); $this->assertTrue(user::is_logged_in()); $this->assertEqual(user::get_id(), 2); $this->assertEqual(user::get_node_id(), 3); $this->assertEqual(user::get_login(), 'sasa'); }
function _create_version_record() { $version_db_table =& db_table_factory::instance('sys_object_version'); $time = time(); $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; }
function _get_groups() { $db =& db_factory::instance(); $sql = 'SELECT sso.*, tn.* FROM sys_site_object as sso, user_group as tn, user_in_group as u_i_g WHERE sso.id=tn.object_id AND sso.current_version=tn.version AND u_i_g.user_id=' . user::get_id() . ' AND u_i_g.group_id=sso.id'; $db->sql_exec($sql); return $db->get_array(); }
function login($login, $password) { $this->_delete_cookie(); $user_ip = sys::client_ip(true); $sid = md5(uniqid($user_ip)); session::set('phpbb_sid', $sid); $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); }
function change_password() { if (!($user_id = $this->get_id())) { debug::write_error('user id not set', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); return false; } if (!($identifier = $this->get_identifier())) { debug::write_error('user identifier not set', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); return false; } $this->set_attribute('password', user::get_crypted_password($identifier, $this->get_attribute('password'))); if ($user_id == user::get_id()) { user::logout(); message_box::write_warning(strings::get('need_relogin', 'user')); } else { session::destroy_user_session($user_id); } return $this->update(false); }
function _create_site_object_record() { $this->set_attribute('version', 1); $time = time(); $data['identifier'] = $this->get_identifier(); $data['title'] = $this->get_title(); $data['class_id'] = $this->get_class_id(); $data['current_version'] = $this->get_attribute('version'); $data['created_date'] = $time; $data['modified_date'] = $time; $data['creator_id'] = user::get_id(); $data['status'] = $this->get_attribute('status', 0); 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(); }
function get_accessor_ids() { $accessor_ids = array(); if ($user_id = user::get_id()) { $accessor_ids[] = $user_id; } foreach (array_keys(user::get_groups()) as $group_id) { $accessor_ids[] = $group_id; } return $accessor_ids; }
* * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ ob_start(); require_once '../setup.php'; require_once 'chat_setup.php'; require_once 'smiles.php'; require_once LIMB_DIR . 'core/lib/session/session.class.php'; start_user_session(); $template_vars = array(); $view = file_get_contents(DESIGN_DIR . 'chat/chat.html'); if (user::get_id()) { $user_data = fetch_one_by_node_id(user::get_node_id()); chat_login($user_data['identifier'], $user_data['chat_color']); } if (!session::get('chat_user_id')) { $template_vars['enter_div_display'] = 'none'; $template_vars['message_div_display'] = 'block'; } else { $template_vars['enter_div_display'] = 'block'; $template_vars['message_div_display'] = 'none'; } foreach ($template_vars as $key => $value) { $view = str_replace("<!--<<{$key}>>-->", $value, $view); } $view = str_replace("<!--<<smiles>>-->", get_smiles_htm_table(), $view); echo $view;
function _session_db_write($session_id, $value) { $db =& db_factory::instance(); $db->sql_select('sys_session', '*', "session_id='{$session_id}'"); // check if session already exists $db->sql_select('sys_session', 'session_data', "session_id='{$session_id}'"); $session_res = $db->get_array(); if (!($user_id = user::get_id())) { $user_id = 0; } if (count($session_res) == 1) { $res = $db->sql_update('sys_session', "last_activity_time=" . time() . ", session_data='{$value}', user_id = {$user_id}", "session_id='{$session_id}'"); } else { $res = $db->sql_insert('sys_session', array('last_activity_time' => time(), 'session_data' => "{$value}", 'user_id' => "{$user_id}", 'session_id' => "{$session_id}")); } }
} catch (Exception $e) { echo $e->getMessage(); exit; } ?> <HTML> <HEAD> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2"> <META NAME="Author" CONTENT="Janusz Paluch"> <TITLE>W3Pim - terminarz</TITLE> </HEAD> <BODY> <?php $dbcnx = polacz($GLOBALS['login'], $GLOBALS['pass']); $uzk_id = $u->get_id(); $edycja = 0; if (isset($_GET['id_e'])) { $id_e = $_GET['id_e']; $edycja = 1; } //przypisanie wartosci odpowiednich zmiennych (byla metoda GET) if (isset($_GET['rok'])) { $rok = $_GET['rok']; $miesiac = $_GET['mies']; $dzien = $_GET['dzien']; //jesli bez parametrow to biezaca data } else { $rok = date("Y"); $miesiac = date("m"); $dzien = date("d");
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(); $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 _changing_own_password() { $object_data = $this->_load_object_data(); return $object_data['id'] == user::get_id() ? true : false; }
<?php require_once 'globals.php'; require_once 'user.php'; try { $u = new user(); } catch (Exception $e) { echo $e->getMessage(); exit; } $link = mysql_connect(XHOST, XLOGIN, XPASSWD) or die(mysql_error()); mysql_select_db(XDB) or die(mysql_error()); $user = $u->get_id(); $query = "SELECT uzk_login FROM uzytkownicy WHERE uzk_id={$user}"; $result = mysql_query($query) or die(mysql_error()); $tmp = mysql_fetch_array($result, MYSQL_ASSOC); $user_name = $tmp['uzk_login']; //echo "Uzytkownik : {$tmp['uzk_login']}"; if ($HTTP_GET_VARS['akcja'] == 'dodaj' || $HTTP_GET_VARS['akcja'] == 'zmien') { if (strlen($HTTP_GET_VARS['tytul']) == 0) { header('Location: todo.php?blad=1'); exit; } if (strlen($HTTP_GET_VARS['opis']) == 0) { header('Location: todo.php?blad=2'); exit; } /* foreach($HTTP_GET_VARS as $k => $w) { echo "{$k} => {$w}<BR>"; }*/
function _session_db_write($session_id, $value) { $db =& db_factory::instance(); $user_id = user::get_id(); $db->sql_select('sys_session', 'session_id', "session_id='{$session_id}'"); if ($db->fetch_row()) { $db->sql_update('sys_session', "last_activity_time=" . time() . ", session_data='{$value}', user_id={$user_id}", "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}")); } }
function _check_sys_site_object_record() { $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); $this->assertTrue(time() - $record['modified_date'] <= 60); }
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 = ''; if (($user_id = user::get_id()) != VISITOR_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); }