2294 $template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/dbx.js"></script>'); |
2294 $template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/dbx.js"></script>'); |
2295 $template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/dbx-key.js"></script>'); |
2295 $template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/dbx-key.js"></script>'); |
2296 $template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/sbedit.js"></script>'); |
2296 $template->add_header('<script type="text/javascript" src="'.scriptPath.'/includes/clientside/sbedit.js"></script>'); |
2297 $template->add_header('<link rel="stylesheet" type="text/css" href="'.scriptPath.'/includes/clientside/dbx.css" />'); |
2297 $template->add_header('<link rel="stylesheet" type="text/css" href="'.scriptPath.'/includes/clientside/dbx.css" />'); |
2298 |
2298 |
2299 // Knock the sidebars dead to keep javascript in plugins from interfering |
|
2300 $template->tpl_strings['SIDEBAR_LEFT'] = ''; |
|
2301 $template->tpl_strings['SIDEBAR_RIGHT'] = ''; |
|
2302 |
|
2303 $template->load_theme('oxygen', 'bleu'); |
2299 $template->load_theme('oxygen', 'bleu'); |
2304 $template->init_vars(); |
2300 $template->init_vars(); |
2305 |
2301 |
2306 $template->header(); |
2302 $template->header(); |
2307 |
2303 |
2376 $content = sanitize_html($content, true); |
2372 $content = sanitize_html($content, true); |
2377 } |
2373 } |
2378 |
2374 |
2379 if ( defined('ENANO_DEMO_MODE') && intval($_POST['type']) == BLOCK_PHP ) |
2375 if ( defined('ENANO_DEMO_MODE') && intval($_POST['type']) == BLOCK_PHP ) |
2380 { |
2376 { |
2381 echo '<div class="error-box" style="margin: 10px 0 10px 0;">Adding PHP code blocks in the Enano administration demo has been disabled for security reasons.</div>'; |
2377 echo '<div class="error-box" style="margin: 10px 0 10px 0;">' . $lang->get('sbedit_err_demo_php_disable') . '</div>'; |
2382 $_POST['php_content'] = '?><Nulled>'; |
2378 $_POST['php_content'] = '?><Nulled>'; |
2383 $content = $_POST['php_content']; |
2379 $content = $_POST['php_content']; |
2384 } |
2380 } |
2385 |
2381 |
2386 // Get the value of item_order |
2382 // Get the value of item_order |
2387 |
2383 |
2388 $q = $db->sql_query('SELECT * FROM '.table_prefix.'sidebar WHERE sidebar_id='.$db->escape($_POST['sidebar_id']).';'); |
2384 $q = $db->sql_query('SELECT * FROM '.table_prefix.'sidebar WHERE sidebar_id='.intval($_POST['sidebar_id']).';'); |
2389 if(!$q) $db->_die('The order number could not be selected'); |
2385 if(!$q) $db->_die('The order number could not be selected'); |
2390 $io = $db->numrows(); |
2386 $io = $db->numrows(); |
2391 |
2387 |
2392 $db->free_result(); |
2388 $db->free_result(); |
2393 |
2389 |
2432 </script> |
2428 </script> |
2433 |
2429 |
2434 <form action="<?php echo makeUrl($paths->page); ?>" method="post"> |
2430 <form action="<?php echo makeUrl($paths->page); ?>" method="post"> |
2435 |
2431 |
2436 <p> |
2432 <p> |
2437 What type of block should this be? |
2433 <?php echo $lang->get('sbedit_create_intro'); ?> |
2438 </p> |
2434 </p> |
2439 <p> |
2435 <p> |
2440 <select name="type" onchange="setType(this)"> <?php /* (NOT WORKING, at least in firefox 2) onload="var thingy = this; setTimeout('setType(thingy)', 500);" */ ?> |
2436 <select name="type" onchange="setType(this)"> <?php /* (NOT WORKING, at least in firefox 2) onload="var thingy = this; setTimeout('setType(thingy)', 500);" */ ?> |
2441 <option value="<?php echo BLOCK_WIKIFORMAT; ?>">Wiki-formatted block</option> |
2437 <option value="<?php echo BLOCK_WIKIFORMAT; ?>"><?php echo $lang->get('sbedit_block_type_wiki'); ?></option> |
2442 <option value="<?php echo BLOCK_TEMPLATEFORMAT; ?>">Template-formatted block (old pre-beta 3 behavior)</option> |
2438 <option value="<?php echo BLOCK_TEMPLATEFORMAT; ?>"><?php echo $lang->get('sbedit_block_type_tpl'); ?></option> |
2443 <option value="<?php echo BLOCK_HTML; ?>">Raw HTML block</option> |
2439 <option value="<?php echo BLOCK_HTML; ?>"><?php echo $lang->get('sbedit_block_type_html'); ?></option> |
2444 <option value="<?php echo BLOCK_PHP; ?>">PHP code block (danger, Will Robinson!)</option> |
2440 <option value="<?php echo BLOCK_PHP; ?>"><?php echo $lang->get('sbedit_block_type_php'); ?></option> |
2445 <option value="<?php echo BLOCK_PLUGIN; ?>">Use code from a plugin</option> |
2441 <option value="<?php echo BLOCK_PLUGIN; ?>"><?php echo $lang->get('sbedit_block_type_plugin'); ?></option> |
2446 </select> |
2442 </select> |
2447 </p> |
2443 </p> |
2448 |
2444 |
2449 <p> |
2445 <p> |
2450 |
2446 |
2451 Block title: <input name="title" type="text" size="40" /><br /> |
2447 <?php echo $lang->get('sbedit_field_block_title'); ?> <input name="title" type="text" size="40" /><br /> |
2452 Which sidebar: <select name="sidebar_id"><option value="<?php echo SIDEBAR_LEFT; ?>">Left</option><option value="<?php echo SIDEBAR_RIGHT; ?>">Right</option></select> |
2448 <?php echo $lang->get('sbedit_field_block_sidebar'); ?> |
|
2449 <select name="sidebar_id"> |
|
2450 <option value="<?php echo SIDEBAR_LEFT; ?>"><?php echo $lang->get('sbedit_field_block_sidebar_left'); ?></option> |
|
2451 <option value="<?php echo SIDEBAR_RIGHT; ?>"><?php echo $lang->get('sbedit_field_block_sidebar_right'); ?></option> |
|
2452 </select> |
2453 |
2453 |
2454 </p> |
2454 </p> |
2455 |
2455 |
2456 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_WIKIFORMAT; ?>"> |
2456 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_WIKIFORMAT; ?>"> |
2457 <p> |
2457 <p> |
2458 Wikitext: |
2458 <?php echo $lang->get('sbedit_field_wikitext'); ?> |
2459 </p> |
2459 </p> |
2460 <p> |
2460 <p> |
2461 <textarea style="width: 98%;" name="wikiformat_content" rows="15" cols="50"></textarea> |
2461 <textarea style="width: 98%;" name="wikiformat_content" rows="15" cols="50"></textarea> |
2462 </p> |
2462 </p> |
2463 </div> |
2463 </div> |
2464 |
2464 |
2465 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_TEMPLATEFORMAT; ?>"> |
2465 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_TEMPLATEFORMAT; ?>"> |
2466 <p> |
2466 <p> |
2467 Template code: |
2467 <?php echo $lang->get('sbedit_field_tplcode'); ?> |
2468 </p> |
2468 </p> |
2469 <p> |
2469 <p> |
2470 <textarea style="width: 98%;" name="templateformat_content" rows="15" cols="50"></textarea> |
2470 <textarea style="width: 98%;" name="templateformat_content" rows="15" cols="50"></textarea> |
2471 </p> |
2471 </p> |
2472 </div> |
2472 </div> |
2473 |
2473 |
2474 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_HTML; ?>"> |
2474 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_HTML; ?>"> |
2475 <p> |
2475 <p> |
2476 HTML to place inside the sidebar: |
2476 <?php echo $lang->get('sbedit_field_html'); ?> |
2477 </p> |
2477 </p> |
2478 <p> |
2478 <p> |
2479 <textarea style="width: 98%;" name="html_content" rows="15" cols="50"></textarea> |
2479 <textarea style="width: 98%;" name="html_content" rows="15" cols="50"></textarea> |
2480 </p> |
2480 </p> |
2481 </div> |
2481 </div> |
2482 |
2482 |
2483 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_PHP; ?>"> |
2483 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_PHP; ?>"> |
2484 <?php if ( defined('ENANO_DEMO_MODE') ) { ?> |
2484 <?php if ( defined('ENANO_DEMO_MODE') ) { ?> |
2485 <p>Creating PHP blocks in demo mode is disabled for security reasons.</p> |
2485 <p><?php echo $lang->get('sbedit_field_php_disabled'); ?></p> |
2486 <?php } else { ?> |
2486 <?php } else { ?> |
2487 <p> |
2487 <?php echo $lang->get('sbedit_field_php'); ?> |
2488 <b>WARNING:</b> If you don't know what you're doing, or if you are not fluent in PHP, stop now and choose a different block type. You will brick your Enano installation if you are not careful here. |
2488 |
2489 ALWAYS remember to write secure code! The Enano team is not responsible if someone drops all your tables because of an SQL injection vulnerability in your sidebar code. You are probably better off using the template-formatted block type. |
|
2490 </p> |
|
2491 <p> |
|
2492 <span style="color: red;"> |
|
2493 It is especially important to note that this code is NOT checked for errors! If there is a syntax error in your code here, it will prevent any pages from loading AT ALL. So you need to use an external PHP editor (like <a href="http://www.jedit.org">jEdit</a>) to check your syntax before you hit save. |
|
2494 </span> You have been warned. |
|
2495 </p> |
|
2496 <p> |
|
2497 Also, you should avoid using output buffering functions (ob_[start|end|get_contents|clean]) here, because Enano uses those to track output from this script. |
|
2498 </p> |
|
2499 <p> |
|
2500 The standard <?php and ?> tags work here. Don't use an initial "<?php" or it will cause a parse error. |
|
2501 </p> |
|
2502 <p> |
|
2503 PHP code: |
|
2504 </p> |
|
2505 <p> |
2489 <p> |
2506 <textarea style="width: 98%;" name="php_content" rows="15" cols="50"></textarea> |
2490 <textarea style="width: 98%;" name="php_content" rows="15" cols="50"></textarea> |
2507 </p> |
2491 </p> |
2508 <?php } ?> |
2492 <?php } ?> |
2509 </div> |
2493 </div> |
2510 |
2494 |
2511 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_PLUGIN; ?>"> |
2495 <div class="sbadd_block" id="blocktype_<?php echo BLOCK_PLUGIN; ?>"> |
2512 <p> |
2496 <p> |
2513 Plugin: |
2497 <?php echo $lang->get('sbedit_field_plugin'); ?> |
2514 </p> |
2498 </p> |
2515 <p> |
2499 <p> |
2516 <select name="plugin_id"> |
2500 <select name="plugin_id"> |
2517 <?php |
2501 <?php |
2518 foreach($template->plugin_blocks as $k => $c) |
2502 foreach($template->plugin_blocks as $k => $c) |
2698 |
2682 |
2699 $parser = $template->makeParserText($vars['sidebar_button']); |
2683 $parser = $template->makeParserText($vars['sidebar_button']); |
2700 $parser->assign_vars(Array( |
2684 $parser->assign_vars(Array( |
2701 'HREF'=>'#', |
2685 'HREF'=>'#', |
2702 'FLAGS'=>'onclick="return false;"', |
2686 'FLAGS'=>'onclick="return false;"', |
2703 'TEXT'=>'Change theme' |
2687 'TEXT' => $lang->get('sidebar_btn_changestyle') |
2704 )); |
2688 )); |
2705 $template->tpl_strings['THEME_LINK'] = $parser->run(); |
2689 $template->tpl_strings['THEME_LINK'] = $parser->run(); |
2706 $parser->assign_vars(Array( |
2690 $parser->assign_vars(Array( |
2707 'TEXT'=>'Log out', |
2691 'TEXT' => $lang->get('sidebar_btn_logout'), |
2708 )); |
2692 )); |
2709 $template->tpl_strings['LOGOUT_LINK'] = $parser->run(); |
2693 $template->tpl_strings['LOGOUT_LINK'] = $parser->run(); |
2710 |
2694 |
2711 $n1 = Array(); |
2695 $n1 = Array(); |
2712 $n2 = Array(); |
2696 $n2 = Array(); |
2761 ob_end_clean(); |
2745 ob_end_clean(); |
2762 $c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c); |
2746 $c = preg_replace('#<a (.*?)>(.*?)</a>#is', '<a href="#" onclick="return false;">\\2</a>', $c); |
2763 break; |
2747 break; |
2764 case BLOCK_PLUGIN: |
2748 case BLOCK_PLUGIN: |
2765 $parser = $template->makeParserText($vars['sidebar_section_raw']); |
2749 $parser = $template->makeParserText($vars['sidebar_section_raw']); |
2766 $c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : 'Can\'t find plugin block'; |
2750 $c = ($template->fetch_block($row['block_content'])) ? $template->fetch_block($row['block_content']) : $lang->get('sbedit_msg_plugin_not_loaded'); |
2767 break; |
2751 break; |
2768 } |
2752 } |
2769 $block_name = $row['block_name']; // $template->tplWikiFormat($row['block_name']); |
2753 $block_name = $row['block_name']; // $template->tplWikiFormat($row['block_name']); |
2770 if ( empty($block_name) ) |
2754 if ( empty($block_name) ) |
2771 $block_name = '<Unnamed>'; |
2755 $block_name = '<' . $lang->get('sbedit_note_block_unnamed') . '>'; |
2772 $t = '<span title="Double-click to rename this block" id="sbrename_' . $row['item_id'] . '" ondblclick="ajaxRenameSidebarStage1(this, \''.$row['item_id'].'\'); return false;">' . $block_name . '</span>'; |
2756 $t = '<span title="' . $lang->get('sbedit_hint_rename') . '" id="sbrename_' . $row['item_id'] . '" ondblclick="ajaxRenameSidebarStage1(this, \''.$row['item_id'].'\'); return false;">' . $block_name . '</span>'; |
2773 if($row['item_enabled'] == 0) $t .= ' <span id="disabled_'.$row['item_id'].'" style="color: red;">(disabled)</span>'; |
2757 if($row['item_enabled'] == 0) $t .= ' <span id="disabled_'.$row['item_id'].'" style="color: red;">' . $lang->get('sbedit_note_block_disabled') . '</span>'; |
2774 else $t .= ' <span id="disabled_'.$row['item_id'].'" style="color: red; display: none;">(disabled)</span>'; |
2758 else $t .= ' <span id="disabled_'.$row['item_id'].'" style="color: red; display: none;">' . $lang->get('sbedit_note_block_disabled') . '</span>'; |
2775 $side = ( $row['sidebar_id'] == SIDEBAR_LEFT ) ? SIDEBAR_RIGHT : SIDEBAR_LEFT; |
2759 $side = ( $row['sidebar_id'] == SIDEBAR_LEFT ) ? SIDEBAR_RIGHT : SIDEBAR_LEFT; |
2776 $tb = '<a title="Enable or disable this block" href="'.makeUrl($paths->page, 'action=disenable&id='.$row['item_id'].'' , true).'" onclick="ajaxDisenableBlock(\''.$row['item_id'].'\'); return false;" ><img alt="Enable/disable this block" style="border-width: 0;" src="'.scriptPath.'/images/disenable.png" /></a> |
2760 $tb = '<a title="' . $lang->get('sbedit_tip_disenable') . '" href="'.makeUrl($paths->page, 'action=disenable&id='.$row['item_id'].'' , true).'" onclick="ajaxDisenableBlock(\''.$row['item_id'].'\'); return false;" ><img alt="' . $lang->get('sbedit_tip_disenable') . '" style="border-width: 0;" src="'.scriptPath.'/images/disenable.png" /></a> |
2777 <a title="Edit the contents of this block" href="'.makeUrl($paths->page, 'action=edit&id='.$row['item_id'].'' , true).'" onclick="ajaxEditBlock(\''.$row['item_id'].'\', this); return false;"><img alt="Edit this block" style="border-width: 0;" src="'.scriptPath.'/images/edit.png" /></a> |
2761 <a title="' . $lang->get('sbedit_tip_edit') . '" href="'.makeUrl($paths->page, 'action=edit&id='.$row['item_id'].'' , true).'" onclick="ajaxEditBlock(\''.$row['item_id'].'\', this); return false;"><img alt="' . $lang->get('sbedit_tip_edit') . '" style="border-width: 0;" src="'.scriptPath.'/images/edit.png" /></a> |
2778 <a title="Permanently delete this block" href="'.makeUrl($paths->page, 'action=delete&id='.$row['item_id'].'' , true).'" onclick="if(confirm(\'Do you really want to delete this block?\')) { ajaxDeleteBlock(\''.$row['item_id'].'\', this); } return false;"><img alt="Delete this block" style="border-width: 0;" src="'.scriptPath.'/images/delete.png" /></a> |
2762 <a title="' . $lang->get('sbedit_tip_delete') . '" href="'.makeUrl($paths->page, 'action=delete&id='.$row['item_id'].'' , true).'" onclick="if(confirm(\'' . $lang->get('sbedit_msg_delete_confirm') . '\')) { ajaxDeleteBlock(\''.$row['item_id'].'\', this); } return false;"><img alt="' . $lang->get('sbedit_tip_delete') . '" style="border-width: 0;" src="'.scriptPath.'/images/delete.png" /></a> |
2779 <a title="Move this block to the other sidebar" href="'.makeUrl($paths->page, 'action=move&id='.$row['item_id'].'&side='.$side, true).'"><img alt="Move this block" style="border-width: 0;" src="'.scriptPath.'/images/move.png" /></a>'; |
2763 <a title="' . $lang->get('sbedit_tip_move') . '" href="'.makeUrl($paths->page, 'action=move&id='.$row['item_id'].'&side='.$side, true).'"><img alt="' . $lang->get('sbedit_tip_move') . '" style="border-width: 0;" src="'.scriptPath.'/images/move.png" /></a>'; |
2780 $as = ''; |
2764 $as = ''; |
2781 $ae = ' '.$tb; |
2765 $ae = ' '.$tb; |
2782 $parser->assign_vars(Array('CONTENT'=>$c,'TITLE'=>$t,'ADMIN_START'=>$as,'ADMIN_END'=>$ae)); |
2766 $parser->assign_vars(Array('CONTENT'=>$c,'TITLE'=>$t,'ADMIN_START'=>$as,'ADMIN_END'=>$ae)); |
2783 echo $parser->run(); |
2767 echo $parser->run(); |
2784 unset($parser); |
2768 unset($parser); |
2792 echo "<input type='hidden' id='divOrder_Left' name='order_left' value='{$order}' />"; |
2776 echo "<input type='hidden' id='divOrder_Left' name='order_left' value='{$order}' />"; |
2793 $order = implode(',', $n2); |
2777 $order = implode(',', $n2); |
2794 echo "<input type='hidden' id='divOrder_Right' name='order_right' value='{$order}' />"; |
2778 echo "<input type='hidden' id='divOrder_Right' name='order_right' value='{$order}' />"; |
2795 echo ' |
2779 echo ' |
2796 <div style="margin: 0 auto 0 auto; text-align: center;"> |
2780 <div style="margin: 0 auto 0 auto; text-align: center;"> |
2797 <input type="submit" name="save" style="font-weight: bold;" value="Save changes" /> |
2781 <input type="submit" name="save" style="font-weight: bold;" value="' . $lang->get('etc_save_changes') . '" /> |
2798 <input type="submit" name="revert" style="font-weight: normal;" value="Revert" onclick="return confirm(\'Do you really want to revert your changes?\nNote: this does not revert edits or deletions, those are saved as soon as you confirm the action.\')" /> |
2782 <input type="submit" name="revert" style="font-weight: normal;" value="' . $lang->get('sbedit_btn_revert') . '" onclick="return confirm($lang.get(\'sbedit_msg_discard_order_confirm\'))" /> |
2799 <br /> |
2783 <br /> |
2800 <a href="'.makeUrl($paths->page, 'action=new&id=0', true).'">Create new block</a> | <a href="'.makeUrl(getConfig('main_page'), false, true).'">Main Page</a> |
2784 <a href="'.makeUrl($paths->page, 'action=new&id=0', true).'">' . $lang->get('sbedit_btn_create_new_stage1') . '</a> | <a href="'.makeUrl(getConfig('main_page'), false, true).'">' . $lang->get('sbedit_btn_main_page') . '</a> |
2801 </div> |
2785 </div> |
2802 </form> |
2786 </form> |
2803 '; |
2787 '; |
2804 } |
2788 } |
2805 |
2789 |