<?php error_reporting(E_ALL); /* Create Object :: CONNECT */ require_once 'lib/dbCon.php'; $DBcon = new EstablishDBConnection(); $DBcon->dbserver = 'localhost'; $DBcon->dbuser = '******'; $DBcon->dbpass = '******'; $DBcon->dbname = 'usr_web231_6'; $DBcon->connectDB(); /******************************************/ //require_once("settings/dbCon.php"); require_once "lib/readdirectory.php"; require_once "lib/modify.php"; $cron = new ModifyEntry(); $cron->table = "cron"; $cron->cols = 'test'; $cron->values = " 'jo' "; $cron->insert(); unset($cron);
} if (!isset($_POST['opt']['4'])) { $_POST['opt']['4'] = ""; } if (!isset($_POST['opt']['5'])) { $_POST['opt']['5'] = ""; } if (!isset($_POST['opt']['6'])) { $_POST['opt']['6'] = ""; } if (!isset($_POST['opt']['7'])) { $_POST['opt']['7'] = ""; } if (!isset($_POST['opt']['8'])) { $_POST['opt']['8'] = ""; } if (!isset($_POST['opt']['9'])) { $_POST['opt']['9'] = ""; } if (!isset($_POST['opt']['10'])) { $_POST['opt']['10'] = ""; } $mysqldate = date('Y-m-d H:i:s', time()); $flash = new ModifyEntry(); $flash->table = $tbl_flashes; $flash->cols = 'userID, CreateDate, section, category, question, type, opt1, opt2, opt3, opt4, opt5, opt6, opt7, opt8, opt9, opt10'; $flash->values = " '" . $user_data['ID'] . "', '" . $mysqldate . "', '" . $_POST['section'] . "', '" . $_POST['category'] . "', '" . $_POST['question'] . "', '" . $_POST['s_type'] . "', '" . $_POST['opt']['1'] . "', '" . $_POST['opt']['2'] . "', '" . $_POST['opt']['3'] . "', '" . $_POST['opt']['4'] . "', '" . $_POST['opt']['5'] . "', '" . $_POST['opt']['6'] . "', '" . $_POST['opt']['7'] . "', '" . $_POST['opt']['8'] . "', '" . $_POST['opt']['9'] . "', '" . $_POST['opt']['10'] . "' "; $flash->insert(); unset($flash); header("Location:" . ROOT_DIR . "flash/newflash.html"); }
$positionID = 1; } $links_l_edit = new ModifyEntry(); $links_l_edit->table = $tbl_links; $links_l_edit->changes = " position = position+{$new_entries} "; $links_l_edit->condition = " cid = '{$t_cid}' "; $links_l_edit->update(); unset($links_l_edit); $links_l_new = new ModifyEntry(); $links_l_new->table = $tbl_links; $links_l_new->cols = 'cid, link, description, description_EN, position, visibility'; $count = 0; foreach ($_POST["links_l_new_link"] as $element) { if ($links_l_new_link[$count] != "" && $links_l_new_description[$count] != "") { $links_l_new->values = "'{$links_l_new_cid[$count]}', '{$links_l_new_link[$count]}', '{$links_l_new_description[$count]}', '{$links_l_new_description_EN[$count]}', '{$positionID}', '0' "; $links_l_new->insert(); $positionID++; } $count++; } unset($links_l_new); } /******************************************/ /* design :: Edit one or more entries */ if (count($_POST["links_l_link"]) > 0) { $links_l_edit = new ModifyEntry(); $links_l_edit->table = $tbl_links; $links_l_edit->condition = " cid = '{$links_l_cid['0']}' "; $links_l_edit->changes = " visibility = '0' "; $links_l_edit->update(); $count = 0;
$positionID = new SelectEntrys(); $positionID->cols = 'position'; $positionID->table = $tbl_ref; $positionID->order = 'position DESC'; $positionID->limit = '1'; $positionID->module = ''; $positionID->template = ''; $positionID = $positionID->row() + 1; $ref_new = new ModifyEntry(); $ref_new->table = $tbl_ref; $ref_new->cols = 'link, description, description_EN, position'; $count = 0; foreach ($_POST["ref_new_link"] as $element) { if ($ref_new_link[$count] != "") { $ref_new->values = "'{$ref_new_link[$count]}', '{$ref_new_description[$count]}', '{$ref_new_description_EN[$count]}', {$positionID}"; $ref_new->insert(); $positionID++; } $count++; } unset($ref_new); } /******************************************/ /* References :: Edit one or more entries */ $ref_edit = new ModifyEntry(); $ref_edit->table = $tbl_ref; $count = 0; foreach ($_POST["ref_link"] as $element) { $ref_edit->condition = " id = '{$ref_id[$count]}' "; $ref_edit->changes = " link = '{$ref_link[$count]}', description = '{$ref_description[$count]}', description_EN = '{$ref_description_EN[$count]}' "; $ref_edit->update();
function update_visiter_stats($tbl_visiter, $tbl_settings, $timestamp, $del_old_visiters, $time_new_visiter) { require_once 'lib/select.php'; require_once 'lib/modify.php'; require_once 'lib/exist.php'; $delimiter = $timestamp - $del_old_visiters * 60; // delete entries older than 2 weeks 60*60*24*14 $visiter = new ModifyEntry(); $visiter->table = $tbl_visiter; $visiter->condition = " UNIX_TIMESTAMP(date) < {$delimiter} "; $visiter->delete(); unset($visiter); $delimiter = $timestamp - $time_new_visiter * 60; $visiter = new CheckExist(); $visiter->tableE = $tbl_visiter; $visiter->conditionE = " IP = '" . $_SERVER['REMOTE_ADDR'] . "' AND UNIX_TIMESTAMP(date) >= {$delimiter} "; $visiter_exist = $visiter->exist(); unset($visiter); if ($visiter_exist == 0) { //$country = file_get_contents('http://api.hostip.info/country.php?ip='.$_SERVER['REMOTE_ADDR']); $date = date("Y-m-d H:i:s", $timestamp); $visiter = new ModifyEntry(); $visiter->table = $tbl_visiter; $visiter->cols = 'IP, date, browser, country, referer'; $visiter->values = " '" . $_SERVER['REMOTE_ADDR'] . "', '{$date}', '" . $_SERVER['HTTP_USER_AGENT'] . "', 'unknown', '" . $_SERVER['HTTP_REFERER'] . "' "; $visiter->insert(); $visiter->table = $tbl_settings; $visiter->changes = " visiters_total = visiters_total+1 "; $visiter->condition = " id = '1' "; $visiter->update(); unset($visiter); } return false; }
*******************************************/ /* Create Thumbs */ $gallery->dir_target = $dir_thumbs; $gallery->height_max = $set[0]["height_thumbs_max"]; $gallery->width = $set[0]["width_thumbs"]; $gallery->pictures = $images; $gallery->createpicture('thumb'); /******************************************/ /* Insert new entry */ //date format: 0000-00-00 00:00:00 $my_time = $_POST[d_year] . '-' . $_POST[d_month] . '-' . $_POST[d_day] . ' ' . $_POST[d_hour] . ':' . $_POST[d_minute] . ':00'; $gallery->table = $tbl_gallery; $gallery->cols = 'title, title_EN, description, description_EN, folder, date, visibility'; $gallery->values = " '{$_POST['title']}', '{$_POST['title_EN']}', '{$_POST['description']}', '{$_POST['description_EN']}', '{$_POST['folder']}', '{$my_time}', '{$_POST['visibility']}' "; $gallery->insert(); /******************************************/ /* UPDATE :: RSS Feed */ include 'update_rss_gallery.php'; /******************************************/ /* Delete :: Object INSERT */ unset($gallery); /******************************************/ /* Load :: Updated Main Content */ header("Location:" . ROOT_DIR . "gallery.html"); /******************************************/ } else { /* Get new subfolders */ $subfolders = new readdirectory(); $subfolders->directory = "gallery/"; $results = $subfolders->listfolder('return');
$positionID = new SelectEntrys(); $positionID->cols = 'position'; $positionID->table = $tbl_profile; $positionID->order = 'position DESC'; $positionID->limit = '1'; $positionID->module = ''; $positionID->template = ''; $positionID = $positionID->row() + 1; $profile_new = new ModifyEntry(); $profile_new->table = $tbl_profile; $profile_new->cols = 'german, english, value, value_EN, position'; $count = 0; foreach ($_POST["profile_new_german"] as $element) { if ($profile_new_value[$count] != "") { $profile_new->values = "'{$profile_new_german[$count]}', '{$profile_new_english[$count]}', '{$profile_new_value_EN[$count]}', '{$profile_new_value[$count]}', '{$positionID}'"; $profile_new->insert(); $positionID++; } $count++; } unset($profile_new); } /******************************************/ /* Profile :: Edit one or more entries */ $profile_edit = new ModifyEntry(); $profile_edit->table = $tbl_profile; $count = 0; foreach ($_POST["profile_german"] as $element) { $profile_edit->condition = " id = '{$profile_id[$count]}' "; $profile_edit->changes = " german = '{$profile_german[$count]}', english = '{$profile_english[$count]}', value = '{$profile_value[$count]}', value_EN = '{$profile_value_EN[$count]}' "; $profile_edit->update();
function insertdata($table, $data, $special = 0) { //global $tpl; global $memcache; global $l; global $tpl; global $user_data; global $getmonth; $objResponse = new xajaxResponse(); //include('settings/template.php'); include 'settings/tables.php'; if ($user_data == '' || !isset($user_data)) { require_once 'lib/functions/get_userdata.php'; } //enter new diary entry if ($table == $tbl_diary) { if ($special == 1) { $html = $tpl->fetch("modules/improve/diary/add_pin.tpl"); // $objResponse->assign("add_pin","style.className",'pin'); $objResponse->assign("add_pin", "innerHTML", $html); $objResponse->includeScript("js/pinterest.js"); $objResponse->call("m_reload"); } else { if ($data['image_file'] != '') { $objResponse->script("document.forms['insert'].submit();"); } else { $mysqldate = date('Y-m-d H:i:s', time()); $diary_note = mysql_real_escape_string(strip_tags($data['note'])); //insert new entry $diary = new ModifyEntry(); $diary->table = $table; $diary->cols = 'userID, entry, date'; $diary->values = " '" . $user_data['ID'] . "', '" . $diary_note . "', '" . $mysqldate . "' "; $diary->insert(); unset($diary); //TODO check if first entry and if yes update user array with start_month and start_year //refresh content include "lib/functions/fetch_diary.php"; $tpl->assign('ay_diary', $ay_diary); $tpl->assign('at_least_one_entry', 1); //else $tpl->assign('at_least_one_entry', 0); //TODO why is this needed now!? $tpl->assign('user_data', $user_data); $html = $tpl->fetch("modules/home/diary_entries.tpl"); $objResponse->assign("diary_entries", "innerHTML", $html); $objResponse->assign("add_pin", "innerHTML", ''); $objResponse->includeScript("js/pinterest.js"); $objResponse->call("m_reload"); } } } elseif ($table == $tbl_goals) { $mysqldate = date('Y-m-d H:i:s', time()); $note = strip_tags(mysql_real_escape_string($data['note'])); //insert new entry $goals = new ModifyEntry(); $goals->table = $table; $goals->cols = 'userID, goal, created'; $goals->values = " '" . $user_data['ID'] . "', '" . $note . "', '" . $mysqldate . "' "; $goals->insert(); unset($goals); //refresh content $html1 = $tpl->fetch("modules/improve/goals/sortfields.tpl"); $objResponse->assign("sortfields", "innerHTML", $html1); include "lib/functions/fetch_goals.php"; $tpl->assign('ay_goals', $ay_goals); $html2 = $tpl->fetch("modules/improve/goals/goal_entries.tpl"); $objResponse->assign("goal_entries", "innerHTML", $html2); $objResponse->call("reset_input"); } elseif ($table == $tbl_distorted_thoughts) { $mysqldate = date('Y-m-d H:i:s', time()); $thought = strip_tags(mysql_real_escape_string($data['thought'])); $response = strip_tags(mysql_real_escape_string($data['response'])); $c_action = strip_tags(mysql_real_escape_string($data['c_action'])); //insert new entry $thoughts = new ModifyEntry(); $thoughts->table = $table; $thoughts->cols = 'userID, thought, response, action, created'; $thoughts->values = " '" . $user_data['ID'] . "', '" . $thought . "', '" . $response . "', '" . $c_action . "', '" . $mysqldate . "' "; $thoughts->insert(); unset($thoughts); //refresh content include "lib/functions/fetch_thoughts.php"; $tpl->assign('ay_thoughts', $ay_thoughts); $html = $tpl->fetch("modules/improve/distorted_thoughts/thought_entries.tpl"); $objResponse->assign("thought_entries", "innerHTML", $html); $objResponse->call("reset_input"); } elseif ($table == $tbl_da_scale_results || $table == $tbl_bd_scale_results) { $i = 0; $dataValid = 1; $mysqldate = date('Y-m-d H:i:s', time()); //check if all items have been answered for ($i = 1; $i <= $data['items_total']; $i++) { if (!isset($data[$i])) { $objResponse->alert('Please answer all items'); // TODO put string in language file $dataValid = 0; break; } } //TODO store aggregated values in user table //all items have been answered if ($dataValid == 1) { $bd_total_score = 0; $da_total_score[0] = $da_total_score[1] = $da_total_score[2] = $da_total_score[3] = $da_total_score[4] = $da_total_score[5] = $da_total_score[6] = 0; //insert new entry $scale_data = new ModifyEntry(); $scale_data->table = $table; for ($i = 1; $i <= $data['items_total']; $i++) { if (isset($data[$i])) { $scale_data->cols = 'userID, itemID, value, date'; $scale_data->values = " '" . $user_data['ID'] . "', '" . $i . "', '" . $data[$i] . "', '" . $mysqldate . "' "; $scale_data->insert(); if ($scale_data->errno() > 0) { break; } if ($table == $tbl_da_scale_results) { switch (true) { case $i <= 5: $da_total_score[0] = $da_total_score[0] + $data[$i]; break; case $i <= 10: $da_total_score[1] = $da_total_score[1] + $data[$i]; break; case $i <= 15: $da_total_score[2] = $da_total_score[2] + $data[$i]; break; case $i <= 20: $da_total_score[3] = $da_total_score[3] + $data[$i]; break; case $i <= 25: $da_total_score[4] = $da_total_score[4] + $data[$i]; break; case $i <= 30: $da_total_score[5] = $da_total_score[5] + $data[$i]; break; case $i <= 35: $da_total_score[6] = $da_total_score[6] + $data[$i]; break; } } if ($table == $tbl_bd_scale_results) { $bd_total_score = $bd_total_score + $data[$i]; } } } unset($scale_data); $scale_data = new ModifyEntry(); $scale_data->table = $tbl_users; if ($table == $tbl_da_scale_results) { ksort($da_total_score); } if ($table == $tbl_da_scale_results) { $scale_data->changes = " da_latest_score = '" . serialize($da_total_score) . "' "; } else { $scale_data->changes = " bd_latest_score = '" . $bd_total_score . "' "; } $scale_data->condition = " ID = '" . $user_data['ID'] . "' "; $scale_data->update(); if ($scale_data->errno() > 0) { break; } if ($table == $tbl_da_scale_results) { $user_data['da_latest_score'] = serialize($da_total_score); } if ($table == $tbl_bd_scale_results) { $user_data['bd_latest_score'] = $bd_total_score; } if (mod_memcache == 1) { $memcache->replace($mem_key1, $user_data, false); } else { $_SESSION['$mem_key1'] = $user_data; } } //update cached data in memcache or session //$l["token"] = substr($_COOKIE["l"], 3, -35); if ($table == $tbl_da_scale_results) { $mem_key2 = "da_scale_data_" . $l["token"]; $mem_key2a = "da_scale_sep_strings_" . $l["token"]; $mem_key2b = "da_scale_sep_dates_" . $l["token"]; if (mod_memcache == 1) { $memcache->delete($mem_key2); $memcache->delete($mem_key2a); $memcache->delete($mem_key2b); } else { unset($_SESSION['$mem_key2']); unset($_SESSION['$mem_key2a']); unset($_SESSION['$mem_key2b']); } } if ($table == $tbl_bd_scale_results) { $mem_key3 = "bd_scale_data_" . $l["token"]; if (mod_memcache == 1) { $memcache->delete($mem_key3); } else { unset($_SESSION['$mem_key3']); } } //redirect to overview/result page if ($dataValid == 1 && $scale_data->errno() == 0 && $table == $tbl_da_scale_results) { $objResponse->redirect(ROOT_DIR . 'analyze/da_scale/index.html'); } if ($dataValid == 1 && $scale_data->errno() == 0 && $table == $tbl_bd_scale_results) { $objResponse->redirect(ROOT_DIR . 'analyze/bd_scale/index.html'); } unset($scale_data); } return $objResponse; }
if (!empty($_POST['note'])) { require_once '././lib/functions/upload_image.php'; if ($_FILES) { $upload_pic = uploadImageFile($_FILES["image_file"], $user_data['ID']); } //print_r($upload_pic); if ($upload_pic != '') { $mysqldate = date('Y-m-d H:i:s', time()); $diary_note = mysql_real_escape_string($_POST['note']); //insert new entry $diary = new ModifyEntry(); $diary->table = $tbl_diary; $diary->cols = 'userID, entry, date, picture'; $diary->values = " '" . $user_data['ID'] . "', '" . $diary_note . "', '" . $mysqldate . "', '" . $upload_pic . "' "; $diary->insert(); unset($diary); } header("Location:" . ROOT_DIR . "improve/diary/index.html"); } elseif (!empty($_POST['submit_del'])) { $del_diary_entry = new ModifyEntry(); $del_diary_entry->table = $tbl_diary; $del_diary_entry->condition = "userID = '" . $user_data['ID'] . "' && ID = '" . $_POST['id_to_delete'] . "' "; $confirm_del = $del_diary_entry->delete(); if ($confirm_del === true && $_POST['pid'] != '') { $path = 'media/images/uploads/' . $user_data['ID'] . '/' . $_POST['pid']; $i_full = explode(".", $_POST['pid']); $path_full = 'media/images/uploads/' . $user_data['ID'] . '/' . $i_full[0] . '_full.' . $i_full[1]; unlink($path); //delete thumbnail unlink($path_full);
$blog->row(); unset($blog); /******************************************/ } else { /* Create Object :: INSERT */ $blog = new ModifyEntry(); /******************************************/ /* Insert new entry */ if (empty($_POST[name])) { $_POST[name] = $name_guest; } $_POST["comment"] = strip_tags($_POST["comment"]); $blog->table = $tbl_blog_comments; $blog->cols = 'bid, name, comment, lang, ip'; $blog->values = " '{$_POST['bid']}', '{$_POST['name']}', '{$_POST['comment']}', '{$lang_active}', '{$_SERVER['REMOTE_ADDR']}' "; $blog->insert(); /******************************************/ /* Prevent Spam :: Save IP and set cookie */ if ($set[0]["time_ban"] > 0) { $blog->table = $tbl_blog_spamban; $blog->cols = 'ip, bid'; $blog->values = " '{$_SERVER['REMOTE_ADDR']}', '{$_POST['bid']}' "; $blog->insert(); $spam = new CheckExist(); $c_name = "ip_" . $_POST[bid]; $c_content = $_SERVER['REMOTE_ADDR']; $c_time = time() + 60 * $set[0]["time_ban"]; $spam->cookieIP($c_name, $c_content, $c_time, '/'); unset($spam); } /******************************************/
$positionID = new SelectEntrys(); $positionID->cols = 'position'; $positionID->table = $tbl_design; $positionID->order = 'position DESC'; $positionID->limit = '1'; $positionID->module = ''; $positionID->template = ''; $positionID = $positionID->row() + 1; $design_new = new ModifyEntry(); $design_new->table = $tbl_design; $design_new->cols = 'german, english, hexcode, imgfolder, position'; $count = 0; foreach ($_POST["design_new_german"] as $element) { if ($design_new_hexcode[$count] != "" && $design_new_imgfolder[$count] != "") { $design_new->values = "'{$design_new_german[$count]}', '{$design_new_english[$count]}', '{$design_new_hexcode[$count]}', '{$design_new_imgfolder[$count]}', '{$positionID}'"; $design_new->insert(); $positionID++; } $count++; } unset($design_new); } /******************************************/ /* design :: Edit one or more entries */ if (count($_POST["design_german"]) > 0) { $design_edit = new ModifyEntry(); $design_edit->table = $tbl_design; $count = 0; foreach ($_POST["design_german"] as $element) { $design_edit->condition = " id = '{$design_id[$count]}' "; $design_edit->changes = " german = '{$design_german[$count]}', english = '{$design_english[$count]}', hexcode = '{$design_hexcode[$count]}', imgfolder = '{$design_imgfolder[$count]}' ";
if ($positionID == 0) { $positionID = 1; } $links_c_edit = new ModifyEntry(); $links_c_edit->table = $tbl_links_c; $links_c_edit->changes = " position = position+{$new_entries} "; $links_c_edit->update(); unset($links_c_edit); $links_c_new = new ModifyEntry(); $links_c_new->table = $tbl_links_c; $links_c_new->cols = 'german, english, position, visibility'; $count = 0; foreach ($_POST["links_c_new_german"] as $element) { if ($links_c_new_german[$count] != "" && $links_c_new_english[$count] != "") { $links_c_new->values = "'{$links_c_new_german[$count]}', '{$links_c_new_english[$count]}', '{$positionID}', '0' "; $links_c_new->insert(); $positionID++; } $count++; } unset($links_c_edit); } /******************************************/ /* design :: Edit one or more entries */ if (count($_POST["links_c_german"]) > 0) { $links_c_edit = new ModifyEntry(); $links_c_edit->table = $tbl_links_c; $links_c_edit->changes = " visibility = '0' "; $links_c_edit->update(); $count = 0; foreach ($_POST["links_c_german"] as $element) {
function rate($site, $id, $rating) { global $memcache; global $duration; global $_COOKIE; global $tpl; include 'settings/tables.php'; $objResponse = new xajaxResponse(); if (!isset($_COOKIE["l"])) { $objResponse->redirect(ROOT_DIR); return $objResponse; } $l["token"] = substr($_COOKIE["l"], 3, -35); $mem_key1 = "user_data_" . $l["token"]; $user_data = $memcache->get($mem_key1); $mem_key2 = "trigger_f_" . $l["token"]; $trigger_f = $memcache->get($mem_key2); include 'modules/logon/get_userdata.php'; $mem_key3 = "ay_flashes_voted_" . $l["token"]; $mem_key4 = "ay_flashes_rated_" . $l["token"]; $ay_flashes_voted = $memcache->get($mem_key3); $ay_flashes_rated = $memcache->get($mem_key4); $ay_flash_cats = $memcache->get('ay_flash_cats'); include 'modules/flash/flashfeed_add.php'; if ($site == 'flash') { $likes_str = 'p_likes_' . $id; $dislikes_str = 'p_dislikes_' . $id; $rate_str = 'p_rate_' . $id; $upd_data = new ModifyEntry(); $upd_data->table = $tbl_flashes; $upd_data->condition = " ID = '{$id}' "; if ($rating == "like") { $upd_data->changes = " likes = likes+1, rating = rating+1 "; } if ($rating == "dislike") { $upd_data->changes = " dislikes = dislikes+1, rating = rating-1 "; } $upd_data->update(); unset($upd_data); $ins_data = new ModifyEntry(); $ins_data->table = $tbl_flash_ratings; $ins_data->cols = 'flashID, userID, rating'; $ins_data->values = " '{$id}', '" . $user_data['ID'] . "', '{$rating}' "; $ins_data->insert(); unset($ins_data); $flash_result = new SelectEntrys(); $flash_result->cols = 'likes, dislikes'; $flash_result->table = $tbl_flashes; $flash_result->condition = " ID = '{$id}' "; $flash_result->multiSelect = 1; $ay_flash_result = $flash_result->row(); unset($flash_result); $ay_flashes_rated[] = $id; sort($ay_flashes_rated); $mem_key4 = "ay_flashes_rated_" . $l["token"]; $memcache->replace($mem_key4, $ay_flashes_rated, false); $objResponse->assign($rate_str, "style.display", 'none'); $objResponse->assign($likes_str, "innerHTML", $ay_flash_result[0]['likes']); $objResponse->assign($dislikes_str, "innerHTML", $ay_flash_result[0]['dislikes']); } return $objResponse; }
function registerUser($data, $action) { global $db; global $debug_mode; $objResponse = new xajaxResponse(); include 'settings/tables.php'; $reg_failure = ""; $email = trim(stripslashes(mysqli_real_escape_string($db, $data['email']))); $firstname = trim(stripslashes(mysqli_real_escape_string($db, $data['firstname']))); if ($action == 'register') { $password = trim(stripslashes(mysqli_real_escape_string($db, md5($data['password'])))); $password2 = trim(stripslashes(mysqli_real_escape_string($db, md5($data['password2'])))); $beta_code = trim(stripslashes(mysqli_real_escape_string($db, md5($data['betacode'])))); //generate activation code $act_code = md5(uniqid(rand())); $token = time() . uniqid(); //check if email is already registered $checkemail = new CheckExist(); $checkemail->tableE = $tbl_users; $checkemail->conditionE = " UserEmail = '" . $email . "' "; $CheckData = $checkemail->exist(); //error handling and validation if (!preg_match('/^([a-zA-Z0-9])+([\\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-]+)+/', $email)) { $reg_failure = "Email not valid."; } elseif (strlen($email) < 5) { $reg_failure = "Email not valid."; } elseif ($CheckData > 0) { $reg_failure = "Email already taken."; } elseif ($password != $password2) { $reg_failure = "Passwords do not match. Please correct your information and try it again."; } elseif (strlen($data['password']) < 5 || strlen($data['password2']) < 5) { $reg_failure = "Password is too short. Please correct your information and try it again."; } elseif (strlen($firstname) < 3) { $reg_failure = "Firstname is too short. Please correct your information and try it again."; } elseif ($beta_code != 'X2DH38u3z') { $reg_failure = "Beta Access Code not valid. Please correct your information and try it again."; } //registration validation successful if ($reg_failure == "") { //create new user in database $user_register = new ModifyEntry(); $user_register->table = $tbl_users; $user_register->cols = 'UserToken, UserEmail, UserPass, firstname, activation_code, language'; $user_register->values = " '{$token}', '{$email}', '{$password}', '{$firstname}', '{$act_code}', 'EN' "; $user_register->insert(); if ($user_register->errno() == 0) { //send email confirmation with activation link to user $Header = "MIME-Version: 1.0\n"; $Header .= "Content-type: text/plain; charset=utf-8\n"; $Header .= "From: noreply@happify.com"; //$from = "From: admin@wiwistud.de"; //activation.html?c=bebf08f7af79422ced07be79c2f2f5c0&t=13140575844e52ed70736d2 $act_link = ROOT_DIR . "logon/activation.html?c=" . $act_code . "&t=" . $token; $subject = "Activation link happify.com"; $message = "Activation link: " . $act_link; if ($debug_mode != "OFF") { require "../phpmailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP //IsSMTP(); // send via SMTP $mail->SMTPSecure = "ssl"; // sets the prefix to the servier $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; $mail->SMTPDebug = 0; $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $webmaster_email = "*****@*****.**"; //Reply to this email ID //$email="*****@*****.**"; // Recipients email ID //$name=$firstname; // Recipient's name //$mail->From = $webmaster_email; //$mail->FromName = "Happify"; $mail->SetFrom($webmaster_email, "Happify"); $mail->AddAddress($email, $firstname); //$mail->AddReplyTo($webmaster_email,"Webmaster"); //$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment //$mail->IsHTML(true); // send as HTML $mail->Subject = $subject; $mail->Body = $message; //HTML Body $mail->AltBody = $message; //Text Body $mail->Send(); } else { mail($email, $subject, $message, $Header); } $objResponse->assign("form_reg", "style.display", 'none'); $objResponse->assign("reg_success", "style.display", 'block'); unset($user_register); } else { $objResponse->assign("p_reg_failure", "style.display", 'block'); $objResponse->assign("p_reg_failure", "innerHTML", "Registration not successful. Please try again."); // TODO move string to language file } } else { $objResponse->assign("p_reg_failure", "style.display", 'block'); $objResponse->assign("p_reg_failure", "innerHTML", $reg_failure); } } else { if ($action == 'notify') { //check if email is already registered $checkemail = new CheckExist(); $checkemail->tableE = $tbl_notify; $checkemail->conditionE = " UserEmail = '" . $email . "' "; $CheckData = $checkemail->exist(); //TODO why does it not work on server if (!preg_match('/^([a-zA-Z0-9])+([\\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-]+)+/', $email)) { $reg_failure = "Email not valid."; } // TODO move string to language file if ($CheckData > 0) { $reg_failure = "Email already registered."; } // TODO move string to language file //registration validation successful if ($reg_failure == "") { //$firstname = $data['firstname']; //create new user in database $user_register = new ModifyEntry(); $user_register->table = $tbl_notify; $user_register->cols = 'UserEmail'; $user_register->values = " '" . $email . "' "; $user_register->insert(); if ($user_register->errno() == 0) { //send email confirmation with activation link to user $Header = "MIME-Version: 1.0\n"; $Header .= "Content-type: text/plain; charset=utf-8\n"; $Header .= "From: noreply@myhappifier.info"; $subject = "myhappifier.info Launch"; $message = "Hi! \r\n\n \nThank you for your registration. We will inform you as soon as Happify launches!\r\n\r\n\n \n \nUntil then: stay happy!"; if ($debug_mode != "OFF") { require "../phpmailer/class.phpmailer.php"; $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP //IsSMTP(); // send via SMTP $mail->SMTPSecure = "ssl"; // sets the prefix to the server $mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server $mail->Port = 465; $mail->SMTPDebug = 0; $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $webmaster_email = "*****@*****.**"; //Reply to this email ID //$email="*****@*****.**"; // Recipients email ID //$name=$firstname; // Recipient's name //$mail->From = $webmaster_email; //$mail->FromName = "Happify"; $mail->SetFrom($webmaster_email, "Happify"); $mail->AddAddress($email, $firstname); //$mail->AddReplyTo($webmaster_email,"Webmaster"); //$mail->WordWrap = 50; // set word wrap //$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment //$mail->AddAttachment("/tmp/image.jpg", "new.jpg"); // attachment //$mail->IsHTML(true); // send as HTML $mail->Subject = $subject; $mail->Body = $message; //HTML Body $mail->AltBody = $message; //Text Body $mail->Send(); //mail does not work } else { mail($email, $subject, $message, $Header); } $objResponse->assign("form_reg", "style.display", 'none'); $objResponse->assign("reg_success", "style.display", 'block'); unset($user_register); } else { $objResponse->assign("p_reg_failure", "style.display", 'block'); $objResponse->assign("p_reg_failure", "innerHTML", "Registration not successful. Please try again."); // TODO move string to language file } } else { $objResponse->assign("p_reg_failure", "style.display", 'block'); $objResponse->assign("p_reg_failure", "innerHTML", $reg_failure); } } } return $objResponse; }