function themify_import()
{
    if (!empty($_FILES)) {
        if (!is_dir(TEMPLATEPATH . '/themify/temp')) {
            mkdir(TEMPLATEPATH . '/themify/temp', 0777);
        }
        if (move_uploaded_file($_FILES['Filedata']['tmp_name'], TEMPLATEPATH . '/themify/temp/' . basename($_FILES['Filedata']['name']))) {
            $file = basename($_FILES['Filedata']['name']);
            $ext = substr(strrchr($file, '.'), 1);
            $dir = "temp/";
            if ($ext == 'zip' || $ext == 'rar') {
                themify_extract_zip(TEMPLATEPATH . '/themify/' . $dir . $file);
            } else {
                if ($ext == 'txt') {
                    $handler = fopen($dir . $file, 'r');
                    if (filesize($dir . $file) > 0) {
                        $data = fread($handler, filesize($dir . $file));
                        set_data(unserialize($data));
                    }
                    fclose($fh);
                }
            }
            $handle = opendir("temp/");
            while ($file = readdir($handle)) {
                if ($file != "." && $file != "..") {
                    unlink("temp/" . $file);
                }
            }
            rmdir("temp/");
            echo "true";
        } else {
            echo "false";
        }
    }
}
Esempio n. 2
0
function set_queData($list)
{
    $data = '';
    foreach ($list as $key => $value) {
        $choices = set_data(parse_config($value['a_choices']));
        $typedata = set_data(parse_config($value['a_typedata']));
        $data .= "{\n            \t          quesid: '{$value['id']}',\n                       titletype: '{$value['q_titletype']}',\n                           title: '{$value['q_title']}',\n                        typedata: [{$typedata}],\n                         choices: [{$choices}],\n                            type:'{$value['a_type']}',\n                      rightIndex: '{$value['q_right']}'\n                      },";
    }
    return $data;
}
Esempio n. 3
0
function jsondb_data($db_name, $table_name, $mapper_key, $data = null)
{
    if ($data) {
        if ($data === 'remove') {
            return del_data($db_name, $table_name, $mapper_key);
        } else {
            return set_data($db_name, $table_name, $mapper_key, $data);
        }
    } else {
        return get_data($db_name, $table_name, $mapper_key);
    }
}
Esempio n. 4
0
/**
* This page serves as the registration page for new users.
*/
require_once 'db_connection.php';
require 'set_data.php';
require 'validate.php';
require 'db_functions.php';
// check if photo's file name is present in the session
if (!isset($_SESSION['photo'])) {
    $photo = "";
}
// if the user has submitted the form
if (isset($_POST['submit'])) {
    // set submitted data to an array $record
    $record = set_data($_POST, $_FILES, $connection);
    // set session to store the name of the photo so that we can have the photo during resubmission
    // (in case of validation errors)
    $_SESSION['photo'] = $record['photo'];
    // validate data in $record
    $errors = validate($record, $connection, "register");
    // if no error exists after validation then encrypt the passwords and
    // enter the details to the database.
    if (!$errors) {
        $record['password'] = md5($record['password']);
        $status = insert_record($record, $connection);
        if ($status == 1) {
            header("Location: mail.php");
        } else {
            $errors .= $status;
        }
Esempio n. 5
0
function send_and_set_data($snt, $commenter_info, $msg)
{
    send_commenter($snt, $commenter_info, $msg);
    set_data($snt, $commenter_info);
}
Esempio n. 6
0
 function show_list()
 {
     # message after add or edit
     $this->content_saved = $_SESSION['content_saved'];
     $_SESSION['content_saved'] = '';
     # default sort (a = ascending)
     $ad = 'a';
     if ($_GET['sort'] && in_array($_GET['sort'], $this->fields_in_list_view)) {
         if ($_GET['ad'] == 'a') {
             $asc_des = 'ASC';
         }
         if ($_GET['ad'] == 'd') {
             $asc_des = 'DESC';
         }
         $order_by = "ORDER by " . $_GET['sort'] . ' ' . $asc_des;
     } else {
         $order_by = "ORDER by {$this->primary_key} DESC";
     }
     # navigation 1/3
     $start = $_GET["start"];
     if (!$start) {
         $start = 0;
     } else {
         $start *= 1;
     }
     // build query_string
     // query_joomla_component (joomla)
     if ($this->query_joomla_component) {
         $query_string = '&option=' . $this->query_joomla_component;
     }
     // navigation
     $query_string .= '&start=' . $start;
     // sorting
     $query_string .= '&ad=' . $_GET['ad'] . '&sort=' . $_GET['sort'];
     // searching
     $query_string .= '&s=' . $_GET['s'] . '&f=' . $_GET['f'];
     //table
     $query_string .= '&table=' . $_GET['table'] . '';
     # search
     if ($_GET['s'] && $_GET['f']) {
         $in_search = addslashes(stripslashes($_GET['s']));
         $in_search_field = $_GET['f'];
         if ($in_search_field == $this->primary_key) {
             $where_search = "WHERE {$in_search_field} = '{$in_search}' ";
         } else {
             $where_search = "WHERE {$in_search_field} LIKE '%{$in_search}%' ";
         }
     }
     # select
     $sql = "SELECT * FROM `{$this->table}` {$where_search} {$order_by}";
     /*
      *	if sorting by distance
      */
     if ($_GET['sort'] && $_GET['sort'] == "distance") {
         if ($_GET['ad'] == 'a') {
             $asc_des = 'DESC';
         }
         if ($_GET['ad'] == 'd') {
             $asc_des = 'ASC';
         }
         // figure out what coords to calculate from
         $usable_coords = usable_coords();
         $rusex = $usable_coords["x"];
         $rusey = $usable_coords["y"];
         $rusez = $usable_coords["z"];
         $res2 = mysqli_query($GLOBALS["___mysqli_ston"], "\tSHOW COLUMNS\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `{$this->table}`") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
         while ($rij3 = mysqli_fetch_assoc($res2)) {
             $fields[] = $this->table . '.' . $rij3["Field"];
         }
         $fieldss = join(",", $fields);
         if ($asc_des == "DESC") {
             $order_by = "ORDER BY -(sqrt(pow((ritem_coordx-(" . $rusex . ")),2)+pow((ritem_coordy-(" . $rusey . ")),2)+pow((ritem_coordz-(" . $rusez . ")),2)))" . $asc_des;
         } else {
             $order_by = "ORDER BY sqrt(pow((ritem_coordx-(" . $rusex . ")),2)+pow((ritem_coordy-(" . $rusey . ")),2)+pow((ritem_coordz-(" . $rusez . ")),2)) DESC";
         }
         if ($this->table == "edtb_systems") {
             $sql = "SELECT " . $fieldss . ",edtb_systems.x AS ritem_coordx,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.y AS ritem_coordy,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.z AS ritem_coordz\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\t\t\t\t\t\t\t\t{$order_by}";
         } elseif ($this->table == "edtb_stations") {
             $sql = "SELECT " . $fieldss . ",edtb_systems.x AS ritem_coordx,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.y AS ritem_coordy,\n\t\t\t\t\t\t\t\t\t\t\t\tedtb_systems.z AS ritem_coordz\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN edtb_systems ON {$this->table}.system_id = edtb_systems.id\n\t\t\t\t\t\t\t\t\t\t\t\t{$order_by}";
         } else {
             $sql = "SELECT " . $fieldss . ",IFNULL(edtb_systems.x, user_systems_own.x) AS ritem_coordx,\n\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(edtb_systems.y, user_systems_own.y) AS ritem_coordy,\n\t\t\t\t\t\t\t\t\t\t\t\tIFNULL(edtb_systems.z, user_systems_own.z) AS ritem_coordz\n\t\t\t\t\t\t\t\t\t\t\t\tFROM {$this->table}\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN edtb_systems ON {$this->table}.system_name = edtb_systems.name\n\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN user_systems_own ON {$this->table}.system_name = user_systems_own.name\n\t\t\t\t\t\t\t\t\t\t\t\t{$order_by}";
         }
         //write_log($sql);
     }
     $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql);
     # navigation 2/3
     $hits_total = mysqli_num_rows($result);
     $sql .= " LIMIT {$start}, {$this->num_rows_list_view}";
     $result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
     if (mysqli_num_rows($result) > 0) {
         $result2 = mysqli_query($GLOBALS["___mysqli_ston"], "SHOW COLUMNS FROM `{$this->table}`") or write_log(mysqli_error($GLOBALS["___mysqli_ston"]), __FILE__, __LINE__);
         while ($rij2 = mysqli_fetch_assoc($result2)) {
             extract($rij2);
             $field_type[$Field] = $Type;
         }
         $count = 0;
         while ($rij = mysqli_fetch_assoc($result)) {
             $count++;
             $this_row = '';
             if ($background == '#38484F') {
                 $background = '#273238';
             } else {
                 $background = '#38484F';
             }
             $dist = false;
             $dist1 = false;
             $exact = "";
             $d_x = "";
             $d_y = "";
             $d_z = "";
             if (array_key_exists("x", $rij) && array_key_exists("y", $rij) && array_key_exists("z", $rij) || array_key_exists("system_name", $rij) || array_key_exists("system_id", $rij)) {
                 $dist = true;
                 $dist1 = true;
                 if (isset($rij["x"]) && isset($rij["y"]) && isset($rij["z"])) {
                     $d_x = $rij["x"];
                     $d_y = $rij["y"];
                     $d_z = $rij["z"];
                 } elseif (isset($rij["system_id"])) {
                     $sys_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE id = '" . $rij["system_id"] . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                     $found = mysqli_num_rows($sys_res);
                     if ($found > 0) {
                         $sys_arr = mysqli_fetch_assoc($sys_res);
                         $d_x = $sys_arr["x"];
                         $d_y = $sys_arr["y"];
                         $d_z = $sys_arr["z"];
                     }
                 } elseif (isset($rij["system_name"]) || $found == 0) {
                     if (valid_coordinates($rij["ritem_coordx"], $rij["ritem_coordy"], $rij["ritem_coordz"])) {
                         $d_x = $rij["ritem_coordx"];
                         $d_y = $rij["ritem_coordy"];
                         $d_z = $rij["ritem_coordz"];
                     } else {
                         $sys_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM edtb_systems\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $rij["system_name"]) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                         $found = mysqli_num_rows($sys_res);
                         if ($found > 0) {
                             $sys_arr = mysqli_fetch_assoc($sys_res);
                             $d_x = $sys_arr["x"];
                             $d_y = $sys_arr["y"];
                             $d_z = $sys_arr["z"];
                         } else {
                             $sys_own_res = mysqli_query($GLOBALS["___mysqli_ston"], "\tSELECT x, y, z\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM user_systems_own\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE name = '" . mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $rij["system_name"]) . "'\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tLIMIT 1");
                             $own_found = mysqli_num_rows($sys_own_res);
                             if ($own_found > 0) {
                                 $sys_own_arr = mysqli_fetch_assoc($sys_own_res);
                                 $d_x = $sys_own_arr["x"];
                                 $d_y = $sys_own_arr["y"];
                                 $d_z = $sys_own_arr["z"];
                             } else {
                                 $d_x = "";
                                 $d_y = "";
                                 $d_z = "";
                             }
                         }
                     }
                 } else {
                     $d_x = "";
                     $d_y = "";
                     $d_z = "";
                 }
             }
             $ii = 0;
             foreach ($rij as $key => $value) {
                 $field_kind = $field_type[$key];
                 $enum = false;
                 $align = "";
                 if ($field_kind == "enum('','0','1')" || $field_kind == "enum('0','1')") {
                     $align = "text-align:center;";
                     $enum = true;
                 }
                 //echo $field_kind;
                 $sort_image = '';
                 if (in_array($key, $this->fields_in_list_view)) {
                     if ($count == 1) {
                         // show nice text of a value
                         if ($this->show_text[$key]) {
                             $show_key = $this->show_text[$key];
                         } else {
                             $show_key = $key;
                         }
                         // sorting
                         if ($_GET['sort'] == $key && $_GET['ad'] == 'a') {
                             $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt=''>";
                             $ad = 'd';
                         }
                         if ($_GET['sort'] == $key && $_GET['ad'] == 'd') {
                             $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt=''>";
                             $ad = 'a';
                         }
                         // remove sort  and ad and add new ones
                         $query_sort = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort={$key}&ad={$ad}";
                         //
                         if (isset($this->skip)) {
                             if (!in_array($key, $this->skip)) {
                                 $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>";
                             }
                         } else {
                             $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>";
                         }
                         // add distance if x,y,z are defined
                         if ($dist1 !== false) {
                             if ($_GET['sort'] == "distance" && $_GET['ad'] == 'a') {
                                 $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt=''>";
                                 $ad = 'd';
                             }
                             if ($_GET['sort'] == "distance" && $_GET['ad'] == 'd') {
                                 $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt=''>";
                                 $ad = 'a';
                             }
                             $query_sort_d = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort=distance&ad={$ad}";
                             $head .= "<td style='white-space:nowrap;padding:10px'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort_d}' class='mte_head'>Distance</a> {$sort_image}</td>";
                             $dist1 = false;
                         }
                     }
                     if ($key == $this->primary_key) {
                         if (substr($this->table, 0, 4) == "edtb") {
                             $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'></td>";
                         } else {
                             $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'><a href='javascript:void(0)' onclick='del_confirm({$value})' title='Delete {$this->show_text[$key]} {$value}'><img src='/style/img/del.png' style='width:16px;height:16px;border:none' alt=''></a>&nbsp;<a href='?{$query_string}&mte_a=edit&id={$value}' title='Edit {$this->show_text[$key]} {$value}'><img src='/style/img/edit.png' style='width:16px;height:16px;border:none' alt='Edit'></a></td>";
                         }
                         if ($key == "id" && $this->table == "edtb_systems") {
                             $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'><a href='/system.php?system_id=" . $value . "'>" . $value . "</a></td>";
                         } else {
                             $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'>{$value}</td>";
                         }
                     } else {
                         if (isset($this->skip)) {
                             if (!in_array($key, $this->skip)) {
                                 $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum);
                             }
                         } else {
                             $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum);
                         }
                     }
                     $ii++;
                 }
             }
             $rows .= "<tr style='border-bottom:1px solid #000;background:{$background}'>{$buttons} {$this_row}</tr>";
         }
     } else {
         $head = "<td style='padding:40px'>{$this->text['Nothing_found']}...</td>";
     }
     # navigation 3/3
     # remove start= from url
     $query_nav = preg_replace('/&(start|mte_a|id)=[^&]*/', '', $query_string);
     # this page
     $this_page = ($this->num_rows_list_view + $start) / $this->num_rows_list_view;
     # last page
     $last_page = ceil($hits_total / $this->num_rows_list_view);
     # navigatie numbers
     if ($this_page > 10) {
         $vanaf = $this_page - 10;
     } else {
         $vanaf = 1;
     }
     if ($last_page > $this_page + 10) {
         $tot = $this_page + 10;
     } else {
         $tot = $last_page;
     }
     for ($f = $vanaf; $f <= $tot; $f++) {
         $nav_toon = $this->num_rows_list_view * ($f - 1);
         if ($f == $this_page) {
             $navigation .= "<td class='mte_nav' style='color:#fffffa;background-color:#808080;font-weight:bold'>{$f}</td> ";
         } else {
             $navigation .= "<td class='mte_nav' style='background-color:#0e0e11'><a data-replace='true' data-target='.rightpanel' class='mtelink' href='{$this->url_script}?{$query_nav}&start={$nav_toon}'>{$f}</a></td>";
         }
     }
     if ($hits_total < $this->num_rows_list_view) {
         $navigation = '';
     }
     # Previous if
     if ($this_page > 1) {
         $last = ($this_page - 1) * $this->num_rows_list_view - $this->num_rows_list_view;
         $last_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$last}' class='mte_nav_prev_next'>{$this->text['Previous']}</a>";
     }
     # Next if:
     if ($this_page != $last_page && $hits_total > 1) {
         $next = $start + $this->num_rows_list_view;
         $next_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$next}' class='mte_nav_prev_next'>{$this->text['Next']}</a>";
     }
     $this->nav_bottom = '<span class="right" style="padding-top:6px">Number of entries: ';
     $this->nav_bottom .= number_format($hits_total);
     $this->nav_bottom .= '</span>';
     if ($navigation) {
         $nav_table = "\n\t\t\t\t<table style='border-collapse:separate;border-spacing:5px;margin-left:35%;margin-right:auto'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td style='padding-right:6px;vertical-align:middle'>{$last_page_html}</td>\n\t\t\t\t\t\t{$navigation}\n\t\t\t\t\t\t<td style='padding-left:6px;vertical-align:middle'>{$next_page_html}</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>\n\t\t\t";
         $this->nav_top = "\n\t\t\t\t<div style='margin-bottom:5px;margin-top:-20px;width:{$this->width_editor}'>\n\t\t\t\t\t\t{$nav_table}\n\t\t\t\t</div>\n\t\t\t";
         $this->nav_bottom .= "\n\t\t\t\t<div style='margin-top:20px;width:100%;text-align:center'>\n\t\t\t\t\t\t{$nav_table}\n\t\t\t\t</div>\n\t\t\t";
     }
     # Search form + Add Record button
     foreach ($this->fields_in_list_view as $option) {
         if ($this->show_text[$option]) {
             $show_option = $this->show_text[$option];
         } else {
             $show_option = $option;
         }
         if ($option == $in_search_field) {
             $options .= "<option selected value='{$option}'>{$show_option}</option>";
         } else {
             $options .= "<option value='{$option}'>{$show_option}</option>";
         }
     }
     $in_search_value = htmlentities(trim(stripslashes($_GET['s'])), ENT_QUOTES);
     $seach_form = "\n\t\t\t<table style='margin-left:0;padding-left:0;border-collapse:collapse;border-spacing:0'>\n\t\t\t\t<tr>\n\t\t\t\t\t<td style='white-space:nowrap;padding-bottom:20px'>\n\t\t\t\t\t\t<form method=get action='{$this->url_script}'>\n\t\t\t\t\t\t\t<input type='hidden' name='table' value='" . $_GET["table"] . "'>\n\t\t\t\t\t\t\t<select class='selectbox' name='f'>{$options}</select>\n\t\t\t\t\t\t\t<input class='textbox' type='text' name='s' value='{$in_search_value}' style='width:220px'>\n\t\t\t\t\t\t\t<input class='button' type='submit' value='{$this->text['Search']}' style='width:80px'>\n\t\t\t\t";
     if ($this->query_joomla_component) {
         $seach_form .= "<input type='hidden' value='{$this->query_joomla_component}' name='option'>";
     }
     $seach_form .= "</form>";
     if ($_GET['s'] && $_GET['f']) {
         if ($this->query_joomla_component) {
             $add_joomla = '?option=' . $this->query_joomla_component;
         }
         $seach_form .= "<button class='button' style='margin-left:0;margin-top:6px' onclick='window.location=\"{$this->url_script}{$add_joomla}\"' style='margin: 0 0 10px 10px'>{$this->text['Clear_search']}</button>";
     }
     $seach_form .= "\n\t\t\t\t\t</td>\n\n\t\t\t\t\t<td style='text-align:right;width:{$this->width_editor}'>";
     if (substr($this->table, 0, 4) != "edtb") {
         $seach_form .= "<button class='button' onclick='window.location=\"{$this->url_script}?{$query_string}&mte_a=new\"' style='margin: 0 0 10px 10px'>{$this->text['Add_Record']}</button>";
     } else {
         $seach_form .= "&nbsp;";
     }
     $seach_form .= "</td>\n\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t";
     // $this->javascript = "
     // function del_confirm(id) {
     // if (confirm('{$this->text['Delete']} record {$this->show_text[$this->primary_key]} ' + id + '...?')) {
     // window.location='$this->url_script?$query_string&mte_a=del&id=' + id
     // }
     // }
     // ";
     $this->javascript = "\n\t\t\tfunction del_confirm(id) {\n\t\t\t\tif (confirm('{$this->text['Delete']} record {$this->show_text[$this->primary_key]} ' + id + '...?')) {\n\t\t\t\t\twindow.location=window.location.href + '&mte_a=del&id=' + id\n\t\t\t\t}\n\t\t\t}\n\t\t";
     # page content
     $this->content = "\n\t\t\t<div style='width: {$this->width_editor};background:transparent;margin:0;border:none'>{$seach_form}</div>\n\t\t\t<table style='text-align:left;margin:0;border-collapse:collapse;border-spacing:0;width:{$this->width_editor}'>\n\t\t\t\t<tr style='background:#0e0e11; color: #fff'><td></td>{$head}</tr>\n\t\t\t\t{$rows}\n\t\t\t</table>\n\n\t\t\t{$this->nav_bottom}\n\t\t";
 }
Esempio n. 7
0
                array_push($values, $_POST['data']['latlng']['lat']);
            }
            if (isset($_POST['data']['latlng']['lng'])) {
                array_push($idx, 'lng');
                array_push($values, $_POST['data']['latlng']['lng']);
            }
        }
        if (isset($_POST['data']['options']['minLevel'])) {
            array_push($idx, 'min_zoom');
            array_push($values, $_POST['data']['options']['minLevel']);
        }
        if (isset($_POST['data']['options']['maxLevel'])) {
            array_push($idx, 'max_zoom');
            array_push($values, $_POST['data']['options']['maxLevel']);
        }
        set_data('project_marker', 'project_id', $_POST['data']['id'], $idx, $values);
    }
}
if ($_POST['req'] == "delData") {
    if ($_POST['data']['options']['type'] == "project") {
        del_data('project', 'project_id', $_POST['data']['id']);
        removeDir("project/{$_POST['data']['id']}");
    }
    if ($_POST['data']['options']['type'] == "layer") {
        del_data('layer', 'layer_id', $_POST['data']['id']);
    }
    if ($_POST['data']['options']['type'] == "vtour") {
        del_data('vtour', 'vtour_id', $_POST['data']['id']);
    }
    if ($_POST['data']['options']['type'] == "pvr") {
        del_data('pvr', 'pvr_id', $_POST['data']['id']);
Esempio n. 8
0
function set_pk($entity_class, $data = array())
{
    return set_data($entity_class, $data, 'pk');
}
Esempio n. 9
0
         $old_id = $marker['marker_id'];
         $new_id = alloc_new_marker_id();
         $trans_id_table['marker'][$old_id] = $new_id;
         //transform old data into new data
         $marker['layer_id'] = $trans_id_table['layer'][$marker['layer_id']];
         $marker['icon_id'] = $trans_id_table['marker_icon'][$marker['icon_id']];
         //delete id from array to save data correctly
         unset($marker['marker_id']);
         //save data to DB
         $fields = array();
         $values = array();
         foreach ($marker as $field => $value) {
             $fields[] = $field;
             $values[] = $value;
         }
         set_data('marker', 'marker_id', $new_id, $fields, $values);
     }
 }
 if (array_key_exists('m_link_inform', $pano_video_data)) {
     for ($i = 0; $i < count($pano_video_data['m_link_inform']); $i++) {
         $m_link_inform = $pano_video_data['m_link_inform'][$i];
         $old_id = $m_link_inform['marker_id'];
         $new_id = $trans_id_table['marker'][$m_link_inform['marker_id']];
         //delete keys from field array
         $keys = array();
         $keys['marker_id'] = $new_id;
         unset($m_link_inform['marker_id']);
         //save data to DB
         set_data_with_comp_pk('m_link_inform', $keys, $m_link_inform);
     }
 }
 function themify_extract_zip($file)
 {
     $zip = zip_open($file);
     $dir = "temp/";
     if (is_resource($zip)) {
         while ($zip_entry = zip_read($zip)) {
             // echo $dir.basename(zip_entry_name($zip_entry));
             $fp = fopen($dir . basename(zip_entry_name($zip_entry)), "w");
             if (zip_entry_open($zip, $zip_entry, "r")) {
                 $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
                 fwrite($fp, "{$buf}");
                 zip_entry_close($zip_entry);
                 fclose($fp);
             }
         }
         zip_close($zip);
     } else {
         echo zipFileErrMsg($zip);
     }
     if (file_exists($dir . "custom-config.xml")) {
         unlink("../custom-config.xml");
         rename($dir . "custom-config.xml", "../custom-config.xml");
     }
     if (file_exists($dir . "custom-modules.php")) {
         unlink("../custom-modules.php");
         rename($dir . "custom-modules.php", "../custom-modules.php");
     }
     if (file_exists($dir . "custom-functions.php")) {
         unlink("../custom-functions.php");
         rename($dir . "custom-functions.php", "../custom-functions.php");
     }
     if (file_exists($dir . "data_export.txt")) {
         $handler = fopen($dir . "data_export.txt", "r");
         $data = fread($handler, filesize($dir . "data_export.txt"));
         set_data(unserialize($data));
         fclose($handler);
     }
 }
Esempio n. 11
0
File: mte.php Progetto: DBnR1/EDTB
    /**
     * Show records
     */
    private function show_list()
    {
        // message after add or edit
        $this->content_saved = $_SESSION["content_saved"];
        $_SESSION["content_saved"] = "";
        // default sort (a = ascending)
        $ad = "a";
        if ($_GET["sort"] && in_array($_GET["sort"], $this->fields_in_list_view)) {
            if ($_GET["ad"] == "a") {
                $asc_des = "ASC";
            }
            if ($_GET["ad"] == "d") {
                $asc_des = "DESC";
            }
            $this->order_by = "ORDER by " . $_GET["sort"] . " " . $asc_des;
        } else {
            $this->order_by = "ORDER by {$this->primary_key} DESC";
        }
        // navigation 1/3
        $start = $_GET["start"];
        if (!$start) {
            $start = 0;
        } else {
            $start *= 1;
        }
        /**
         * build query_string
         */
        // navigation
        $query_string .= "&start=" . $start;
        // sorting
        $query_string .= "&ad=" . $_GET["ad"] . "&sort=" . $_GET["sort"];
        // searching
        $query_string .= "&s=" . $_GET["s"] . "&f=" . $_GET["f"];
        //table
        $query_string .= "&table=" . $_GET["table"];
        /**
         * search
         */
        if ($_GET["s"] && $_GET["f"]) {
            $in_search = addslashes(stripslashes($_GET["s"]));
            $in_search_field = $_GET["f"];
            if ($in_search_field == $this->primary_key) {
                $this->where_search = "WHERE {$in_search_field} = '{$in_search}' ";
            } else {
                $this->where_search = "WHERE {$in_search_field} LIKE '%{$in_search}%' ";
            }
        }
        /**
         * get sql query
         */
        $sql = $this->get_sql();
        $hits = $this->mysqli->query($sql) or write_log($this->mysqli->error, __FILE__, __LINE__);
        // navigation 2/3
        $hits_total = $hits->num_rows;
        $hits->close();
        $sql .= " LIMIT {$start}, {$this->num_rows_list_view}";
        $result = $this->mysqli->query($sql) or write_log($this->mysqli->error, __FILE__, __LINE__);
        if ($result->num_rows > 0) {
            $query = "SHOW COLUMNS FROM `{$this->table}`";
            $cols = $this->mysqli->query($query) or write_log($this->mysqli->error, __FILE__, __LINE__);
            while ($obj = $cols->fetch_object()) {
                $Field = $obj->Field;
                $Type = $obj->Type;
                $field_type[$Field] = $Type;
            }
            $cols->close();
            $count = 0;
            while ($data = $result->fetch_object()) {
                $count++;
                $this_row = "";
                $background = $background == "#38484f" ? "#273238" : "#38484f";
                $dist = false;
                $dist1 = false;
                $d_x = "";
                $d_y = "";
                $d_z = "";
                $esc_sys_name = $this->mysqli->real_escape_string($data->system_name);
                if (property_exists($data, "x") && property_exists($data, "y") && property_exists($data, "z") || property_exists($data, "system_name") || property_exists($data, "system_id")) {
                    $dist = true;
                    $dist1 = true;
                    if (isset($data->x) && isset($data->y) && isset($data->z)) {
                        $d_x = $data->x;
                        $d_y = $data->y;
                        $d_z = $data->z;
                    } elseif (isset($data->system_id)) {
                        $query = "  SELECT x, y, z\n                                    FROM edtb_systems\n                                    WHERE id = '{$data->system_id}'\n                                    LIMIT 1";
                        $coord_result = $this->mysqli->query($query);
                        $found = $coord_result->num_rows;
                        if ($found > 0) {
                            $obj = $coord_result->fetch_object();
                            $d_x = $obj->x;
                            $d_y = $obj->y;
                            $d_z = $obj->z;
                        }
                        $coord_result->close();
                    } elseif (isset($data->system_name) || $found == 0) {
                        if (valid_coordinates($data->ritem_coordx, $data->ritem_coordy, $data->ritem_coordz)) {
                            $d_x = $data->ritem_coordx;
                            $d_y = $data->ritem_coordy;
                            $d_z = $data->ritem_coordz;
                        } else {
                            $query = "  SELECT x, y, z\n                                        FROM edtb_systems\n                                        WHERE name = '{$esc_sys_name}'\n                                        LIMIT 1";
                            $coord_result = $this->mysqli->query($query);
                            $found = $coord_result->num_rows;
                            if ($found > 0) {
                                $obj = $coord_result->fetch_object();
                                $d_x = $obj->x;
                                $d_y = $obj->y;
                                $d_z = $obj->z;
                            } else {
                                $query = "  SELECT x, y, z\n                                            FROM user_systems_own\n                                            WHERE name = '{$esc_sys_name}'\n                                            LIMIT 1";
                                $coord_result = $this->mysqli->query($query);
                                $own_found = $coord_result->num_rows;
                                if ($own_found > 0) {
                                    $obj = $coord_result->fetch_object();
                                    $d_x = $obj->x;
                                    $d_y = $obj->y;
                                    $d_z = $obj->z;
                                } else {
                                    $d_x = "";
                                    $d_y = "";
                                    $d_z = "";
                                }
                            }
                            $coord_result->close();
                        }
                    } else {
                        $d_x = "";
                        $d_y = "";
                        $d_z = "";
                    }
                }
                $ii = 0;
                foreach ($data as $key => $value) {
                    $field_kind = $field_type[$key];
                    $enum = false;
                    $align = "";
                    if ($field_kind == "enum('','0','1')" || $field_kind == "enum('0','1')") {
                        $align = "text-align:center;";
                        $enum = true;
                    }
                    //echo $field_kind;
                    $sort_image = "";
                    if (in_array($key, $this->fields_in_list_view)) {
                        if ($count == 1) {
                            // show nice text of a value
                            if ($this->show_text[$key]) {
                                $show_key = $this->show_text[$key];
                            } else {
                                $show_key = $key;
                            }
                            // sorting
                            if ($_GET["sort"] == $key && $_GET["ad"] == "a") {
                                $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt='Asc' id='sort_a'>";
                                $ad = "d";
                            }
                            if ($_GET["sort"] == $key && $_GET["ad"] == "d") {
                                $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt='Desc' id='sort_d'>";
                                $ad = "a";
                            }
                            // remove sort  and ad and add new ones
                            $query_sort = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort={$key}&ad={$ad}";
                            //
                            if (isset($this->skip)) {
                                if (!in_array($key, $this->skip)) {
                                    $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>";
                                }
                            } else {
                                $head .= "<td style='white-space:nowrap;padding:10px;" . $align . "'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort}' class='mte_head'>{$show_key}</a> {$sort_image}</td>";
                            }
                            // add distance if x,y,z are defined
                            if ($dist1 !== false) {
                                if ($_GET["sort"] == "distance" && $_GET["ad"] == "a") {
                                    $sort_image = "<img src='/style/img/sort_a.png' style='width:9px;height:8px;border:none' alt=''>";
                                    $ad = "d";
                                }
                                if ($_GET["sort"] == "distance" && $_GET["ad"] == "d") {
                                    $sort_image = "<img src='/style/img/sort_d.png' style='width:9px;height:8px;border:none' alt=''>";
                                    $ad = "a";
                                }
                                $query_sort_d = preg_replace('/&(sort|ad)=[^&]*/', '', $query_string) . "&sort=distance&ad={$ad}";
                                $head .= "<td style='white-space:nowrap;padding:10px'><a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_sort_d}' class='mte_head'>Distance</a> {$sort_image}</td>";
                                $dist1 = false;
                            }
                        }
                        if ($key == $this->primary_key) {
                            if (substr($this->table, 0, 4) == "edtb") {
                                $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'></td>";
                            } else {
                                $buttons = "<td style='width:1%;white-space:nowrap;padding:10px;vertical-align:middle'><a href='javascript:void(0)' onclick='del_confirm({$value})' class='delete_record' title='Delete {$this->show_text[$key]} {$value}' id='delete_" . $value . "'><img src='/style/img/del.png' style='width:16px;height:16px;border:none' alt='Delete' class='data_point_delete'></a>&nbsp;<a href='?{$query_string}&mte_a=edit&id={$value}' class='edit_record' title='Edit {$this->show_text[$key]} {$value}' id='edit_" . $value . "'><img src='/style/img/edit.png' style='width:16px;height:16px;border:none' alt='Edit' class='data_point_edit'></a></td>";
                            }
                            if ($key == "id" && $this->table == "edtb_systems") {
                                $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'><a href='/System?system_id=" . $value . "'>" . $value . "</a></td>";
                            } else {
                                $this_row .= "<td style='width:1%;padding:10px;vertical-align:middle'>{$value}</td>";
                            }
                        } else {
                            if (isset($this->skip)) {
                                if (!in_array($key, $this->skip)) {
                                    $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum);
                                }
                            } else {
                                $this_row .= set_data($key, $value, $d_x, $d_y, $d_z, $dist, $this->table, $enum);
                            }
                        }
                        $ii++;
                    }
                }
                unset($value);
                $rows .= "<tr style='border-bottom:1px solid #000;background:{$background}'>{$buttons} {$this_row}</tr>";
            }
        } else {
            $head = "<td style='padding:40px'>{$this->text['Nothing_found']}...</td>";
        }
        // navigation 3/3
        // remove start= from url
        $query_nav = preg_replace('/&(start|mte_a|id)=[^&]*/', '', $query_string);
        // this page
        $this_page = ($this->num_rows_list_view + $start) / $this->num_rows_list_view;
        // last page
        $last_page = ceil($hits_total / $this->num_rows_list_view);
        // navigatie numbers
        if ($this_page > 10) {
            $vanaf = $this_page - 10;
        } else {
            $vanaf = 1;
        }
        if ($last_page > $this_page + 10) {
            $tot = $this_page + 10;
        } else {
            $tot = $last_page;
        }
        for ($f = $vanaf; $f <= $tot; $f++) {
            $nav_toon = $this->num_rows_list_view * ($f - 1);
            if ($f == $this_page) {
                $navigation .= "<td class='mte_nav' style='color:#fffffa;background-color:#808080;font-weight:700'>{$f}</td> ";
            } else {
                $navigation .= "<td class='mte_nav' style='background-color:#0e0e11'><a data-replace='true' data-target='.rightpanel' class='mtelink' href='{$this->url_script}?{$query_nav}&start={$nav_toon}'>{$f}</a></td>";
            }
        }
        if ($hits_total < $this->num_rows_list_view) {
            $navigation = "";
        }
        // Previous if
        if ($this_page > 1) {
            $last = ($this_page - 1) * $this->num_rows_list_view - $this->num_rows_list_view;
            $last_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$last}' class='mte_nav_prev_next'>{$this->text['Previous']}</a>";
        }
        // Next if:
        if ($this_page != $last_page && $hits_total > 1) {
            $next = $start + $this->num_rows_list_view;
            $next_page_html = "<a data-replace='true' data-target='.rightpanel' href='{$this->url_script}?{$query_nav}&start={$next}' class='mte_nav_prev_next'>{$this->text['Next']}</a>";
        }
        $this->nav_bottom = '<span class="right" style="padding-top:6px">Number of entries: ';
        $this->nav_bottom .= number_format($hits_total);
        $this->nav_bottom .= "</span>";
        if ($navigation) {
            $nav_table = "\n                <table style='border-collapse:separate;border-spacing:5px;margin-left:35%;margin-right:auto'>\n                    <tr>\n                        <td style='padding-right:6px;vertical-align:middle'>{$last_page_html}</td>\n                        {$navigation}\n                        <td style='padding-left:6px;vertical-align:middle'>{$next_page_html}</td>\n                    </tr>\n                </table>\n            ";
            $this->nav_top = "\n                <div style='margin-bottom:5px;margin-top:-20px;width:{$this->width_editor}'>\n                        {$nav_table}\n                </div>\n            ";
            $this->nav_bottom .= "\n                <div style='margin-top:20px;width:100%;text-align:center'>\n                        {$nav_table}\n                </div>\n            ";
        }
        /**
         * Search form + Add Record button
         */
        foreach ($this->fields_in_list_view as $option) {
            $show_option = $this->show_text[$option] ? $this->show_text[$option] : $option;
            $options .= $option == $in_search_field ? '<option selected value="' . $option . '">' . $show_option . '</option>' : '<option value="' . $option . '">' . $show_option . '</option>';
        }
        unset($option);
        $in_search_value = htmlentities(trim(stripslashes($_GET["s"])), ENT_QUOTES);
        $seach_form = "\n            <table style='margin-left:0;padding-left:0;border-collapse:collapse;border-spacing:0;width:100%'>\n                <tr>\n                    <td style='white-space:nowrap;padding-bottom:20px'>\n                        <form method=get action='{$this->url_script}' id='search_form'>\n                            <input type='hidden' name='table' value='" . $_GET["table"] . "'>\n                            <select class='selectbox' name='f'>{$options}</select>\n                            <input class='textbox' type='text' name='s' value='{$in_search_value}' style='width:220px'>\n                            <input class='button' type='submit' value='{$this->text['Search']}' style='width:80px'>\n                ";
        $seach_form .= "</form>";
        if ($_GET["s"] && $_GET["f"]) {
            $seach_form .= "<button class='button button_clear' onclick='window.location=\"{$this->url_script}\"' style='margin: 0 0 10px 10px'>{$this->text['Clear_search']}</button>";
        }
        $seach_form .= '
                    </td>

                    <td style="text-align:right">';
        if (substr($this->table, 0, 4) != "edtb") {
            $seach_form .= "<button class='button button_add' onclick='window.location=\"{$this->url_script}?{$query_string}&mte_a=new\"' style='margin: 0 0 10px 10px'>{$this->text['Add_Record']}</button>";
        } else {
            $seach_form .= "&nbsp;";
        }
        $seach_form .= "</td>\n\n                </tr>\n            </table>\n        ";
        $this->javascript = "\n            function del_confirm(id) {\n                if (confirm('{$this->text['Delete']} record {$this->show_text[$this->primary_key]} ' + id + '...?')) {\n                    window.location=window.location.href + '&mte_a=del&id=' + id\n                }\n            }\n        ";
        // page content
        $this->content = "\n            <div style='width: {$this->width_editor};background:transparent;margin:0;border:none'>{$seach_form}</div>\n            <table style='text-align:left;margin:0;border-collapse:collapse;border-spacing:0;width:{$this->width_editor}'>\n                <tr style='background:#0e0e11; color: #fff'><td></td>{$head}</tr>\n                {$rows}\n            </table>\n\n            {$this->nav_bottom}\n        ";
    }
Esempio n. 12
0
/**
* This page serves as the edit page for the users profile.
*/
require_once 'db_connection.php';
require 'set_data.php';
require 'validate.php';
require 'db_functions.php';
// check if photo's file name is present in the session
if (!isset($_SESSION['photo'])) {
    $photo = "";
}
// if the user has submitted the form
if (isset($_POST['update'])) {
    $userId = $_SESSION['id'];
    // set the submitted data to the array $row
    $row = set_data($_POST, $_FILES, $connection);
    // validate $row
    $errors = validate($row, $connection, "update");
    // if no error exists after validation then update the details of the user
    if (!$errors) {
        $status = update_record($userId, $connection, $row);
        if ($status == 1) {
            $_SESSION['message'] = "Your changes have been saved successfully";
            header("Location: home.php");
        } else {
            $_SESSION['message'] = "Sorry! Unable to save your changes";
            header("Location: home.php");
        }
    }
} else {
    // populate the fields for editing if user is logged in