Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Jingcheng Liu committed Jul 30, 2012
1 parent 0065091 commit 6cddfea
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 140 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/MailController.php
Expand Up @@ -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());
}
Expand Down
6 changes: 1 addition & 5 deletions app/controllers/RegisterController.php
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion default.settings.php
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion doc/users.sql
Expand Up @@ -19,7 +19,7 @@ SET time_zone = "+00:00";
--
-- Database: `users`
--

DROP TABLE IF EXISTS `users`;
-- --------------------------------------------------------

--
Expand Down
171 changes: 39 additions & 132 deletions doc/xiaoyou.sql
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -73,96 +67,51 @@ 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;

-- --------------------------------------------------------

--
-- 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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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`
--
Expand Down

0 comments on commit 6cddfea

Please sign in to comment.