123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- <?php // $Id: inscription_second.php 9246 2006-09-25 13:24:53Z bmol $
- /*
- ==============================================================================
- Dokeos - elearning and course management software
-
- Copyright (c) 2004 Dokeos S.A.
- Copyright (c) 2003 Ghent University (UGent)
- Copyright (c) 2001 Universite catholique de Louvain (UCL)
- Copyright (c) various contributors
-
- For a full list of contributors, see "credits.txt".
- The full license can be read in "license.txt".
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- See the GNU General Public License for more details.
-
- Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
- ==============================================================================
- */
- /**
- ==============================================================================
- * This script reacts on the form data normally delivered by inscription.php
- * to register users into Dokeos.
- * (but malicious users can easily send POST data from their own scripts).
- *
- * @package dokeos.auth
- * @deprecated File not in use
- ==============================================================================
- */
- /*==========================
- INIT
- ==========================*/
- $langFile = "registration";
- require("../inc/global.inc.php");
- $TABLEUSER = Database::get_main_table(MAIN_USER_TABLE);
- define ("CHECK_PASS_EASY_TO_FIND", false);
- if (!isset($userPasswordCrypted)) $userPasswordCrypted = false;
- $regDataOk = false; // default value...
- if(!empty($_POST['submitRegistration']))
- {
- $regexp = "^[0-9a-z_\.-]+@(([0-9]{1,3}\.){3}[0-9]{1,3}|([0-9a-z][0-9a-z-]*[0-9a-z]\.)+[a-z]{2,4})$";
- $uname = trim ($_POST["uname" ]);
- $email = trim ($_POST["email" ]);
- $official_code = trim ($_POST["official_code" ]);
- $lastname = trim ($_POST["lastname" ]);
- $firstname = trim ($_POST["firstname" ]);
- $password = trim ($_POST["password" ]);
- $password1 = trim ($_POST["password1" ]);
- $language = $_POST['form_user_language'];
-
- $status=($_POST['status'] == COURSEMANAGER)?COURSEMANAGER:STUDENT;
- $uname=eregi_replace('[^a-z0-9_.-]','_',strtr(stripslashes($uname),'ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ','AAAAAAaaaaaaOOOOOOooooooEEEEeeeeCcIIIIiiiiUUUUuuuuyNn'));
- /*==========================
- DATA SUBIMITED CHECKIN
- ==========================*/
- // CHECK THE LANGUAGE OF THE USER PROFILE
- // we use the platform language if the user cannot select his language or if the chosen language is not valid (spoofed form)
- if (get_setting('registration', 'language') == "true")
- {
- // check if the submitted value is a valid language. If not we use the platform language (against form sppofing)
- $language_list=api_get_languages();
- $language_name=$language_list['name'];
- $language_folder=$language_list['folder'];
- if (!in_array($language,$language_folder))
- {
- $language=get_setting('platformLanguage');
- }
- }
- else
- {
- // we use the platform languange as the language for the profile
- $language=get_setting('platformLanguage');
- }
- // CHECK IF THERE IS NO EMPTY FIELD
- if (
- empty($lastname)
- OR empty($firstname)
- OR (empty($official_code)
- AND (get_setting('registration','officialcode')=="true"))
- OR empty($password1)
- OR empty($password)
- OR empty($uname)
- OR (empty($email) AND api_get_setting('registration','email')=="true")
- )
- {
- $regDataOk = false;
- unset($password1, $password);
- $error_message .= "<p>".get_lang('langEmptyFields')."</p>\n";
- }
- // CHECK IF THE TWO PASSWORD TOKEN ARE IDENTICAL
- elseif($password1 != $password)
- {
- $regDataOk = false;
- unset($password1, $password);
- $error_message .= "<p>".get_lang('langPassTwice')."</p>\n";
- }
- elseif(CHECK_PASS_EASY_TO_FIND && !api_check_password($password))
- {
- $error_message .= "<p>".get_lang('langPassTooEasy')." : <code>".api_generate_password()."</code><br></p>";
- }
- // CHECK EMAIL ADDRESS VALIDITY
- elseif( !empty($email) && ! eregi( $regexp, $email ))
- {
- $regDataOk = false;
- unset($password1, $password, $email);
- $error_message .= "<p>".get_lang('langEmailWrong').".</p>\n";
- }
- // CHECK IF THE LOGIN NAME IS ALREADY OWNED BY ANOTHER USER
- else
- {
- $result = api_sql_query("SELECT user_id FROM $TABLEUSER
- WHERE username='$uname'");
- if (mysql_num_rows($result) > 0)
- {
- $regDataOk = false;
- unset($password1, $password, $uname);
- $error_message .= "<p>".get_lang('langUserFree')."</p>";
- }
- else
- {
- $regDataOk = true;
- }
- }
- }
- $nameTools = get_lang('Registration');
- if ( ! $regDataOk)
- {
- Display::display_header($nameTools);
- api_display_tool_title($nameTools);
- echo $error_message;
- echo "<p>",
- "<a href=\"inscription.php?lastname=",urlencode(stripslashes($lastname)),"&firstname=",urlencode(stripslashes($firstname)),"&official_code=",urlencode(stripslashes($official_code)),"&uname=",urlencode(stripslashes($uname)),"&email=",urlencode(stripslashes($email)),"&status=",$status,"\">",
- get_lang('langAgain'),
- "</a>",
- "</p>\n";
- Display::display_footer();
- exit;
-
- }
- /*> > > > > > > > > > > > REGISTRATION ACCEPTED < < < < < < < < < < < <*/
- if ($regDataOk)
- {
- /*-----------------------------------------------------
- STORE THE NEW USER DATA INSIDE THE CLAROLINE DATABASE
- -----------------------------------------------------*/
- api_sql_query("INSERT INTO ".$TABLEUSER."
- SET lastname = '".$lastname."',
- firstname = '".$firstname."',
- username = '".$uname."',
- password = '".($userPasswordCrypted?md5($password):$password)."',
- email = '".$email."',
- status = '".$status."',
- official_code = '".$official_code."',
- language = '".$language."'
- ");
- $_uid = mysql_insert_id();
- if ($_uid)
- {
- /*--------------------------------------
- SESSION REGISTERING
- --------------------------------------*/
- $_user['firstName'] = stripslashes($firstname);
- $_user['lastName' ] = stripslashes($lastname);
- $_user['mail' ] = $email;
- $_user['language'] = $language;
- $is_allowedCreateCourse = ($status == 1) ? true : false ;
- api_session_register('_uid');
- api_session_register('_user');
- api_session_register('is_allowedCreateCourse');
- //stats
- include(api_get_path(LIBRARY_PATH)."events.lib.inc.php");
- event_login();
- // last user login date is now
- $user_last_login_datetime = 0; // used as a unix timestamp it will correspond to : 1 1 1970
- api_session_register('user_last_login_datetime');
- /*--------------------------------------
- EMAIL NOTIFICATION
- --------------------------------------*/
- if(strstr($email,'@'))
- {
- // Lets predefine some variables. Be sure to change the from address!
- $emailto = "\"$firstname $lastname\" <$email>";
- $emailfromaddr = api_get_setting('emailAdministrator');
- $emailfromname = api_get_setting('siteName');
- $emailsubject = "[".get_setting('siteName')."] ".get_lang('YourReg')." ".get_setting('siteName');
- // The body can be as long as you wish, and any combination of text and variables
- $emailbody=get_lang('langDear')." ".stripslashes("$firstname $lastname").",\n\n".get_lang('langYouAreReg')." ". get_setting('siteName') ." ".get_lang('langSettings')." ". $uname ."\n". get_lang('langPass')." : ".stripslashes($password)."\n\n" .get_lang('langAddress') ." ". api_get_setting('siteName') ." ". get_lang('langIs') ." : ". $rootWeb ."\n\n". get_lang('langProblem'). "\n\n". get_lang('langFormula').",\n\n".get_setting('administratorName')." ".get_setting('administratorSurname')."\n". get_lang('langManager'). " ".get_setting('siteName')."\nT. ".get_setting('administratorTelephone')."\n" .get_lang('langEmail') ." : ".get_setting('emailAdministrator');
- // Here we are forming one large header line
- // Every header must be followed by a \n except the last
- $emailheaders = "From: ".get_setting('administratorSurname')." ".get_setting('administratorName')." <".get_setting('emailAdministrator').">\n";
- $emailheaders .= "Reply-To: ".get_setting('emailAdministrator');
- // Because I predefined all of my variables, this api_send_mail() function looks nice and clean hmm?
- @api_send_mail( $emailto, $emailsubject, $emailbody, $emailheaders);
- }
- }
- Display::display_header($nameTools);
- api_display_tool_title($nameTools);
- echo "<p>".get_lang('langDear')." ".stripslashes("$firstname $lastname").",<br><br>".get_lang('langPersonalSettings').".</p>\n";
- if(!empty($email))
- {
- echo "<p>".get_lang('langMailHasBeenSent').".</p>";
- }
- if($is_allowedCreateCourse)
- {
- echo "<p>",get_lang('langNowGoCreateYourCourse'),".</p>\n";
- $actionUrl = "../create_course/add_course.php";
- }
- else
- {
- echo "<p>",get_lang('langNowGoChooseYourCourses'),".</p>\n";
- $actionUrl = "courses.php?action=subscribe";
- }
- // ?uidReset=true&uidReq=$_uid
- echo "<form action=\"",$actionUrl,"\" method=\"post\">\n",
- "<input type=\"submit\" name=\"next\" value=\"",get_lang('langNext'),"\" validationmsg=\" ",get_lang('langNext')," \">\n",
- "</form>\n";
- } // else Registration accepted
- $already_second=1;
- Display::display_footer();
- ?>
|