public static function getUserEditRight($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle, $fse_id) { $user_rights = self::getUserRights($project_id, $fse_id); $project_shortname = substr($project_id, 0, strlen($project_id) - 3); if ($project_shortname == SYSTEM_PROJECT_SHORTNAME && $domain_handle == 'document' && $volume_handle == 'blog' && $part_handle != 'na' && $chapter_handle != 'na') { $author_info = FSEInfo::getBasicProfile($part_handle); if ($author_info == false) { return self::EDIT_PAGE_USER_ERROR; } if ($fse_id == $author_info['fse_id']) { if ($user_info['status'] > 0) { return self::EDIT_PAGE_USER_BANNED; } } else { if ($user_rights[1] != 't') { return self::EDIT_PAGE_USER_NO_RIGHT; } } } else { if ($user_rights[1] != 't') { return self::EDIT_PAGE_USER_NO_RIGHT; } } return 0; }
<p> ' . $plain_content['content'] . ' </p> <hr/>'; foreach ($comments as $comment) { $author_info = FSEInfo::getNameInfo($comment['author_id']); if ($author_info == false) { continue; } $replied_name_info = false; if (preg_match("/^[0-9a-f]{32}\$/", $comment['replied_author_id'])) { $replied_name_info = FSEInfo::getNameInfo($comment['replied_author_id']); } $ret_info->detail .= ' <div class="media" style="margin-top:5px;"> <a class="media-left" href="' . FSEInfo::getPersonalHomeLink($author_info) . '"> <img class="small-avatar" src="' . $author_info['avatar_url'] . '" alt="' . $author_info['nick_name'] . '"> </a> <div class="media-body"> <p style="line-height: 1; margin-top:0; margin-bottom:0;"> <small><strong class="text-info">' . $author_info['nick_name'] . '</strong></small> </p> <p style="line-height: 1; margin-top:0; margin-bottom:0;"> <small>'; if ($replied_name_info != false) { $ret_info->detail .= t('Reply to ') . '<strong class="text-info">' . $replied_name_info['nick_name'] . ': </strong>'; } $ret_info->detail .= h5($comment['body']) . '</small> </p> </div>
?> </h1> </header> <ul class="list-group"> <?php foreach ($top_authors as $ta) { ?> <li class="list-group-item"> <h4 class="list-group-item-heading"> <a href="<?php echo "/{$doc_lang}/blog/" . $ta['part_handle']; ?> "> <?php $author_info = FSEInfo::getBasicProfile($ta['part_handle']); echo h5($author_info['nick_name']); ?> </a> </h4> </li> <?php } ?> </ul> <?php } ?> </div><!-- col-md-4 -->
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 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); }
$nr_comments = 1; } $nr = 0; $ret_info->detail = '<ul class="list-group" style="width:300px;">'; foreach ($comments as $comment) { if ($nr >= $nr_comments) { break; } $author_name_info = FSEInfo::getNameInfo($comment['author_id']); if ($author_name_info == false) { continue; } $author_info = FSEInfo::getBasicProfile($author_name_info['user_name']); unset($replied_name_info); if (preg_match("/^[0-9a-f]{32}\$/", $comment['replied_author_id'])) { $replied_name_info = FSEInfo::getNameInfo($comment['replied_author_id']); if ($replied_name_info == false) { unset($replied_name_info); } } $ret_info->detail .= ' <li class="list-group-item"> <p> <small><strong class="text-info">' . $author_info['nick_name'] . '</strong>' . (isset($replied_name_info) ? t('Reply to ') . '<strong class="text-info">' . $replied_name_info['nick_name'] . '</strong>' : '') . ': ' . h5($comment['body']) . ' </small> </p> </li>'; $nr++; } $ret_info->detail .= '</ul>'; echo $json->encode($ret_info);
} if ($comment['action'] == DocSectionManager::COMMENT_ACTION_PRAISE) { $body = '<span class="glyphicon glyphicon-thumbs-up" style="color:#eb7350;"></span>'; } else { $body = ''; } $ret_info->detail .= ' <li id="liComment' . $comment['id'] . '" class="list-group-item" data-value="' . $comment['id'] . '"> <div class="media"> <span class="badge">14</span> <a class="media-left" href="#"> <img class="small-avatar" src="' . $author_name_info['avatar_url'] . '" alt="avatar"> </a> <section class="media-body"> <h6 class="media-heading"> ' . FSEInfo::getPersonalHomeLink($author_name_info, true) . ' </h6> <p> <small>' . $body . '</small> </p> </section><!-- media-body --> <footer class="comment-block"> <div class="block-left"> <p> <span class="glyphicon glyphicon-clock"></span> ' . $comment['create_time'] . ' </p> </div> <div class="block-right"> <ul> <li><a class="reply-comment" href="#" data-name="' . $author_name_info['nick_name'] . '"
public function delete_member() { if (!fse_try_to_login()) { header("location:/fse_login"); return; } $project_id = $this->post('projectID'); $area_handle = $this->post('areaHandle'); $domain_handle = $this->post('domainHandle'); $volume_handle = $this->post('volumeHandle'); $part_handle = $this->post('partHandle'); $chapter_handle = $this->post('chapterHandle'); $section_id = $this->post('sectionID'); $member_username = $this->post('memberUsername'); $page_path = ProjectInfo::assemblePath($project_id, $domain_handle, $volume_handle, $part_handle, $chapter_handle); $page_id = Page::getByPath($page_path)->getCollectionID(); if ($page_id <= 0) { header('Location: /'); return; } if (!fse_try_to_login()) { set_page_action_status($page_id, t('Delete Member'), 'error', t('You do not sign in or session expired.')); header("Location: {$page_path}"); return; } $curr_fse_id = $_SESSION['FSEInfo']['fse_id']; $curr_rights = ProjectInfo::getUserRights($project_id, $curr_fse_id); if ($curr_rights[0] != 't') { set_page_action_status($page_id, t('Delete Member'), 'error', t('You have no right to edit member roles.')); header("Location: {$page_path}"); return; } $fse_info = FSEInfo::getBasicProfile($member_username); if ($fse_info == false) { set_page_action_status($page_id, t('Delete Member'), 'error', t('No such user!')); header("Location: {$page_path}"); return; } ProjectInfo::removeMember($project_id, $fse_info['fse_id']); $section_manager = new DocSectionManager(); $res = $section_manager->deleteSection($project_id, $domain_handle, $section_id); if ($res != DocSectionManager::EC_OK) { set_page_action_status($page_id, t('Delete Member'), 'error', t('Failed to add/edit member roles: %s', $section_manager->getErrorMessage($res))); header("Location: {$page_path}"); return; } set_page_action_status($page_id, t('Delete Member'), 'success', t('Succeed to delete the member.')); header("Location: {$page_path}"); }
?> "> <img class="small-avatar" src="<?php echo $author_name_info['avatar_url']; ?> " alt="avatar"> </a> <section class="media-body"> <h6 class="media-heading"> <?php echo FSEInfo::getPersonalHomeLink($author_name_info, true); ?> </h6> <p><small> <?php echo (isset($replied_name_info) ? t('Reply to ') . FSEInfo::getPersonalHomeLink($replied_name_info, true) . ': ' : '') . h5($comment['body']); ?> </small></p> </section><!-- media-body --> <footer class="comment-block"> <div class="block-left"> <p> <span class="glyphicon glyphicon-clock"></span> <?php echo $comment['create_time']; ?> </p> </div> <div class="block-right"> <ul> <li><a class="reply-comment" href="#" data-name="<?php
?> "> <img class="small-avatar" src="<?php echo $author_name_info['avatar_url']; ?> " alt="avatar"> </a> <section class="media-body"> <h6 class="media-heading"> <?php echo FSEInfo::getPersonalHomeLink($author_name_info, true); ?> </h6> <p><small> <?php echo (isset($replied_name_info) ? t('Reply to ') . FSEInfo::getPersonalHomeLink($replied_name_info, true) . ': ' : '') . $body; ?> </small></p> </section><!-- media-body --> <footer class="comment-block"> <div class="block-left"> <p> <span class="glyphicon glyphicon-clock"></span> <?php echo $comment['create_time']; ?> </p> </div> <div class="block-right"> <ul> <li><a class="reply-comment" href="#" data-name="<?php
echo '<a class="thumbnail" href="' . $fv->getURL() . '">'; echo '<img class="attached-file" src="' . $fv->getThumbnail(1, false) . '"' . 'title="' . htmlspecialchars($fv->getTitle(), ENT_QUOTES | ENT_HTML5) . '"' . 'data-desc="' . htmlspecialchars($fv->getDescription(), ENT_QUOTES | ENT_HTML5) . '"' . 'data-type="' . $fv->getGenericTypeText() . '"' . 'data-mime-type="' . $fv->getMimeType() . '"' . 'data-value="' . $fv->getURL() . '" />' . PHP_EOL; echo '</a>' . PHP_EOL; echo '</section>' . PHP_EOL; } } echo '</div>' . PHP_EOL; } ?> </section> <footer class="section-block"> <section class="author-info"> <p> <?php echo FSEInfo::getPersonalHomeLink($author_name_info, true) . PHP_EOL; ?> <?php echo $edit_time . PHP_EOL; ?> </p> </section> <section class="block-left <?php echo $visible_class; ?> "> <p> <a title="<?php echo $edit_dialog_title; ?> " class="<?php
$page_id = $_REQUEST['cID']; $project_id = $_REQUEST['projectID']; $domain_handle = $_REQUEST['domainHandle']; $volume_handle = $_REQUEST['volumeHandle']; $part_handle = $_REQUEST['partHandle']; $project_shortname = substr($project_id, 0, strlen($project_id) - 3); $doc_lang = substr($project_id, -2); if (!fse_try_to_login()) { $error_info = t('You are not signed in.'); } else { if ($project_shortname != SYSTEM_PROJECT_SHORTNAME || $domain_handle != 'document' || $volume_handle != 'blog') { $error_info = t('Bad Request!'); } else { $form_action = "/fse_settings/projects/add_new_blog"; $fse_id = $_SESSION['FSEInfo']['fse_id']; $user_info = FSEInfo::getBasicProfile($part_handle); $user_rights = ProjectInfo::getUserRights($project_id, $fse_id); if ($user_rights[1] == 't' && $user_info['fse_id'] != $fse_id) { $error_info = t('Only the author of this blog zone can add new blog!'); } else { if ($user_info['fse_id'] != $fse_id) { $error_info = t('You are not the author of this blog zone!'); } else { if ($user_info['email_verified'] == 0) { $error_info = t('Your primary email address has not been verified. Please verify it first in your Personal Settings page.'); } else { if ($user_info['status'] > 0) { $error_info = t('You are banned currently due to the violation against the site policy!'); } } }
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!')); }
$attached_files = $json->decode($attached_files); if (is_array($attached_files) == false) { $error_info = t('Section content file is bad or lost!'); } else { 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!'); } } } } }
echo FSEInfo::getPersonalHomeLink($author_name_info, true, $link_style); ?> <span class="glyphicon glyphicon-clock"></span> <?php echo $edit_time; ?> </small> </p> <?php if (isset($last_author_id)) { ?> <p> <small><span class="glyphicon glyphicon-edit"></span> <?php echo FSEInfo::getPersonalHomeLink($last_author_name_info, true, $link_style); ?> <span class="glyphicon glyphicon-clock"></span> <?php echo $last_edit_time; ?> </small> </p> <?php } ?> </div> </div> </div> </div>
if (!preg_match("/^[0-9a-f]{32}\$/", $hashed_passwd)) { $ret_info->detail = t('Bad password!'); echo $json->encode($ret_info); exit(0); } $db = Loader::db(); $row = $db->getRow("SELECT * FROM fse_basic_profiles WHERE user_name=?", array($user_name)); if (count($row) == 0 || $row['hashed_passwd'] != $hashed_passwd) { $ret_info->detail = t('Bad user or password!'); echo $json->encode($ret_info); exit(0); } $_SESSION['FSEInfo'] = $row; $db->Execute("UPDATE fse_basic_profiles SET last_login_time=NOW() WHERE user_name=?", array($user_name)); $ret_info->status = 'ok'; if (strlen($redirect_url)) { $ret_info->detail = $redirect_url; } else { $ret_info->detail = FSEInfo::getPersonalHomeLink($row); } if ($save_passwd != "on") { echo $json->encode($ret_info); exit(0); } setcookie("FSEID", $row['fse_id'], time() + 3600 * 24 * 7, DIR_REL . '/'); setcookie("HashedPasswd", $hashed_passwd, time() + 3600 * 24 * 7, DIR_REL . '/'); echo $json->encode($ret_info); exit(0); ?>
" alt="Project Icon"> </a> <div class="media-body"> <span class="badge"><?php echo $info['heat_level']; ?> </span> <h4 class="media-heading"><a href="<?php echo $link; ?> "><?php echo h5($info['name']); ?> </a></h4> <h5 class="media-heading"><?php echo FSEInfo::getPersonalHomeLink($owner_info, true); ?> </h5> <p><?php echo h5($info['short_desc']); ?> </p> </div> </div> </li> <?php } ?> </ul> <?php } else {
<span class="badge"><?php echo $cpt['nr_sections'] - 1; ?> </span> <h4 class="list-group-item-heading"> <a href="<?php echo "{$page_path}/" . $prt['part_handle'] . '/' . $cpt['chapter_handle']; ?> "><?php echo h5($cpt['chapter_name']); ?> </a> </h4> <p class="list-group-item-text"> <?php echo FSEInfo::getPersonalHomeLink($author_info, true); ?> </p> </li> <?php } } ?> </ul> </li> <?php } ?> </ul> </div> <div class="panel-footer">
* 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/FSEInfo.php'; $wiki_id = $_GET['WikiID']; $prefix = substr($wiki_id, 0, 3); if ($prefix == 'FSP') { $project_id = substr($wiki_id, 3); $doc_lang = substr($project_id, -2); header("location:/{$doc_lang}/project/{$project_id}"); exit(0); } else { if ($prefix == 'FSE') { $fse_user_name = substr($wiki_id, 3); $fse_info = FSEInfo::getBasicProfile($fse_user_name); if ($fse_info) { $home_link = FSEInfo::getPersonalHomeLink($fse_info); header("location:{$home_link}"); exit(0); } } else { if ($prefix == 'htt') { header("location:{$wiki_id}"); exit(0); } } } header('location:/');