示例#1
0
function update_order($order, $id)
{
    global $conn, $modul;
    if ($id) {
        $sql = "SELECT id, sort_order FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE sort_order = '" . $order . "' AND id != '" . $id . "' LIMIT 1 ";
        $result = db_mysql_query($sql, $conn);
        if (db_mysql_num_rows($result)) {
            $arr = db_mysql_fetch_array($result);
            $order++;
            $sql_upd = "UPDATE " . $_SESSION['TABLE_PREFIX'] . $modul . " SET sort_order = '" . $order . "' WHERE id = '" . $arr['id'] . "' ";
            db_mysql_query($sql_upd, $conn);
            update_order($order, $arr['id']);
        }
    }
}
示例#2
0
function print_chart($params, $line, $option = NULL, $select = 0)
{
    global $conn;
    $height = 300;
    $chart_height = 360;
    $max_width = 800;
    $chart_width = 900;
    if (!isset($params['FILTER'])) {
        $params['FILTER'] = NULL;
    } elseif (!isset($params['SORT'])) {
        $params['SORT'] = NULL;
    }
    if (!isset($params['GROUP'])) {
        $params['GROUP'] = NULL;
    }
    if (!isset($params['ADD'])) {
        $params['ADD'] = NULL;
    }
    $result = db_mysql_query(select_tbody($params['TABLE'], $params['SORT'], $params['FILTER'], $params['GROUP'], $params['ADD']), $conn);
    $max = 0;
    $base_arr = array();
    $count = db_mysql_num_rows($result);
    while ($arr = db_mysql_fetch_array($result)) {
        if ($arr[$line['VAL']] >= $max) {
            $max = $arr[$line['VAL']];
        }
        if ($line['DATA'] == 'date') {
            $date = explode('-', $arr['datefromto']);
            if ($option == 'hour') {
                array_push($base_arr, date('H', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('H', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('H', strtotime('-1 hour', $date[0])));
                    array_push($base_arr, date('H', strtotime('+1 hour', $date[0])));
                }
            }
            if ($option == 'day') {
                array_push($base_arr, date('d.m', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('d.m', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('d.m', strtotime('-1 day', $date[0])));
                    array_push($base_arr, date('d.m', strtotime('+1 day', $date[0])));
                }
            }
            if ($option == 'month') {
                array_push($base_arr, date('F', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('F', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('F', strtotime('-1 month', $date[0])));
                    array_push($base_arr, date('F', strtotime('+1 month', $date[0])));
                }
            }
            if ($option == 'year') {
                array_push($base_arr, date('Y', $date[0]));
                $data_arr[$arr[$line['KEY']]][date('Y', $date[0])] = $arr[$line['VAL']];
                if ($count == 1) {
                    array_unshift($base_arr, date('Y', strtotime('-1 year', $date[0])));
                    array_push($base_arr, date('Y', strtotime('+1 year', $date[0])));
                }
            }
        } else {
            array_push($base_arr, $arr[$line['DATA']]);
            $data_arr[$arr[$line['KEY']]][$arr[$line['DATA']]] = $arr[$line['VAL']];
        }
    }
    foreach ($data_arr as $key => $value) {
        if (count($value) == 1) {
            array_unshift($data_arr[$key], 0);
            array_push($data_arr[$key], 0);
        }
    }
    print "<div class='chart-wrapper'>";
    print "<svg version='1.2' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' class='chart' aria-labelledby='title' role='img' height='100%' width='100%' viewBox='0 0 " . $chart_width . " " . $chart_height . "'>";
    print base_chart($base_arr, array(floor($max / 2), $max), $height, $max_width, 50);
    if ($select != 0) {
        print data_chart($data_arr[$select], 1, $max, $height, $max_width, 50);
    } else {
        $i = 1;
        foreach ($data_arr as $key => $value) {
            print data_chart($value, $i, $max, $height, $max_width, 50);
            $i++;
        }
    }
    print "</svg>";
    if (count($data_arr) > 1) {
        print "<ul class='legend'>";
        $i = 1;
        foreach ($data_arr as $key => $value) {
            print "<li><div class='color-box color-" . $i . "'></div>" . $key . "</li>";
            $i++;
        }
        print "</ul>";
    }
    print "</div>";
}
                     if ($i != $num) {
                         $sql .= ", ";
                     }
                 }
                 $sql .= ")";
                 db_mysql_query($sql, $conn);
                 if ($action != 'add') {
                     $id = db_last_id($conn);
                 }
             }
         }
         ###### Inhalt aus datenbank auslesen wenn ID gesetzt und Datenaktualisiert wurden ######
         if (isset($id)) {
             $sql = "SELECT * FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE id = '" . $id . "' ";
             $result = db_mysql_query($sql, $conn);
             if (db_mysql_num_rows($result)) {
                 foreach (db_mysql_fetch_array($result) as $key => $val) {
                     ${$key} = $val;
                 }
             }
         }
         $success = true;
     } else {
         foreach ($_POST as $key => $val) {
             ${$key} = $val;
         }
     }
 } else {
     ###### Bei Reload variablen neu befüllen #######
     foreach ($_POST as $key => $val) {
         ${$key} = $val;
示例#4
0
 }
 if ($arr['type'] == 'multicheckbox') {
     ${$arr['title']} = unserialize(${$arr['title']});
     foreach (${$arr['title']} as $key => $val) {
         ${"c_multi_" . $arr['title'] . "_" . $key} = $val;
     }
     if ($arr['source_table']) {
         if (!isset($arr['value']) or !$arr['value']) {
             $arr['value'] = 'id';
         }
         if (!isset($arr['label']) or !$arr['label']) {
             $arr['label'] = 'title';
         }
         $sql_sub = "SELECT " . $arr['value'] . ", " . $arr['label'] . " FROM " . $_SESSION['TABLE_PREFIX'] . $arr['source_table'] . " WHERE c_active = '1' ";
         $result_sub = db_mysql_query($sql_sub, $conn);
         if (db_mysql_num_rows($result_sub)) {
             $i = 1;
             while ($arr_sub = db_mysql_fetch_array($result_sub)) {
                 $formdata['c_multi_' . $arr['title'] . '_' . $arr_sub[$arr['value']]] = array('type' => 'checkbox', 'parent_class' => 'multi_checkbox', 'settings' => array('data' => array($arr_sub[$arr['value']] => $arr_sub[$arr['label']])));
                 if ($i == 1) {
                     $formdata['c_multi_' . $arr['title'] . '_' . $arr_sub[$arr['value']]]['label'] = $formdata[$arr['title']]['label'];
                     unset($formdata[$arr['title']]);
                     $i++;
                 }
             }
         }
     } else {
         $arr['source_value'] = unserialize($arr['source_value']);
         $i = 1;
         foreach ($arr['source_value'] as $key => $val) {
             $formdata['c_multi_' . $arr['title'] . '_' . $key] = array('type' => 'checkbox', 'parent_class' => 'multi_checkbox', 'settings' => array('data' => array($key => $val)));
示例#5
0
function init($data, $para = "default", $table = NULL)
{
    global $conn, $modul;
    switch ($para) {
        case "add":
            $return_data = init($data, $table);
            break;
        case "number":
            $return_data = number_format($data, 0, ",", ".");
            break;
        case "int":
            $return_data = $data;
            break;
        case "text":
            $return_data = $data;
            break;
        case "activate":
            $return_data = $data;
            break;
        case "duration":
            $hour = floor($data / 3600);
            $min = floor(($data - $hour * 3600) / 60);
            $sec = $data - $hour * 3600 - $min * 60;
            if ($hour < 10) {
                $hour = "0" . $hour;
            }
            if ($min < 10) {
                $min = "0" . $min;
            }
            if ($sec < 10) {
                $sec = "0" . $sec;
            }
            $return_data = $hour . ":" . $min . ":" . $sec;
            break;
        case "datefromto":
            $data = explode('-', $data);
            $return_data = date('d.m.Y - H:i', $data[0]) . " " . v('CMT_TO') . " " . date('d.m.Y - H:i', $data[1]);
            break;
        case "date":
            $return_data = date('d.m.Y - H:i', $data);
            break;
        case "select":
            preg_match("/(.*)_(.*)/i", $modul, $next_modul);
            if ($next_modul) {
                $next_modul = $next_modul[1];
            } else {
                $next_modul = $modul;
            }
            if ($table == 'id_field' or $table == 'id_parent') {
                if ($table == 'id_field') {
                    $table = $next_modul . "_fields";
                }
                if ($table == 'id_parent') {
                    $table = $modul;
                }
                $sql = "SELECT title FROM " . $_SESSION['TABLE_PREFIX'] . $table . " WHERE id='" . $data . "' LIMIT 1";
                $result = db_mysql_query($sql, $conn);
                if (db_mysql_num_rows($result)) {
                    $arr = db_mysql_fetch_array($result);
                    $return_data = $arr['title'];
                } else {
                    $return_data = NULL;
                }
            } else {
                $sql = "SELECT source_table, label FROM " . $_SESSION['TABLE_PREFIX'] . $next_modul . "_fields WHERE title='" . $table . "' LIMIT 1";
                $result = db_mysql_query($sql, $conn);
                if (db_mysql_num_rows($result)) {
                    $arr = db_mysql_fetch_array($result);
                    if (!$arr['label']) {
                        $arr['label'] = 'title';
                    }
                    $sql_tmp = "SELECT " . $arr['label'] . " FROM " . $_SESSION['TABLE_PREFIX'] . $arr['source_table'] . " WHERE id='" . $data . "' LIMIT 1";
                    $result_tmp = db_mysql_query($sql_tmp, $conn);
                    if (db_mysql_num_rows($result_tmp)) {
                        $arr_tmp = db_mysql_fetch_array($result_tmp);
                        $return_data = $arr_tmp[$arr['label']];
                    } else {
                        $return_data = NULL;
                    }
                } else {
                    $return_data = NULL;
                }
            }
            break;
        case "textarea":
            $return_data = $data;
            break;
        case "default":
        default:
            if (is_numeric($data)) {
                $return_data = init($data, 'number');
            } else {
                $return_data = $data;
            }
            break;
    }
    return $return_data;
}
示例#6
0
function tbody($params)
{
    global $conn, $modul, $sub_page, $pages;
    if (!isset($sub_page) or $sub_page == 0) {
        $sub_page = 1;
    }
    if ($modul == 'content_tree') {
        if (isset($params['FILTER'])) {
            $arr_tmp = create_tree('content_tree', 0, $params['FILTER']);
        } else {
            $arr_tmp = create_tree('content_tree', 0);
        }
        if ($arr_tmp) {
            $tbody = "<div class='table-body tree'>";
            $tbody .= tree_nav_table($params, 'content', $arr_tmp, tree_get_parents('content_tree', NULL));
            $tbody .= "</div><!-- /.table-body -->";
        }
    } else {
        if (!isset($params['FILTER'])) {
            $params['FILTER'] = NULL;
        } elseif (!isset($params['SORT'])) {
            $params['SORT'] = NULL;
        }
        if (!isset($params['GROUP'])) {
            $params['GROUP'] = NULL;
        }
        if (!isset($params['ADD'])) {
            $params['ADD'] = NULL;
        }
        $result = db_mysql_query(select_tbody($params['TABLE'], $params['SORT'], $params['FILTER'], $params['GROUP'], $params['ADD'], 100), $conn);
        if ($sub_page <= 1) {
            $sql_sub = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $_SESSION['TABLE_PREFIX'] . $modul . "' AND COLUMN_NAME = 'sort_order' ";
            $result_sub = db_mysql_query($sql_sub, $conn);
            if ($modul == 'content_tree') {
                $tbody = "<div class='table-body tree'>";
            } else {
                if (db_mysql_num_rows($result_sub)) {
                    $tbody = "<div class='table-body sortable'>";
                } else {
                    $tbody = "<div class='table-body " . $modul . "'>";
                }
            }
        }
        while ($arr = db_mysql_fetch_array($result)) {
            $tbody .= "<div class='table-row' id='" . $arr['id'] . "' >";
            foreach ($params['TABLE'] as $key => $value) {
                $data = init($arr[$key], $value, $key);
                if ($value == 'activate') {
                    $tbody .= "<div class='table-cell icon-only " . $key . "'>";
                    if ($arr[$key]) {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "_de" . $value . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $value . "-active'></i>";
                    } else {
                        $tbody .= "<a href='#' class='icon-cell " . $key . "_" . $value . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $value . "'></i>";
                    }
                    $tbody .= "</div><!-- /.table-cell -->";
                } else {
                    $tbody .= "<div class='table-cell " . $key . "'>" . $data . "</div><!-- /.table-cell -->";
                }
            }
            if (count(array_filter($params['CONSTRUCT']))) {
                $width = 40 + 26 * count(array_filter($params['CONSTRUCT']));
                $tbody .= "<div class='table-cell tools' style='width: " . $width . "px;'>";
                foreach ($params['CONSTRUCT'] as $key => $value) {
                    if ($value === true) {
                        if ($key == 'activate') {
                            if (!isset($arr['c_default']) or $arr['c_default'] == 0) {
                                if ($arr['c_active']) {
                                    $tbody .= "<a href='#' class='icon-cell de" . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "-active'></i>";
                                } else {
                                    $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i>";
                                }
                                $tbody .= "</a>";
                            }
                        } elseif ($key == 'delete') {
                            if (!isset($arr['c_default']) or $arr['c_default'] == 0) {
                                $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                            }
                        } else {
                            $tbody .= "<a href='#' class='icon-cell " . $key . "' data-content='" . $modul . "' id='" . $arr['id'] . "' ><i class='icon-" . $key . "'></i></a>";
                        }
                    }
                }
                $tbody .= "</div><!-- /.table-cell -->";
            }
            $tbody .= "</div><!-- /.table-row -->";
        }
        if (ceil($pages) != $sub_page) {
            $next_page = $sub_page + 1;
            $tbody .= "<form id='next_rows' method='POST'>";
            $tbody .= "<input type='hidden' name='modul' value='" . $modul . "'>";
            $tbody .= "<input type='hidden' name='params' value='" . serialize($params) . "'>";
            $tbody .= "<input type='hidden' name='sub_page' value='" . $next_page . "'>";
            $tbody .= "</form>";
        }
        $tbody .= "</div><!-- /.table-body -->";
    }
    if (isset($tbody)) {
        print $tbody;
    }
}
示例#7
0
function check_duplicate($val, $key = 'title')
{
    global $conn, $modul, $id, $action;
    $sql = "SELECT * FROM " . $_SESSION['TABLE_PREFIX'] . $modul . " WHERE " . $key . " = '" . $val . "' ";
    if ($action != 'copy') {
        if (isset($id) && $id) {
            $sql .= "AND id != '" . $id . "' ";
        }
    }
    if (isset($_POST['language']) && $_POST['language']) {
        $sql .= "AND language = '" . $_POST['language'] . "' ";
    }
    $result = db_mysql_query($sql, $conn);
    if (db_mysql_num_rows($result)) {
        return true;
    } else {
        return false;
    }
}
示例#8
0
function cross_table($title, $value = 0, $value_name = NULL, $value_label = NULL)
{
    global $conn, $formdata, $modul;
    preg_match("/(.*)_(.*)/i", $modul, $next_modul);
    if ($next_modul) {
        $next_modul = $next_modul[1];
    } else {
        $next_modul = $modul;
    }
    $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $_SESSION['TABLE_PREFIX'] . $formdata[$title]['settings']['data'] . "' AND COLUMN_NAME = 'id_parent' ";
    $result = db_mysql_query($sql, $conn);
    $id_parent = db_mysql_num_rows($result);
    if ($id_parent) {
        $arr_tmp = create_tree($formdata[$title]['settings']['data']);
        generate_tree_select($title, $arr_tmp, tree_get_parents($formdata[$title]['settings']['data'], $value));
        $formdata['levels'] = array('type' => 'hidden', 'value' => 1);
        unset($formdata[$title]);
    } else {
        if ($title == 'language') {
            $next_modul = 'content';
        }
        $sql = "SELECT * FROM information_schema.COLUMNS WHERE TABLE_NAME = '" . $_SESSION['TABLE_PREFIX'] . $next_modul . "_fields' AND COLUMN_NAME = 'id' ";
        $result = db_mysql_query($sql, $conn);
        if (db_mysql_num_rows($result)) {
            $sql = "SELECT value, label FROM " . $_SESSION['TABLE_PREFIX'] . $next_modul . "_fields WHERE source_table = '" . $formdata[$title]['settings']['data'] . "' ";
            $result = db_mysql_query($sql, $conn);
            if (db_mysql_num_rows($result)) {
                $arr = db_mysql_fetch_array($result);
            }
        }
        if (!isset($arr['value']) or !$arr['value']) {
            $arr['value'] = 'id';
        }
        if (!isset($arr['label']) or !$arr['label']) {
            $arr['label'] = 'title';
        }
        if (isset($value_name) && $value_name) {
            $arr['value'] = $value_name;
        }
        if (isset($value_label) && $value_label) {
            $arr['value'] = $value_label;
        }
        $sql_tmp = "SELECT " . $arr['value'] . ", " . $arr['label'] . ", sort_order FROM " . $formdata[$title]['settings']['data'] . " WHERE c_active = '1' ";
        if ($formdata[$title]['settings']['data'] == 'content_templates') {
            $sql_tmp .= "GROUP BY id_template ";
        }
        $sql_tmp .= "ORDER BY sort_order ASC ";
        $result_tmp = db_mysql_query($sql_tmp, $conn);
        if ($formdata[$title]['settings']['data'] == 'cmt_accounts') {
            $formdata[$title]['value'] = CMT_USER_ID;
        }
        unset($formdata[$title]['settings']['data']);
        if ($formdata[$title]['type'] != 'radio') {
            $formdata[$title]['settings']['data'][0] = "...";
        }
        while ($arr_tmp = db_mysql_fetch_array($result_tmp)) {
            if ($arr['label'] == 'label') {
                $formdata[$title]['settings']['data'][$arr_tmp[$arr['value']]] = v("CMT_" . $arr_tmp[$arr['label']]);
            } else {
                $formdata[$title]['settings']['data'][$arr_tmp[$arr['value']]] = $arr_tmp[$arr['label']];
            }
        }
    }
}