本文整理汇总了PHP中at_insert_id函数的典型用法代码示例。如果您正苦于以下问题:PHP at_insert_id函数的具体用法?PHP at_insert_id怎么用?PHP at_insert_id使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了at_insert_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addGroup
/**
* Adding a group
* @param int the group type specified in the table, social_groups_types
* @param string name of the group
* @param string description of the group
* @param int privacy setting, public is 0, private is 1. Public means everyone can see the message board and users. Private is the opposite
* @return the id of this new group if succeded, false otherwise.
*/
function addGroup($type_id, $name, $description, $privacy)
{
global $addslashes;
$type_id = intval($type_id);
$name = $addslashes($name);
$description = $addslashes($description);
$privacy = intval($privacy);
$member_id = $_SESSION['member_id'];
$sql = "INSERT INTO %ssocial_groups (`member_id`, `type_id`, `name`, `description`, `privacy`, `created_date`, `last_updated`) VALUES (%d, %d, '%s', '%s', %d, NOW(), NOW())";
$result = queryDB($sql, array(TABLE_PREFIX, $member_id, $type_id, $name, $description, $privacy));
$group_id = at_insert_id();
if ($result > 0) {
//add it to the group member table
$sql = "INSERT INTO %ssocial_groups_members (group_id, member_id) VALUES (%d, %d)";
$result = queryDB($sql, array(TABLE_PREFIX, $group_id, $_SESSION['member_id']));
if ($result > 0) {
$act = new Activity();
$str1 = _AT('has_added_group', '<a href="' . url_rewrite(AT_SOCIAL_BASENAME . 'groups/view.php?id=' . $group_id) . '">' . htmlentities_utf8($name)) . '</a>';
$act->addActivity($member_id, $str1);
unset($act);
}
return $group_id;
}
return false;
}
示例2: init_test_result_questions
function init_test_result_questions($test_id, $is_random, $num_questions, $mid)
{
$sql = "INSERT INTO %stests_results VALUES (NULL, %d, '%s', NOW(), '', 0, NOW(), 0)";
$result = queryDB($sql, array(TABLE_PREFIX, $test_id, $mid));
$result_id = at_insert_id();
if ($is_random) {
// Retrieve 'num_questions' question_id randomly from those who are related to this test_id
$non_required_questions = array();
$required_questions = array();
$sql = "SELECT question_id, required FROM %stests_questions_assoc WHERE test_id=%d";
$rows_questions = queryDB($sql, array(TABLE_PREFIX, $test_id));
foreach ($rows_questions as $row) {
if ($row['required'] == 1) {
$required_questions[] = $row['question_id'];
} else {
$non_required_questions[] = $row['question_id'];
}
}
$num_required = count($required_questions);
if ($num_required < max(1, $num_questions)) {
shuffle($non_required_questions);
$required_questions = array_merge($required_questions, array_slice($non_required_questions, 0, $num_questions - $num_required));
}
$random_id_string = implode(',', $required_questions);
$sql = "SELECT TQ.*, TQA.* FROM %stests_questions TQ INNER JOIN %stests_questions_assoc TQA USING (question_id) WHERE TQ.course_id=%d AND TQA.test_id=%d AND TQA.question_id IN (%s) ORDER BY TQ.question_id";
$rows_questions = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $_SESSION['course_id'], $test_id, $random_id_string));
} else {
$sql = "SELECT TQ.*, TQA.* FROM %stests_questions TQ INNER JOIN %stests_questions_assoc TQA USING (question_id) WHERE TQ.course_id=%d AND TQA.test_id=%d ORDER BY TQA.ordering, TQA.question_id";
$rows_questions = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $_SESSION['course_id'], $test_id));
}
// $sql either gets a random set of questions (if $test_row['random']) ordered by 'question_id'
// or the set of all questions for this test (sorted by 'ordering').
foreach ($rows_questions as $row) {
$sql = "INSERT INTO %stests_answers VALUES (%d, %d, %d, '', '', '')";
$result = queryDB($sql, array(TABLE_PREFIX, $result_id, $row['question_id'], $_SESSION['member_id']));
}
return $result_id;
}
示例3: date
$_POST['postal'] = $addslashes($_POST['postal']);
$_POST['city'] = $addslashes($_POST['city']);
$_POST['province'] = $addslashes($_POST['province']);
$_POST['country'] = $addslashes($_POST['country']);
$_POST['phone'] = $addslashes($_POST['phone']);
if (defined('AT_EMAIL_CONFIRMATION') && AT_EMAIL_CONFIRMATION) {
$status = AT_STATUS_UNCONFIRMED;
} else {
$status = AT_STATUS_STUDENT;
}
$now = date('Y-m-d H:i:s');
// we use this later for the email confirmation.
/* insert into the db */
$sql = "INSERT INTO %smembers \n\t\t (login,\n\t\t password,\n\t\t email,\n\t\t website,\n\t\t first_name,\n\t\t second_name,\n\t\t last_name,\n\t\t dob,\n\t\t gender,\n\t\t address,\n\t\t postal,\n\t\t city,\n\t\t province,\n\t\t country,\n\t\t phone,\n\t\t status,\n\t\t preferences,\n\t\t creation_date,\n\t\t language,\n\t\t inbox_notify,\n\t\t private_email,\n\t\t last_login)\n\t\t VALUES ('{$_POST['login']}',\n\t\t '{$_POST['password']}',\n\t\t '{$_POST['email']}',\n\t\t '{$_POST['website']}',\n\t\t '{$_POST['first_name']}',\n\t\t '{$_POST['second_name']}',\n\t\t '{$_POST['last_name']}', \n\t\t '{$dob}', \n\t\t '{$_POST['gender']}', \n\t\t '{$_POST['address']}',\n\t\t '{$_POST['postal']}',\n\t\t '{$_POST['city']}',\n\t\t '{$_POST['province']}',\n\t\t '{$_POST['country']}', \n\t\t '{$_POST['phone']}', \n\t\t {$status}, \n\t\t '{$_config['pref_defaults']}', \n\t\t '{$now}',\n\t\t '{$_SESSION['lang']}', \n\t\t {$_config['pref_inbox_notify']}, \n\t\t {$_POST['private_email']}, \n\t\t '0000-00-00 00:00:00')";
$result = queryDB($sql, array(TABLE_PREFIX)) or die(at_db_error());
$m_id = at_insert_id($db);
if (!$result) {
require AT_INCLUDE_PATH . 'header.inc.php';
$msg->addError('DB_NOT_UPDATED');
$msg->printAll();
require AT_INCLUDE_PATH . 'footer.inc.php';
exit;
}
if (isset($master_list_sql)) {
queryDB($master_list_sql, array(TABLE_PREFIX, $student_id, $student_pin));
}
//reset login attempts
if ($result) {
$sql = "DELETE FROM %smember_login_attempt WHERE login='%s'";
queryDB($sql, array(TABLE_PREFIX, $_POST['login']));
}
示例4: importQTI
function importQTI($question)
{
global $msg;
if ($question['question'] == '') {
$msg->addError(array('EMPTY_FIELDS', _AT('question')));
}
//Multiple answer can have 0+ answers, in the QTIImport.class, if size(answer) < 2, answer will be came a scalar.
//The following code will change $question[answer] back to a vector.
$question['answer'] = $question['answers'];
if (!$msg->containsErrors()) {
$choice_new = array();
// stores the non-blank choices
$answer_new = array();
// stores the associated "answer" for the choices
foreach ($question['choice'] as $choiceNum => $choiceOpt) {
$choiceOpt = validate_length($choiceOpt, 255);
$choiceOpt = escapeSQLValue(trim($choiceOpt));
$question['answer'][$choiceNum] = intval($question['answer'][$choiceNum]);
if ($choiceOpt == '') {
/* an empty option can't be correct */
$question['answer'][$choiceNum] = 0;
} else {
/* filter out empty choices/ remove gaps */
$choice_new[] = $choiceOpt;
if (in_array($choiceNum, $question['answer'])) {
$answer_new[] = 1;
} else {
$answer_new[] = 0;
}
if ($question['answer'][$choiceNum] != 0) {
$has_answer = TRUE;
}
}
}
if ($has_answer != TRUE) {
$hidden_vars['required'] = htmlspecialchars($question['required']);
$hidden_vars['feedback'] = htmlspecialchars($question['feedback']);
$hidden_vars['question'] = htmlspecialchars($question['question']);
$hidden_vars['category_id'] = htmlspecialchars($question['category_id']);
for ($i = 0; $i < count($choice_new); $i++) {
$hidden_vars['answer[' . $i . ']'] = htmlspecialchars($answer_new[$i]);
$hidden_vars['choice[' . $i . ']'] = htmlspecialchars($choice_new[$i]);
}
$msg->addConfirm('NO_ANSWER', $hidden_vars);
} else {
//add slahes throughout - does that fix it?
$question['answer'] = $answer_new;
$question['choice'] = $choice_new;
$question['answer'] = array_pad($question['answer'], 10, 0);
$question['choice'] = array_pad($question['choice'], 10, '');
$question['feedback'] = str_replace("'", "\\'", escapeSQLValue($question['feedback']));
$question['question'] = str_replace("'", "\\'", escapeSQLValue($question['question']));
$sql_params = array($question['category_id'], $_SESSION['course_id'], $question['feedback'], $question['question'], $question['choice'][0], $question['choice'][1], $question['choice'][2], $question['choice'][3], $question['choice'][4], $question['choice'][5], $question['choice'][6], $question['choice'][7], $question['choice'][8], $question['choice'][9], $question['answer'][0], $question['answer'][1], $question['answer'][2], $question['answer'][3], $question['answer'][4], $question['answer'][5], $question['answer'][6], $question['answer'][7], $question['answer'][8], $question['answer'][9], 'DEFAULT');
$sql = vsprintf(AT_SQL_QUESTION_MULTIANSWER, $sql_params);
$result = queryDB($sql, array());
if ($result > 0) {
return at_insert_id();
}
}
}
}
示例5: createPatchesFilesRecord
/**
* Insert record into table patches_files
* @access private
* @param $patch_files_array Patch information
* @author Cindy Qi Li
*/
function createPatchesFilesRecord($patch_files_array)
{
$sql = "INSERT INTO %spatches_files (patches_id, action, name, location) VALUES (%d, '%s', '%s', '%s' )";
$result = queryDB($sql, array(TABLE_PREFIX, $this->patch_id, $this->patch_id, $patch_files_array['action'], my_add_null_slashes($patch_files_array['name']), my_add_null_slashes($patch_files_array['location'])));
$this->patch_file_id = at_insert_id();
return true;
}
示例6: add_update_course
//.........这里部分代码省略.........
} else {
$instructor = $_SESSION['member_id'];
if (!$course_data['course']) {
$course_quotas = "max_quota=" . AT_COURSESIZE_DEFAULT . ", max_file_size=" . AT_FILESIZE_DEFAULT . ",";
$row = $Backup->getRow($initial_content_info[0], $initial_content_info[1]);
if (count($initial_content_info) == 2 && $system_courses[$initial_content_info[1]]['member_id'] == $_SESSION['member_id']) {
if ($MaxCourseSize < $row['contents']['file_manager']) {
$msg->addError('RESTORE_TOO_BIG');
}
} else {
$initial_content_info = intval($course_data['initial_content']);
}
} else {
unset($initial_content_info);
$course_quotas = "max_quota='{$system_courses[$course_data[course]][max_quota]}', max_file_size='{$system_courses[$course_data[course]][max_file_size]}',";
}
}
if ($msg->containsErrors()) {
return FALSE;
}
//display defaults
if (!$course_data['course']) {
$menu_defaults = ",home_links='{$_config['home_defaults']}', main_links='{$_config['main_defaults']}', side_menu='{$_config['side_defaults']}'";
} else {
$menu_defaults = ',home_links=\'' . $system_courses[$course_data['course']]['home_links'] . '\', main_links=\'' . $system_courses[$course_data['course']]['main_links'] . '\', side_menu=\'' . $system_courses[$course_data['course']]['side_menu'] . '\'';
}
$sql = "REPLACE INTO %scourses \n SET \n course_id=%d, \n member_id='%s', \n access='%s', \n title='%s', \n description='%s', \n course_dir_name='%s', \n cat_id=%d, \n content_packaging='%s', \n notify=%d, \n hide=%d, \n {$course_quotas}\n primary_language='%s',\n created_date='%s',\n rss=%d,\n copyright='%s',\n icon='%s',\n banner='%s',\n release_date='%s', \n end_date='%s' \n {$menu_defaults}";
$result = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $course_data['instructor'], $course_data['access'], $course_data['title'], $course_data['description'], $course_data['course_dir_name'], $course_data['category_parent'], $course_data['content_packaging'], $course_data['notify'], $course_data['hide'], $course_data['pri_lang'], $course_data['created_date'], $course_data['rss'], $course_data['copyright'], $course_data['icon'], $course_data['banner'], $release_date, $end_date));
if (!$result) {
echo at_db_error();
echo 'DB Error';
exit;
}
$new_course_id = $_SESSION['course_id'] = at_insert_id();
if (isset($isadmin)) {
global $sqlout;
write_to_log(AT_ADMIN_LOG_REPLACE, 'courses', $result, $sqlout);
}
if (isset($isadmin)) {
//get current instructor and unenroll from course if different from POST instructor
$old_instructor = $system_courses[$course_data['course']]['member_id'];
if ($old_instructor != $course_data['instructor']) {
//remove old from course enrollment
$sql = "DELETE FROM %scourse_enrollment WHERE course_id=%d AND member_id=%d";
$result = queryDB($sql, array(TABLE_PREFIX, $course_data['course'], $old_instructor));
global $sqlout;
write_to_log(AT_ADMIN_LOG_DELETE, 'course_enrollment', $result, $sqlout);
}
}
//enroll new instructor
$sql = "REPLACE INTO %scourse_enrollment VALUES (%d, %d, 'y', 0, '" . _AT('instructor') . "', 0)";
$result = queryDB($sql, array(TABLE_PREFIX, $course_data['instructor'], $new_course_id));
if (isset($isadmin)) {
global $sqlout;
write_to_log(AT_ADMIN_LOG_REPLACE, 'course_enrollment', $result, $sqlout);
}
// create the course content directory
$path = AT_CONTENT_DIR . $new_course_id . '/';
@mkdir($path, 0700);
@copy(AT_CONTENT_DIR . 'index.html', AT_CONTENT_DIR . $new_course_id . '/index.html');
// create the course backup directory
$path = AT_BACKUP_DIR . $new_course_id . '/';
@mkdir($path, 0700);
@copy(AT_CONTENT_DIR . 'index.html', AT_BACKUP_DIR . $new_course_id . '/index.html');
/* insert some default content: */
if (!$course_data['course_id'] && $course_data['initial_content'] == '1') {
示例7: trim
} else {
$auto_enroll_id = 0;
}
if (isset($_POST['save']) || isset($_POST['add'])) {
/* insert or update a category */
$name = trim($_POST['name']);
$name = $addslashes($name);
$name = validate_length($name, 50);
if (isset($_POST['add']) && !$_POST['add_ids']) {
$msg->addError('NO_ITEM_SELECTED');
}
if (!$msg->containsErrors()) {
if ($auto_enroll_id == 0) {
$sql = "INSERT INTO %sauto_enroll(associate_string, name) VALUES ('%s', '%s')";
$rows_inserted = queryDB($sql, array(TABLE_PREFIX, get_random_string(6, 10), $name));
$auto_enroll_id = at_insert_id();
write_to_log(AT_ADMIN_LOG_INSERT, 'auto_enroll', $rows_inserted, $sqlout);
} else {
$sql = "UPDATE %sauto_enroll SET name = '%s' WHERE auto_enroll_id = %d";
$rows_updated = queryDB($sql, array(TABLE_PREFIX, $name, $auto_enroll_id));
write_to_log(AT_ADMIN_LOG_UPDATE, 'auto_enroll', $rows_updated, $sqlout);
}
if (isset($_POST['add'])) {
foreach ($_POST['add_ids'] as $elem) {
// unable to determine the purpose of this query
// which always returns $row['cnt'] == 0, during queryDB() testing.
$sql = "SELECT count(*) cnt FROM %sauto_enroll_courses\n\t\t\t\t WHERE auto_enroll_id = %d\n\t\t\t\t AND course_id = %d";
$row = queryDB($sql, array(TABLE_PREFIX, $auto_enroll_id, $elem), TRUE);
if ($row["cnt"] == 0) {
$sql = "INSERT INTO %sauto_enroll_courses (auto_enroll_id, course_id) VALUES (%d, %d)";
$rows_inserted = queryDB($sql, array(TABLE_PREFIX, $auto_enroll_id, $elem));
示例8: date
$num_replies_add = $num_open_replies - $num_close_replies - 1;
for ($i = 0; $i < $num_replies_add; $i++) {
$_POST['body'] .= '[/reply]';
}
$_POST['body'] .= "\n" . '[op]mods/_standard/forums/forum/view.php?fid=' . $_POST['fid'] . SEP . 'pid=' . $_POST['parent_id'] . SEP . 'page=' . $_POST['page'] . '#' . $_POST['reply'];
$_POST['body'] .= '[/op][/reply]';
}
/* use this value instead of NOW(), because we want the parent post to have the exact */
/* same date. and not a second off if that may happen */
/* this fails however */
$now = date('Y-m-d H:i:s');
$sql_subject = $addslashes($_POST['subject']);
$sql_body = $addslashes($_POST['body']);
$sql = "INSERT INTO %sforums_threads VALUES (NULL, %d, %d, %d, '%s', 0, '%s', '%s', NOW(), 0, 0)";
$result = queryDB($sql, array(TABLE_PREFIX, $_POST['parent_id'], $_SESSION['member_id'], $_POST['fid'], $now, $sql_subject, $sql_body, $now));
$this_id = at_insert_id();
/* Increment count for posts in forums table in database */
$sql = "UPDATE %sforums SET num_posts=num_posts+1, last_post='%s' WHERE forum_id=%d";
$result = queryDB($sql, array(TABLE_PREFIX, $now, $_POST['fid']));
// If there are subscribers to this forum, send them an email notification
$subscriber_email_list = array();
// list of subscribers array('email', 'full_name')
$subscriber_list = '';
$enrolled = array();
// get list of student enrolled in this course
// This needs to be replaced with a tool to clean forum subscriptions when unenrolling
$sql = "SELECT member_id from %scourse_enrollment WHERE course_id = %d AND approved = 'y'";
$rows_enrolled = queryDB($sql, array(TABLE_PREFIX, $_SESSION['course_id']));
foreach ($rows_enrolled as $row) {
$enrolled[] = $row['member_id'];
}
示例9: _AT
}
if ($_POST['percentage_from'][0] == '') {
$empty_fields[] = _AT('percentage_from') . ' at line 1';
}
if ($_POST['percentage_to'][0] == '') {
$empty_fields[] = _AT('percentage_to') . ' at line 1';
}
if (!empty($empty_fields)) {
$msg->addError(array('EMPTY_FIELDS', implode(', ', $empty_fields)));
}
if (!$msg->containsErrors()) {
$_POST['scale_name'] = $addslashes($_POST['scale_name']);
if ($action == "add") {
$sql = "INSERT INTO %sgrade_scales (member_id, scale_name, created_date) VALUES ( %d, '%s', now())";
$result = queryDB($sql, array(TABLE_PREFIX, $_SESSION["member_id"], $_POST["scale_name"]));
$grade_scale_id = at_insert_id();
} else {
if ($action == "edit" && isset($_POST["grade_scale_id"])) {
$grade_scale_id = $_POST["grade_scale_id"];
$sql = "UPDATE %sgrade_scales SET scale_name = '%s' WHERE grade_scale_id = %d";
$result = queryDB($sql, array(TABLE_PREFIX, $_POST["scale_name"], $grade_scale_id));
// clean up scale details for new insertions
$sql = "DELETE FROM %sgrade_scales_detail WHERE grade_scale_id = %d";
$result = queryDB($sql, array(TABLE_PREFIX, $grade_scale_id));
}
}
for ($i = 0; $i < 10; $i++) {
if ($_POST['scale_value'][$i] != "") {
$_POST['scale_value'][$i] = $addslashes(trim($_POST['scale_value'][$i]));
$_POST['percentage_from'][$i] = intval($_POST['percentage_from'][$i]);
$_POST['percentage_to'][$i] = intval($_POST['percentage_to'][$i]);
示例10: header
}
$msg->addFeedback('CANCELLED');
header('Location: ' . $_last_visited_page);
exit;
} else {
if (isset($_POST['submit'])) {
$guest_name = $addslashes(trim($_POST["guest_name"]));
$organization = $addslashes(trim($_POST["organization"]));
$location = $addslashes(trim($_POST["location"]));
$role = $addslashes(trim($_POST["role"]));
$focus = $addslashes(trim($_POST["focus"]));
if ($guest_name != "" || $organization != "" || $location != "" || $role != "" || $focus != "") {
$guest_id = get_next_guest_id();
$sql = "INSERT INTO %sguests (guest_id, name, organization, location, role, focus)\n VALUES ('%s', '%s', '%s', '%s', '%s', '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $guest_id, $guest_name, $organization, $location, $role, $focus));
$result_id = at_insert_id();
}
$gid_str = isset($guest_id) ? SEP . "gid=" . $guest_id : "";
if (isset($cid)) {
$gid_str .= SEP . 'cid=' . $cid;
}
global $_base_href;
if ($test_row['display']) {
# header('Location: '.url_rewrite('mods/_standard/tests/take_test_q.php?tid='.$tid.$gid_str, AT_PRETTY_URL_IS_HEADER));
header('Location: ' . $_base_href . 'mods/_standard/tests/take_test_q.php?tid=' . $tid . $gid_str);
} else {
#header('Location: '.url_rewrite('mods/_standard/tests/take_test.php?tid='.$tid.$gid_str, AT_PRETTY_URL_IS_HEADER));
header('Location: ' . $_base_href . 'mods/_standard/tests/take_test.php?tid=' . $tid . $gid_str);
}
exit;
}
示例11: implode
$missing_fields = implode(', ', $missing_fields);
$msg->addError(array('EMPTY_FIELDS', $missing_fields));
}
if (!$msg->containsErrors()) {
$_POST['type_title'] = $addslashes($_POST['type_title']);
$_POST['prefix'] = $addslashes($_POST['prefix']);
$_POST['description'] = $addslashes($_POST['description']);
$sql = "INSERT INTO %sgroups_types VALUES (NULL, %d, '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $_SESSION['course_id'], $_POST['type_title']));
$group_type_id = at_insert_id();
$start_index = 0;
for ($i = 0; $i < $num_groups; $i++) {
$group_title = $_POST['prefix'] . ' ' . ($i + 1);
$sql = "INSERT INTO %sgroups VALUES (NULL, %d, '%s', '%s', '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $group_type_id, $group_title, $_POST['description'], $modules));
$group_id = at_insert_id();
$_SESSION['groups'][$group_id] = $group_id;
// call module init scripts:
if (isset($_POST['modules'])) {
foreach ($_POST['modules'] as $mod) {
$module =& $moduleFactory->getModule($mod);
$module->createGroup($group_id);
}
}
if (isset($_POST['fill'])) {
// put students in this group
for ($j = $start_index; $j < min($start_index + $num_students_per_group, $total_students); $j++) {
$sql = "INSERT INTO %sgroups_members VALUES (%d, %d)";
queryDB($sql, array(TABLE_PREFIX, $group_id, $students[$j]));
}
$start_index = $j;
示例12: add_users
function add_users($user_list, $enroll, $course)
{
global $db;
global $msg;
global $_config;
global $addslashes;
require_once AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php';
if (defined('AT_EMAIL_CONFIRMATION') && AT_EMAIL_CONFIRMATION) {
$status = AT_STATUS_UNCONFIRMED;
} else {
$status = AT_STATUS_STUDENT;
}
foreach ($user_list as $student) {
if (!$student['remove']) {
$student['uname'] = $addslashes($student['uname']);
$student['email'] = $addslashes($student['email']);
$student['fname'] = $addslashes($student['fname']);
$student['lname'] = $addslashes($student['lname']);
if (!$student['exists']) {
$sql = "INSERT INTO %smembers \n\t\t\t\t (login,\n\t\t\t\t password,\n\t\t\t\t email,\n\t\t\t\t first_name,\n\t\t\t\t last_name,\n\t\t\t\t gender,\n\t\t\t\t status,\n\t\t\t\t preferences,\n\t\t\t\t creation_date,\n\t\t\t\t language,\n\t\t\t\t inbox_notify,\n\t\t\t\t private_email)\n\t\t\t\t VALUES \n\t\t\t\t ('{$student['uname']}',\n\t\t\t\t '" . sha1($student[uname]) . "',\n\t\t\t\t '{$student['email']}',\n\t\t\t\t '{$student['fname']}',\n\t\t\t\t '{$student['lname']}',\n\t\t\t\t 'n', \n\t\t\t\t {$status}, \n\t\t\t\t '{$_config['pref_defaults']}', \n\t\t\t\t NOW(),\n\t\t\t\t '{$_config['default_language']}', \n\t\t\t\t {$_config['pref_inbox_notify']}, \n\t\t\t\t 1)";
$result = queryDB($sql, array(TABLE_PREFIX));
if ($result == 1) {
$m_id = at_insert_id();
$student['exists'] = _AT('import_err_email_exists');
$role = "Student";
$sql = "INSERT INTO %scourse_enrollment (member_id, course_id, approved, last_cid, role) VALUES (%d, %d, '%s', 0, '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $m_id, $course, $enroll, $role));
if ($result > 0) {
$enrolled_list .= '<li>' . $student['uname'] . '</li>';
if (defined('AT_EMAIL_CONFIRMATION') && AT_EMAIL_CONFIRMATION) {
$sql = "SELECT email, creation_date FROM %smembers WHERE member_id=%d";
$row = queryDB($sql, array(TABLE_PREFIX, $m_id), TRUE);
$code = substr(md5($row['email'] . $row['creation_date'] . $m_id), 0, 10);
// send email here.
$confirmation_link = AT_BASE_HREF . 'confirm.php?id=' . $m_id . SEP . 'm=' . $code;
$subject = $_config['site_name'] . ': ' . _AT('email_confirmation_subject');
$body = _AT(array('new_account_enroll_confirm', $_SESSION['course_title'], $confirmation_link)) . "\n\n";
} else {
$subject = $_config['site_name'] . ': ' . _AT('account_information');
$body = _AT(array('new_account_enroll', AT_BASE_HREF, $_SESSION['course_title'])) . "\n\n";
}
//$body .= SITE_NAME.': '._AT('account_information')."\n";
$body .= _AT('web_site') . ' : ' . AT_BASE_HREF . "\n";
$body .= _AT('login_name') . ' : ' . $student['uname'] . "\n";
$body .= _AT('password') . ' : ' . $student['uname'] . "\n";
$mail = new ATutorMailer();
$mail->From = $_config['contact_email'];
$mail->AddAddress($student['email']);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->Send();
unset($mail);
} else {
$already_enrolled .= '<li>' . $student['uname'] . '</li>';
}
} else {
//$msg->addError('LIST_IMPORT_FAILED');
}
} else {
if (!$student['err_disabled']) {
$sql = "SELECT member_id FROM %smembers WHERE email='%s'";
$rows_members = queryDB($sql, array(TABLE_PREFIX, $student['email']), TRUE);
$role = "Student";
if (count($rows_members) > 0) {
$row = $rows_members;
$m_id = $row['member_id'];
$sql = "INSERT INTO %scourse_enrollment (member_id, course_id, approved, last_cid, role) VALUES (%d, %d, '%s', 0, '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $m_id, $course, $enroll, $role));
if ($result > 0) {
$enrolled_list .= '<li>' . $student['uname'] . '</li>';
} else {
$sql = "REPLACE INTO %scourse_enrollment (member_id, course_id, approved, last_cid, role) VALUES (%d, %s, '%s', 0, '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $m_id, $course, $enroll, $role));
$enrolled_list .= '<li>' . $student['uname'] . '</li>';
}
$subject = $_config['site_name'] . ': ' . _AT('email_confirmation_subject');
$body = _AT(array('enrol_message_approved', $_SESSION['course_title'], AT_BASE_HREF)) . "\n\n";
$body .= _AT('web_site') . ' : ' . AT_BASE_HREF . "\n";
$body .= _AT('login_name') . ' : ' . $student['uname'] . "\n";
$mail = new ATutorMailer();
$mail->From = $_config['contact_email'];
$mail->AddAddress($student['email']);
$mail->Subject = $subject;
$mail->Body = $body;
$mail->Send();
unset($mail);
}
} else {
if ($student['err_disabled']) {
$not_enrolled_list .= '<li>' . $student['uname'] . '</li>';
}
}
}
}
}
if ($already_enrolled) {
$feedback = array('ALREADY_ENROLLED', $already_enrolled);
$msg->addFeedback($feedback);
}
if ($enrolled_list) {
//.........这里部分代码省略.........
示例13: urldecode
}
if ($rtn_pair[0] == 'expire') {
$expire_threshold = $rtn_pair[1];
}
if ($rtn_pair[0] == 'error') {
$error = urldecode($rtn_pair[1]);
}
}
if ($error != '') {
$msg->addError(array('TILE_AUTHENTICATION_FAIL', $error));
header('Location: ' . AT_BASE_HREF . 'mods/_core/imscp/index.php');
exit;
} else {
$sql = "INSERT INTO %soauth_client_servers\n\t\t\t\t\t (oauth_server, consumer_key, consumer_secret, expire_threshold, create_date)\n\t\t\t\t\t VALUES ('%s', '%s',\n\t\t\t\t\t '%s', %d, now())";
$result = queryDB($sql, array(TABLE_PREFIX, $_config['transformable_uri'], $consumer_key, $consumer_secret, $expire_threshold));
$oauth_server_id = at_insert_id();
}
} else {
$oauth_server_id = $row['oauth_server_id'];
$consumer_key = $row['consumer_key'];
$consumer_secret = $row['consumer_secret'];
$expire_threshold = $row['expire_threshold'];
}
$consumer = new OAuthConsumer($consumer_key, $consumer_secret, $client_callback_url);
// 2. get request token
$req_req = OAuthRequest::from_consumer_and_token($consumer, NULL, "GET", AT_TILE_OAUTH_REQUEST_TOKEN_URL);
$req_req->sign_request($sig_method, $consumer, NULL);
$oauth_server_response = file_get_contents($req_req);
// handle OAUTH request token response
foreach (explode('&', $oauth_server_response) as $rtn) {
$rtn_pair = explode('=', $rtn);
示例14: fs_copy_file
/**
* copies a file to another workspace.
* currently only used for submitting assignments.
**/
function fs_copy_file($file_id, $src_owner_type, $src_owner_id, $dest_owner_type, $dest_owner_id, $dest_folder_id)
{
$sql = "SELECT file_name, file_size, description FROM %sfiles WHERE file_id=%d AND owner_type=%d AND owner_id=%d";
$row = queryDB($sql, array(TABLE_PREFIX, $file_id, $src_owner_type, $src_owner_id), TRUE);
if (count($row) == 0) {
return false;
}
$sql = "INSERT INTO %sfiles VALUES (NULL, %d, %d, %d, %d, 0, NOW(), 0, 0, '%s', %d, '%s')";
$result = queryDB($sql, array(TABLE_PREFIX, $dest_owner_type, $dest_owner_id, $_SESSION['member_id'], $dest_folder_id, $row['file_name'], $row['file_size'], $row['description']));
$id = at_insert_id();
$src_file = fs_get_file_path($file_id) . $file_id;
$dest_file = fs_get_file_path($id) . $id;
copy($src_file, $dest_file);
}
示例15: _AT
if (empty($_POST['title'])) {
$missing_fields[] = _AT('title');
}
if (empty($_POST['courses'])) {
$missing_fields[] = _AT('courses');
}
if ($missing_fields) {
$missing_fields = implode(', ', $missing_fields);
$msg->addError(array('EMPTY_FIELDS', $missing_fields));
}
$_POST['edit'] = intval($_POST['edit']);
if (!$msg->containsErrors()) {
//add forum
$sql = "INSERT INTO %sforums (title, description, mins_to_edit) VALUES ('%s','%s', %d)";
$result = queryDB($sql, array(TABLE_PREFIX, $_POST['title'], $_POST['description'], $_POST['edit']));
$forum_id = at_insert_id();
global $sqlout;
write_to_log(AT_ADMIN_LOG_INSERT, 'forums', $result, $sqlout);
//for each course, add an entry to the forums_courses table
foreach ($_POST['courses'] as $course) {
$sql = "INSERT INTO %sforums_courses VALUES (%d,%d)";
$result = queryDB($sql, array(TABLE_PREFIX, $forum_id, $course));
global $sqlout;
write_to_log(AT_ADMIN_LOG_INSERT, 'forums_courses', $result, $sqlout);
}
$msg->addFeedback('ACTION_COMPLETED_SUCCESSFULLY');
if ($course == "0") {
$msg->addFeedback('FORUM_POSTING');
}
header('Location: ' . AT_BASE_HREF . 'mods/_standard/forums/admin/forums.php');
exit;