function togglestate() { global $apx, $db, $set; $id = (int) $_REQUEST['id']; $status = (int) $_REQUEST['status']; if (!$id) { terminate(); } $open = $apx->session->get('news_cat_open'); $open = array_map('intval', dash_unserialize($open)); if (!is_array($open)) { $open = array(); } if ($status) { if (!in_array($id, $open)) { $open[] = $id; } } else { $index = array_search($id, $open); if ($index !== false) { unset($open[$index]); } } $apx->session->set('news_cat_open', dash_serialize($open)); }
function convertRecursiveTable($table) { global $db; $db->query("\n\t\tALTER TABLE `" . $table . "` ADD `parents` VARCHAR(255) NOT NULL ,\n\t\tADD `children` TEXT NOT NULL ,\n\t\tADD ord TINYINT(3) NOT NULL\n\t"); $lastlevel = 0; $ord = array(); $parents = array(); $data = $db->fetch("SELECT a.id,count(*) AS level FROM " . $table . " AS a," . $table . " AS b WHERE ( a.lft BETWEEN b.lft AND b.rgt ) GROUP BY a.lft"); foreach ($data as $res) { while (count($parents) > $res['level'] - 1) { array_pop($parents); } if ($lastlevel < $res['level']) { $ord[$res['level']] = 0; } else { ++$ord[$res['level']]; } //Eltern definieren $db->query("\n\t\t\tUPDATE " . $table . "\n\t\t\tSET parents='" . dash_serialize($parents) . "', children='|', ord='" . $ord[$res['level']] . "'\n\t\t\tWHERE id='" . $res['id'] . "'\n\t\t"); //Knoten bei Eltern als Kindknoten hinzufügen if ($parents) { $db->query("\n\t\t\t\tUPDATE " . $table . "\n\t\t\t\tSET children=CONCAT(children, '" . $res['id'] . "|')\n\t\t\t\tWHERE id IN (" . implode(',', $parents) . ")\n\t\t\t"); } $parents[] = $res['id']; $lastlevel = $res['level']; } $db->query("\n\t\tALTER TABLE `" . $table . "`\n\t DROP `root_id`,\n\t DROP `lft`,\n\t DROP `rgt`;\n\t"); }
function edit_book($info) { global $set, $db, $apx; $thistype = 'book'; //Aktualisieren if ($_POST['send'] == 2) { if (!checkToken()) { infoInvalidToken(); } elseif (!$_POST['title'] || !$_POST['text']) { infoNotComplete(); } elseif (!$this->update_pic()) { /*DO NOTHING*/ } elseif (!$this->update_teaserpic()) { /*DO NOTHING*/ } else { //Website-URLs clean if (substr($_POST['website'], 0, 4) == 'www.') { $_POST['website'] = 'http://' . $_POST['website']; } $_POST['picture'] = $this->picpath; $_POST['teaserpic'] = $this->teaserpicpath; $_POST['media'] = dash_serialize(array_map('intval', $_POST['media'])); $db->dupdate(PRE . '_products', 'prodid,title,text,meta_description,picture,teaserpic,website,manufacturer,publisher,isbn,genre,media,custom1,custom2,custom3,custom4,custom5,custom6,custom7,custom8,custom9,custom10,buylink,price,recprice,guarantee,allowcoms,allowrating,restricted,top,searchable', "WHERE id='" . $_REQUEST['id'] . "' LIMIT 1"); logit('PRODUCTS_EDIT', 'ID #' . $_REQUEST['id']); //Release eintragen $db->query("DELETE FROM " . PRE . "_products_releases WHERE prodid='" . $_REQUEST['id'] . "'"); for ($i = 1; $i <= 10; $i++) { if (!isset($_POST['release'][$i])) { continue; } $element = $_POST['release'][$i]; if ($element['year']) { list($reldata, $relstamp, $relsystem) = $this->generate_release($element); $db->query("INSERT INTO " . PRE . "_products_releases (prodid,system,data,stamp) VALUES ('" . $_REQUEST['id'] . "','" . $relsystem . "','" . addslashes(serialize($reldata)) . "','" . $relstamp . "')"); } } //Tags $db->query("DELETE FROM " . PRE . "_products_tags WHERE id='" . $_REQUEST['id'] . "'"); $tagids = produceTagIds($_POST['tags']); foreach ($tagids as $tagid) { $db->query("INSERT IGNORE INTO " . PRE . "_products_tags VALUES('" . $_REQUEST['id'] . "', '" . $tagid . "')"); } printJSRedirect(get_index('products.show')); } } else { //Variablen freigeben foreach ($info as $key => $value) { $_POST[$key] = $value; } //Media $_POST['media'] = dash_unserialize($info['media']); if (!is_array($_POST['media'])) { $_POST['media'] = array(); } //Releases auslesen $_POST['release'] = array(); $data = $db->fetch("SELECT system,data FROM " . PRE . "_products_releases WHERE prodid='" . $_REQUEST['id'] . "' ORDER BY ord ASC"); if (count($data)) { $ri = 1; foreach ($data as $res) { $res['data'] = unserialize($res['data']); if (is_array($res['data'])) { $_POST['release'][$ri] = $res['data']; $_POST['release'][$ri]['system'] = $res['system']; ++$ri; } } } //Benutzerdefinierte Felder for ($i = 1; $i <= 10; $i++) { $fieldname = $set['products']['custom_' . $thistype][$i - 1]; $apx->tmpl->assign('CUSFIELD' . $i . '_NAME', replace($fieldname)); $apx->tmpl->assign('CUSTOM' . $i, compatible_hsc($_POST['custom' . $i])); } //Bild $picture = ''; if ($info['picture']) { $picturepath = $info['picture']; $poppicpath = str_replace('-thumb.', '.', $picturepath); if (file_exists(BASEDIR . getpath('uploads') . $poppicpath)) { $picture = '../' . getpath('uploads') . $poppicpath; } else { $picture = '../' . getpath('uploads') . $picturepath; } } //Bild $teaserpic = ''; if ($info['teaserpic']) { $teaserpicpath = $info['teaserpic']; $poppicpath = str_replace('-thumb.', '.', $teaserpicpath); if (file_exists(BASEDIR . getpath('uploads') . $poppicpath)) { $teaserpic = '../' . getpath('uploads') . $poppicpath; } else { $teaserpic = '../' . getpath('uploads') . $teaserpicpath; } } //Tags $tags = array(); $tagdata = $db->fetch("\n\t\t\tSELECT t.tag\n\t\t\tFROM " . PRE . "_products_tags AS n\n\t\t\tLEFT JOIN " . PRE . "_tags AS t USING(tagid)\n\t\t\tWHERE n.id='" . $_REQUEST['id'] . "'\n\t\t\tORDER BY t.tag ASC\n\t\t"); $tags = get_ids($tagdata, 'tag'); $_POST['tags'] = implode(', ', $tags); $apx->tmpl->assign('ACTION', 'edit'); $apx->tmpl->assign('ID', $_REQUEST['id']); $apx->tmpl->assign('PRODID', intval($_POST['prodid'])); $apx->tmpl->assign('TITLE', compatible_hsc($_POST['title'])); $apx->tmpl->assign('TEXT', compatible_hsc($_POST['text'])); $apx->tmpl->assign('META_DESCRIPTION', compatible_hsc($_POST['meta_description'])); $apx->tmpl->assign('PICTURE', $picture); $apx->tmpl->assign('TEASERPIC', $teaserpic); $apx->tmpl->assign('PIC_COPY', compatible_hsc($_POST['pic_copy'])); $apx->tmpl->assign('TEASERPIC_COPY', compatible_hsc($_POST['teaserpic_copy'])); $apx->tmpl->assign('WEBSITE', compatible_hsc($_POST['website'])); $apx->tmpl->assign('TAGS', compatible_hsc($_POST['tags'])); $apx->tmpl->assign('MANUFACTURER', $this->get_units($_POST['manufacturer'], iif($set['products']['filtermanu'], 'person'))); $apx->tmpl->assign('PUBLISHER', $this->get_units($_POST['publisher'], iif($set['products']['filtermanu'], 'company'))); $apx->tmpl->assign('ISBN', compatible_hsc($_POST['isbn'])); $apx->tmpl->assign('GENRELIST', $this->get_genre($thistype, $_POST['genre'])); $apx->tmpl->assign('MEDIALIST', $this->get_media($thistype, $_POST['media'])); $apx->tmpl->assign('RELEASE', $this->get_release($thistype)); $apx->tmpl->assign('BUYLINK', compatible_hsc($_POST['buylink'])); $apx->tmpl->assign('PRICE', compatible_hsc($_POST['price'])); $apx->tmpl->assign('RECPRICE', compatible_hsc($_POST['recprice'])); $apx->tmpl->assign('GUARANTEE', compatible_hsc($_POST['guarantee'])); $apx->tmpl->assign('ALLOWCOMS', (int) $_POST['allowcoms']); $apx->tmpl->assign('ALLOWRATING', (int) $_POST['allowrating']); $apx->tmpl->assign('RESTRICTED', (int) $_POST['restricted']); $apx->tmpl->assign('TOP', (int) $_POST['top']); $apx->tmpl->assign('SEARCHABLE', (int) $_POST['searchable']); $apx->tmpl->parse('add_edit_' . $thistype); } }
function repair() { global $db; $lastlevel = 0; $ord = array(); $parents = array(); //Funktionsfähigen Teil auslesen $nodes = $this->getTree(); $nodeCount = count($nodes); $nodeIds = get_ids($nodes, $this->primary); $nodeIds[] = -1; //Parents, Childrend und Ord zurücksetzen $db->query("\n\t\t\tUPDATE " . $this->table . "\n\t\t\tSET parents='|', children='|', ord='0'\n\t\t"); //Struktur neu setzen foreach ($nodes as $res) { while (count($parents) > $res['level'] - 1) { array_pop($parents); } if ($lastlevel < $res['level']) { $ord[$res['level']] = 0; } else { ++$ord[$res['level']]; } //Eltern definieren $db->query("\n\t\t\t\tUPDATE " . $this->table . "\n\t\t\t\tSET parents='" . dash_serialize($parents) . "', children='|', ord='" . $ord[$res['level']] . "'\n\t\t\t\tWHERE " . $this->primary . "='" . $res[$this->primary] . "'\n\t\t\t"); //Knoten bei Eltern als Kindknoten hinzufügen if ($parents) { $db->query("\n\t\t\t\t\tUPDATE " . $this->table . "\n\t\t\t\t\tSET children=CONCAT(children, '" . $res[$this->primary] . "|')\n\t\t\t\t\tWHERE " . $this->primary . " IN (" . implode(',', $parents) . ")\n\t\t\t\t"); } $parents[] = $res[$this->primary]; $lastlevel = $res['level']; } //Restliche Knoten flachklopfen if (isset($ord[1])) { $ord = $ord[1] + 1; } else { $ord = 0; } if ($levelOrd[1]) { $ord = $levelOrd[1]; } $data = $db->fetch("\n\t\t\tSELECT " . $this->primary . "\n\t\t\tFROM " . $this->table . "\n\t\t\tWHERE " . $this->primary . " NOT IN (" . implode(', ', $nodeIds) . ")\n\t\t\tORDER BY parents ASC, ord ASC\n\t\t"); if (count($data)) { foreach ($data as $res) { $db->query("\n\t\t\t\t\tUPDATE " . $this->table . "\n\t\t\t\t\tSET parents='|', children='|', ord='" . $ord . "'\n\t\t\t\t\tWHERE " . $this->primary . "='" . $res[$this->primary] . "'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); $ord++; } } }
clearIndices(PRE . '_products'); clearIndices(PRE . '_products_groups'); clearIndices(PRE . '_products_releases'); clearIndices(PRE . '_products_units'); //config Update updateConfig('products', "\n\t\t\t\tINSERT INTO `apx_config` (`module`, `varname`, `type`, `addnl`, `value`, `tab`, `lastchange`, `ord`) VALUES\n\t\t\t\t('products', 'epp', 'int', '', '20', 'VIEW', 1220200389, 1000),\n\t\t\t\t('products', 'manu_epp', 'int', '', '20', 'VIEW', 1220200389, 2000),\n\t\t\t\t('products', 'manu_searchepp', 'int', '', '20', 'VIEW', '0', '2500'),\n\t\t\t\t('products', 'manuprod_epp', 'int', '', '20', 'VIEW', 1220200389, 3000),\n\t\t\t\t('products', 'searchepp', 'int', '', '20', 'VIEW', '0', '3500'),\n\t\t\t\t('products', 'relepp', 'int', '', '20', 'VIEW', 1220200389, 1000),\n\t\t\t\t('products', 'sortby', 'select', 'a:2:{i:1;s:7:\"{TITLE}\";i:0;s:9:\"{RELEASE}\";}', '1', 'VIEW', 1220200389, 4000),\n\t\t\t\t\n\t\t\t\t('products', 'searchable', 'switch', '', '1', 'OPTIONS', 1220200389, 1000),\n\t\t\t\t('products', 'coms', 'switch', '', '1', 'OPTIONS', 1220200390, 2000),\n\t\t\t\t('products', 'ratings', 'switch', '', '1', 'OPTIONS', 1220200390, 3000),\n\t\t\t\t('products', 'filtermanu', 'switch', '', '1', 'OPTIONS', 1220200390, 4000),\n\t\t\t\t\n\t\t\t\t('products', 'custom_normal', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 1000),\n\t\t\t\t('products', 'custom_game', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 2000),\n\t\t\t\t('products', 'custom_software', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 3000),\n\t\t\t\t('products', 'custom_hardware', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 4000),\n\t\t\t\t('products', 'custom_music', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 5000),\n\t\t\t\t('products', 'custom_movie', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 6000),\n\t\t\t\t('products', 'custom_book', 'array', '', 'a:0:{}', 'CUSTOM', 1220200390, 7000),\n\t\t\t\t\n\t\t\t\t('products', 'pic_width', 'int', '', '120', 'IMAGES', 1220200390, 1000),\n\t\t\t\t('products', 'pic_height', 'int', '', '120', 'IMAGES', 1220200390, 2000),\n\t\t\t\t('products', 'pic_popup', 'switch', '', '1', 'IMAGES', 1220200390, 3000),\n\t\t\t\t('products', 'pic_popup_width', 'int', '', '640', 'IMAGES', 1220200390, 4000),\n\t\t\t\t('products', 'pic_popup_height', 'int', '', '480', 'IMAGES', 1220200390, 5000),\n\t\t\t\t('products', 'pic_quality', 'switch', '', '1', 'IMAGES', 1220200390, 6000),\n\t\t\t\t\n\t\t\t\t('products', 'teaserpic_width', 'int', '', '120', 'IMAGES', 1220200390, 7000),\n\t\t\t\t('products', 'teaserpic_height', 'int', '', '120', 'IMAGES', 1220200390, 8000),\n\t\t\t\t('products', 'teaserpic_popup', 'switch', '', '1', 'IMAGES', 1220200390, 9000),\n\t\t\t\t('products', 'teaserpic_popup_width', 'int', '', '640', 'IMAGES', 1220200390, 10000),\n\t\t\t\t('products', 'teaserpic_popup_height', 'int', '', '480', 'IMAGES', 1220200390, 11000),\n\t\t\t\t('products', 'teaserpic_quality', 'switch', '', '1', 'IMAGES', 1220200390, 12000);\n\t\t\t"); $mysql = "\n\t\t\t\tCREATE TABLE `apx_products_tags` (\n\t\t\t\t\t`id` INT( 11 ) UNSIGNED NOT NULL ,\n\t\t\t\t\t`tagid` INT( 11 ) UNSIGNED NOT NULL ,\n\t\t\t\t\tPRIMARY KEY ( `id` , `tagid` )\n\t\t\t\t) ENGINE=MyISAM;\n\t\t\t\t\n\t\t\t\tALTER TABLE `apx_products_groups` CHANGE `type` `type` ENUM( 'normal', 'game', 'music', 'movie', 'book', 'software', 'hardware' ) NOT NULL DEFAULT 'game' ;\n\t\t\t\tALTER TABLE `apx_products` CHANGE `media` `media` TINYTEXT NOT NULL ;\n\t\t\t\t\n\t\t\t\tALTER TABLE `apx_products` ADD INDEX ( `type` ) ;\n\t\t\t\tALTER TABLE `apx_products` ADD INDEX ( `active` ) ;\n\t\t\t\tALTER TABLE `apx_products_groups` ADD INDEX ( `grouptype` ) ;\n\t\t\t\tALTER TABLE `apx_products_groups` ADD INDEX ( `type` ) ;\n\t\t\t\tALTER TABLE `apx_products_releases` ADD INDEX ( `prodid` ) ;\n\t\t\t\tALTER TABLE `apx_products_releases` ADD INDEX ( `stamp` ) ;\n\t\t\t\tALTER TABLE `apx_products_units` ADD INDEX ( `type` ) ;\n\t\t\t"; $queries = split_sql($mysql); foreach ($queries as $query) { $db->query($query); } //Media anpassen $data = $db->fetch("SELECT id, type, media, systems FROM " . PRE . "_products"); if (count($data)) { foreach ($data as $res) { $db->query("UPDATE " . PRE . "_products SET media='|" . $res['media'] . "|', systems='" . dash_serialize(unserialize($res['media'])) . "' WHERE id='" . $res['id'] . "' LIMIT 1"); if (in_array($res['type'], array('software', 'book', 'music'))) { $db->query("UPDATE " . PRE . "_products_releases SET system='" . $res['media'] . "' WHERE prodid='" . $res['id'] . "'"); } } } //Tags erzeugen transformKeywords(PRE . '_products', PRE . '_products_tags'); case 110: //zu 1.1.1 //Indizes entfernen clearIndices(PRE . '_products'); clearIndices(PRE . '_products_groups'); clearIndices(PRE . '_products_releases'); clearIndices(PRE . '_products_units'); $mysql = "\n\t\t\t\tALTER TABLE `apx_products` ADD `restricted` TINYINT( 1 ) UNSIGNED NOT NULL AFTER `allowrating` ;\n\t\t\t\t\n\t\t\t\tALTER TABLE `apx_products` ADD INDEX ( `type` ) ;\n\t\t\t\tALTER TABLE `apx_products` ADD INDEX ( `active` ) ;\n\t\t\t\tALTER TABLE `apx_products_groups` ADD INDEX ( `grouptype` ) ;\n\t\t\t\tALTER TABLE `apx_products_groups` ADD INDEX ( `type` ) ;\n\t\t\t\tALTER TABLE `apx_products_releases` ADD INDEX ( `prodid` ) ;\n\t\t\t\tALTER TABLE `apx_products_releases` ADD INDEX ( `stamp` ) ;\n\t\t\t\tALTER TABLE `apx_products_units` ADD INDEX ( `type` ) ;\n\t\t\t";
///////////////////////////////////////////////////////////////////////////////////////////////// //Keine Treffer if (!count($result)) { message($apx->lang->get('MSG_EMPTYSEARCH'), 'javascript:history.back();'); } else { list($usec, $sec) = explode(' ', microtime()); $b2 = (double) $usec + (double) $sec; list($usec, $sec) = explode(' ', $searchstart); $b1 = (double) $usec + (double) $sec; $searchtime = round($b2 - $b1, 5); if (count($highlight)) { $highlightme = serialize($highlight); } else { $highlightme = ''; } $resultstring = dash_serialize($result); $hash = md5(uniqid(time())); $ign = serialize($ignored); $db->query("INSERT INTO " . PRE . "_forum_search (userid,result,display,highlight,ignored,order_field,order_dir,time,hash) VALUES ('" . $user->info['userid'] . "','" . addslashes($resultstring) . "','" . addslashes($display) . "','" . addslashes($highlightme) . "','" . addslashes($ign) . "','" . addslashes($_POST['sortby']) . "','" . addslashes($_POST['sortby_dir']) . "','" . $searchtime . "','" . addslashes($hash) . "')"); $searchid = $db->insert_id(); message($apx->lang->get('MSG_OK'), 'search.php?search=' . $searchid . '&hash=' . $hash); } } } /////////////////////////////////////////////////////////////////////////////////////////////// FORMULAR $pforum = array(); $data = forum_readout(); foreach ($data as $res) { ++$i; //Nicht sichtbare Foren überspringen if (!forum_access_visible($res) || !forum_access_read($res)) {