public function initializeFriends() { $this->friends = array(); $sql = "SELECT IDFRIEND FROM FRIEND WHERE IDUSER = " . $this->id; $stmt = $this->pdo->query($sql); while ($friend = $stmt->fetch()) { $newFriend = build_user($friend['IDFRIEND']); $newFriend->initializeArticles(); array_push($this->friends, $newFriend); } }
public function __construct() { if ($_SESSION['ID'] != null) { header('Location:/user'); } parent::__construct(); $this->users = array(); $sql = 'SELECT * FROM USERS'; $stmt = $this->pdo->query($sql); while ($rep = $stmt->fetch()) { $user = build_user($rep['ID']); array_push($this->users, $user); } }
public function __construct() { parent::__construct(); if ($_SESSION['ID'] == null) { header('Location:/'); } else { if ($_SESSION['admin'] == "admin") { header('Location:/admin'); } else { $this->user = build_user($_SESSION['ID']); $this->user->initializeFriends(); $this->user->initializeCategories(); $this->user->initializeFlux(); $this->user->initializeArticles(); $this->user->initializeMailBox(); $this->user->initializeTwitter(); } } }
$user['id'] = $_SESSION['pwg_uid']; } } // Now check the auto-login if ($user['id'] == $conf['guest_id']) { auto_login(); } // using Apache authentication override the above user search if ($conf['apache_authentication']) { $remote_user = null; foreach (array('REMOTE_USER', 'REDIRECT_REMOTE_USER') as $server_key) { if (isset($_SERVER[$server_key])) { $remote_user = $_SERVER[$server_key]; break; } } if (isset($remote_user)) { if (!($user['id'] = get_userid($remote_user))) { $user['id'] = register_user($remote_user, '', '', false); } } } // automatic login by authentication key if (isset($_GET['auth'])) { auth_key_login($_GET['auth']); } $user = build_user($user['id'], (defined('IN_ADMIN') and IN_ADMIN) ? false : true); if ($conf['browser_language'] and (is_a_guest() or is_generic()) and $language = get_browser_language()) { $user['language'] = $language; } trigger_notify('user_init', $user);
} else { $infos[] = l10n('Congratulations, Piwigo installation is completed'); if (isset($error_copy)) { $errors[] = $error_copy; } else { session_set_save_handler('pwg_session_open', 'pwg_session_close', 'pwg_session_read', 'pwg_session_write', 'pwg_session_destroy', 'pwg_session_gc'); if (function_exists('ini_set')) { ini_set('session.use_cookies', $conf['session_use_cookies']); ini_set('session.use_only_cookies', $conf['session_use_only_cookies']); ini_set('session.use_trans_sid', intval($conf['session_use_trans_sid'])); ini_set('session.cookie_httponly', 1); } session_name($conf['session_name']); session_set_cookie_params(0, cookie_path()); register_shutdown_function('session_write_close'); $user = build_user(1, true); log_user($user['id'], false); // email notification if (isset($_POST['send_password_by_mail'])) { include_once PHPWG_ROOT_PATH . 'include/functions_mail.inc.php'; $keyargs_content = array(get_l10n_args('Hello %s,', $admin_name), get_l10n_args('Welcome to your new installation of Piwigo!', ''), get_l10n_args('', ''), get_l10n_args('Here are your connection settings', ''), get_l10n_args('', ''), get_l10n_args('Link: %s', get_absolute_root_url()), get_l10n_args('Username: %s', $admin_name), get_l10n_args('Password: %s', $admin_pass1), get_l10n_args('Email: %s', $admin_mail), get_l10n_args('', ''), get_l10n_args('Don\'t hesitate to consult our forums for any help: %s', PHPWG_URL)); pwg_mail($admin_mail, array('subject' => l10n('Just another Piwigo gallery'), 'content' => l10n_args($keyargs_content), 'content_format' => 'text/plain')); } } } if (count($errors) != 0) { $template->assign('errors', $errors); } if (count($infos) != 0) { $template->assign('infos', $infos); }
$template->append('main', array($checkbox => $conf[$checkbox]), true); } break; case 'comments': $template->assign('comments', array('NB_COMMENTS_PAGE' => $conf['nb_comment_page'], 'comments_order' => $conf['comments_order'], 'comments_order_options' => $comments_order)); foreach ($comments_checkboxes as $checkbox) { $template->append('comments', array($checkbox => $conf[$checkbox]), true); } break; case 'default': $edit_user = build_user($conf['guest_id'], false); include_once PHPWG_ROOT_PATH . 'profile.php'; $errors = array(); if (save_profile_from_post($edit_user, $errors)) { // Reload user $edit_user = build_user($conf['guest_id'], false); $page['infos'][] = l10n('Information data registered in database'); } $page['errors'] = array_merge($page['errors'], $errors); load_profile_in_template($action, '', $edit_user, 'GUEST_'); $template->assign('default', array()); break; case 'display': foreach ($display_checkboxes as $checkbox) { $template->append('display', array($checkbox => $conf[$checkbox]), true); } $template->append('display', array('picture_informations' => unserialize($conf['picture_informations']), 'NB_CATEGORIES_PAGE' => $conf['nb_categories_page']), true); break; case 'sizes': // we only load the derivatives if it was not already loaded: it occurs // when submitting the form and an error remains
/** * Redirects to the given URL (HTML method). * once this function called, the execution doesn't go further * (presence of an exit() instruction. * * @param string $url * @param string $msg * @param integer $refresh_time * @return void */ function redirect_html($url, $msg = '', $refresh_time = 0) { global $user, $template, $lang_info, $conf, $lang, $t2, $page, $debug; if (!isset($lang_info) || !isset($template)) { $user = build_user($conf['guest_id'], true); load_language('common.lang'); trigger_notify('loading_lang'); load_language('lang', PHPWG_ROOT_PATH . PWG_LOCAL_DIR, array('no_fallback' => true, 'local' => true)); $template = new Template(PHPWG_ROOT_PATH . 'themes', get_default_theme()); } elseif (defined('IN_ADMIN') and IN_ADMIN) { $template = new Template(PHPWG_ROOT_PATH . 'themes', get_default_theme()); } if (empty($msg)) { $msg = nl2br(l10n('Redirection...')); } $refresh = $refresh_time; $url_link = $url; $title = 'redirection'; $template->set_filenames(array('redirect' => 'redirect.tpl')); include PHPWG_ROOT_PATH . 'include/page_header.php'; $template->set_filenames(array('redirect' => 'redirect.tpl')); $template->assign('REDIRECT_MSG', $msg); $template->parse('redirect'); include PHPWG_ROOT_PATH . 'include/page_tail.php'; exit; }
function set_user_on_env_nbm(&$nbm_user, $is_action_send) { global $user, $lang, $lang_info, $env_nbm; $user = build_user($nbm_user['user_id'], true); switch_lang_to($user['language']); if ($is_action_send) { $env_nbm['mail_template'] = get_mail_template($env_nbm['email_format']); $env_nbm['mail_template']->set_filename('notification_by_mail', 'notification_by_mail.tpl'); } }
public function get_listing($path = '', $page = '', $query = null) { global $CFG, $USER, $OUTPUT, $COURSE, $DB; require_once "{$CFG->dirroot}/google/constants.php"; require_once 'course_constants.php'; $ret = array(); $ret['dynload'] = true; $user = build_user(); $course = $COURSE; // $user = $USER->email; // TODO: uncomment $useraccount = $USER->email; $user = $useraccount; $deptstr = get_string('departmentaccountstring', 'repository_morsle'); // get departmental folder if exists $shortname = is_number(substr($course->shortname, 0, 5)) ? substr($course->shortname, 6) : $course->shortname; $morsleaccount = strtolower($course->shortname . '@' . $this->domain); // SPLIT INTO DEPARTMENTAL CODES $dept = explode("-", $shortname); if (defined($dept[0])) { $deptstr = CONSTANT($dept[0]) . $deptstr; $deptshortstr = strtolower(substr($deptstr, 0, 6)); $deptaccount = strtolower($deptstr . '@' . $this->domain); } else { $deptstr = 'nodept'; $deptshortstr = 'nodept'; $deptaccount = 'nodept'; } // get course level folders or documents $maxfiles = get_config('morsle', 'maxfilesreturned'); // get a docid if available $path = base64_decode($path); if ($path == '') { $root_path = null; $pathleftover = null; $search_path = null; } elseif ($path == $deptstr) { $root_path = $deptstr; $pathleftover = null; $search_path = null; } elseif (strpos($path, '|')) { list($docid, $pathleftover) = explode('|', $path); $search_path = 'folder%3A' . $docid; $root_path = strtolower(substr($pathleftover, 0, 6)); } else { $root_path = strtolower(substr($path, 0, 6)); $pathleftover = $path; $search_path = null; } // handle a search instance if ($query !== null) { $root_path = 'queryi'; } switch ($root_path) { case null: // empty: get only the readonly and writeable folders plus any files and user folder and (if available) department folder $user = $morsleaccount; $search = array('xoauth_requestor_id' => $user, 'showfolders' => 'true', 'folder' => 'folder%3Aroot', 'max-results' => $maxfiles); if ($search_path !== null) { // looking for another folder's contents $search['folder'] = $search_path; } $mauth = new morsle_oauth_request(null, null, $search); // subauthtoken ignored // unset($search['repo_id']); $mdocs = new morsle_docs($mauth); $ret['list'] = $mdocs->get_file_list($search, $this); // get user level folders or documents $user = $useraccount; $title = get_string('useraccountstring', 'repository_morsle') . $user; $url = DOCUMENTFEED_URL; $ret['list'][] = array('title' => $title, 'url' => $url, 'source' => $url, 'date' => usertime(strtotime(time())), 'children' => array(), 'path' => base64_encode('User Files'), 'thumbnail' => (string) $OUTPUT->pix_url('f/folder-64')); // check to see if we even have a departmental account for this department but don't show the departmental collection if we're already in it indicated by $wdir // TODO: this needs to change if we eliminate morsle table, but if the read-only or writeable folders get renamed then we need the table // department account if exists $conditions = " shortname = '{$deptstr}' "; $user = $deptaccount; $title = get_string('deptaccountstring', 'repository_morsle') . $user; if (strpos($path, $deptstr) === false && ($is_morsle_dept = $DB->get_record_select('morsle_active', $conditions))) { $ret['list'][] = array('title' => $deptstr, 'url' => $url, 'source' => $url, 'date' => usertime(strtotime(time())), 'children' => array(), 'path' => base64_encode($deptstr), 'thumbnail' => (string) $OUTPUT->pix_url('f/folder-64')); } $ret['path'][]['name'] = 'Morsle Files'; break; case 'queryi': case 'user f': // user account google files $search = array('xoauth_requestor_id' => $user, 'path' => $pathleftover, 'showfolders' => 'true', 'repo_id' => 5, 'max-results' => $maxfiles); if ($search_path !== null) { // looking for another folder's contents $search['folder'] = $search_path; } if ($query !== null) { $search['q'] = $query; } $mauth = new morsle_oauth_request(null, null, $search); // subauthtoken ignored unset($search['repo_id']); $mdocs = new morsle_docs($mauth); $ret['list'] = $mdocs->get_file_list($search, $this); $ret['path'][]['name'] = $pathleftover; break; case '/': // TODO: what does this get $search = array('xoauth_requestor_id' => $user, 'folder' => $search_path, 'repo_id' => 5, 'max-results' => $maxfiles); $mauth = new morsle_oauth_request(null, null, $search); // subauthtoken ignored unset($search['repo_id']); $mdocs = new morsle_docs($mauth); $ret['list'] = $mdocs->get_file_list($search, $this); break; case $deptstr: // department account google files, if we got here it means department files exist $user = $deptaccount; $search = array('xoauth_requestor_id' => $user, 'path' => $pathleftover, 'showfolders' => 'true', 'repo_id' => 5, 'max-results' => $maxfiles); if ($search_path !== null) { // looking for another folder's contents $search['folder'] = $search_path; } $mauth = new morsle_oauth_request(null, null, $search); // subauthtoken ignored unset($search['repo_id']); $mdocs = new morsle_docs($mauth); $ret['list'] = $mdocs->get_file_list($search, $this); $ret['path'][]['name'] = $pathleftover; break; case 'morsle': // only way we'd get here is if the read-only or writeable folder got clicked $user = $morsleaccount; $search = array('xoauth_requestor_id' => $user, 'path' => 'Morsle Files', 'max-results' => $maxfiles); if ($search_path !== null) { // looking for another folder's contents $search['folder'] = $search_path; } $mauth = new morsle_oauth_request(null, null, $search); // subauthtoken ignored unset($search['repo_id']); $mdocs = new morsle_docs($mauth); $ret['list'] = $mdocs->get_file_list($search); $ret['path'][]['name'] = $pathleftover; break; default: // empty: get only the readonly and writeable folders user folder and (if available) department folder $user = $morsleaccount; // list($title, $domain) = explode('@',$user); $search = array('xoauth_requestor_id' => $user, 'showfolders' => 'true', 'max-results' => $maxfiles); if ($search_path !== null) { // looking for another folder's contents $search['folder'] = $search_path; } $mauth = new morsle_oauth_request(null, null, $search); // subauthtoken ignored // unset($search['repo_id']); $mdocs = new morsle_docs($mauth); $ret['list'] = $mdocs->get_file_list($search, $this); // check to see if we even have a departmental account for this department but don't show the departmental collection if we're already in it indicated by $wdir // TODO: this needs to change if we eliminate morsle table $conditions = " shortname = '{$deptstr}' "; $user = $deptaccount; $title = get_string('deptaccountstring', 'repository_morsle') . $user; if (strpos($path, $deptstr) === false && ($is_morsle_dept = $DB->get_record_select('morsle_active', $conditions))) { $ret['list'][] = array('title' => $deptstr, 'url' => $url, 'source' => $url, 'date' => usertime(strtotime(time())), 'children' => array(), 'path' => base64_encode($deptstr), 'thumbnail' => (string) $OUTPUT->pix_url('f/folder-64')); } $ret['path'][]['name'] = 'Morsle Files'; } return $ret; }
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | // +-----------------------------------------------------------------------+ // | 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 | // | | // | 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. | // +-----------------------------------------------------------------------+ if (!defined("PHPWG_ROOT_PATH")) { die("Hacking attempt!"); } $edit_user = build_user($_GET['user_id'], false); if (!empty($_POST)) { check_pwg_token(); } include_once PHPWG_ROOT_PATH . 'profile.php'; $errors = array(); save_profile_from_post($edit_user, $errors); load_profile_in_template(get_root_url() . 'admin.php?page=profile&user_id=' . $edit_user['id'], get_root_url() . 'admin.php?page=user_list', $edit_user); $page['errors'] = array_merge($page['errors'], $errors); $template->set_filename('profile', 'profile.tpl'); $template->assign_var_from_handle('ADMIN_CONTENT', 'profile');
/** * Triggered on "user_init", change current view depending of URL params. */ public function user_init() { global $user, $conf; $this->is_admin = is_admin(); $this->user = array('id' => $user['id'], 'username' => $user['username'], 'language' => $user['language'], 'theme' => $user['theme']); // inactive on ws.php to allow AJAX admin tasks if ($this->is_admin && script_basename() != 'ws') { // show_queries if (isset($_GET['ato_show_queries'])) { $this->data['show_queries'] = (bool) $_GET['ato_show_queries']; } $conf['show_queries'] = $this->data['show_queries']; if ($this->data['view_as'] == 0) { $this->data['view_as'] = $user['id']; } if (empty($this->data['lang'])) { $this->data['lang'] = $user['language']; } if (empty($this->data['theme'])) { $this->data['theme'] = $user['theme']; } // view_as if (!defined('IN_ADMIN')) { if (isset($_GET['ato_view_as'])) { $this->data['view_as'] = (int) $_GET['ato_view_as']; } if ($this->data['view_as'] != $user['id']) { $user = build_user($this->data['view_as'], true); if (isset($_GET['ato_view_as'])) { $this->data['theme'] = $user['theme']; $this->data['lang'] = $user['language']; } } } // theme if (isset($_GET['ato_theme'])) { $this->data['theme'] = $_GET['ato_theme']; } $user['theme'] = $this->data['theme']; // lang if (isset($_GET['ato_lang'])) { $this->data['lang'] = $_GET['ato_lang']; } $user['language'] = $this->data['lang']; // debug_l10n if (isset($_GET['ato_debug_l10n'])) { $this->data['debug_l10n'] = (bool) $_GET['ato_debug_l10n']; } $conf['debug_l10n'] = $this->data['debug_l10n']; // debug_template if (isset($_GET['ato_debug_template'])) { $this->data['debug_template'] = (bool) $_GET['ato_debug_template']; } $conf['debug_template'] = $this->data['debug_template']; // template_combine_files if (isset($_GET['ato_template_combine_files'])) { $this->data['template_combine_files'] = (bool) $_GET['ato_template_combine_files']; } $conf['template_combine_files'] = $this->data['template_combine_files']; // no_history if (isset($_GET['ato_no_history'])) { $this->data['no_history'] = (bool) $_GET['ato_no_history']; } if ($this->data['no_history']) { add_event_handler('pwg_log_allowed', create_function('', 'return false;')); } $this->save(); } }
FROM ' . USER_FEED_TABLE . ' WHERE id = \'' . $feed_id . '\' ;'; $feed_row = pwg_db_fetch_assoc(pwg_query($query)); if (empty($feed_row)) { page_not_found(l10n('Unknown feed identifier')); } if ($feed_row['user_id'] != $user['id']) { // new user $user = build_user($feed_row['user_id'], true); } } else { $image_only = true; if (!is_a_guest()) { // auto session was created - so switch to guest $user = build_user($conf['guest_id'], true); } } // Check the status now after the user has been loaded check_status(ACCESS_GUEST); list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); include_once PHPWG_ROOT_PATH . 'include/feedcreator.class.php'; set_make_full_url(); $rss = new UniversalFeedCreator(); $rss->encoding = get_pwg_charset(); $rss->title = $conf['gallery_title']; $rss->title .= ' (as ' . stripslashes($user['username']) . ')'; $rss->link = get_gallery_home_url(); // +-----------------------------------------------------------------------+ // | Feed creation | // +-----------------------------------------------------------------------+