1239 echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>'; |
1240 echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>'; |
1240 echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>'; |
1241 echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>'; |
1241 return; |
1242 return; |
1242 } |
1243 } |
1243 |
1244 |
1244 echo '<h2>Page management</h2>'; |
1245 if ( ENANO_DBLAYER != 'MYSQL' ) |
1245 |
1246 die('<h3>' . $lang->get('acpdb_err_not_supported_title') . '</h3> |
1246 if ( isset($_POST['search']) || isset($_POST['select']) || ( isset($_GET['source']) && $_GET['source'] == 'ajax' ) ) |
1247 <p>' . $lang->get('acpdb_err_not_supported_desc') . '</p>'); |
1247 { |
1248 |
1248 // The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms... |
1249 if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes' && defined('ENANO_DEMO_MODE') ) |
1249 $source = ( isset($_GET['source']) ) ? $_GET['source'] : false; |
1250 { |
1250 if ( $source == 'ajax' ) |
1251 redirect(makeUrlComplete('Special', 'Administration'), $lang->get('acpdb_err_demo_mode_title'), $lang->get('acpdb_err_demo_mode_desc'), 5); |
1251 { |
1252 } |
1252 $_POST['search'] = true; |
1253 |
1253 $_POST['page_url'] = $_GET['page_id']; |
1254 global $system_table_list; |
1254 } |
1255 if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes') |
1255 if ( isset($_POST['search']) ) |
1256 { |
1256 { |
1257 |
1257 $pid = $_POST['page_url']; |
1258 if(defined('SQL_BACKUP_CRYPT')) |
1258 } |
1259 // Try to increase our time limit |
1259 elseif ( isset($_POST['select']) ) |
1260 @set_time_limit(0); |
1260 { |
1261 // Do the actual export |
1261 $pid = $_POST['page_force_url']; |
1262 $aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : ''; |
1262 } |
1263 $filename = 'enano_backup_' . enano_date('ymd') . '.sql' . $aesext; |
1263 else |
1264 ob_start(); |
1264 { |
1265 // Spew some headers |
1265 echo 'Internal error selecting page search terms'; |
1266 $headdate = enano_date('F d, Y \a\t h:i a'); |
1266 return false; |
1267 echo <<<HEADER |
1267 } |
1268 -- Enano CMS SQL backup |
1268 // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary |
1269 -- Generated on {$headdate} by {$session->username} |
1269 $k = array_keys($paths->nslist); |
1270 |
1270 for ( $i = 0; $i < sizeof($paths->nslist); $i++ ) |
1271 HEADER; |
1271 { |
1272 // build the table list |
1272 $ln = strlen($paths->nslist[$k[$i]]); |
1273 $base = ( isset($_POST['do_system_tables']) ) ? $system_table_list : Array(); |
1273 if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]]) |
1274 $add = ( isset($_POST['additional_tables'])) ? $_POST['additional_tables'] : Array(); |
1274 { |
1275 $tables = array_merge($base, $add); |
1275 $ns = $k[$i]; |
1276 |
1276 $page_id = substr($pid, $ln, strlen($pid)); |
1277 // Log it! |
1277 } |
1278 $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'db_backup\', '.time().', \''.enano_date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(implode(', ', $tables)) . '\')'); |
1278 } |
1279 if ( !$e ) |
1279 // The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id |
1280 $db->_die(); |
1280 // Now, iterate through $paths->pages searching for a page with this name or ID |
1281 |
1281 for ( $i = 0; $i < sizeof($paths->pages) / 2; $i++ ) |
1282 foreach($tables as $i => $t) |
1282 { |
1283 { |
1283 if ( !isset($final_pid) ) |
1284 if(!preg_match('#^([a-z0-9_]+)$#i', $t)) |
1284 { |
1285 die('Hacking attempt'); |
1285 if ( $paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id) ) |
1286 // if($t == table_prefix.'files' && isset($_POST['do_data'])) |
1286 { |
1287 // unset($tables[$i]); |
1287 $final_pid = str_replace(' ', '_', $page_id); |
1288 } |
1288 } |
1289 foreach($tables as $t) |
1289 else if ( $paths->pages[$i]['name'] == $page_id ) |
1290 { |
1290 { |
1291 // THE FOLLOWING COMMENT DOES NOT APPLY AS OF 1.0. |
1291 $final_pid = $paths->pages[$i]['urlname_nons']; |
1292 // Sorry folks - this script CAN'T backup enano_files and enano_search_index due to the sheer size of the tables. |
1292 } |
1293 // If encryption is enabled the log data will be excluded too. |
1293 else if ( strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id)) ) |
1294 $result = export_table( |
1294 { |
1295 $t, |
1295 $final_pid = $paths->pages[$i]['urlname_nons']; |
1296 isset($_POST['do_struct']), |
1296 } |
1297 ( isset($_POST['do_data']) ), |
1297 else if ( strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id)) ) |
1298 false |
1298 { |
1299 ) . "\n"; |
1299 $final_pid = $paths->pages[$i]['urlname_nons']; |
1300 if ( !$result ) |
1300 } |
1301 { |
1301 if ( isset($final_pid) ) |
1302 $db->_die(); |
1302 { |
1303 } |
1303 $_POST['name'] = $paths->pages[$i]['name']; |
1304 echo $result; |
1304 $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; |
1305 } |
1305 } |
1306 $data = ob_get_contents(); |
1306 } |
1307 ob_end_clean(); |
1307 } |
1308 if(defined('SQL_BACKUP_CRYPT')) |
1308 if ( !isset($final_pid) ) |
1309 { |
1309 { |
1310 // Free some memory, we don't need this stuff any more |
1310 echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; |
1311 $db->close(); |
1311 return false; |
1312 unset($paths, $db, $template, $plugins); |
1312 } |
1313 $tea = new TEACrypt(); |
1313 $_POST['namespace'] = $ns; |
1314 $data = $tea->encrypt($data, $session->private_key); |
1314 $_POST['old_namespace'] = $ns; |
1315 } |
1315 $_POST['page_id'] = $final_pid; |
1316 header('Content-disposition: attachment; filename='.$filename.''); |
1316 $_POST['old_page_id'] = $final_pid; |
1317 header('Content-type: application/octet-stream'); |
1317 if ( !isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']]) ) |
1318 header('Content-length: '.strlen($data)); |
1318 { |
1319 echo $data; |
1319 echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; |
1320 exit; |
1320 return false; |
1321 } |
1321 } |
1322 else |
1322 } |
1323 { |
1323 |
1324 // Show the UI |
1324 if ( isset($_POST['page_id']) && isset($_POST['namespace']) && !isset($_POST['cancel']) ) |
1325 echo '<form action="'.makeUrlNS('Admin', 'DBBackup', 'submitting=yes', true).'" method="post" enctype="multipart/form-data">'; |
1325 { |
|
1326 $cpage = $paths->pages[$paths->nslist[$_POST['old_namespace']].$_POST['old_page_id']]; |
|
1327 if(isset($_POST['submit'])) |
|
1328 { |
|
1329 switch(true) |
|
1330 { |
|
1331 case true: |
|
1332 // Create a list of things to update |
|
1333 $page_info = Array( |
|
1334 'name'=>$_POST['name'], |
|
1335 'urlname'=>sanitize_page_id($_POST['page_id']), |
|
1336 'namespace'=>$_POST['namespace'], |
|
1337 'special'=>isset($_POST['special']) ? '1' : '0', |
|
1338 'visible'=>isset($_POST['visible']) ? '1' : '0', |
|
1339 'comments_on'=>isset($_POST['comments_on']) ? '1' : '0', |
|
1340 'protected'=>isset($_POST['protected']) ? '1' : '0' |
|
1341 ); |
|
1342 |
|
1343 $updating_urlname_or_namespace = ( $page_info['namespace'] != $cpage['namespace'] || $page_info['urlname'] != $cpage['urlname_nons'] ); |
|
1344 |
|
1345 if ( !isset($paths->nslist[ $page_info['namespace'] ]) ) |
|
1346 { |
|
1347 echo '<div class="error-box">The namespace you selected is not properly registered.</div>'; |
|
1348 break; |
|
1349 } |
|
1350 if ( isset($paths->pages[ $paths->nslist[$page_info['namespace']] . $page_info[ 'urlname' ] ]) && $updating_urlname_or_namespace ) |
|
1351 { |
|
1352 echo '<div class="error-box">There is already a page that exists with that URL string and namespace.</div>'; |
|
1353 break; |
|
1354 } |
|
1355 // Build the query |
|
1356 $q = 'UPDATE '.table_prefix.'pages SET '; |
|
1357 $k = array_keys($page_info); |
|
1358 foreach($k as $c) |
|
1359 { |
|
1360 $q .= $c.'=\''.$db->escape($page_info[$c]).'\','; |
|
1361 } |
|
1362 $q = substr($q, 0, strlen($q)-1); |
|
1363 // Build the WHERE statements |
|
1364 $q .= ' WHERE '; |
|
1365 $k = array_keys($cpage); |
|
1366 if ( !isset($cpage) ) |
|
1367 die('[internal] no cpage'); |
|
1368 foreach($k as $c) |
|
1369 { |
|
1370 if($c != 'urlname_nons' && $c != 'urlname' && $c != 'really_protected') |
|
1371 { |
|
1372 $q .= $c.'=\''.$db->escape($cpage[$c]).'\' AND '; |
|
1373 } |
|
1374 else if($c == 'urlname') |
|
1375 { |
|
1376 $q .= $c.'=\''.$db->escape($cpage['urlname_nons']).'\' AND '; |
|
1377 } |
|
1378 } |
|
1379 // Trim off the last " AND " and append a semicolon |
|
1380 $q = substr($q, 0, strlen($q)-5) . ';'; |
|
1381 // Send the completed query to MySQL |
|
1382 $e = $db->sql_query($q); |
|
1383 if(!$e) $db->_die('The page data could not be updated.'); |
|
1384 // Update any additional tables |
|
1385 $q = Array( |
|
1386 'UPDATE '.table_prefix.'categories SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1387 'UPDATE '.table_prefix.'comments SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1388 'UPDATE '.table_prefix.'logs SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1389 'UPDATE '.table_prefix.'page_text SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1390 'UPDATE '.table_prefix.'acl SET page_id=\''.$page_info['urlname'].'\',namespace=\''.$page_info['namespace'].'\' WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';' |
|
1391 ); |
|
1392 foreach($q as $cq) |
|
1393 { |
|
1394 $e = $db->sql_query($cq); |
|
1395 if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.'); |
|
1396 } |
|
1397 // Update $cpage |
|
1398 $cpage = $page_info; |
|
1399 $cpage['urlname_nons'] = $cpage['urlname']; |
|
1400 $cpage['urlname'] = $paths->nslist[$cpage['namespace']].$cpage['urlname']; |
|
1401 $_POST['old_page_id'] = $page_info['urlname']; |
|
1402 $_POST['old_namespace'] = $page_info['namespace']; |
|
1403 echo '<div class="info-box">Your changes have been saved.</div>'; |
|
1404 break; |
|
1405 } |
|
1406 } elseif(isset($_POST['delete'])) { |
|
1407 $q = Array( |
|
1408 'DELETE FROM '.table_prefix.'categories WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1409 'DELETE FROM '.table_prefix.'comments WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1410 'DELETE FROM '.table_prefix.'logs WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1411 'DELETE FROM '.table_prefix.'page_text WHERE page_id=\'' . $db->escape($_POST['old_page_id']) . '\' AND namespace=\'' . $db->escape($_POST['old_namespace']) . '\';', |
|
1412 ); |
|
1413 foreach($q as $cq) |
|
1414 { |
|
1415 $e = $db->sql_query($cq); |
|
1416 if(!$e) $db->_die('Some of the additional tables containing page information could not be updated.'); |
|
1417 } |
|
1418 |
|
1419 if(!$db->sql_query( |
|
1420 'DELETE FROM '.table_prefix.'pages WHERE urlname="'.$db->escape($_POST['old_page_id']).'" AND namespace="'.$db->escape($_POST['old_namespace']).'";' |
|
1421 )) $db->_die('The page could not be deleted.'); |
|
1422 echo '<div class="info-box">This page has been deleted.</p><p><a href="javascript:ajaxPage(\''.$paths->nslist['Admin'].'PageManager\');">Return to Page manager</a><br /><a href="javascript:ajaxPage(\''.$paths->nslist['Admin'].'Home\');">Admin home</a></div>'; |
|
1423 return; |
|
1424 } |
|
1425 $url = makeUrlNS('Special', 'Administration', 'module='.$paths->cpage['module'], true); |
|
1426 echo '<form action="'.$url.'" method="post">'; |
|
1427 ?> |
1326 ?> |
1428 <h3>Modify page: <?php echo htmlspecialchars($_POST['name']); ?></h3> |
1327 <p><?php echo $lang->get('acpdb_intro'); ?></p> |
1429 <table border="0"> |
1328 <p><label><input type="checkbox" name="do_system_tables" checked="checked" /> <?php echo $lang->get('acpdb_lbl_system_tables'); ?></label><p> |
1430 <tr> |
1329 <p><?php echo $lang->get('acpdb_lbl_additional_tables'); ?></p> |
1431 <td>Namespace:</td> |
1330 <p><select name="additional_tables[]" multiple="multiple"> |
1432 <td> |
1331 <?php |
1433 <select name="namespace"> |
1332 if ( ENANO_DBLAYER == 'MYSQL' ) |
1434 <?php |
1333 { |
1435 $nm = array_keys($paths->nslist); |
1334 $q = $db->sql_query('SHOW TABLES;') or $db->_die('Somehow we were denied the request to get the list of tables.'); |
1436 foreach ( $nm as $ns ) |
1335 } |
1437 { |
1336 else if ( ENANO_DBLAYER == 'PGSQL' ) |
1438 if ( $ns != 'Special' && $ns != 'Admin' ) |
1337 { |
1439 { |
1338 $q = $db->sql_query('SELECT relname FROM pg_stat_user_tables ORDER BY relname;') or $db->_die('Somehow we were denied the request to get the list of tables.'); |
1440 echo '<option '; |
1339 } |
1441 if ( $_POST['namespace'] == $ns ) |
1340 while($row = $db->fetchrow_num()) |
1442 echo 'selected="selected" '; |
1341 { |
1443 echo 'value="'.$ns.'">'; |
1342 if(!in_array($row[0], $system_table_list)) echo '<option value="'.$row[0].'">'.$row[0].'</option>'; |
1444 if ( $paths->nslist[$ns] == '' ) |
1343 } |
1445 echo '[No prefix]'; |
1344 ?> |
1446 else |
1345 </select> |
1447 echo $paths->nslist[$ns]; |
1346 </p> |
1448 echo '</option>'; |
1347 <p><label><input type="checkbox" name="do_struct" checked="checked" /> <?php echo $lang->get('acpdb_lbl_include_structure'); ?></label><br /> |
1449 } |
1348 <label><input type="checkbox" name="do_data" checked="checked" /> <?php echo $lang->get('acpdb_lbl_include_data'); ?></label> |
1450 } ?> |
1349 </p> |
1451 </select> |
1350 <p><input type="submit" value="<?php echo $lang->get('acpdb_btn_create_backup'); ?>" /></p> |
1452 </td> |
|
1453 </tr> |
|
1454 <tr> |
|
1455 <td> |
|
1456 Page title: |
|
1457 </td> |
|
1458 <td> |
|
1459 <input type="text" name="name" value="<?php echo htmlspecialchars($cpage['name']); ?>" /> |
|
1460 </td> |
|
1461 </tr> |
|
1462 <tr> |
|
1463 <td> |
|
1464 Page URL string:<br /> |
|
1465 <small>No spaces, and don't enter the namespace prefix (e.g. User:).<br /> |
|
1466 Changing this value is usually not a good idea, especially for templates and project pages.</small> |
|
1467 </td> |
|
1468 <td> |
|
1469 <input type="text" name="page_id" value="<?php echo htmlspecialchars(dirtify_page_id($cpage['urlname_nons'])); ?>" /> |
|
1470 </td> |
|
1471 </tr> |
|
1472 <tr> |
|
1473 <td></td> |
|
1474 <td> |
|
1475 <input <?php if($cpage['comments_on']) echo 'checked="checked"'; ?> name="comments_on" type="checkbox" id="cmt" /> |
|
1476 <label for="cmt">Enable comments for this page</label> |
|
1477 </td> |
|
1478 </tr> |
|
1479 <tr> |
|
1480 <td></td> |
|
1481 <td> |
|
1482 <input <?php if($cpage['special']) echo 'checked="checked"'; ?> name="special" type="checkbox" id="spc" /> |
|
1483 <label for="spc">Bypass the template engine for this page</label><br /> |
|
1484 <small>This option enables you to use your own HTML headers and other code. It is recommended that only advanced users enable this feature. As with other Enano pages, you may use PHP code in your pages, meaning you can use Enano's API on the page.</small> |
|
1485 </td> |
|
1486 </tr> |
|
1487 <tr> |
|
1488 <td></td> |
|
1489 <td> |
|
1490 <input <?php if($cpage['visible']) echo 'checked="checked"'; ?> name="visible" type="checkbox" id="vis" /> |
|
1491 <label for="vis">Allow this page to be shown in page lists</label><br /> |
|
1492 <small>Unchecking this checkbox prevents the page for being indexed for searching. The index is rebuilt each time a page is saved, and you can force an index rebuild by going to the page <?php echo $paths->nslist['Special']; ?>SearchRebuild.</small> |
|
1493 </td> |
|
1494 </tr> |
|
1495 <tr> |
|
1496 <td></td> |
|
1497 <td> |
|
1498 <input <?php if($cpage['protected']) echo 'checked="checked"'; ?> name="protected" type="checkbox" id="prt" /> |
|
1499 <label for="prt">Prevent non-administrators from editing this page</label><br /> |
|
1500 <small>This option only has an effect when Wiki Mode is enabled.</small> |
|
1501 </td> |
|
1502 </tr> |
|
1503 <tr> |
|
1504 <td></td> |
|
1505 <td> |
|
1506 <input type="submit" name="delete" value="Delete page" style="color: red" onclick="return confirm('Do you REALLY want to delete this page?')" /> |
|
1507 </td> |
|
1508 </tr> |
|
1509 <tr> |
|
1510 <td colspan="2" style="text-align: center;"> |
|
1511 <hr /> |
|
1512 </td> |
|
1513 </tr> |
|
1514 <tr> |
|
1515 <td colspan="2" style="text-align: right;"> |
|
1516 <input type="hidden" name="old_page_id" value="<?php echo htmlspecialchars($_POST['old_page_id']); ?>" /> |
|
1517 <input type="hidden" name="old_namespace" value="<?php echo htmlspecialchars($_POST['old_namespace']); ?>" /> |
|
1518 <input type="Submit" name="submit" value="Save changes" style="font-weight: bold;" /> |
|
1519 <input type="submit" name="cancel" value="Cancel changes" /> |
|
1520 </td> |
|
1521 </tr> |
|
1522 </table> |
|
1523 <?php |
1351 <?php |
1524 echo '</form>'; |
1352 echo '</form>'; |
1525 } |
1353 } |
1526 else |
|
1527 { |
|
1528 echo '<h3>Please select a page</h3>'; |
|
1529 echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">'; |
|
1530 ?> |
|
1531 <p>Search for page title (remember prefixes like User: and File:) <?php echo $template->pagename_field('page_url'); ?> <input type="submit" style="font-weight: bold;" name="search" value="Search" /></p> |
|
1532 <p>Select page title from a list: <select name="page_force_url"> |
|
1533 <?php |
|
1534 for($i=0;$i<sizeof($paths->pages)/2;$i++) |
|
1535 { |
|
1536 if($paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['namespace'] != 'Special') echo '<option value="'.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['urlname_nons'].'">'.htmlspecialchars($paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['name']).'</option>'."\n"; |
|
1537 } |
|
1538 ?> |
|
1539 </select> <input type="submit" name="select" value="Select" /></p> |
|
1540 <?php |
|
1541 echo '</form>'; |
|
1542 |
|
1543 } |
|
1544 } |
1354 } |
1545 */ |
|
1546 |
1355 |
1547 function page_Admin_PageEditor() |
1356 /* |
1548 { |
1357 * Admin:PageManager sources are in /plugins/admin/PageManager.php. |
1549 global $db, $session, $paths, $template, $plugins; // Common objects |
1358 */ |
1550 global $lang; |
1359 |
1551 if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) |
1360 /* |
1552 { |
1361 * Admin:PageEditor sources are in /plugins/admin/PageEditor.php. |
1553 $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); |
1362 */ |
1554 echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>'; |
|
1555 echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>'; |
|
1556 return; |
|
1557 } |
|
1558 |
|
1559 |
|
1560 echo '<h2>Edit page content</h2>'; |
|
1561 |
|
1562 if(isset($_POST['search']) || isset($_POST['select'])) { |
|
1563 // The object of the game: using only the text a user entered, guess the page ID and namespace. *sigh* I HATE writing search algorithms... |
|
1564 if(isset($_POST['search'])) $pid = $_POST['page_url']; |
|
1565 elseif(isset($_POST['select'])) $pid = $_POST['page_force_url']; |
|
1566 else { echo 'Internal error selecting page search terms'; return false; } |
|
1567 // Look for a namespace prefix in the urlname, and assign a different namespace, if necessary |
|
1568 $k = array_keys($paths->nslist); |
|
1569 for($i=0;$i<sizeof($paths->nslist);$i++) |
|
1570 { |
|
1571 $ln = strlen($paths->nslist[$k[$i]]); |
|
1572 if(substr($pid, 0, $ln) == $paths->nslist[$k[$i]]) |
|
1573 { |
|
1574 $ns = $k[$i]; |
|
1575 $page_id = substr($pid, $ln, strlen($pid)); |
|
1576 } |
|
1577 } |
|
1578 // The namespace is in $ns and the page name or ID (we don't know which yet) is in $page_id |
|
1579 // Now, iterate through $paths->pages searching for a page with this name or ID |
|
1580 for($i=0;$i<sizeof($paths->pages)/2;$i++) |
|
1581 { |
|
1582 if(!isset($final_pid)) |
|
1583 { |
|
1584 if ($paths->pages[$i]['urlname_nons'] == str_replace(' ', '_', $page_id)) $final_pid = str_replace(' ', '_', $page_id); |
|
1585 elseif($paths->pages[$i]['name'] == $page_id) $final_pid = $paths->pages[$i]['urlname_nons']; |
|
1586 elseif(strtolower($paths->pages[$i]['urlname_nons']) == strtolower(str_replace(' ', '_', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; |
|
1587 elseif(strtolower($paths->pages[$i]['name']) == strtolower(str_replace('_', ' ', $page_id))) $final_pid = $paths->pages[$i]['urlname_nons']; |
|
1588 if(isset($final_pid)) { $_POST['name'] = $paths->pages[$i]['name']; $_POST['urlname'] = $paths->pages[$i]['urlname_nons']; } |
|
1589 } |
|
1590 } |
|
1591 if(!isset($final_pid)) { echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; return false; } |
|
1592 $_POST['namespace'] = $ns; |
|
1593 $_POST['page_id'] = $final_pid; |
|
1594 if(!isset($paths->pages[$paths->nslist[$_POST['namespace']].$_POST['urlname']])) { echo 'The page you searched for cannot be found. <a href="#" onclick="ajaxPage(\''.$paths->nslist['Admin'].'PageManager\'); return false;">Back</a>'; return false; } |
|
1595 } |
|
1596 |
|
1597 if(isset($_POST['page_id']) && !isset($_POST['cancel'])) |
|
1598 { |
|
1599 echo '<form name="main" action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post">'; |
|
1600 if(!isset($_POST['content']) || isset($_POST['revert'])) $content = RenderMan::getPage($_POST['page_id'], $_POST['namespace'], 0, false, false, false, false); |
|
1601 else $content = $_POST['content']; |
|
1602 if(isset($_POST['save'])) |
|
1603 { |
|
1604 $data = $content; |
|
1605 $id = md5( microtime() . mt_rand() ); |
|
1606 |
|
1607 $minor = isset($_POST['minor']) ? 'true' : 'false'; |
|
1608 $q='INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,page_id,namespace,page_text,char_tag,author,edit_summary,minor_edit) VALUES(\'page\', \'edit\', '.time().', \''.date('d M Y h:i a').'\', \'' . $db->escape($_POST['page_id']) . '\', \'' . $db->escape($_POST['namespace']) . '\', \''.$db->escape($data).'\', \''.$id.'\', \''.$session->username.'\', \''.$db->escape(htmlspecialchars($_POST['summary'])).'\', '.$minor.');'; |
|
1609 if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.'); |
|
1610 |
|
1611 $query = 'UPDATE '.table_prefix.'page_text SET page_text=\''.$db->escape($data).'\',char_tag=\''.$id.'\' WHERE page_id=\'' . $db->escape($_POST['page_id']) . '\' AND namespace=\'' . $db->escape($_POST['namespace']) . '\';'; |
|
1612 $e = $db->sql_query($query); |
|
1613 if(!$e) echo '<div class="warning-box">The page data could not be saved. MySQL said: '.mysql_error().'<br /><br />Query:<br /><pre>'.$query.'</pre></div>'; |
|
1614 else echo '<div class="info-box">Your page has been saved. <a href="'.makeUrlNS($_POST['namespace'], $_POST['page_id']).'">View page...</a></div>'; |
|
1615 } elseif(isset($_POST['preview'])) { |
|
1616 echo '<h3>Preview</h3><p><b>Reminder:</b> This is only a preview; your changes to this page have not yet been saved.</p><div style="margin: 1em; padding: 10px; border: 1px dashed #606060; background-color: #F8F8F8; max-height: 200px; overflow: auto;">'.RenderMan::render($content).'</div>'; |
|
1617 } |
|
1618 ?> |
|
1619 <p> |
|
1620 <textarea name="content" rows="20" cols="60" style="width: 100%;"><?php echo htmlspecialchars($content); ?></textarea><br /> |
|
1621 Edit summary: <input name="summary" value="<?php if(isset($_POST['summary'])) echo htmlspecialchars($_POST['summary']); ?>" size="40" /><br /> |
|
1622 <label><input type="checkbox" name="minor" <?php if(isset($_POST['minor'])) echo 'checked="checked" '; ?>/> This is a minor edit</label> |
|
1623 </p> |
|
1624 <p> |
|
1625 <input type="hidden" name="page_id" value="<?php echo htmlspecialchars($_POST['page_id']); ?>" /> |
|
1626 <input type="hidden" name="namespace" value="<?php echo htmlspecialchars($_POST['namespace']); ?>" /> |
|
1627 <input type="submit" name="save" value="Save changes" style="font-weight: bold;" /> <input type="submit" name="preview" value="Show preview" /> <input type="submit" name="revert" value="Revert changes" onclick="return confirm('Do you really want to revert your changes?');" /> <input type="submit" name="cancel" value="Cancel" onclick="return confirm('Do you really want to cancel your changes?');" /> |
|
1628 </p> |
|
1629 <?php |
|
1630 echo '</form>'; |
|
1631 } else { |
|
1632 echo '<h3>Please select a page</h3>'; |
|
1633 echo '<form action="'.makeUrl($paths->nslist['Special'].'Administration', 'module='.$paths->cpage['module']).'" method="post" onsubmit="if(!submitAuthorized) return false;" enctype="multipart/form-data">'; |
|
1634 ?> |
|
1635 <p>Search for page title (remember prefixes like User: and File:) <?php echo $template->pagename_field('page_url'); ?> <input type="submit" style="font-weight: bold;" name="search" value="Search" /></p> |
|
1636 <p>Select page title from a list: <select name="page_force_url"> |
|
1637 <?php |
|
1638 for ( $i = 0; $i < sizeof($paths->pages) / 2; $i++ ) |
|
1639 { |
|
1640 if($paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['namespace'] != 'Special') echo '<option value="'.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['urlname_nons'].'">'.$paths->nslist[$paths->pages[$i]['namespace']].$paths->pages[$i]['name'].'</option>'."\n"; |
|
1641 } |
|
1642 ?> |
|
1643 </select> <input type="submit" name="select" value="Select" /></p> |
|
1644 <?php |
|
1645 echo '</form>'; |
|
1646 } |
|
1647 } |
|
1648 |
1363 |
1649 function page_Admin_ThemeManager() |
1364 function page_Admin_ThemeManager() |
1650 { |
1365 { |
1651 |
1366 |
1652 global $db, $session, $paths, $template, $plugins; // Common objects |
1367 global $db, $session, $paths, $template, $plugins; // Common objects |
1734 echo('</form>'); |
1449 echo('</form>'); |
1735 } |
1450 } |
1736 elseif(isset($_POST['editsave'])) { |
1451 elseif(isset($_POST['editsave'])) { |
1737 $q = 'UPDATE '.table_prefix.'themes SET theme_name=\'' . $db->escape($_POST['name']) . '\',default_style=\''.$db->escape($_POST['defaultcss']).'\' WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; |
1452 $q = 'UPDATE '.table_prefix.'themes SET theme_name=\'' . $db->escape($_POST['name']) . '\',default_style=\''.$db->escape($_POST['defaultcss']).'\' WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; |
1738 $s = $db->sql_query($q); |
1453 $s = $db->sql_query($q); |
1739 if(!$s) die('Error updating name value: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1454 if(!$s) die('Error updating name value: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1740 else echo('<div class="info-box">Theme data updated.</div>'); |
1455 else echo('<div class="info-box">Theme data updated.</div>'); |
1741 } |
1456 } |
1742 elseif(isset($_POST['up'])) { |
1457 elseif(isset($_POST['up'])) { |
1743 // If there is only one theme or if the selected theme is already at the top, do nothing |
1458 // If there is only one theme or if the selected theme is already at the top, do nothing |
1744 $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; |
1459 $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; |
1745 $s = $db->sql_query($q); |
1460 $s = $db->sql_query($q); |
1746 if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1461 if(!$s) die('Error selecting order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1747 $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; |
1462 $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; |
1748 $sn = $db->sql_query($q); |
1463 $sn = $db->sql_query($q); |
1749 if(!$sn) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1464 if(!$sn) die('Error selecting order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1750 $r = $db->fetchrow_num($sn); |
1465 $r = $db->fetchrow_num($sn); |
1751 if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == 1 /* ...and check if this theme is already at the top */ ) { echo('<div class="warning-box">This theme is already at the top of the list, or there is only one theme installed.</div>'); } else { |
1466 if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == 1 /* ...and check if this theme is already at the top */ ) { echo('<div class="warning-box">This theme is already at the top of the list, or there is only one theme installed.</div>'); } else { |
1752 // Get the order IDs of the selected theme and the theme before it |
1467 // Get the order IDs of the selected theme and the theme before it |
1753 $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; |
1468 $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\'' . $db->escape($_POST['theme_id']) . '\''; |
1754 $s = $db->sql_query($q); |
1469 $s = $db->sql_query($q); |
1755 if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1470 if(!$s) die('Error selecting order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1756 $r = $db->fetchrow_num($s); |
1471 $r = $db->fetchrow_num($s); |
1757 $r = $r[0]; |
1472 $r = $r[0]; |
1758 $rb = $r - 1; |
1473 $rb = $r - 1; |
1759 // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) |
1474 // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) |
1760 $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1475 $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1761 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1476 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1762 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1477 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1763 echo('<div class="info-box">Theme moved up.</div>'); |
1478 echo('<div class="info-box">Theme moved up.</div>'); |
1764 } |
1479 } |
1765 $db->free_result($s); |
1480 $db->free_result($s); |
1766 $db->free_result($sn); |
1481 $db->free_result($sn); |
1767 } |
1482 } |
1768 elseif(isset($_POST['down'])) { |
1483 elseif(isset($_POST['down'])) { |
1769 // If there is only one theme or if the selected theme is already at the top, do nothing |
1484 // If there is only one theme or if the selected theme is already at the top, do nothing |
1770 $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; |
1485 $q = 'SELECT theme_order FROM '.table_prefix.'themes ORDER BY theme_order;'; |
1771 $s = $db->sql_query($q); |
1486 $s = $db->sql_query($q); |
1772 if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1487 if(!$s) die('Error selecting order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1773 $r = $db->fetchrow_num($s); |
1488 $r = $db->fetchrow_num($s); |
1774 if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == $db->numrows($s) /* ...and check if this theme is already at the bottom */ ) { echo('<div class="warning-box">This theme is already at the bottom of the list, or there is only one theme installed.</div>'); } else { |
1489 if( /* check for only one theme... */ $db->numrows($s) < 2 || $r[0] == $db->numrows($s) /* ...and check if this theme is already at the bottom */ ) { echo('<div class="warning-box">This theme is already at the bottom of the list, or there is only one theme installed.</div>'); } else { |
1775 // Get the order IDs of the selected theme and the theme before it |
1490 // Get the order IDs of the selected theme and the theme before it |
1776 $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; |
1491 $q = 'SELECT theme_order FROM '.table_prefix.'themes WHERE theme_id=\''.$db->escape($_POST['theme_id']).'\''; |
1777 $s = $db->sql_query($q); |
1492 $s = $db->sql_query($q); |
1778 if(!$s) die('Error selecting order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1493 if(!$s) die('Error selecting order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1779 $r = $db->fetchrow_num($s); |
1494 $r = $db->fetchrow_num($s); |
1780 $r = $r[0]; |
1495 $r = $r[0]; |
1781 $rb = $r + 1; |
1496 $rb = $r + 1; |
1782 // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) |
1497 // Thank God for jEdit's rectangular selection and the ablity to edit multiple lines at the same time ;) |
1783 $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1498 $q = 'UPDATE '.table_prefix.'themes SET theme_order=0 WHERE theme_order='.$rb.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1784 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1499 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$rb.' WHERE theme_order='.$r.''; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1785 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1500 $q = 'UPDATE '.table_prefix.'themes SET theme_order='.$r.' WHERE theme_order=0'; /* Check for errors... <sigh> */ $s = $db->sql_query($q); if(!$s) die('Error updating order information: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1786 echo('<div class="info-box">Theme moved down.</div>'); |
1501 echo('<div class="info-box">Theme moved down.</div>'); |
1787 } |
1502 } |
1788 } |
1503 } |
1789 else if(isset($_POST['uninstall'])) |
1504 else if(isset($_POST['uninstall'])) |
1790 { |
1505 { |
1791 $q = 'SELECT * FROM '.table_prefix.'themes;'; |
1506 $q = 'SELECT * FROM '.table_prefix.'themes;'; |
1792 $s = $db->sql_query($q); |
1507 $s = $db->sql_query($q); |
1793 if ( !$s ) |
1508 if ( !$s ) |
1794 { |
1509 { |
1795 die('Error getting theme count: '.mysql_error().'<br /><u>SQL:</u><br />'.$q); |
1510 die('Error getting theme count: '.$db->get_error().'<br /><u>SQL:</u><br />'.$q); |
1796 } |
1511 } |
1797 $n = $db->numrows($s); |
1512 $n = $db->numrows($s); |
1798 $db->free_result(); |
1513 $db->free_result(); |
1799 |
1514 |
1800 if ( $_POST['theme_id'] == 'oxygen' ) |
1515 if ( $_POST['theme_id'] == 'oxygen' ) |
2678 |
2394 |
2679 </table> |
2395 </table> |
2680 </div> |
2396 </div> |
2681 <?php |
2397 <?php |
2682 echo '</form>'; |
2398 echo '</form>'; |
2683 } |
|
2684 |
|
2685 function page_Admin_DBBackup() |
|
2686 { |
|
2687 global $db, $session, $paths, $template, $plugins; // Common objects |
|
2688 global $lang; |
|
2689 if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) |
|
2690 { |
|
2691 $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); |
|
2692 echo '<h3>' . $lang->get('adm_err_not_auth_title') . '</h3>'; |
|
2693 echo '<p>' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '</p>'; |
|
2694 return; |
|
2695 } |
|
2696 |
|
2697 if ( ENANO_DBLAYER != 'MYSQL' ) |
|
2698 die('<h3>Not supported</h3> |
|
2699 <p>This function is only supported under the MySQL database driver.</p>'); |
|
2700 |
|
2701 if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes' && defined('ENANO_DEMO_MODE') ) |
|
2702 { |
|
2703 redirect(makeUrlComplete('Special', 'Administration'), 'Access denied', 'You\'ve got to be kidding me. Forget it, kid.', 4 ); |
|
2704 } |
|
2705 |
|
2706 global $system_table_list; |
|
2707 if(isset($_GET['submitting']) && $_GET['submitting'] == 'yes') |
|
2708 { |
|
2709 |
|
2710 if(defined('SQL_BACKUP_CRYPT')) |
|
2711 // Try to increase our time limit |
|
2712 @set_time_limit(0); |
|
2713 // Do the actual export |
|
2714 $aesext = ( defined('SQL_BACKUP_CRYPT') ) ? '.tea' : ''; |
|
2715 $filename = 'enano_backup_' . date('ymd') . '.sql' . $aesext; |
|
2716 ob_start(); |
|
2717 // Spew some headers |
|
2718 $headdate = date('F d, Y \a\t h:i a'); |
|
2719 echo <<<HEADER |
|
2720 -- Enano CMS SQL backup |
|
2721 -- Generated on {$headdate} by {$session->username} |
|
2722 |
|
2723 HEADER; |
|
2724 // build the table list |
|
2725 $base = ( isset($_POST['do_system_tables']) ) ? $system_table_list : Array(); |
|
2726 $add = ( isset($_POST['additional_tables'])) ? $_POST['additional_tables'] : Array(); |
|
2727 $tables = array_merge($base, $add); |
|
2728 |
|
2729 // Log it! |
|
2730 $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'db_backup\', '.time().', \''.date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(implode(', ', $tables)) . '\')'); |
|
2731 if ( !$e ) |
|
2732 $db->_die(); |
|
2733 |
|
2734 foreach($tables as $i => $t) |
|
2735 { |
|
2736 if(!preg_match('#^([a-z0-9_]+)$#i', $t)) |
|
2737 die('Hacking attempt'); |
|
2738 // if($t == table_prefix.'files' && isset($_POST['do_data'])) |
|
2739 // unset($tables[$i]); |
|
2740 } |
|
2741 foreach($tables as $t) |
|
2742 { |
|
2743 // THE FOLLOWING COMMENT DOES NOT APPLY AS OF 1.0. |
|
2744 // Sorry folks - this script CAN'T backup enano_files and enano_search_index due to the sheer size of the tables. |
|
2745 // If encryption is enabled the log data will be excluded too. |
|
2746 $result = export_table( |
|
2747 $t, |
|
2748 isset($_POST['do_struct']), |
|
2749 ( isset($_POST['do_data']) ), |
|
2750 false |
|
2751 ) . "\n"; |
|
2752 if ( !$result ) |
|
2753 { |
|
2754 $db->_die(); |
|
2755 } |
|
2756 echo $result; |
|
2757 } |
|
2758 $data = ob_get_contents(); |
|
2759 ob_end_clean(); |
|
2760 if(defined('SQL_BACKUP_CRYPT')) |
|
2761 { |
|
2762 // Free some memory, we don't need this stuff any more |
|
2763 $db->close(); |
|
2764 unset($paths, $db, $template, $plugins); |
|
2765 $tea = new TEACrypt(); |
|
2766 $data = $tea->encrypt($data, $session->private_key); |
|
2767 } |
|
2768 header('Content-disposition: attachment, filename="'.$filename.'";'); |
|
2769 header('Content-type: application/transact-sql'); |
|
2770 header('Content-length: '.strlen($data)); |
|
2771 echo $data; |
|
2772 exit; |
|
2773 } |
|
2774 else |
|
2775 { |
|
2776 // Show the UI |
|
2777 echo '<form action="'.makeUrlNS('Admin', 'DBBackup', 'submitting=yes', true).'" method="post" enctype="multipart/form-data">'; |
|
2778 ?> |
|
2779 <p>This page allows you to back up your Enano database should something go miserably wrong.</p> |
|
2780 <p><label><input type="checkbox" name="do_system_tables" checked="checked" /> Export tables that are part of the Enano core</label><p> |
|
2781 <p>Additional tables to export:</p> |
|
2782 <p><select name="additional_tables[]" multiple="multiple"> |
|
2783 <?php |
|
2784 if ( ENANO_DBLAYER == 'MYSQL' ) |
|
2785 { |
|
2786 $q = $db->sql_query('SHOW TABLES;') or $db->_die('Somehow we were denied the request to get the list of tables.'); |
|
2787 } |
|
2788 else if ( ENANO_DBLAYER == 'PGSQL' ) |
|
2789 { |
|
2790 $q = $db->sql_query('SELECT relname FROM pg_stat_user_tables ORDER BY relname;') or $db->_die('Somehow we were denied the request to get the list of tables.'); |
|
2791 } |
|
2792 while($row = $db->fetchrow_num()) |
|
2793 { |
|
2794 if(!in_array($row[0], $system_table_list)) echo '<option value="'.$row[0].'">'.$row[0].'</option>'; |
|
2795 } |
|
2796 ?> |
|
2797 </select> |
|
2798 </p> |
|
2799 <p><label><input type="checkbox" name="do_struct" checked="checked" /> Include table structure</label><br /> |
|
2800 <label><input type="checkbox" name="do_data" checked="checked" /> Include table data</label> |
|
2801 </p> |
|
2802 <p><input type="submit" value="Create backup" /></p> |
|
2803 <?php |
|
2804 echo '</form>'; |
|
2805 } |
|
2806 } |
2399 } |
2807 |
2400 |
2808 function page_Admin_AdminLogout() |
2401 function page_Admin_AdminLogout() |
2809 { |
2402 { |
2810 global $db, $session, $paths, $template, $plugins; // Common objects |
2403 global $db, $session, $paths, $template, $plugins; // Common objects |