public function view() { if (fse_try_to_login()) { header("location:/fse_settings/profile"); } else { header("location:/"); } exit(0); }
public function delete_app_key() { $app_key = $this->post('appKey'); if (!fse_try_to_login()) { header("location:/fse_login"); } if (!preg_match("/^[a-f0-9]{64}\$/", $app_key)) { $this->set('error', t('Bad app key!')); return; } $db = Loader::db(); $res = $db->Execute("DELETE FROM fse_app_keys WHERE app_key=?", array($app_key)); if ($db->Affected_Rows() == 0) { $this->set('error', t('No such app key!')); return; } $this->set('success', t('App key deleted!')); }
* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ defined('C5_EXECUTE') or die('Access Denied.'); Loader::model('fsen_localization'); FSENLocalization::setupInterfaceLocalization4AjaxRequest(); require_once 'helpers/check_login.php'; require_once 'helpers/fsen/DocSectionManager.php'; require_once 'helpers/fsen/ProjectInfo.php'; $domain_handle = $_REQUEST['domainHandle']; $section_id = $_REQUEST['sectionID']; $current_ver_code = $_REQUEST['currentVerCode']; if (!fse_try_to_login()) { $error_info = t('You are not signed in.'); } else { if (preg_match("/^[a-f0-9]{32}\$/", $section_id) && in_array($domain_handle, ProjectInfo::$mDomainList)) { $db = Loader::db(); $section_info = DocSectionManager::getSectionInfo($domain_handle, $section_id); if (count($section_info) == 0) { $error_info = t('No such section ID!'); } else { if ($current_ver_code == 0 || $current_ver_code > $section_info['max_ver_code']) { $error_info = t('Bad request!'); } else { $project_id = $section_info['project_id']; $doc_lang = substr($project_id, -2); $project_info = ProjectInfo::getBasicInfo($project_id); if ($project_info == false) {
public function delete_blog() { if (!fse_try_to_login()) { header("location:/fse_login"); return; } $curr_page_id = $this->post('cID'); $project_id = $this->post('projectID'); $domain_handle = $this->post('domainHandle'); $volume_handle = $this->post('volumeHandle'); $part_handle = $this->post('partHandle'); $chapter_handle = $this->post('chapterHandle'); $curr_page_path = Page::getByID($curr_page_id)->getCollectionPath(); $form_token_name = $this->post('formTokenName'); $form_token = $this->post('formToken'); if ($_SESSION[$form_token_name] != $form_token) { set_page_action_status($curr_page_id, t('Delete Blog'), 'error', t('Bad request or session expired!')); unset($_SESSION[$form_token_name]); header("Location: {$curr_page_path}"); return; } unset($_SESSION[$form_token_name]); $cpt_page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle); $chapter_page = Page::getByPath($cpt_page_path); if ($chapter_page->getCollectionID() == false) { set_page_action_status($curr_page_id, t('Delete Blog'), 'error', t('No such blog page!')); header("Location: {$curr_page_path}"); return; } $chapter_page->delete(); $db = Loader::db(); $doc_lang = substr($project_id, -2); $db->Execute("DELETE FROM fsen_chapter_tags_{$doc_lang} WHERE chapter_handle=?", array($chapter_handle)); $db->Execute('DELETE FROM fsen_chapter_categories WHERE chapter_handle=?', array($chapter_handle)); $db->Execute("DELETE FROM fsen_project_doc_volume_part_chapters_{$doc_lang}\n\tWHERE project_id=? AND domain_handle=? AND volume_handle=? AND part_handle=? AND chapter_handle=?", array($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle)); ProjectInfo::onDeleteBlog($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle); set_page_action_status($curr_page_id, t('Delete Blog'), 'success', t('Succeed to delete the blog.')); header("Location: {$curr_page_path}"); }
public function login($is_mobile_theme = false, $project_id = false) { $ret_info = new ReturnInfo(); $ret_info->status = 'bad'; $ret_info->detail = ''; $ret_info->user_name = 'na'; $ret_info->nick_name = 'na'; $ret_info->project_rights = '0123456789abcdef'; if (fse_try_to_login()) { $ret_info->status = 'ok'; $ret_info->user_name = $_SESSION['FSEInfo']['user_name']; $ret_info->nick_name = $_SESSION['FSEInfo']['nick_name']; if ($project_id && ProjectInfo::getDomainName($project_id, 'home')) { $res = ProjectInfo::getUserRights($project_id, $_SESSION['FSEInfo']['fse_id']); if ($res) { $ret_info->project_rights = $res; } } $link = FSEInfo::getPersonalHomeLink(); if ($is_mobile_theme == 'true') { $ret_info->detail = ' <li> <a class="menu-item with-icon" href="' . $link . '" title="Personal homepage"> <span class="glyphicon glyphicon-user"></span> ' . $ret_info->nick_name . '</a> </li> <li> <a class="menu-item with-icon" href="/fse_settings"> <span class="glyphicon glyphicon-cogwheel"></span> ' . t('Settings') . ' </a> </li> <li> <a class="menu-item with-icon" href="/fse_logout/logout"> <span class="glyphicon glyphicon-log-out"></span> ' . t('Sign out') . ' </a> </li>'; } else { $ret_info->detail = ' <li> <a class="inline-list" href="' . $link . '" title="Personal homepage"> <span class="glyphicon glyphicon-user"></span> ' . $ret_info->nick_name . '</a> </li> <li> <a class="inline-list only-icon" href="/fse_settings" title="Settings"> <span class="glyphicon glyphicon-cogwheel"></span></a> </li> <li> <a class="inline-list only-icon" href="/fse_logout/logout" title="Sign out"> <span class="glyphicon glyphicon-log-out"></span></a> </li>'; } } else { if ($is_mobile_theme == 'true') { $ret_info->detail = ' <li> <a class="menu-item" href="/fse_login">' . t('Sign in') . '</a> </li> <li> <a class="menu-item" href="/fse_register">' . t('Sign up') . '</a> </li>'; } else { $ret_info->detail = ' <li> <a class="button" href="/fse_login">' . t('Sign in') . '</a> </li> <li> <a class="button button-blue" href="/fse_register">' . t('Sign up') . '</a> </li>'; } } $js = Loader::helper('json'); echo $js->encode($ret_info); exit(0); }
public function delete_account() { $delete_intent = $this->post('deleteIntent'); $user_name = $this->post('userName'); $hashed_passwd = $this->post('hashedPasswd'); if (!fse_try_to_login()) { header("location:/fse_login"); } if ($delete_intent != 'delete my account') { $this->set('error', t('You did not confirm your intent!')); return; } if ($_SESSION['FSEInfo']['user_name'] != $user_name) { $this->set('error', t('Wrong username!')); return; } if ($_SESSION['FSEInfo']['hashed_passwd'] != $hashed_passwd) { $this->set('error', t('Wrong password!')); return; } $db = Loader::db(); $projects = $db->getAll('SELECT project_id, doc_lang FROM fsen_projects WHERE fse_id=?', array($_SESSION['FSEInfo']['fse_id'])); foreach ($projects as $p) { $db->Execute("DELETE FROM fsen_projects WHERE project_id=?", array($p['project_id'])); /* delete project pages */ $page = Page::getByPath(ProjectInfo::assemblePath($p['project_id'], 'home')); if ($page->getCollectionID() > 0) { $page->delete(); } ProjectInfo::onDeleteProject($p['project_id']); } if (preg_match("/^zh/i", $_SESSION['FSEInfo']['def_locale'])) { $doc_lang = 'zh'; } else { $doc_lang = 'en'; } ProjectInfo::deleteProjectDocPart(SYSTEM_PROJECT_SHORTNAME . '-' . $doc_lang, 'document', 'blog', $user_name); $page = Page::getByPath("/{$doc_lang}/engineer/{$user_name}"); if ($page->getCollectionID() > 0) { $page->delete(); } $db->query("DELETE FROM fse_basic_profiles WHERE user_name=?", array($user_name)); $nick_name = $_SESSION['FSEInfo']['nick_name']; $email_box = $_SESSION['FSEInfo']['email_box']; $url_register = BASE_URL . '/fse_register'; $mail_subject = t('[FSEN] Your account have been deleted!'); $mail_body = t('Dear %s, We have deleted your account at FSEN (FullStackEngineer.Net)! We welcome you to sign up a new account at FSEN at any time: %s Good luck and regards, Your friends at FSEN', $nick_name, $url_register); $mh = Loader::helper('mail'); $mh->setSubject($mail_subject); $mh->setBody($mail_body); $mh->from(EMAIL_DEFAULT_FROM_ADDRESS, EMAIL_DEFAULT_FROM_NAME); if (defined('EMAIL_DEFAULT_BCC_ADDRESS')) { $mh->bcc(EMAIL_DEFAULT_BCC_ADDRESS, EMAIL_DEFAULT_BCC_NAME); } $mh->to($email_box, $nick_name); $mh->sendMail(); unset($_SESSION['FSEInfo']); setcookie("FSEID", null, time() - 3600 * 24 * 365, DIR_REL . '/'); setcookie("HashedPasswd", null, time() - 3600 * 24 * 365, DIR_REL . '/'); header("location:/"); exit(0); }
public function view() { if (fse_try_to_login()) { header("Location:/"); } }
public function get_public_profile($user_name = false) { $ret_info = new ReturnInfo(); $ret_info->status = 'bad'; $ret_info->fse_info = array(); $js = Loader::helper('json'); if (!fse_try_to_login()) { echo $js->encode($ret_info); exit(0); } if ($user_name) { $ret_info->status = 'ok'; $ret_info->fse_info = FSEInfo::getPublicProfile($user_name); } else { $ret_info->status = 'ok'; $fse_info = $_SESSION['FSEInfo']; unset($fse_info['fse_id']); unset($fse_info['hashed_passwd']); # we return email box for the logged in user # unset ($fse_info['email_box']); # unset ($fse_info['avatar_file_id']); if (!isset($fse_info['avatar_url'])) { $fse_info['avatar_url'] = get_url_from_file_id($fse_info['avatar_file_id']); } $ret_info->fse_info = $fse_info; } echo $js->encode($ret_info); exit(0); }