function insert_page($cat_id, $title, $parent_cat_id)
{
    global $database;
    $title = trim($title);
    if (1 > $cat_id) {
        return;
    }
    $parent = (int) $database->get_one("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE cat_id = {$parent_cat_id} LIMIT 1");
    $parent_section = '';
    $parent_titles = array_reverse(get_parent_titles($parent));
    foreach ($parent_titles as $parent_title) {
        $parent_section .= page_filename($parent_title) . '/';
    }
    if ($parent_section == '/') {
        $parent_section = '';
    }
    $link = '/' . $parent_section . page_filename($title);
    $filename = WB_PATH . PAGES_DIRECTORY . $link . '.php';
    make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
    $get_same_page = $database->query("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE link = '{$link}' LIMIT 1");
    if ($get_same_page->numRows() > 0) {
        echo "Page {$link} exists.";
        return;
    }
    $q = "INSERT INTO " . TABLE_PREFIX . "pages (cat_id,  page_title, menu_title, parent, template, target, visibility, searching, menu, language, admin_groups, viewing_groups, modified_when, modified_by)\n        VALUES ({$cat_id},  '{$title}', '{$title}', {$parent}, '', '', 'public', '1', '3', 'CS', '1,2', '1', '" . time() . "', 1)";
    $pages = $database->query($q);
    if ($database->is_error()) {
        echo $database->get_error();
        return;
    }
    $page_id = $pages->handle->insert_id;
    return $page_id;
}
 }
 // Work-out what the link and page filename should be
 if ($parent == '0') {
     $link = '/' . page_filename($title);
     $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . '.php';
 } else {
     $parent_section = '';
     $parent_titles = array_reverse(get_parent_titles($parent));
     foreach ($parent_titles as $parent_title) {
         $parent_section .= page_filename($parent_title) . '/';
     }
     if ($parent_section == '/') {
         $parent_section = '';
     }
     $link = '/' . $parent_section . page_filename($title);
     $filename = WB_PATH . PAGES_DIRECTORY . '/' . $parent_section . page_filename($title) . '.php';
     make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
 }
 // Check if a page with same page filename exists
 $flag = true;
 $get_same_page = $database->query("SELECT page_id FROM " . TABLE_PREFIX . "pages WHERE link = '{$link}'");
 if ($get_same_page->numRows() > 0 or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '.php') or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '/')) {
     $error[] .= "<br /><span class='red'><b>#{$i}: " . "</b> " . $MESSAGE['PAGES']['PAGE_EXISTS'] . " ({$link})<span><br />";
     $flag = false;
 }
 if ($flag) {
     $admin_groups = implode(',', $admin_groups);
     $viewing_groups = implode(',', $viewing_groups);
     $run[$i]['msg'] = "{$i}) Title: {$title} Module: {$module} Parent: {$parent}<br />";
     $language = DEFAULT_LANGUAGE;
     $time = mktime();
Example #3
0
} else {
    $title = $admin->get_post_escaped('title');
    $short = $admin->get_post_escaped('short');
    $long = $admin->get_post_escaped('long');
    $commenting = $admin->get_post_escaped('commenting');
    $active = $admin->get_post_escaped('active');
    $old_link = $admin->get_post_escaped('link');
    $group_id = $admin->get_post_escaped('group');
}
// Get page link URL
$sql = 'SELECT `link` FROM `' . TABLE_PREFIX . 'pages` WHERE `page_id`=' . (int) $page_id;
$oldLink = $database->get_one($sql);
// Include WB functions file
require_once WB_PATH . '/framework/functions.php';
// Work-out what the link should be
$newLink = '/posts/' . page_filename($title) . PAGE_SPACER . $post_id;
// create new accessfile
createNewsAccessFile($newLink, $oldLink, $page_id, $section_id, $post_id);
// get publisedwhen and publisheduntil
$publishedwhen = jscalendar_to_timestamp($admin->get_post_escaped('publishdate'));
if ($publishedwhen == '' || $publishedwhen < 1) {
    $publishedwhen = 0;
}
$publisheduntil = jscalendar_to_timestamp($admin->get_post_escaped('enddate'), $publishedwhen);
if ($publisheduntil == '' || $publisheduntil < 1) {
    $publisheduntil = 0;
}
// Update row
$sql = 'UPDATE `' . TABLE_PREFIX . 'mod_news_posts` ';
$sql .= 'SET `group_id`=' . (int) $group_id . ', ';
$sql .= '`title`=\'' . $title . '\', ';
 public function createPage($title, $parent, $module, $visibility, $admin_groups, $viewing_groups)
 {
     global $database;
     // admin object initialisieren
     require_once WB_PATH . '/framework/class.admin.php';
     require_once WB_PATH . '/framework/functions.php';
     require_once WB_PATH . '/framework/class.order.php';
     $admin = new admin('Pages', 'pages_add', false, false);
     $title = htmlspecialchars($title);
     // sicherstellen, dass Admin in der Admin-Gruppe und in der Betrachter-Gruppe existiert
     if (!in_array(1, $admin_groups)) {
         $admin_groups[] = 1;
     }
     if (!in_array(1, $viewing_groups)) {
         $viewing_groups[] = 1;
     }
     // Leerer Titel?
     if ($title == '' || substr($title, 0, 1) == '.') {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, kit_error_blank_title));
         return false;
     }
     // pruefen, ob die Seite ueber die erforderlichen Rechte verfuegt
     if (!in_array(1, $admin->get_groups_id())) {
         $admin_perm_ok = false;
         foreach ($admin_groups as $adm_group) {
             if (in_array($adm_group, $admin->get_groups_id())) {
                 $admin_perm_ok = true;
             }
         }
         if ($admin_perm_ok == false) {
             $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, kit_error_insufficient_permissions));
             return false;
         }
         $admin_perm_ok = false;
         foreach ($viewing_groups as $view_group) {
             if (in_array($view_group, $admin->get_groups_id())) {
                 $admin_perm_ok = true;
             }
         }
         if ($admin_perm_ok == false) {
             $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, kit_error_insufficient_permissions));
             return false;
         }
     }
     $admin_groups = implode(',', $admin_groups);
     $viewing_groups = implode(',', $viewing_groups);
     // Dateinamen erstellen
     if ($parent == '0') {
         $link = '/' . page_filename($title);
         // Dateinamen 'index' und 'intro' umbenennen um Kollisionen zu vermeiden
         if ($link == '/index' || $link == '/intro') {
             $link .= '_0';
             $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . '_0' . PAGE_EXTENSION;
         } else {
             $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . PAGE_EXTENSION;
         }
     } else {
         $parent_section = '';
         $parent_titles = array_reverse(get_parent_titles($parent));
         foreach ($parent_titles as $parent_title) {
             $parent_section .= page_filename($parent_title) . '/';
         }
         if ($parent_section == '/') {
             $parent_section = '';
         }
         $page_filename = page_filename($title);
         $page_filename = str_replace('_', '-', $page_filename);
         $link = '/' . $parent_section . $page_filename;
         $filename = WB_PATH . PAGES_DIRECTORY . '/' . $parent_section . $page_filename . PAGE_EXTENSION;
         make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
     }
     // prufen, ob bereits eine Datei mit dem gleichen Dateinamen existiert
     $dbPages = new db_wb_pages();
     $where = array();
     $where[db_wb_pages::field_link] = $link;
     $pages = array();
     if (!$dbPages->sqlSelectRecord($where, $pages)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbPages->getError()));
         return false;
     }
     if (sizeof($pages) > 0 || file_exists(WB_PATH . PAGES_DIRECTORY . $link . PAGE_EXTENSION) || file_exists(WB_PATH . PAGES_DIRECTORY . $link . '/')) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, sprintf(kit_error_page_exists, $link)));
         return false;
     }
     // include the ordering class
     $order = new order(TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent');
     // clean order
     $order->clean($parent);
     // get the new order
     $position = $order->get_new($parent);
     // Template und Sprache der uebergeordneten Seite ermitteln
     $where = array();
     $where[db_wb_pages::field_page_id] = $parent;
     $pages = array();
     if (!$dbPages->sqlSelectRecord($where, $pages)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbPages->getError()));
         return false;
     }
     if (sizeof($pages) > 0) {
         $template = $pages[0][db_wb_pages::field_template];
         $language = $pages[0][db_wb_pages::field_language];
     } else {
         $template = '';
         $language = DEFAULT_LANGUAGE;
     }
     // Neue Seite in Tabelle einfuegen
     $data = array();
     $data[db_wb_pages::field_page_title] = $title;
     $data[db_wb_pages::field_menu_title] = $title;
     $data[db_wb_pages::field_parent] = $parent;
     $data[db_wb_pages::field_template] = $template;
     $data[db_wb_pages::field_target] = '_top';
     $data[db_wb_pages::field_position] = $position;
     $data[db_wb_pages::field_visibility] = $visibility;
     $data[db_wb_pages::field_searching] = 1;
     $data[db_wb_pages::field_menu] = 1;
     $data[db_wb_pages::field_language] = $language;
     $data[db_wb_pages::field_admin_groups] = $admin_groups;
     $data[db_wb_pages::field_viewing_groups] = $viewing_groups;
     $data[db_wb_pages::field_modified_when] = time();
     $data[db_wb_pages::field_modified_by] = $admin->get_user_id();
     $page_id = -1;
     if (!$dbPages->sqlInsertRecord($data, $page_id)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbPages->getError()));
         return false;
     }
     // work out the level
     $level = level_count($page_id);
     // work out root parent
     $root_parent = root_parent($page_id);
     // work out page trail
     $page_trail = get_page_trail($page_id);
     $where = array();
     $where[db_wb_pages::field_page_id] = $page_id;
     $data = array();
     $data[db_wb_pages::field_link] = $link;
     $data[db_wb_pages::field_level] = $level;
     $data[db_wb_pages::field_root_parent] = $root_parent;
     $data[db_wb_pages::field_page_trail] = $page_trail;
     if (!$dbPages->sqlUpdateRecord($data, $where)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbPages->getError()));
         return false;
     }
     // create a new file in the /pages directory
     create_access_file($filename, $page_id, $level);
     // add position 1 to new page
     $position = 1;
     // add a new record to section table
     $dbSections = new db_wb_sections();
     $data = array();
     $data[db_wb_sections::field_page_id] = $page_id;
     $data[db_wb_sections::field_position] = $position;
     $data[db_wb_sections::field_module] = $module;
     $data[db_wb_sections::field_block] = 1;
     $section_id = -1;
     if (!$dbSections->sqlInsertRecord($data, $section_id)) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $dbSections->getError()));
         return false;
     }
     if (file_exists(WB_PATH . '/modules/' . $module . '/add.php')) {
         require WB_PATH . '/modules/' . $module . '/add.php';
     }
     if ($database->is_error()) {
         $this->setError(sprintf('[%s - %s] %s', __METHOD__, __LINE__, $database->get_error()));
         return false;
     }
     return $page_id;
 }
 }
 if ($type == 2) {
     $bildtype = ".jpg";
 }
 if ($type == 3) {
     $bildtype = ".png";
 }
 if ($bildtype == "" or $width == 0) {
     echo '<p style="color: red; text-align: center;">no picture file uploaded (jpg, gif, png)</p>';
     continue;
     //nur überspringen!
 }
 $fname = $_FILES['uploadpic']['name'][$i];
 //Extension weg und standardisieren:
 $fname = substr($fname, 0, strlen($fname) - 4);
 $fname = page_filename($fname);
 //ggf eine Zahl anhängen:
 if (isset($_REQUEST['nooverwrite'])) {
     $ncount = 1;
     while ($ncount < 100) {
         if ($ncount == 1) {
             $imagename = $fname . $bildtype;
         } else {
             $imagename = $fname . '-' . $ncount . $bildtype;
         }
         $imagepfad = $picture_dir . '/' . $imagename;
         if (!file_exists($imagepfad)) {
             break;
         }
         $ncount++;
     }
Example #6
0
        $link .= '_0';
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . '_0' . PAGE_EXTENSION;
    } else {
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . PAGE_EXTENSION;
    }
} else {
    $parent_section = '';
    $parent_titles = array_reverse(get_parent_titles($parent));
    foreach ($parent_titles as $parent_title) {
        $parent_section .= page_filename($parent_title) . '/';
    }
    if ($parent_section == '/') {
        $parent_section = '';
    }
    $link = '/' . $parent_section . page_filename($title);
    $filename = WB_PATH . PAGES_DIRECTORY . '/' . $parent_section . page_filename($title) . PAGE_EXTENSION;
    make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
}
// Check if a page with same page filename exists
$sql = 'SELECT `page_id` FROM `' . TABLE_PREFIX . 'pages` ' . 'WHERE `link`=\'' . $link . '\'';
$get_same_page = $database->get_one($sql);
if ($get_same_page or file_exists(WB_PATH . PAGES_DIRECTORY . $link . PAGE_EXTENSION) or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '/')) {
    $admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS']);
}
// Include the ordering class
require WB_PATH . '/framework/class.order.php';
$order = new order(TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent');
// First clean order
$order->clean($parent);
// Get new order
$position = $order->get_new($parent);
    $link = '/' . page_filename($title);
    // rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
    if ($link == '/index' || $link == '/intro') {
        $link .= '_0';
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . '_0' . PAGE_EXTENSION;
    } else {
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($title) . PAGE_EXTENSION;
    }
} else {
    $parent_section = '';
    $hSql = 'SELECT `link` FROM `' . TABLE_PREFIX . 'pages` WHERE `page_id` = ' . $parent;
    $parent_section = $database->get_one($hSql);
    //echo "parentsection ".$parent_section."<br />";
    $filename = WB_PATH . PAGES_DIRECTORY . $parent_section . '/' . page_filename($title) . PAGE_EXTENSION;
    make_dir(WB_PATH . PAGES_DIRECTORY . $parent_section);
    $link = $parent_section . '/' . page_filename($title);
    //echo "filename ".$filename."<br />";
    //echo "link ".$link."<br />";
}
// Check if a page with same page filename exists
$sql = 'SELECT `page_id` FROM `' . TABLE_PREFIX . 'pages` ' . 'WHERE `link`=\'' . $link . '\'';
$get_same_page = $database->get_one($sql);
if ($get_same_page or file_exists(WB_PATH . PAGES_DIRECTORY . $link . PAGE_EXTENSION) or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '/')) {
    $admin->print_error($MESSAGE['PAGES_PAGE_EXISTS']);
}
// Include the ordering class
require WB_PATH . '/framework/class.order.php';
$order = new order(TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent');
// First clean order
$order->clean($parent);
// Get new order
    $link = '/' . page_filename($the_link);
    // rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
    if ($link == '/index' || $link == '/intro') {
        $link .= '_' . $page_id;
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($the_link) . '_' . $page_id . PAGE_EXTENSION;
    } else {
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . page_filename($the_link) . PAGE_EXTENSION;
    }
} else {
    $parent_section = '';
    $hSql = 'SELECT `link` FROM `' . TABLE_PREFIX . 'pages` WHERE `page_id` = ' . $parent;
    $parent_section = $database->get_one($hSql);
    //echo "parentsection ".$parent_section."<br />";
    $filename = WB_PATH . PAGES_DIRECTORY . $parent_section . '/' . page_filename($the_link) . PAGE_EXTENSION;
    make_dir(WB_PATH . PAGES_DIRECTORY . $parent_section);
    $link = $parent_section . '/' . page_filename($the_link);
    //echo "filename ".$filename."<br />";
    //echo "link ".$link."<br />";
}
// Check if a page with same page filename exists
// $database = new database();
$sql = 'SELECT `page_id`,`page_title` FROM `' . TABLE_PREFIX . 'pages` WHERE `link` = "' . $link . '" AND `page_id` != ' . $page_id;
$get_same_page = $database->query($sql);
if ($get_same_page->numRows() > 0) {
    $admin->print_error($MESSAGE['PAGES_PAGE_EXISTS']);
}
// Update page with new order
$sql = 'UPDATE `' . TABLE_PREFIX . 'pages` SET `parent`=' . $parent . ', `position`=' . $position . ' WHERE `page_id`=' . $page_id . '';
// $database = new database();
$database->query($sql);
// Get page trail
    header('Location: ../../');
}
$mod_dir = basename(dirname(__FILE__));
$tablename = $mod_dir;
// Include config file
require_once '../../config.php';
// Check if the config file has been set-up
if (!defined('WB_PATH')) {
    header('Location: ../../');
    exit(0);
}
require_once WB_PATH . '/framework/class.frontend.php';
require_once WB_PATH . '/framework/functions.php';
// Create new frontend object
$wb = new frontend();
$topic_link2 = page_filename($topic_link);
if ($topic_link2 !== $topic_link) {
    header('Location: ../../');
    exit(0);
}
$theq = "SELECT topic_id, section_id, page_id FROM " . TABLE_PREFIX . "mod_" . $tablename . " WHERE link = '" . $topic_link . "'";
$query_topics = $database->query($theq);
$num_topics = $query_topics->numRows();
if ($num_topics == 1) {
    $topic = $query_topics->fetchRow();
    $topic_id = $topic['topic_id'];
    $section_id = $topic['section_id'];
    $page_id = $topic['page_id'];
    define('TOPIC_ID', $topic_id);
    require WB_PATH . "/index.php";
} else {
$w_zoom = (int) $_POST['w_zoom'];
$h_zoom = (int) $_POST['h_zoom'];
$w_view = (int) $_POST['w_view'];
$h_view = (int) $_POST['h_view'];
$w_thumb = (int) $_POST['w_thumb'];
$h_thumb = (int) $_POST['h_thumb'];
$zoomclass = page_filename($_POST['zoomclass']);
$zoomrel = page_filename($_POST['zoomrel']);
$w_zoom2 = (int) $_POST['w_zoom2'];
$h_zoom2 = (int) $_POST['h_zoom2'];
$w_view2 = (int) $_POST['w_view2'];
$h_view2 = (int) $_POST['h_view2'];
$w_thumb2 = (int) $_POST['w_thumb2'];
$h_thumb2 = (int) $_POST['h_thumb2'];
$zoomclass2 = page_filename($_POST['zoomclass2']);
$zoomrel2 = page_filename($_POST['zoomrel2']);
$picture_values = $w_zoom . ',' . $h_zoom . ',' . $w_view . ',' . $h_view . ',' . $w_thumb . ',' . $h_thumb . ',' . $zoomclass . ',' . $zoomrel . ',' . $w_zoom2 . ',' . $h_zoom2 . ',' . $w_view2 . ',' . $h_view2 . ',' . $w_thumb2 . ',' . $h_thumb2 . ',' . $zoomclass2 . ',' . $zoomrel2;
$picture_values = str_replace(' ', '', $picture_values);
$picture_values = str_replace('-', '_', $picture_values);
$is_master_for = $admin->add_slashes(trim($_POST['is_master_for']));
$is_master_for = str_replace(' ', '', $is_master_for);
if ($is_master_for != '') {
    $autoarchive = 0;
    $use_timebased_publishing = 0;
    $allow_global_settings_change = 0;
    $is_master_Arr = explode(',', $is_master_for);
    if (is_numeric(trim($is_master_Arr[0]))) {
        $theq = "SELECT section_id FROM " . TABLE_PREFIX . "mod_topics_settings WHERE section_id IN (" . $is_master_for . ")";
        $query_others = $database->query($theq);
        if (!$database->is_error()) {
            $is_master_for = '';
Example #11
0
 if ($old_section_id != $new_section_id) {
     $query_sections = $database->query("SELECT page_id FROM " . TABLE_PREFIX . "sections WHERE section_id = '{$new_section_id}'");
     $sections = $query_sections->fetchRow();
     $page_id = $sections['page_id'];
     $section_id = $new_section_id;
 }
 // Get new order position
 $position = $item_order->get_new($section_id);
 // Insert new row into database
 $database->query("INSERT INTO " . TABLE_PREFIX . "mod_bakery_items (section_id, page_id, position, created_when, created_by) VALUES ('{$section_id}', '{$page_id}', '{$position}','" . time() . "','" . $admin->get_user_id() . "')");
 // Get the id
 $orig_item_id = $item_id;
 $item_id = $database->get_one("SELECT LAST_INSERT_ID()");
 // GET NEW ITEM LINK
 // Work-out what the link should be
 $item_link = $module_pages_directory . page_filename($title) . PAGE_SPACER . $item_id;
 // Replace triple page spacer by one page spacer
 $item_link = str_replace(PAGE_SPACER . PAGE_SPACER . PAGE_SPACER, PAGE_SPACER, $item_link);
 // UPDATE DATABASE
 // First get item attributes of the original item id
 $query_item_attributes = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_bakery_item_attributes WHERE item_id = '{$orig_item_id}'");
 if ($query_item_attributes->numRows() > 0) {
     while ($ia = $query_item_attributes->fetchRow()) {
         // ia = item_attributes
         // Insert duplicated item attributes
         $database->query("INSERT INTO " . TABLE_PREFIX . "mod_bakery_item_attributes (item_id, option_id, attribute_id, price, operator) VALUES ('{$item_id}', '{$ia['option_id']}', '{$ia['attribute_id']}', '{$ia['price']}', '{$ia['operator']}')");
     }
 }
 // Update duplicated item data
 $database->query("UPDATE " . TABLE_PREFIX . "mod_bakery_items SET section_id = '{$section_id}', page_id = '{$page_id}', title = '{$title}', link = '{$item_link}', sku = '{$sku}', stock = '{$stock}', price = '{$price}', shipping = '{$shipping}', tax_rate = '{$tax_rate}', definable_field_0 = '{$definable_field_0}', definable_field_1 = '{$definable_field_1}', definable_field_2 = '{$definable_field_2}', description = '{$description}', full_desc = '{$full_desc}', active = '0', modified_when = '" . time() . "', modified_by = '" . $admin->get_user_id() . "' WHERE item_id = '{$item_id}'");
 // Check if there was a db error
//if usage as eventkalender use both time fields, (and make sure they are not in the past? No - it should be possible to edit past events)
if ($settings_fetch['sort_topics'] == 3) {
    if ($publishedwhen < $t) {
        echo '<h2 style="text-align:center">' . $MOD_TOPICS['TIME_WARNING1'] . '</h2>';
    }
    if ($publisheduntil == 0) {
        $publisheduntil = $publishedwhen + 3600;
    }
    if ($publisheduntil < $publishedwhen) {
        echo '<h2 style="text-align:center">' . $MOD_TOPICS['TIME_WARNING2'] . '</h2>';
        $publisheduntil = $publishedwhen + 3600;
    }
}
$title_link = page_filename($title);
$old_link = $admin->get_post_escaped('link');
$user_link = page_filename($admin->get_post_escaped('user_link'));
$topic_link = topics_findlink($title_link, $old_link, $user_link);
if ($create_topics_accessfiles > 0) {
    topics_createaccess_file($old_link, $topic_link, $movetopic, $topics_directory, $topics_directory_depth);
}
//$title= addslashes($title);
$theqbase = " short_description = '{$short_description}', content_short = '{$short}', content_long = '{$long}', content_extra = '{$extra}', txtr1 = '{$txtr1}', txtr2 = '{$txtr2}', txtr3 = '{$txtr3}', commenting = '{$commenting}', hascontent = '{$hascontent}', picture = '{$picture}', description = '{$description}', keywords = '{$keywords}'" . $queryextra;
//New field groups_id:
if (isset($topic_fetch['groups_id'])) {
    $theqbase .= ", groups_id = '{$groups_id}'";
}
// Update row
$theq = "UPDATE " . TABLE_PREFIX . "mod_" . $tablename . " SET " . $theqbase . ", title = '{$title}', link = '{$topic_link}', published_when = '{$publishedwhen}', published_until = '{$publisheduntil}', active = '{$active}' WHERE topic_id = '{$topic_id}'";
//echo $theq;
$database->query($theq);
$copytopic = $admin->get_post_escaped('copytopic');
Example #13
0
        $link .= '_' . $page_id;
        $filename = LEPTON_PATH . PAGES_DIRECTORY . '/' . page_filename($page_link) . '_' . $page_id . PAGE_EXTENSION;
    } else {
        $filename = LEPTON_PATH . PAGES_DIRECTORY . '/' . page_filename($page_link) . PAGE_EXTENSION;
    }
} else {
    $parent_section = '';
    $parent_titles = array_reverse(get_parent_titles($parent));
    foreach ($parent_titles as $parent_title) {
        $parent_section .= page_filename($parent_title) . '/';
    }
    if ($parent_section == '/') {
        $parent_section = '';
    }
    $link = '/' . $parent_section . page_filename($page_link);
    $filename = LEPTON_PATH . PAGES_DIRECTORY . '/' . $parent_section . page_filename($page_link) . PAGE_EXTENSION;
}
// Check if a page with same page filename exists
$sql = 'SELECT `page_id`,`page_title` FROM `' . TABLE_PREFIX . 'pages` WHERE `link` = "' . $link . '" AND `page_id` != ' . $page_id;
$get_same_page = $database->query($sql);
if ($get_same_page->numRows() > 0) {
    $admin->print_error($MESSAGE['PAGES_PAGE_EXISTS']);
}
// Update page with new order
$sql = 'UPDATE `' . TABLE_PREFIX . 'pages` SET `parent`=' . $parent . ', `position`=' . $position . ' WHERE `page_id`=' . $page_id . '';
$database->query($sql);
// Get page trail
$page_trail = get_page_trail($page_id);
// Update page settings in the pages table
$sql = 'UPDATE `' . TABLE_PREFIX . 'pages` SET ';
$sql .= '`parent` = ' . $parent . ', ';
function insert_parameters($item_id, $parameters)
{
    global $database;
    if ($item_id > 0 && isset($parameters) && is_array($parameters)) {
        foreach ($parameters as $param_name => $param_value) {
            if (!empty($param_name) && !empty($param_value)) {
                $slug = page_filename($param_name);
                $q = "INSERT INTO " . TABLE_PREFIX . "mod_eshop_item_parameter (item_id, name, slug, value)\n                    VALUES ({$item_id}, '{$param_name}', '{$slug}', '{$param_value}')\n                    ON DUPLICATE KEY UPDATE value = '{$param_value}'";
                $database->query($q);
            }
        }
    }
}
function clone_page($title, $parent, $pagetoclone, $copy_title, $visibility)
{
    // Get objects and vars from outside this function
    global $admin, $template, $database, $TEXT, $PCTEXT, $MESSAGE;
    global $page_id, $section_id;
    // Get page list from database
    $query = "SELECT * FROM `" . TABLE_PREFIX . "pages` WHERE `page_id` = " . $pagetoclone;
    $get_page = $database->query($query);
    $is_page = $get_page->fetchRow(MYSQL_ASSOC);
    // Work-out what the link and page filename should be
    if ($parent == '0') {
        $link = '/' . page_filename($title);
        $filename = WB_PATH . PAGES_DIRECTORY . $link . '.php';
    } else {
        $parent_section = '';
        $parent_titles = array_reverse(get_parent_titles($parent));
        foreach ($parent_titles as $parent_title) {
            $parent_section .= page_filename($parent_title) . '/';
        }
        if ($parent_section == '/') {
            $parent_section = '';
        }
        $link = '/' . $parent_section . page_filename($title);
        $filename = WB_PATH . PAGES_DIRECTORY . '/' . $parent_section . page_filename($title) . '.php';
        make_dir(WB_PATH . PAGES_DIRECTORY . '/' . $parent_section);
    }
    // Check if a page with same page filename exists
    $get_same_page = $database->query("SELECT `page_id` FROM `" . TABLE_PREFIX . "pages` WHERE `link` = '{$link}'");
    if ($get_same_page->numRows() > 0 or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '.php') or file_exists(WB_PATH . PAGES_DIRECTORY . $link . '/')) {
        $admin->print_error($MESSAGE['PAGES']['PAGE_EXISTS'], 'tool_clone.php?pagetoclone=' . $pagetoclone);
    }
    // check the title
    if ($copy_title) {
        $page_title = $is_page['page_title'];
    } else {
        $page_title = $title;
    }
    // Include the ordering class
    $order = new order(TABLE_PREFIX . 'pages', 'position', 'page_id', 'parent');
    // First clean order
    $order->clean($parent);
    // Get new order
    $position = $order->get_new($parent);
    // Insert page into pages table
    $template = $is_page['template'];
    $visibility = $visibility;
    $admin_groups = $is_page['admin_groups'];
    $viewing_groups = $is_page['viewing_groups'];
    $query = "INSERT INTO `" . TABLE_PREFIX . "pages` " . "(`page_title`,`menu_title`,`parent`,`template`,`target`,`position`,`visibility`,`searching`,`menu`,`language`,`admin_groups`,`viewing_groups`,`modified_when`,`modified_by`) VALUES ('" . $database->escapeString($page_title) . "','" . $database->escapeString($title) . "','{$parent}','{$template}','_top','{$position}','{$visibility}','1','1','" . DEFAULT_LANGUAGE . "','{$admin_groups}','{$viewing_groups}','" . time() . "','" . $admin->get_user_id() . "')";
    $database->query($query);
    if ($database->is_error()) {
        $admin->print_error($database->get_error());
    }
    // Get the page id
    $page_id = $database->get_one("SELECT LAST_INSERT_ID()");
    // Work out level
    $level = level_count($page_id);
    // Work out root parent
    $root_parent = root_parent($page_id);
    // Work out page trail
    $page_trail = get_page_trail($page_id);
    // Update page with new level and link
    $database->query("UPDATE `" . TABLE_PREFIX . "pages` SET `link` = '{$link}', `level` = '{$level}', `root_parent` = '{$root_parent}', `page_trail` = '{$page_trail}' WHERE `page_id` = '{$page_id}'");
    // Create a new file in the /pages dir
    create_access_file($filename, $page_id, $level);
    // Make new sections, database
    $query = "SELECT * FROM `" . TABLE_PREFIX . "sections` WHERE `page_id` = '{$pagetoclone}'";
    $get_section = $database->query($query);
    while (false != ($is_section = $get_section->fetchRow(MYSQL_ASSOC))) {
        // Add new record into the sections table
        $from_section = $is_section['section_id'];
        $position = $is_section['position'];
        $module = $is_section['module'];
        $block = $is_section['block'];
        $publ_start = $is_section['publ_start'];
        $publ_end = $is_section['publ_end'];
        $database->query("INSERT INTO `" . TABLE_PREFIX . "sections` (`page_id`,`position`,`module`,`block`,`publ_start`,`publ_end`) VALUES ('{$page_id}','{$position}', '{$module}','{$block}','{$publ_start}','{$publ_end}')");
        // Get the section id
        $section_id = $database->get_one("SELECT LAST_INSERT_ID()");
        require WB_PATH . '/modules/' . $module . '/info.php';
        // Include the selected modules add file if it exists
        if (file_exists(WB_PATH . '/modules/' . $module . '/add.php')) {
            require WB_PATH . '/modules/' . $module . '/add.php';
        }
        // copy module settings per section
        $query = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE '%mod_" . $module . "%'";
        $res = $database->query($query);
        while ($row = $res->fetchRow()) {
            // there must be a section_id column at least
            if ($database->query("DESCRIBE {$row['0']} section_id")) {
                clone_lines($row[0], $pagetoclone, $page_id, $from_section, $section_id, $database);
            }
        }
        // some manual corrections that can not be automatically detected
        if ($module == 'miniform') {
            // delete the form submissions which are also copied
            $query = "DELETE FROM " . TABLE_PREFIX . "mod_miniform_data WHERE `section_id` = " . $section_id;
            $database->query($query);
        } elseif ($module == 'mpform') {
            // delete the form submissions which are also copied
            $query = "DELETE FROM " . TABLE_PREFIX . "mod_mpform_submissions WHERE `section_id` = " . $section_id;
            $database->query($query);
            // update refererence to result table
            $query = "UPDATE " . TABLE_PREFIX . "mod_mpform_settings SET `tbl_suffix` = " . $section_id . " WHERE `section_id` = " . $section_id;
            $database->query($query);
            // new results table
            $results = TABLE_PREFIX . "mod_mpform_results_" . $section_id;
            $s = "CREATE TABLE `{$results}` ( `session_id` VARCHAR(20) NOT NULL," . ' `started_when` INT NOT NULL DEFAULT \'0\' ,' . ' `submitted_when` INT NOT NULL DEFAULT \'0\' ,' . ' `referer` VARCHAR( 255 ) NOT NULL, ' . ' PRIMARY KEY ( `session_id` ) ' . ' )';
            $database->query($s);
            $query = "SELECT field_id FROM " . TABLE_PREFIX . "mod_mpform_fields WHERE `section_id` = " . $section_id;
            $ids = $database->query($query);
            while ($fid = $ids->fetchRow()) {
                // Insert new column into database
                $s = "ALTER TABLE `{$results}` add `field" . $fid[0] . "` TEXT NOT NULL";
                $database->query($s);
            }
        } elseif ($module == 'form') {
            // delete the form submissions which are also copied
            $query = "DELETE FROM " . TABLE_PREFIX . "mod_form_submissions WHERE `section_id` = " . $section_id;
            $database->query($query);
        } elseif ($module == 'minigallery') {
            // copy images
            $mediaDir = WB_PATH . MEDIA_DIRECTORY;
            $src = $mediaDir . "/minigallery/{$from_section}";
            $dst = $mediaDir . "/minigallery/{$section_id}";
            recurse_copy($src, $dst);
        }
    }
    return $page_id;
}