예제 #1
0
function con_reindex_page_sort($idcat)
{
    global $db, $cms_db;
    if (!function_exists('getIdList')) {
        include_once 'inc/fnc.tpl.php';
    }
    $idcat = (int) $idcat;
    $sql = 'SELECT idcatside FROM ' . $cms_db['cat_side'] . ' WHERE idcat = ' . $idcat . ' ORDER BY sortindex';
    $list_idcatsides = array();
    getIdList($sql, $list_idcatsides, 'idcatside');
    $index = 0;
    foreach ($list_idcatsides as $idcatside) {
        $index++;
        $sql = "UPDATE " . $cms_db['cat_side'] . " SET sortindex={$index} WHERE idcatside = {$idcatside}";
        $db->query($sql);
    }
}
예제 #2
0
function con_config_side_save($idcat, $idside, $idtpl, $idtplconf, $idsidelang, $idcatside, $idcatnew, $author, $title, $meta_keywords, $summary, $online, $user_protected, $view, $created, $lastmodified, $startdate, $starttime, $enddate, $endtime, $meta_author, $meta_description, $meta_robots, $meta_redirect_time, $meta_redirect, $meta_redirect_url, $rewrite_use_automatic, $rewrite_url, $idlay, $use_redirect = true)
{
    global $db, $client, $sess, $perm, $lang, $cms_db, $cfg_client, $cms_lang, $val_ct;
    global $idcatside, $idside;
    if (!(is_numeric($idtpl) || is_int($idtpl))) {
        return;
    }
    if (!(is_numeric($idtplconf) || is_int($idtplconf))) {
        return;
    }
    if (empty($title)) {
        $title = $cms_lang['con_defaulttitle'];
    }
    $rewrite_use_automatic = $rewrite_use_automatic > 0 ? 1 : 0;
    rewriteGenerateMapping();
    if ($rewrite_use_automatic) {
        $rewrite_url = rewriteGenerateUrlString($title);
        $rewrite_url = rewriteMakeUniqueStringForLang('idcatside', $idcatside, $rewrite_url);
    } else {
        $rewrite_url = rewriteGenerateUrlString($rewrite_url, true);
    }
    // idcatside für rechte
    $idcatside_for_rights = $idcatside;
    $idcat_for_rights = $idcat;
    if (!is_array($idcatnew)) {
        $idcatnew['0'] = $idcat;
    }
    $start = createDate($startdate, $starttime);
    $end = createDate($enddate, $endtime);
    $meta_redirect = $meta_redirect == '1' ? '1' : '0';
    $meta_redirect_url = $meta_redirect_url == 'http://' || $meta_redirect_url == '' ? '' : $meta_redirect_url;
    set_magic_quotes_gpc($title);
    set_magic_quotes_gpc($summary);
    set_magic_quotes_gpc($meta_author);
    set_magic_quotes_gpc($meta_description);
    set_magic_quotes_gpc($meta_keywords);
    set_magic_quotes_gpc($meta_robots);
    set_magic_quotes_gpc($meta_redirect_url);
    if (empty($idside)) {
        //echo "new page";exit;
        // Seite erstellen
        $sql = "INSERT INTO {$cms_db['side']} (idclient) VALUES ('{$client}')";
        $db->query($sql);
        // neue idside suchen
        $idside = mysql_insert_id();
        // Seite in alle Ordner einfügen
        foreach ($idcatnew as $value) {
            //sortindex suchen
            $sql = "SELECT MAX(sortindex) AS sortindex FROM " . $cms_db['cat_side'] . " WHERE idcat='{$value}'";
            $db->query($sql);
            if ($db->next_record()) {
                $sortindex = $db->f('sortindex') + 1;
            } else {
                $sortindex = 1;
            }
            $sql = "SELECT * FROM {$cms_db['cat_side']} WHERE idcat='{$value}' AND is_start='1'";
            $db->query($sql);
            $is_start = $db->next_record() ? '0' : '1';
            $sql = "INSERT INTO {$cms_db['cat_side']} (idcat, idside, sortindex, is_start) VALUES ('{$value}', '{$idside}', '{$sortindex}', '{$is_start}')";
            $db->query($sql);
        }
        // idcatside suchen
        $sql = "SELECT idcatside FROM {$cms_db['cat_side']} WHERE idside='{$idside}'";
        $idcatside = array();
        getIdList($sql, $idcatside, '', 'idcatside');
        // für jede Sprache erstellen
        $a_languages = get_languages_by_client($client);
        foreach ($a_languages as $tmp_lang) {
            if ($tmp_lang == $lang) {
                $side_online = $online;
                $side_start = $start;
                $side_end = $end;
            } else {
                $side_online = 0;
                $side_start = time();
                $side_end = time();
            }
            //TODO Problems to update template in multilang pages
            $catobject =& sf_factoryGetObject('PAGE', 'Cat');
            $catobject->loadByIdcatIdlang($idcatnew['0'], $tmp_lang);
            $cat_is_protected = $catobject->getIsProtected();
            if ($cat_is_protected) {
                $side_online = $side_online | 0x4;
            }
            if ($tmp_lang == $lang) {
                $tmp_meta_description = $meta_description;
                $tmp_meta_keywords = $meta_keywords;
                $tmp_meta_robots = $meta_robots;
            } else {
                $cfg_lang = $val_ct->get_by_group('cfg_lang', $client, $tmp_lang);
                $tmp_meta_description = htmlentities($cfg_lang['meta_description'], ENT_COMPAT, 'UTF-8');
                $tmp_meta_keywords = htmlentities($cfg_lang['meta_keywords'], ENT_COMPAT, 'UTF-8');
                $tmp_meta_robots = htmlentities($cfg_lang['meta_robots'], ENT_COMPAT, 'UTF-8');
            }
            $sql = 'INSERT INTO ' . $cms_db['side_lang'];
            $sql .= ' (idside, idlang, title, meta_keywords, summary, created, lastmodified, author, meta_redirect, meta_redirect_url,';
            $sql .= ' user_protected, online, start, end, meta_author, meta_description, meta_robots, meta_redirect_time, rewrite_use_automatic, rewrite_url) ';
            $sql .= 'VALUES (';
            $sql .= " '{$idside}', '{$tmp_lang}', '{$title}', '{$tmp_meta_keywords}', '{$summary}', '{$created}', '{$lastmodified}', '{$author}', ";
            $sql .= " '{$meta_redirect}', '{$meta_redirect_url}', '{$user_protected}', '{$side_online}', '{$side_start}', '{$side_end}', ";
            $sql .= " '{$meta_author}', '{$tmp_meta_description}', '{$tmp_meta_robots}', '{$meta_redirect_time}', '{$rewrite_use_automatic}', '{$rewrite_url}')";
            $db->query($sql);
        }
        // idsidelang für die Templateerstellung raussuchen
        $sql = "SELECT idsidelang FROM " . $cms_db['side_lang'] . " WHERE idside='{$idside}'";
        $tmp_idsidelang = array();
        $affectedrows = getIdList($sql, $tmp_idsidelang, '', 'idsidelang');
        //print_r($tmp_idsidelang);exit;
        // Template erstellen
        if ($affectedrows) {
            foreach ($tmp_idsidelang as $value) {
                con_config_tpl_save($idtpl, $idlay, '', $value, $idtplconf);
            }
            //exit;
        }
        // Seite für Frontend erzeugen
        if ($cfg_client['publish'] == '1') {
            foreach ($a_languages as $tmp_lang) {
                $sql = 'INSERT INTO ' . $cms_db['code'] . "(idlang, idcatside, changed) VALUES ('{$tmp_lang}', '" . $idcatside['0'] . "', '1')";
                $db->query($sql);
            }
        }
        // Event
        fire_event('con_side_new', array('idside' => $idside, 'name' => $title));
        // Content aus Cache löschen
        sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend', 'content'));
        // Danach ins Frontend?
        // ermittle redirect-url
        if ($view) {
            $url_location = $sess->url($cfg_client['htmlpath'] . $cfg_client['contentfile'] . '?lang=' . $lang . '&idcatside=' . $idcatside['0'] . '&view=' . $view);
        } else {
            $url_location = $sess->url("main.php?area=con_editframe&idcatside=" . $idcatside['0']);
        }
        $idcatside = $idcatside['0'];
    } else {
        // handle $online-Angabe
        // 0 -> offline setzen
        // 1 -> online setzen
        // 2 -> zeitsteuerung setzen
        switch ((int) $online) {
            case 0:
                $change_online = 'online & 0xFC';
                break;
            case 1:
                $change_online = '((online & 0xFC) | 0x01)';
                break;
            case 2:
                $change_online = '((online & 0xFC) | 0x02)';
                break;
            default:
                $change_online = '0';
                break;
        }
        // update der 'side_lang' Tabelle
        $sql = 'UPDATE ' . $cms_db['side_lang'] . ' ';
        $sql .= 'SET';
        $sql .= " title='{$title}', meta_keywords='{$meta_keywords}', summary='{$summary}', meta_redirect='{$meta_redirect}', ";
        $sql .= " meta_redirect_url='{$meta_redirect_url}', user_protected = '{$user_protected}', online = {$change_online}, start='{$start}', ";
        $sql .= " end='{$end}', meta_author='{$meta_author}', meta_description='{$meta_description}', meta_robots='{$meta_robots}', ";
        $sql .= " meta_redirect_time = '{$meta_redirect_time}', rewrite_use_automatic = '{$rewrite_use_automatic}', rewrite_url = '{$rewrite_url}' ";
        $sql .= 'WHERE idsidelang = ' . $idsidelang;
        $db->query($sql);
        // in welchem Ordner existiert die Seite?
        $sql = 'SELECT idcat FROM ' . $cms_db['cat_side'] . ' WHERE idside = ' . $idside;
        $tmp_idcat = array();
        getIdList($sql, $tmp_idcat, 'idcat');
        if (is_array($tmp_idcat)) {
            // Seite in neue Ordner einfügen
            foreach ($idcatnew as $value) {
                if (!in_array($value, $tmp_idcat)) {
                    $sql = 'SELECT * FROM ' . $cms_db['cat_side'] . ' WHERE idcat = ' . $value . ' AND is_start = 1';
                    $db->query($sql);
                    $is_start = $db->next_record() ? '0' : '1';
                    //sortindex suchen
                    $sql = "SELECT MAX(sortindex) AS sortindex FROM " . $cms_db['cat_side'] . " WHERE idcat='{$value}'";
                    $db->query($sql);
                    if ($db->next_record()) {
                        $sortindex = $db->f('sortindex') + 1;
                    } else {
                        $sortindex = 1;
                    }
                    if ($value == $idcatnew['0'] && !in_array($idcat, $idcatnew)) {
                        $sql = 'UPDATE ' . $cms_db['cat_side'] . ' ';
                        $sql .= 'SET';
                        $sql .= ' idcat    = ' . $value . ',';
                        $sql .= ' sortindex    = ' . $sortindex . ',';
                        $sql .= ' is_start = ' . $is_start . ' ';
                        $sql .= 'WHERE  idcat = ' . $idcat;
                        $sql .= ' AND  idside = ' . $idside;
                        $db->query($sql);
                        if (in_array($idcat, $idcatnew)) {
                            unset($tmp_idcat[$idcat]);
                        }
                        //alte kategorie neu sortieren
                        if (!function_exists('con_reindex_page_sort')) {
                            include_once 'inc/fnc.con.php';
                        }
                        con_reindex_page_sort($idcat);
                    } else {
                        //sortindex suchen
                        $sql = "SELECT MAX(sortindex) AS sortindex FROM " . $cms_db['cat_side'] . " WHERE idcat='{$value}'";
                        $db->query($sql);
                        if ($db->next_record()) {
                            $sortindex = $db->f('sortindex') + 1;
                        } else {
                            $sortindex = 1;
                        }
                        $sql = 'INSERT INTO ' . $cms_db['cat_side'] . ' ';
                        $sql .= ' (idcat , idside , is_start, sortindex) ';
                        $sql .= 'VALUES';
                        $sql .= " ({$value}, {$idside}, {$is_start}, {$sortindex}) ";
                        $db->query($sql);
                    }
                }
            }
            // Seite aus nicht benutzen Ordnern löschen
            // jb_todo: rechte löschen??
            foreach ($tmp_idcat as $value) {
                if (!in_array($value, $idcatnew)) {
                    // suche alle idcatsides, die nicht mehr existieren
                    $sql = 'SELECT idcatside FROM ' . $cms_db['cat_side'] . " WHERE idcat='{$value}' AND idside='{$idside}'";
                    $db->query($sql);
                    $db->next_record();
                    // lösche alte 'code' Einträge
                    $sql = 'DELETE FROM ' . $cms_db['code'] . " WHERE idcatside='" . $db->f('idcatside') . "'";
                    $db->query($sql);
                    // lösche alte 'cat_side' Einträge
                    $sql = 'DELETE FROM ' . $cms_db['cat_side'] . " WHERE idside='{$idside}' AND idcat='{$value}'";
                    $db->query($sql);
                    // falls kein Startartikel mehr vorhanden neuen setzen
                    $sql = 'SELECT * FROM ' . $cms_db['cat_side'] . " WHERE idcat='{$value}' AND is_start='1'";
                    $db->query($sql);
                    if (!$db->affected_rows()) {
                        $sql = 'UPDATE ' . $cms_db['cat_side'] . " SET is_start = '1' WHERE idcat='{$value}' ORDER BY sortindex LIMIT 1";
                        $db->query($sql);
                    }
                    //sortindex neu sortieren
                    if (!function_exists('con_reindex_page_sort')) {
                        include_once 'inc/fnc.con.php';
                    }
                    con_reindex_page_sort($value);
                    // jb_todo:
                    // lösche alte 'tpl_conf' Einträge
                    // muß noch eingetragen werden
                    //Event
                    fire_event('get_unused_idcatside_by_save_side', array('idside' => $idside, 'idcat' => $value, 'idcatside' => $db->f('idcatside')));
                }
            }
        }
        // Template konfigurieren
        $have_perm_save_configdata = $perm->have_perm(27, 'side', $idcatside_for_rights, $idcat_for_rights);
        //		if ($idtplconf == '0' && $idtpl != '0') {
        //	 		$sql = 'SELECT idsidelang FROM ' . $cms_db['side_lang'] . " WHERE idside = $idside";
        //			$tmp_idsidelang = array();
        //			$affected_rows = getIdList($sql, $tmp_idsidelang, '', 'idsidelang');
        //			//print_r($tmp_idsidelang);exit;
        //
        //			// Template erstellen
        //			if ($affected_rows) {
        //				foreach ($tmp_idsidelang as $value) {
        //					con_config_tpl_save($idtpl, $idlay, '', $value, $idtplconf, $have_perm_save_configdata);
        //				}
        //			}
        //		}
        //		else {
        con_config_tpl_save($idtpl, $idlay, '', $idsidelang, $idtplconf, $have_perm_save_configdata);
        //		}
        // Rechte setzen
        if ($perm->have_perm(22, 'side', $idcatside_for_rights, $idcat_for_rights)) {
            global $backend_cms_gruppenids, $backend_cms_gruppenrechte, $backend_cms_gruppenrechtegeerbt, $backend_cms_gruppenrechteueberschreiben;
            $perm->set_group_rights('side', $idcatside_for_rights, $backend_cms_gruppenids, $backend_cms_gruppenrechte, $backend_cms_gruppenrechtegeerbt, $backend_cms_gruppenrechteueberschreiben, '', 0x7ffd0000, $idcat_for_rights, 0x7ffd0000);
        }
        if ($perm->have_perm(14, 'cat', $idcat_for_rights)) {
            global $frontend_cms_gruppenids, $frontend_cms_gruppenrechte, $frontend_cms_gruppenrechtegeerbt, $frontend_cms_gruppenrechteueberschreiben;
            $perm->set_group_rights('frontendpage', $idcatside_for_rights, $frontend_cms_gruppenids, $frontend_cms_gruppenrechte, $frontend_cms_gruppenrechtegeerbt, $frontend_cms_gruppenrechteueberschreiben, '', 68719476735.0, $idcat_for_rights, 4294967295.0);
        }
        // Codestatus ändern
        change_code_status($idcatside_for_rights, 1, 'idcatside');
        // Event
        fire_event('con_side_edit', array('idside' => $idside, 'name' => $title));
        // Content aus Cache löschen
        sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend', 'content'));
        // ermittle redirect-url
        if ($view) {
            $url_location = $sess->url($cfg_client['htmlpath'] . $cfg_client['contentfile'] . '?lang=' . $lang . '&idcatside=' . $idcatside . '&view=' . $view);
        } else {
            $url_location = $sess->url('main.php?area=con');
        }
    }
    // Cache-Group Frontend löschen
    sf_factoryCallMethod('UTILS', 'DbCache', null, null, 'flushByGroup', array('frontend'));
    if ($use_redirect) {
        redirect_page($url_location);
    }
}
예제 #3
0
파일: index.php 프로젝트: marval2/daiktuint
<html>
	<head>
		<title>Daiktų interneto projektas</title>
		<?php 
include 'config/setup.php';
?>
	</head>	
	<body>
		<form method="POST" >
			<label for="labelId"> Daviklio ID : </label>
			<select id="cmbId" name="daviklioID" onchange="showGraph()">
				<option value="0"> Pasirinkite daviklio ID </option>
				<?php 
$arr = getIdList();
$arrayElementSize = count($arr);
for ($x = 0; $x < $arrayElementSize; $x++) {
    ?>
					
					<option value=<?php 
    echo $arr[$x]['device_id'];
    ?>
><?php 
    echo $arr[$x]['device_id'];
    ?>
					 
				<?php 
}
?>
			</select>
			<input type="hidden" name="selected_text" id="selected_text" value="" />
		</form>