/** * Execute the view of the template "adduser.tpl.php" * * @return bool true on success else false */ function perform() { // check permission to add new user $this->B->F(USER_FILTER, 'permission', array('action' => 'add')); // add user on demande if ($_GET['sec'] == 'adduser' && isset($_POST['adduser'])) { // Init form field values $this->B->tpl_error = FALSE; $this->B->form_forename = ''; $this->B->form_lastname = ''; $this->B->form_email = ''; $this->B->form_login = ''; $this->B->form_passwd = ''; $this->B->form_rights = ''; $this->B->form_status = ''; // check if required fields are empty if (FALSE == $this->_check_empty_fields()) { $this->_reset_old_fields_data(); return TRUE; } $_data = array('error' => 'tpl_error', 'user_data' => array('forename' => $this->B->db->escape(commonUtil::stripSlashes($_POST['forename'])), 'lastname' => $this->B->db->escape(commonUtil::stripSlashes($_POST['lastname'])), 'email' => $this->B->db->escape(commonUtil::stripSlashes($_POST['email'])), 'login' => $this->B->db->escape(commonUtil::stripSlashes($_POST['login'])), 'passwd' => $this->B->db->escape(md5($_POST['passwd'])), 'rights' => 1, 'status' => 1)); // add new user data if (FALSE !== ($user_id = $this->B->M(MOD_USER, 'add', $_data))) { @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1&m=user&sec=edituser&uid=' . $user_id); exit; } else { $this->_reset_old_fields_data(); return TRUE; } } return TRUE; }
/** * Evaluate the option requests of the option template * * @param array $data */ function perform($data) { // Init this variable $this->B->modul_options = FALSE; // update the main options on demande $this->_update_main_options(); // update options of other modules $this->B->B('set_options'); // if some config are modified, write the config file and reload the page if ($this->B->_modified == TRUE) { $this->B->M(MOD_COMMON, 'sys_update_config', $this->B->sys); @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1&m=option'); exit; } // update language bad words list $this->_update_bad_words_list(); // assign tpl array with available public template groups $this->_load_public_tpl_groups(); // assign tpl array with available bad word lists $this->_get_bad_words_list(); // Load options templates from other modules $this->B->mod_option = array(); $this->B->B('get_options'); return TRUE; }
/** * Execute the view of the template "addlist.tpl.php" * * @return bool true on success else false */ function perform() { if (isset($_POST['addlist'])) { // Init form field values $this->B->form_error = FALSE; $this->B->form_name = ''; $this->B->form_emailserver = ''; $this->B->form_email = ''; $this->B->form_description = ''; $this->B->form_status = ''; // Check if some form fields are empty if (empty($_POST['name']) || empty($_POST['emailserver']) || empty($_POST['email'])) { $this->B->form_error = 'You have fill out the fields: name, emailserver, email !'; $this->_reset_old_fields_data(); return TRUE; } else { // add new email list $this->B->tmp_data = array('name' => $this->B->db->escape(commonUtil::stripSlashes($_POST['name'])), 'emailserver' => $this->B->db->escape(commonUtil::stripSlashes($_POST['emailserver'])), 'email' => $this->B->db->escape(commonUtil::stripSlashes($_POST['email'])), 'description' => $this->B->db->escape(commonUtil::stripSlashes($_POST['description'])), 'folder' => $this->B->db->escape($list_folder), 'status' => (int) $_POST['status']); if (TRUE === $this->B->M(MOD_EARCHIVE, 'add_list', $this->B->tmp_data)) { @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1&m=earchive'); exit; } else { $this->B->form_error = 'An unexpected error occured. Please check error_log!'; $this->_reset_old_fields_data(); return TRUE; } } } return TRUE; }
/** * Execute the view of the template "group_register.tpl.php" * * @return bool true on success else false */ function perform() { // check if option allow_register is not set if ($this->B->sys['option']['user']['allow_register'] == FALSE) { @header('Location: ' . SF_BASE_LOCATION . '/index.php'); exit; } // init template vars $this->B->tpl_error = FALSE; $this->B->tpl_success = NULL; // create capcha picture and public key $this->B->M(MOD_USER, 'captcha_make', array('captcha_pic' => 'tpl_captcha_pic', 'public_key' => 'tpl_public_key')); if ($_POST['do_register']) { // validate captcha turing/public keys if (FALSE === $this->B->M(MOD_USER, 'captcha_validate', array('turing_key' => $_POST['captcha_turing_key'], 'public_key' => $_POST['captcha_public_key']))) { $this->B->tpl_error = '- Wrong turing key<br /><br />'; $this->_reset_form_data(); return TRUE; } if (FALSE == $this->B->M(MOD_USER, 'register', array('register' => $_POST['do_register'], 'error_var' => 'tpl_error', 'email_subject' => 'Your Earchive registration', 'email_msg' => 'You have to click on the link below to activate your account:<br /><br />(URL)<br /><br />Please contact the administrator on problems: (EMAIL).', 'reg_data' => array('login' => $_POST['login'], 'passwd1' => $_POST['passwd1'], 'passwd2' => $_POST['passwd2'], 'forename' => $_POST['forename'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'])))) { $this->B->tpl_success = 'fail'; $this->_reset_form_data(); return TRUE; } $this->B->tpl_success = 'ok'; } return TRUE; }
/** * Execute the view of the template "group_search.tpl.php" * * @return bool true on success else false */ function perform() { //get all available email lists and store the result in the array $B->tpl_list $this->B->M(MOD_EARCHIVE, 'get_lists', array('var' => 'tpl_list', 'fields' => array('lid', 'name', 'email', 'description', 'status'))); //get the messages of the searching result and store the result in the array $B->tpl_msg $this->B->M(MOD_EARCHIVE, 'search', array('var' => 'tpl_msg', 'search' => $_REQUEST['search'], 'bool' => 'and', 'order' => 'mdate desc', 'limit' => 100, 'fields' => array('mid', 'lid', 'subject', 'sender', 'mdate'), 'get_list' => TRUE)); return TRUE; }
/** * Check if version number has changed and perfom additional upgarde code * Furthermore assign array with module menu names for the top right * module html seletor * * @param array $data */ function perform($data) { // get os related separator to set include path if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $tmp_separator = ';'; } else { $tmp_separator = ':'; } // set include path to the PEAR packages ini_set('include_path', SF_BASE_DIR . 'modules/common/PEAR' . $tmp_separator . ini_get('include_path')); unset($tmp_separator); // include PEAR DB class include_once SF_BASE_DIR . 'modules/common/PEAR/MDB2.php'; // init system config array $this->B->sys = array(); // include system config array $this->B->sys if (file_exists(SF_BASE_DIR . 'modules/common/config/config.php')) { include_once SF_BASE_DIR . 'modules/common/config/config.php'; } // if setup was done if ($this->B->sys['info']['status'] == TRUE) { $this->B->dsn = array('phptype' => $this->B->sys['db']['type'], 'username' => $this->B->sys['db']['user'], 'password' => $this->B->sys['db']['passwd'], 'hostspec' => $this->B->sys['db']['host'], 'database' => $this->B->sys['db']['name']); $this->B->db =& MDB2::connect($this->B->dsn); if (MDB2::isError($this->B->db)) { trigger_error('Cannot connect to the database: ' . __FILE__ . ' ' . __LINE__, E_USER_ERROR); } } else { // switch to the admin section if we comes from the public section if (SF_SECTION == 'public') { @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1'); exit; } // launch setup screen include $this->B->M(MOD_COMMON, 'get_module_view', array('m' => 'setup', 'view' => 'index')); // Send the output buffer to the client ob_end_flush(); exit; } // Check for upgrade if (MOD_COMMON_VERSION != (string) $this->B->sys['module']['common']['version']) { // set the new version num of this module $this->B->sys['module']['common']['version'] = MOD_COMMON_VERSION; $this->B->system_update_flag = TRUE; // include here additional upgrade code } if (SF_SECTION == 'admin') { // sort handler array by name ksort($this->B->handler_list); // assign template handler names array // this array is used to build the modul select form of the admin menu $this->B->tpl_mod_list = array(); foreach ($this->B->handler_list as $key => $value) { if ($value['menu_visibility'] == TRUE) { $this->B->tpl_mod_list[$key] = $value; } } } }
/** * Execute the view of the template "group_validate.tpl.php" * * @return bool true on success else false */ function perform() { $this->B->tpl_is_valid = $this->B->M(MOD_USER, 'validate', array('md5_str' => $_GET['usr_id'])); if (TRUE === $this->B->tpl_is_valid) { $this->B->tpl_validation_message = 'Your account is now active.'; } else { $this->B->tpl_validation_message = 'Account activation fails!!!'; } return TRUE; }
/** * Check if version number has changed and perfom additional upgarde code * Furthermore assign array with module menu names for the top right * module html seletor * * @param array $data */ function perform($data) { // check for install or upgrade if (MOD_EARCHIVE_VERSION != (string) $this->B->sys['module']['earchive']['version']) { // set the new version num of this module $this->B->sys['module']['earchive']['version'] = MOD_EARCHIVE_VERSION; $this->B->system_update_flag = TRUE; $this->B->M(MOD_EARCHIVE, 'upgrade'); } }
/** * Execute the view of the template "group_message.tpl.php" * * @return bool true on success else false * @todo validate $_GET['mid'] */ function perform() { /* get all available email lists and store the result in the array $B->tpl_list */ $this->B->M(MOD_EARCHIVE, 'get_lists', array('var' => 'tpl_list', 'fields' => array('lid', 'name', 'email', 'description', 'status'))); /* get the requested message and store the result in the array $B->tpl_msg assign template vars with message data */ $this->B->M(MOD_EARCHIVE, 'get_message', array('mid' => (int) $_GET['mid'], 'var' => 'tpl_msg', 'fields' => array('subject', 'sender', 'mdate', 'body', 'folder'))); /* get the message attachments and store the result in the array $B->tpl_attach */ $this->B->M(MOD_EARCHIVE, 'get_attachments', array('var' => 'tpl_attach', 'mid' => (int) $_GET['mid'], 'fields' => array('aid', 'mid', 'lid', 'file', 'size', 'type'))); return TRUE; }
/** * Check if version number has changed and perfom additional upgarde code * * @param array $data */ function perform($data) { // Check for upgrade if (MOD_USER_VERSION != (string) $this->B->sys['module']['user']['version']) { // set the new version num of this module $this->B->sys['module']['user']['version'] = MOD_USER_VERSION; $this->B->system_update_flag = TRUE; $this->B->M(MOD_USER, 'upgrade'); // include here additional upgrade code } }
/** * Execute the view of the template "group_list.tpl.php" * * @return bool true on success else false * @todo validate $_GET['lid'] */ function perform() { /* check if registered user is required to access this list */ $this->B->M(MOD_EARCHIVE, 'have_access', array('lid' => (int) $_GET['lid'])); /* get all available email lists and store the result in the array $B->tpl_list */ $this->B->M(MOD_EARCHIVE, 'get_lists', array('var' => 'tpl_list', 'fields' => array('lid', 'name', 'email', 'description', 'status'))); /* get the messages of the requested email list and store the result in the array $B->tpl_msg assign template vars with message data */ $this->B->M(MOD_EARCHIVE, 'get_messages', array('lid' => (int) $_GET['lid'], 'var' => 'tpl_msg', 'fields' => array('mid', 'lid', 'subject', 'sender', 'mdate'), 'order' => 'mdate DESC', 'pager' => array('var' => 'tpl_prevnext', 'limit' => 15, 'delta' => 3))); return TRUE; }
/** * Check if registered user is required to access list with status 3 * * @param array $data */ function perform(&$data) { /* get list status */ $this->B->M(MOD_EARCHIVE, 'get_list', array('lid' => $data['lid'], 'var' => 'tmp_list', 'fields' => array('status'))); if ($this->B->tmp_list['status'] == 3 && $this->B->is_logged === FALSE) { $query = base64_encode($this->_getQueryString()); @header('Location: ' . SF_BASE_LOCATION . '/index.php?view=login&url=' . $query); exit; } return TRUE; }
/** * Execute the view of the template "group_attach.tpl.php" * * @return bool true on success else false * @todo validate $_GET['mid'] */ function perform() { //Get the demanded attachment and send it to the client //get the top requested email list attachment folder $this->B->M(MOD_EARCHIVE, 'get_list', array('var' => 'tpl_list', 'lid' => (int) $_GET['lid'], 'fields' => array('folder'))); //get the requested message attachment folder $this->B->M(MOD_EARCHIVE, 'get_message', array('var' => 'tpl_msg', 'mid' => (int) $_GET['mid'], 'lid' => (int) $_GET['lid'], 'fields' => array('folder'))); //get the attachment file name, type $this->B->M(MOD_EARCHIVE, 'get_attach', array('var' => 'tpl_attach', 'aid' => (int) $_GET['aid'], 'mid' => (int) $_GET['mid'], 'lid' => (int) $_GET['lid'], 'fields' => array('file', 'type'))); // set params to send http header and content $this->B->attach_params = array('file' => './data/earchive/' . $this->B->tpl_list['folder'] . '/' . $this->B->tpl_msg['folder'] . '/' . stripslashes($this->B->tpl_attach['file']), 'contenttype' => $this->B->tpl_attach['type'], 'contentdisposition' => array(HTTP_DOWNLOAD_ATTACHMENT, stripslashes($this->B->tpl_attach['file']))); return TRUE; }
/** * fetch all attachments from a message * * @param int $mid message id * @param array $account account data */ function _fetch_attach($message_id, $mid, $account, $_folder) { // check if there are attachments attachments if (!isset($this->_msg->msg[$mid]['at']['pid']) && count($this->_msg->msg[$mid]['at']['pid']) == 0) { return TRUE; } else { $path = SF_BASE_DIR . 'data/earchive/' . $account['folder'] . '/' . $_folder; if (!@mkdir($path, SF_DIR_MODE)) { trigger_error('Unable to create list message folder', E_USER_ERROR); } foreach ($this->_msg->msg[$mid]['at']['pid'] as $i => $aid) { $att_data = array(); $body = $this->_msg->getBody($mid, $this->_msg->msg[$mid]['at']['pid'][$i]); $_file = $this->_decodeEmailHeader($this->_msg->msg[$mid]['at']['fname'][$i]); $att_data['path_file'] = $path . '/' . $_file; $att_data['file'] = $this->B->db->escape($_file); $att_data['type'] = $this->B->db->escape($this->_msg->msg[$mid]['at']['ftype'][$i]); $att_data['size'] = $this->_msg->msg[$mid]['at']['fsize'][$i]; $att_data['mid'] = $message_id; $att_data['lid'] = $account['lid']; $att_data['content'] = $body['message']; $this->B->M(MOD_EARCHIVE, 'add_attach', $att_data); } } return TRUE; }
/** * Execute the view of the template "index.tpl.php" * create the template variables * and listen to an action * * @return bool true on success else false */ function perform() { // create capcha picture and public key $this->B->M(MOD_USER, 'captcha_make', array('captcha_pic' => 'tpl_captcha_pic', 'public_key' => 'tpl_public_key')); // Check login data if (isset($_POST['login'])) { // validate captcha turing/public keys if (FALSE === $this->B->M(MOD_USER, 'captcha_validate', array('turing_key' => $_POST['captcha_turing_key'], 'public_key' => $_POST['captcha_public_key']))) { $this->B->tpl_error = 'Wrong turing key!!<br /><br />'; $this->_reset_form_data(); return TRUE; } $this->B->M(MOD_USER, 'check_login', array('login' => $_POST['login_name'], 'passwd' => $_POST['password'], 'forward_url' => $_REQUEST['url'])); } return TRUE; }
/** * Execute the view of the template "showmessages.tpl.php" * * @return bool true on success else false */ function perform() { // Delete messages on demande if (isset($_POST['deletemess'])) { if (count($_POST['mid']) > 0) { foreach ($_POST['mid'] as $mid) { // assign template vars with list data $this->B->M(MOD_EARCHIVE, 'delete_message', array('mid' => (int) $mid)); } } } // assign template vars with list data $this->B->M(MOD_EARCHIVE, 'get_list', array('lid' => (int) $_REQUEST['lid'], 'var' => 'tpl_list', 'fields' => array('lid', 'name'))); // assign template vars with message data $this->B->M(MOD_EARCHIVE, 'get_messages', array('lid' => (int) $_REQUEST['lid'], 'var' => 'tpl_messages', 'order' => 'mdate DESC', 'pager' => array('var' => 'tpl_messages_pager', 'limit' => 20, 'delta' => 3), 'fields' => array('mid', 'lid', 'subject', 'sender', 'mdate'))); return TRUE; }
/** * Do setup for this module * * @param array $data */ function perform($data) { // launch setup if ($_POST['do_setup']) { $_data = array('dbhost' => (string) $_POST['dbhost'], 'dbuser' => (string) $_POST['dbuser'], 'dbpasswd' => (string) $_POST['dbpasswd'], 'dbname' => (string) $_POST['dbname'], 'dbtype' => (string) $_POST['dbtype'], 'dbtablesprefix' => (string) $_POST['dbtablesprefix'], 'dbcreate' => (string) $_POST['create_db'], 'charset' => (string) $_POST['charset'], 'userlogin' => (string) $_POST['userlogin'], 'username' => (string) $_POST['username'], 'userlastname' => (string) $_POST['userlastname'], 'userpasswd1' => (string) $_POST['userpasswd1'], 'userpasswd2' => (string) $_POST['userpasswd2']); if (FALSE == $this->B->M(MOD_SETUP, 'sys_setup', $_data)) { $this->B->form_host = htmlspecialchars(commonUtil::stripSlashes($_POST['dbhost'])); $this->B->form_user = htmlspecialchars(commonUtil::stripSlashes($_POST['dbuser'])); $this->B->form_dbname = htmlspecialchars(commonUtil::stripSlashes($_POST['dbname'])); $this->B->form_tableprefix = htmlspecialchars(commonUtil::stripSlashes($_POST['dbtablesprefix'])); $this->B->form_sysname = htmlspecialchars(commonUtil::stripSlashes($_POST['username'])); $this->B->form_syslastname = htmlspecialchars(commonUtil::stripSlashes($_POST['userlastname'])); $this->B->form_syslogin = htmlspecialchars(commonUtil::stripSlashes($_POST['userlogin'])); } } return TRUE; }
/** * Execute the view of the template "editlist.tpl.php" * * @return bool true on success else false */ function perform() { // init $this->B->form_error = FALSE; // delete list if ($_POST['dellist'] == 1) { // check if the user of this request try to delete a list // with rights other than administrator 5. // if (TRUE == $this->B->F(MOD_EARCHIVE, 'permission', array('action' => 'delete'))) { $this->B->M(MOD_EARCHIVE, 'delete_list', array('lid' => (int) $_REQUEST['lid'])); @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1&m=earchive'); exit; } else { $this->B->form_error = 'You can\'t remove this list'; $this->_reset_old_fields_data(); return TRUE; } } // Modify list data if (isset($_POST['editlist'])) { // check if some fields are empty if (empty($_POST['name']) || empty($_POST['emailserver']) || empty($_POST['email'])) { $this->B->form_error = 'You have fill out all fields!'; $this->_reset_old_fields_data(); return TRUE; } else { // list form data $this->B->tmp_data = array('name' => $this->B->db->escape(commonUtil::stripSlashes($_POST['name'])), 'emailserver' => $this->B->db->escape(commonUtil::stripSlashes($_POST['emailserver'])), 'email' => $this->B->db->escape(commonUtil::stripSlashes($_POST['email'])), 'description' => $this->B->db->escape(commonUtil::stripSlashes($_POST['description'])), 'status' => (int) $_POST['status']); // update list data if (TRUE === $this->B->M(MOD_EARCHIVE, 'update_list', array('lid' => (int) $_REQUEST['lid'], 'data' => $this->B->tmp_data))) { @header('Location: index.php?admin=1&m=earchive'); exit; } else { $this->B->form_error = $_error; $this->_reset_old_fields_data(); return TRUE; } } } else { // assign template vars with list data $this->B->M(MOD_EARCHIVE, 'get_list', array('lid' => (int) $_REQUEST['lid'], 'var' => 'tpl_data', 'fields' => array('lid', 'name', 'status', 'email', 'emailserver', 'description'))); } return TRUE; }
/** * Set options for this module * * @param array $data */ function perform($data) { // set the passID to external fetching emails if (isset($_POST['update_earchive_options_passID'])) { if (!preg_match("/[^a-zA-Z0-9]+/", $_POST['passID'])) { $this->B->sys['module']['earchive']['passID'] = $_POST['passID']; $this->B->_modified = TRUE; } } // Rebuild the words index of all messages if (isset($_POST['earchive_rebuild_index'])) { $this->B->M(MOD_EARCHIVE, 'rebuild_words_index'); } // fetch messages from email accounts if (isset($_POST['earchive_fetch_emails'])) { $this->B->M(MOD_EARCHIVE, 'fetch_emails', array('status' => 'status>1')); } }
/** * Do setup for this module * * @param array $data */ function perform($data) { // Init error array $this->B->setup_error = array(); $success = TRUE; if ($success == TRUE) { $success = $this->B->M(MOD_SYSTEM, 'sys_setup'); } // connect to the database if ($success == TRUE) { $success = $this->B->M(MOD_COMMON, 'sys_setup_validate', array('dbcreate' => $data['dbcreate'], 'dbtype' => $data['dbtype'], 'dbuser' => $data['dbuser'], 'dbpasswd' => $data['dbpasswd'], 'dbname' => $data['dbname'], 'dbhost' => $data['dbhost'], 'dbtablesprefix' => $data['dbtablesprefix'])); } // validate user data if ($success == TRUE) { $success = $this->B->M(MOD_USER, 'sys_setup_validate', array('username' => $data['username'], 'userlastname' => $data['userlastname'], 'userlogin' => $data['userlogin'], 'userpasswd1' => $data['userpasswd1'], 'userpasswd2' => $data['userpasswd2'])); } // validate earchive data if ($success == TRUE) { $success = $this->B->M(MOD_EARCHIVE, 'sys_setup_validate'); } if ($success == TRUE) { $success = $this->B->M(MOD_COMMON, 'sys_setup', array('dbcreate' => $data['dbcreate'], 'dbtype' => $data['dbtype'], 'dbuser' => $data['dbuser'], 'dbpasswd' => $data['dbpasswd'], 'dbname' => $data['dbname'], 'dbhost' => $data['dbhost'], 'dbtablesprefix' => $data['dbtablesprefix'])); } if ($success == TRUE) { $success = $this->B->M(MOD_USER, 'sys_setup', array('username' => $data['username'], 'userlastname' => $data['userlastname'], 'userlogin' => $data['userlogin'], 'userpasswd1' => $data['userpasswd1'], 'userpasswd2' => $data['userpasswd2'])); } if ($success == TRUE) { $success = $this->B->M(MOD_EARCHIVE, 'sys_setup'); } if ($success == TRUE) { $success = $this->B->M(MOD_OPTION, 'sys_setup'); } // check on errors before proceed if ($success == TRUE) { // set default template group that com with this package $this->B->conf_val['option']['tpl'] = 'earchive'; $this->B->conf_val['info']['status'] = TRUE; $this->B->M(MOD_COMMON, 'sys_update_config', $this->B->conf_val); @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1'); exit; } return $success; }
/** * Set options for this module * * @param array $data */ function perform($data) { // get var name to store the result $this->B->{$data}['error_var'] = FALSE; $this->_error =& $this->B->{$data}['error_var']; if (FALSE === $this->_validate($data)) { return FALSE; } $_data = array('error' => 'tmp_error', 'user_data' => array('forename' => $this->B->db->escape(commonUtil::stripSlashes($data['reg_data']['forename'])), 'lastname' => $this->B->db->escape(commonUtil::stripSlashes($data['reg_data']['lastname'])), 'email' => $this->B->db->escape(commonUtil::stripSlashes($data['reg_data']['email'])), 'login' => $this->B->db->escape(commonUtil::stripSlashes($data['reg_data']['login'])), 'passwd' => $this->B->db->escape(md5($data['reg_data']['passwd1'])), 'rights' => 1, 'status' => 1)); if (FALSE === ($uid = $this->B->M(MOD_USER, 'add', $_data))) { $this->_error .= 'Couldnt add user data'; return FALSE; } else { $header = "From: {$this->B->sys['option']['email']}\r\n"; $header .= "MIME-Version: 1.0\r\n"; $header .= "Content-type: text/html; charset={$this->B->sys['option']['charset']}\r\n"; if ($this->B->sys['option']['user']['register_type'] == 'auto') { $ustr = $this->_add_registered_user_data($uid); $validate_msg = str_replace("(URL)", "<a href='" . SF_BASE_LOCATION . "/index.php?view=validate&usr_id={$ustr}'>validate</a>", $data['email_msg']); $validate_msg = str_replace("(EMAIL)", "<a href='mailto:{$this->B->sys['option']['email']}'>{$this->B->sys['option']['email']}</a>", $validate_msg); if (FALSE == @mail($data['reg_data']['email'], $data['email_subject'], $validate_msg, $header)) { trigger_error("Email couldnt be sended to the user who want to register: {$data['reg_data']['email']}", E_USER_ERROR); $this->_error .= "Unexpected error: Email couldnt be send to you!<br>Please contact the <a href='mailto:{$this->B->sys['option']['email']}'>admin</a> to validate your account."; return FALSE; } } elseif ($this->B->sys['option']['user']['register_type'] == 'manual') { $subject = 'User validation needed'; $msg = 'You have to validate a user registration:<br />'; $msg .= '<a href="' . SF_BASE_LOCATION . '/index.php?admin=1&m=user&sec=edituser&uid=' . $uid . '">' . SF_BASE_LOCATION . '/index.php?admin=1&m=user&sec=edituser&uid=' . $uid . '</a>'; if (FALSE === @mail($this->B->sys['option']['email'], $subject, $msg, $header)) { trigger_error("Sending manual validation email fails for login: {$_data['login']}.", E_USER_ERROR); $this->_error .= "Unexpected error: Email couldnt be send to you!<br>Please contact the <a href='mailto:{$this->B->sys['option']['email']}'>admin</a> to validate your account."; return FALSE; } return TRUE; } return TRUE; } }
/** * Delete email list message data and attachement folder * * @param array $data */ function perform($data) { if (empty($data['mid'])) { return FALSE; } // get message folder and lid $this->B->M(MOD_EARCHIVE, 'get_message', array('mid' => $data['mid'], 'var' => 'm_data', 'fields' => array('lid', 'folder'))); // get list folder $this->B->M(MOD_EARCHIVE, 'get_list', array('lid' => $this->B->m_data['lid'], 'var' => 'l_data', 'fields' => array('lid', 'folder'))); // build whole path to message folder $path = SF_BASE_DIR . '/data/earchive/' . $this->B->l_data['folder'] . '/' . $this->B->m_data['folder']; if (!empty($this->B->m_data['folder']) && @is_dir($path)) { // delete attachements folder for this message commonUtil::delete_dir_tree($path); } // delete list messages $sql = "\n DELETE FROM \n {$this->B->sys['db']['table_prefix']}earchive_messages\n WHERE\n mid={$data['mid']}"; $result = $this->B->db->query($sql); if (MDB2::isError($result)) { trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR); return FALSE; } // delete list messages $sql = "\n DELETE FROM \n {$this->B->sys['db']['table_prefix']}earchive_attach\n WHERE\n mid={$data['mid']}"; $result = $this->B->db->query($sql); if (MDB2::isError($result)) { trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR); return FALSE; } // delete list messages word indexes $sql = "\n DELETE FROM \n {$this->B->sys['db']['table_prefix']}earchive_words_crc32\n WHERE\n mid={$data['mid']}"; $result = $this->B->db->query($sql); if (MDB2::isError($result)) { trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR); return FALSE; } return TRUE; }
/** * Execute the view of the template "editmessage.tpl.php" * * @return bool true on success else false */ function perform() { // init $this->B->form_error = FALSE; // Modify list data if (isset($_POST['updatemessage'])) { // check if some fields are empty if (empty($_POST['subject'])) { $this->B->form_error = 'You have to fill out subject field!'; $this->_reset_old_fields_data(); return TRUE; } else { // delete attachments ? if (is_array($_POST['aid']) && count($_POST['aid'] > 0)) { foreach ($_POST['aid'] as $aid) { $this->B->M(MOD_EARCHIVE, 'delete_attach', array('mid' => (int) $_REQUEST['mid'], 'aid' => (int) $aid)); } } // update message data $tmp_data = array('subject' => $this->B->db->escape(commonUtil::stripSlashes($_POST['subject'])), 'body' => $this->B->db->escape(commonUtil::stripSlashes($_POST['body']))); if (TRUE === $this->B->M(MOD_EARCHIVE, 'update_message', array('mid' => (int) $_REQUEST['mid'], 'fields' => $tmp_data))) { @header('Location: index.php?admin=1&m=earchive&sec=showmessages&lid=' . (int) $_REQUEST["lid"] . '&pageID=' . (int) $_REQUEST["pageID"]); exit; } else { $this->B->form_error = 'Error during update. Try again!'; $this->_reset_old_fields_data(); return TRUE; } } } else { // assign template vars with message data $this->B->M(MOD_EARCHIVE, 'get_message', array('mid' => (int) $_REQUEST['mid'], 'var' => 'tpl_data', 'fields' => array('mid', 'lid', 'subject', 'sender', 'body', 'folder'))); // assign template vars with message attach data $this->B->M(MOD_EARCHIVE, 'get_attachments', array('mid' => (int) $_REQUEST['mid'], 'var' => 'tpl_attach', 'fields' => array('aid', 'file', 'size', 'type'))); } return TRUE; }
/** * update user data * * @return bool true on success else false * @access privat */ function _update_user_data() { // prepare user data array $_data = array('error' => 'tpl_error', 'user_id' => (int) $_REQUEST['uid'], 'fields' => array('forename' => $_POST['forename'], 'lastname' => $_POST['lastname'], 'email' => $_POST['email'], 'rights' => (int) $_POST['rights'], 'status' => (int) $_POST['status'])); // update password if it isnt empty if (!empty($_POST['passwd'])) { $_data['fields']['passwd'] = md5($_POST['passwd']); } // update user data if (FALSE != $this->B->M(MOD_USER, 'update', $_data)) { @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1&m=user'); exit; } return TRUE; }
/** * check if the logged user have rights to set status * of other users * * @param int $uid user id to modify * @return bool */ function ask_set_status($uid) { if ($this->B->logged_user_rights == 5) { return TRUE; } if ($this->B->logged_user_rights == 4) { // get user rights $this->B->M(MOD_USER, 'get', array('error' => 'tmp_error', 'result' => 'tmp_data', 'user_id' => $uid, 'fields' => array('rights'))); $rights = $this->B->tmp_data['rights']; $this->B->tmp_data['rights'] = NULL; if ($rights >= $this->B->logged_user_rights) { return FALSE; } else { return TRUE; } } return FALSE; }
/** * Execute the view of the template "default.tpl.php" * create the template variables * * @return bool true * @todo pagination results */ function perform() { // get all users $this->B->M(MOD_USER, 'get_users', array('error' => 'tpl_error', 'result' => 'all_users', 'fields' => array('uid', 'rights', 'status', 'email', 'login', 'forename', 'lastname'))); return TRUE; }
/** * Assign an array with the whole earchive options template path string * This is a subtemplate of the options module main template * * @param array $data */ function perform($data) { $this->B->mod_option[] = $this->B->M(MOD_COMMON, 'get_module_view', array('m' => 'earchive', 'view' => 'option')); }
/** * Execute the view of the template "group_index.tpl.php" * * @return bool true on success else false */ function perform() { //get all available email lists and store the result in the array $B->tpl_list $this->B->M(MOD_EARCHIVE, 'get_lists', array('var' => 'tpl_list', 'fields' => array('lid', 'name', 'email', 'description', 'status'))); return TRUE; }
/** * Execute the view of the template "default.tpl.php" * * @return bool true on success else false */ function perform() { // get all available lists $this->B->M(MOD_EARCHIVE, 'get_lists', array('var' => 'all_lists', 'fields' => array('lid', 'status', 'email', 'name', 'description'))); return TRUE; }