diff --git a/README.markdown b/README.markdown index d450a20..1207314 100644 --- a/README.markdown +++ b/README.markdown @@ -3,6 +3,8 @@ * Edit the corresponding setup. * $ cp login/inc/config-example.php login/inc/config.php * Edit the corresponding setup. +* $ mkdir upload +* $ chown http upload * $ chmod 0744 upload * Import users.sql and xiaoyou.sql * Enabled php-openssl. diff --git a/app/controllers/MailController.php b/app/controllers/MailController.php index 1f7eb58..5859d46 100644 --- a/app/controllers/MailController.php +++ b/app/controllers/MailController.php @@ -26,7 +26,7 @@ public function create() }else { //$receiver=fRecordSet::build('Profile',array('login_name=' => $re ),array())->getRecord(0); $receiver=fRecordSet::build('Profile',array('login_name=' => $re ),array()); - if($receiver->getCount()>0)$receiver=$receiver->getRecord(0); + if($receiver->count())$receiver=$receiver->getRecord(0); else throw new fNotFoundException('user doesn\'t exist'); $mail->setReceiver($receiver->getId()); } diff --git a/app/controllers/RegisterController.php b/app/controllers/RegisterController.php index 097b0c0..f1c84d8 100644 --- a/app/controllers/RegisterController.php +++ b/app/controllers/RegisterController.php @@ -44,11 +44,7 @@ public function submit() throw new fValidationException('用户名中只允许出现小写字母和数字'); if (!Name::existid($realname,$stuid)) throw new fValidationException('无效的用户信息(请务必填写用于注册的本科学号,并使用中文姓名注册)'); - - if ($email == GLOBAL_INVITATION_EMAIL) { - $email = 'xiaoyou' . substr(md5(md5(time()) . rand()), 0, 10) . '@acm.sjtu.edu.cn'; - } - + $h = acm_userpass_hash($password); try { $udb = new fDatabase('mysql', UDB_NAME, UDB_USER, UDB_PASS, UDB_HOST); diff --git a/default.settings.php b/default.settings.php index d1801ea..43cf5a1 100755 --- a/default.settings.php +++ b/default.settings.php @@ -23,7 +23,7 @@ define('AVATAR_BASE', '/avatars'); define('UPLOAD_DIR', '/srv/http/xiaoyou/upload/'); define('UPLOAD_BASE', '/upload'); -define('UPLOAD_EXT',array('jpg','png','bmp','gif')); +define('UPLOAD_EXT',serialize(array('jpg','png','bmp','gif'))); define('SMTP_PRO', 'ssl');//ssl or tls define('SMTP_ADDR', 'smtp.googlemail.com'); define('SMTP_PORT', '465'); diff --git a/doc/users.sql b/doc/users.sql index 83cfb3a..a97ebe0 100644 --- a/doc/users.sql +++ b/doc/users.sql @@ -19,7 +19,7 @@ SET time_zone = "+00:00"; -- -- Database: `users` -- - +DROP TABLE IF EXISTS `users`; -- -------------------------------------------------------- -- diff --git a/doc/xiaoyou.sql b/doc/xiaoyou.sql index 9178c22..fac4a62 100644 --- a/doc/xiaoyou.sql +++ b/doc/xiaoyou.sql @@ -19,14 +19,27 @@ SET time_zone = "+00:00"; -- -- Database: `xiaoyou` -- - +DROP TABLE IF EXISTS `activities`; +DROP TABLE IF EXISTS `article_comments`; +DROP TABLE IF EXISTS `articles`; +DROP TABLE IF EXISTS `contacts`; +DROP TABLE IF EXISTS `experiences`; +DROP TABLE IF EXISTS `honors`; +DROP TABLE IF EXISTS `invitations`; +DROP TABLE IF EXISTS `mails`; +DROP TABLE IF EXISTS `msgs`; +DROP TABLE IF EXISTS `names`; +DROP TABLE IF EXISTS `papers`; +DROP TABLE IF EXISTS `tweet_comments`; +DROP TABLE IF EXISTS `tweets`; +DROP TABLE IF EXISTS `profiles`; -- -------------------------------------------------------- -- -- Table structure for table `activities` -- -DROP TABLE IF EXISTS `activities`; + CREATE TABLE IF NOT EXISTS `activities` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `profile_id` bigint(20) unsigned DEFAULT NULL, @@ -38,30 +51,11 @@ CREATE TABLE IF NOT EXISTS `activities` ( -- -------------------------------------------------------- --- --- Table structure for table `articles` --- - -DROP TABLE IF EXISTS `articles`; -CREATE TABLE IF NOT EXISTS `articles` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `title` varchar(200) NOT NULL, - `content` text NOT NULL, - `priority` int(11) NOT NULL, - `type` enum('news','post','culture','infrastructure','halloffame') NOT NULL, - `visible` tinyint(1) NOT NULL, - `created_at` datetime NOT NULL, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- -------------------------------------------------------- - -- -- Table structure for table `article_comments` -- -DROP TABLE IF EXISTS `article_comments`; + CREATE TABLE IF NOT EXISTS `article_comments` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `article_id` bigint(20) unsigned NOT NULL, @@ -73,88 +67,43 @@ CREATE TABLE IF NOT EXISTS `article_comments` ( KEY `profile_id` (`profile_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- -------------------------------------------------------- - --- --- Table structure for table `contacts` --- - -DROP TABLE IF EXISTS `contacts`; -CREATE TABLE IF NOT EXISTS `contacts` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `profile_id` bigint(20) unsigned NOT NULL, - `type` enum('douban','email','facebook','qq','renren','twitter','weibo','tele','mobile','msn') NOT NULL, - `content` varchar(1000) NOT NULL, - `created_at` datetime NOT NULL, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `profile_id` (`profile_id`), - KEY `type` (`type`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- -- --- Table structure for table `experiences` +-- Table structure for table `articles` -- -DROP TABLE IF EXISTS `experiences`; -CREATE TABLE IF NOT EXISTS `experiences` ( + +CREATE TABLE IF NOT EXISTS `articles` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `profile_id` bigint(20) unsigned NOT NULL, - `start_year` char(4) NOT NULL, - `start_month` int(11) DEFAULT NULL, - `end_year` char(4) DEFAULT NULL, - `end_month` int(11) DEFAULT NULL, - `type` enum('bachelor','master','doctor','postdoc','work') NOT NULL, - `major` varchar(200) NOT NULL, - `location` varchar(200) NOT NULL, - `mentor` varchar(200) DEFAULT NULL, + `title` varchar(200) NOT NULL, + `content` text NOT NULL, + `priority` int(11) NOT NULL, + `type` enum('news','post','culture','infrastructure','halloffame') NOT NULL, + `visible` tinyint(1) NOT NULL, `created_at` datetime NOT NULL, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `profile_id` (`profile_id`) + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -- -------------------------------------------------------- -- --- Table structure for table `honors` +-- Table structure for table `contacts` -- -DROP TABLE IF EXISTS `honors`; -CREATE TABLE IF NOT EXISTS `honors` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `profile_id` bigint(20) unsigned NOT NULL, - `year` char(4) NOT NULL, - `month` int(11) DEFAULT NULL, - `description` varchar(200) NOT NULL, - `created_at` datetime NOT NULL, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `profile_id` (`profile_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- -------------------------------------------------------- --- --- Table structure for table `invitations` --- - -DROP TABLE IF EXISTS `invitations`; -CREATE TABLE IF NOT EXISTS `invitations` ( +CREATE TABLE IF NOT EXISTS `contacts` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `email` varchar(200) NOT NULL, - `invitecode` varchar(100) NOT NULL, - `is_mail_sent` tinyint(1) NOT NULL, - `user_registered` tinyint(1) NOT NULL, - `inviter_profile_id` bigint(20) unsigned NOT NULL, + `profile_id` bigint(20) unsigned NOT NULL, + `type` enum('douban','email','facebook','qq','renren','twitter','weibo','tele','mobile','msn') NOT NULL, + `content` varchar(1000) NOT NULL, `created_at` datetime NOT NULL, `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), - UNIQUE KEY `email` (`email`), - KEY `inviter_profile_id` (`inviter_profile_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; + KEY `profile_id` (`profile_id`), + KEY `type` (`type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- -------------------------------------------------------- @@ -162,7 +111,7 @@ CREATE TABLE IF NOT EXISTS `invitations` ( -- Table structure for table `mails` -- -DROP TABLE IF EXISTS `mails`; + CREATE TABLE IF NOT EXISTS `mails` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `sender` bigint(20) unsigned NOT NULL, @@ -180,7 +129,7 @@ CREATE TABLE IF NOT EXISTS `mails` ( -- Table structure for table `msgs` -- -DROP TABLE IF EXISTS `msgs`; + CREATE TABLE IF NOT EXISTS `msgs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `sender` bigint(20) unsigned NOT NULL, @@ -196,7 +145,7 @@ CREATE TABLE IF NOT EXISTS `msgs` ( -- Table structure for table `names` -- -DROP TABLE IF EXISTS `names`; + CREATE TABLE IF NOT EXISTS `names` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `start_year` char(4) DEFAULT NULL, @@ -212,34 +161,11 @@ CREATE TABLE IF NOT EXISTS `names` ( -- -------------------------------------------------------- --- --- Table structure for table `papers` --- - -DROP TABLE IF EXISTS `papers`; -CREATE TABLE IF NOT EXISTS `papers` ( - `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, - `profile_id` bigint(20) unsigned NOT NULL, - `title` varchar(200) NOT NULL, - `authors` varchar(200) NOT NULL, - `publish_place` varchar(200) NOT NULL, - `publish_year` char(4) NOT NULL, - `is_first_author` tinyint(1) NOT NULL, - `is_at_sjtu` tinyint(1) NOT NULL, - `is_best_paper` tinyint(1) NOT NULL, - `created_at` datetime NOT NULL, - `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, - PRIMARY KEY (`id`), - KEY `profile_id` (`profile_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - --- -------------------------------------------------------- - -- -- Table structure for table `profiles` -- -DROP TABLE IF EXISTS `profiles`; + CREATE TABLE IF NOT EXISTS `profiles` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `login_name` varchar(100) NOT NULL, @@ -273,7 +199,7 @@ CREATE TABLE IF NOT EXISTS `profiles` ( -- Table structure for table `tweets` -- -DROP TABLE IF EXISTS `tweets`; + CREATE TABLE IF NOT EXISTS `tweets` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `profile_id` bigint(20) unsigned NOT NULL, @@ -289,7 +215,7 @@ CREATE TABLE IF NOT EXISTS `tweets` ( -- Table structure for table `tweet_comments` -- -DROP TABLE IF EXISTS `tweet_comments`; + CREATE TABLE IF NOT EXISTS `tweet_comments` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `tweet_id` bigint(20) unsigned NOT NULL, @@ -317,25 +243,6 @@ ALTER TABLE `article_comments` -- ALTER TABLE `contacts` ADD CONSTRAINT `contacts_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- --- Constraints for table `experiences` --- -ALTER TABLE `experiences` - ADD CONSTRAINT `experiences_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- --- Constraints for table `honors` --- -ALTER TABLE `honors` - ADD CONSTRAINT `honors_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- --- Constraints for table `papers` --- -ALTER TABLE `papers` - ADD CONSTRAINT `papers_ibfk_1` FOREIGN KEY (`profile_id`) REFERENCES `profiles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE; - -- -- Constraints for table `tweets` --