\n";
/*
http://localhost/d/Sel2In/prjs/php2/
prjs/php2/
/public_html/prjs/php2/
/home/t7/public_html/prjs/php2/
http://Sel2In.com/prjs/php2/
http://Sel2In.com/prjs/php2/
*/
require_once("{$dir1}code/core/html_entity_decode_php4.php"); // ../../../
require_once("{$dir1}code/config-defaults.php");
require_once("{$dir1}code/common.php"); // ../../../
require_once("{$dir1}code/common2.php");
require_once("{$dir1}code/sql/db.php"); // ../../../common.php
require_once ($dir1.'code/phpmailer/class.phpmailer.php');
global $sqlc;
//if (!isset($emailerid)) { $emailerid=returnglobal('sid');}
//This next line is for security reasons. It ensures that the $emailerid value is never anything but a number.
//$emailerid=sanitize_int($emailerid);
//DEFAULT SETTINGS FOR TEMPLATES
if (!$publicdir) {$publicdir=".";}
$tpldir="$publicdir/templates";
echo "";
if(!validate_email($usr1 )){//
$msgP = $msgP . "{$usr1} is an invalid email id please try again.\n
\n";
$regk = false;
}
/*if(!isset($_POST['terms'])){
$msgP = $msgP . "You must agree to the terms and check the checkbox to indicate acceptance.\n
\n";
}*/
//echo "
reg m4 reok $regk smg p {$msgP}
\n ";
if($regk ){
$sSql = "select tid from sel2in_ec_users where email = '" . db_quote($usr1) . "'";
echo "\n";
$result = mysql_query($sSql) ;
if (!$result) {
//err
$msgP = "err db2 " . mysql_error();
}else{
if(!$row=mysql_fetch_array($result)){
//if(!$row=mysql_fetch_array($result))
//no data - ok reg
//$veri = randomkey(15);
$sign1 = '';
$firstname = trim($_POST["firstname"]);
$sSql = "insert into sel2in_ec_users (email,firstname,active, whn) values".
"('" . db_quote($usr1) . "', '" . db_quote($firstname) . "','y', now() )" ;
$result = mysql_query($sSql);
if (!$result) {
$msg3 = "Registration failed please contact support {$siteadminemail}\n
";
$regk = false;
}else{
global $sitename ,$rooturl, $relativeurl, $folderPre ;
echo "";
$sSql = "select tid from sel2in_ec_users where email = '" . db_quote($usr1) . "'";
$result = mysql_query($sSql) ;
if(!$row=mysql_fetch_array($result)){
echo "Can't find tid of inserted row $usr1";
}else{
$usrTid = $row[0];
$c1 = $_POST['course'];
//echo "$ll c 1 $c1 $ll";
if($c1==''){
$crs = $_POST['courses'];
echo "";
$crs1='';
if(isset($crs) && is_array ($crs) && count($crs) > 0)
foreach($crs as $cr){
if($crs1== '')$crs1=$cr;
echo "" ;
$sSql = "insert into sel2in_ec_signups (tid_c, tid_u, isActiv) values ($cr, $usrTid,1)";
$result = mysql_query($sSql) ;
if (!$result) {
$msg3 = "Registration failed please contact support {$siteadminemail} Could not add course sign ups debug course id $cr at " . dt2() . ". Give support this error message too (copy paste)\n
";
$regk = false;
break;
}
}else{
$cr=$c1;
$crs1=$cr;
$sSql = "insert into sel2in_ec_signups (tid_c, tid_u, isActiv) values ($cr, $usrTid,1)";
$result = mysql_query($sSql) ;
if (!$result) {
$msg3 = "Registration failed please contact support {$siteadminemail} Could not add course sign ups debug course id $cr at " . dt2() . ". Give support this error message too (copy paste)\n
";
$regk = false;
break;
}
}
if($sign1 == ''){
echo "";
$sSql = "select folder, name, des from sel2in_ec_courses where tid= $crs1";
$result = mysql_query($sSql) ;
if (!$result) {
$msg3 = "Registration failed at get folder for course code $cr please contact support {$siteadminemail} Could not add course sign ups debug course id $cr at " . dt2() . ". Give support this error message too (copy paste)\n
";
echo $msg3 ;
$regk = false;
break;
}
if(!$rowS1 =mysql_fetch_array($result)){
$msg3 = "Registration failed at get folder, no data, for course code $cr please contact support {$siteadminemail} Could not add course sign ups debug course id $cr at " . dt2() . ". Give support this error message too (copy paste)\n
";
echo $msg3 ;
$regk = false;
break;
}
$sign1 = $rowS1[0];
echo "");
echo "");
$body1 = file_get_contents ($folderPre . $sign1 . "1.html");
/*
$rowInfo
$sSql ="SELECT usr_tid , usr_fname,usr_eml," .//0 1 2
" crse_tid, crse_nam, crse_fldr, crse_des,crse_fcnt, " . //3 4 5 6 7
" sign_tid, sign_actv " . // 8 9
*/
$rowInfo[] = 0;
$rowInfo[] = $firstname;
$rowInfo[] = $usr1;
$rowInfo[] = $cr;
$rowInfo[] = $rowS1[1];
$rowInfo[] = $rowS1[0];
$rowInfo[] = $rowS1[2];
$rowInfo[] = 0;
}
}else{
echo "
Error :you did not choose any registations\n";
$regk = false;
}
}
//MailTextMessage($body, $subject, $to, $from, $sitename, $ishtml=false, $bouncemail=null)
$subject = "First email from {$sitename}";
$actUrl = "{$rooturl}/reg.jsp?a=act&v={$veri}&u={$usr1}";
$g ="";
$ii = false;
if($g!=''){
$ii = strripos($g, $relativeurl );
if($ii !== false){
//echo "ii $ii " . " str len g " . strlen($g) . " str len rela " . strlen($relativeurl);
$g = @substr($g, $ii + strlen($relativeurl));
}
$actUrl = $actUrl . "&g=" . htmlspecialchars($g);
}
//$body = "Hello {$firstname},\n
you or someone else recently registered with us at {$sitename} ,\n
\n
thank you.\n
Regards,\n
{$sitename} Team.
{$ll}{$ll}To unsubscribe please go to {$rooturl}unsub.jsp?e={$usr1}{$ll}If you cannot see that link then copy this and go here in your browser :{$ll}{$rooturl}unsub.jsp?e={$usr1}{$ll}{$ll}Your first course follows:{$ll}Name: {$rowS1[1]}{$ll}Description : {$rowS1[2]}{$ll}";
global $dirMn ;
//$body = 'body';
$body = (file_get_contents($dirMn . "res/mail_first.html")) . $body1;
require_once("{$dir1}code/mailer.php");
bodDo($body, $rowInfo);
//echo "\n
". $body ."\n
";
$to = $usr1;
global $siteadminemail , $bouncemail;
$from = $siteadminemail ;
$ishtml = true;
$mailGo = "2";
echo "";
$body = $body . "{$ll}";
$textbody = strip_tags($body);
$textbody = str_replace(""", '"', $textbody);
$txtMail = strip_tags(br2nl(html_entity_decode_php4($textbody ))) ;
if(stripos($rooturl, "localhost") === false && stripos($rooturl, "a.com/") === false
&& stripos($rooturl, "tgk3/") === false ){
//$mailGo = MailTextMessage($body, $subject, $to, $from, $sitename, $ishtml, $txtMail ,bouncemail);
$mailGo = MailTextMessage($body, $subject, $to, $from, $sitename, $ishtml=true, $txtMail, $bouncemail);
//$mailGo = mail($to, $subject, $body );
}else{
$mailGo = true;
echo "$ll \n
root url {$rooturl} ii {$ii} {$ll}Mail body :{$ll}$body {$ll}{$ll}Mail Text :{$ll}
$txtMail{$ll}{$ll}";
}
if($mailGo !== false){
$sSql = "insert into sel2in_ec_history (tid_s, tid_u, tid_c, isActiv, nmbr, day) values " .
"((select max(tid) from sel2in_ec_signups where tid_c = $cr and tid_u = $usrTid), $usrTid, $cr, 1, 1, now())";
echo "";
$result2 = mysql_query($sSql);
if(!$result2 )echo "Db err with sel2in_ec_history $usrTid, $cr, please report to support " . mysql_error();
//$msg3 = "Welcome {$firstname} You have been sent an email (to {$usr1}); to verify your account please click the link in the email to activate your account. You must activate this account before you can use it.\n
";
$msg3 = "Registration initiated, sent first email. Welcome {$firstname} ";
$mode = $MOD_ACT;
}else{
$msg3 = "Registration failed please contact support {$siteadminemail} Provide your email id and time of trial with timezone\n
";
}
}
if($c1!=''){ ?>
";
$result1 = mysql_query($sSql);
$crs = $_POST['courses'];
unset($curC);
while(($row =mysql_fetch_array($result1)) ){
echo "";
$rtn = array_search($row[1], $crs);
if($rtn === false){
$sSql = "delete from sel2in_ec_signups where tid = {$row[0]}";
echo "";
$result = mysql_query($sSql);
}
if($row[2] == null || $row[2] != 1){
$sSql = "update sel2in_ec_signups set isActiv=1 where tid = {$row[0]} ";
$result = mysql_query($sSql);
}
$curC[] = $row[1];
}
unset($cr);
if(isset($crs) && is_array ($crs) && count($crs) > 0)
foreach($crs as $cr){
echo "";
$rtn = false;
if(isset($curC) && is_array ($curC) && count($curC) > 0){
$rtn = array_search($cr, $curC);
}
if($rtn === false){
$sSql = "insert into sel2in_ec_signups (tid_c, tid_u, isActiv) values ($cr, $usrTid,1)";
echo "";
$result = mysql_query($sSql) ;
if (!$result) {
$msg3 = "Registration failed please contact support {$siteadminemail} Could not add course sign ups debug course id $cr\n
";
$regk = false;
break;
}
}
}
else{
}
$mode = $MOD_ACT;
/*
foreach($crs as $cr){
array_search
$sSql = "insert into sel2in_ec_signups (tid_c, tid_u, isActiv) values ($cr, $usrTid,1)";
if (!$result) {
$msg3 = "Registration failed please contact support {$siteadminemail} Could not add course sign ups debug course id $cr\n
";
$regk = false;
break;
}
}
*/
}
}
}else{
$mode = $MOD_REG;
}
}else if($_POST["a"] == "l"){
$usr1 = trim($_POST["email"]);
$sSql = "select email from sel2in_ec_users where email = '" . db_quote($usr1) . "' and token = '" . db_quote(trim($_POST["password"])) . "'";
echo "";
$result = mysql_query($sSql) ;
if (!$result) {
//err
$msg3 = "err db2 " . mysql_error();
}else{
//echo "ok1 \n
\n"; mysql_fetch_array
if($row=mysql_fetch_array($result)){
//good login
$_SESSION[$NmUsr] = $usr1;
$rmme="";
if(isset($_POST[$NmRemme])){
$f1 =fopen("/tmp/cookieRemme.txt", "w");
if($f1){
fwrite($f1, $_SESSION[’token’] . " at 2 usr {$usr1}\n" . date('H i S') );
fclose($f1);}
//setcookie($NmRemme, $usr1, time()+60*60*24*800);//$_POST[$NmUsr]
$rmme="&{$NmRemme}=1";
}
if(isset($_SESSION[’ref1’] )){
$f1 =fopen("/tmp/sur.txt", "w");
if($f1){
fwrite($f1, $_SESSION[’ref1’]);
fclose($f1);
}
/*$f1 =fopen("/tmp/reg-goto1.txt", "w");
if($f1){
fwrite($f1, $_SESSION[’token’] . " at 2 \n" );
fclose($f1);}*/
//include('index.php');
header('Location: ' . $_SESSION[’ref1’] );
//echo "\n
oo ref 1 " . $_SESSION[’ref1’];
}else if(isset($_SESSION[’ref2’] )){
header('Location: ' . $_SESSION[’ref2’]);
}else{
//default login
header('Location: ' . "../");//default home page
}
unset($_SESSION[’ref1’]);
unset($_SESSION[’ref2’]);
//exit();
}else{
$msgLogin = "Invalid login, please re-try.";
}
}
}else if($_GET["a"] == "act"){
$mode = $MOD_ACT;
}else if($_POST["a"] == "actDo"){
$mode = $MOD_NOR;
//echo " act do 1 ";
$verGiven = $_POST["actCode"];
$usr = trim($_POST["email"]);
$pwd = trim($_POST["password"]);
$sSql = "select active, verification, token from sel2in_ec_users where email = '" .db_quote($usr) . "'";
echo "";
$result = mysql_query($sSql) ;
if (!$result) {
//err
//echo "err db1 a " . mysql_error();
}else{
//echo " act do 2 ";
//echo "ok1 \n
\n";
if($row=mysql_fetch_array($result)){
//data got check user details
if($row['active'] == 'n'){
//ok is inactive - activate if auth
if($row['verification'] == $verGiven && $row['token'] == $pwd){
//activate
$sSql = "update sel2in_ec_users set active = 'y' where email ='" . db_quote($usr) ."'";
$result = mysql_query($sSql) ;
if (!$result) {
$msg3 = "Registration Activation failed (DB error) please contact support \n
";
$regk = false;
}else{
$_SESSION[$NmUsr] = $usr;
if(isset($_SESSION[’ref1’])){
header('Location: ' . $_SESSION[’ref1’] );
}else if(isset($_SESSION[’ref2’] )){
header('Location: ' . $_SESSION[’ref2’]);
}else if(isset($_GET[’g’] )){
global $rooturl;
header('Location: ' . $rooturl . "/". $_GET[’g’] );
}else{
//default login
header('Location: ' . "../index.php");//default home page
}
$msg3 = "Ok, account {$usr} is now activated please login.\n
";
}
}else{
$msg3 = "Invalid credentials. Please register or login to try again press
back.\n
\n";
}
}else{
$_SESSION[$NmUsr] = $usr;
if(isset($_SESSION[’ref1’])){
header('Location: ' . $_SESSION[’ref1’] );
}else if(isset($_SESSION[’ref2’] )){
header('Location: ' . $_SESSION[’ref2’]);
}else if(isset($_GET[’g’] )){
global $rooturl;
header('Location: ' . $rooturl . "/". $_GET[’g’] );
}else{
//default login
header('Location: ' . "index.php");//default home page
}
$msg3 = "Account already active please login\n
r0 " . $row['active'] . "
r1 " . $row['verification'] . "
";
}
}else{
$msg3 = "Invalid credentials. Please register or login.\n
";
$regk = false;
}
}
}
function chkPwd(){
//return true;
$p = trim($_POST["password"]);
$o= true;
global $msgP;
if(strlen($p) < 3){
$msgP = $msgP . "Password too short please try with a password that is at least 3 chars long.\n
\n";
$o= false;
}
if($p != $_POST["password2"]){
if($o){
$l = "P";
}else{
$l = "Also, p";
}
$msgP = $msgP . "{$l}assword and confirm password do not match please use the same in both fields.\n
\n";
$o= false;
}
if($p == $_POST["email"]){
$msgP = $msgP . "Password and username/ email must be different
\n";
$o= false;
}
return $o;
}
?>
{$msgP}
\n";
}
if ($mode == $MOD_NOR ){
$_SESSION['reg-fn'] = "";
$_SESSION['reg-ln'] = "";
$usr ="";
}
?>
Registrations
Registrations
{$msg3}
\n";
}
?>
ses ref1 :" . $_SESSION[’ref1’] . "]\n
\n";
//echo "\n
cook ref1 :" . $_COOKIE[’ref1’] . "]\n
\n";
?>
Page rendered on " . date("Y M d H:i:s") . "";
if($_GET["newReg"] == 1){
echo "\n\n";
}
?>