Advertisement
Guest User

Untitled

a guest
Mar 14th, 2017
1,560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.27 KB | None | 0 0
  1. <?php
  2. /*
  3. * Made by Samerton
  4. * http://worldscapemc.co.uk
  5. *
  6. * License: MIT
  7. */
  8.  
  9. if(!isset($registration_enabled)){
  10. // Registration is disabled
  11. Redirect::to('/');
  12. die();
  13. }
  14.  
  15. // Registration page
  16.  
  17. require('core/integration/uuid.php'); // For UUID stuff
  18. require('core/includes/password.php'); // For password hashing
  19. require('core/includes/validate_date.php'); // For date validation
  20.  
  21. // Are custom usernames enabled?
  22. $custom_usernames = $queries->getWhere("settings", array("name", "=", "displaynames"));
  23. $custom_usernames = $custom_usernames[0]->value;
  24.  
  25. // Is UUID linking enabled?
  26. $uuid_linking = $queries->getWhere('settings', array('name', '=', 'uuid_linking'));
  27. $uuid_linking = $uuid_linking[0]->value;
  28.  
  29. // Is mcassoc enabled?
  30. $account_association = $queries->getWhere('settings', array('name', '=', 'use_mcassoc'));
  31. $account_association = $account_association[0]->value;
  32.  
  33. if(isset($_GET['step']) && isset($_SESSION['mcassoc'])){
  34. // Get site ID
  35. $mcassoc_site_id = $queries->getWhere('settings', array('name', '=', 'sitename'));
  36. $mcassoc_site_id = $mcassoc_site_id[0]->value;
  37.  
  38. $mcassoc_shared_secret = $queries->getWhere('settings', array('name', '=', 'mcassoc_key'));
  39. $mcassoc_shared_secret = $mcassoc_shared_secret[0]->value;
  40.  
  41. $mcassoc_instance_secret = $queries->getWhere('settings', array('name', '=', 'mcassoc_instance'));
  42. $mcassoc_instance_secret = $mcassoc_instance_secret[0]->value;
  43.  
  44. // Initialise
  45. define('MCASSOC', true);
  46.  
  47. $mcassoc = new MCAssoc($mcassoc_shared_secret, $mcassoc_site_id, $mcassoc_instance_secret);
  48. $mcassoc->enableInsecureMode();
  49.  
  50. require('core/integration/run_mcassoc.php');
  51. die();
  52. }
  53.  
  54. // Use recaptcha?
  55. $recaptcha = $queries->getWhere("settings", array("name", "=", "recaptcha"));
  56. $recaptcha = $recaptcha[0]->value;
  57.  
  58. $recaptcha_key = $queries->getWhere("settings", array("name", "=", "recaptcha_key"));
  59. $recaptcha_secret = $queries->getWhere('settings', array('name', '=', 'recaptcha_secret'));
  60.  
  61. // Is email verification enabled?
  62. $email_verification = $queries->getWhere('settings', array('name', '=', 'email_verification'));
  63. $email_verification = $email_verification[0]->value;
  64.  
  65. // Deal with any input
  66. if(Input::exists()){
  67. if(Token::check(Input::get('token'))){
  68. // Valid token
  69.  
  70. if($recaptcha == 'true'){
  71. // Check reCAPCTHA
  72. $url = 'https://www.google.com/recaptcha/api/siteverify';
  73.  
  74. $post_data = 'secret=' . $recaptcha_secret[0]->value . '&response=' . Input::get('g-recaptcha-response');
  75.  
  76. $ch = curl_init($url);
  77. curl_setopt($ch, CURLOPT_POST, 1);
  78. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  79. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  80. curl_setopt($ch, CURLOPT_HEADER, 0);
  81. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  82.  
  83. $result = curl_exec($ch);
  84.  
  85. $result = json_decode($result, true);
  86. } else {
  87. // reCAPTCHA is disabled
  88. $result = array(
  89. 'success' => 'true'
  90. );
  91. }
  92.  
  93. if(isset($result['success']) && $result['success'] == 'true'){
  94. // Validate
  95. $validate = new Validate();
  96.  
  97. $to_validation = array( // Base field validation
  98. 'password' => array(
  99. 'required' => true,
  100. 'min' => 6,
  101. 'max' => 30
  102. ),
  103. 'password_again' => array(
  104. 'matches' => 'password'
  105. ),
  106. 'email' => array(
  107. 'required' => true,
  108. 'min' => 4,
  109. 'max' => 64,
  110. 'unique' => 'users'
  111. ),
  112. 't_and_c' => array(
  113. 'required' => true,
  114. 'agree' => true
  115. ),
  116. 'location' => array(
  117. 'max' => 128
  118. )
  119. );
  120.  
  121. if($recaptcha === "true"){ // check Recaptcha response
  122. $to_validation['g-recaptcha-response'] = array(
  123. 'required' => true
  124. );
  125. }
  126.  
  127. // Validate date of birth
  128. if(Input::get('birthday') && (!validateDate(Input::get('birthday')) || strtotime(Input::get('birthday')) > strtotime('now'))){
  129. // Invalid
  130. $error = '<div class="alert alert-danger">' . $user_language['invalid_date_of_birth'] . '</div>';
  131. } else {
  132. // Valid date of birth
  133. if($uuid_linking == '1'){
  134. if($custom_usernames == "true"){ // validate username and Minecraft name
  135. $to_validation['mcname'] = array(
  136. 'required' => true,
  137. //'isvalid' => true,
  138. 'min' => 3,
  139. 'max' => 20,
  140. 'unique' => 'users'
  141. );
  142. $to_validation['username'] = array(
  143. 'required' => true,
  144. 'min' => 3,
  145. 'max' => 20,
  146. 'unique' => 'users'
  147. );
  148. $mcname = htmlspecialchars(Input::get('mcname'));
  149.  
  150. // Perform validation on Minecraft name
  151. $profile = ProfileUtils::getProfile(str_replace(' ', '%20', $mcname));
  152. $mcname_result = $profile->getProfileAsArray();
  153.  
  154. if(isset($mcname_result['username']) && !empty($mcname_result['username'])){
  155. // Valid
  156. } else {
  157. // Invalid
  158. $invalid_mcname = true;
  159. }
  160.  
  161. } else { // only validate Minecraft name
  162. $to_validation['username'] = array(
  163. 'required' => true,
  164. 'min' => 3,
  165. 'max' => 20,
  166. 'unique' => 'users'
  167. );
  168. $mcname = htmlspecialchars(Input::get('username'));
  169.  
  170. // Perform validation on Minecraft name
  171. $profile = ProfileUtils::getProfile(str_replace(' ', '%20', $mcname));
  172. $mcname_result = $profile->getProfileAsArray();
  173.  
  174. if(isset($mcname_result['username']) && !empty($mcname_result['username'])){
  175. // Valid
  176. } else {
  177. // Invalid
  178. $invalid_mcname = true;
  179. }
  180.  
  181. }
  182. } else {
  183. if($custom_usernames == "true"){ // validate username and Minecraft name
  184. $to_validation['mcname'] = array(
  185. 'required' => true,
  186. 'min' => 3,
  187. 'max' => 20,
  188. 'unique' => 'users'
  189. );
  190. $to_validation['username'] = array(
  191. 'required' => true,
  192. 'min' => 3,
  193. 'max' => 20,
  194. 'unique' => 'users'
  195. );
  196. $mcname = htmlspecialchars(Input::get('mcname'));
  197. } else { // only validate Minecraft name
  198. $to_validation['username'] = array(
  199. 'required' => true,
  200. 'min' => 3,
  201. 'max' => 20,
  202. 'unique' => 'users'
  203. );
  204. $mcname = htmlspecialchars(Input::get('username'));
  205. }
  206. }
  207.  
  208. // Check to see if the Minecraft username was valid
  209. if(!isset($invalid_mcname)){
  210. // Valid, continue with validation
  211. $validation = $validate->check($_POST, $to_validation); // Execute validation
  212.  
  213. if($validation->passed()){
  214. if($uuid_linking == '1'){
  215. if(!isset($mcname_result)){
  216. $profile = ProfileUtils::getProfile(str_replace(' ', '%20', $mcname));
  217. $mcname_result = $profile->getProfileAsArray();
  218. }
  219. if(isset($mcname_result["uuid"]) && !empty($mcname_result['uuid'])){
  220. $uuid = $mcname_result['uuid'];
  221. } else {
  222. $uuid = '';
  223. }
  224. } else {
  225. $uuid = '';
  226. }
  227.  
  228. // Minecraft user account association
  229. if(isset($account_association) && $account_association == '1'){
  230. // MCAssoc enabled
  231. // Get data from database
  232. $mcassoc_site_id = $queries->getWhere('settings', array('name', '=', 'sitename'));
  233. $mcassoc_site_id = $mcassoc_site_id[0]->value;
  234.  
  235. $mcassoc_shared_secret = $queries->getWhere('settings', array('name', '=', 'mcassoc_key'));
  236. $mcassoc_shared_secret = $mcassoc_shared_secret[0]->value;
  237.  
  238. $mcassoc_instance_secret = $queries->getWhere('settings', array('name', '=', 'mcassoc_instance'));
  239. $mcassoc_instance_secret = $mcassoc_instance_secret[0]->value;
  240.  
  241. // Initialise
  242. define('MCASSOC', true);
  243.  
  244. $mcassoc = new MCAssoc($mcassoc_shared_secret, $mcassoc_site_id, $mcassoc_instance_secret);
  245. $mcassoc->enableInsecureMode();
  246.  
  247. require('core/integration/run_mcassoc.php');
  248. die();
  249.  
  250. } else {
  251. // MCAssoc disabled
  252. $user = new User();
  253.  
  254. $ip = $user->getIP();
  255. if(filter_var($ip, FILTER_VALIDATE_IP)){
  256. // Valid IP
  257. } else {
  258. // TODO: Invalid IP, do something else
  259. }
  260.  
  261. $password = password_hash(Input::get('password'), PASSWORD_BCRYPT, array("cost" => 13));
  262. // Get current unix time
  263. $date = new DateTime();
  264. $date = $date->getTimestamp();
  265.  
  266. try {
  267. $code = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 60);
  268. $user->create(array(
  269. 'username' => htmlspecialchars(Input::get('username')),
  270. 'mcname' => $mcname,
  271. 'uuid' => $uuid,
  272. 'password' => $password,
  273. 'pass_method' => 'default',
  274. 'joined' => $date,
  275. 'group_id' => 1,
  276. 'email' => htmlspecialchars(Input::get('email')),
  277. 'reset_code' => $code,
  278. 'lastip' => htmlspecialchars($ip),
  279. 'last_online' => $date,
  280. 'birthday' => date('Y-m-d', strtotime(str_replace('-', '/', htmlspecialchars(Input::get('birthday'))))),
  281. 'location' => htmlspecialchars(Input::get('location'))
  282. ));
  283.  
  284. if($email_verification == '1'){
  285. $php_mailer = $queries->getWhere('settings', array('name', '=', 'phpmailer'));
  286. $php_mailer = $php_mailer[0]->value;
  287.  
  288. if($php_mailer == '1'){
  289. // PHP Mailer
  290. require('core/includes/phpmailer/PHPMailerAutoload.php');
  291. require('core/email.php');
  292.  
  293. $mail = new PHPMailer;
  294. $mail->IsSMTP();
  295. $mail->SMTPDebug = 0;
  296. $mail->Debugoutput = 'html';
  297. $mail->Host = $GLOBALS['email']['host'];
  298. $mail->Port = $GLOBALS['email']['port'];
  299. $mail->SMTPSecure = $GLOBALS['email']['secure'];
  300. $mail->SMTPAuth = $GLOBALS['email']['smtp_auth'];
  301. $mail->Username = $GLOBALS['email']['username'];
  302. $mail->Password = $GLOBALS['email']['password'];
  303. $mail->setFrom($GLOBALS['email']['username'], $GLOBALS['email']['name']);
  304. $mail->From = $GLOBALS['email']['username'];
  305. $mail->FromName = $GLOBALS['email']['name'];
  306. $mail->addAddress(htmlspecialchars(Input::get('email')), htmlspecialchars(Input::get('username')));
  307. $mail->Subject = $sitename . ' - ' . $user_language['register'];
  308.  
  309. // HTML to display in message
  310. $path = join(DIRECTORY_SEPARATOR, array(ROOT_PATH, 'styles', 'templates', $template, 'email', 'register.html'));
  311. $html = file_get_contents($path);
  312.  
  313. $link = 'http://' . $_SERVER['SERVER_NAME'] . '/validate/?c=' . $code;
  314.  
  315. $html = str_replace(array('[Sitename]', '[Register]', '[Greeting]', '[Message]', '[Link]', '[Thanks]'), array($sitename, $user_language['register'], $email_language['greeting'], $email_language['message'], $link, $email_language['thanks']), $html);
  316.  
  317. $mail->msgHTML($html);
  318. $mail->IsHTML(true);
  319. $mail->Body = $html;
  320.  
  321. if(!$mail->send()) {
  322. echo "Mailer Error: " . $mail->ErrorInfo;
  323. die();
  324. } else {
  325. echo "Message sent!";
  326. }
  327. } else {
  328. // PHP mail function
  329. $siteemail = $queries->getWhere('settings', array('name', '=', 'outgoing_email'));
  330. $siteemail = $siteemail[0]->value;
  331.  
  332. $to = Input::get('email');
  333. $subject = $sitename . ' - ' . $user_language['register'];
  334.  
  335. $message = $email_language['greeting'] . PHP_EOL .
  336. $email_language['message'] . PHP_EOL . PHP_EOL .
  337. 'http://' . $_SERVER['SERVER_NAME'] . '/validate/?c=' . $code . PHP_EOL . PHP_EOL .
  338. $email_language['thanks'] . PHP_EOL .
  339. $sitename;
  340.  
  341. $headers = 'From: ' . $siteemail . "\r\n" .
  342. 'Reply-To: ' . $siteemail . "\r\n" .
  343. 'X-Mailer: PHP/' . phpversion();
  344. mail($to, $subject, $message, $headers);
  345. }
  346. } else {
  347. // Email verification disabled
  348. // Redirect straight to verification link
  349. echo '<script>window.location.replace("/validate/?c=' . $code . '");</script>';
  350. die();
  351. }
  352.  
  353. Session::flash('home', '<div class="alert alert-info alert-dismissible"> <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span></button>' . $user_language['registration_check_email'] . '</div>');
  354. Redirect::to('/');
  355. die();
  356.  
  357. } catch(Exception $e){
  358. die($e->getMessage());
  359. }
  360. }
  361. } else {
  362. // Errors
  363. $error = '<div class="alert alert-danger">';
  364. foreach($validation->errors() as $validation_error){
  365.  
  366. if(strpos($validation_error, 'is required') !== false){
  367. // x is required
  368. switch($validation_error){
  369. case (strpos($validation_error, 'username') !== false):
  370. $error .= $user_language['username_required'] . '<br />';
  371. break;
  372. case (strpos($validation_error, 'email') !== false):
  373. $error .= $user_language['email_required'] . '<br />';
  374. break;
  375. case (strpos($validation_error, 'password') !== false):
  376. $error .= $user_language['password_required'] . '<br />';
  377. break;
  378. case (strpos($validation_error, 'mcname') !== false):
  379. $error .= $user_language['mcname_required'] . '<br />';
  380. break;
  381. case (strpos($validation_error, 't_and_c') !== false):
  382. $error .= $user_language['accept_terms'] . '<br />';
  383. break;
  384. case (strpos($validation_error, 'location') !== false):
  385. $error .= $user_language['location_required'] . '<br />';
  386. break;
  387. }
  388.  
  389. } else if(strpos($validation_error, 'minimum') !== false){
  390. // x must be a minimum of y characters long
  391. switch($validation_error){
  392. case (strpos($validation_error, 'username') !== false):
  393. $error .= $user_language['username_minimum_3'] . '<br />';
  394. break;
  395. case (strpos($validation_error, 'mcname') !== false):
  396. $error .= $user_language['mcname_minimum_3'] . '<br />';
  397. break;
  398. case (strpos($validation_error, 'password') !== false):
  399. $error .= $user_language['password_minimum_6'] . '<br />';
  400. break;
  401. case (strpos($validation_error, 'location') !== false):
  402. $error .= $user_language['location_minimum_2'] . '<br />';
  403. break;
  404. }
  405.  
  406. } else if(strpos($validation_error, 'maximum') !== false){
  407. // x must be a maximum of y characters long
  408. switch($validation_error){
  409. case (strpos($validation_error, 'username') !== false):
  410. $error .= $user_language['username_maximum_20'] . '<br />';
  411. break;
  412. case (strpos($validation_error, 'mcname') !== false):
  413. $error .= $user_language['mcname_maximum_20'] . '<br />';
  414. break;
  415. case (strpos($validation_error, 'password') !== false):
  416. $error .= $user_language['password_maximum_30'] . '<br />';
  417. break;
  418. case (strpos($validation_error, 'location') !== false):
  419. $error .= $user_language['location_maximum_128'] . '<br />';
  420. break;
  421. }
  422.  
  423. } else if(strpos($validation_error, 'must match') !== false){
  424. // password must match password again
  425. $error .= $user_language['passwords_dont_match'] . '<br />';
  426.  
  427. } else if(strpos($validation_error, 'already exists') !== false){
  428. // already exists
  429. $error .= $user_language['username_mcname_email_exists'] . '<br />';
  430. } else if(strpos($validation_error, 'not a valid Minecraft account') !== false){
  431. // Invalid Minecraft username
  432. $error .= $user_language['invalid_mcname'] . '<br />';
  433.  
  434. } else if(strpos($validation_error, 'Mojang communication error') !== false){
  435. // Mojang server error
  436. $error .= $user_language['mcname_lookup_error'] . '<br />';
  437.  
  438. }
  439. }
  440. $error .= '</div>';
  441. //$error = '<div class="alert alert-danger">' . $user_language['registration_error'] . '</div>';
  442. }
  443. } else {
  444. // Invalid Minecraft name
  445. $error = '<div class="alert alert-danger">' . $user_language['invalid_mcname'] . '</div>';
  446. }
  447. }
  448.  
  449. } else {
  450. // reCAPTCHA failed
  451. $error = '<div class="alert alert-danger">' . $user_language['invalid_recaptcha'] . '</div>';
  452. }
  453.  
  454. } else {
  455. // Invalid token
  456. Session::flash('register', '<div class="alert alert-danger">' . $admin_language['invalid_token'] . '</div>');
  457. }
  458. }
  459.  
  460. if(isset($error)){
  461. $smarty->assign('REGISTRATION_ERROR', $error);
  462. } else {
  463. $smarty->assign('REGISTRATION_ERROR', '');
  464. }
  465.  
  466. // Generate code for page
  467. $form_content = '
  468. <div class="form-group">
  469. <input type="text" name="username" id="username" autocomplete="off" value="' . escape(Input::get('username')) . '" class="form-control input-lg" placeholder="';
  470. if($custom_usernames == "false"){ $form_content .= $user_language['minecraft_username']; } else { $form_content .= $user_language['username']; }
  471. $form_content .= '" tabindex="1">
  472. </div>
  473. ';
  474. // Custom usernames?
  475. if($custom_usernames !== "false"){
  476. $form_content .= '
  477. <div class="form-group">
  478. <input type="text" name="mcname" id="mcname" autocomplete="off" class="form-control input-lg" placeholder="' . $user_language['minecraft_username'] . '" tabindex="2">
  479. </div>';
  480. }
  481. // Continue
  482. $form_content .= '
  483. <div class="form-group">
  484. <input type="email" name="email" id="email" value="' . escape(Input::get('email')) . '" class="form-control input-lg" placeholder="' . $user_language['email_address'] . '" tabindex="3">
  485. </div>
  486. <div class="form-group">
  487. <input type="text" name="location" id="location" class="form-control input-lg" placeholder="' . $user_language['location'] . '" tabindex="5">
  488. </div>
  489. <div class="row">
  490. <div class="col-xs-12 col-sm-6 col-md-6">
  491. <div class="form-group">
  492. <input type="password" name="password" id="password" class="form-control input-lg" placeholder="' . $user_language['password'] . '" tabindex="6">
  493. </div>
  494. </div>
  495. <div class="col-xs-12 col-sm-6 col-md-6">
  496. <div class="form-group">
  497. <input type="password" name="password_again" id="password_again" class="form-control input-lg" placeholder="' . $user_language['confirm_password'] . '" tabindex="7">
  498. </div>
  499. </div>
  500. </div>
  501. ';
  502. // Recaptcha
  503. if($recaptcha === "true"){
  504. $form_content .= '
  505. <center>
  506. <div class="g-recaptcha" data-sitekey="' . htmlspecialchars($recaptcha_key[0]->value) . '"></div>
  507. </center>
  508. <br />
  509. ';
  510. }
  511. // Continue
  512. $form_content .= '
  513. <div class="row">
  514. <div class="col-xs-4 col-sm-3 col-md-3">
  515. <span class="button-checkbox">
  516. <button type="button" class="btn" data-color="info" tabindex="7"> ' . $user_language['i_agree'] . '</button>
  517. <input type="checkbox" name="t_and_c" id="t_and_c" class="hidden" value="1">
  518. </span>
  519. </div>
  520. <div class="col-xs-8 col-sm-9 col-md-9">
  521. ' . $user_language['agree_t_and_c'] . '
  522. </div>
  523. </div>
  524. ';
  525.  
  526. $form_submit = '
  527. <div class="row">
  528. <input type="hidden" name="token" value="' . Token::generate() . '">
  529. <div class="col-xs-12 col-md-6">
  530. <button type="submit" class="btn btn-primary btn-block btn-lg">
  531. ' . $user_language['register'] . '
  532. </button>
  533. </div>
  534. <div class="col-xs-12 col-md-6"><a href="/signin" class="btn btn-success btn-block btn-lg">' . $user_language['sign_in'] . '</a></div>
  535. </div>
  536. ';
  537.  
  538. // Session messages
  539. if(Session::exists('register')){
  540. $smarty->assign('SESSION_FLASH', Session::flash('register'));
  541. } else {
  542. $smarty->assign('SESSION_FLASH', '');
  543. }
  544.  
  545. $smarty->assign('CREATE_AN_ACCOUNT', $user_language['create_an_account']);
  546. $smarty->assign('FORM_CONTENT', $form_content);
  547. $smarty->assign('FORM_SUBMIT', $form_submit);
  548. ?>
  549. <!DOCTYPE html>
  550. <html lang="en">
  551. <head>
  552. <meta charset="utf-8">
  553. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  554. <meta name="viewport" content="width=device-width, initial-scale=1">
  555. <meta name="description" content="<?php echo $sitename; ?> registration form">
  556. <meta name="author" content="<?php echo $sitename; ?>">
  557. <meta name="theme-color" content="#454545" />
  558. <?php if(isset($custom_meta)){ echo $custom_meta; } ?>
  559.  
  560. <?php
  561. // Generate header and navbar content
  562. // Page title
  563. $title = $user_language['register'];
  564.  
  565. require('core/includes/template/generate.php');
  566. ?>
  567.  
  568. <link href="/core/assets/plugins/bootstrap-datepicker/css/bootstrap-datepicker3.min.css" rel="stylesheet">
  569. <!-- Custom style -->
  570. <style>
  571. html {
  572. overflow-y: scroll;
  573. }
  574. </style>
  575.  
  576. </head>
  577. <body>
  578. <?php
  579. // Navbar
  580. $smarty->display('styles/templates/' . $template . '/navbar.tpl');
  581.  
  582. // Registration template
  583. $smarty->display('styles/templates/' . $template . '/register.tpl');
  584.  
  585. // HTML Purifier
  586. require_once('core/includes/htmlpurifier/HTMLPurifier.standalone.php');
  587. $config = HTMLPurifier_Config::createDefault();
  588. $config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
  589. $config->set('URI.DisableExternalResources', false);
  590. $config->set('URI.DisableResources', false);
  591. $config->set('HTML.Allowed', 'u,p,b,i,a,s');
  592. $config->set('HTML.AllowedAttributes', 'target, href');
  593. $config->set('Attr.AllowedFrameTargets', array('_blank', '_self', '_parent', '_top'));
  594. $purifier = new HTMLPurifier($config);
  595. ?>
  596. <!-- Modal -->
  597. <div class="modal fade" id="t_and_c_m" tabindex="-1" role="dialog" aria-labelledby="t_and_c_m_Label" aria-hidden="true">
  598. <div class="modal-dialog modal-lg">
  599. <div class="modal-content">
  600. <div class="modal-header">
  601. <h4 class="modal-title" id="t_and_c_m_Label"><?php echo $user_language['terms_and_conditions']; ?></h4>
  602. </div>
  603. <div class="modal-body">
  604. <?php
  605. $t_and_c = $queries->getWhere("settings", array("name", "=", "t_and_c"));
  606. echo $purifier->purify(htmlspecialchars_decode($t_and_c[0]->value));
  607. $t_and_c = $queries->getWhere("settings", array("name", "=", "t_and_c_site"));
  608. echo $purifier->purify(htmlspecialchars_decode($t_and_c[0]->value));
  609. ?>
  610. </div>
  611. <div class="modal-footer">
  612. <button type="button" class="btn btn-primary" data-dismiss="modal"><?php echo $general_language['close']; ?></button>
  613. </div>
  614. </div><!-- /.modal-content -->
  615. </div><!-- /.modal-dialog -->
  616. </div><!-- /.modal -->
  617.  
  618. <?php
  619. // Footer
  620. require('core/includes/template/footer.php');
  621. $smarty->display('styles/templates/' . $template . '/footer.tpl');
  622.  
  623. // Scripts
  624. require('core/includes/template/scripts.php');
  625.  
  626. if($recaptcha === "true"){
  627. ?>
  628.  
  629. <script src="https://www.google.com/recaptcha/api.js"></script>
  630. <?php
  631. }
  632. ?>
  633. <script src="/core/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script>
  634.  
  635. <script>
  636. $('.datepicker').datepicker({
  637. orientation: 'bottom'
  638. });
  639.  
  640. $(function () {
  641. $('.button-checkbox').each(function () {
  642. // Settings
  643. var $widget = $(this),
  644. $button = $widget.find('button'),
  645. $checkbox = $widget.find('input:checkbox'),
  646. color = $button.data('color'),
  647. settings = {
  648. on: {
  649. icon: 'glyphicon glyphicon-check'
  650. },
  651. off: {
  652. icon: 'glyphicon glyphicon-unchecked'
  653. }
  654. };
  655. // Event Handlers
  656. $button.on('click', function () {
  657. $checkbox.prop('checked', !$checkbox.is(':checked'));
  658. $checkbox.triggerHandler('change');
  659. updateDisplay();
  660. });
  661. $checkbox.on('change', function () {
  662. updateDisplay();
  663. });
  664. // Actions
  665. function updateDisplay() {
  666. var isChecked = $checkbox.is(':checked');
  667. // Set the button's state
  668. $button.data('state', (isChecked) ? "on" : "off");
  669. // Set the button's icon
  670. $button.find('.state-icon')
  671. .removeClass()
  672. .addClass('state-icon ' + settings[$button.data('state')].icon);
  673. // Update the button's color
  674. if (isChecked) {
  675. $button
  676. .removeClass('btn-default')
  677. .addClass('btn-' + color + ' active');
  678. }
  679. else {
  680. $button
  681. .removeClass('btn-' + color + ' active')
  682. .addClass('btn-default');
  683. }
  684. }
  685. // Initialisation
  686. function init() {
  687. updateDisplay();
  688. // Inject the icon if applicable
  689. if ($button.find('.state-icon').length == 0) {
  690. $button.prepend('<i class="state-icon ' + settings[$button.data('state')].icon + '"></i>');
  691. }
  692. }
  693. init();
  694. });
  695. });
  696. </script>
  697. </body>
  698. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement