$login = gcms::getVars($_SESSION, 'login', array('id' => 0, 'status' => -1, 'email' => '', 'password' => '')); // ตรวจสอบค่าที่ส่งมา if ($topic == '' || $url == '' || $login['email'] == '') { $ret['error'] = 'ACTION_ERROR'; $ret['location'] = 'close'; } elseif ($reciever == '') { $ret['ret_share_reciever'] = 'this'; $ret['input'] = 'share_reciever'; } elseif ($_POST['share_antispam'] != $_SESSION[$_POST['antispam']]) { $ret['ret_share_antispam'] = 'this'; $ret['input'] = 'share_antispam'; } else { // ข้อความในอีเมล์ $replace = array(); $replace['/%SENDER%/'] = $login['displayname'] == '' ? $login['email'] : $login['displayname']; $replace['/%URL%/'] = $url; $replace['/%TOPIC%/'] = $topic; // send mail $error = gcms::sendMail(1, 'share', $replace, $reciever); if ($error == '') { unset($_SESSION[$_POST['antispam']]); $ret['error'] = 'EMAIL_SEND_SUCCESS'; } else { $ret['alert'] = rawurlencode($error); } $ret['location'] = 'close'; } } // คืนค่าเป็น JSON echo gcms::array2json($ret); }
// ส่งอีเมล์แจ้งสมาชิก $reciever = array(); foreach (explode(',', $save['reciever']) as $item) { if ($item != -1) { $reciever[$item] = $item; } } if (sizeof($reciever) > 0) { $sql = "SELECT `fname`,`lname`,`email` FROM `" . DB_USER . "` WHERE `status` IN (" . implode(',', $reciever) . ")"; foreach ($db->customQuery($sql) as $item) { // ส่งอีเมล์ $replace = array(); $replace['/%FNAME%/'] = $item['fname']; $replace['/%LNAME%/'] = $item['lname']; $replace['/%URL%/'] = WEB_URL . "/index.php?module={$index['module']}"; gcms::sendMail(1, 'edocument', $replace, $item['email']); } $ret['error'] = 'EDOCUMENT_SAVE_AND_SEND_SUCCESS'; } else { $ret['error'] = 'ADD_COMPLETE'; } } else { $ret['error'] = 'ADD_COMPLETE'; } } else { $db->edit(DB_EDOCUMENT, $id, $save); $ret['error'] = 'EDIT_SUCCESS'; } // ส่งค่ากลับ $ret['location'] = rawurlencode(WEB_URL . "/index.php?module={$index['module']}"); } else {
unset($replace); // สุ่มรหัสผ่านใหม่ $password = gcms::rndname(6); // ข้อมูลอีเมล์ $replace = array(); $replace['/%PASSWORD%/'] = $password; $replace['/%EMAIL%/'] = $item['email']; if ($action == 'activate' || $item['activatecode'] != '') { // activate หรือ ยังไม่ได้ activate $save['activatecode'] = $item['activatecode'] == '' ? gcms::rndname(32) : $item['activatecode']; $replace['/%ID%/'] = $save['activatecode']; // send mail $err = gcms::sendMail(1, 'member', $replace, $item['email']); } else { // send mail $err = gcms::sendMail(3, 'member', $replace, $item['email']); } if ($err == '') { // อัปเดทรหัสผ่านใหม่ $save['password'] = md5($password . $item['email']); // บันทึก $db->edit(DB_USER, $item['id'], $save); } else { echo $err; } } } elseif ($action == 'accept') { // ยอมรับสมาชิกที่เลือก $sql = "UPDATE `" . DB_USER . "` SET `activatecode`='' WHERE `id` IN ({$ids}) AND `fb`='0'"; $db->query($sql); } elseif ($action == 'ban') {
$sql = "SELECT * FROM `" . DB_USER . "` WHERE (`email`='{$email}' OR (`phone1`!='' AND `phone1`='{$email}')) AND `fb`='0' LIMIT 1"; $user = $db->customQuery($sql); if (sizeof($user) == 1) { $user = $user[0]; // สุ่มและอัปเดทรหัสผ่านใหม่ $password = gcms::rndname(6); $save['password'] = md5($password . $user['email']); $db->edit(DB_USER, $user['id'], $save); // ส่งเมล์แจ้งสมาชิก $replace = array(); $replace['/%PASSWORD%/'] = $password; $replace['/%EMAIL%/'] = $user['email']; if ($user['activatecode'] != '') { $replace['/%ID%/'] = $user['activatecode']; // send mail $err = gcms::sendMail(1, 'member', $replace, $user['email']); } else { // send mail $err = gcms::sendMail(3, 'member', $replace, $user['email']); } $ret['alert'] = rawurlencode(sprintf($lng['FORGOT_SUCCESS'], $user['email'])); $ret['location'] = $_POST['modal'] == 'true' ? 'close' : 'back'; } else { $ret['input'] = 'forgot_email'; $ret['error'] = 'EMAIL_NOT_FOUND'; } } } // คืนค่าเป็น JSON echo gcms::array2json($ret); }
$_SESSION['login']['id'] = $lastid; $_SESSION['login']['password'] = $password; // แสดงข้อความตอบรับการสมัครสมาชิก $ret['alert'] = sprintf($lng['NEWREGISTER_NOACTIVATE_ALERT'], $save['email']); // กลับไปแก้ไขข้อมูลอื่นๆ เพิ่มเติม $ret['location'] = $_POST['modal'] != 'true' ? rawurlencode(WEB_URL . '/index.php?module=editprofile&id=' . $lastid) : 'close'; } if ($config['sendmail'] == 1) { // ข้อมูลอีเมล์ $replace = array(); $replace['/%EMAIL%/'] = $save['email']; $replace['/%PASSWORD%/'] = $password; $replace['/%ID%/'] = $save['activatecode']; // send mail $id = $config['user_activate'] == 0 ? 2 : 1; gcms::sendMail($id, 'member', $replace, $save['email']); } // โหลดโมดูลที่ติดตั้ง เพื่อแจ้งการเพิ่มสมาชิกใหม่ให้กับโมดูล define('MAIN_INIT', 'new_register'); $dir = ROOT_PATH . 'modules/'; $f = opendir($dir); while (false !== ($owner = readdir($f))) { if ($owner != '.' && $owner != '..') { if (is_dir($dir . $owner)) { if (is_file($dir . $owner . '/add_member.php')) { include $dir . $owner . '/add_member.php'; } } } } closedir($f);