| 1 | <?php
 | 
  
    | 2 | /**
 | 
  
    | 3 |  *
 | 
  
    | 4 |  * @category        admin
 | 
  
    | 5 |  * @package         pages
 | 
  
    | 6 |  * @author          WebsiteBaker Project
 | 
  
    | 7 |  * @copyright       Ryan Djurovich
 | 
  
    | 8 |  * @copyright       WebsiteBaker Org. e.V.
 | 
  
    | 9 |  * @link            http://websitebaker.org/
 | 
  
    | 10 |  * @license         http://www.gnu.org/licenses/gpl.html
 | 
  
    | 11 |  * @platform        WebsiteBaker 2.8.3
 | 
  
    | 12 |  * @requirements    PHP 5.3.6 and higher
 | 
  
    | 13 |  * @version         $Id: modify.php 2 2017-07-02 15:14:29Z Manuela $
 | 
  
    | 14 |  * @filesource      $HeadURL: svn://isteam.dynxs.de/wb/2.10.x/trunk/admin/pages/modify.php $
 | 
  
    | 15 |  * @lastmodified    $Date: 2017-07-02 17:14:29 +0200 (Sun, 02 Jul 2017) $
 | 
  
    | 16 |  *
 | 
  
    | 17 | */
 | 
  
    | 18 | // Create new admin object
 | 
  
    | 19 | if ( !defined( 'WB_PATH' ) ){ require( dirname(dirname((__DIR__))).'/config.php' ); }
 | 
  
    | 20 | if ( !class_exists('admin', false) ) { require(WB_PATH.'/framework/class.admin.php'); }
 | 
  
    | 21 | 
 | 
  
    | 22 | $admin = new admin('Pages', 'pages_modify');
 | 
  
    | 23 | // Get page id
 | 
  
    | 24 | 
 | 
  
    | 25 |     $requestMethod = '_'.strtoupper($_SERVER['REQUEST_METHOD']);
 | 
  
    | 26 |     $page_id = intval(isset(${$requestMethod}['page_id']) ? ${$requestMethod}['page_id'] : 0);
 | 
  
    | 27 |     if( ($page_id == 0) || !is_numeric($page_id) ) {
 | 
  
    | 28 |         $sInfo = strtoupper(basename(__DIR__).'_'.basename(__FILE__, '.'.PAGE_EXTENSION)).'::';
 | 
  
    | 29 |         $sDEBUG=(@DEBUG?$sInfo:'');
 | 
  
    | 30 |         $admin->print_error($sDEBUG.$MESSAGE['PAGES_NOT_FOUND'], ADMIN_URL.'/pages/index.php' );
 | 
  
    | 31 |     }
 | 
  
    | 32 | 
 | 
  
    | 33 | /*
 | 
  
    | 34 | if( (!($page_id = $admin->checkIDKEY('page_id', $page_id, $_SERVER['REQUEST_METHOD']))) )
 | 
  
    | 35 | {
 | 
  
    | 36 |     $admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS'], ADMIN_URL );
 | 
  
    | 37 | }
 | 
  
    | 38 | */
 | 
  
    | 39 | 
 | 
  
    | 40 | // Get perms
 | 
  
    | 41 | if(!$admin->get_page_permission($page_id,'admin')) {
 | 
  
    | 42 |     $admin->print_error($MESSAGE['PAGES_INSUFFICIENT_PERMISSIONS'], ADMIN_URL );
 | 
  
    | 43 | }
 | 
  
    | 44 | 
 | 
  
    | 45 | $sectionId = isset($_GET['wysiwyg']) ? htmlspecialchars($admin->get_get('wysiwyg')) : NULL;
 | 
  
    | 46 | 
 | 
  
    | 47 | // Get page details
 | 
  
    | 48 | $results_array=$admin->get_page_details($page_id);
 | 
  
    | 49 | 
 | 
  
    | 50 | // Get display name of person who last modified the page
 | 
  
    | 51 | $user=$admin->get_user_details($results_array['modified_by']);
 | 
  
    | 52 | 
 | 
  
    | 53 | // Convert the unix ts for modified_when to human a readable form
 | 
  
    | 54 | 
 | 
  
    | 55 | $modified_ts = ($results_array['modified_when'] != 0)
 | 
  
    | 56 |         ? $modified_ts = date(TIME_FORMAT.', '.DATE_FORMAT, $results_array['modified_when']+TIMEZONE)
 | 
  
    | 57 |         : 'Unknown';
 | 
  
    | 58 | // $ftan_module = $GLOBALS['ftan_module'];
 | 
  
    | 59 | // Setup template object, parse vars to it, then parse it
 | 
  
    | 60 | // Create new template object
 | 
  
    | 61 | $template = new Template(dirname($admin->correct_theme_source('pages_modify.htt')));
 | 
  
    | 62 | // $template->debug = true;
 | 
  
    | 63 | $template->set_file('page', 'pages_modify.htt');
 | 
  
    | 64 | $template->set_block('page', 'main_block', 'main');
 | 
  
    | 65 | // $template->set_var('FTAN', $admin->getFTAN() );
 | 
  
    | 66 | 
 | 
  
    | 67 | $template->set_var(array(
 | 
  
    | 68 |             'PAGE_ID' => $results_array['page_id'],
 | 
  
    | 69 |             // 'PAGE_IDKEY' => $admin->getIDKEY($results_array['page_id']),
 | 
  
    | 70 |             'PAGE_IDKEY' => $results_array['page_id'],
 | 
  
    | 71 |             'PAGE_TITLE' => ($results_array['page_title']),
 | 
  
    | 72 |             'MENU_TITLE' => ($results_array['menu_title']),
 | 
  
    | 73 |             'ADMIN_URL' => ADMIN_URL,
 | 
  
    | 74 |             'WB_URL' => WB_URL,
 | 
  
    | 75 |             'THEME_URL' => THEME_URL
 | 
  
    | 76 |             ));
 | 
  
    | 77 | 
 | 
  
    | 78 | $template->set_var(array(
 | 
  
    | 79 |             'MODIFIED_BY' => $user['display_name'],
 | 
  
    | 80 |             'MODIFIED_BY_USERNAME' => $user['username'],
 | 
  
    | 81 |             'MODIFIED_WHEN' => $modified_ts,
 | 
  
    | 82 |             'LAST_MODIFIED' => $MESSAGE['PAGES']['LAST_MODIFIED'],
 | 
  
    | 83 |             ));
 | 
  
    | 84 | 
 | 
  
    | 85 | $template->set_block('main_block', 'show_modify_block', 'show_modify');
 | 
  
    | 86 | if($modified_ts == 'Unknown')
 | 
  
    | 87 | {
 | 
  
    | 88 |     $template->set_block('show_modify', '');
 | 
  
    | 89 |     $template->set_var('CLASS_DISPLAY_MODIFIED', 'hide');
 | 
  
    | 90 | 
 | 
  
    | 91 | } else {
 | 
  
    | 92 |     $template->set_var('CLASS_DISPLAY_MODIFIED', '');
 | 
  
    | 93 |     $template->parse('show_modify', 'show_modify_block', true);
 | 
  
    | 94 | }
 | 
  
    | 95 | 
 | 
  
    | 96 | // Work-out if we should show the "manage sections" link
 | 
  
    | 97 | $sql = 'SELECT COUNT(*) FROM `'.TABLE_PREFIX.'sections` '
 | 
  
    | 98 |      . 'WHERE `page_id`='.(int)$page_id.' AND `module`=\'menu_link\'';
 | 
  
    | 99 | $query_sections = $database->get_one($sql);
 | 
  
    | 100 | 
 | 
  
    | 101 | $template->set_block('main_block', 'show_section_block', 'show_section');
 | 
  
    | 102 | if($query_sections) {
 | 
  
    | 103 |     $template->set_block('show_section', '');
 | 
  
    | 104 |     $template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
 | 
  
    | 105 | } elseif(MANAGE_SECTIONS == 'enabled') {
 | 
  
    | 106 |     $template->set_var('TEXT_MANAGE_SECTIONS', $HEADING['MANAGE_SECTIONS']);
 | 
  
    | 107 |     $template->parse('show_section', 'show_section_block', true);
 | 
  
    | 108 | } else {
 | 
  
    | 109 |     $template->set_block('show_section', '');
 | 
  
    | 110 |     $template->set_var('DISPLAY_MANAGE_SECTIONS', 'display:none;');
 | 
  
    | 111 | }
 | 
  
    | 112 | 
 | 
  
    | 113 | // Insert language TEXT
 | 
  
    | 114 | $template->set_var(array(
 | 
  
    | 115 |                 'TEXT_CURRENT_PAGE' => $TEXT['CURRENT_PAGE'],
 | 
  
    | 116 |                 'TEXT_CHANGE_SETTINGS' => $TEXT['CHANGE_SETTINGS'],
 | 
  
    | 117 |                 'HEADING_MODIFY_PAGE' => $HEADING['MODIFY_PAGE']
 | 
  
    | 118 |                 ));
 | 
  
    | 119 | 
 | 
  
    | 120 | // Parse and print header template
 | 
  
    | 121 | $template->parse('main', 'main_block', false);
 | 
  
    | 122 | $template->pparse('output', 'page');
 | 
  
    | 123 | 
 | 
  
    | 124 | // get template used for the displayed page (for displaying block details)
 | 
  
    | 125 | if (SECTION_BLOCKS)
 | 
  
    | 126 | {
 | 
  
    | 127 |     $sql = 'SELECT `template` FROM `'.TABLE_PREFIX.'pages` '
 | 
  
    | 128 |          . 'WHERE `page_id`='.(int)$page_id;
 | 
  
    | 129 |     if (($sTemplate = $database->get_one($sql)) !== null) {
 | 
  
    | 130 |         $page_template = ($sTemplate == '') ? DEFAULT_TEMPLATE : $sTemplate;
 | 
  
    | 131 |         // include template info file if exists
 | 
  
    | 132 |         if (is_readable(WB_PATH.'/templates/'.$page_template.'/info.php')) {
 | 
  
    | 133 |             include_once(WB_PATH.'/templates/'.$page_template.'/info.php');
 | 
  
    | 134 |         }
 | 
  
    | 135 |     }
 | 
  
    | 136 | }
 | 
  
    | 137 | 
 | 
  
    | 138 | // Get sections for this page
 | 
  
    | 139 | $module_permissions = $_SESSION['MODULE_PERMISSIONS'];
 | 
  
    | 140 | // workout for edit only one section for faster pageloading
 | 
  
    | 141 | // Constant later set in wb_settings, in meantime defined in framework/initialize.php
 | 
  
    | 142 | $sql = 'SELECT * FROM `'.TABLE_PREFIX.'sections` ';
 | 
  
    | 143 | $sql .= (defined('EDIT_ONE_SECTION') && EDIT_ONE_SECTION && is_numeric($sectionId))
 | 
  
    | 144 |         ? 'WHERE `section_id` = '.(int)$sectionId
 | 
  
    | 145 |         : 'WHERE `page_id` = '.(int)$page_id;
 | 
  
    | 146 | $sql .= ' ORDER BY position ASC';
 | 
  
    | 147 | $query_sections = $database->query($sql);
 | 
  
    | 148 | if($query_sections->numRows() > 0)
 | 
  
    | 149 | {
 | 
  
    | 150 |     while($section = $query_sections->fetchRow(MYSQLI_ASSOC))
 | 
  
    | 151 |     {
 | 
  
    | 152 |         $now = time();
 | 
  
    | 153 |         $bSectionInactive = !(($now<=$section['publ_end'] || $section['publ_end']==0) && ($now>=$section['publ_start'] || $section['publ_start']==0));
 | 
  
    | 154 |         $section_id = $section['section_id'];
 | 
  
    | 155 |         $module = $section['module'];
 | 
  
    | 156 |         //Have permission?
 | 
  
    | 157 |         if(!is_numeric(array_search($module, $module_permissions)))
 | 
  
    | 158 |         {
 | 
  
    | 159 |             // Include the modules editing script if it exists
 | 
  
    | 160 |             if (!is_readable(WB_PATH.'/modules/'.$module.'/modify.php')){
 | 
  
    | 161 |                 $admin->print_error($MESSAGE['GENERIC_MODULE_VERSION_ERROR'],ADMIN_URL.'/pages/settings.php?page_id='.(int)$page_id);
 | 
  
    | 162 |             } else {
 | 
  
    | 163 | //                print /* '<a name="'.$section_id.'"></a>'. */"\n";
 | 
  
    | 164 |                 $sSectionBlock = '<div class="block-outer">'."\n";
 | 
  
    | 165 | // set container if SECTION_BLOCKS disabled
 | 
  
    | 166 | //                $sSectionInfoLine  = ($bSectionInactive ? false: true);
 | 
  
    | 167 |                 $sSectionInfoLine  = ($bSectionInactive ? 'inactive': 'active');
 | 
  
    | 168 | //                $sSectionInfoLine  = ($bSectionInactive ? '<div class="section-inactive">': '<div class="section-active">')."\n" ;
 | 
  
    | 169 |                 // output block name if blocks are enabled
 | 
  
    | 170 | //                if (SECTION_BLOCKS) {
 | 
  
    | 171 |                     if (isset($block[$section['block']]) && trim(strip_tags(($block[$section['block']]))) != '')
 | 
  
    | 172 |                     {
 | 
  
    | 173 |                         $block_name = htmlentities(strip_tags($block[$section['block']]));
 | 
  
    | 174 |                     } else {
 | 
  
    | 175 |                         if ($section['block'] == 1)
 | 
  
    | 176 |                         {
 | 
  
    | 177 |                             $block_name = $TEXT['MAIN'];
 | 
  
    | 178 |                         } else {
 | 
  
    | 179 |                             $block_name = '#' . (int) $section['block'];
 | 
  
    | 180 |                         }
 | 
  
    | 181 |                     }
 | 
  
    | 182 | 
 | 
  
    | 183 |                     ob_start() ;
 | 
  
    | 184 |                     require(WB_PATH.'/modules/'.$module.'/modify.php');
 | 
  
    | 185 |                     $content = ob_get_clean() ;
 | 
  
    | 186 |                     if($content != '')
 | 
  
    | 187 |                     {
 | 
  
    | 188 |                       echo $sSectionBlock;//block-outer
 | 
  
    | 189 |                       $sSectionIdPrefix = (defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : '' );
 | 
  
    | 190 |                       $data = array();
 | 
  
    | 191 |                       $tpl = new Template(dirname($admin->correct_theme_source('SectionInfoLine.htt')),'keep');
 | 
  
    | 192 |                       // $template->debug = true;
 | 
  
    | 193 |                       $tpl->set_file('page', 'SectionInfoLine.htt');
 | 
  
    | 194 |                       $tpl->set_block('page', 'main_block', 'main');
 | 
  
    | 195 |                       $tpl->set_block('main_block', 'section_block', 'section_save');
 | 
  
    | 196 |                       $data['aTarget.SectionIdPrefix'] = $sSectionIdPrefix.$section_id;
 | 
  
    | 197 |                       $data['aTarget.SectionInfoLine'] = $sSectionInfoLine;
 | 
  
    | 198 |                       $data['aTarget.sectionBlock'] = $section['block'];
 | 
  
    | 199 |                       $data['aTarget.SectionId'] = $section_id;
 | 
  
    | 200 |                       $data['aTarget.pageId'] = $page_id;
 | 
  
    | 201 |                       $data['aTarget.FTAN'] = $admin->getFTAN();
 | 
  
    | 202 |                       $data['aTarget.BlockName'] = $block_name;
 | 
  
    | 203 |                       $data['aTarget.sectionUrl'] = ADMIN_URL.'/pages/';
 | 
  
    | 204 |                       $data['aTarget.sectionModule'] = $section['module'];
 | 
  
    | 205 |                       $data['aTarget.title'] = $section['title'];
 | 
  
    | 206 |                       $data['aTarget.Content'] = '';
 | 
  
    | 207 |                       if( $admin->get_permission('pages_settings') ) {
 | 
  
    | 208 |                         $data['lang.TEXT_SUBMIT'] = $TEXT['SAVE'];
 | 
  
    | 209 |                           $tpl->parse('section_save', 'section_block');
 | 
  
    | 210 |                       } else {
 | 
  
    | 211 |                           $tpl->parse('section_save', '');
 | 
  
    | 212 |                       }
 | 
  
    | 213 |                       $tpl->set_var($data);
 | 
  
    | 214 |                       $tpl->parse('main', 'main_block', false);
 | 
  
    | 215 |                       $tpl->pparse('output', 'page');
 | 
  
    | 216 |                       unset($tpl);
 | 
  
    | 217 |                      $sAfterContent = '</div>'."\n" ;
 | 
  
    | 218 |                      $content = $content."\n".$sAfterContent;
 | 
  
    | 219 |                      echo $content;
 | 
  
    | 220 |                 }
 | 
  
    | 221 |             }
 | 
  
    | 222 |         }
 | 
  
    | 223 |     }
 | 
  
    | 224 | }
 | 
  
    | 225 | 
 | 
  
    | 226 | // Print admin footer
 | 
  
    | 227 | $admin->print_footer();
 |