function addUser(&$user) { //add user account global $ax, $set, $mode, $rxEmail; do { if (!$user['name'] or !$user['mail'] or !$user['newPw']) { $msg = $ax['usr_cred_required']; break; } if (!preg_match("/^[\\w\\s\\._-]{2,}\$/u", $user['name'])) { $msg = $ax['usr_un_invalid']; break; } if (!preg_match($rxEmail, $user['mail'])) { $msg = $ax['usr_em_invalid']; break; } $stH = stPrep("SELECT `name`,`email` FROM `users` WHERE (`name` = ? OR `email` = ?) AND `status` >= 0"); stExec($stH, array($user['name'], $user['mail'])); $row = $stH->fetch(PDO::FETCH_ASSOC); $stH = null; if ($row) { // name or email already exists $msg = $row['name'] == $user['name'] ? $ax['usr_name_exists'] : $ax['usr_email_exists']; break; } $password = md5($user['newPw']); $stH = stPrep("INSERT INTO `users` (`name`,`password`,`email`,`groupID`,`language`) VALUES (?,?,?,?,?)"); $result = stExec($stH, array($user['name'], $password, $user['mail'], $user['grpID'], $set['language'])); if (!$result) { $msg = "Database Error: {$ax['usr_not_added']}"; break; } $user['id'] = dbLastRowId(); //set id to new user $msg = $ax['usr_added']; $mode = ''; } while (false); return $msg; }
$oUid = $uid; //set original user ID to current user } //set repeat params $r_i = $r_t == 1 ? $ri1 : ($r_t == 2 ? $ri2 : 0); $r_p = $r_t == 1 ? $rp1 : ($r_t == 2 ? $rp2 : 0); $r_m = $rpm; //update tables if ($mode == "add_exe") { //add new event $q = "INSERT INTO `events` (`private`,`title`,`venue`,`text1`,`text2`,`text3`,`catID`,`userID`,`approved`,`notify`,`notMail`,`sDate`,`eDate`,`sTime`,`eTime`,`rType`,`rInterval`,`rPeriod`,`rMonth`,`rUntil`,`aDateTime`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $stH = stPrep($q); //add to events table $result = stExec($stH, array($pri, $tit, $ven, $desHtml, $xf1Html, $xf2Html, $cid, $uid, $apd, $not, $nml, $sDate, $eDate, $sTime, $eTime, $r_t, $r_i, $r_p, $r_m, $runtil, $todayDT)); $stH = null; $eid = dbLastRowId(); //set id to new event $cMsg .= $xx['evt_confirm_added']; } else { //update event $edr = $uname; $adtStamp = mktime(substr($adt, 11, 2), substr($adt, 14, 2), 0, substr($adt, 5, 2), substr($adt, 8, 2), substr($adt, 0, 4)); $modDT = time() - $adtStamp > 600 ? $todayDT : '9999-00-00 00:00'; //mod time not set if < 10 mins passed if ($editN != 1) { //update the series $stH = stPrep("UPDATE `events`\n\t\t\t\t\tSET `private`=?, `title`=?, `venue`=?, `text1`=?, `text2`=?, `text3`=?, `catID`=?, `userID`=?, `editor`=?, `approved`=?, `notify`=?, `notMail`=?, `sDate`=?, `eDate`=?, `sTime`=?, `eTime`=?, `rType`=?, `rInterval`=?, `rPeriod`=?, `rMonth`=?, `rUntil`=?, `mDateTime`=?\n\t\t\t\t\t\tWHERE `ID`=?"); //update events table stExec($stH, array($pri, $tit, $ven, $desHtml, $xf1Html, $xf2Html, $cid, $uid, $uname, $apd, $not, $nml, $sDate, $eDate, $sTime, $eTime, $r_t, $r_i, $r_p, $r_m, $runtil, $modDT, $eid)); $cMsg .= $xx['evt_confirm_saved']; } else {