File indexing completed on 2024-12-22 05:33:15

0001 <?php
0002 /*
0003  *   GFX 4
0004  * 
0005  *   support: happy.snizzo@gmail.com
0006  *   website: http://www.gfx3.org
0007  *   credits: Claudio Desideri
0008  *   
0009  *   This software is released under the MIT License.
0010  *   http://opensource.org/licenses/mit-license.php
0011  */
0012 
0013 /*
0014  * Contains different methods used in testing
0015  * environment. Mostly for developers or used in
0016  * the admin panel of the ocs server 
0017  */
0018 class OCSTest{
0019   
0020   public static function install_ocs_database()
0021   {
0022     EDatabase::q("
0023     CREATE TABLE IF NOT EXISTS `ocs_apitraffic` (
0024       `ip` bigint(20) NOT NULL,
0025       `count` int(11) NOT NULL,
0026       PRIMARY KEY (`ip`)
0027     ) ENGINE=MyISAM;
0028     ");
0029 
0030     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_comment` (
0031       `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
0032       `type` tinyint(1) NOT NULL,
0033       `owner` int(11) NOT NULL,
0034       `content` int(11) NOT NULL,
0035       `content2` int(11) NOT NULL,
0036       `parent` int(11) NOT NULL,
0037       `votes` int(11) NOT NULL DEFAULT '0',
0038       `score` int(3) NOT NULL DEFAULT '0',
0039       `subject` varchar(255) NOT NULL,
0040       `date` varchar(50) NOT NULL,
0041       `message` text NOT NULL,
0042       PRIMARY KEY (`id`)
0043     ) ENGINE=InnoDB;
0044     ");
0045     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_content` (
0046       `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
0047       `owner` int(11) NOT NULL,
0048       `votes` int(11) NOT NULL DEFAULT '1',
0049       `score` int(3) NOT NULL DEFAULT '50',
0050       `downloads` int(11) NOT NULL DEFAULT '0',
0051       `license` tinyint(1) NOT NULL DEFAULT '0',
0052       `name` varchar(255) NOT NULL,
0053       `type` varchar(45) NOT NULL,
0054       `downloadname1` varchar(255) DEFAULT NULL,
0055       `downloadlink1` varchar(255) DEFAULT NULL,
0056       `preview1` varchar(255) NOT NULL,
0057       `preview2` varchar(255) NOT NULL,
0058       `preview3` varchar(255) NOT NULL,
0059       `personid` varchar(255) NOT NULL,
0060       `version` varchar(25) DEFAULT NULL,
0061       `summary` text,
0062       `description` text,
0063       `changelog` text,
0064       PRIMARY KEY (`id`),
0065       KEY `score` (`score`),
0066       KEY `personid` (`personid`)
0067     ) ENGINE=MyISAM;
0068     ");
0069     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_fan` (
0070       `person` int(11) NOT NULL,
0071       `content` int(11) NOT NULL,
0072       KEY `person` (`person`,`content`)
0073     ) ENGINE=InnoDB;
0074     ");
0075     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_person` (
0076       `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
0077       `login` varchar(45) NOT NULL,
0078       `password` varchar(45) NOT NULL,
0079       `firstname` varchar(45) NOT NULL,
0080       `lastname` varchar(45) NOT NULL,
0081       `email` varchar(100) NOT NULL,
0082       PRIMARY KEY (`id`)
0083     ) ENGINE=MyISAM;");
0084 
0085     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_activity` (
0086       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
0087       `type` int(2) NOT NULL,
0088       `person` int(11) NOT NULL,
0089       `timestamp` int(15) NOT NULL,
0090       `message` text NOT NULL,
0091       PRIMARY KEY (`id`),
0092       KEY `person` (`person`)
0093     ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;");
0094 
0095     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_friendship` (
0096       `id1` int(11) NOT NULL,
0097       `id2` int(11) NOT NULL,
0098       UNIQUE KEY `id1` (`id1`,`id2`)
0099     ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
0100 
0101     EDatabase::q("CREATE TABLE IF NOT EXISTS `ocs_friendinvitation` (
0102       `fromuser` varchar(255) NOT NULL,
0103       `touser` varchar(255) NOT NULL,
0104       `message` text NOT NULL,
0105       UNIQUE KEY `from` (`fromuser`,`touser`),
0106       KEY `fromuser` (`fromuser`),
0107       KEY `touser` (`touser`),
0108       KEY `fromuser_2` (`fromuser`),
0109       KEY `touser_2` (`touser`),
0110       KEY `fromuser_3` (`fromuser`)
0111     ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
0112   }
0113   
0114   public static function reset_ocs_database()
0115   {
0116     EDatabase::q("DROP TABLE IF EXISTS `ocs_apitraffic`;");
0117     EDatabase::q("DROP TABLE IF EXISTS `ocs_comment`;");
0118     EDatabase::q("DROP TABLE IF EXISTS `ocs_content`;");
0119     EDatabase::q("DROP TABLE IF EXISTS `ocs_fan`;");
0120     EDatabase::q("DROP TABLE IF EXISTS `ocs_person`;");
0121     EDatabase::q("DROP TABLE IF EXISTS `ocs_activity`;");
0122     EDatabase::q("DROP TABLE IF EXISTS `ocs_friendship`;");
0123     EDatabase::q("DROP TABLE IF EXISTS `ocs_friendinvitation`;");
0124     
0125     OCSTest::install_ocs_database();
0126   }
0127   
0128 }
0129 
0130 ?>