Changeset 1546
- Timestamp:
- 08/24/06 20:51:31 (2 years ago)
- Location:
- trunk/gregarius
- Files:
-
- 4 modified
-
admin/channels.php (modified) (1 diff)
-
admin/opml.php (modified) (2 diffs)
-
ajax.php (modified) (1 diff)
-
schema.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/gregarius/admin/channels.php
r1542 r1546 741 741 break; 742 742 743 743 case 'dump': 744 // Make sure this is a POST 745 if(!isset($_POST['dumpact'])) { 746 die('Sorry, you can\'t access this via a GET'); 747 } 748 $tbl = array('"','"'); 749 error_reporting(E_ALL); 750 rss_require('schema.php'); 751 $tables=getExpectedTables(); 752 unset($tables['cache']); 753 //$tables=array('channels','tag','config'); 754 $bfr=''; 755 $bfr .= '<'.'?xml version="1.0" encoding="UTF-8"?'.'>'."\n"; 756 $bfr .= '<dump prefix="'.getTable('').'" date="'.date('r').'">'."\n"; 757 foreach($tables as $table => $prefixed) { 758 $rs = rss_query("select * from $prefixed"); 759 $bfr .="<$table>\n"; 760 while($row=rss_fetch_assoc($rs)) { 761 $r="<row "; 762 foreach($row as $key => $val) { 763 $val=htmlspecialchars($val); 764 $r.=" $key=\"$val\" "; 765 } 766 $r .= "/>\n"; 767 $bfr .=$r; 768 } 769 $bfr .="</$table>\n"; 770 } 771 $bfr .='</dump>'."\n"; 772 $gzdata = gzencode($bfr, 9); 773 $tempfname=tempnam("/tmp", "rss.dump").'.xml.gz'; 774 $df=fopen($tempfname,'w'); 775 fwrite($df, $gzdata); 776 fclose($df); 777 die($tempfname); 778 break; 744 779 default: 745 780 break; -
trunk/gregarius/admin/opml.php
r1528 r1546 91 91 // export 92 92 opml_export_form(); 93 93 dump_export_form(); 94 94 echo "</div>\n"; 95 95 } … … 113 113 } 114 114 115 116 /***** DUMP ******/ 117 118 function dump_export_form() { 119 120 echo "<fieldset style=\"vertical-align:top\">\n<legend>".__('XML Dump:')."</legend>\n"; 121 echo "<form method=\"post\" action=\"".$_SERVER['PHP_SELF']."\">\n" 122 ."<p><label for=\"action\">". __('Dump your Gregarius installation to XML'). "</label>\n" 123 ."<input type=\"submit\" name=\"dumpact\" id=\"action\" value=\"".__('Dump!')."\" />" 124 ."<input type=\"hidden\" name=\"". CST_ADMIN_DOMAIN ."\" value=\"".CST_ADMIN_DOMAIN_CHANNEL."\"/>\n" 125 ."<input type=\"hidden\" name=\"".CST_ADMIN_METAACTION."\" value=\"dump\"/>\n" 126 ."</p>\n</form>\n" 127 ."</fieldset>\n"; 128 } 129 115 130 ?> -
trunk/gregarius/ajax.php
r1525 r1546 215 215 toggle.innerHTML="<?php echo LBL_TAG_SUBMITTING ?>"; 216 216 submit_tag(id,fld.value); 217 } else if (toggle.innerHTML == "<?php echo LBL_TAG_EDIT ?>") {217 } else if (toggle.innerHTML == "<?php echo LBL_TAG_EDIT ?>") { 218 218 var isIE=document.all?true:false; 219 219 // the tag container -
trunk/gregarius/schema.php
r1520 r1546 38 38 $missing_tables = array(); 39 39 $actual_tables=array(); 40 $expected_tables = array ( 40 $expected_tables = getExpectedTables(); 41 42 $rs = rss_query( "show tables", true, true ); 43 while(list($tbl) = rss_fetch_row($rs)) { 44 $actual_tables[]=$tbl; 45 } 46 47 foreach ($expected_tables as $base => $tbl) { 48 $exists = array_search($tbl,$actual_tables); 49 if ($exists === FALSE || $exists === NULL) { 50 $missing_tables[]=$base; 51 } 52 } 53 54 $updated = 0; 55 if (count($missing_tables) > 0) { 56 $msg = (count($actual_tables)?"Updating":"Creating") 57 .' your database schema! This should be a one-time operation,' 58 .' if you see this message over and over again please import your database schema' 59 .' manually.'; 60 rss_error($msg, RSS_ERROR_WARNING); 61 62 foreach($missing_tables as $table) { 63 $updated += call_user_func("_init_$table"); 64 } 65 66 if ($updated == count($missing_tables)) { 67 rss_error("Successfully created $updated of $updated database tables!", RSS_ERROR_NOTICE); 68 } else { 69 rss_error( 70 (count($missing_tables) - $updated) . " out of " 71 . count($missing_tables) ." tables could not be created!",RSS_ERROR_ERROR); 72 } 73 } 74 75 if ($updated) { 76 rss_invalidate_cache(); 77 } 78 return $updated; 79 } 80 81 function getExpectedTables() { 82 $expected_tables = array ( 41 83 "channels" => trim(getTable("channels")), 42 84 "config" => trim(getTable("config")), … … 52 94 53 95 ); 54 55 $rs = rss_query( "show tables", true, true ); 56 while(list($tbl) = rss_fetch_row($rs)) { 57 $actual_tables[]=$tbl; 58 } 59 60 foreach ($expected_tables as $base => $tbl) { 61 $exists = array_search($tbl,$actual_tables); 62 if ($exists === FALSE || $exists === NULL) { 63 $missing_tables[]=$base; 64 } 65 } 66 67 $updated = 0; 68 if (count($missing_tables) > 0) { 69 $msg = (count($actual_tables)?"Updating":"Creating") 70 .' your database schema! This should be a one-time operation,' 71 .' if you see this message over and over again please import your database schema' 72 .' manually.'; 73 rss_error($msg, RSS_ERROR_WARNING); 74 75 foreach($missing_tables as $table) { 76 $updated += call_user_func("_init_$table"); 77 } 78 79 if ($updated == count($missing_tables)) { 80 rss_error("Successfully created $updated of $updated database tables!", RSS_ERROR_NOTICE); 81 } else { 82 rss_error( 83 (count($missing_tables) - $updated) . " out of " 84 . count($missing_tables) ." tables could not be created!",RSS_ERROR_ERROR); 85 } 86 } 87 88 if ($updated) { 89 rss_invalidate_cache(); 90 } 91 return $updated; 92 } 93 96 return $expected_tables; 97 } 94 98 function rss_query_wrapper($query, $dieOnError=true, $preventRecursion=false) { 95 99 global $out;
