function output_domain_block($project_id) { foreach (ProjectInfo::$mDomainList as $domain_handle) { if ($domain_handle == 'home' || $domain_handle == 'misc') { continue; } $domain_link = ProjectInfo::assemblePath($project_id, $domain_handle); $domain_name = ProjectInfo::getDomainName($project_id, $domain_handle); $domain_desc = ProjectInfo::getDomainDesc($project_id, $domain_handle); switch ($domain_handle) { case 'download': $icon_name = 'download'; break; case 'document': $icon_name = 'book'; break; case 'community': $icon_name = 'group'; break; case 'contribute': $icon_name = 'heart'; break; } ?> <div class="col-sm-3 col-md-3 col-lg-3 note-block"> <div class="well text-center"> <div class="note-icon"> <a href="<?php echo $domain_link; ?> "> <span class="glyphicon glyphicon-<?php echo $icon_name; ?> "></span> </a> </div> <div class="note-desc"> <h2> <a href="<?php echo $domain_link; ?> "> <?php echo h5($domain_name); ?> </a> </h2> <p> <?php echo h5($domain_desc); ?> </p> </div> </p> </div> </div> <?php } }
public function do_register() { $txt = Loader::helper('text'); $user_name = $txt->sanitize($this->post('userName')); $hashed_passwd = $txt->sanitize($this->post('hashedPasswd')); $email_box = $txt->sanitize($this->post('emailBox')); $nick_name = $txt->sanitize($this->post('nickName')); $user_locale = $txt->sanitize($this->post('userLocale')); $location_country = $txt->sanitize($this->post('locationCountry')); $location_province = $txt->sanitize($this->post('locationProvince')); $location_district = $txt->sanitize($this->post('locationDistrict')); # check captcha here $captcha = Loader::helper('validation/captcha'); if (!$captcha->check("captchaCode")) { $this->set('error', t('Wrong captcha code!')); return; } $txt = Loader::helper('text'); if ($user_name != $txt->urlify($user_name)) { $this->set('error', t('Bad username!')); return; } if (!preg_match("/^[\\w][\\w-]{3,29}\$/", $user_name)) { $this->set('error', t('Bad username!')); return; } if (!preg_match("/^[\\w-]+([.+][\\w-]+)*@[\\w-]+(\\.[\\w-]+)+\$/", $email_box)) { $this->set('error', t('Bad email address!')); return; } if (!preg_match("/^[\\x{2E80}-\\x{9FFF}\\x{A000}-\\x{A4FF}\\x{AC00}-\\x{D7FF}\\x{F900}-\\x{FFFD}\\w_]{2,30}\$/u", $nick_name)) { $this->set('error', t('Bad nickname!')); return; } if (!check_hashed_passwd($user_name, $hashed_passwd)) { $this->set('error', t('You are using too weak passsword or the password is same as your username!')); return; } foreach (array($location_country, $location_province, $location_district) as $location) { $fragments = explode(":", $location, 2); if (!preg_match("/^[0-9]*\$/", $fragments[0]) || strlen($fragments[1]) < 2) { $this->set('error', t('Bad location!')); return; } } $db = Loader::db(); $fse_id = hash_hmac("md5", $user_name, $email_box); $query = 'INSERT IGNORE fse_basic_profiles (fse_id, user_name, hashed_passwd, email_box, nick_name, location_country, location_province, location_district, email_verified, create_time, update_time, last_login_time, def_locale) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 0, NOW(), NOW(), NOW(), ?)'; $res = $db->Execute($query, array($fse_id, $user_name, $hashed_passwd, $email_box, $nick_name, $location_country, $location_province, $location_district, $user_locale)); if ($db->Affected_Rows() == 0) { $this->set('error', t('Duplicated user name or email address.')); return; } $res = $db->getOne("SELECT fse_id FROM fsen_projects WHERE project_id='sys-en'"); if (strlen($res) == 0) { /* make this user as the owner of the system projects */ $db->Execute("UPDATE fsen_projects SET fse_id=? WHERE project_id LIKE 'sys-__'", array($fse_id)); $fse_info = FSEInfo::getNameInfo($fse_id); ProjectInfo::setUserAsOwner('sys-en', $fse_id); ProjectInfo::addOwnerMemberSection('sys-en', $fse_info); ProjectInfo::setUserAsOwner('sys-zh', $fse_id); ProjectInfo::addOwnerMemberSection('sys-zh', $fse_info); } if (preg_match("/^zh/i", $user_locale)) { $doc_lang = 'zh'; } else { $doc_lang = 'en'; } if (!$this->add_personal_homepage($user_name, $nick_name, $doc_lang)) { return; } if (!$this->add_blog_zone_page($db, $user_name, $nick_name, $doc_lang)) { return; } $hash_value = hash_hmac("md5", microtime() . rand(), $email_box); $db->Execute("REPLACE INTO fse_email_box_validation_hashes (email_box, hash_value, update_time)\n\tVALUES (?, ?, NOW())", array($email_box, $hash_value)); $location_country = substr(strstr($location_country, ':'), 1); $location_province = substr(strstr($location_province, ':'), 1); $location_district = substr(strstr($location_district, ':'), 1); $url_validate_email = BASE_URL . "/fse_validate_email/{$hash_value}"; $url_profile = BASE_URL . "/{$doc_lang}/engineer/{$user_name}"; $url_about = BASE_URL . "/{$doc_lang}/help/site-policy"; $mail_subject = t('[FSEN] Welcome to be a full stack engineer!'); $mail_body = t('Dear %s, Thanks for your registration at FSEN (FullStackEngineer.Net)! Here is your registration information: * Username: %s * Email Address: %s * Location: %s %s %s First, please click the following link to verify this email address: %s You can click the following link to visit your personal homepage at FSEN: %s Please also visit the following link to know the rules to use this site: %s Thanks, Your friends at FSEN', $nick_name, $user_name, $email_box, $location_country, $location_province, $location_district, $url_validate_email, $url_profile, $url_about); $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(); $this->set('success', t('Succeed to register. Welcome to be a Full Stack Engineer!')); }
echo "fsenDocLang={$doc_lang}&cID={$page_id}&projectID={$project_id}&domainHandle={$domain_handle}&volumeHandle={$volume_handle}&partHandle={$part_handle}"; ?> "> <m class="glyphicon glyphicon-circle-plus"></m> </a> </span> </h2> </header> <ul> <?php $chapters = ProjectInfo::getAllChapters($project_id, $domain_handle, $volume_handle, $part_handle); foreach ($chapters as $cpt) { ?> <li class="list-unstyled"> <a href="<?php echo ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $parts[$p]['part_handle'], $cpt['chapter_handle']); ?> "> <p><span></span><?php echo h5($cpt['chapter_name']); ?> </p> </a> </li> <?php } ?> </ul> </nav> <?php $start_part++;
" title="<?php echo ProjectInfo::getDomainDesc($sys_project_id, 'misc'); ?> " class="inline-list small"><?php echo ProjectInfo::getDomainName($sys_project_id, 'misc'); ?> </a> </li> <?php foreach ($volumes as $v) { ?> <li> <a href="<?php echo ProjectInfo::assemblePath($sys_project_id, 'misc', $v['volume_handle']); ?> " title="<?php echo h5($v['volume_desc']); ?> " class="inline-list small"><?php echo h5($v['volume_name']); ?> </a> </li> <?php } ?> </ul>
<small><?php echo FSEInfo::getPersonalHomeLink($author_name_info, true); ?> <br/><?php echo $publish_date; ?> </small> </div> <div class="col-md-4 wrap-on-xs"> <?php echo t('Replies #: ') . ($thd['nr_sections'] - 1); ?> <br/> <?php if ($thd['nr_sections'] > 1) { $last_section = ProjectInfo::getLastSectionInfo($project_id, $domain_handle, $volume_handle, $part_handle, $thd['chapter_handle']); $author_name_info = FSEInfo::getNameInfo($last_section['author_id']); $publish_date = date('Y-m-d H:i', $last_section['create_ctime']); ?> <small><?php echo FSEInfo::getPersonalHomeLink($author_name_info, true); ?> <br/><?php echo $publish_date; ?> </small> <?php } ?> </div> </div>
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}"); }
if (strncmp($type_handle, "member", 6) != 0) { $error_info = t('Section is not a member section!'); } else { if ($attached_files[0] > 0) { $attached_file_0 = File::getByID($attached_files[0]); } $type_fragments = explode(":", $type_handle); if (count($type_fragments) != 5) { $error_info = t('Bad member section!'); } else { $member_username = $type_fragments[2]; $member_fse_info = FSEInfo::getBasicProfile($member_username); if ($member_fse_info == false) { $error_info = t('Bad member username!'); } else { $roles = ProjectInfo::getUserRoles($project_id, $member_fse_info['fse_id']); $member_roles = $roles['member_roles']; if ($member_roles == '') { $error_info = t('Not a valid member!'); } else { if ($member_roles == 'owner') { $error_info = t('You can not edit roles of the owner!'); } } } } } } } } }
public static function addOwnerMemberSection($project_id, $fse_info = false) { /* add owner member section on misc page */ if ($fse_info == false) { $project_info = ProjectInfo::getBasicInfo($project_id); if ($project_info == false) { exit(0); } $fse_info = FSEInfo::getNameInfo($project_info['fse_id']); $fse_info = FSEInfo::getBasicProfile($fse_info['user_name']); } else { $fse_info['avatar_url'] = get_url_from_file_id($fse_info['avatar_file_id']); } $page_path = self::assemblePath($project_id, 'misc'); $about_page = Page::getByPath($page_path); $type_handle = 'member:markdown_safe:' . $fse_info['user_name'] . ':primary:none'; $section_content = sprintf(self::OWNER_MARKDOWN_TEXT, FSEInfo::getPersonalHomeLink($fse_info, true), FSEInfo::getPersonalHomeLink($fse_info), $fse_info['avatar_url'], ProjectInfo::$mRoleDescriptions[substr($project_id, -2)]['owner'], h5($fse_info['self_desc'])); $section_manager = new DocSectionManager(); $res = $section_manager->addNewSection($fse_info['fse_id'], $about_page->getCollectionID(), 'Members', $project_id, 'misc', 'na', 'na', 'na', $type_handle, '', $section_content, '[]'); }
/** * @return \yii\db\ActiveQuery */ public function getProjectInfo() { return $this->hasOne(ProjectInfo::className(), ['id' => 'project_info_id']); }
* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * 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.'); require_once 'helpers/fsen/DocSectionManager.php'; $home_long_desc = trim(ProjectInfo::getDomainLongDesc($project_id, 'home')); if (mb_strlen($home_long_desc) > 15) { $alert_content = DocSectionManager::safeMarkdown2HTML($home_long_desc); ?> <header class="project-alert-banner alert alert-dismissible fade in" role='alert'> <?php echo $alert_content; ?> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> </header> <?php } ?>
<li><a href="<?php echo ProjectInfo::assemblePath($project_id, 'home'); ?> "><?php echo ProjectInfo::getDomainName($project_id, 'home'); ?> </a></li> <li><a href="<?php echo ProjectInfo::assemblePath($project_id, $domain_handle); ?> "><?php echo ProjectInfo::getDomainName($project_id, $domain_handle); ?> </a></li> <li class="active"><?php echo ProjectInfo::getVolumeName($project_id, $domain_handle, $volume_handle); ?> </li> </ol> </nav> <?php include 'inc/project_main_areas.php'; if ($project_shortname != SYSTEM_PROJECT_SHORTNAME) { include 'inc/project_footer.php'; } include 'inc/footer.php'; include 'inc/status-bar.php'; ?> </div>
<h1> <?php echo h5($c->getCollectionName()); ?> </h1> <p class="lead"> <?php echo h5($c->getCollectionDescription()); ?> </p> </div> </header> <?php if ($project_shortname != SYSTEM_PROJECT_SHORTNAME) { $domain_long_desc = ProjectInfo::getDomainLongDesc($project_id, $domain_handle); $domain_long_desc = DocSectionManager::safeMarkdown2HTML($domain_long_desc); ?> <header class="text-center project-subpage-desc"> <span class="glyphicon glyphicon-circle-info big-glyph text-major-default"></span><?php echo $domain_long_desc; ?> </header> <?php } ?> <article class="formal-content" lang="<?php echo $doc_lang; ?> ">
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); }
echo '<a href="' . $thd['chapter_handle'] . '">' . h5($thd['chapter_name']) . '</a>' . PHP_EOL; } ?> </li> <?php } ?> </ul> <ul class="list-group"> <li class="list-group-item list-group-item-info"> <?php echo t('Normal Q&A'); ?> </li> <?php $normal_threads = ProjectInfo::getNormalThreads($project_id, $domain_handle, $volume_handle, $part_handle); foreach ($normal_threads as $thd) { ?> <li class="list-group-item"> <span class="badge"><?php echo $thd['nr_sections'] - 1; ?> </span> <?php if ($thd['chapter_handle'] == $chapter_handle) { echo h5($thd['chapter_name']) . PHP_EOL; } else { echo '<a href="' . $thd['chapter_handle'] . '">' . h5($thd['chapter_name']) . '</a>' . PHP_EOL; } ?> </li>
<?php echo t('Other Blogs'); ?> </h3> </header> <?php if (count($normal_blogs) > 0) { ?> <ul class="list-group"> <?php foreach ($normal_blogs as $blg) { ?> <li class="list-group-item"> <p> <a href="<?php echo ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $blg['chapter_handle']); ?> "><?php echo h5($blg['chapter_name']); ?> </a> </p> </li> <?php } ?> </ul> <?php } ?>
?> </p> </li> <?php } ?> </ul> <?php } ?> </div><!-- col-md-8 --> <div class="col-md-4"> <?php $top_authors = ProjectInfo::getTopBlogAuthors($doc_lang); if (count($top_authors) > 0) { ?> <header> <h1> <?php echo t('Top Blog Authors'); ?> </h1> </header> <ul class="list-group"> <?php foreach ($top_authors as $ta) { ?> <li class="list-group-item">
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); }
fclose($fp); unset($fp); } $curr_fse_id = $_SESSION['FSEInfo']['fse_id']; if ($author_id != $curr_fse_id) { $error_info = t('You are not the author of this section.'); } else { $author_name_info = FSEInfo::getNameInfo($author_id); $filename = DocSectionManager::getSectionContentPath($section_id, $current_ver_code, 'html'); $html_content = file_get_contents($filename); if ($html_content == false || $author_name_info == false) { $error_info = t('Bad author or section content.'); } else { $project_id = $section_info['project_id']; $doc_lang = substr($project_id, -2); $project_info = ProjectInfo::getBasicInfo($project_id); if ($project_info == false) { $error_info = t('Bad project'); } else { $uh = Loader::helper('concrete/urls'); $bt = BlockType::getByHandle('document_section'); $form_action = $uh->getBlockTypeToolsURL($bt) . '/new_comment.php'; $delete_action = $uh->getBlockTypeToolsURL($bt) . '/delete_comment.php'; $fetch_earlier_action = $uh->getBlockTypeToolsURL($bt) . '/fetch_earlier_action_comments.php'; $form_token = hash_hmac('md5', time(), $section_id); $_SESSION['formToken4CommentSection'] = $form_token; unset($uh); unset($bt); } } }
$ret_info->status = 'success'; $nr = 0; foreach ($sections as $pst) { if ($nr >= $nr_requested) { break; } $author_info = FSEInfo::getNameInfo($pst['author_id']); if ($author_info == false) { continue; } $comments = DocSectionManager::getCachedComments($domain_handle, $pst['id']); if (count($comments) == 0) { continue; } $plain_content = DocSectionManager::getPlainContent($pst['id'], $pst['curr_ver_code']); $link = ProjectInfo::assemblePath($pst['project_id'], $pst['domain_handle'], $pst['volume_handle'], $pst['part_handle'], $pst['chapter_handle']); $link .= '#section-' . $pst['id']; if (strlen($plain_content['title']) == 0) { $page = Page::getByID($pst['page_id']); $plain_content['title'] = $page->getCollectionName(); } $ret_info->detail .= ' <div class="panel panel-default"> <div class="panel-body"> <div class="media" style="margin-top:15px"> <a class="media-left" href="' . FSEInfo::getPersonalHomeLink($author_info) . '"> <img class="middle-avatar" src="' . $author_info['avatar_url'] . '" alt="' . $author_info['nick_name'] . '"> </a> <div class="media-body"> <h4 class="media-heading"> <a href="' . $link . '">' . h5($plain_content['title']) . '</a>
<header> <h1> <?php echo t('Top Projects'); ?> </h1> </header> <?php $db = Loader::db(); $projects = $db->getAll("SELECT * FROM fsen_projects WHERE doc_lang=? AND project_id NOT LIKE 'sys-__' ORDER BY heat_level DESC LIMIT 10", array($doc_lang)); if (count($projects) > 0) { ?> <ul class="list-group"> <?php foreach ($projects as $p) { $icon_url = ProjectInfo::getIconURL($p['icon_file_id']); $link = "/{$doc_lang}/project/" . $p['project_id']; $owner_info = FSEInfo::getNameInfo($p['fse_id']); ?> <li class="list-group-item"> <div class="media"> <a class="media-left" href="<?php echo $link; ?> "> <img class="middle-icon" src="<?php echo $icon_url; ?> " alt="Project Icon"> </a> <div class="media-body" style="width:100%">
$display_order = 100; foreach ($fses as $fse) { echo '=> Adding blog home page for ' . $fse['user_name'] . '...'; if ($fse['def_locale'] == 'zh_CN') { $doc_lang = 'zh'; $all_blogs_page = $zh_blogs_page; $page_desc = $fse['nick_name'] . '的博客'; } else { $doc_lang = 'en'; $all_blogs_page = $en_blogs_page; $page_desc = 'Blogs of ' . $fse['nick_name']; } $sys_project_id = SYSTEM_PROJECT_SHORTNAME . '-' . $doc_lang; $db->Execute("INSERT IGNORE fsen_project_doc_volume_parts\n (project_id, domain_handle, volume_handle, part_handle, part_name, part_desc, required, display_order)\nVALUES (?, 'document', 'blog', ?, ?, ?, 1, ?)", array($sys_project_id, $fse['user_name'], $fse['nick_name'], $page_desc, $display_order)); $page = ProjectInfo::getProjectPage($sys_project_id, 'document', 'blog', $fse['user_name']); if ($page == false) { $page = ProjectInfo::addPartPage($sys_project_id, 'document', $all_blogs_page, $fse['user_name'], $fse['nick_name'], $page_desc); echo 'Created.<br/>'; } else { echo 'Existed.<br/>'; } flush(); ob_flush(); $display_order += 1; // use system default for blog page $page->update(array('cCacheFullPageContent' => -1, 'cCacheFullPageContentOverrideLifetime' => '0', 'cCacheFullPageContentLifetimeCustom' => 0)); $page = Page::getByPath("/{$doc_lang}/engineer/" . $fse['user_name']); // short cache for the personal page. $page->update(array('cCacheFullPageContent' => 1, 'cCacheFullPageContentOverrideLifetime' => 'custom', 'cCacheFullPageContentLifetimeCustom' => 10)); } Cache::flush();
?> " class="tab-item"><span class="glyphicon glyphicon-book"></span></a> <a <?php echo $domain_handle == 'download' ? 'class="active"' : ''; ?> href="<?php echo ProjectInfo::assemblePath($project_id, 'download'); ?> " class="tab-item"><span class="glyphicon glyphicon-download"></span></a> <a <?php echo $domain_handle == 'home' ? 'class="active"' : ''; ?> href="<?php echo ProjectInfo::assemblePath($project_id, 'home'); ?> " class="tab-item"><span class="glyphicon glyphicon-home"></span></a> <?php if ($domain_handle != 'home') { ?> <img src="<?php echo get_url_from_file_id($project_info['icon_file_id'], '/files/images/icon-fsen-144.png'); ?> "/ alt="Logo Icon" /> <h1><?php echo h5($project_info['name']); ?> </h1>
?> ">« <?php echo h5($name); ?> </a> </li> <?php } if ($idx_curr_part == count($parts) - 1) { ?> <li class="next disabled"> <a href="#">»</a> </li> <?php } else { $href = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $parts[$idx_curr_part + 1]['part_handle']); $name = $parts[$idx_curr_part + 1]['part_name']; ?> <li class="next"> <a href="<?php echo $href; ?> "><?php echo h5($name); ?> »</a> </li> <?php } ?> </ul>
} else { if (!in_array($domain_handle, ProjectInfo::$mDomainList)) { $error_info = t('Bad request.'); } else { $project_info = ProjectInfo::getBasicInfo($project_id); if ($project_info == false) { $error_info = t('Bad project'); } else { $fse_id = $_SESSION['FSEInfo']['fse_id']; $user_rights = ProjectInfo::getUserRights($project_id, $fse_id); $c = Page::getByID($page_id); $a = Area::get($c, $_REQUEST['areaHandle']); if (!is_object($a)) { $error_info = t('Bad request!'); } else { if (($user_right = ProjectInfo::getUserEditRight($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle, $fse_id)) != 0) { switch ($user_right) { case ProjectInfo::EDIT_PAGE_USER_BANNED: $error_info = t('You are banned currently due to the violation against the site policy!'); break; case ProjectInfo::EDIT_PAGE_USER_NO_RIGHT: $error_info = t('You have no right to edit this blog!'); break; default: $error_info = t('Bad request!'); break; } } } } }
} 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 > $section_info['max_ver_code']) { $error_info = t('Bad request!'); } else { $project_id = $section_info['project_id']; $project_info = ProjectInfo::getBasicInfo($project_id); if ($project_info == false) { $error_info = t('Bad project'); } else { if (($user_right = ProjectInfo::getUserEditRight($project_id, $domain_handle, $section_info['volume_handle'], $section_info['part_handle'], $section_info['chapter_handle'], $_SESSION['FSEInfo']['fse_id'])) != 0) { switch ($user_right) { case ProjectInfo::EDIT_PAGE_USER_BANNED: $error_info = t('You are banned currently due to the violation against the site policy!'); break; case ProjectInfo::EDIT_PAGE_USER_NO_RIGHT: $error_info = t('You have no right to edit this section!'); break; default: $error_info = t('Bad request!'); break; } } else { $filename = DocSectionManager::getSectionContentPath($section_id, $current_ver_code, 'org'); $fp = fopen($filename, "r"); if ($fp) {
} $volumes = $db->getAll("SELECT * FROM fsen_project_doc_volumes\n\tWHERE project_id=? AND domain_handle=? ORDER BY display_order", array($project_id, $d['domain_handle'])); foreach ($volumes as $v) { $volume_path = ProjectInfo::assemblePath($project_id, $d['domain_handle'], $v['volume_handle']); $volume_page = Page::getByPath($volume_path); if ($volume_page->getCollectionID() == false) { $volume_page = ProjectInfo::addVolumePage($project_id, $domain_page, $d['domain_handle'], $v['volume_handle'], $v['volume_name'], $v['volume_desc']); echo ' Added volume page for '; echo $v['volume_handle']; echo '<br/>'; flush(); ob_flush(); } $parts = $db->getAll("SELECT * FROM fsen_project_doc_volume_parts\nWHERE project_id=? AND domain_handle=? AND volume_handle=? ORDER BY display_order", array($project_id, $d['domain_handle'], $v['volume_handle'])); foreach ($parts as $p) { $part_path = ProjectInfo::assemblePath($project_id, $d['domain_handle'], $v['volume_handle'], $p['part_handle']); $part_page = Page::getByPath($volume_path); if ($part_page->getCollectionID() == false) { $part_page = ProjectInfo::addPartPage($project_id, $d['domain_handle'], $volume_page, $p['part_handle'], $p['part_name'], $p['part_desc']); echo ' Add part page for '; echo $p['part_handle']; echo '<br/>'; flush(); ob_flush(); } } } } } Cache::flush(); exit(0);
<?php $parts = ProjectInfo::getAllParts($project_id, $domain_handle, $volume_handle); foreach ($parts as $prt) { $latest_chapters = ProjectInfo::getLatestChapters($project_id, $domain_handle, $volume_handle, $prt['part_handle']); ?> <li class="list-group-item"> <ul class="list-group"> <li class="list-group-item"> <span class="badge"><?php echo $prt['nr_chapters']; ?> </span> <h3 class="list-group-item-heading"> <a href="<?php echo ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $prt['part_handle']); ?> "><?php echo h5($prt['part_name']); ?> </a></h3> <p class="list-group-item-text"><?php echo h5($prt['part_desc']); ?> </p> </li> <?php if (count($latest_chapters) > 0) { foreach ($latest_chapters as $cpt) { $author_info = FSEInfo::getNameInfo($cpt['fse_id']); ?>
$error_info = t('You are not signed in.'); } else { if ($domain_handle != 'misc') { $error_info = t('Bad domain or volume.'); } else { $form_action = "/fse_settings/projects/add_new_member"; $c = Page::getByID($_REQUEST['cID']); $a = Area::get($c, $_REQUEST['areaHandle']); if (!is_object($a)) { $error_info = t('Bad request!'); } else { $project_info = ProjectInfo::getBasicInfo($project_id); if ($project_info == false) { $error_info = t('Bad project!'); } else { if (substr(ProjectInfo::getUserRights($project_id, $_SESSION['FSEInfo']['fse_id']), 0, 1) != 't') { $error_info = t('You have no right to add new member to this project!'); } } } } } ?> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"> <span aria-hidden="true">×</span> <span class="sr-only"><?php echo t('Close'); ?> </span>
$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) { $error_info = t('Bad project'); } else { $curr_fse_id = $_SESSION['FSEInfo']['fse_id']; $user_rights = ProjectInfo::getUserRights($project_id, $curr_fse_id); if (($section_info['status'] == DocSectionManager::SS_ADMIN_DELETED || $section_info['status'] == DocSectionManager::SS_ADMIN_SHIELDED) && $user_rights[2] != 't') { $error_info = t('You have no right to recover a deleted/shielded post by the administrator.'); } else { if ($user_rights[2] != 't' && $section_info['author_id'] != $curr_fse_id) { $error_info = t('You have no right to recover the post.'); } } } $form_action = "/fse_settings/projects/recover_post"; } } } else { $error_info = t('Bad Request!'); } }
public function update() { $txt = Loader::helper('text'); $user_name = $this->post('userName'); $email_box = $txt->sanitize($this->post('emailBox')); $nick_name = $txt->sanitize($this->post('nickName')); $avatar_file_id = (int) $txt->sanitize($this->post('avatarFileID')); $self_desc = $txt->sanitize($this->post('selfDesc')); $public_email = $txt->sanitize($this->post('publicEmail')); $public_url = $txt->sanitize($this->post('publicURL')); $public_org = $txt->sanitize($this->post('publicORG')); $location_country = $txt->sanitize($this->post('locationCountry')); $location_province = $txt->sanitize($this->post('locationProvince')); $location_district = $txt->sanitize($this->post('locationDistrict')); if (!fse_try_to_login()) { header("location:/fse_login"); } if ($_SESSION['FSEInfo']['user_name'] != $user_name) { $this->set('error', t('Session expired or system error!')); return; } if (!preg_match("/^[\\w-]+([.+][\\w-]+)*@[\\w-]+(\\.[\\w-]+)+\$/", $email_box)) { $this->set('error', t('Bad email address!')); return; } if (!preg_match("/^[\\x{2E80}-\\x{9FFF}\\x{A000}-\\x{A4FF}\\x{AC00}-\\x{D7FF}\\x{F900}-\\x{FFFD}\\w_]{2,30}\$/u", $nick_name)) { $this->set('error', t('Bad nickname!')); return; } if ($self_desc == "") { $self_desc = NULL; } if ($public_email == "") { $public_email = NULL; } else { if (!preg_match("/^[\\w-]+([.+][\\w-]+)*@[\\w-]+(\\.[\\w-]+)+\$/", $public_email)) { $this->set('error', t('Bad public email!')); return; } } if ($public_url == "") { $public_url = NULL; } else { if (!preg_match("/^(http|https):\\/\\/[^\\s]*\$/", $public_url)) { $this->set('error', t('Bad public URL!')); return; } } if ($public_org == "") { $public_org = NULL; } foreach (array($location_country, $location_province, $location_district) as $location) { $fragments = explode(":", $location, 2); if (!preg_match("/^[0-9]*\$/", $fragments[0]) || strlen($fragments[1]) < 2) { $this->set('error', t('Bad location!')); return; } } $db = Loader::db(); if ($email_box != $_SESSION['FSEInfo']['email_box']) { $res = $db->getOne("SELECT user_name FROM fse_basic_profiles WHERE email_box=?", array($email_box)); if ($res !== NULL) { $this->set('error', t('Duplicated email address!')); return; } $res = $db->Execute("UPDATE fse_basic_profiles SET email_verified=0 WHERE user_name=?", array($user_name)); $hash_value = hash_hmac("md5", microtime() . rand(), $email_box); $db->Execute("REPLACE INTO fse_email_box_validation_hashes (email_box, hash_value, update_time)\n\tVALUES (?, ?, NOW())", array($email_box, $hash_value)); $url_validate_email = BASE_URL . "/fse_validate_email/{$hash_value}"; $text_validate_email = t(' You have changed your primary email address, please click the following link to verify the new email address: %s ', $url_validate_email); } else { $text_validate_email = ""; } $res = $db->Execute("UPDATE fse_basic_profiles\n\tSET email_box=?, nick_name=?, avatar_file_id=?, self_desc=?, public_email=?, public_url=?, public_org=?,\n\t\tlocation_country=?, location_province=?, location_district=?\n\tWHERE user_name=?", array($email_box, $nick_name, $avatar_file_id, $self_desc, $public_email, $public_url, $public_org, $location_country, $location_province, $location_district, $user_name)); if (preg_match("/^zh/i", $_SESSION['FSEInfo']['def_locale'])) { $doc_lang = 'zh'; } else { $doc_lang = 'en'; } $_SESSION['FSEInfo']['email_box'] = $email_box; $_SESSION['FSEInfo']['nick_name'] = $nick_name; $_SESSION['FSEInfo']['avatar_file_id'] = $avatar_file_id; $_SESSION['FSEInfo']['location_country'] = $location_country; $_SESSION['FSEInfo']['location_province'] = $location_province; $_SESSION['FSEInfo']['location_district'] = $location_district; $_SESSION['FSEInfo']['self_desc'] = $self_desc; $_SESSION['FSEInfo']['public_email'] = $public_email; $_SESSION['FSEInfo']['public_url'] = $public_url; $_SESSION['FSEInfo']['public_org'] = $public_org; $_SESSION['FSEInfo']['avatar_url'] = get_url_from_file_id($avatar_file_id, '/files/images/icon-def-avatar.png'); $_SESSION['FSEInfo']['small_avatar_url'] = get_thumbnail_url_from_file_id($avatar_file_id, '/files/images/icon-def-avatar-small.png'); FSEInfo::onUpdateProfile($_SESSION['FSEInfo'], $doc_lang); ProjectInfo::onUpdatePersonalProfile($_SESSION['FSEInfo'], $doc_lang); $url_profile = BASE_URL . "/{$doc_lang}/engineer/{$user_name}"; $location_country = substr(strstr($location_country, ':'), 1); $location_province = substr(strstr($location_province, ':'), 1); $location_district = substr(strstr($location_district, ':'), 1); $email_subject = t('[FSEN] Your profile has changed!'); $email_body = t('Dear %s, This is a notification from FSEN (FullStackEngineer.Net) for the change of your profile: * Nickname: %s * Primary Email: %s * Public Email: %s * URL: %s * Orgnization: %s * Location: %s %s %s * Self Description: %s %s You can click the following link to visit your personal homepage at FSEN: %s Thanks, Your friends at FSEN', $nick_name, $nick_name, $email_box, $public_email, $public_url, $public_org, $location_country, $location_province, $location_district, $self_desc, $text_validate_email, $url_profile); $mh = Loader::helper('mail'); $mh->setSubject($email_subject); $mh->setBody($email_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(); $this->set('success', t('Your personal profile changed!')); }