function getLinkTitle($dataArray) { $html = file_get_html($dataArray['link']); foreach ($html->find('title') as $element) { toPrint_oneMsg('linkTitle', $element->plaintext); } }
function DB_inert_newgroup($dataArray) { $sql = "INSERT INTO p_group(subjectkey,gp_topic,gp_intro,gp_member,gp_orgkey) VALUES ('" . $dataArray['subjectkey'] . "','" . $dataArray['topic'] . "','" . $dataArray['intro'] . "','" . $dataArray['member'] . "','" . $dataArray['orgkey'] . "')"; $sql_result = mysql_query($sql) or die('MySQL query error'); if ($sql_result > 0) { $gp_id = mysql_insert_id(); $_gpKey = "G2014" . $gp_id; $sql2 = "UPDATE p_group SET groupkey='" . $_gpKey . "',edit_date=NOW() WHERE group_id='" . $gp_id . "'"; $sql_result = mysql_query($sql2); toPrint_oneMsg('action', 'success'); $recordStr = 'Result:' . $sql_result . '|Userkey:' . $_SESSION['userkey']; } else { toPrint_oneMsg('action', 'fail'); $recordStr = 'Result:' . $sql_result . '|SQL:' . $sql . '|Userkey:' . $_SESSION['userkey']; } recordlog('InsertGp', 'NA', $recordStr); }
function DB_insert_user_feedback($dataArray) { if (isset($_SESSION['userkey'])) { $_userKey = $_SESSION['userkey']; } else { $_userKey = 'unknown'; } $sql = "INSERT INTO user_feedback(from_userkey,feedback_text,page) VALUES ('" . $_userKey . "','" . $dataArray['feedbackText'] . "','" . $dataArray['location'] . "')"; $sql_result = mysql_query($sql) or die('MySQL query error'); if ($sql_result > 0) { toPrint_oneMsg('action', 'success'); $recordStr = 'Result:' . $sql_result . '|Userkey:' . $_userKey; sendEmail('Admin', $_userKey, $dataArray['feedbackText'] . '<br/>' . $dataArray['location'], 'Feedback From Platform', '*****@*****.**'); } else { $recordStr = 'Result:' . $sql_result . '|SQL:' . $sql . '|Userkey:' . $_userKey; toPrint_oneMsg('action', 'fail'); } recordlog('InsertFeedback', $dataArray['location'], $recordStr); }
function DB_get_post_info($dataArray) { $area = 'p_'; $tableName = $area . 'post'; $tableName_comment = $area . 'post_comment'; $tableName_attach = $area . 'post_attach'; $comment_str = ''; $attach_str = ''; $action = $dataArray['subAction']; toPrint_oneMsg('subAction', $dataArray['subAction']); switch ($action) { case "init": $sql = "Select cp.post_id,cp.postkey,cp.from_userkey,cp.to_key,cp.update_date,cp.create_date,cp.remark,cp.post_topic,cp.post_text,cp.post_attach,cp.num_comment,cp.create_date,up.username,up.userpic FROM " . $tableName . " as cp LEFT JOIN user_profile as up ON cp.from_userkey = up.userkey WHERE cp.enable = '1' AND cp.to_key ='" . $dataArray['to_key'] . "' ORDER BY cp.update_date DESC limit 21"; break; case "more": $sql = "Select cp.post_id,cp.postkey,cp.from_userkey,cp.to_key,cp.update_date,cp.create_date,cp.post_topic,cp.post_text,cp.post_attach,cp.num_comment,cp.create_date,up.username,up.userpic FROM " . $tableName . " as cp LEFT JOIN user_profile as up ON cp.from_userkey = up.userkey WHERE cp.enable = '1' AND cp.to_key ='" . $dataArray['to_key'] . "' AND cp.update_date < '" . $dataArray['getPost_min_editdate'] . "' ORDER BY cp.update_date DESC limit 21"; break; case "update": $sql = "Select cp.post_id,cp.postkey,cp.from_userkey,cp.to_key,cp.update_date,cp.create_date,cp.remark,cp.post_topic,cp.post_text,cp.post_attach,cp.num_comment,cp.create_date,up.username,up.userpic FROM " . $tableName . " as cp LEFT JOIN user_profile as up ON cp.from_userkey = up.userkey WHERE cp.enable = '1' AND cp.to_key ='" . $dataArray['to_key'] . "' AND cp.update_date >= '" . $dataArray['getPost_max_editdate'] . "' ORDER BY cp.update_date DESC limit 21"; break; } //echo($sql); $sql_result = mysql_query($sql); while ($row_data = mysql_fetch_assoc($sql_result)) { $postkey = $row_data['postkey']; if ($row_data['num_comment'] != '0') { $comment_str = ''; $sql2 = "Select cp.postkey,cp.from_userkey,cp.create_date,cp.post_text,up.username,up.userpic FROM " . $tableName_comment . " as cp LEFT JOIN user_profile as up ON cp.from_userkey = up.userkey WHERE cp.from_postkey= '" . $postkey . "' AND cp.enable = '1' ORDER BY cp.create_date ASC"; $sql2_result = mysql_query($sql2); while ($row_data2 = mysql_fetch_assoc($sql2_result)) { $comment_str = $comment_str . toString_multiTagWithoutAttr('comment', $row_data2); } } if ($row_data['post_attach'] != '0') { $attach_str = ''; $sql3 = "Select attach_type,attach_link FROM " . $tableName_attach . " WHERE from_postkey='" . $postkey . "' AND enable = '1' ORDER BY post_attach_id ASC"; $sql3_result = mysql_query($sql3); while ($row_data3 = mysql_fetch_assoc($sql3_result)) { $attach_str = $attach_str . toString_multiTagWithoutAttr('attach', $row_data3); } } toPrint_multiTagWithoutAttr_special('post', $row_data, $comment_str . $attach_str); } $recordStr = 'Result:' . $sql_result . '|Userkey:' . $_SESSION['userkey']; recordlog('GetPost', $dataArray['to_key'], $recordStr); }
function DB_update_editGpInfo($dataArray) { $_userkey = $_SESSION['userkey']; if ($dataArray['editRight'] == 'student') { $sql = "UPDATE p_group SET gp_topic='" . $dataArray['topic'] . "',gp_intro='" . $dataArray['intro'] . "',gp_control='" . $dataArray['control'] . "',subjectkey='" . $dataArray['subjectkey'] . "',edit_userkey='" . $_userkey . "',edit_date=NOW() WHERE groupkey='" . $dataArray['groupkey'] . "'"; } else { $sql = "UPDATE p_group SET gp_topic='" . $dataArray['topic'] . "',gp_intro='" . $dataArray['intro'] . "',gp_control='" . $dataArray['control'] . "',gp_member='" . $dataArray['member'] . "',gp_orgkey='" . $dataArray['orgkey'] . "',subjectkey='" . $dataArray['subjectkey'] . "',edit_userkey='" . $_userkey . "',edit_date=NOW() WHERE groupkey='" . $dataArray['groupkey'] . "'"; } $result = mysql_query($sql); if ($result > 0) { toPrint_oneMsg('action', 'success'); } else { toPrint_oneMsg('action', 'fail'); } $recordStr = 'Result:' . $sql_result . 'SQL:' . $sql . '|:' . $dataArray['groupkey'] . '|Userkey:' . $_userKey; recordlog('editgetGpInfo', $dataArray['groupkey'], $recordStr); }
function DB_select_submitForgetPw($userInfoType, $userInfo, $userMethod, $userHintsAns) { if ($userInfoType == 'email') { $colName = 'ufp.pw_email'; } else { $colName = 'u.login_name'; } $sql = "Select u.login_name,u.login_pw,up.realname,ufp.pw_email,ufp.pw_ques,ufp.pw_ans FROM user_forget_pw AS ufp LEFT JOIN user AS u ON ufp.user_id = u.user_id LEFT JOIN user_profile AS up ON u.user_id = up.user_id WHERE BINARY " . $colName . " = '" . $userInfo . "'"; $sql_result = mysql_query($sql) or die('MySQL query error'); $isExist = mysql_num_rows($sql_result); if ($isExist > 0) { while ($row = mysql_fetch_assoc($sql_result)) { $row['result'] = 'true'; if ($userMethod == 'chooseEmail') { $content = 'Thank you for sign up! Your login informaton:'; $emailName = $row['realname']; $username = $row['realname']; $content = $content . '<p>Login name:' . $row['login_name'] . '</p><p>Login password' . $row['login_pw'] . '</p>'; $subject = 'Learning collaborative and sharing platform'; $content = $content . '<p>Please login to the platform again</p>'; sendEmail($emailName, $username, $content, $subject, $row['pw_email']); toPrint_oneMsg('sendemail', 'true'); toPrint_oneMsg('result', 'true'); } else { if ($userMethod == 'chooseHints') { if ($userHintsAns == $row['pw_ans']) { toPrint_multiTagWithoutAttr('userGetPw', $row); } else { toPrint_oneMsg('hints', 'false'); toPrint_oneMsg('result', 'true'); } } } } $recordStr = 'GetPwSuccess:' . '|userInfoType:' . $userInfoType . '|userInfo:' . $userInfo . '|userMethod:' . $userMethod . '|$userHintsAns:' . $userHintsAns; recordlog('getForgetPw', 'index', $recordStr); return true; } else { $isExist = 'false'; $recordStr = 'GetPwFail:' . '|userInfoType:' . $userInfoType . '|userInfo:' . $userInfo . '|userMethod:' . $userMethod . '|$userHintsAns:' . $userHintsAns; recordlog('getForgetPw', 'index', $recordStr); toPrint_oneMsg('result', $isExist); return false; } }