OSDN Git Service

tag: sqlite0904
authorkmorimatsu <kmorimatsu@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 17 Mar 2009 02:05:38 +0000 (02:05 +0000)
committerkmorimatsu <kmorimatsu@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 17 Mar 2009 02:05:38 +0000 (02:05 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@981 1ca29b6e-896d-4ea0-84a5-967f57386b96

18 files changed:
sqlite/tags/sqlite0904/extra/sqlite/installsqlite.php [new file with mode: 0644]
sqlite/tags/sqlite0904/extra/sqlite/readme-ja.txt [new file with mode: 0644]
sqlite/tags/sqlite0904/license.txt [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/plugins/NP_SQLite.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/plugins/sqlite/index.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/plugins/sqlite/language/japanese-euc.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/plugins/sqlite/language/japanese-utf8.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/plugins/sqlite/restore.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/.htaccess [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/convert.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/index.html [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/note.txt [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/sqlite.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/sqlitealtertable.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/sqliteconfig.php [new file with mode: 0644]
sqlite/tags/sqlite0904/nucleus/sqlite/sqlitequeryfunctions.php [new file with mode: 0644]
sqlite/tags/sqlite0904/readme-en.txt [new file with mode: 0644]
sqlite/tags/sqlite0904/readme-ja.txt [new file with mode: 0644]

diff --git a/sqlite/tags/sqlite0904/extra/sqlite/installsqlite.php b/sqlite/tags/sqlite0904/extra/sqlite/installsqlite.php
new file mode 100644 (file)
index 0000000..f0c4c9d
--- /dev/null
@@ -0,0 +1,86 @@
+<?php
+/*******************************************
+* mysql_xxx => nucleus_mysql_xxx converter *
+*                              for Nucleus *
+*     ver 0.6.1b  Written by Katsumi       *
+*******************************************/
+
+// The license of this script is GPL
+
+// Check lanuage
+if (strpos(strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']),'ja')===0) {
+       $charset='EUC-JP';
+} else {
+       $charset='iso-8859-1';
+}
+header("Content-Type: text/html; charset=$charset");
+
+if (!file_exists('./nucleus/sqlite/convert.php')) exit;
+include('./nucleus/sqlite/convert.php');
+
+?><html><body><?php 
+
+$myself='installsqlite.php';
+if ((@$_GET['go'])!='yes') {
+
+       if ($charset=='EUC-JP') {
+               ?>¤³¤Î¥Ú¡¼¥¸¤Ç¤Ï¡¢SQLite ¤Ç»ÈÍѤ¹¤ë¤¿¤á¤Î Nucleus ¤Î³Æ¥Õ¥¡¥¤¥ë¤ÎÊѹ¹¤ò¹Ô¤¤¤Þ¤¹¡£<br /><br />
+               ¤¹¤Ù¤Æ¤Î &quot;mysql_xxx&quot; ´Ø¿ô¸Æ¤Ó½Ð¤·¤Îɽµ­¤¬ &quot;nucleus_mysql_xxx&quot;¤ËÊѹ¹¤µ¤ì¤Þ¤¹.<br /><br />
+               <?php if (!function_exists('mysql_query')) {?>
+                       ¤³¤ÎÊѹ¹¤Ï¡¢MySQL ´Ø¿ô¤¬ PHP ¤Ë¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢É¬¿Ü¤Ç¤Ï¤¢¤ê¤Þ¤»¤ó¡£<br />
+                       ¤³¤Î¾ì¹ç &quot;install.php&quot; ¤È &quot;config.php&quot; ¤À¤±¤ËÊѹ¹¤¬É¬ÍפǤ¹¡£<br />
+                       ¤â¤·MySQL ´Ø¿ô¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤ª¤é¤º¡¢¾­ÍèŪ¤Ë¤â¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Ê¤¤¤³¤È¤¬³Î¼Â¤Ê¾ì¹ç¡¢<br />
+                       <a href="?go=yes&amp;modify=no">¤³¤³¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤</a>(install.php ¤È config.php ¤¬Êѹ¹¤µ¤ì¤Þ¤¹)¡£<br /><br />
+                       ¤½¤¦¤Ç¤Ê¤±¤ì¤Ð¡¢²¼¤Î¥ê¥ó¥¯¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£<br /><br />
+               <?php } ?>
+               <a href="?go=yes&amp;modify=yes">Êѹ¹¤ò³«»Ï</a>(¤³¤Î¥Ç¥£¥ì¥¯¥È¥ê¤Î¤¹¤Ù¤Æ¤Î PHP ¥Õ¥¡¥¤¥ë¤¬Êѹ¹¤µ¤ì¤Þ¤¹)¡£<br /><br />
+               »Ï¤á¤ëÁ°¤Ë¡¢Êѹ¹¤µ¤ì¤ë¤Ù¤­ PHP ¥Õ¥¡¥¤¥ë¤Î¥Ñ¡¼¥ß¥Ã¥·¥ç¥ó¤¬¡¢Æɤ߽ñ¤­²Äǽ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤³¤È¤ò³Îǧ¤·¤Æ¤¯¤À¤µ¤¤¡£
+               </body></html><?php
+       } else {
+               ?>This page is to modify Nucleus core files for using SQLite as database engine.<br /><br />
+               All the &quot;mysql_xxx&quot; functions will be converted to &quot;nucleus_mysql_xxx&quot;.<br /><br />
+               <?php if (!function_exists('mysql_query')) {?>
+                       This modification is not required if MySQL functions of PHP are not installed in the server.<br />
+                       In this case, only the &quot;install.php&quot; and &quot;config.php&quot; must be modified.<br />
+                       If you are sure that the MySQL function is never (now and in future) installed, <br />
+                       <a href="?go=yes&amp;modify=no">please click here</a>(install.php and config.php will be changed).<br /><br />
+                       Otherwise, please click following link.<br /><br />
+               <?php } ?>
+               <a href="?go=yes&amp;modify=yes">Start modification</a>(all the PHP files in this directory will be changed).<br /><br />
+               Please make sure that all PHP files to be modified are readable and writable.
+               </body></html><?php
+       }
+       exit;
+}
+
+if ((@$_GET['modify'])=='yes') {
+       // Obtain all PHP files in current and child directories.
+       $phpfiles=array();
+       seekPhpFiles('./',$phpfiles,$myself);
+       
+       // Modify all PHP files; mysql_xxxx is replaced by nucleus_mysql_XXXX.
+       $allok=true;
+       foreach ($phpfiles as $file) $allok=$allok && changeFunctions($file);
+       if (!$allok) ExitWithError();
+}
+
+// Modify config.php, install.php and backup.php
+modifyConfigInstall();
+
+if ($charset=='EUC-JP') {
+       ?>¤¹¤Ù¤Æ¤ÎÊѹ¹¤¬½ªÎ»¤·¤Þ¤·¤¿¡£<hr />
+       <a href="install.php">¤³¤³¤ò¥¯¥ê¥Ã¥¯¤·¤Æ Nucleus w/SQLite ¤Î¥¤¥ó¥¹¥È¡¼¥ë¤ò³«»Ï¤·¤Æ¤¯¤À¤µ¤¤¡£</a><br />
+       <?php
+} else {
+       ?>All modificatios are sccesfully done.<hr />
+       <a href="install.php">Click here to install Nucleus w/SQLite</a><br />
+       <?php
+}
+if (@rename('installsqlite.php','installsqlite.php~')) {
+       if ($charset=='EUC-JP') {
+               echo '(&quot;installsqlite.php&quot; ¤Ï &quot;installsqlite.php~&quot; ¤Ë¥Õ¥¡¥¤¥ë̾¤¬Êѹ¹¤µ¤ì¤Æ¤¤¤Þ¤¹¡£)';
+       } else {
+               echo '(&quot;installsqlite.php&quot; has been renamed to &quot;installsqlite.php~&quot;.)';
+       }
+}
+?></body></html>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/extra/sqlite/readme-ja.txt b/sqlite/tags/sqlite0904/extra/sqlite/readme-ja.txt
new file mode 100644 (file)
index 0000000..a955bb4
--- /dev/null
@@ -0,0 +1,45 @@
+\81@\82±\82Ì\83m\81[\83g\82Å\82Í\81ANucleus \82Ì\90V\82µ\82¢\83o\81[\83W\83\87\83\93\82ª\8cö\8aJ\82³\82ê
+\82½\8dÛ\82É\81ASQLite \94Å\82ð\90»\8dì\82·\82é\95û\96@\82É\82Â\82¢\82Ä\8fq\82×\82Ü\82·\81B
+
+
+\81\96\81\96\81\96\81\96\81\96\81@installsqlite.php \82É\82Â\82¢\82Ä\81B\81@\81\96\81\96\81\96\81\96\81\96
+
+\81@\8eå\82È\8eg\97p\96Ú\93I\82Í\81ANucleus \82Ì\83o\81[\83W\83\87\83\93\83A\83b\83v\82ª\82 \82Á\82½\8dÛ
+\82É\81ASQLite \91Î\89\9e\82É\82·\82é\82½\82ß\82É\83R\83A\83t\83@\83C\83\8b\82ð\8f\91\82«\8a·\82¦\82é\82±
+\82Æ\82Å\82·\81B\83R\83A\82Ì PHP \83t\83@\83C\83\8b\82Ì mysql_xxxx() \82ª\82·\82×\82Ä\81A
+nucleus_mysql_xxxx() \82É\8f\91\82«\8a·\82¦\82ç\82ê\82Ü\82·\81B\8eg\97p\82·\82é\8dÛ\82Í\81A
+\82±\82Ì\83t\83@\83C\83\8b\82ð Nucleus \82Ì\83\8b\81[\83g\83f\83B\83\8c\83N\83g\83\8a(config.php
+\82Ì\82 \82é\8fê\8f\8a)\82É\88Ú\93®\82µ\81A\83u\83\89\83E\83U\82Å\83A\83N\83Z\83X\82µ\82Ä\82­\82¾\82³\82¢\81B
+
+\81@\89Á\82¦\82Ä\81Ainstall.php \8by\82Ñ\81Aconfig.php \82É\81A
+\81winclude($DIR_NUCLEUS.'sqlite/sqlite.php');\81x\82ª\8e©\93®\93I\82É
+\8f\91\82«\91«\82³\82ê\82Ü\82·\81B
+
+\81@backup.php \82Í\81ASQLite \82Å\82Ì\83f\81[\83^\83\8a\83X\83g\83A\82ª\8dÅ\93K\89»\82³\82ê
+\82é\82æ\82¤\82É\81A\95Ï\8dX\82³\82ê\82Ü\82·\81isqlite_restore_execute_queries()
+\82ª\8eg\97p\82³\82ê\82é\82æ\82¤\82É\82È\82è\82Ü\82·\81j\81B
+
+\81@\82³\82ç\82É\81Ainstall.php \82Å\82Ì\83C\83\93\83X\83g\81[\83\8b\89æ\96Ê\82ÌHTML\82ª\8eá\8a±
+\8fC\90³\82³\82ê\81A\88ê\95\94\82ÌMySQL\93Á\88Ù\93I\82È\83I\83v\83V\83\87\83\93\82É\81wdummy\81x\82ª\8ew
+\92è\82³\82ê\82é\82æ\82¤\82É\95Ï\8dX\82³\82ê\82Ü\82·\81B
+
+\81@install.sql \82Ì nucleus_plugin_option \83e\81[\83u\83\8b\8dì\90¬\95\94\95ª\82Ì
+\83N\83G\83\8a\81[\95\82ª\88È\89º\82Ì\82æ\82¤\82É\95Ï\8dX\82³\82ê\82Ü\82·\81iauto_increment\82ª\8dí\8f\9c
+\82³\82ê\82Ü\82·\81j\81B
+
+CREATE TABLE `nucleus_plugin_option` (
+  `ovalue` text NOT NULL,
+  `oid` int(11) NOT NULL,
+  `ocontextid` int(11) NOT NULL default '0',
+  PRIMARY KEY  (`oid`,`ocontextid`)
+) TYPE=MyISAM;
+
+
+\81\96\81\96\81\96\81\96\81\96\81@\8eè\93®\82Å\95Ï\8dX\82µ\82È\82¢\82Æ\82¢\82¯\82È\82¢\8e\96\8d\80\81@\81\96\81\96\81\96\81\96\81\96
+
+\81@installsqlite.php \82Ì\8eÀ\8ds\82Å\95K\97v\82È\95Ï\8dX\82Ì\82¤\82¿\8fd\97v\82È\95¨\82É
+\82Â\82¢\82Ä\82Í\96w\82Ç\8ds\82í\82ê\82Ü\82·\82ª\81A\88ê\95\94\8eè\93®\82Å\95Ï\8dX\82µ\82È\82¯\82ê\82Î\82È\82ç
+\82È\82¢\95\94\95ª\82ª\82 \82é\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B
+
+\81@SQLite wrapper 0.81 \82Å\82Í\81ANucleus 3.2x\82ÆNucleus3.3\82ð
+\95Ï\8dX\82·\82é\8fã\82Å\81A\8eè\93®\82Å\82Ì\95Ï\8dX\82Í\95K\97v\82 \82è\82Ü\82¹\82ñ\81B
diff --git a/sqlite/tags/sqlite0904/license.txt b/sqlite/tags/sqlite0904/license.txt
new file mode 100644 (file)
index 0000000..dcfa4c2
--- /dev/null
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/sqlite/tags/sqlite0904/nucleus/plugins/NP_SQLite.php b/sqlite/tags/sqlite0904/nucleus/plugins/NP_SQLite.php
new file mode 100644 (file)
index 0000000..8eea475
--- /dev/null
@@ -0,0 +1,185 @@
+<?php 
+   /***********************************
+   * NP_SQLite plugin  ver 0.8.0      *
+   *                                  *
+   * This plugin modifies the plugins *
+   *     when these are installed.    *
+   *                                  *
+   * Written by Katsumi               *
+   ***********************************/
+//  The licence of this script is GPL
+class NP_SQLite extends NucleusPlugin { 
+       function getName() { return 'NP_SQLite'; }
+       function getMinNucleusVersion() { return 320; }
+       function getAuthor()  { $this->install(); return 'Katsumi'; }
+       function getVersion() { global $SQLITECONF; return $SQLITECONF['VERSION']; }
+       function getURL() {return 'http://hp.vector.co.jp/authors/VA016157/';}
+       function getDescription() { return $this->showinfo(); } 
+       function supportsFeature($what) { return (int)($what=='SqlTablePrefix'); }
+       function getEventList() { return array('PreAddPlugin','PreSkinParse','QuickMenu'); }
+       function hasAdminArea() { return 1; }
+
+       function install(){
+               if (!$this->getOption('allowsql')) {
+                       $this->createOption('allowsql',$this->translated('Allow SQL query during the management?'),'yesno','no');
+               }
+               if (!$this->getOption('numatonce')) {
+                       $this->createOption('numatonce',$this->translated('Number of SQL queries at once when DB restore.'),'text','20','datatype=numerical'); 
+                       $this->createOption('refreshwait',$this->translated('Wating tile (seconds) when DB restore.'),'text','1','datatype=numerical');
+               }
+       }
+       
+       var $infostr;
+       function showinfo() {
+               global $SQLITECONF;
+               if ($this->infostr) echo "<b>".$this->infostr."</b><hr />\n";
+               return $this->translated('NP_SQLite plugin. Filesize of DB is now ').filesize($SQLITECONF['DBFILENAME']).' bytes.';
+       }
+
+       function init(){
+       }
+
+       function event_QuickMenu(&$data){
+               global $member;
+               $this->_showDebugMessage();
+
+               // only show to admins
+               if (!($member->isLoggedIn() && $member->isAdmin())) return;
+
+               array_push($data['options'], array(
+                               'title' => 'SQLite',
+                               'url' => $this->getAdminURL(),
+                               'tooltip' => $this->translated('SQLite management')
+                       ) );
+       }
+       function event_PreSkinParse(&$data){
+               $this->_showDebugMessage();
+       }
+       function _showDebugMessage(){
+               global $SQLITECONF;
+               if (isset($SQLITECONF['DEBUGMESSAGE'])) sqlite_DebugMessage();
+               unset($SQLITECONF['DEBUGMESSAGE']);
+       }
+
+       function event_PreAddPlugin(&$data){
+               // This event happens before loading "NP_XXXX.php" file.
+               // Therefore, modification is possible here.
+               $this->modify_plugin($data['file'],true);
+       }
+       function modify_plugin($pluginfile,$install=false){
+               global $DIR_PLUGINS,$SQLITECONF;
+               if ($SQLITECONF['OVERRIDEMODE']) return true;
+
+               $admindir=$DIR_PLUGINS.strtolower(substr($pluginfile,3));
+               $pluginfile=$DIR_PLUGINS.$pluginfile;
+               
+               // List up all PHP files.
+               $phpfiles=array();
+               array_push($phpfiles,$pluginfile.'.php');
+               $this->seekPhpFiles($admindir,$phpfiles);
+               
+               // Modify the PHP files.
+               $allok=true;
+               foreach ($phpfiles as $file) {
+                       if (!$this->changeFunctions($file)) {
+                               $allok=false;
+                       }
+               }
+               if ($allok) {
+                       if ($install) $this->infostr=$this->translated('Pluing was installed sucessfully');
+                       return true;
+               }
+               
+               if (!$install) return false;
+               if ($this->is_japanese()) {
+                       echo '<html><head><meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" /></head>';
+                       echo '<body><h3>PHP ¥Õ¥¡¥¤¥ë¤ò¼êÆ°¤ÇÊѹ¹¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£</h3>';
+               } else echo '<html><body><h3>Need to modify PHP file(s) manually.</h3>';
+               foreach ($phpfiles as $file) echo $this->show_Lines($file);
+               exit ('</body></html>');
+       }
+
+       function seekPhpFiles($dir,&$phpfiles){
+               if (!is_dir($dir)) return;
+               $d = dir($dir);
+               $dirpath=realpath($d->path);
+               $dirs=array();
+               if (substr($dirpath,-1)!='/' && substr($dirpath,-1)!="\\") $dirpath.='/';
+               while (false !== ($entry = $d->read())) {
+                       if ($entry=='.' || $entry=='..') continue;
+                       if (is_file($dirpath.$entry) && substr($entry,-4)=='.php') array_push($phpfiles,realpath($dirpath.$entry));
+                       if (is_dir($dirpath.$entry))  array_push($dirs,realpath($dirpath.$entry));
+               }
+               $d->close();
+               foreach($dirs as $dir) $this->seekPhpFiles($dir,$phpfiles);
+       }
+       function changeFunctions($file){
+               if (!is_file($file=realpath($file))) return false;
+               if (!is_readable($file)) return false;
+               $before=$this->read_from_file($file);
+               // Do this process until change does not occur.. 
+               // Otherwise, sometime file is not completely modified.
+               $after=$this->do_replace($before);
+               if ($before!=$after) return $this->write_to_file($file,$after);
+               return true;
+       }
+       function do_replace(&$text) {
+               // Do this process until change does not occur.. 
+               // Otherwise, sometime file is not completely modified.
+               $after=$text;
+               do $after=preg_replace('/([^_])mysql_([_a-z]+)([\s]*?)\(/','$1nucleus_mysql_$2(',($before=$after));
+               while ($before!=$after);
+               return $after;
+       }
+       function show_Lines($file){
+               if (!is_file($file=realpath($file))) return '';
+               if (!is_readable($file)) return '';
+               $result='';
+               $lines=file($file);
+               $firsttime=true;
+               foreach($lines as $num=>$before) {
+                       $after=$this->do_replace($before);
+                       if ($after!=$before) {
+                               if ($firsttime) $result.="<hr />\nFile: <b>$file</b><br /><br />\n";
+                               $firsttime=false;
+                               $result.="Modify line <b>".($num+1)."</b> like: &quot;\n";
+                               $result.=str_replace('nucleus_mysql_','<font color="#ff0000">nucleus_</font>mysql_',htmlspecialchars($after))."&quot;<br /><br />\n";
+                       }
+               }
+               return $result;
+       }
+       function read_from_file($file) {
+               if (function_exists('file_get_contents') ) $ret=file_get_contents($file);
+               else {
+                       ob_start();
+                       readfile($file);
+                       $ret=ob_get_contents();
+                       ob_end_clean();
+               }
+               return $ret;
+       }
+       function write_to_file($file,&$text){
+               if (!$handle = @fopen($file, 'w')) return false;
+               fwrite($handle,$text);
+               fclose($handle);
+               return true;
+       }
+       function is_japanese(){
+               $language = str_replace( array('\\','/'), array('',''), getLanguageName());
+               return (strpos($language,'japanese')===0);
+       }
+
+       // Language stuff
+       var $langArray;
+       function translated($english){
+               if (!is_array($this->langArray)) {
+                       $this->langArray=array();
+                       $language=$this->getDirectory().'language/'.str_replace( array('\\','/'), array('',''), getLanguageName()).'.php';
+                       if (file_exists($language)) include($language);
+               }
+               if (!($ret=$this->langArray[$english])) $ret=$english;
+               return $ret;
+       }
+
+}
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/index.php b/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/index.php
new file mode 100644 (file)
index 0000000..a44f5b0
--- /dev/null
@@ -0,0 +1,241 @@
+<?php
+    /*****************************
+    * SQLite database tool       *
+    *                 ver 0.8.0  *
+    * Written by Katsumi         *
+    *****************************/
+    
+// This library is GPL.
+
+       include('../../../config.php');
+       
+       include($DIR_LIBS . 'PLUGINADMIN.php');
+
+       // create the admin area page
+       $pa = new PluginAdmin('SQLite');
+       $pa->start();
+       $p=&$pa->plugin;
+       $pluginUrl=$p->getAdminURL();
+
+
+       // check if superadmin is logged in
+       if (!($member->isLoggedIn() && $member->isAdmin()))
+       {
+               echo '<p>' . _ERROR_DISALLOWED . '</p>';
+               $pa->end();
+               exit;
+       }
+
+       // Check ticket
+       if (requestVar('SQLiteCommand') && (!$manager->checkTicket())){
+               echo '<p>' . _ERROR_BADTICKET . '</p>';
+               $pa->end();
+               exit;
+       }
+       $ticket=$manager->addTicketToUrl('');
+       $ticket=substr($ticket,strpos($ticket,'ticket=')+7);
+
+?><script type="text/javascript">
+//<![CDATA[
+function $(id) {
+  return document.getElementById(id);
+}
+//]]>
+</script><?php
+
+       $idnum=0;
+       echo '<h2>'.$p->translated('SQLite management')."</h2>\n";
+       
+       $infostr='';
+       switch(requestVar('SQLiteCommand')){
+       case 'VACUUM':
+               nucleus_mysql_query('VACUUM');
+               $infostr='VACUUM was done.';
+               break;
+       case 'integrity_check':
+               $res=nucleus_mysql_query('PRAGMA integrity_check');
+               $infostr='Integrity check result:'."<br />\n";
+               while ($a=nucleus_mysql_fetch_array($res)) $infostr.=$a[0]."<br />\n";
+               break;
+       case 'plugin_check':
+               $pluginfile=requestVar('plugin');
+               $query='SELECT COUNT(*) as result FROM `'.sql_table('plugin').'` WHERE pfile="'.addslashes($pluginfile).'"';
+               if (!quickQuery($query)) {
+                       $infostr="No such plugin!";
+                       break;
+               }
+               if ($p->modify_plugin($pluginfile)) {
+                       $infostr=$p->translated('The plugin, ').$pluginfile.$p->translated(' was checked and modified (if modification required)');
+                       break;
+               }
+
+               // Modification failed.  Show the lines that must be modified
+               $phpfiles=array();
+               array_push($phpfiles,$DIR_PLUGINS.$pluginfile.'.php');
+               $admindir=$DIR_PLUGINS.strtolower(substr($pluginfile,3));
+               $p->seekPhpFiles($admindir,$phpfiles);
+               $infostr=$p->translated('Please modify the PHP files').": <br />\n";
+               foreach ($phpfiles as $file) $infostr.=$p->show_Lines($file);
+               break;
+       case "QUERY":
+               $infostr='<table><tr><th>'.'Query'.
+'&nbsp;&nbsp;&nbsp;&nbsp;(-&gt;<a href="javascript:Copy this query" onclick="
+var t=$(\'QueryShown\').innerHTML+\'\';
+$(\'ExecQuery\').value=t.replace(/^\s+|\s+$/g,\'\');
+return false;
+">Copy</a>)'.
+               "</th></td><tr><td id=\"QueryShown\">\n".htmlspecialchars($query=requestVar('query'))."</td></tr></table><br />\n";
+               if (requestVar('confirm')!='confirmed'){
+                       $infostr=$p->translated('Please check the "I am sure." checkbox to execute query').$infostr;
+                       break;
+               }
+               ob_start();
+               $res=nucleus_mysql_query($query);
+               $errorstr=ob_get_contents();
+               ob_end_clean();
+               if (!$res) {
+                       $infostr.=nucleus_mysql_error()."<br />\n";
+                       if (preg_match('/sqlite_query\(\):([^<]*)in <b>/i',$errorstr,$matches)) $infostr.=$matches[1];
+                       break;
+               }
+               if (preg_match('/ OFFSET ([0-9]+)$/i',$query,$matches)) $offset=$matches[1];
+               else $offset=0;
+               
+               // Get resut into an array
+               $resulttable=array();
+               $columnname=array();
+               $columnnum=0;
+               while ($a=nucleus_mysql_fetch_array($res,SQLITE_ASSOC)) {
+                       if ($columnnum<count($a)) {
+                               $i=0;
+                               foreach ($a as $key=>$value) $columnname[$i++]=$key;
+                               $columnnum=count($a);
+                       }
+                       $templine=array();
+                       foreach ($a as $key=>$value) $templine[$key]=$value;
+                       array_push($resulttable,$templine);
+               }
+               
+               // Create table HTML from the array
+               $infostr.="<table><tr>";
+               for ($i=0;$i<$columnnum;$i++) $infostr.="<th>".$columnname[$i]."</th>";
+               $infostr.="</tr>\n";
+               foreach ($resulttable as $templine) {
+                       $infostr.="<tr>";
+                       for ($i=0;$i<$columnnum;$i++) {
+                               $value=(string)$templine[$columnname[$i]];
+                               if (50<strlen($value)) {
+                                       $value='<span id="sqliteobj'.$idnum.'"><a href="" title="'.'Click this to show all'.'" onclick="'.
+                                               '$(\'sqliteobj'.$idnum.'\').innerHTML='.
+                                               '$(\'sqliteobj'.$idnum.'-2\').innerHTML;'.
+                                               'return false;">'.htmlspecialchars(substr($value,0,50)).".....</a></span>\n".
+                                               '<span style="DISPLAY:none;" id="sqliteobj'.$idnum.'-2">'.htmlspecialchars($value)."</span>\n";
+                                       $idnum++;
+                               } else $value=htmlspecialchars($value);
+                               switch(requestVar('option')){
+                               case 'showalltables':
+                                       if ($columnname[$i]!='name') break;
+                                       $query="SELECT * FROM '$value' LIMIT 10";
+                                       $value='<a href="'.htmlspecialchars($pluginUrl).
+                                               '?SQLiteCommand=QUERY&confirm=confirmed&option=showtable&ticket='.$ticket.
+                                               '&query='.htmlspecialchars($query).'">'.
+                                               $value.'</a>';
+                                       break;
+                               default:
+                               }
+                               $value=preg_replace('/\\n$/','',$value);
+                               $value=str_replace("\n","<br />\n",$value);
+                               $infostr.="<td>".$value."</td>";
+                       }
+                       $infostr.="</tr>\n";
+                       $offset++;
+               }
+               $infostr.="</table>\n";
+               switch(requestVar('option')){
+               case 'showtable':
+                       $query=requestVar('query');
+                       $offset=(int)$offset;
+                       $query=preg_replace('/ OFFSET ([0-9]+)$/i','',$query)." OFFSET $offset";
+                       $res=nucleus_mysql_query($query);
+                       if (!nucleus_mysql_fetch_array($res)) break;
+                       $infostr.='
+<form method="POST" action="'.htmlspecialchars($pluginUrl).'">
+<input type="hidden" name="SQLiteCommand" value="QUERY">
+<input type="hidden" name="confirm" value="confirmed">
+<input type="hidden" name="ticket" value="'.$ticket.'">
+<input type="hidden" name="query" value="'.htmlspecialchars($query).'">
+<input type="hidden" name="option" value="showtable">
+<input type="submit" value="More">
+</form>';
+                       break;
+               default:
+               }
+               break;
+       default:
+       }
+       
+       echo $p->translated('PHP version: ').phpversion()."<br />\n";
+       if ($res = nucleus_mysql_query('SELECT sqlite_version();')) $ret = nucleus_mysql_fetch_array($res);
+       if (!$ret) $SQLiteVersion='?.?.?';
+       else if (!($SQLiteVersion=$ret[0])) $SQLiteVersion='?.?.?';
+       echo $p->translated('SQLite DB version: ').$SQLiteVersion."<br />\n";;
+       echo $p->translated('SQLite wrapper version: ').$SQLITECONF['VERSION']."<br />\n";
+       echo $p->translated('SQLite DB file size: ').filesize($SQLITECONF['DBFILENAME'])." bytes<br />\n";
+       echo "<hr />\n";
+
+?><table><tr><th><?php echo $p->translated('Tools'); ?></th><th><?php echo $p->translated('Execute SQL Query'); ?></th></tr>
+<tr><td>
+<form method="POST" action="<?php echo htmlspecialchars($pluginUrl);?>">
+<input type="hidden" name="SQLiteCommand" value="VACUUM">
+<input type="hidden" name="ticket" value="<?php echo $ticket; ?>">
+<input type="submit" value="<?php echo $p->translated('VACUUM'); ?>">
+</form>
+<form method="POST" action="<?php echo htmlspecialchars($pluginUrl);?>">
+<input type="hidden" name="SQLiteCommand" value="integrity_check">
+<input type="hidden" name="ticket" value="<?php echo $ticket; ?>">
+<input type="submit" value="<?php echo $p->translated('Integrity Check'); ?>">
+</form>
+<form method="POST" action="<?php echo htmlspecialchars($pluginUrl);?>">
+<select name="plugin">
+<?php
+       $res=nucleus_mysql_query('SELECT pfile FROM `'.sql_table('plugin').'`');
+       while($result=nucleus_mysql_fetch_row($res)) {
+               if (requestVar('plugin')==$result[0]) echo '<option selected value="'.$result[0].'">'.$result[0]."</option>\n";
+               else echo '<option value="'.$result[0].'">'.$result[0]."</option>\n";
+       }
+?>
+</select>
+<input type="hidden" name="SQLiteCommand" value="plugin_check">
+<input type="hidden" name="ticket" value="<?php echo $ticket; ?>">
+<input type="submit" value="<?php echo $p->translated('Check plugin'); ?>">
+</form>
+<?php
+       if ('yes'==$p->getOption('allowsql')) {
+?><form method="POST" action="<?php echo htmlspecialchars($pluginUrl);?>">
+<input type="hidden" name="SQLiteCommand" value="QUERY">
+<input type="hidden" name="ticket" value="<?php echo $ticket; ?>">
+<input type="hidden" name="confirm" value="confirmed">
+<input type="hidden" name="query" value="SELECT name, sqlite_table_structure(name) as table_structure FROM sqlite_master WHERE type='table'">
+<input type="hidden" name="option" value="showalltables">
+<input type="submit" value="<?php echo $p->translated('Show all tables'); ?>">
+</form><?php
+       }
+?>
+</td><td><?php
+       if ('yes'!=$p->getOption('allowsql')) echo $p->translated('Query not allowed. To use it, change the plugin option.');
+       else {
+?><form method="POST" action="<?php echo htmlspecialchars($pluginUrl);?>">
+<input type="hidden" name="SQLiteCommand" value="QUERY">
+<input type="hidden" name="ticket" value="<?php echo $ticket; ?>">
+<textarea name="query" id="ExecQuery" cols="50" rows="10"></textarea><br />
+<input type="submit" value="<?php echo $p->translated('Execute'); ?>">
+<input type="checkbox" name="confirm" value="confirmed"><?php echo $p->translated('I am sure.'); ?>
+</form>
+<?php  }
+?></td>
+</table>
+<br /><?php
+
+       if ($infostr) echo "<hr />\n".$infostr;
+       $pa->end();
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/language/japanese-euc.php b/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/language/japanese-euc.php
new file mode 100644 (file)
index 0000000..37fab4b
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+$this->langArray['Allow SQL query during the management?']='´ÉÍý¤ÎºÝ¡¢SQL ¥¯¥¨¥ê¤ò»ÈÍѤ·¤Þ¤¹¤«¡©';
+$this->langArray['Number of SQL queries at once when DB restore.']='¥Ç¡¼¥¿¥Ù¡¼¥¹Éü¸µ¤ÎºÝ¡¢°ì²ó¤¢¤¿¤ê²¿¸Ä¤Î SQL ¥¯¥¨¥ê¤ò¼Â¹Ô¤·¤Þ¤¹¤«¡©';
+$this->langArray['Wating tile (seconds) when DB restore.']='¥Ç¡¼¥¿¥Ù¡¼¥¹Éü¸µ¤ÎºÝ¡¢Àܳ¤ÎÂÔ¤Á»þ´Ö¤Ï²¿Éäˤ·¤Þ¤¹¤«¡©';
+$this->langArray['NP_SQLite plugin. Filesize of DB is now ']='NP_SQLite ¥×¥é¥°¥¤¥ó. ¸½ºß¤Î¥Ç¡¼¥¿¥Ù¡¼¥¹¥Õ¥¡¥¤¥ë¥µ¥¤¥º¤Ï';
+$this->langArray['SQLite management']='SQLite ´ÉÍý';
+$this->langArray['Pluing was installed sucessfully']='¥×¥é¥°¥¤¥ó¤ÏÀµ¾ï¤Ë¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Þ¤·¤¿';
+$this->langArray['I am sure.']='³Î¤«¤Ë¼Â¹Ô¤·¤Þ¤¹';
+$this->langArray['Please check the "I am sure." checkbox to execute query']='¥¯¥¨¥ê¤ò¼Â¹Ô¤¹¤ë¤Ë¤Ï"³Î¤«¤Ë¼Â¹Ô¤·¤Þ¤¹"¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤';
+$this->langArray['Click this to show all']='Á´Ê¸¤òɽ¼¨¤¹¤ë¤Ë¤Ï¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤';
+$this->langArray['PHP version: ']='PHP ¤Î¥Ð¡¼¥¸¥ç¥ó: ';
+$this->langArray['SQLite DB version: ']='SQLite ¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥Ð¡¼¥¸¥ç¥ó: ';
+$this->langArray['SQLite wrapper version: ']='SQLite ¥é¥Ã¥Ñ¤Î¥Ð¡¼¥¸¥ç¥ó: ';
+$this->langArray['SQLite DB file size: ']='¥Ç¡¼¥¿¥Ù¡¼¥¹¤Î¥Õ¥¡¥¤¥ë¥µ¥¤¥º: ';
+$this->langArray['Query not allowed. To use it, change the plugin option.']='¥¯¥¨¥ê¡¼¤Ï»È¤¨¤Þ¤»¤ó¡£»ÈÍѤ¹¤ë¤Ë¤Ï¡¢¥×¥é¥°¥¤¥ó¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤·¤Æ¤¯¤À¤µ¤¤¡£';
+$this->langArray['Tools']='¥Ä¡¼¥ë';
+$this->langArray['Execute SQL Query']='SQL ¥¯¥¨¥ê¤Î¼Â¹Ô';
+$this->langArray['VACUUM']='¥Ð¥­¥å¡¼¥à';
+$this->langArray['Integrity Check']='À°¹çÀ­¥Á¥§¥Ã¥¯';
+$this->langArray['Show all tables']='Á´¥Æ¡¼¥Ö¥ë¤Îɽ¼¨';
+$this->langArray['Execute']='¼Â¹Ô';
+$this->langArray['The plugin, ']='¥×¥é¥°¥¤¥ó ';
+$this->langArray[' was checked and modified (if modification required)']=' ¤ÎÄ´ºº(ɬÍפʾì¹ç¤Ï¤½¤ÎÊѹ¹)¤¬´°Î»¤·¤Þ¤·¤¿¡£';
+$this->langArray['Please modify the PHP files']='¼¡¤Î¤è¤¦¤Ë PHP ¥Õ¥¡¥¤¥ë¤òÊѹ¹¤·¤Æ¤¯¤À¤µ¤¤';
+$this->langArray['Check plugin']='¥×¥é¥°¥¤¥ó¤Î¥Á¥§¥Ã¥¯';
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/language/japanese-utf8.php b/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/language/japanese-utf8.php
new file mode 100644 (file)
index 0000000..0d76dfb
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+$this->langArray['Allow SQL query during the management?']='管理の際、SQL クエリを使用しますか?';
+$this->langArray['Number of SQL queries at once when DB restore.']='データベース復元の際、一回あたり何個の SQL クエリを実行しますか?';
+$this->langArray['Wating tile (seconds) when DB restore.']='データベース復元の際、接続の待ち時間は何秒にしますか?';
+$this->langArray['NP_SQLite plugin. Filesize of DB is now ']='NP_SQLite プラグイン. 現在のデータベースファイルサイズは';
+$this->langArray['SQLite management']='SQLite 管理';
+$this->langArray['Pluing was installed sucessfully']='プラグインは正常にインストールされました';
+$this->langArray['I am sure.']='確かに実行します';
+$this->langArray['Please check the "I am sure." checkbox to execute query']='クエリを実行するには"確かに実行します"をチェックしてください';
+$this->langArray['Click this to show all']='全文を表示するにはクリックしてください';
+$this->langArray['PHP version: ']='PHP のバージョン: ';
+$this->langArray['SQLite DB version: ']='SQLite データベースのバージョン: ';
+$this->langArray['SQLite wrapper version: ']='SQLite ラッパのバージョン: ';
+$this->langArray['SQLite DB file size: ']='データベースのファイルサイズ: ';
+$this->langArray['Query not allowed. To use it, change the plugin option.']='クエリーは使えません。使用するには、プラグインオプションを変更してください。';
+$this->langArray['Tools']='ツール';
+$this->langArray['Execute SQL Query']='SQL クエリの実行';
+$this->langArray['VACUUM']='バキューム';
+$this->langArray['Integrity Check']='整合性チェック';
+$this->langArray['Show all tables']='全テーブルの表示';
+$this->langArray['Execute']='実行';
+$this->langArray['The plugin, ']='プラグイン ';
+$this->langArray[' was checked and modified (if modification required)']=' の調査(必要な場合はその変更)が完了しました。';
+$this->langArray['Please modify the PHP files']='次のように PHP ファイルを変更してください';
+$this->langArray['Check plugin']='プラグインのチェック';
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/restore.php b/sqlite/tags/sqlite0904/nucleus/plugins/sqlite/restore.php
new file mode 100644 (file)
index 0000000..8bc07ae
--- /dev/null
@@ -0,0 +1,120 @@
+<?php
+    /***************************************
+    * SQLite-MySQL database transfer tool  *
+    *                           ver 0.8.0  *
+    * Written by Katsumi                   *
+    ***************************************/
+    
+// This library is GPL.
+
+error_reporting(E_ERROR | E_WARNING);
+chdir('../../../');
+if (!file_exists('./nucleus/sqlite/sqlite.php')) exit;
+
+if (!isset($_GET['dbfile'])) exit;
+
+$dbfile=str_replace(array('\\','/'),array('',''),$_GET['dbfile']);
+if (isset($_GET['numatonce'])) $numatonce=(int)$_GET['numatonce'];
+else $numatonce=20;
+if (isset($_GET['refreshwait'])) $refreshwait=(int)$_GET['refreshwait'];
+else $refreshwait=1;
+
+// Check $dbfile
+if (substr($dbfile,0,1)=='.') exit;
+if (preg_match('/\.php$/i',$dbfile)) exit;
+if (preg_match('/\.htm$/i',$dbfile)) exit;
+if (preg_match('/\.html$/i',$dbfile)) exit;
+if (!file_exists('./nucleus/sqlite/'.$dbfile)) exit;
+
+include ('./nucleus/sqlite/sqlite.php');
+
+$dbarray=file('./nucleus/sqlite/'.$dbfile);
+if (isset($_GET['dbpoint'])) $dbpoint=(int)$_GET['dbpoint'];
+else $dbpoint=0;
+$ret='';
+$err=false;
+
+while ($numatonce--) {
+       $query='';
+       $instring=false;
+       $cont=true;
+       
+       //Remove comment
+       while (@is_string(($t=$dbarray[$dbpoint]))) {
+               if (trim($t)!='' && substr($t,0,1)!='#' && substr($t,0,2)!='--') break;
+               $dbpoint++;
+       }
+       
+       //Get query string from array
+       while ($cont && @is_string($dbarray[$dbpoint])) {
+               $t=$dbarray[$dbpoint++];
+               while ($t) {
+                       if ($instring) {
+                               for ($i=0;$i<strlen($t);$i++) {
+                                       $query.=($c=$t[0]);
+                                       $t=substr($t,1);
+                                       if ($c=="'") {
+                                               $instring=false;
+                                               break;
+                                       } else if ($c=="\\") {
+                                               $query.=$t[0];
+                                               $t=substr($t,1);
+                                       }
+                               }
+                               continue;
+                       }
+                       if (($c=$t[0])==';') {
+                               $cont=false;
+                               break;
+                       }
+                       $query.=$c;
+                       $t=substr($t,1);
+                       if ($c=="'") $instring=true;
+               }
+       }
+       if ($query) {
+               if (nucleus_mysql_query($query)) $ret.="OK<br/>".htmlspecialchars(substr($query,0,200)).".....<hr />\n";
+               else $err=true;
+       }
+}
+nucleus_mysql_close();
+
+//Set 'dbtotal'
+$dbtotal=$dbpoint;
+while (@is_string(($dbarray[$dbtotal]))) $dbtotal++;
+
+if ($dbtotal==$dbpoint)  { // All done.
+       unlink('./nucleus/sqlite/'.$dbfile);
+       if (@include('./nucleus/language/japanese-utf8.php')) $lng='UTF-8';
+       else if (@include('./nucleus/language/japanese-euc.php')) $lng='EUC-JP';
+       else $lng='';
+       echo "<html><head><title>Restore Complete</title>\n";
+       if ($lng) echo "<meta http-equiv=\"content-type\" content=\"text/html; charset=$lng\" />\n";
+       echo "</head><body>\n";
+       if ($lng) {
+               echo '<p>'._RESTORE_COMPLETE.'</p>';
+               echo '<p><a href="../../">'._BACKTOMANAGE.'</a></p>';
+       } else {
+               echo '<p>Restore Complete</p>';
+               echo '<p><a href="../../">Back to Nucleus management</a></p>';
+       }
+       echo "\n</body></html>";
+       exit;
+}
+
+$f=(int)((float)100*$dbpoint/$dbtotal);
+$ret="$f % done.<hr>\n".$ret;
+
+if (isset($_GET['numatonce'])) $numatonce=$_GET['numatonce'];
+else $numatonce=20;
+$url="?dbfile=$dbfile&amp;numatonce=$numatonce&amp;refreshwait=$refreshwait&amp;dbpoint=$dbpoint";
+if ($err) $refresh='';
+else $refresh="<meta http-equiv=\"refresh\" content=\"$refreshwait; url=$url\">";
+
+?><html><head>
+<title>Creating database file</title>
+<?php echo $refresh; ?>
+</head><body>
+<a href="<?php echo $url; ?>">Continue</a><hr />
+<?php echo $ret;
+?></body></html>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/.htaccess b/sqlite/tags/sqlite0904/nucleus/sqlite/.htaccess
new file mode 100644 (file)
index 0000000..ff2beb8
--- /dev/null
@@ -0,0 +1,2 @@
+order deny,allow
+deny from all
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/convert.php b/sqlite/tags/sqlite0904/nucleus/sqlite/convert.php
new file mode 100644 (file)
index 0000000..a1c7d9e
--- /dev/null
@@ -0,0 +1,151 @@
+<?php
+/*******************************************
+* mysql_xxx => nucleus_mysql_xxx converter *
+*                              for Nucleus *
+*     ver 0.8.5   Written by Katsumi       *
+*******************************************/
+
+// The license of this script is GPL
+
+function modifyConfigInstall(){
+       // Modify config.php
+       $pattern=array();
+       $replace=array();
+       array_push($pattern,'/^([\s\S]*?)include([^\(]*?)\(([\s\S]*?)\$([\s\S]+)\'globalfunctions.php\'([\s\S]*?)$/');
+       array_push($replace,'$1include$2($3\$DIR_NUCLEUS.\'sqlite/sqlite.php\'$5'.'$1include$2($3\$$4\'globalfunctions.php\'$5');
+       if (file_exists('./config.php')) {
+               $before=read_from_file('./config.php');
+               if (strpos($before,'sqlite.php')===false) {
+                       $before=file('./config.php');
+                       $after='';
+                       foreach($before as $line) $after.=preg_replace($pattern,$replace,$line);
+                       if (!write_to_file(realpath('./config.php'),$after)) ExitWithError();
+               }
+       }
+       
+       // Modify install.php
+       if (file_exists('./install.php')) {
+               $before=read_from_file('./install.php');
+               if (strpos($before,'sqlite.php')===false) {
+               
+                       // The same pattern/replce is also used for install.php
+                       array_push($pattern,'/aConfPlugsToInstall([\s\S]+)\'NP_SkinFiles\'/i');
+                       array_push($replace,'aConfPlugsToInstall$1\'NP_SkinFiles\',\'NP_SQLite\'');
+                       array_push($pattern,'/<input[^>]+name="mySQL_host"([^\/]+)\/>/i');
+                       array_push($replace,'<input name="mySQL_host" type="hidden" value="dummy" />Not needed for SQLite');
+                       array_push($pattern,'/<input[^>]+name="mySQL_user"([^\/]+)\/>/i');
+                       array_push($replace,'<input name="mySQL_user" type="hidden" value="dummy" />Not needed for SQLite');
+                       array_push($pattern,'/<input[^>]+name="mySQL_password"([^\/]+)\/>/i');
+                       array_push($replace,'<input name="mySQL_password" type="hidden" value="dummy" />Not needed for SQLite');
+                       array_push($pattern,'/<input[^>]+name="mySQL_database"([^\/]+)\/>/i');
+                       array_push($replace,'<input name="mySQL_database" type="hidden" value="dummy" />Not needed for SQLite');
+                       array_push($pattern,'/<input[^>]+name="mySQL_create"([^\)]+)<\/label>/i');
+                       array_push($replace,'Database will be created if not exist.');
+                       $before=file('./install.php');
+                       $after='<?php include("nucleus/sqlite/sqlite.php"); ?>';
+                       foreach($before as $line) $after.=preg_replace($pattern,$replace,$line);
+                       if (!write_to_file(realpath('./install.php'),$after)) ExitWithError();
+               }
+       }
+       
+       // Modify backup.php
+       if (!modifyBackup('./nucleus/libs/backup.php')) // less than version 3.3
+               modifyBackup('./nucleus/plugins/backup/NP_BackupAdmin.php','class'); // more than version 3.4 (??)
+
+       // Modify install.sql
+       if (file_exists('./install.sql')) {
+               $before=file('./install.sql');
+               $pluginoptiontable=false;
+               $after='';
+               foreach($before as $line){
+                       if ($pluginoptiontable) {
+                               if (preg_match('/TYPE\=MyISAM;/i',$line)) $pluginoptiontable=false;
+                               else if (preg_match('/`oid`[\s]+int\(11\)[\s]+NOT[\s]+NULL[\s]+auto_increment/i',$line))
+                                       $line=preg_replace('/[\s]+auto_increment/i'," default '0'",$line);
+                       } else {
+                               if (preg_match('/CREATE[\s]+TABLE[\s]+`nucleus_plugin_option`/i',$line)) $pluginoptiontable=true;
+                       }
+                       if (strlen($after)==0) {
+                               $replace='PRAGMA synchronous = off;';
+                               if (!strstr($line,$replace)) $after=preg_replace('/^[^\r\n]*([\r\n]*)$/',$replace.'$1$1',$line);
+                       }
+                       $after.=$line;
+               }
+               if ($after!=$before) {
+                       if (!write_to_file(realpath('./install.sql'),$after)) ExitWithError();
+               }
+       }
+}
+
+function modifyBackup($file,$type='global'){
+       if (!file_exists($file)) return false;
+       $before=read_from_file($file);
+       if (strpos($before,'sqlite_restore_execute_queries')===false) {
+               $pattern='/_execute_queries[\s]*\(([^\)]+)\)[\s]*;/i';
+               if ($type=='class') $pattern='/\$this->_execute_queries[\s]*\(([^\)]+)\)[\s]*;/i';
+               $replace='sqlite_restore_execute_queries($1);';
+               $after=preg_replace($pattern,$replace,$before);
+               if (!write_to_file(realpath($file),$after)) ExitWithError();
+       }
+       return true;    
+}
+
+function seekPhpFiles($dir,&$phpfiles,$myself){
+       if (!is_dir($dir)) return;
+       $d = dir($dir);
+       $dirpath=realpath($d->path);
+       $dirs=array();
+       if (substr($dirpath,-1)!='/' && substr($dirpath,-1)!="\\") $dirpath.='/';
+       while (false !== ($entry = $d->read())) {
+               if ($entry=='.' || $entry=='..') continue;
+               if (is_file($dirpath.$entry) && substr($entry,-4)=='.php' && $entry!==$myself) array_push($phpfiles,realpath($dirpath.$entry));
+               if (is_dir($dirpath.$entry) && $entry!='language' && $entry!='sqlite' )  array_push($dirs,realpath($dirpath.$entry));
+       }
+       $d->close();
+       foreach($dirs as $dir) seekPhpFiles($dir,$phpfiles,$myself);
+}
+function changeFunctions($file){
+       if (!is_file($file=realpath($file))) return false;
+       if (!is_readable($file)) {
+               echo "Cannot read: $file<br />\n";
+               return false;
+       }
+       $before=read_from_file($file);
+       $after=do_replace($before);
+       if ($before!=$after) return write_to_file($file,$after);
+       return true;
+}
+function do_replace(&$text) {
+       // Do this process until change does not occur any more... 
+       // Otherwise, sometime file is not completely modified.
+       // This is indeed the case for BLOG.php.
+       $after=$text;
+       do $after=preg_replace('/([^_])mysql_([_a-z]+)([\s]*?)\(/','$1nucleus_mysql_$2(',($before=$after));
+       while ($before!=$after);
+       return $after;
+}
+function read_from_file($file) {
+       if (function_exists('file_get_contents') ) $ret=file_get_contents($file);
+       else {
+               ob_start();
+               readfile($file);
+               $ret=ob_get_contents();
+               ob_end_clean();
+       }
+       return $ret;
+}
+function write_to_file($file,&$text){
+       if (!$handle = @fopen($file, 'w')) {
+               echo "Cannot change: $file<br />\n";
+               return false;
+       }
+       fwrite($handle,$text);
+       fclose($handle);
+       echo "Changed: $file<br />\n";
+       return true;
+}
+function ExitWithError($text='Error occured.') {
+       echo "$text</body></html>";
+       exit;
+}
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/index.html b/sqlite/tags/sqlite0904/nucleus/sqlite/index.html
new file mode 100644 (file)
index 0000000..42682b4
--- /dev/null
@@ -0,0 +1 @@
+<html><body></body></html>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/note.txt b/sqlite/tags/sqlite0904/nucleus/sqlite/note.txt
new file mode 100644 (file)
index 0000000..1517224
--- /dev/null
@@ -0,0 +1,86 @@
+\r
+  The licence of this script is GPL\r
+\r
+                ACKOWLEDGMENT\r
+\r
+  I thank all the people of Nucleus JP forum \r
+  who discussed this project. Especially, I \r
+  thank kosugiatkips, mekyo, and nakahara21 \r
+  for ideas of some part of code.\r
+  I also thank Jon Jensen for his generous\r
+  acceptance for using his PHP code in the\r
+  earlier version of this library.\r
+\r
+  The features that are supported by this library but not\r
+  generally by SQLite are as follows:\r
+\r
+  CREATE TABLE IF NOT EXISTS, auto_increment,\r
+  DROP TABLE IF EXISTS, ALTER TABLE,\r
+  RENAME TABLE, DESC,\r
+  INSERT INTO ... SET xx=xx, xx=xx,\r
+  REPLACE INTO ... SET xx=xx, xx=xx,\r
+  SHOW KEYS FROM, SHOW INDEX FROM,\r
+  SHOW FIELDS FROM, SHOW COLUMNS FROM,\r
+  CREATE TABLE ... KEYS xxx (xxx,xxx)\r
+  SHOW TABLES LIKE, TRUNCATE TABLE\r
+  SHOW TABLES\r
+\r
+\r
+  Following functions are available in SQL query.\r
+\r
+  CONCAT, IF, IFNULL, NULLIF, SUBSTRING, \r
+  match() against(),\r
+  replace, UNIX_TIMESTAMP, REGEXP, DAYOFMONTH, MONTH, YEAR, \r
+  ADDDATE, DATE_ADD, SUBDATE, DATE_SUB, FIND_IN_SET,\r
+  CURDATE, CURRENT_DATE, CURTIME, CURRENT_TIME, CURRENT_TIMESTAMP, \r
+  LOCALTIME, LOCALTIMESTAMP, SYSDATE, DATE_FORMAT, TIME_FORMAT, \r
+  DAYNAME, DAYOFWEEK, DAYOFYEAR, EXTRACT, FROM_DAYS, FROM_UNIXTIME,\r
+  HOUR, MINUTE, MONTH, MONTHNAME, PERIOD_ADD, PERIOD_DIFF, QUARTER,\r
+  SECOND, SEC_TO_TIME, SECOND, WEEK, WEEKDAY, YEAR, YEARWEEK,\r
+  FORMAT, INET_ATON, INET_NTOA, MD5,\r
+  ACOS, ASIN, ATAN, CEIL, CEILING, COS, COT, CRC32, DEGREES, \r
+  EXP, FLOOR, GREATEST, MAX, LEAST, MIN, ln, log, log2, log10,\r
+  MOD, PI, POW, POWER, RADIANS, RAND, SIGN, SIN, SQRT, TAN,\r
+  ASCII, BIN, BIT_LENGTH, CHAR, CHAR_LENGTH, CONCAT_WS,\r
+  CONV, ELT, EXPORT_SET, FIELD, HEX, INSERT, LOCATE,\r
+  INSTR, LCASE, LOWER, LEFT, LENGTH, OCTET_LENGTH,\r
+  LOAD_FILE, LPAD, LTRIM, MAKE_SET, MID, SUBSTRING,\r
+  OCT, ORD, QUOTE, REPEAT, REVERSE, RIGHT, RPAD,\r
+  RTRIM, SOUNDEX, SPACE, SUBSTRING_INDEX, TRIM,\r
+  UCASE, UPPER,\r
+\r
+\r
+ Release note:\r
+  Version 0.8.0\r
+    -This is the first established version and\r
+     exactly the same as ver 0.7.8b.\r
+\r
+  Version 0.8.1\r
+    -Execute "PRAGMA short_column_names=1" first.\r
+    -Avoid executing outside php file in some very specfic environment.\r
+    -Avoid executing multiple queries using ";" as delimer.\r
+    -Add check routine for the installed SQLite\r
+\r
+  Version 0.8.5\r
+    -Use SQLite_Functions class\r
+    -'PRAGMA synchronous = off;' when installing\r
+\r
+  Version 0.8.5.5\r
+    - ALTER TABLE syntaxes updated, bugs fixed\r
+\r
+  Version 0.8.6.0\r
+    - ALTER TABLE almost completery re-written\r
+    - DESC 'table' 'field' supported\r
+    - The function 'php' is unregestered from SQL query.\r
+\r
+  Version 0.9.0.1\r
+    - Support RENAME TABLE\r
+    - Some tunings are done to improve the speed.\r
+\r
+  Version 0.9.0.2\r
+    - Debug of CREATE TABLE routine.\r
+    - NP_SQLite: trim the query when 'Copy' is used.\r
+\r
+  Version 0.9.0.4\r
+    - Debug of REGEX function\r
+    - Add mysql_server_info() and mysql_client_info() functions.\r
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/sqlite.php b/sqlite/tags/sqlite0904/nucleus/sqlite/sqlite.php
new file mode 100644 (file)
index 0000000..271bdb9
--- /dev/null
@@ -0,0 +1,567 @@
+<?php\r
+    /****************************************\r
+    * SQLite-MySQL wrapper for Nucleus      *\r
+    *                           ver 0.9.0.4 *\r
+    * Written by Katsumi                    *\r
+    ****************************************/\r
+\r
+// Check SQLite installed\r
+\r
+if (!function_exists('sqlite_open')) exit('Sorry, SQLite is not available from PHP (maybe, not installed in the server).');\r
+\r
+// Initializiation stuff\r
+require_once dirname(__FILE__) . '/sqliteconfig.php';\r
+$SQLITE_DBHANDLE=sqlite_open($SQLITECONF['DBFILENAME']);\r
+require_once dirname(__FILE__) . '/sqlitequeryfunctions.php';\r
+$SQLITECONF['VERSION']='0.9.0.4';\r
+\r
+//Following thing may work if MySQL is NOT installed in server.\r
+if (!function_exists('mysql_query')) {\r
+       define ("MYSQL_ASSOC", SQLITE_ASSOC);\r
+       define ("MYSQL_BOTH", SQLITE_BOTH);\r
+       define ("MYSQL_NUM", SQLITE_NUM);\r
+       function mysql_connect(){\r
+               global $SQLITECONF;\r
+               $SQLITECONF['OVERRIDEMODE']=true;\r
+               $args=func_get_args();\r
+               return call_user_func_array('nucleus_mysql_connect',$args);\r
+       }\r
+       foreach (array('mysql_affected_rows','mysql_change_user','mysql_client_encoding','mysql_close',\r
+               'mysql_create_db','mysql_data_seek','mysql_db_name','mysql_db_query','mysql_drop_db','mysql_errno',\r
+               'mysql_error','mysql_escape_string','mysql_fetch_array','mysql_fetch_assoc','mysql_fetch_field','mysql_fetch_lengths',\r
+               'mysql_fetch_object','mysql_fetch_row','mysql_field_flags','mysql_field_len','mysql_field_name','mysql_field_seek',\r
+               'mysql_field_table','mysql_field_type','mysql_free_result','mysql_get_client_info','mysql_get_host_info',\r
+               'mysql_get_proto_info','mysql_get_server_info','mysql_info','mysql_insert_id','mysql_list_dbs',\r
+               'mysql_list_fields','mysql_list_processes','mysql_list_tables','mysql_num_fields','mysql_num_rows','mysql_numrows',\r
+               'mysql_pconnect','mysql_ping','mysql_query','mysql_real_escape_string','mysql_result','mysql_select_db',\r
+               'mysql_stat','mysql_tablename','mysql_thread_id','mysql_unbuffered_query')\r
+                as $value) eval(\r
+               "function $value(){\n".\r
+               "  \$args=func_get_args();\n".\r
+               "  return call_user_func_array('nucleus_$value',\$args);\n".\r
+               "}\n");\r
+}\r
+\r
+// Empty object for mysql_fetch_object().\r
+class SQLITE_OBJECT {}\r
+\r
+function sqlite_ReturnWithError($text='Not supported',$more=''){\r
+       // Show warning when error_reporting() is set.\r
+       if (!(error_reporting() & E_WARNING)) return false;\r
+       \r
+       // Seek the file and line that originally called sql function.\r
+       $a=debug_backtrace();\r
+       foreach($a as $key=>$btrace) {\r
+               if (!($templine=$btrace['line'])) continue;\r
+               if (!($tempfile=$btrace['file'])) continue;\r
+               $file=str_replace('\\','/',$file);\r
+               if (!$line && !$file && strpos($tempfile,'/sqlite.php')===false && strpos($tempfile,'/sqlitequeryfunctions.php')===false) {\r
+                       $line=$templine;\r
+                       $file=$tempfile;\r
+               }\r
+               echo "\n<!--$tempfile line:$templine-->\n";\r
+       }\r
+       echo "Warning from SQLite-MySQL wrapper: $text<br />\n";\r
+       if ($line && $file) echo "in <b>$file</b> on line <b>$line</b><br />\n";\r
+       echo $more;\r
+       return false;\r
+}\r
+function sqlite_DebugMessage($text=''){\r
+       global $SQLITECONF;\r
+       if (!$SQLITECONF['DEBUGREPORT']) return;\r
+       if ($text) $SQLITECONF['DEBUGMESSAGE'].="\n".$text."\n";\r
+       if (headers_sent()) {\r
+               echo '<!--sqlite_DebugMessage'.$SQLITECONF['DEBUGMESSAGE'].'sqlite_DebugMessage-->';\r
+               unset($SQLITECONF['DEBUGMESSAGE']);\r
+       }\r
+}\r
+\r
+// nucleus_mysql_XXXX() functions follow.\r
+\r
+function nucleus_mysql_connect($p1=null,$p2=null,$p3=null,$p4=null,$p5=null){\r
+       // All prameters are ignored.\r
+       global $SQLITE_DBHANDLE,$SQLITECONF;\r
+       if (!$SQLITE_DBHANDLE) $SQLITE_DBHANDLE=sqlite_open($SQLITECONF['DBFILENAME']);\r
+       // Initialization queries.\r
+       foreach($SQLITECONF['INITIALIZE'] as $value) nucleus_mysql_query($value);\r
+       // Unregister the function 'php' in sql query.\r
+       sqlite_create_function($SQLITE_DBHANDLE,'php','pi');\r
+       return $SQLITE_DBHANDLE;\r
+}\r
+\r
+function nucleus_mysql_close($p1=null){\r
+       global $SQLITE_DBHANDLE;\r
+       if (!($dbhandle=$p1)) $dbhandle=$SQLITE_DBHANDLE;\r
+       $SQLITE_DBHANDLE='';\r
+       return sqlite_close ($dbhandle);\r
+}\r
+\r
+function nucleus_mysql_select_db($p1,$p2=null){\r
+       // SQLite does not support multiple databases in a file.\r
+       // So this function do nothing and always returns true.\r
+       // Note: mysql_select_db() function returns true/false,\r
+       // not link-ID.\r
+       return true;\r
+}\r
+\r
+function nucleus_mysql_query($p1,$p2=null,$unbuffered=false){//echo htmlspecialchars($p1)."<br />\n";\r
+       global $SQLITE_DBHANDLE,$SQLITECONF;\r
+       if (!($dbhandle=$p2)) $dbhandle=$SQLITE_DBHANDLE;\r
+       $query=trim($p1);\r
+       if (strpos($query,"\xEF\xBB\xBF")===0) $query=substr($query,3);// UTF-8 stuff\r
+       if (substr($query,-1)==';') $query=substr($query,0,strlen($query)-1);\r
+       \r
+       // Escape style is changed from MySQL type to SQLite type here.\r
+       // This is important to avoid possible SQL-injection.\r
+       $strpositions=array();// contains the data show where the strings are (startposition => endposition)\r
+       if (strpos($query,'`')!==false || strpos($query,'"')!==false || strpos($query,"'")!==false)\r
+               $strpositions=sqlite_changeQuote($query);\r
+       //echo "<br />".htmlspecialchars($p1)."<br /><br />\n".htmlspecialchars($query)."<hr />\n";\r
+\r
+       // Debug mode\r
+       if ($SQLITECONF['DEBUGMODE']) $query=sqlite_mysql_query_debug($query);\r
+       \r
+       // Anyway try it.\r
+       if ($unbuffered) {\r
+               if ($ret=@sqlite_unbuffered_query($dbhandle,$query)) return $ret;\r
+       } else {\r
+               if ($ret=@sqlite_query($dbhandle,$query)) return $ret;\r
+       }\r
+       \r
+       // Error occured. Query must be translated.\r
+       return sqlite_mysql_query_sub($dbhandle,$query,$strpositions,$p1,$unbuffered);\r
+}\r
+function sqlite_mysql_query_sub($dbhandle,$query,$strpositions=array(),$p1=null,$unbuffered=false){//echo htmlspecialchars($p1)."<br />\n";\r
+       // Query translation is needed, especially when changing the data in database.\r
+       // So far, this routine is written for 'CREATE TABLE','DROP TABLE', 'INSERT INTO',\r
+       // 'SHOW TABLES LIKE', 'SHOW KEYS FROM', 'SHOW INDEX FROM'\r
+       // and several functions used in query.\r
+       // How about 'UPDATE' ???\r
+       global $SQLITE_DBHANDLE,$SQLITECONF;\r
+       $beforetrans=time()+microtime();\r
+       if (!$p1) $p1=$query;\r
+       $morequeries=array();\r
+       $temptable=false;\r
+       $uquery=strtoupper($query);\r
+       if (strpos($uquery,'CREATE TABLE')===0 || ($temptable=(strpos($uquery,'CREATE TEMPORARY TABLE')===0))) {\r
+               if (!($i=strpos($query,'('))) return sqlite_ReturnWithError('nucleus_mysql_query: '.$p1);\r
+               //check if the command is 'CREATE TABLE IF NOT EXISTS'\r
+               if (strpos(strtoupper($uquery),'CREATE TABLE IF NOT EXISTS')===0) {\r
+                       $tablename=trim(substr($query,26,$i-26));\r
+                       if (substr($tablename,0,1)!="'") $tablename="'$tablename'";\r
+                       $res=sqlite_query($dbhandle,"SELECT tbl_name FROM sqlite_master WHERE tbl_name=$tablename LIMIT 1");\r
+                       if (nucleus_mysql_num_rows($res)) return true;\r
+               } else {\r
+                       $tablename=trim(substr($query,12,$i-12));\r
+                       if (substr($tablename,0,1)!="'") $tablename="'$tablename'";\r
+               }\r
+               $query=trim(substr($query,$i+1));\r
+               for ($i=strlen($query);0<$i;$i--) if ($query[$i]==')') break;\r
+               $query=substr($query,0,$i);\r
+               $commands=_sqlite_divideByChar(',',$query);\r
+               require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+               $query=sqlite_createtable_query($commands,$tablename,$temptable,$morequeries);\r
+       } else if (strpos($uquery,'DROP TABLE IF EXISTS')===0) {\r
+               if (!($i=strpos($query,';'))) $i=strlen($query);\r
+               $tablename=trim(substr($query,20,$i-20));\r
+               if (substr($tablename,0,1)!="'") $tablename="'$tablename'";\r
+               $res=sqlite_query($dbhandle,"SELECT tbl_name FROM sqlite_master WHERE tbl_name=$tablename LIMIT 1");\r
+               if (!nucleus_mysql_num_rows($res)) return true;\r
+               $query='DROP TABLE '.$tablename;\r
+       } else if (strpos($uquery,'ALTER TABLE ')===0) {\r
+               $query=trim(substr($query,11));\r
+               if ($i=strpos($query,' ')) {\r
+                       $tablename=trim(substr($query,0,$i));\r
+                       $query=trim(substr($query,$i));\r
+                       require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+                       $ret =sqlite_altertable($tablename,$query,$dbhandle);\r
+                       if (!$ret) sqlite_ReturnWithError('SQL error',"<br /><i>".nucleus_mysql_error()."</i><br />".htmlspecialchars($p1)."<br /><br />\n".htmlspecialchars("ALTER TABLE $tablename $query")."<hr />\n");\r
+                       return $ret;\r
+               }\r
+               // Else, syntax error\r
+       } else if (strpos($uquery,'RENAME TABLE ')===0) {\r
+               require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+               return sqlite_renametable(_sqlite_divideByChar(',',substr($query,13)),$dbhandle);\r
+       } else if (strpos($uquery,'INSERT INTO ')===0 || strpos($uquery,'REPLACE INTO ')===0 ||\r
+                       strpos($uquery,'INSERT IGNORE INTO ')===0 || strpos($uquery,'REPLACE IGNORE INTO ')===0) {\r
+               $buff=str_replace(' IGNORE ',' OR IGNORE ',substr($uquery,0,($i=strpos($uquery,' INTO ')+6)));\r
+               $query=trim(substr($query,$i));\r
+               if ($i=strpos($query,' ')) {\r
+                       $buff.=trim(substr($query,0,$i+1));\r
+                       $query=trim(substr($query,$i));\r
+               }\r
+               if ($i=strpos($query,' ')) {\r
+                       if (strpos(strtoupper($query),'SET')===0) {\r
+                               $query=trim(substr($query,3));\r
+                               $commands=_sqlite_divideByChar(',',$query);\r
+                               $query=' VALUES(';\r
+                               $buff.=' (';\r
+                               foreach($commands as $key=>$value){\r
+                                       //echo "[".htmlspecialchars($value)."]";\r
+                                       if (0<$key) {\r
+                                               $buff.=', ';\r
+                                               $query.=', ';\r
+                                       }\r
+                                       if ($i=strpos($value,'=')) {\r
+                                               $buff.=trim(substr($value,0,$i));\r
+                                               $query.=substr($value,$i+1);\r
+                                       }\r
+                               }\r
+                               $buff.=')';\r
+                               $query.=')';\r
+                       } else {\r
+                               $beforevalues='';\r
+                               $commands=_sqlite_divideByChar(',',$query);\r
+                               $query='';\r
+                               foreach($commands as $key=>$value){\r
+                                       if ($beforevalues=='' && preg_match('/^(.*)\)\s+VALUES\s+\(/i',$value,$matches)) {\r
+                                               $beforevalues=$buff.' '.$query.$matches[1].')';\r
+                                       }\r
+                                       if (0<$key) $query.=$beforevalues.' VALUES ';// supports multiple insertion\r
+                                       $query.=$value.';';\r
+                               }\r
+                       }\r
+               }\r
+               $query=$buff.' '.$query;\r
+       } else if (strpos($uquery,'SHOW TABLES LIKE ')===0) {\r
+               $query='SELECT name FROM sqlite_master WHERE type=\'table\' AND name LIKE '.substr($query,17);\r
+       } else if (strpos($uquery,'SHOW TABLES')===0) {\r
+               $query='SELECT name FROM sqlite_master WHERE type=\'table\'';\r
+       } else if (strpos($uquery,'SHOW KEYS FROM ')===0) {\r
+               require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+               $query=sqlite_showKeysFrom(trim(substr($query,15)),$dbhandle);\r
+       } else if (strpos($uquery,'SHOW INDEX FROM ')===0) {\r
+               require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+               $query=sqlite_showKeysFrom(trim(substr($query,16)),$dbhandle);\r
+       } else if (strpos($uquery,'SHOW FIELDS FROM ')===0) {\r
+               require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+               $query=sqlite_showFieldsFrom(trim(substr($query,17)),$dbhandle);\r
+       } else if (strpos($uquery,'SHOW COLUMNS FROM ')===0) {\r
+               require_once(dirname(__FILE__) . '/sqlitealtertable.php');\r
+               $query=sqlite_showFieldsFrom(trim(substr($query,18)),$dbhandle);\r
+       } else if (strpos($uquery,'TRUNCATE TABLE ')===0) {\r
+               $query='DELETE FROM '.substr($query,15);\r
+       } else if (preg_match('/^DESC \'([^\']+)\' \'([^\']+)\'$/',$query,$m)) {\r
+               return nucleus_mysql_query("SHOW FIELDS FROM '$m[1]' LIKE '$m[2]'");\r
+       } else if (preg_match('/^DESC ([^\s]+) ([^\s]+)$/',$query,$m)) {\r
+               return nucleus_mysql_query("SHOW FIELDS FROM '$m[1]' LIKE '$m[2]'");\r
+       } else SQLite_Functions::sqlite_modifyQueryForUserFunc($query,$strpositions);\r
+\r
+       //Throw query again.\r
+       $aftertrans=time()+microtime();\r
+       if ($unbuffered) {\r
+               $ret=sqlite_unbuffered_query($dbhandle,$query);\r
+       } else {\r
+               $ret=sqlite_query($dbhandle,$query);\r
+       }\r
+\r
+       $afterquery=time()+microtime();\r
+       if ($SQLITECONF['MEASURESPEED']) sqlite_DebugMessage("translated query:$query\n".\r
+               'translation: '.($aftertrans-$beforetrans).'sec, query: '.($afterquery-$aftertrans).'sec');\r
+       if (!$ret) sqlite_ReturnWithError('SQL error',"<br /><i>".nucleus_mysql_error()."</i><br />".htmlspecialchars($p1)."<br /><br />\n".htmlspecialchars($query)."<hr />\n");\r
+       foreach ($morequeries as $value) if ($value) @sqlite_query($dbhandle,$value);\r
+       return $ret;\r
+}\r
+function sqlite_changeQuote(&$query){\r
+       // This function is most important.\r
+       // When you modify this function, do it very carefully.\r
+       // Otherwise, you may allow crackers to do SQL-injection.\r
+       // This function returns array that shows where the strings are.\r
+       $sarray=array();\r
+       $ret='';\r
+       $qlen=strlen($query);\r
+       for ($i=0;$i<$qlen;$i++) {\r
+               // Go to next quote\r
+               if (($i1=strpos($query,'"',$i))===false) $i1=$qlen;\r
+               if (($i2=strpos($query,"'",$i))===false) $i2=$qlen;\r
+               if (($i3=strpos($query,'`',$i))===false) $i3=$qlen;\r
+               if ($i1==$qlen && $i2==$qlen && $i3==$qlen) {\r
+                       $temp=preg_replace('/[\s]+/',' ',substr($query,$i)); // Change all spacying to ' '.\r
+                       $ret.=($temp);\r
+                       if (strstr($temp,';')) exit('Warning: try to use more than two queries?');\r
+                       break;\r
+               }\r
+               if ($i2<($j=$i1)) $j=$i2;\r
+               if ($i3<$j) $j=$i3;\r
+               $temp=preg_replace('/[\s]+/',' ',substr($query,$i,$j-$i)); // Change all spacying to ' '.\r
+               $ret.=($temp);\r
+               $c=$query[($i=$j)]; // $c keeps the type of quote.\r
+               if (strstr($temp,';')) exit('Warning: try to use more than two queries?');\r
+               \r
+               // Check between quotes.\r
+               // $j shows the begging positioin.\r
+               // $i will show the ending position.\r
+               $j=(++$i);\r
+               while ($i<$qlen) {\r
+                       if (($i1=strpos($query,$c,$i))===false) $i1=$qlen;\r
+                       if (($i2=strpos($query,"\\",$i))===false) $i2=$qlen;\r
+                       if ($i2<$i1) {\r
+                               // \something. Skip two characters.\r
+                               $i=$i2+2;\r
+                               continue;\r
+                       } if ($i1<($qlen-1) && $query[$i1+1]==$c) {\r
+                               // "", '' or ``.  Skip two characters.\r
+                               $i=$i1+2;\r
+                               continue;\r
+                       } else {// OK. Reached the end position\r
+                               $i=$i1;\r
+                               break;\r
+                       }\r
+               }\r
+               $i1=strlen($ret);\r
+               $ret.="'".sqlite_changeslashes(substr($query,$j,$i-$j));\r
+               if ($i<$qlen) $ret.="'"; //else Syntax error in query.\r
+               $i2=strlen($ret);\r
+               $sarray[$i1]=$i2;\r
+       }//echo htmlspecialchars($query).'<br />'.htmlspecialchars($ret).'<br />';\r
+       $query=$ret;\r
+       return $sarray;\r
+}\r
+function sqlite_changeslashes(&$text){\r
+       // By SQLite, "''" is used in the quoted string instead of "\'".\r
+       // In addition, only "'" seems to be allowed for perfect quotation of string.\r
+       // This routine is used for the conversion from MySQL type to SQL type.\r
+       // Do NOT use stripslashes() but use stripcslashes().  Otherwise, "\r\n" is not converted.\r
+       if ($text==='') return '';\r
+       return (sqlite_escape_string (stripcslashes((string)$text)));\r
+}\r
+function _sqlite_divideByChar($char,$query,$limit=-1){\r
+       if (!is_array($char)) $char=array($char);\r
+       $ret=array();\r
+       $query=trim($query);\r
+       $buff='';\r
+       while (strlen($query)){\r
+               $i=strlen($query);\r
+               foreach($char as $value){\r
+                       if (($j=strpos($query,$value))!==false) {\r
+                               if ($j<$i) $i=$j;\r
+                       }\r
+               }\r
+               if (($j=strpos($query,'('))===false) $j=strlen($query);\r
+               if (($k=strpos($query,"'"))===false) $k=strlen($query);\r
+               if ($i<$j && $i<$k) {// ',' found\r
+                       $buff.=substr($query,0,$i);\r
+                       if (strlen($buff)) $ret[]=$buff;\r
+                       $query=trim(substr($query,$i+1));\r
+                       $buff='';\r
+                       $limit--;\r
+                       if ($limit==0) exit;\r
+               } else if ($j<$i && $j<$k) {// '(' found\r
+                       if (($i=strpos($query,')',$j))===false) {\r
+                               $buff.=$query;\r
+                               if (strlen($buff)) $ret[]=$buff;\r
+                               $query=$buff='';\r
+                       } else {\r
+                               $buff.=substr($query,0,$i+1);\r
+                               $query=substr($query,$i+1);\r
+                       }\r
+               } else if ($k<$i && $k<$j) {// "'" found\r
+                       if (($i=strpos($query,"'",$k+1))===false) {\r
+                               $buff.=$query;\r
+                               if (strlen($buff)) $ret[]=$buff;\r
+                               $query=$buff='';\r
+                       } else {\r
+                               $buff.=substr($query,0,$i+1);\r
+                               $query=substr($query,$i+1);\r
+                       }\r
+               } else {// last column\r
+                       $buff.=$query;\r
+                       if (strlen($buff)) $ret[]=$buff;\r
+                       $query=$buff='';\r
+               }\r
+       }\r
+       if (strlen($buff)) $ret[]=$buff;\r
+       return $ret;\r
+}\r
+function sqlite_mysql_query_debug(&$query){\r
+       // There is nothing to do here in this version.\r
+       return $query;\r
+}\r
+\r
+function nucleus_mysql_list_tables($p1=null,$p2=null) {\r
+       global $SQLITE_DBHANDLE,$MYSQL_DATABASE;\r
+       return sqlite_query($SQLITE_DBHANDLE,"SELECT name as Tables_in_$MYSQL_DATABASE FROM sqlite_master WHERE type='table'");\r
+}\r
+function nucleus_mysql_listtables($p1=null,$p2=null) { return nucleus_mysql_list_tables($p1,$p2);}\r
+\r
+function nucleus_mysql_affected_rows($p1=null){\r
+       global $SQLITE_DBHANDLE;\r
+       if (!($dbhandle=$p1)) $dbhandle=$SQLITE_DBHANDLE;\r
+       return sqlite_changes($dbhandle);\r
+}\r
+\r
+function nucleus_mysql_error($p1=null){\r
+       global $SQLITE_DBHANDLE;\r
+       if (!($dbhandle=$p1)) $dbhandle=$SQLITE_DBHANDLE;\r
+       return sqlite_error_string ( sqlite_last_error ($dbhandle) );\r
+}\r
+\r
+function nucleus_mysql_fetch_array($p1,$p2=SQLITE_BOTH){\r
+       return sqlite_fetch_array ($p1,$p2);\r
+}\r
+\r
+function nucleus_mysql_fetch_assoc($p1){\r
+       return sqlite_fetch_array($p1,SQLITE_ASSOC);\r
+}\r
+\r
+function nucleus_mysql_fetch_object($p1,$p2=SQLITE_BOTH){\r
+       if (is_array($ret=sqlite_fetch_array ($p1,$p2))) {\r
+               $o=new SQLITE_OBJECT;\r
+               foreach ($ret as $key=>$value) {\r
+                       if (strstr($key,'.')) {// Remove table name.\r
+                               $key=preg_replace('/^(.+)\."(.+)"$/','"$2"',$key);\r
+                               $key=preg_replace('/^(.+)\.([^.^"]+)$/','$2',$key);\r
+                       }\r
+                       $o->$key=$value;\r
+               }\r
+               return $o;\r
+       } else return false;\r
+}\r
+\r
+function nucleus_mysql_fetch_row($p1){\r
+       return sqlite_fetch_array($p1,SQLITE_NUM);\r
+}\r
+\r
+function nucleus_mysql_field_name($p1,$p2){\r
+       return sqlite_field_name ($p1,$p2);\r
+}\r
+\r
+function nucleus_mysql_free_result($p1){\r
+       // ???? Cannot find corresponding function of SQLite.\r
+       // Maybe SQLite is NOT used for the high spec server\r
+       // that need mysql_free_result() function because of\r
+       // many SQL-queries in a script.\r
+       return true;\r
+}\r
+\r
+function nucleus_mysql_insert_id($p1=null){\r
+       global $SQLITE_DBHANDLE;\r
+       if (!($dbhandle=$p1)) $dbhandle=$SQLITE_DBHANDLE;\r
+       return sqlite_last_insert_rowid ($dbhandle);\r
+}\r
+\r
+function nucleus_mysql_num_fields($p1){\r
+       return sqlite_num_fields ($p1);\r
+}\r
+\r
+function nucleus_mysql_num_rows($p1){\r
+       return sqlite_num_rows ($p1);\r
+}\r
+function nucleus_mysql_numrows($p1){\r
+       return sqlite_num_rows ($p1);\r
+}\r
+\r
+function nucleus_mysql_result($p1,$p2,$p3=null){\r
+       if ($p3) return sqlite_ReturnWithError('nucleus_mysql_result');\r
+       if (!$p2) return sqlite_fetch_single ($p1);\r
+       $a=sqlite_fetch_array ($p1);\r
+       return $a[$p2];\r
+}\r
+\r
+function nucleus_mysql_unbuffered_query($p1,$p2=null){\r
+       return nucleus_mysql_query($p1,$p2,true);\r
+}\r
+\r
+function nucleus_mysql_client_encoding($p1=null){\r
+       return sqlite_libencoding();\r
+}\r
+\r
+function nucleus_mysql_data_seek($p1,$p2) {\r
+       return sqlite_seek($p1,$p2);\r
+}\r
+\r
+function nucleus_mysql_errno ($p1=null){\r
+       global $SQLITE_DBHANDLE;\r
+       if (!($dbhandle=$p1)) $dbhandle=$SQLITE_DBHANDLE;\r
+       return sqlite_last_error($dbhandle);\r
+}\r
+\r
+function nucleus_mysql_escape_string ($p1){\r
+       // The "'" will be changed to "''".\r
+       // This way works for both MySQL and SQLite when single quotes are used for string.\r
+       // Note that single quote is always used in this wrapper.\r
+       // If a plugin is made on SQLite-Nucleus and such plugin will be used for MySQL-Nucleus,\r
+       // nucleus_mysql_escape_string() will be changed to mysql_escape_string() and\r
+       // this routine won't be used, so this way won't be problem.\r
+       return sqlite_escape_string($p1);\r
+}\r
+\r
+function nucleus_mysql_real_escape_string ($p1,$p2=null){\r
+       //addslashes used here.\r
+       return addslashes($p1);\r
+}\r
+\r
+function nucleus_mysql_create_db ($p1,$p2=null){\r
+       // All prameters are ignored.\r
+       // Returns always true;\r
+       return true;\r
+}\r
+\r
+function nucleus_mysql_pconnect($p1=null,$p2=null,$p3=null,$p4=null,$p5=null){\r
+       global $SQLITE_DBHANDLE,$SQLITECONF;\r
+       sqlite_close ($SQLITE_DBHANDLE);\r
+       $SQLITE_DBHANDLE=sqlite_popen($SQLITECONF['DBFILENAME']);\r
+       return ($SQLITE['DBHANDLE']=$SQLITE_DBHANDLE);\r
+}\r
+\r
+function nucleus_mysql_fetch_field($p1,$p2=null){\r
+       if ($p2) return sqlite_ReturnWithError('nucleus_mysql_fetch_field');\r
+       // Only 'name' is supported.\r
+       $o=new SQLITE_OBJECT;\r
+       $o->name=array();\r
+       if(is_array($ret=sqlite_fetch_array ($p1,SQLITE_ASSOC )))\r
+               foreach ($ret as $key=>$value) {\r
+                       if (is_string($key)) array_push($o->name,$key);\r
+               }\r
+       return $o;\r
+\r
+}\r
+function nucleus_mysql_get_client_info(){\r
+       return nucleus_mysql_get_server_info();\r
+}\r
+function nucleus_mysql_get_server_info(){\r
+       $res=nucleus_mysql_query('SELECT sqlite_version();');\r
+       if (!$res) return '?.?.?';\r
+       $row=nucleus_mysql_fetch_row($res);\r
+       if (!$row) return '?.?.?';\r
+       return $row[0];\r
+}\r
+\r
+// This function is called instead of _execute_queries() in backp.php\r
+function sqlite_restore_execute_queries(&$query){\r
+       global $DIR_NUCLEUS,$DIR_LIBS,$DIR_PLUGINS,$CONF;\r
+       \r
+       // Skip until the first "#" or "--"\r
+       if (($i=strpos($query,"\n#"))===false) $i=strlen($query);\r
+       if (($j=strpos($query,"\n--"))===false) $j=strlen($query);\r
+       if ($i<$j) $query=substr($query,$i+1);\r
+       else  $query=substr($query,$j+1);\r
+       \r
+       // Save the query to temporary file in sqlite directory.\r
+       if (function_exists('microtime')) {\r
+               $prefix=preg_replace('/[^0-9]/','',microtime());\r
+       } else {\r
+               srand(time());\r
+               $prefix=(string)rand(0,999999);\r
+       }\r
+       $tmpname=tempnam($DIR_NUCLEUS.'sqlite/',"tmp$prefix");\r
+       if (!($handle=@fopen($tmpname,'w'))) return 'Cannot save temporary DB file.';\r
+       fwrite($handle,$query);\r
+       fclose($handle);\r
+       $tmpname=preg_replace('/[\s\S]*?[\/\\\\]([^\/\\\\]+)$/','$1',$tmpname);\r
+       \r
+       // Read the option from NP_SQLite\r
+       if (!class_exists('NucleusPlugin')) { include($DIR_LIBS.'PLUGIN.php');}\r
+       if (!class_exists('NP_SQLite')) { include($DIR_PLUGINS.'NP_SQLite.php'); }\r
+       $p=new NP_SQLite();\r
+       if (!($numatonce=@$p->getOption('numatonce'))) $numatonce=20;\r
+       if (!($refreshwait=@$p->getOption('refreshwait'))) $refreshwait=1;\r
+       \r
+       // Start process.\r
+       $url="plugins/sqlite/restore.php?dbfile=$tmpname&numatonce=$numatonce&refreshwait=$refreshwait";\r
+       header('HTTP/1.0 301 Moved Permanently');\r
+       header('Location: '.$url);\r
+       exit('<html><body>Moved Permanently</body></html>');\r
+}\r
+\r
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/sqlitealtertable.php b/sqlite/tags/sqlite0904/nucleus/sqlite/sqlitealtertable.php
new file mode 100644 (file)
index 0000000..f6cd8dd
--- /dev/null
@@ -0,0 +1,391 @@
+<?php
+    /****************************************
+    * SQLite-MySQL wrapper for Nucleus      *
+    *                           ver 0.9.0.2 *
+    * Written by Katsumi   License: GPL     *
+    ****************************************/
+
+function sqlite_createtable_query($commands,$tablename,$temptable,&$morequeries){
+       if ($temptable) $query="CREATE TEMPORARY TABLE $tablename (";
+       else $query="CREATE TABLE $tablename (";
+       $auto_increment=$first=true;
+       foreach($commands as $key => $value) {
+               if (strpos(strtolower($value),'auto_increment')==strlen($value)-14) $auto_increment=true;
+               $isint=preg_match('/int\(([0-9]*?)\)/i',$value);
+               $isint=$isint | preg_match('/tinyint\(([0-9]*?)\)/i',$value);
+               $value=preg_replace('/int\(([0-9]*?)\)[\s]+unsigned/i','int($1)',$value);
+               $value=preg_replace('/int\([0-9]*?\)[\s]+NOT NULL[\s]+auto_increment$/i',' INTEGER NOT NULL PRIMARY KEY',$value);
+               $value=preg_replace('/int\([0-9]*?\)[\s]+auto_increment$/i',' INTEGER PRIMARY KEY',$value);
+               if ($auto_increment) $value=preg_replace('/^PRIMARY KEY(.*?)$/i','',$value);
+               while (preg_match('/PRIMARY KEY[\s]*\((.*)\([0-9]+\)(.*)\)/i',$value)) // Remove '(100)' from 'PRIMARY KEY (`xxx` (100))'
+                       $value=preg_replace('/PRIMARY KEY[\s]*\((.*)\([0-9]+\)(.*)\)/i','PRIMARY KEY ($1 $2)',$value);
+               
+               // CREATE KEY queries for SQLite (corresponds to KEY 'xxxx'('xxxx', ...) of MySQL
+               if (preg_match('/^FULLTEXT KEY(.*?)$/i',$value,$matches)) {
+                       array_push($morequeries,'CREATE INDEX '.str_replace('('," ON $tablename (",$matches[1]));
+                       $value='';
+               } else if (preg_match('/^UNIQUE KEY(.*?)$/i',$value,$matches)) {
+                       array_push($morequeries,'CREATE UNIQUE INDEX '.str_replace('('," ON $tablename (",$matches[1]));
+                       $value='';
+               } else if (preg_match('/^KEY(.*?)$/i',$value,$matches)) {
+                       array_push($morequeries,'CREATE INDEX '.str_replace('('," ON $tablename (",$matches[1]));
+                       $value='';
+               }
+               
+               // Check if 'DEFAULT' is set when 'NOT NULL'
+               $uvalue=strtoupper($value);
+               if (strpos($uvalue,'NOT NULL')!==false && 
+                               strpos($uvalue,'DEFAULT')===false &&
+                               strpos($uvalue,'INTEGER NOT NULL PRIMARY KEY')===false) {
+                       if ($isint) $value.=" DEFAULT 0";
+                       else $value.=" DEFAULT ''";
+               }
+               
+               if ($value) {
+                       if ($first) $first=false;
+                       else $query.=',';
+                        $query.=' '.$value;
+               }
+       }
+       $query.=' )';
+       return $query;
+}
+
+function sqlite_renametable($commands,$dbhandle){
+       $carray=array();
+       foreach($commands as $command){
+               $command=_sqlite_divideByChar(array(' ',"\t","\r","\n"),$command);
+               if (count($command)!=3) return sqlite_ReturnWithError(htmlspecialchars("near '$command[0]': syntax error"));
+               if (strtoupper($command[1])!='TO') return sqlite_ReturnWithError(htmlspecialchars("near '$command[1]': syntax error"));
+               $carray[str_replace("'",'',$command[0])]=str_replace("'",'',$command[2]);
+       }
+       foreach($carray as $old=>$new){
+               if (!sqlite_copytable($old,$new,$dbhandle)) return false;
+               if (!sqlite_query($dbhandle,"DROP TABLE $old")) return sqlite_ReturnWithError(htmlspecialchars("fail to remove table, '$old'"));
+       }
+       sqlite_query($dbhandle,'VACUUM');
+       return true;
+}
+
+function sqlite_copytable($table,$newname,$dbhandle,$newtablearray=array()){
+       // Getting information from original table and create new table
+       $res = sqlite_query($dbhandle,"SELECT sql,name,type FROM sqlite_master WHERE tbl_name = '".$table."' ORDER BY type DESC");
+       if(!sqlite_num_rows($res)) return sqlite_ReturnWithError('no such table: '.$table);
+       if (count($newtablearray)) {
+               $query="CREATE TABLE $newname (".implode(',',$newtablearray).')';
+               if (!sqlite_query($dbhandle,$query)) return sqlite_ReturnWithError('Table could not be created.');
+       } else {
+               while($row=sqlite_fetch_array($res,SQLITE_ASSOC)){
+                       if (!preg_match('/^([^\(]*)[\s]([^\(\']+)[\s]*\(([\s\S]*)$/',$row['sql'],$m) &&
+                               !preg_match('/^([^\(]*)[\s]\'([^\(]+)\'[\s]*\(([\s\S]*)$/',$row['sql'],$m)) return sqlite_ReturnWithError('unknown error');
+                       if (!sqlite_query($dbhandle,$m[1]." '$newname' (".$m[3])) return sqlite_ReturnWithError('Table could not be created.');
+               }
+       }
+       // Copy the items
+       sqlite_query($dbhandle,'BEGIN');
+       $res=sqlite_unbuffered_query($dbhandle,"SELECT * FROM $table");
+       while($row=sqlite_fetch_array($res,SQLITE_ASSOC)){
+               $keys=$values=array();
+               foreach($row as $key=>$value) {
+                       if (count($newtablearray) && !isset($newtablearray[strtolower($key)])) continue;
+                       $keys[]="'$key'";
+                       $values[]="'".sqlite_escape_string($value)."'";
+               }
+               if (!sqlite_query($dbhandle,"INSERT INTO '$newname'(".implode(', ',$keys).') VALUES ('.implode(', ',$values).')')) {
+                       sqlite_query($dbhandle,'COMMIT');
+                       return false;
+               }
+       }
+       sqlite_query($dbhandle,'COMMIT');
+       $orgnum=sqlite_array_query($dbhandle,"SELECT COUNT(*) FROM $table");
+       $newnum=sqlite_array_query($dbhandle,"SELECT COUNT(*) FROM $newname");
+       if ($orgnum[0][0]!=$newnum[0][0]) return sqlite_ReturnWithError('Data transfer failed.');
+       return true;
+}
+function sqlite_altertable($table,$alterdefs,$dbhandle){
+       // Almost completely re-written in February 2008.
+       $table=str_replace("'",'',$table);
+
+       // Getting information from original table
+       $res = sqlite_query($dbhandle,"SELECT sql,name,type FROM sqlite_master WHERE tbl_name = '".$table."' ORDER BY type DESC");
+       if(!sqlite_num_rows($res)) return sqlite_ReturnWithError('no such table: '.$table);
+       $orgindex=array();
+       $row=sqlite_fetch_array($res,SQLITE_ASSOC); //table sql
+       $orgsql=$row['sql'];
+       while($row=sqlite_fetch_array($res,SQLITE_ASSOC)) $orgindex[strtolower($row['name'])]=$row['sql'];
+       if (!preg_match('/^[^\(]+\((.*)\);*$/',$orgsql,$m)) return sqlite_ReturnWithError('unknown error');
+       $orgtablearray=array();
+       foreach(_sqlite_divideByChar(',',$orgtable=$m[1]) as $value){
+               if (!preg_match('/^([^\s\']+)[\s]+([\s\S]*)$/',$value,$m) &&
+                       !preg_match('/^\'([^\']+)\'[\s]+([\s\S]*)$/',$value,$m)) return sqlite_ReturnWithError('unknown error');
+               $orgtablearray[strtolower($m[1])]="'$m[1]' $m[2]";
+       }
+       $desttablearray=$orgtablearray;
+       $destindex=$orgindex;
+
+       // Convert table
+       foreach(_sqlite_divideByChar(',',$alterdefs) as $def){
+               $def=_sqlite_divideByChar(array(' ',"\t","\r","\n"),trim($def));
+               if (($c=count($def))<2) return sqlite_ReturnWithError('near "'.htmlspecialchars($def[0]).'": syntax error');
+               // Check if FIRST/AFTER is used.
+               $first=$after=false;
+               if (strtoupper($def[$c-1])=='FIRST') {
+                       $first=true;
+                       array_pop($def);
+               } elseif (strtoupper($def[$c-2])=='AFTER') {
+                       $after=strtolower(str_replace("'",'',array_pop($def)));
+                       array_pop($def);
+               }
+               // Ignore CONSTRAINT and COLUMN
+               $method=strtoupper(array_shift($def));
+               switch(strtoupper($def[0])){
+               case 'CONSTRAINT': // delete two
+                       array_shift($def);
+               case 'COLUMN': // delete one
+                       array_shift($def);
+               default:
+                       break;
+               }
+               // The main routine of this function follow.
+               switch($method){
+               case 'MODIFY':
+               case 'ALTER':
+                       if (error_reporting() & E_NOTICE) sqlite_ReturnWithError('ALTER/MODIFY is not supported');
+                       break;
+               case 'DROP':
+               case 'CHANGE':
+                       if (strtoupper($def[0])=='INDEX') {
+                               // delete index
+                               unset($destindex[strtolower($def[1])]);
+                       } else {
+                               // delete field
+                               unset($desttablearray[strtolower(str_replace("'",'',$def[0]))]);
+                       }
+                       if ($method!='CHANGE') break;
+               case 'ADD':
+                       $field=array_shift($def);
+                       switch($submedthod=strtoupper($field)){
+                       case 'UNIQUE':
+                       case 'PRIMARY':
+                       case 'FOREIGN':
+                       case 'INDEX':
+                       case 'FULLTEXT':
+                               // add index
+                               if (strtoupper($index=array_shift($def))=='KEY') $index=array_shift($def);
+                               $def=implode(' ',$def);
+                               $destindex[strtolower(str_replace("'",'',$index))]=
+                                       ($submedthod=='UNIQUE'?'CREATE UNIQUE INDEX ':'CREATE INDEX ').
+                                       "$index ON '$table' $def";
+                               break;
+                       default:
+                               // add field
+                               $field=str_replace("'",'',$field);
+                               if ($first) {
+                                       $desttablearray=array_merge(
+                                               array(strtolower($field)=>"'$field' ".implode(' ',$def)),
+                                               $desttablearray);
+                               } elseif($after) {
+                                       $temp=$desttablearray;
+                                       $desttablearray=array();
+                                       $ok=false;
+                                       foreach($temp as $key=>$value) {
+                                               $desttablearray[$key]=$value;
+                                               if ($ok || $key!=$after) continue;
+                                               $ok=true;
+                                               $desttablearray[strtolower($field)]="'$field' ".implode(' ',$def);
+                                       }
+                                       if (!$ok) {
+                                               $desttablearray[strtolower($field)]="'$field' ".implode(' ',$def);
+                                               if (error_reporting() & E_NOTICE) sqlite_ReturnWithError(htmlspecialchars("Field '$after' not found."));
+                                       }
+                               } else {
+                                       $desttablearray[strtolower($field)]="'$field' ".implode(' ',$def);
+                               }
+                       }
+                       break;
+               default:
+                       return sqlite_ReturnWithError('near "'.htmlspecialchars($method).'": syntax error');
+               }
+       }
+
+       // Create temporary table that has the modified field and copy the items into it.
+       if (function_exists('microtime')) $tmptable='t'.str_replace(array(' ','.'),'',microtime());
+       else $tmptable = 't'.rand(0,999999).time();
+       if (!sqlite_copytable($table,$tmptable,$dbhandle,$desttablearray)) return false;
+
+       // New temporary table sccusfully made.
+       // So, delete the original table and copy back the temporary table to one with original name.
+       sqlite_query("DROP TABLE $table",$dbhandle);
+       if (sqlite_copytable($tmptable,$table,$dbhandle)) sqlite_query("DROP TABLE $tmptable",$dbhandle);
+
+       // Add the indexes, finally.
+       foreach($destindex as $index) sqlite_query($index,$dbhandle);
+       sqlite_query($dbhandle,'VACUUM');
+       return true;
+}
+function sqlite_showKeysFrom($tname,$dbhandle) {
+       // This function is for supporing 'SHOW KEYS FROM' and 'SHOW INDEX FROM'.
+       // For making the same result as obtained by MySQL, temporary table is made.
+       if (preg_match('/^([^\s]+)\s+LIKE\s+\'([^\']+)\'$/i',$tname,$m)) list($m,$tname,$like)=$m;
+       $tname=str_replace("'",'',$tname);
+       
+       // Create a temporary table for making result
+       if (function_exists('microtime')) $tmpname='t'.str_replace('.','',str_replace(' ','',microtime()));
+       else $tmpname = 't'.rand(0,999999).time();
+       sqlite_query($dbhandle,"CREATE TEMPORARY TABLE $tmpname ('Table', 'Non_unique', 'Key_name', 'Seq_in_index',".
+               " 'Column_name', 'Collation', 'Cardinality', 'Sub_part', 'Packed', 'Null', 'Index_type', 'Comment')"); 
+       
+       // First, get the sql query when the table created
+       $res=sqlite_query($dbhandle,"SELECT sql FROM sqlite_master WHERE tbl_name = '$tname' ORDER BY type DESC");
+       $a=nucleus_mysql_fetch_assoc($res);
+       $tablesql=$a['sql'];
+       
+       // Check if each columns are unique
+       $notnull=array();
+       foreach(_sqlite_divideByChar(',',substr($tablesql,strpos($tablesql,'(')+1)) as $value) {
+               $name=str_replace("'",'',substr($value,0,strpos($value,' ')));
+               if (strpos(strtoupper($value),'NOT NULL')!==false) $notnull[$name]='';
+               else $notnull[$name]='YES';
+       }
+       
+       // Get the primary key (and check if it is unique???).
+       if (preg_match('/[^a-zA-Z_\']([\S]+)[^a-zA-Z_\']+INTEGER NOT NULL PRIMARY KEY/i',$tablesql,$matches)) {
+               $pkey=str_replace("'",'',$matches[1]);
+               $pkeynull='';
+       } else if (preg_match('/[^a-zA-Z_\']([\S]+)[^a-zA-Z_\']+INTEGER PRIMARY KEY/i',$tablesql,$matches)) {
+               $pkey=str_replace("'",'',$matches[1]);
+               $pkeynull='YES';
+       } else if (preg_match('/PRIMARY KEY[\s]*?\(([^\)]+)\)/i',$tablesql,$matches)) {
+               $pkey=null;// PRIMARY KEY ('xxx'[,'xxx'])
+               foreach(explode(',',$matches[1]) as $key=>$value) {
+                       $value=str_replace("'",'',trim($value));
+                       $key++;
+                       $cardinality=nucleus_mysql_num_rows(sqlite_query($dbhandle,"SELECT '$value' FROM '$tname'"));
+                       sqlite_query($dbhandle,"INSERT INTO $tmpname ('Table', 'Non_unique', 'Key_name', 'Seq_in_index',".
+                               " 'Column_name', 'Collation', 'Cardinality', 'Sub_part', 'Packed', 'Null', 'Index_type', 'Comment')".
+                               " VALUES ('$tname', '0', 'PRIMARY', '$key',".
+                               " '$value', 'A', '$cardinality', null, null, '', 'BTREE', '')"); 
+               }
+       } else $pkey=null;
+       
+       // Check the index.
+       $res=sqlite_query($dbhandle,"SELECT sql,name FROM sqlite_master WHERE type = 'index' and tbl_name = '$tname' ORDER BY type DESC");
+       while ($a=nucleus_mysql_fetch_assoc($res)) {
+               if (!($sql=$a['sql'])) {// Primary key
+                       if ($pkey && strpos(strtolower($a['name']),'autoindex')) {
+                               $cardinality=nucleus_mysql_num_rows(sqlite_query($dbhandle,"SELECT $pkey FROM '$tname'"));
+                               sqlite_query($dbhandle,"INSERT INTO $tmpname ('Table', 'Non_unique', 'Key_name', 'Seq_in_index',".
+                                       " 'Column_name', 'Collation', 'Cardinality', 'Sub_part', 'Packed', 'Null', 'Index_type', 'Comment')".
+                                       " VALUES ('$tname', '0', 'PRIMARY', '1',".
+                                       " '$pkey', 'A', '$cardinality', null, null, '$pkeynull', 'BTREE', '')"); 
+                               $pkey=null;
+                       }
+               } else {// Non-primary key
+                       if (($name=str_replace("'",'',$a['name'])) && preg_match('/\(([\s\S]+)\)/',$sql,$matches)) {
+                       if (isset($like) && $name!=$like) continue;
+                               foreach(explode(',',$matches[1]) as $key=>$value) {
+                                       $columnname=str_replace("'",'',$value);
+                                       if (strpos(strtoupper($sql),'CREATE UNIQUE ')===0) $nonunique='0';
+                                       else $nonunique='1';
+                                       $cardinality=nucleus_mysql_num_rows(sqlite_query($dbhandle,"SELECT $columnname FROM '$tname'"));
+                                       sqlite_query($dbhandle,"INSERT INTO $tmpname ('Table', 'Non_unique', 'Key_name', 'Seq_in_index',".
+                                               " 'Column_name', 'Collation', 'Cardinality', 'Sub_part', 'Packed', 'Null', 'Index_type', 'Comment')".
+                                               " VALUES ('$tname', '$nonunique', '$name', '".(string)($key+1)."',".
+                                               " '$columnname', 'A', '$cardinality', null, null, '$notnull[$columnname]', 'BTREE', '')"); 
+                               }
+                       }
+               }
+       }
+       if ($pkey) { // The case that the key (index) is not defined.
+               $cardinality=nucleus_mysql_num_rows(sqlite_query($dbhandle,"SELECT $pkey FROM '$tname'"));
+               sqlite_query($dbhandle,"INSERT INTO $tmpname ('Table', 'Non_unique', 'Key_name', 'Seq_in_index',".
+                       " 'Column_name', 'Collation', 'Cardinality', 'Sub_part', 'Packed', 'Null', 'Index_type', 'Comment')".
+                       " VALUES ('$tname', '0', 'PRIMARY', '1',".
+                       " '$pkey', 'A', '$cardinality', null, null, '$pkeynull', 'BTREE', '')"); 
+               $pkey=null;
+       }
+       
+       // return the final query to show the keys in MySQL style (using temporary table).
+       return "SELECT * FROM $tmpname";
+}
+function sqlite_showFieldsFrom($tname,$dbhandle){
+       // This function is for supporing 'SHOW FIELDS FROM' and 'SHOW COLUMNS FROM'.
+       // For making the same result as obtained by MySQL, temporary table is made.
+       if (preg_match('/^([^\s]+)\s+LIKE\s+\'([^\']+)\'$/i',$tname,$m)) list($m,$tname,$like)=$m;
+       $tname=str_replace("'",'',$tname);
+       
+       // First, get the sql query when the table created
+       $res=sqlite_query($dbhandle,"SELECT sql FROM sqlite_master WHERE tbl_name = '$tname' ORDER BY type DESC");
+       $a=nucleus_mysql_fetch_assoc($res);
+       $tablesql=trim($a['sql']);
+       if (preg_match('/^[^\(]+\(([\s\S]*?)\)$/',$tablesql,$matches)) $tablesql=$matches[1];
+       $tablearray=array();
+       foreach(_sqlite_divideByChar(',',$tablesql) as $value) {
+               $value=trim($value);
+               if ($i=strpos($value,' ')) {
+                       $name=str_replace("'",'',substr($value,0,$i));
+                       $value=trim(substr($value,$i));
+                       if (substr($value,-1)==',') $value=substr($value,strlen($value)-1);
+                       $tablearray[$name]=$value;
+               }
+       }
+       
+       // Check if INDEX has been made for the parameter 'MUL' in 'KEY' column
+       $multi=array();
+       $res=sqlite_query($dbhandle,"SELECT name FROM sqlite_master WHERE type = 'index' and tbl_name = '$tname' ORDER BY type DESC");
+       while ($a=nucleus_mysql_fetch_assoc($res)) $multi[str_replace("'",'',$a['name'])]='MUL';
+       
+       // Create a temporary table for making result
+       if (function_exists('microtime')) $tmpname='t'.str_replace('.','',str_replace(' ','',microtime()));
+       else $tmpname = 't'.rand(0,999999).time();
+       sqlite_query($dbhandle,"CREATE TEMPORARY TABLE $tmpname ('Field', 'Type', 'Null', 'Key', 'Default', 'Extra')"); 
+       
+       // Check the table
+       foreach($tablearray as $field=>$value) {
+               if (strtoupper($field)=='PRIMARY') continue;//PRIMARY KEY('xx'[,'xx'])
+               if (isset($like) && $field!=$like) continue;
+               $uvalue=strtoupper($value.' ');
+               $key=(string)$multi[$field];
+               if ($uvalue=='INTEGER NOT NULL PRIMARY KEY ' || $uvalue=='INTEGER PRIMARY KEY ') {
+                       $key='PRI';
+                       $extra='auto_increment';
+               } else $extra='';
+               if ($i=strpos($uvalue,' ')) {
+                       $type=substr($value,0,$i);
+                       if (strpos($type,'(') && ($i=strpos($value,')')))
+                               $type=substr($value,0,$i+1);
+               } else $type='';
+               if (strtoupper($type)=='INTEGER') $type='int(11)';
+               if (strpos($uvalue,'NOT NULL')===false) $null='YES';
+               else {
+                       $null='';
+                       $value=preg_replace('/NOT NULL/i','',$value);
+                       $uvalue=strtoupper($value);
+               }
+               if ($i=strpos($uvalue,'DEFAULT')) {
+                       $default=trim(substr($value,$i+7));
+                       if (strtoupper($default)=='NULL') {
+                               $default="";
+                               $setdefault="";
+                       } else {
+                               if (substr($default,0,1)=="'") $default=substr($default,1,strlen($default)-2);
+                               $default="'".$default."',";
+                               $setdefault="'Default',";
+                       }
+               } else if ($null!='YES' && $extra!='auto_increment') {
+                       if (strpos(strtolower($type),'int')===false) $default="'',";
+                       else $default="'0',";
+                       $setdefault="'Default',";
+               } else {
+                       $default="";
+                       $setdefault="";
+               }
+               sqlite_query($dbhandle,"INSERT INTO '$tmpname' ('Field', 'Type', 'Null', 'Key', $setdefault 'Extra')".
+                       " VALUES ('$field', '$type', '$null', '$key', $default '$extra')");
+       }
+       
+       // return the final query to show the keys in MySQL style (using temporary table).
+       return "SELECT * FROM $tmpname";
+}
+
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/sqliteconfig.php b/sqlite/tags/sqlite0904/nucleus/sqlite/sqliteconfig.php
new file mode 100644 (file)
index 0000000..4b556b8
--- /dev/null
@@ -0,0 +1,14 @@
+<?php
+$SQLITECONF=array();
+
+// Detabase definition.
+// Modify here if you use another file for database.
+$SQLITECONF['DBFILENAME']=dirname(__FILE__).'/.dbsqlite';
+
+// Options
+$SQLITECONF['DEBUGMODE']=false;
+$SQLITECONF['DEBUGREPORT']=false;
+$SQLITECONF['MEASURESPEED']=false;
+$SQLITECONF['INITIALIZE']=array('PRAGMA short_column_names=1;');
+
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/nucleus/sqlite/sqlitequeryfunctions.php b/sqlite/tags/sqlite0904/nucleus/sqlite/sqlitequeryfunctions.php
new file mode 100644 (file)
index 0000000..244faf3
--- /dev/null
@@ -0,0 +1,890 @@
+<?php
+    /****************************************
+    * SQLite-MySQL wrapper for Nucleus      *
+    *                           ver 0.9.0.1 *
+    * Written by Katsumi   License: GPL     *
+    ****************************************/
+
+// Register user-defined functions used in SQL query.
+// The SQLite_QueryFunctions object is created to register SQLite queries.
+$SQLITECONF['object']=new SQLite_Functions;
+// After the registration, the object is not required any more.
+unset($SQLITECONF['object']);
+
+
+// The class for SQLite user functions
+class SQLite_Functions {
+
+// Constructor is used for the registration of user-defined functions of SQLite
+function SQLite_Functions(){
+       global $SQLITE_DBHANDLE;
+       foreach($this as $key=>$value){
+               $key=strtoupper($key);
+               if (substr($key,0,7)!='DEFINE_') continue;
+               $key=substr($key,7);
+               if (substr($value,0,7)=='sqlite_') $value=array('SQLite_Functions',$value);
+               @sqlite_create_function($SQLITE_DBHANDLE,$key,$value);
+       }
+}
+
+var $define_ASCII='ord';
+
+var $define_BIN='decbin';
+
+var $define_BIT_LENGTH='sqlite_userfunc_BIT_LENGTH';
+function sqlite_userfunc_BIT_LENGTH($p1){
+       return strlen($p1)*8;
+}
+
+var $define_CHAR='sqlite_userfunc_CHAR';
+function sqlite_userfunc_CHAR(){
+       if (!($lastnum=func_num_args())) return null;
+       $args=&func_get_args();
+       $ret='';
+       for ($i=0;$i<$lastnum;$i++) {
+               if ($args[$i]!==null) $ret.=chr($args[$i]);
+       }
+       return $ret;
+}
+
+var $define_CHAR_LENGTH='sqlite_userfunc_CHAR_LENGTH';
+function sqlite_userfunc_CHAR_LENGTH($str){
+       if (function_exists('mb_strlen')) return mb_strlen($str);
+       return strlen($str);
+}
+
+var $define_CONCAT_WS='sqlite_userfunc_CONCAT_WS';
+function sqlite_userfunc_CONCAT_WS(){
+       if (($lastnum=func_num_args())<2) return null;
+       $args=&func_get_args();
+       if ($args[0]===null) return null;
+       $ret='';
+       for ($i=1;$i<$lastnum;$i++) {
+               if ($args[$i]===null) continue;
+               if ($ret) $ret.=$args[0];
+               $ret.=(string)($args[$i]);
+       }
+       return $ret;
+}
+
+var $define_CONV='sqlite_userfunc_CONV';
+function sqlite_userfunc_CONV($p1,$p2,$p3){
+       $t36='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+       $p1=strtoupper(trim((string)$p1));
+       if ($p3<0 && substr($p1,0,1)=='-') {
+               $sign='-';
+               $p1=substr($p1,1);
+       } else $sign='';
+       $p3=abs($p3);
+       $v=0;
+       for ($i=0;$i<strlen($p1);$i++) $v=$v*$p2+strpos($t36,$p1[$i]);
+       if (!$v) return '0';
+       $ret='';
+       while ($v) {
+               $i=$v % $p3;
+               $ret=$t36[$i].$ret;
+               $v=($v-$i)/$p3;
+       }
+       return $sign.$ret;
+}
+
+var $define_ELT='sqlite_userfunc_ELT';
+function sqlite_userfunc_ELT(){
+       if (($lastnum=func_num_args())<2) return null;
+       $args=&func_get_args();
+       if ($args[0]<1 || $lastnum<$args[0]) return null;
+       return $args[$args[0]];
+}
+
+var $define_EXPORT_SET='sqlite_userfunc_EXPORT_SET';
+function sqlite_userfunc_EXPORT_SET($p1,$p2,$p3,$p4=',',$p5=64){
+       if ($p1<2147483648) $p1=decbin($p1);
+       else $p1=decbin($p1/2147483648).decbin($p1 % 2147483648);
+       $p1=substr(decbin($p1).str_repeat('0',$p5),0,$p5);
+       $p1=str_replace(array('1','0'),array($p2.$p4,$p3.$p4),$p1);
+       return substr($p1,0,strlen($p1)-strlen($p4));
+}
+
+var $define_FIELD='sqlite_userfunc_FIELD';
+function sqlite_userfunc_FIELD(){
+       if (($lastnum=func_num_args())<2) return null;
+       $args=&func_get_args();
+       for ($i=1;$i<$lastnum;$i++) if ($args[0]==$args[$i]) return $i;
+       return 0;
+}
+
+var $define_HEX='sqlite_userfunc_HEX';
+function sqlite_userfunc_HEX($p1){
+       if (is_numeric($p1)) return dechex ($p1);
+       $p1=(string)$p1;
+       $ret='';
+       for($i=0;$i<strlen($p1);$i++) $ret.=substr('0'.dechex($p1[$i]),-2);
+       return $ret;
+}
+
+var $define_INSERT='sqlite_userfunc_INSERT';
+function sqlite_userfunc_INSERT($p1,$p2,$p3,$p4){
+       if (function_exists('mb_substr')) return mb_substr($p1,0,$p2-1).$p4.mb_substr($p1,$p2+$p3-1);
+       return substr($p1,0,$p2-1).$p4.substr($p1,$p2+$p3-1);
+}
+
+var $define_LOCATE='sqlite_userfunc_LOCATE';
+function sqlite_userfunc_LOCATE($p1,$p2,$p3=1){
+       if (substr($p1,1)=='_') $p2='-'.$p2;
+       else $p2='_'.$p2;
+       if (function_exists('mb_strpos')) return (int)mb_strpos($p2,$p1,$p3);
+       if (($p=strpos(substr($p2,$p3),$p1))===false) return 0;
+       return $p+$p3;
+}
+
+var $define_INSTR='sqlite_userfunc_INSTR';
+function sqlite_userfunc_INSTR($p1,$p2){
+       return SQLite_Functions::sqlite_userfunc_LOCATE($p2,$p1);
+}
+
+var $define_LCASE='sqlite_userfunc_LOWER';
+var $define_LOWER='sqlite_userfunc_LOWER';
+function sqlite_userfunc_LOWER($p1){
+       if (function_exists('mb_strtolower')) return mb_strtolower($p1);
+       return strtolower($p1);
+}
+
+var $define_LEFT='sqlite_userfunc_LEFT';
+function sqlite_userfunc_LEFT($p1,$p2){
+       if (function_exists('mb_substr')) return mb_substr($p1,0,$p2);
+       return substr($p1,0,$p2);
+}
+
+var $define_LENGTH='strlen';
+var $define_OCTET_LENGTH='strlen';
+
+var $define_LOAD_FILE='sqlite_userfunc_LOAD_FILE';
+function sqlite_userfunc_LOAD_FILE($p1){
+       if (!file_exists($p1)) return null;
+       if (!is_array($a=@file($p1))) return null;
+       $ret='';
+       foreach($a as $value) $ret.=$value;
+       return $ret;
+}
+
+var $define_LPAD='sqlite_userfunc_LPAD';
+function sqlite_userfunc_LPAD($p1,$p2,$p3){
+       return substr(str_repeat($p3,$p2/strlen($p3)).$p1,0-$p2);
+}
+
+var $define_LTRIM='ltrim';
+
+var $define_MAKE_SET='sqlite_userfunc_MAKE_SET';
+function sqlite_userfunc_MAKE_SET($p1,$p2,$p3){
+       if (($lastnum=func_num_args())<2) return null;
+       $args=&func_get_args();
+       $ret='';
+       if ($args[0]<2147483648) $bits=decbin($args[0]);
+       else $bits=decbin($args[0]/2147483648).decbin($args[0] % 2147483648);
+       for ($i=1;$i<$lastnum;$i++) {
+               if ($bits[strlen($bits)-$i]=='1' && $args[$i]) {
+                       if ($ret) $ret.=',';
+                       $ret.=$args[$i];
+               }
+       }
+       return 0;
+}
+
+var $define_MID='sqlite_userfunc_SUBSTRING';
+var $define_SUBSTRING='sqlite_userfunc_SUBSTRING';
+function sqlite_userfunc_SUBSTRING($p1,$p2,$p3=null){
+       $p2--;
+       if (function_exists('mb_substr')) {
+               if ($p3) return mb_substr($p1,$p2,$p3);
+               return mb_substr($p1,$p2);
+       }
+       if ($p3) return substr($p1,$p2,$p3);
+       return substr($p1,$p2);
+}
+
+var $define_OCT='sqlite_userfunc_OCT';
+function sqlite_userfunc_OCT($p1){
+       if ($p1===null) return null;
+       return SQLite_Functions::sqlite_userfunc_CONV($p1,10,8);
+}
+
+var $define_ORD='sqlite_userfunc_ORD';
+function sqlite_userfunc_ORD($p1){
+       if (function_exists('mb_substr')) $p1=mb_substr($p1,0,1);
+       else $p1=substr($p1,0,1);
+       $ret=0;
+       for ($i=0;$i<strlen($p1);$i++) $ret=$ret*256+ord($p1[$i]);
+       return $ret;
+}
+
+var $define_QUOTE='sqlite_userfunc_QUOTE';
+function sqlite_userfunc_QUOTE($p1){
+       if ($p1===null) return 'NULL';
+       return str_replace(array("'","\\","\x1A"),array("\\'","\\\\","\\z"),$p1);
+}
+
+var $define_REPEAT='str_repeat';
+
+var $define_REVERSE='sqlite_userfunc_REVERSE';
+function sqlite_userfunc_REVERSE($p1){
+       if (function_exists('mb_strlen')) {
+               $ret='';
+               for ($i=mb_strlen($p1)-1;0<=$i;$i++) $ret.=mb_substr($p1,$i,1);
+               return $ret;
+       }
+       return strrev($p1);
+}
+
+var $define_RIGHT='sqlite_userfunc_RIGHT';
+function sqlite_userfunc_RIGHT($p1){
+       if (function_exists('mb_substr')) return mb_substr($p1,0-$p2);
+       return substr($p1,0-$p2);
+}
+
+var $define_RPAD='sqlite_userfunc_RPAD';
+function sqlite_userfunc_RPAD($p1,$p2,$p3){
+       return substr($p1.str_repeat($p3,$p2/strlen($p3)),0,$p2);
+}
+
+var $define_RTRIM='rtrim';
+var $define_SOUNDEX='soundex';
+
+var $define_SPACE='sqlite_userfunc_SPACE';
+function sqlite_userfunc_SPACE($p1){
+       return str_repeat(' ',$p1);
+}
+
+var $define_SUBSTRING_INDEX='sqlite_userfunc_SUBSTRING_INDEX';
+function sqlite_userfunc_SUBSTRING_INDEX($p1,$p2,$p3){
+       if (!is_array($a=explode($p2,$p1))) return null;
+       $ret='';
+       if (0<$p3) {
+               for ($i=0;$i<$p3;$i++) {
+                       if ($ret) $ret.=$p2;
+                       $ret.=$a[$i];
+               }
+       } else {
+               for ($i=0;$i<0-$p3;$i++) {
+                       if ($ret) $ret.=$p2;
+                       $ret.=$a[count($a)-1-$i];
+               }
+       }
+       return $ret;
+}
+
+var $define_TRIM='sqlite_userfunc_TRIM';
+function sqlite_userfunc_TRIM($p1,$p2=null,$p3=null){
+       if (!$p2 && !$p3) return trim($p1);
+       if (!$p2) $p2=' ';
+       switch(strtoupper($p1)){
+               case 'BOTH':
+                       while (strpos($p3,$p2)===0) $p3=substr($p3,strlen($p2));
+               case 'TRAILING':
+                       while (strrpos($p3,$p2)===strlen($p3)-strlen($p2)-1) $p3=substr($p3,0,strlen($p3)-strlen($p2));
+                       break;
+               case 'LEADING':
+                       while (strpos($p3,$p2)===0) $p3=substr($p3,strlen($p2));
+                       break;
+       }
+       return $p2;
+}
+
+var $define_UCASE='sqlite_userfunc_UPPER';
+var $define_UPPER='sqlite_userfunc_UPPER';
+function sqlite_userfunc_UPPER($p1){
+       if (function_exists('mb_strtoupper')) return mb_strtoupper($p1);
+       return strtoupper($p1);
+}
+
+var $define_ACOS='acos';
+var $define_ASIN='asin';
+
+var $define_ATAN='sqlite_userfunc_ATAN';
+function sqlite_userfunc_ATAN($p1,$p2=null){
+       if (!$p2) return atan($p1);
+       if ($p1>0 && $p2>0) return atan($p1/$p2);
+       else if ($p1>0 && $p2<0) return pi-atan(-$p1/$p2);
+       else if ($p1<0 && $p2<0) return pi+atan($p1/$p2);
+       else if ($p1<0 && $p2>0) return 2*pi-atan(-$p1/$p2);
+       else return 0;
+}
+
+var $define_CEIL='ceil';
+var $define_CEILING='ceil';
+var $define_COS='cos';
+
+var $define_COT='sqlite_userfunc_COT';
+function sqlite_userfunc_COT($p1){
+       return 1/tan($p1);
+}
+
+var $define_CRC32='crc32';
+
+var $define_DEGREES='sqlite_userfunc_DEGREES';
+function sqlite_userfunc_DEGREES($p1){
+       return ($p1/pi)*180;
+}
+
+var $define_EXP='exp';
+var $define_FLOOR='floor';
+var $define_GREATEST='max';
+var $define_MAX='max';
+var $define_LEAST='min';
+var $define_MIN='min';
+var $define_ln='log';
+
+var $define_log='sqlite_userfunc_LOG';
+function sqlite_userfunc_LOG($p1,$p2=null){
+       if ($p2) return log($p1)/log($p2);
+       return log($p1);
+}
+
+var $define_log2='sqlite_userfunc_LOG2';
+function sqlite_userfunc_LOG2($p1){
+       return log($p1)/log(2);
+}
+
+var $define_log10='log10';
+
+var $define_MOD='sqlite_userfunc_MOD';
+function sqlite_userfunc_MOD($p1,$p2){
+       return $p1 % $p2;
+}
+
+var $define_PI='sqlite_userfunc_PI';
+function sqlite_userfunc_PI(){
+       return pi;
+}
+
+var $define_POW='sqlite_userfunc_POW';
+var $define_POWER='sqlite_userfunc_POW';
+function sqlite_userfunc_POW($p1,$p2){
+       return pow($p1,$p2);
+}
+
+var $define_RADIANS='sqlite_userfunc_RADIANS';
+function sqlite_userfunc_RADIANS($p1){
+       return ($p1/180)*pi;
+}
+
+var $define_RAND='sqlite_userfunc_RAND';
+function sqlite_userfunc_RAND($p1=null){
+       if ($p1) srand($p1);
+       return rand(0,1073741823)/1073741824;
+}
+
+var $define_SIGN='sqlite_userfunc_SIGN';
+function sqlite_userfunc_SIGN($p1){
+       if ($p1>0) return 1;
+       else if ($p1<0) return -1;
+       return 0;
+}
+
+var $define_SIN='sin';
+var $define_SQRT='sqrt';
+var $define_TAN='tan';
+
+var $define_TRUNCATE='sqlite_userfunc_TRUNCATE';
+function sqlite_userfunc_TRUNCATE($p1,$p2){
+       $p2=pow(10,$p2);
+       return ((int)($p1*$p2))/$p2;
+}
+
+var $define_FORMAT='sqlite_userfunc_FORMAT';
+function sqlite_userfunc_FORMAT($p1,$p2){
+       return number_format($p1, $p2, '.', ',');
+}
+
+var $define_INET_ATON='sqlite_userfunc_INET_ATON';
+function sqlite_userfunc_INET_ATON($p1){
+       $a=explode('.',$p1);
+       return (($a[0]*256+$a[1])*256+$a[2])*256+$a[3];
+}
+
+var $define_INET_NTOA='sqlite_userfunc_INET_NTOA';
+function sqlite_userfunc_INET_NTOA($p1){
+       $a=array();
+       for ($i=0;$i<4;$i++){
+               $a[$i]=(string)($p1 % 256);
+               $p1=(int)($p1/256);
+       }
+       return $a[3].'.'.$a[2].'.'.$a[1].'.'.$a[0];
+}
+
+var $define_MD5='md5';
+
+
+var $define_CURDATE='sqlite_userfunc_CURDATE';
+var $define_CURRENT_DATE='sqlite_userfunc_CURDATE';
+function sqlite_userfunc_CURDATE(){
+       return date('Y-m-d');
+}
+
+var $define_CURTIME='sqlite_userfunc_CURTIME';
+var $define_CURRENT_TIME='sqlite_userfunc_CURTIME';
+function sqlite_userfunc_CURTIME(){
+       return date('H:i:s');
+}
+
+var $define_CURRENT_TIMESTAMP='sqlite_userfunc_NOW';
+var $define_LOCALTIME='sqlite_userfunc_NOW';
+var $define_LOCALTIMESTAMP='sqlite_userfunc_NOW';
+var $define_SYSDATE='sqlite_userfunc_NOW';
+function sqlite_userfunc_NOW(){
+       return date('Y-m-d H:i:s');
+}
+
+var $define_DATE_FORMAT='sqlite_userfunc_DATE_FORMAT';
+var $define_TIME_FORMAT='sqlite_userfunc_DATE_FORMAT';
+function sqlite_userfunc_DATE_FORMAT($p1,$p2){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       $func='if ($matches=="%") return "%";';
+       $func='return date($matches,'.$t.');';
+       return preg_replace_callback ('/%([%a-zA-Z])/',create_function('$matches',$func), $p2);
+}
+
+var $define_DAYNAME='sqlite_userfunc_DAYNAME';
+function sqlite_userfunc_DAYNAME($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('l',$t);
+}
+
+var $define_DAYOFWEEK='sqlite_userfunc_DAYOFWEEK';
+function sqlite_userfunc_DAYOFWEEK($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('w',$t)+1;
+}
+
+var $define_DAYOFYEAR='sqlite_userfunc_DAYOFYEAR';
+function sqlite_userfunc_DAYOFYEAR($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('z',$t);
+}
+
+var $define_EXTRACT='sqlite_userfunc_EXTRACT';
+function sqlite_userfunc_EXTRACT($p1,$p2){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p2,$yr,$mt,$dy,$hr,$mn,$sc);
+       switch(strtoupper($p1)) {
+               case'SECOND': // SECONDS 
+                       return $sc;
+               case'MINUTE': // MINUTES 
+                       return $m;
+               case'HOUR': // HOURS 
+                       return $hr;
+               case'MONTH': // MONTHS 
+                       return $mt;
+               case'YEAR': // YEARS 
+                       return $y;
+               case'MINUTE_SECOND': // 'MINUTES:SECONDS' 
+                       return date('is',$t);
+               case'HOUR_MINUTE': // 'HOURS:MINUTES' 
+                       return date('Hi',$t);
+               case'DAY_HOUR': // 'DAYS HOURS' 
+                       return date('dH',$t);
+               case'YEAR_MONTH': // 'YEARS-MONTHS' 
+                       return date('Ym',$t);
+               case'HOUR_SECOND': // 'HOURS:MINUTES:SECONDS' 
+                       return date('Hs',$t);
+               case'DAY_MINUTE': // 'DAYS HOURS:MINUTES' 
+                       return date('di',$t);
+               case'DAY_SECOND': // 'DAYS HOURS:MINUTES:SECONDS' 
+                       return date('ds',$t);
+               case'DAY': // DAYS 
+               default:
+                       return $dy;
+       }
+}
+
+var $define_FROM_DAYS='sqlite_userfunc_FROM_DAYS';
+function sqlite_userfunc_FROM_DAYS($p1){
+       return date('Y-m-d',($p1-719528)*86400);
+}
+
+var $define_FROM_UNIXTIME='sqlite_userfunc_FROM_UNIXTIME';
+function sqlite_userfunc_FROM_UNIXTIME($p1,$p2=null){
+       if ($p2) return sqlite_userfunc_DATE_FORMAT($p1,$p2);
+       return date('Y-m-d H:i:s',$p1);
+}
+
+var $define_HOUR='sqlite_userfunc_HOUR';
+function sqlite_userfunc_HOUR($p1){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return $hr;
+}
+
+var $define_MINUTE='sqlite_userfunc_MINUTE';
+function sqlite_userfunc_MINUTE($p1){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return $mn;
+}
+
+var $define_MONTHNAME='sqlite_userfunc_MONTHNAME';
+function sqlite_userfunc_MONTHNAME($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('F',$t);
+}
+
+
+var $define_PERIOD_ADD='sqlite_userfunc_PERIOD_ADD';
+function sqlite_userfunc_PERIOD_ADD($p1,$p2){
+       $y=(int)($p1/100);
+       $m=$p1-$y*100;
+       $t=mktime(0,0,0,$m+$p2,1,$y, -1);
+       return date('Ym',$t);
+}
+
+var $define_PERIOD_DIFF='sqlite_userfunc_PERIOD_DIFF';
+function sqlite_userfunc_PERIOD_DIFF($p1,$p2){
+       $y1=(int)($p1/100);
+       $m1=$p1-$y1*100;
+       $y2=(int)($p2/100);
+       $m2=$p1-$y2*100;
+       $t1=mktime(0,0,0,$m1,1,$y1, -1);
+       $t2=mktime(0,0,0,$m2,1,$y2, -1);
+       $y1=date('Y',$t1);
+       $y2=date('Y',$t2);
+       return (int)(mktime(0,0,0,$m1-$m2,1,1970+$y1-$y2, -1)/60/60/24/28);
+}
+
+var $define_QUARTER='sqlite_userfunc_QUARTER';
+function sqlite_userfunc_QUARTER($p1){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       switch($mt){
+               case 1: case 2: case 3: return 1;
+               case 4: case 5: case 6: return 2;
+               case 7: case 8: case 9: return 3;
+               default: return 4;
+       }
+}
+
+var $define_SECOND='sqlite_userfunc_SECOND';
+function sqlite_userfunc_SECOND($p1){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return $sc;
+}
+
+var $define_SEC_TO_TIME='sqlite_userfunc_SEC_TO_TIME';
+function sqlite_userfunc_SEC_TO_TIME($p1){
+       return date('H:i:s',$p1);
+}
+
+var $define_WEEK='sqlite_userfunc_WEEK';
+function sqlite_userfunc_WEEK($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('W',$t);
+}
+
+var $define_WEEKDAY='sqlite_userfunc_WEEKDAY';
+function sqlite_userfunc_WEEKDAY($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       if (0<($w=date('w',$t))) return $w-1;
+       return 6;
+}
+
+var $define_YEAR='sqlite_userfunc_YEAR';
+function sqlite_userfunc_YEAR($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('Y',$t);
+}
+
+var $define_YEARWEEK='sqlite_userfunc_YEARWEEK';
+function sqlite_userfunc_YEARWEEK($p1){
+       $t=SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return date('YW',$t);
+}
+
+
+var $define_FIND_IN_SET='sqlite_userfunc_FIND_IN_SET';
+function sqlite_userfunc_FIND_IN_SET($p1,$p2){
+       if ($p1==null && $p2==null) return null;
+       if (!$p2) return 0;
+       foreach (explode(',',$p2) as $key=>$value) if ($value==$p1) return ($key+1);
+       return 0;
+}
+
+
+var $define_ADDDATE='sqlite_userfunc_ADDDATE';
+function sqlite_userfunc_ADDDATE($p1,$p2,$p3='DAY'){
+       return date("Y-m-d",sqlite_ADDDATE($p1,$p2,$p3));
+}
+
+var $define_SUBDATE='sqlite_userfunc_SUBDATE';
+function sqlite_userfunc_SUBDATE($p1,$p2,$p3='DAY'){
+       return date("Y-m-d",sqlite_ADDDATE($p1,0-$p2,$p3));
+}
+
+var $define_CONCAT='sqlite_userfunc_CONCAT';
+function sqlite_userfunc_CONCAT(){
+       if (!($lastnum=func_num_args())) return null;
+       $args=&func_get_args();
+       $ret='';
+       for ($i=0;$i<$lastnum;$i++) {
+               if ($args[$i]===null) return null;
+               $ret.=(string)($args[$i]);
+       }
+       return $ret;
+}
+
+var $define_IF='sqlite_userfunc_IF';
+function sqlite_userfunc_IF($p1,$p2,$p3){
+       if ((int)$p1) return $p2;
+       return $p3;
+}
+
+var $define_IFNULL='sqlite_userfunc_IFNULL';
+function sqlite_userfunc_IFNULL($p1,$p2){
+       if ($p1!=null) return $p1;
+       return $p2;
+}
+
+var $define_NULLIF='sqlite_userfunc_NULLIF';
+function sqlite_userfunc_NULLIF($p1,$p2){
+       if ($p1==$p2) return null;
+       return $p1;
+}
+
+
+var $define_match_against='sqlite_userfunc_match_against';
+function sqlite_userfunc_match_against(){
+       if (!($lastnum=func_num_args())) return 0;
+       if (!(--$lastnum)) return 0;
+       $args=&func_get_args();
+       if (!$args[$lastnum]) return 0;
+       $pattern='/'.quotemeta($args[$lastnum]).'/i';
+       $ret=0;
+       for($i=0;$i<$lastnum;$i++) $ret=$ret+preg_match_all ($pattern,$args[$i],$matches);
+       return $ret;
+}
+
+var $define_replace='sqlite_userfunc_replace';
+function sqlite_userfunc_replace($p1,$p2,$p3){
+       return str_replace($p3,$p1,$p2);
+}
+
+var $define_UNIX_TIMESTAMP='sqlite_userfunc_UNIX_TIMESTAMP';
+function sqlite_userfunc_UNIX_TIMESTAMP($p1=null){
+       if (!$p1) return time();
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       if ($yr) return mktime($hr,$mn,$sc,$mt,$dy,$yr, -1);
+       return $p1;//TIMESTAMP
+}
+
+var $define_REGEXP='sqlite_userfunc_REGEXP';
+function sqlite_userfunc_REGEXP($p1,$p2){
+       return preg_match ("/$p2/",$p1);
+}
+
+var $define_DAYOFMONTH='sqlite_userfunc_DAYOFMONTH';
+function sqlite_userfunc_DAYOFMONTH($p1){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return $dy;
+}
+
+var $define_MONTH='sqlite_userfunc_MONTH';
+function sqlite_userfunc_MONTH($p1){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       return $mt;
+}
+
+
+function sqlite_resolvedatetime($p1,&$yr,&$mt,&$dy,&$hr,&$mn,&$sc){
+       $t=trim($p1);
+       if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2}) ([0-9]{2}):([0-9]{2}):([0-9]{2})$/', $t,$matches)) {
+               //DATETIME
+               $yr=(int)$matches[1];
+               $mt=(int)$matches[2];
+               $dy=(int)$matches[3];
+               $hr=(int)$matches[4];
+               $mn=(int)$matches[5];
+               $sc=(int)$matches[6];
+       } else if (preg_match('/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/', $t,$matches)) {
+               //DATE
+               $yr=(int)$matches[1];
+               $mt=(int)$matches[2];
+               $dy=(int)$matches[3];
+               $hr=$mn=$sc=0;
+       } else if (preg_match('/^([0-9]{4})([0-9]{2})([0-9]{2})$/', $t,$matches)) {
+               //YYYYMMDD
+               $yr=(int)$matches[1];
+               $mt=(int)$matches[2];
+               $dy=(int)$matches[3];
+               $hr=$mn=$sc=0;
+       } else if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})$/', $t,$matches)) {
+               //YYMMDD
+               $yr=(int)$matches[1];
+               $mt=(int)$matches[2];
+               $dy=(int)$matches[3];
+               $hr=$mn=$sc=0;
+               if ($yr<70) $yr=$yr+2000;
+               else $yr=$yr+1900;
+       }
+       return mktime($hr,$mn,$sc,$mt,$dy,$yr, -1);
+}
+
+function sqlite_ADDDATE($p1,$p2,$p3){
+       SQLite_Functions::sqlite_resolvedatetime($p1,$yr,$mt,$dy,$hr,$mn,$sc);
+       $a=explode(' ',preg_replace('/[^0-9]/',' ',trim((string)$p2)));
+       switch(strtoupper($p3)) {
+               case'SECOND': // SECONDS 
+                       $sc += (int)$p2;
+                       break;
+               case'MINUTE': // MINUTES 
+                       $mn += (int)$p2;
+                       break;
+               case'HOUR': // HOURS 
+                       $hr += (int)$p2;
+                       break;
+               case'MONTH': // MONTHS 
+                       $mt += (int)$p2;
+                       break;
+               case'YEAR': // YEARS 
+                       $yr += (int)$p2;
+                       break;
+               case'MINUTE_SECOND': // 'MINUTES:SECONDS' 
+                       $mn += (int)$a[0];
+                       $sc += (int)$a[1];
+                       break;
+               case'HOUR_MINUTE': // 'HOURS:MINUTES' 
+                       $hr += (int)$a[0];
+                       $mn += (int)$a[1];
+                       break;
+               case'DAY_HOUR': // 'DAYS HOURS' 
+                       $dy += (int)$a[0];
+                       $hr += (int)$a[1];
+                       break;
+               case'YEAR_MONTH': // 'YEARS-MONTHS' 
+                       $yr += (int)$a[0];
+                       $mt += (int)$a[1];
+                       break;
+               case'HOUR_SECOND': // 'HOURS:MINUTES:SECONDS' 
+                       $hr += (int)$a[0];
+                       $mn += (int)$a[1];
+                       $sc += (int)$a[2];
+                       break;
+               case'DAY_MINUTE': // 'DAYS HOURS:MINUTES' 
+                       $dy += (int)$a[0];
+                       $hr += (int)$a[1];
+                       $mn += (int)$a[2];
+                       break;
+               case'DAY_SECOND': // 'DAYS HOURS:MINUTES:SECONDS' 
+                       $dy += (int)$a[0];
+                       $hr += (int)$a[1];
+                       $mn += (int)$a[2];
+                       $sc += (int)$a[3];
+                       break;
+               case'DAY': // DAYS 
+               default:
+                       $dy += (int)$p2;
+                       break;
+       }
+       return mktime($hr,$mn,$sc,$mt,$dy,$yr, -1);
+}
+
+// For creating table structure (table and index/indeces)
+var $define_sqlite_table_structure='sqlite_userfunc_sqlite_table_structure';
+function sqlite_userfunc_sqlite_table_structure($p1){
+       global $SQLITE_DBHANDLE;
+       $ret='';
+       if ($res=sqlite_query($SQLITE_DBHANDLE,"SELECT sql FROM sqlite_master WHERE tbl_name='$p1'")) {
+               while ($array=sqlite_fetch_array($res,SQLITE_NUM)) $ret.=$array[0].";\n";
+       }
+       return $ret;
+}
+
+
+// Modification of query for some functions.
+function sqlite_modifyQueryForUserFunc(&$query,$strpositions,$pattern=null,$replacement=null){
+       // Write this part very carefully.  Otherwise, you may allow crackers to do SQL-injection.
+       global $SQLITE_MQFUFCB_OK,$SQLITE_MQFUFCB_COUNT,$SQLITE_MQFUFCB_REPLACE;
+       
+       // Store the previous string
+       $orgstrings=array();
+       foreach ($strpositions as $start => $end) array_push($orgstrings, trim(substr($query,$start,$end-$start)));
+       
+       $lquery=strtolower($query);
+       if (!$pattern) $pattern=array();
+       if (!$replacement) $replacement=array();
+       
+       // match() against() support. Following way does NOT accept SQL-injection.  Note that the string is always quoted by "'".
+       array_push($pattern,'/match \(([^\']*?)\) against \(/i');
+       array_push($replacement,'match_against ($1,');  
+       // REGEXP support
+       if (strpos($lquery,'regexp')!==false) {
+               array_push($pattern,'/([^a-z_\.])([a-z_\.]+)[\s]+REGEXP[\s]+\'([^\']*?)\'([^\']?)/i');
+               array_push($replacement,'$1regexp($2,\'$3\')$4');       
+       }
+       // ADDDATE/SUBDATE support (INTERVAL support)
+       array_push($pattern,'/([^a-zA-Z_])ADDDATE[\s]*?\(([^,]+),[\s]*?INTERVAL[\s]+([\S]+)[\s]+([^\)]+)\)/i');
+       array_push($replacement,'$1adddate($2,$3,\'$4\')');
+       array_push($pattern,'/([^a-zA-Z_])DATE_ADD[\s]*?\(([^,]+),[\s]*?INTERVAL[\s]+([\S]+)[\s]+([^\)]+)\)/i');
+       array_push($replacement,'$1adddate($2,$3,\'$4\')');
+       array_push($pattern,'/([^a-zA-Z_])SUBDATE[\s]*?\(([^,]+),[\s]*?INTERVAL[\s]+([\S]+)[\s]+([^\)]+)\)/i');
+       array_push($replacement,'$1subdate($2,$3,\'$4\')');
+       array_push($pattern,'/([^a-zA-Z_])DATE_SUB[\s]*?\(([^,]+),[\s]*?INTERVAL[\s]+([\S]+)[\s]+([^\)]+)\)/i');
+       array_push($replacement,'$1subdate($2,$3,\'$4\')');
+       
+       // EXTRACT support
+       array_push($pattern,'/([^a-zA-Z_])EXTRACT[\s]*?\(([a-zA-Z_]+)[\s]+FROM/i');
+       array_push($replacement,'$1extract(\'$2\',');
+       
+       // TRIM support:
+       array_push($pattern,'/([^a-zA-Z_])TRIM[\s]*?\((BOTH|LEADING|TRAILING)[\s]+FROM/i');
+       array_push($replacement,'$1extract(\'$2\',\' \',');
+       array_push($pattern,'/([^a-zA-Z_])TRIM[\s]*?\((BOTH|LEADING|TRAILING)[\s]+([\s\S]+)[\s]+FROM/i');
+       array_push($replacement,'$1extract(\'$2\',$3,');
+       
+       // Change it.
+       $temp=preg_replace ($pattern,$replacement,$query);
+       
+       // Comfirm if strings did not change.
+       $ok=true;
+       foreach ($orgstrings as $key=>$value) if ($value) {
+               if (strpos($temp,$value)!==false) {
+                       // This string is OK, therefore will be ignored in the next "step by step" step.
+                       $orgstrings[$key]='';
+                       continue;
+               }
+               $ok=false;
+       }
+       if ($ok) { // return if everything is OK.
+               $query=$temp;
+               return;
+       }
+       
+       // At least one of string changed. Need to do step by step.
+       foreach ($pattern as $key=>$pat) {
+               // Replace is done step by step for each RegExp replace statement.
+               $SQLITE_MQFUFCB_REPLACE=$replace[$key];// Set the grobal var.
+               $num=preg_match_all($pat,$query,$matches);
+               // First, check if OK.
+               $replaceOK=array();
+               for ($i=1;$i<=$num;$i++) {
+                       $SQLITE_MQFUFCB_OK=array();
+                       $SQLITE_MQFUFCB_OK[$i]=true; // Set the grobal var.
+                       $SQLITE_MQFUFCB_COUNT=0; // Set the grobal var.
+                       // Only $i-st replacement will be done in the next line.
+                       $temp=preg_replace_callback($pat,array('SQLite_Functions','sqlite_modifyQueryForUserFuncCallBack'), $query, $i);
+                       $ok=true;
+                       foreach ($orgstrings as $value) if ($value) {
+                               if (strpos($temp,$value)!==false) continue;
+                               $ok=false;
+                               break;
+                       }
+                       if ($ok) $replaceOK[$i]=true;
+               }
+               // Replace
+               $SQLITE_MQFUFCB_OK=$replaceOK;// Copy the OK array
+               $SQLITE_MQFUFCB_COUNT=0;
+               $query=preg_replace_callback($pat,array('SQLite_Functions','sqlite_modifyQueryForUserFuncCallBack'), $query);
+       }
+}
+
+function sqlite_modifyQueryForUserFuncCallBack($mathces){
+       global $SQLITE_MQFUFCB_OK,$SQLITE_MQFUFCB_COUNT,$SQLITE_MQFUFCB_REPLACE;
+       if ($SQLITE_MQFUFCB_OK[++$SQLITE_MQFUFCB_COUNT]) return $SQLITE_MQFUFCB_REPLACE;
+       else return $mathces[0];
+}
+
+}//class SQLite_QueryFunctions
+
+?>
\ No newline at end of file
diff --git a/sqlite/tags/sqlite0904/readme-en.txt b/sqlite/tags/sqlite0904/readme-en.txt
new file mode 100644 (file)
index 0000000..408e83e
--- /dev/null
@@ -0,0 +1,39 @@
+*************************************************
+* MySQL-SQLite wrapper for Nucleus ver 0.8      *
+*************************************************
+
+Copyright (C) 2006-2007  Katsumi
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+----------------------------------------------------------------------
+
+This tool is needed when using Nucleus with SQLite as database engine.
+
+
+****************************** How to use ******************************
+
+  When installing Nucleus, the access-ID and password are not required. SQLite
+uses normal file as database.  This is fixed to "nucleus/sqlite/.dbsqlite" 
+(if you would like another file name, please set it in "sqlite.php" file). 
+Set the permission of "nucleus/sqlite/" directory to 777 or something like this. 
+Then execute install.php. That's it! If you see the install-complete message, 
+probably the install is succeded.  NP_SkinFiles as well as NP_SQLite are 
+automatically installed.  If not, install it manually.
+
+  The usage of Nucleus is almost (99%) the same as that of normal Nucleus.  When
+installing plugins, NP_SQLite will convert the plugin files automatically if the
+permission of these files is set to be writable.
+
diff --git a/sqlite/tags/sqlite0904/readme-ja.txt b/sqlite/tags/sqlite0904/readme-ja.txt
new file mode 100644 (file)
index 0000000..6afe98d
--- /dev/null
@@ -0,0 +1,45 @@
+**********************************************
+* MySQL-SQLite wrapper for Nucleus ver 0.8   *
+**********************************************
+Copyright (C) 2006-2007\94N\81AKatsumi
+
+\82±\82Ì\83v\83\8d\83O\83\89\83\80\82Í\83t\83\8a\81[\83\\83t\83g\83E\83F\83A\82Å\82·\81B\82 \82È\82½\82Í\82±\82ê\82ð\81A\83t\83\8a\81[\83\\83t\83g\83E\83F
+\83A\8dà\92c\82É\82æ\82Á\82Ä\94­\8ds\82³\82ê\82½ GNU \88ê\94Ê\8cö\8fO\97\98\97p\8b\96\91ø\8c_\96ñ\8f\91(\83o\81[\83W\83\87\83\932\82©\81A\8aó
+\96]\82É\82æ\82Á\82Ä\82Í\82»\82ê\88È\8d~\82Ì\83o\81[\83W\83\87\83\93\82Ì\82¤\82¿\82Ç\82ê\82©)\82Ì\92è\82ß\82é\8fð\8c\8f\82Ì\89º\82Å\8dÄ\94Ð\95z
+\82Ü\82½\82Í\89ü\95Ï\82·\82é\82±\82Æ\82ª\82Å\82«\82Ü\82·\81B
+
+\82±\82Ì\83v\83\8d\83O\83\89\83\80\82Í\97L\97p\82Å\82 \82é\82±\82Æ\82ð\8aè\82Á\82Ä\94Ð\95z\82³\82ê\82Ü\82·\82ª\81A*\91S\82­\82Ì\96³\95Û\8fØ* 
+\82Å\82·\81B\8f¤\8bÆ\89Â\94\\90«\82Ì\95Û\8fØ\82â\93Á\92è\82Ì\96Ú\93I\82Ö\82Ì\93K\8d\87\90«\82Í\81A\8c¾\8aO\82É\8e¦\82³\82ê\82½\82à\82Ì\82à\8aÜ
+\82ß\91S\82­\91\8dÝ\82µ\82Ü\82¹\82ñ\81B\8fÚ\82µ\82­\82ÍGNU \88ê\94Ê\8cö\8fO\97\98\97p\8b\96\91ø\8c_\96ñ\8f\91\82ð\82²\97\97\82­\82¾\82³\82¢\81B
+\82 \82È\82½\82Í\82±\82Ì\83v\83\8d\83O\83\89\83\80\82Æ\8b¤\82É\81AGNU \88ê\94Ê\8cö\8fO\97\98\97p\8b\96\91ø\8c_\96ñ\8f\91\82Ì\95¡\90»\95¨\82ð\88ê\95\94
+\8eó\82¯\8eæ\82Á\82½\82Í\82¸\82Å\82·\81B\82à\82µ\8eó\82¯\8eæ\82Á\82Ä\82¢\82È\82¯\82ê\82Î\81A\83t\83\8a\81[\83\\83t\83g\83E\83F\83A\8dà\92c\82Ü
+\82Å\90¿\8b\81\82µ\82Ä\82­\82¾\82³\82¢(\88\90æ\82Í the Free Software Foundation, Inc., 59
+Temple Place, Suite 330, Boston, MA 02111-1307 USA)\81B
+
+----------------------------------------------------------------------
+
+\82±\82Ì\83c\81[\83\8b\82Í\81ANucleus \82Å\83f\81[\83^\83x\81[\83X\82Æ\82µ\82Ä\81ASQLite \82ð\97p\82¢\82é\82½\82ß\82Ì\95¨\82Å\82·\81B
+
+\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81@\8eg\97p\95û\96@\81@\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96\81\96
+
+\81@Nucleus \82Ì\83C\83\93\83X\83g\81[\83\8b\82Ì\8dÛ\82Í\81A\83f\81[\83^\83x\81[\83X\82Ì\83A\83N\83Z\83XID\82â\83p\83X\83\8f\81[\83h\82È\82Ç\82Í
+\8ew\92è\82·\82é\95K\97v\82Í\82 \82è\82Ü\82¹\82ñ\81BSQLite \82Í\83f\81[\83^\83x\81[\83X\82Æ\82µ\82Ä\92Ê\8fí\83t\83@\83C\83\8b\82ð\97p\82¢\82Ü\82·\81B
+\82±\82ê\82Í\81A\81wnucleus/sqlite/.dbsqlite\81x\8cÅ\92è\82Å\82·\81B\83C\83\93\83X\83g\81[\83\8b\91O\82É\81wnucleus/sqlite/\81x
+\83t\83H\83\8b\83_\82Ì\83p\81[\83~\83b\83V\83\87\83\93\82ð\81A\93Ç\82Ý\8f\91\82«\89Â\94\\82È\8c`\81i777\82Æ\82©\81j\82É\82µ\82Ä\82­\82¾\82³\82¢\81B\95Ê\82Ì
+\83t\83@\83C\83\8b\96¼\82ð\8eg\97p\82µ\82½\82¢\8fê\8d\87\82Í\81A\81wnucleus/sqlite/sqlite.php\81x\82ð\8f\91\82«\8a·\82¦\82Ä\82­\82¾\82³\82¢\81B
+
+\81@\82 \82Æ\82Í\81A\81winstall.php\81x\82ð\8eÀ\8ds\82·\82é\82¾\82¯\82Å\82·\81B\83I\83\8a\83W\83i\83\8b\94Å\82ÌNucleus\82Æ\93¯\82\82æ
+\82¤\82È\83C\83\93\83X\83g\81[\83\8b\8a®\97¹\89æ\96Ê\82ª\8fo\82ê\82Î\81A\82¨\82»\82ç\82­\83C\83\93\83X\83g\81[\83\8b\82ª\90¬\8c÷\82µ\82Ä\82¢\82Ü\82·\81B
+\82±\82Ì\82Æ\82«\81ANP_SkinFiles \82É\89Á\82¦\82Ä\81ANP_SQLite \82à\83v\83\89\83O\83C\83\93\82Æ\82µ\82Ä\83f\83t\83H\83\8b\83g\82Å\83C\83\93\83X
+\83g\81[\83\8b\82³\82ê\82é\82Í\82¸\82Å\82·\81B\82à\82µ\83C\83\93\83X\83g\81[\83\8b\82³\82ê\82Ä\82¢\82È\82¢\8fê\8d\87\82Í\81A\8eè\93®\82Å\83C\83\93\83X\83g\81[\83\8b
+\82µ\82Ä\82­\82¾\82³\82¢\81B
+
+\81@\82 \82Æ\82Ì\8eg\82¢\95û\82Í\95\81\92Ê\82Ì Nucleus \82Æ 99% \93¯\82\82Å\82·\81B\83v\83\89\83O\83C\83\93\82ð\83C\83\93\83X\83g\81[\83\8b\82·\82é\8dÛ\82Í\81A
+PHP\83t\83@\83C\83\8b\82Ì\83p\81[\83~\83b\83V\83\87\83\93\82ð\93Ç\82Ý\8f\91\82«\89Â\94\\82È\90Ý\92è\82É\82µ\82Ä\82¨\82¯\82Î\81ANP_SQLite \82ª\8e©\93®\93I\82É
+SQLite\97p\82É\83v\83\89\83O\83C\83\93\82ÌPHP\83t\83@\83C\83\8b\82ð\8f\91\82«\8a·\82¦\82Ä\82­\82ê\82é\82Í\82¸\82Å\82·\81B
+
+\81@extra/sqlite/ \83t\83H\83\8b\83_\82É\82Í\81ANucleus \82Ì\83o\81[\83W\83\87\83\93\83A\83b\83v\82ª\82 \82Á\82½\8dÛ\82Ì\91Î\8f\88
+\83c\81[\83\8b\82ª\92u\82©\82ê\82Ä\82¢\82Ü\82·\82Ì\82Å\81A\8aJ\94­\8eÒ\82Ì\95û\82Í\82»\82¿\82ç\82à\8eQ\8fÆ\82µ\82Ä\82­\82¾\82³\82¢\81B
+