function plugin($template, $customer) { global $documents_dirs; $result = ''; // xajax response object, can be used in the plugin $JSResponse = new xajaxResponse(); foreach ($documents_dirs as $doc) { if (file_exists($doc . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template)) { $doc_dir = $doc; continue; } } // read template information if (file_exists($file = $doc_dir . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'info.php')) { include $file; } // call plugin if (!empty($engine['plugin'])) { if (file_exists($file = $doc_dir . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $engine['name'] . DIRECTORY_SEPARATOR . $engine['plugin'] . '.php')) { include $file; } if (file_exists($doc_dir . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $engine['name'] . DIRECTORY_SEPARATOR . $engine['plugin'] . '.js')) { $JSResponse->removeScript($_SERVER['REQUEST_URI'] . '&template=' . $template); $JSResponse->includeScript($_SERVER['REQUEST_URI'] . '&template=' . $template); } } $JSResponse->assign('plugin', 'innerHTML', $result); $JSResponse->assign('title', 'value', isset($engine['form_title']) ? $engine['form_title'] : $engine['title']); return $JSResponse; }
function includeScript($sFilename) { $objResponse = new xajaxResponse(); $objResponse->includeScript($sFilename); return $objResponse; }
function selectdata($table, $data) { //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 == '') { require_once 'lib/functions/get_userdata.php'; } if ($table == $tbl_diary) { if ($data == 'clear_filter') { include "././lib/functions/fetch_diary.php"; } else { $selected_month = mysql_real_escape_string($data['month']); $selected_year = mysql_real_escape_string($data['year']); //$mysqldate = date( 'Y-m-d H:i:s', time() ); $start_date = date("Y-m-d H:i:s", mktime(0, 0, 0, $selected_month, 1, $selected_year)); $end_date = date("Y-m-d H:i:s", mktime(23, 59, 59, $selected_month + 1, 0, $selected_year)); //The last day of any given month can be expressed as the "0" day of the next month //strtotime("+1 month", $myTimestamp); //select new entry $diary = new SelectEntrys(); $diary->cols = "ID, entry, date, picture"; $diary->table = $tbl_diary; $diary->condition = " userID = '" . $user_data['ID'] . "' AND date >= '" . $start_date . "' AND date <= '" . $end_date . "' "; $diary->order = 'date DESC'; //$diary->limit = 10; $diary->multiSelect = 1; $ay_diary = $diary->row(); if (isset($ay_diary[0])) { require_once 'lib/functions/convert_date.php'; $count = 0; foreach ($ay_diary as $date_format) { $ay_diary[$count]["date"] = convert_date($date_format['date'], 0, $getmonth); $count++; } } } //refresh content //include("lib/functions/fetch_diary.php"); $tpl->assign('ay_diary', $ay_diary); //TODO why is this needed now!? $tpl->assign('user_data', $user_data); //if at least one entry exists if (isset($ay_diary[0])) { $tpl->assign('at_least_one_entry', 1); } else { $tpl->assign('at_least_one_entry', 0); } $html = $tpl->fetch("modules/home/diary_entries.tpl"); $objResponse->assign("diary_entries", "innerHTML", $html); // if ($data == 'clear_filter') { $objResponse->includeScript("js/pinterest.js"); $objResponse->call("m_reload"); // } } return $objResponse; }
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; }
function page($site, $id, $total) { global $memcache; global $tpl; global $duration; global $_COOKIE; //$tpl = new Smarty; include 'settings/tables.php'; include 'settings/page_settings.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'; if ($site == 'friendslist') { $objResponse->includeScript("http://connect.facebook.net/en_US/all.js#xfbml=1"); $page_friendslist = $id; $start_friendslist = $per_page_friendslist * $page_friendslist - $per_page_friendslist; $tpl->assign('per_page_friendslist', $per_page_friendslist); $tpl->assign('start_friendslist', $start_friendslist); $total_pages = ceil(count($user_data['fb_friends']) / $per_page_friendslist); $tpl->assign('total_pages', "{$total_pages}"); $tpl->assign('category', "friendslist"); $tpl->assign('current_page', $id); $tpl->assign("usr_data", $user_data); $html = $tpl->fetch("modules/account/friendslist.tpl"); $html2 = $tpl->fetch("pagenavi_ajax.tpl"); $objResponse->assign("friendslist", "innerHTML", $html); $objResponse->assign("pagenavi_friendslist", "innerHTML", $html2); } if ($site == 'favorites') { $page_favorites = $id; $start_favorites = $per_page_favorites * $page_favorites - $per_page_favorites; $tpl->assign('per_page_favorites', $per_page_favorites); $tpl->assign('start_favorites', $start_favorites); $total_pages = ceil($total / $per_page_favorites); $tpl->assign('total_pages', "{$total_pages}"); $tpl->assign('total', $total); $favorites = new SelectEntrys(); $favorites->cols = "{$tbl_favorites}.flashID, {$tbl_flashes}.question"; $favorites->table = $tbl_favorites; $favorites->join = " LEFT JOIN {$tbl_flashes} ON ({$tbl_flashes}.ID = {$tbl_favorites}.flashID) "; $favorites->condition = " {$tbl_favorites}.userID = '" . $user_data['ID'] . "' "; $favorites->order = "{$tbl_favorites}.time DESC"; $favorites->limit = "{$start_favorites}, {$per_page_favorites}"; $favorites->multiSelect = 1; $ay_favorites = $favorites->row(); $tpl->assign('ay_favorites', $ay_favorites); $tpl->assign('category', "favorites"); $tpl->assign('current_page', $id); $html = $tpl->fetch("modules/account/favorites_list.tpl"); $html2 = $tpl->fetch("pagenavi_ajax.tpl"); $objResponse->assign("p_favorites", "innerHTML", $html); $objResponse->assign("pagenavi_favorites", "innerHTML", $html2); } return $objResponse; }
function move($direction, $table, $position, $cid) { global $tpl; $objResponse = new xajaxResponse(); /* Distinguish between up and down movement */ if ($direction == "up") { $delimiter = "<"; $order = "DESC"; //$modify1 = "position = position-1"; //$modify2 = "position = position+1"; } else { $delimiter = ">"; $order = "ASC"; //$modify1 = "position = position+1"; //$modify2 = "position = position-1"; } /***********************************/ /* Let's move */ require_once 'lib/select.php'; require_once 'lib/modify.php'; $select = new SelectEntrys(); $select->table = $table; $select->cols = 'position'; $select->condition = " position {$delimiter} '{$position}' "; if ($cid) { $select->condition .= " AND cid = '{$cid}' "; } $select->order = "position {$order}"; $select->limit = '1'; $select->module = ''; $select->template = ''; $position_less = $select->row(); $select->cols = 'id'; $position_less_id = $select->row(); $update = new ModifyEntry(); $update->table = $table; if ($position > 1 && $direction == "up" || $position_less > 0 && $direction == "down") { $update->condition = " position = '{$position}' "; if ($cid) { $update->condition .= " AND cid = '{$cid}' "; } $update->changes = " position = '{$position_less}' "; $update->update(); $update->condition = " id = '{$position_less_id}' "; if ($cid) { $update->condition .= " AND cid = '{$cid}' "; } $update->changes = " position = '{$position}' "; $update->update(); } unset($select); unset($update); /***********************************/ /* Get data in new order */ require_once 'settings/config.php'; require_once 'settings/tables.php'; require_once 'settings/template.php'; if ($table == $tbl_profile) { $profile = new SelectEntrys(); $profile->cols = 'id, german, english, value, value_EN, position'; $profile->table = $table; $profile->order = 'position'; $profile->multiSelect = '1'; $tpl->assign('array_profile', $profile->row()); unset($profile); $html = $tpl->fetch("shortprofile_content.tpl"); $objResponse->assign("layout_navi_profile", "innerHTML", $html); $html = $tpl->fetch("admin/settings_profile_fields.tpl"); $objResponse->assign("layout_set_profile", "innerHTML", $html); } if ($table == $tbl_ref) { $ref = new SelectEntrys(); $ref->cols = 'id, link, description, description_EN, position'; $ref->table = $table; $ref->order = 'position'; $ref->multiSelect = '1'; $tpl->assign('array_ref', $ref->row()); unset($ref); $html = $tpl->fetch("quicklinks_content.tpl"); $objResponse->assign("layout_navi_ref", "innerHTML", $html); $html = $tpl->fetch("admin/settings_quicklinks_fields.tpl"); $objResponse->assign("layout_set_ref", "innerHTML", $html); } if ($table == $tbl_design) { $design = new SelectEntrys(); $design->cols = 'id, german, english, hexcode, imgfolder, position'; $design->table = $table; $design->order = 'position'; $design->multiSelect = '1'; $tpl->assign('array_design', $design->row()); unset($design); $html = $tpl->fetch("set_design.tpl"); $objResponse->assign("layout_navi_design", "innerHTML", $html); $html = $tpl->fetch("admin/settings_design_fields.tpl"); $objResponse->assign("layout_set_design", "innerHTML", $html); $objResponse->includeScript("js/change_settings.js"); $objResponse->call("reload_tpl"); } if ($table == $tbl_links_c) { $links_c = new SelectEntrys(); $links_c->cols = ' id, german, english, position, visibility '; $links_c->table = $tbl_links_c; $links_c->order = "position"; $links_c->multiSelect = '1'; $array_c = $links_c->row(); unset($links_c); $tpl->assign('array_c', $array_c); $html = $tpl->fetch("admin/links_c.tpl"); $objResponse->assign("layout_links_c", "innerHTML", $html); } if ($table == $tbl_links) { $links_l = new SelectEntrys(); $links_l->cols = 'id, cid, link, description, description_EN, position, visibility'; $links_l->table = $table; $links_l->condition = "cid = '{$cid}' "; // due to performance concerns $links_l->order = 'cid, position'; $links_l->multiSelect = '1'; $array_l = $links_l->row(); foreach ($array_l as $array1 => $array2) { $array[$array2["cid"]][$array2["id"]] = array('id' => $array2["id"], 'cid' => $array2["cid"], 'link' => $array2["link"], 'description' => $array2["description"], 'description_EN' => $array2["description_EN"], 'position' => $array2["position"], 'visibility' => $array2["visibility"]); } $tpl->assign("this", $cid); $tpl->assign("array", $array); unset($links_l); $html = $tpl->fetch("admin/links_l.tpl"); $p_name = "layout_links_l_" . $cid; $objResponse->assign($p_name, "innerHTML", $html); } return $objResponse; /***********************************/ }