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> </li>
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']); ?> <li class="list-group-item"> <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>
<a href="' . $link . '">' . h5($plain_content['title']) . '</a> <span class="label label-primary">' . $pst['nr_comments'] . '</span> <span class="label label-success">' . $pst['nr_praise'] . '</span> </h4> <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>';
<a href="<?php echo ProjectInfo::assemblePath($project_id, $domain_handle, $vlm['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> </div> <?php if (count($latest_chapter) > 0) { $author_info = FSEInfo::getNameInfo($latest_chapter['fse_id']); ?> <div class="col-md-6 wrap-on-xs"> <span class="badge"><?php echo $latest_chapter['nr_sections'] - 1; ?> </span> <h4 class="list-group-item-heading"> <a href="<?php echo "{$page_path}/" . $vlm['volume_handle'] . '/' . $prt['part_handle'] . '/' . $latest_chapter['chapter_handle']; ?> "><?php echo h5($latest_chapter['chapter_name']); ?> </a> </h4>
public static function setUserAsOwner($project_id, $fse_id) { $fse_name_info = FSEInfo::getNameInfo($fse_id); if ($fse_name_info == false) { return false; } $rights = 'tttttttttttttttt'; $db = Loader::db(); $query = "INSERT INTO fsen_project_members VALUES (?, ?, ?, ?, ?, ?, NOW(), NOW()) ON DUPLICATE KEY\n\tUPDATE member_roles=?, member_rights=?"; $res = $db->Execute($query, array($project_id, $fse_id, $fse_name_info['nick_name'], 'The owner of the project', 'owner', $rights, 'owner', $rights)); return true; }
<div class="tab-content"> <!-- Projects --> <div role="tabpanel" class="tab-pane fade in active" id="divProjects"> <div class="v-seperator"> </div> <?php if ($nr_projects > 0) { ?> <ul class="list-group"> <?php foreach ($my_projects as $prj) { $info = ProjectInfo::getBasicInfo($prj['project_id']); $icon_url = ProjectInfo::getIconURL($info['icon_file_id']); $link = '/' . $info['doc_lang'] . '/project/' . $info['project_id']; $owner_info = FSEInfo::getNameInfo($info['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"> <span class="badge"><?php echo $info['heat_level'];
$path_frags = explode ('/', trim ($page_path, '/')); $project_id = $path_frags[1]; */ if ($currentVerCode > 0) { $last_author_id = $author_id; $last_edit_time = $edit_time; $last_author_name_info = FSEInfo::getNameInfo($last_author_id); $full_content_file_name = DocSectionManager::getSectionContentPath($sectionID, 0, 'org'); $fp = fopen($full_content_file_name, "r"); if ($fp) { $author_id = trim(fgets($fp)); $fstats = fstat($fp); $edit_time = date('Y-m-d H:i', $fstats['mtime']) . ' CST'; fclose($fp); unset($fp); $author_name_info = FSEInfo::getNameInfo($author_id); } } $request_part = "?fsenDocLang={$doc_lang}&domainHandle={$domainHandle}§ionID={$sectionID}¤tVerCode={$currentVerCode}"; $visible_class = 'visible-on-logged-in'; $link_style = false; $type_fragments = explode(":", $type_handle); switch ($type_fragments[0]) { case 'post-question': $panel_style = 'panel-primary'; $link_style = 'bg-primary'; break; case 'post-answer': $panel_style = 'panel-success'; break; case 'post-note':
if (!preg_match("/^[a-f0-9]{32}\$/", $section_id)) { $ret_info->detail = t('Bad section'); echo $json->encode($ret_info); exit(0); } $comments = DocSectionManager::getEarlierActionComments($domain_handle, $section_id, $oldest_comment_id); if (count($comments) == 0) { $ret_info->status = 'nodata'; $ret_info->detail = t('No data available'); echo $json->encode($ret_info); exit(0); } $ret_info->status = 'success'; $ret_info->detail = ''; foreach ($comments as $comment) { $author_name_info = FSEInfo::getNameInfo($comment['author_id']); if ($author_name_info == false) { continue; } 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>
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!')); }