├── config └── .gitkeep ├── .gitignore ├── assets ├── img │ ├── glyphicons-halflings.png │ ├── project │ │ └── profile │ │ │ └── default.png │ └── glyphicons-halflings-white.png └── js │ └── bootstrap.min.js ├── README.md ├── index.php ├── .htaccess ├── application ├── controllers │ ├── IndexController.class.php │ ├── UserController.class.php │ └── ProjectController.class.php ├── views │ ├── project │ │ ├── unlike.php │ │ ├── like.php │ │ ├── pledge.php │ │ ├── rate.php │ │ ├── search.php │ │ ├── user.php │ │ ├── edit.php │ │ ├── create.php │ │ └── view.php │ ├── user │ │ ├── unfollow.php │ │ ├── follow.php │ │ ├── login.php │ │ ├── view.php │ │ ├── history.php │ │ ├── register.php │ │ ├── profile.php │ │ └── home.php │ ├── footer.php │ ├── layout.php │ └── header.php └── models │ ├── SampleModel.class.php │ ├── CommentModel.class.php │ ├── PledgeModel.class.php │ ├── LikeModel.class.php │ ├── RateModel.class.php │ ├── SearchhistoryModel.class.php │ ├── FollowModel.class.php │ ├── UserModel.class.php │ └── ProjectModel.class.php ├── fastphp ├── fastphp.php ├── Controller.class.php ├── Model.class.php ├── View.class.php ├── Core.php └── Sql.class.php ├── sql └── tables.sql └── LICENSE /config/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | config.php 2 | assets/img/project/ 3 | assets/misc/ 4 | .buildpath 5 | .project 6 | .settings 7 | *.txt 8 | -------------------------------------------------------------------------------- /assets/img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glkwhr/Crowdfunding/HEAD/assets/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /assets/img/project/profile/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glkwhr/Crowdfunding/HEAD/assets/img/project/profile/default.png -------------------------------------------------------------------------------- /assets/img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/glkwhr/Crowdfunding/HEAD/assets/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Crowdfunding 2 | A crowdfunding website. 3 | 4 | # How to use 5 | Please add `config.php` into `crowdfunding/config/` folder. 6 | 7 | ```php 8 | 2 | RewriteEngine On 3 | 4 | # If the requested file exists 5 | RewriteCond %{REQUEST_FILENAME} !-f 6 | RewriteCond %{REQUEST_FILENAME} !-d 7 | 8 | # If the requested file doesn't exists, rewrite to index.php?url= 9 | # item/index ==> index.php?url=item/index 10 | # Use GET['url'] to get string "item/index" 11 | RewriteRule ^(.*)$ index.php?url=$1 [PT,L] 12 | -------------------------------------------------------------------------------- /application/controllers/IndexController.class.php: -------------------------------------------------------------------------------- 1 | checkLogin()) { 6 | header('location:' . APP_URL . '/user/home'); 7 | } else { 8 | $this->assign('title', 'Crowdfunding'); 9 | $this->assign('content', 'Welcome to Crowdfunding!'); 10 | } 11 | 12 | $this->render(); 13 | } 14 | 15 | function error() { 16 | $this->assign('title', 'Crowdfunding'); 17 | $this->render(); 18 | } 19 | } -------------------------------------------------------------------------------- /application/views/project/unlike.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |

Unliked ">

6 | 7 | 8 |

You have not followed "> yet

9 | 10 | 11 |
12 |
-------------------------------------------------------------------------------- /application/views/user/unfollow.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |

Unfollowed ">

6 | 7 | 8 |

You have not followed "> yet

9 | 10 | 11 |
12 |
-------------------------------------------------------------------------------- /application/views/footer.php: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 17 | -------------------------------------------------------------------------------- /application/models/SampleModel.class.php: -------------------------------------------------------------------------------- 1 | _dbHandle->prepare($sql); 7 | $sth->execute(array(':pid' => $pid)); 8 | return $sth->fetchAll(PDO::FETCH_ASSOC); 9 | } 10 | 11 | function delete($data=array()) { 12 | $sql = "delete from `sample` where `pid` = :pid and `filename` = :filename"; 13 | $sth = $this->_dbHandle->prepare($sql); 14 | $sth->execute(array (':pid' => $data[0], ':filename' => $data[1])); 15 | return $sth->rowCount(); 16 | } 17 | } -------------------------------------------------------------------------------- /application/views/layout.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |

Welcome to Crowdfunding

4 |

You can check out the projects as a guest, or login to enjoy all features.

5 |
6 | Register 7 | Login now 8 | Explore 9 |
10 |
11 |
-------------------------------------------------------------------------------- /application/views/project/like.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |

Just liked ">

6 | 7 | 8 |

You have liked ">

9 |

Unlike

10 | 11 | 12 |
13 |
-------------------------------------------------------------------------------- /application/views/project/pledge.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |

Failed to back ">the project

6 | 7 | 8 |

Please update your CCN info first. ">GO

9 | 10 | 11 |

Just backed ">the project

12 | 13 | 14 |
15 |
-------------------------------------------------------------------------------- /application/views/user/follow.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |

Now following ">

6 | 7 | 8 |

You have followed ">

9 |

Unfollow

10 | 11 | 12 |
13 |
-------------------------------------------------------------------------------- /fastphp/fastphp.php: -------------------------------------------------------------------------------- 1 | run(); -------------------------------------------------------------------------------- /application/views/project/rate.php: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 | 5 |

Failed to rate ">the project

6 | 7 | 8 |

You have either rated this project already, or not backed this project. ">Return

9 | 10 | 11 |

Just rated ">the project

12 | 13 | 14 |
15 |
-------------------------------------------------------------------------------- /fastphp/Controller.class.php: -------------------------------------------------------------------------------- 1 | _controller = $controller; 12 | $this->_action = $action; 13 | $this->_view = new View($controller, $action); 14 | } 15 | 16 | public function assign($name, $value) { 17 | $this->_view->assign($name, $value); 18 | } 19 | 20 | public function render() { 21 | $this->_view->render(); 22 | } 23 | 24 | public function getInput($data) { 25 | // page security 26 | $data = trim($data); 27 | $data = stripslashes($data); 28 | $data = htmlspecialchars($data); 29 | return $data; 30 | } 31 | } -------------------------------------------------------------------------------- /fastphp/Model.class.php: -------------------------------------------------------------------------------- 1 | connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); 10 | 11 | // Get class name of the model 12 | $this->_model = get_class($this); 13 | // Delete "Model" in the end of the name 14 | $this->_model = substr($this->_model, 0, - 5); 15 | 16 | // The table name should be the same as the Class 17 | $this->_table = strtolower($this->_model); 18 | 19 | switch ($this->_table) { 20 | case 'user': 21 | $this->_primaryKey = 'uname'; 22 | break; 23 | case 'project': 24 | $this->_primaryKey = 'pid'; 25 | break; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /application/models/CommentModel.class.php: -------------------------------------------------------------------------------- 1 | $value) { 7 | switch ($type) { 8 | case 'uname': 9 | break; 10 | case 'pid': 11 | break; 12 | case 'content': 13 | break; 14 | case 'time': 15 | break; 16 | } 17 | } 18 | return $errors; 19 | } 20 | 21 | function add($data) { 22 | $data['time'] = date("Y-m-d-h-m-s"); 23 | return parent::add($data); 24 | } 25 | 26 | function getComment($pid) { 27 | $sql = "select * from `comment` where `pid` = :pid order by `time` desc"; 28 | $sth = $this->_dbHandle->prepare($sql); 29 | $sth->execute(array(':pid' => $pid)); 30 | return $sth->fetchAll(PDO::FETCH_ASSOC); 31 | } 32 | } -------------------------------------------------------------------------------- /application/models/PledgeModel.class.php: -------------------------------------------------------------------------------- 1 | _dbHandle->prepare($sql); 13 | $sth->execute(array(':pid' => $pid)); 14 | return $sth->fetch()['c']; 15 | } 16 | 17 | function exists($uname, $pid) { 18 | $sql = "select * from `pledge` where `pid`=:pid and `uname`=:uname"; 19 | $sth = $this->_dbHandle->prepare($sql); 20 | $sth->execute(array(':pid' => $pid, ':uname' => $uname)); 21 | return !empty($sth->fetch()); 22 | } 23 | 24 | function getHistory($uname) { 25 | $sql = "select `pledge`.`pid` as `pid`, `pledge`.`uname`, `pname`, `amount`, `time` from `pledge` inner join `project` on `pledge`.`pid`=`project`.`pid` where `pledge`.`uname`=:uname"; 26 | $sth = $this->_dbHandle->prepare($sql); 27 | $sth->execute(array(':uname' => $uname)); 28 | return $sth->fetchAll(); 29 | } 30 | } -------------------------------------------------------------------------------- /application/models/LikeModel.class.php: -------------------------------------------------------------------------------- 1 | _dbHandle->prepare($sql); 7 | $sth->execute(array(':uname' => $user, ':pid' => $pid)); 8 | return !empty($sth->fetch()); 9 | } 10 | 11 | function countLiked($pid) { 12 | $sql = "select count(distinct `uname`) as c from `like` where `pid`=:pid"; 13 | $sth = $this->_dbHandle->prepare($sql); 14 | $sth->execute(array(':pid' => $pid)); 15 | return $sth->fetch()['c']; 16 | } 17 | 18 | function add($data) { 19 | $data['time'] = date("Y-m-d h:m:s"); 20 | return parent::add($data); 21 | } 22 | 23 | function delete($data) { 24 | $sql = "delete from `like` where `uname`=:uname and `pid`=:pid"; 25 | $sth = $this->_dbHandle->prepare($sql); 26 | $sth->execute(array(':uname' => $data['uname'], ':pid' => $data['pid'])); 27 | return $sth->rowCount(); 28 | } 29 | 30 | function getHistory($uname) { 31 | $sql = "select `like`.`pid` as `pid`, `like`.`uname`, `pname`, `time` from `like` inner join `project` on `like`.`pid`=`project`.`pid` where `like`.`uname`=:uname"; 32 | $sth = $this->_dbHandle->prepare($sql); 33 | $sth->execute(array(':uname' => $uname)); 34 | return $sth->fetchAll(); 35 | } 36 | } -------------------------------------------------------------------------------- /application/models/RateModel.class.php: -------------------------------------------------------------------------------- 1 | _dbHandle->prepare($sql); 15 | $sth->execute(array(':pid' => $pid)); 16 | return $sth->fetch()['c']; 17 | } 18 | 19 | function avgScore($pid) { 20 | $sql = "select avg(`score`) as c from `rate` where `pid`=:pid"; 21 | $sth = $this->_dbHandle->prepare($sql); 22 | $sth->execute(array(':pid' => $pid)); 23 | return $sth->fetch()['c']; 24 | } 25 | 26 | function exists($uname, $pid) { 27 | $sql = "select * from `rate` where `pid`=:pid and `uname`=:uname"; 28 | $sth = $this->_dbHandle->prepare($sql); 29 | $sth->execute(array(':pid' => $pid, ':uname' => $uname)); 30 | return !empty($sth->fetch()); 31 | } 32 | 33 | function getHistory($uname) { 34 | $sql = "select `rate`.`pid` as `pid`, `rate`.`uname`, `pname`, `score`, `time` from `rate` inner join `project` on `rate`.`pid`=`project`.`pid` where `rate`.`uname`=:uname"; 35 | $sth = $this->_dbHandle->prepare($sql); 36 | $sth->execute(array(':uname' => $uname)); 37 | return $sth->fetchAll(); 38 | } 39 | } -------------------------------------------------------------------------------- /fastphp/View.class.php: -------------------------------------------------------------------------------- 1 | _controller = $controller; 9 | $this->_action = $action; 10 | } 11 | 12 | public function assign($name, $value) { 13 | $this->variables[$name] = $value; 14 | } 15 | 16 | public function render() { 17 | extract($this->variables); // Variables are used in the .php files below 18 | $defaultHeader = APP_PATH . 'application/views/header.php'; 19 | $defaultFooter = APP_PATH . 'application/views/footer.php'; 20 | $defaultLayout = APP_PATH . 'application/views/layout.php'; 21 | 22 | $controllerHeader = APP_PATH . 'application/views/' . $this->_controller . '/header.php'; 23 | $controllerFooter = APP_PATH . 'application/views/' . $this->_controller . '/footer.php'; 24 | $controllerLayout = APP_PATH . 'application/views/' . $this->_controller . '/' . $this->_action . '.php'; 25 | 26 | if (file_exists($controllerHeader)) { 27 | include ($controllerHeader); 28 | } else { 29 | include ($defaultHeader); 30 | } 31 | 32 | if (file_exists($controllerLayout)) { 33 | include ($controllerLayout); 34 | } else { 35 | include ($defaultLayout); 36 | } 37 | 38 | if (file_exists($controllerFooter)) { 39 | include ($controllerFooter); 40 | } else { 41 | include ($defaultFooter); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /application/models/SearchhistoryModel.class.php: -------------------------------------------------------------------------------- 1 | exists($data)) { 7 | return parent::add($data); 8 | } else { 9 | return $this->updateTime($data); 10 | } 11 | } 12 | 13 | function updateTime($data) { 14 | $sql = sprintf("update `searchhistory` set `time`=:time where `uname`=:uname and`keyword`=:keyword"); 15 | $sth = $this->_dbHandle->prepare($sql); 16 | $sth->execute(array( 17 | ':time' => $data['time'], 18 | ':uname' => $data['uname'], 19 | ':keyword' => $data['keyword'] 20 | )); 21 | return $sth->rowCount(); 22 | } 23 | 24 | function exists($data) { 25 | $sql = "select * from `searchhistory` where `keyword`=:keyword and `uname`=:uname"; 26 | $sth = $this->_dbHandle->prepare($sql); 27 | $sth->execute(array(':keyword' => $data['keyword'], ':uname' => $data['uname'])); 28 | return !empty($sth->fetch()); 29 | } 30 | 31 | function getHistory($uname) { 32 | $sql = "select * from `searchhistory` where `uname`=:uname"; 33 | $sth = $this->_dbHandle->prepare($sql); 34 | $sth->execute(array(':uname' => $uname)); 35 | return $sth->fetchAll(); 36 | } 37 | 38 | function clear($uname) { 39 | $sql = sprintf("delete from `searchhistory` where `uname` = :uname"); 40 | $sth = $this->_dbHandle->prepare($sql); 41 | $sth->execute(array (':uname' => $uname)); 42 | 43 | return $sth->rowCount(); 44 | } 45 | } -------------------------------------------------------------------------------- /application/views/user/login.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 |
14 |

15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 |
23 |
24 | 25 | 26 |
27 |
28 | 31 |
32 | 33 |
34 | 35 |
-------------------------------------------------------------------------------- /application/views/project/search.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 |

Cannot find the project.

5 | " class="btn btn-primary btn-lg" role="button">Explore 6 |
7 | 8 |
9 | 10 |
11 |
12 | "> 13 | " alt="Project Profile Picture"> 14 | 15 |
16 |

17 |

18 |

by ">

19 |

" class="btn btn-primary" role="button">View 20 | hasLiked($user, $row['pid'])):?> 21 | Liked 22 | 23 | Like 24 | 25 |

26 |
27 |
28 |
29 | 30 |
31 | 32 |
-------------------------------------------------------------------------------- /application/views/project/user.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 8 | 9 |
10 | 11 |
12 |
13 | "> 14 | " alt="Project Profile Picture"> 15 | 16 |
17 |

18 |

19 |

by ">

20 |

" class="btn btn-primary" role="button">View 21 | hasLiked($user, $row['pid'])):?> 22 | Liked 23 | 24 | Like 25 | 26 |

27 |
28 |
29 |
30 | 31 |
32 |
-------------------------------------------------------------------------------- /application/views/user/view.php: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |

Username

5 |
6 |
7 |

Email

8 |
9 |
10 |

Interests

11 | 12 |
13 | 14 | 15 | 21 | 22 |
16 |
17 | 18 |
19 |
20 |
23 | 24 |
25 | 26 |
27 |

28 | 29 | 30 | Unfollow 31 | 32 | Follow 33 | 34 | 35 | Projects 36 |

37 |
38 |
39 |
-------------------------------------------------------------------------------- /application/views/user/history.php: -------------------------------------------------------------------------------- 1 | 6 |
7 | 8 |
9 | 12 | 13 | 14 |
15 |
16 | 17 |

You searched at . 18 |

19 |
20 | 21 | 22 |

You have not searched any project yet. 23 | 24 |

25 | 26 |
27 | 30 | 31 | 32 |
33 |

34 | You liked "> 35 | at . 36 |

37 |
38 | 39 | 40 |

You have not liked any project yet. 41 | 42 |

43 | 44 |
45 | 48 | 49 | 50 |
51 |

52 | You funded "> 53 | with $ at . 54 |

55 |
56 | 57 | 58 |

You have not funded any project yet. 59 | 60 |

61 | 62 |
63 | 66 | 67 | 68 |
69 |

70 | You rated "> 71 | with scores at . 72 |

73 |
74 | 75 | 76 |

You have not rated any project yet. 77 | 78 |

79 | 80 |
-------------------------------------------------------------------------------- /application/models/FollowModel.class.php: -------------------------------------------------------------------------------- 1 | _dbHandle->prepare($sql); 8 | $sth->execute(array(':uname1' => $user1, ':uname2' => $user2)); 9 | return !empty($sth->fetch()); 10 | } 11 | 12 | function add($data) { 13 | $data['time'] = date("Y-m-d h:m:s"); 14 | return parent::add($data); 15 | } 16 | 17 | function delete($data) { 18 | $sql = "delete from `follow` where `uname1`=:uname1 and `uname2`=:uname2"; 19 | $sth = $this->_dbHandle->prepare($sql); 20 | $sth->execute(array(':uname1' => $data['uname1'], ':uname2' => $data['uname2'])); 21 | return $sth->rowCount(); 22 | } 23 | 24 | function getFollowingPledges($uname) { 25 | $sql = "select `uname`, `pid`, `pname`, `amount`, `time` 26 | from (select A.`uname`, A.`pid`, `pname`, `amount`, `time` from `pledge` as A inner join `project` as B on A.`pid`=B.`pid`) as C 27 | inner join 28 | (select `uname2` from `follow` where `uname1`=:uname1) as D 29 | on C.`uname`=D.`uname2` 30 | order by `time` desc;"; 31 | $sth = $this->_dbHandle->prepare($sql); 32 | $sth->execute(array(':uname1' => $uname)); 33 | return $sth->fetchAll(); 34 | } 35 | 36 | function getFollowingRates($uname) { 37 | $sql = "select `uname`, `pid`, `pname`, `score`, `time` 38 | from (select A.`uname`, A.`pid`, `pname`, `score`, `time` from `rate` as A inner join `project` as B on A.`pid`=B.`pid`) as C 39 | inner join 40 | (select `uname2` from `follow` where `uname1`=:uname1) as D 41 | on C.`uname`=D.`uname2` 42 | order by `time` desc;"; 43 | $sth = $this->_dbHandle->prepare($sql); 44 | $sth->execute(array(':uname1' => $uname)); 45 | return $sth->fetchAll(); 46 | } 47 | 48 | function getFollowingProjects($uname) { 49 | $sql = "select `uname`, `pid`, `pname`, `posttime` 50 | from `project` as A 51 | inner join 52 | (select `uname2` from `follow` where `uname1`=:uname1) as B 53 | on A.`uname`=B.`uname2` 54 | order by `posttime` desc;"; 55 | $sth = $this->_dbHandle->prepare($sql); 56 | $sth->execute(array(':uname1' => $uname)); 57 | return $sth->fetchAll(); 58 | } 59 | 60 | function getFollowingLikes($uname) { 61 | $sql = "select `uname`, `pid`, `pname`, `time` 62 | from (select A.`uname`, A.`pid`, `pname`, `time` from `like` as A inner join `project` as B on A.`pid`=B.`pid`) as C 63 | inner join 64 | (select `uname2` from `follow` where `uname1`=:uname1) as D 65 | on C.`uname`=D.`uname2` 66 | order by `time` desc;"; 67 | $sth = $this->_dbHandle->prepare($sql); 68 | $sth->execute(array(':uname1' => $uname)); 69 | return $sth->fetchAll(); 70 | } 71 | 72 | function getFollowingComments($uname) { 73 | $sql = "select `uname`, `pid`, `pname`, `content`, `time` 74 | from (select A.`uname`, A.`pid`, `pname`, `content`, `time` from `comment` as A inner join `project` as B on A.`pid`=B.`pid`) as C 75 | inner join 76 | (select `uname2` from `follow` where `uname1`=:uname1) as D 77 | on C.`uname`=D.`uname2` 78 | order by `time` desc;"; 79 | $sth = $this->_dbHandle->prepare($sql); 80 | $sth->execute(array(':uname1' => $uname)); 81 | return $sth->fetchAll(); 82 | } 83 | } -------------------------------------------------------------------------------- /application/views/user/register.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 | 6 |
7 |

Welcome

8 |

Registration succeeded!

9 |

Please login to enjoy all features.

10 | Login now 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |

20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 |
30 | 31 | 32 | 33 | 34 | 35 |
36 | 37 |
38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 |
46 | 47 | 48 | 49 | 50 | 51 |
52 | 53 |
54 | 55 | 56 | 57 | 58 | 59 |
60 | 61 |
62 | 63 | 64 |
65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 |
73 |
74 | 75 |
76 |
77 | 78 |
-------------------------------------------------------------------------------- /fastphp/Core.php: -------------------------------------------------------------------------------- 1 | setReporting(); 13 | $this->removeMagicQuotes(); 14 | $this->unregisterGlobals(); 15 | $this->route(); 16 | } 17 | 18 | // Routing 19 | public function route() { 20 | $controllerName = 'Index'; 21 | $action = 'index'; 22 | $param = array(); 23 | 24 | $url = isset($_GET['url']) ? $_GET['url'] : false; 25 | if ($url) { 26 | $urlArray = explode('/', $url); 27 | $urlArray = array_filter($urlArray); 28 | 29 | $controllerName = ucfirst($urlArray[0]); 30 | 31 | array_shift($urlArray); 32 | $action = $urlArray ? $urlArray[0] : 'index'; 33 | 34 | array_shift($urlArray); 35 | $param = $urlArray ? $urlArray : array(); 36 | } 37 | 38 | $controller = $controllerName . 'Controller'; 39 | 40 | if ((int)method_exists($controller, $action)) { 41 | //error_log($action); 42 | $dispatch = new $controller($controllerName, $action); 43 | call_user_func_array(array( 44 | $dispatch, 45 | $action 46 | ), $param); 47 | } else { 48 | header('location:' . APP_URL); 49 | //error_log($controller . " Controller does not exist."); 50 | //exit($controller . "Controller does not exist."); 51 | } 52 | } 53 | 54 | public function setReporting() { 55 | if (APP_DEBUG === true) { 56 | error_reporting(E_ALL); 57 | ini_set('display_errors', 'On'); 58 | } else { 59 | error_reporting(E_ALL); 60 | ini_set('display_errors', 'Off'); 61 | ini_set('log_errors', 'On'); 62 | ini_set('error_log', RUNTIME_PATH . 'logs/error.log'); 63 | } 64 | } 65 | 66 | public function stripSlashesDeep($value) { 67 | $value = is_array($value) ? array_map(array( 68 | $this, 69 | 'stripSlashesDeep' 70 | ), $value) : stripslashes($value); 71 | return $value; 72 | } 73 | 74 | public function removeMagicQuotes() { 75 | if (get_magic_quotes_gpc()) { 76 | $_GET = isset($_GET) ? $this->stripSlashesDeep($_GET) : ''; 77 | $_POST = isset($_POST) ? $this->stripSlashesDeep($_POST) : ''; 78 | $_COOKIE = isset($_COOKIE) ? $this->stripSlashesDeep($_COOKIE) : ''; 79 | $_SESSION = isset($_SESSION) ? $this->stripSlashesDeep($_SESSION) : ''; 80 | } 81 | } 82 | 83 | public function unregisterGlobals() { 84 | if (ini_get('register_globals')) { 85 | $array = array( 86 | '_SESSION', 87 | '_POST', 88 | '_GET', 89 | '_COOKIE', 90 | '_REQUEST', 91 | '_SERVER', 92 | '_ENV', 93 | '_FILES' 94 | ); 95 | foreach ($array as $value) { 96 | foreach ($GLOBALS[$value] as $key => $var) { 97 | if ($var === $GLOBALS[$key]) { 98 | unset($GLOBALS[$key]); 99 | } 100 | } 101 | } 102 | } 103 | } 104 | 105 | public static function loadClass($class) { 106 | $frameworks = FRAME_PATH . $class . '.class.php'; 107 | $controllers = APP_PATH . 'application/controllers/' . $class . '.class.php'; 108 | $models = APP_PATH . 'application/models/' . $class . '.class.php'; 109 | 110 | if (file_exists($frameworks)) { 111 | include $frameworks; 112 | } elseif (file_exists($controllers)) { 113 | include $controllers; 114 | } elseif (file_exists($models)) { 115 | include $models; 116 | } else { 117 | // Error 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /application/views/project/edit.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | *.jpg, *.jpge, *.png (less than 1MB) 29 | 30 | 31 | 32 |
33 | 34 |
35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 |
43 | 44 | 45 | 46 | 47 | 48 |
49 | 50 |
51 | 52 | 53 | less than 2MB 54 | 55 | 56 | 57 |
58 | 59 | 60 |
61 | 62 | 63 | 64 | 65 | 66 |
67 | 68 | 69 | 73 |
74 |
75 | -------------------------------------------------------------------------------- /application/views/header.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 24 | 25 | Crowdfunding 26 | 27 | 28 | -------------------------------------------------------------------------------- /application/views/user/profile.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
32 | 33 |
34 | 35 | 36 | 37 | 38 | 39 |
40 | 41 |
42 | 43 | 44 | 45 | 46 | 47 |
48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 | 57 |
58 | 59 | 60 | 61 | 62 | 63 |
64 | 65 |
66 | 67 | 68 |
69 | 70 |
71 | 72 | 73 | 74 | 75 | 76 |
77 |
78 | 79 |
80 |
81 |
-------------------------------------------------------------------------------- /application/views/project/create.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 |

Project successfully created!

6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |

16 | 17 |
18 | 19 | 20 | *.jpg, *.gif, *.png (less than 1MB) 21 | 22 | 23 | 24 |
25 | 26 |
27 | 28 | 29 | 30 | 31 | 32 |
33 | 34 |
35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 |
43 | 44 | 45 | 46 | 47 | 48 |
49 | 50 |
51 | 52 | 53 | 54 | 55 | 56 |
57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 |
65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 |
73 | 74 |
75 | 76 | 77 | 78 | 79 | 80 |
81 | 82 |
83 | 84 |
85 |
86 | 87 |
-------------------------------------------------------------------------------- /application/models/UserModel.class.php: -------------------------------------------------------------------------------- 1 | $value) { 7 | switch ($type) { 8 | case 'uname': 9 | // validate username 10 | if (empty($value)) { 11 | $errors['unameError'] = "username cannot be empty"; 12 | } else { 13 | if ($this->hasUname($value)) { 14 | $errors['unameError'] = "username already exists"; 15 | } 16 | } 17 | break; 18 | case 'upwd': 19 | // TODO validate password 20 | if (empty($value)) { 21 | $errors['upwdError'] = "password cannot be empty"; 22 | } else { 23 | 24 | } 25 | break; 26 | case 'name': 27 | // TODO validate realname 28 | if (empty($value)) { 29 | $errors['nameError'] = "name cannot be empty"; 30 | } else { 31 | if (!preg_match("/^[a-zA-Z ]*$/", $value)) { 32 | $errors['nameError'] = "invalid name"; 33 | } 34 | } 35 | break; 36 | case 'ccn': 37 | // TODO validate credit card number 38 | if (!is_numeric($value)) { 39 | $errors['ccnError'] = "invalid credit card number"; 40 | } 41 | break; 42 | case 'email': 43 | // TODO validate email address 44 | if (!filter_var($value, FILTER_VALIDATE_EMAIL)) { 45 | $errors['emailError'] = "invalid email address"; 46 | } 47 | break; 48 | case 'addr': 49 | // TODO validate address 50 | break; 51 | case 'interest': 52 | // TODO validate interest 53 | if (!preg_match("/^[a-zA-Z ]*(,[a-zA-Z ]*)*$/", $value)) { 54 | $errors['interestError'] = "invalid interest(s)"; 55 | } 56 | } 57 | } 58 | return $errors; 59 | } 60 | 61 | public function isInvalidUpdate($data) { 62 | $errors = array(); 63 | foreach ($data as $type => $value) { 64 | switch ($type) { 65 | case 'uname': 66 | // validate username 67 | break; 68 | case 'upwd': 69 | // TODO validate password 70 | if (empty($value)) { 71 | $errors['upwdError'] = "password cannot be empty"; 72 | } else { 73 | 74 | } 75 | break; 76 | case 'name': 77 | // TODO validate realname 78 | if (empty($value)) { 79 | $errors['nameError'] = "name cannot be empty"; 80 | } else { 81 | if (!preg_match("/^[a-zA-Z ]*$/", $value)) { 82 | $errors['nameError'] = "invalid name"; 83 | } 84 | } 85 | break; 86 | case 'ccn': 87 | // TODO validate credit card number 88 | if (!empty($value) && !is_numeric($value)) { 89 | $errors['ccnError'] = "invalid credit card number"; 90 | } 91 | break; 92 | case 'email': 93 | // TODO validate email address 94 | if (!empty($value) && !filter_var($value, FILTER_VALIDATE_EMAIL)) { 95 | $errors['emailError'] = "invalid email address"; 96 | } 97 | break; 98 | case 'addr': 99 | // TODO validate address 100 | break; 101 | case 'interest': 102 | // TODO validate interest 103 | if (!empty($value) && !preg_match("/^[a-zA-Z ]*(,[a-zA-Z ]*)*$/", $value)) { 104 | $errors['interestError'] = "invalid interest(s)"; 105 | } 106 | } 107 | } 108 | return $errors; 109 | } 110 | 111 | private function hasUname($uname) { 112 | $ret = false; 113 | if ($this->select($uname)) { 114 | $ret = true; 115 | } 116 | return $ret; 117 | } 118 | 119 | public function checkLogin() { 120 | if (session_status() == PHP_SESSION_NONE) { 121 | session_start(); 122 | } 123 | $ret = false; 124 | if (!isset($_SESSION['user']) || empty($_SESSION['user'])) { 125 | if (!empty($_COOKIE['username']) && !empty($_COOKIE['password'])) { 126 | // use cookies to login 127 | $user = $this->login($_COOKIE['username'], $_COOKIE['password']); 128 | if (!empty($user)) { 129 | $_SESSION['user'] = $user; 130 | $ret = true; 131 | } 132 | } 133 | } else { 134 | $ret = true; 135 | } 136 | return $ret; 137 | } 138 | 139 | public function login($username, $password) { 140 | $user = array(); 141 | if (($upwd = $this->select($username, 'upwd')) && password_verify($password, $upwd['upwd'])) { 142 | $user['username'] = $username; 143 | } 144 | return $user; 145 | } 146 | } -------------------------------------------------------------------------------- /sql/tables.sql: -------------------------------------------------------------------------------- 1 | Drop table if EXISTS`Rate`; 2 | Drop table if EXISTS`Follow`; 3 | Drop table if EXISTS`Comment`; 4 | Drop table if EXISTS`Like`; 5 | Drop table if EXISTS`Pledge`; 6 | Drop table if EXISTS`sample`; 7 | Drop table if EXISTS`project`; 8 | Drop table if EXISTS`user`; 9 | 10 | CREATE TABLE `User`( 11 | `uname` VARCHAR(40) NOT NULL, 12 | `upwd` BINARY(60) NULL, 13 | `name` VARCHAR(40) NULL, 14 | `ccn` VARCHAR(40) NULL, 15 | `email` VARCHAR(40) NULL, 16 | `addr` VARCHAR(40) NULL, 17 | `interest` VARCHAR(40) NULL, 18 | PRIMARY KEY (`uname`) 19 | ); 20 | 21 | CREATE TABLE `Project` ( 22 | `pid` INT NOT NULL, 23 | `pname` VARCHAR(40) NULL, 24 | `uname` VARCHAR(40) NULL, 25 | `description` VARCHAR(40) NULL, 26 | `profpic` VARCHAR(40) NULL, # filename of the profile picture 27 | `tag` VARCHAR(40) NULL, 28 | `minamount` INT NULL, 29 | `maxamount` INT NULL, 30 | `curamount` INT NULL, 31 | `posttime` DATETIME NULL, 32 | `status` VARCHAR(40) NULL, 33 | `endtime` DATETIME NULL, 34 | `actualendtime` DATETIME NULL, 35 | `plannedcompletiontime` DATETIME NULL, 36 | `actualcompletiontime` DATETIME NULL, 37 | `progress` INT NULL, 38 | PRIMARY KEY (`pid`), 39 | FOREIGN KEY (`uname`) REFERENCES `user`(`uname`) 40 | ); 41 | 42 | CREATE TABLE `Sample` ( 43 | `pid` INT NOT NULL, 44 | `filename` VARCHAR(40) NOT NULL, 45 | `uploadtime` DATETIME NULL, 46 | PRIMARY KEY (`filename`), 47 | FOREIGN KEY (`pid`) REFERENCES `project`(`pid`) 48 | ); 49 | 50 | # one user can back the same project for multiple times 51 | CREATE TABLE `Pledge` ( 52 | `uname` VARCHAR(40) NOT NULL, 53 | `pid` INT NOT NULL, 54 | `amount` INT NULL, 55 | `time` DATETIME NOT NULL, 56 | `charged` BOOLEAN NOT NULL, 57 | PRIMARY KEY (`pid`, `uname`, `time`), 58 | FOREIGN KEY (`pid`) REFERENCES `project`(`pid`), 59 | FOREIGN KEY (`uname`) REFERENCES `user`(`uname`) 60 | ); 61 | 62 | CREATE TABLE `Like` ( 63 | `uname` VARCHAR(40) NOT NULL, 64 | `pid` INT NOT NULL, 65 | `time` DATETIME NOT NULL, 66 | PRIMARY KEY (`pid`,`uname`), 67 | FOREIGN KEY (`pid`) REFERENCES `project`(`pid`), 68 | FOREIGN KEY (`uname`) REFERENCES `user`(`uname`) 69 | ); 70 | 71 | CREATE TABLE `Comment` ( 72 | `uname` VARCHAR(40) NOT NULL, 73 | `pid` INT NOT NULL, 74 | `content` VARCHAR(40) NULL, 75 | `time` DATETIME not NULL, 76 | PRIMARY KEY (`pid`,`uname`,`time`), 77 | FOREIGN KEY (`pid`) REFERENCES `project`(`pid`), 78 | FOREIGN KEY (`uname`) REFERENCES `user`(`uname`) 79 | ); 80 | 81 | # one user cannot rate the same project again 82 | CREATE TABLE `Rate` ( 83 | `uname` VARCHAR(40) NOT NULL, 84 | `pid` INT NOT NULL, 85 | `score` FLOAT NULL, 86 | `time` DATETIME NOT NULL, 87 | PRIMARY KEY (`pid`,`uname`), 88 | FOREIGN KEY (`pid`) REFERENCES `project`(`pid`), 89 | FOREIGN KEY (`uname`) REFERENCES `user`(`uname`) 90 | ); 91 | 92 | CREATE TABLE `Follow` ( 93 | `uname1` VARCHAR(40) NOT NULL, 94 | `uname2` VARCHAR(40) NOT NULL, 95 | `time` DATETIME NOT NULL, 96 | PRIMARY KEY (`uname1`,`uname2`), 97 | FOREIGN KEY (`uname1`) REFERENCES `user`(`uname`), 98 | FOREIGN KEY (`uname2`) REFERENCES `user`(`uname`) 99 | ); 100 | 101 | CREATE TABLE `SearchHistory` ( 102 | `uname` VARCHAR(40) NOT NULL, 103 | `keyword` VARCHAR(40) NOT NULL, 104 | `time` DATETIME NOT NULL, 105 | PRIMARY KEY (`uname`,`keyword`, `time`), 106 | FOREIGN KEY (`uname`) REFERENCES `user`(`uname`) 107 | ); 108 | 109 | DROP TRIGGER IF EXISTS `trig_before_insert_pledge`; 110 | delimiter // 111 | CREATE TRIGGER `trig_before_insert_pledge` AFTER INSERT ON `pledge` 112 | FOR EACH ROW 113 | BEGIN 114 | UPDATE `project` AS P 115 | SET `curamount` = `curamount` + new.`amount` 116 | WHERE P.`pid` = new.`pid`; 117 | IF EXISTS (SELECT * FROM `project` AS P WHERE P.`pid` = new.`pid` AND `curamount` > `maxamount`) THEN 118 | UPDATE `project` AS P 119 | SET `status` = 'progressing', `actualendtime` = CURRENT_TIMESTAMP, `progress` = '0' 120 | WHERE P.`pid` = new.`pid`; 121 | END IF; 122 | END;// 123 | delimiter ; 124 | 125 | DROP EVENT IF EXISTS event_charge; 126 | CREATE EVENT IF NOT EXISTS event_charge 127 | ON SCHEDULE EVERY 1 MINUTE 128 | DO 129 | UPDATE `pledge` AS G 130 | SET `charged` = TRUE 131 | WHERE G.`charged` = FALSE AND G.`pid` IN (SELECT `pid` FROM `project` WHERE `status` = 'progressing' OR `status` = 'completed'); -------------------------------------------------------------------------------- /application/views/user/home.php: -------------------------------------------------------------------------------- 1 | 6 |
7 | 8 |
9 | 12 | 13 | 14 |
15 |

16 | "> 17 | 18 | posted "> 19 | on . 20 |

21 |
22 | 23 | 24 |

None of those you are following posted any project yet. 25 | 26 |

27 | 28 |
29 | 32 | 33 | 34 |
35 |

36 | "> 37 | 38 | liked "> 39 | at . 40 |

41 |
42 | 43 | 44 |

None of those you are following liked any project yet. 45 | 46 |

47 | 48 |
49 | 52 | 53 | 54 |
55 |
56 |

57 | 64 |
65 |
66 | 67 | 68 | 69 |

None of those you are following commented any project yet. 70 | 71 |

72 | 73 |
74 | 77 | 78 | 79 |
80 |

81 | "> 82 | 83 | funded "> 84 | with $ at . 85 |

86 |
87 | 88 | 89 |

None of those you are following funded any project yet. 90 | 91 |

92 | 93 |
94 | 97 | 98 | 99 |
100 |

101 | "> 102 | 103 | rated "> 104 | with score at . 105 |

106 |
107 | 108 | 109 |

None of those you are following rated any project yet. 110 | 111 |

112 |
-------------------------------------------------------------------------------- /fastphp/Sql.class.php: -------------------------------------------------------------------------------- 1 | PDO::FETCH_ASSOC 20 | ); 21 | $this->_dbHandle = new PDO($dsn, $user, $pass, $option); 22 | } catch (PDOException $e) { 23 | exit('Error: ' . $e->getMessage()); 24 | } 25 | } 26 | 27 | public function where($filter) { 28 | if (!empty($filter)) { 29 | $this->filter .= ' WHERE '; 30 | $this->filter .= $filter; 31 | } 32 | 33 | return $this; 34 | } 35 | 36 | public function order($order = array()) { 37 | if (isset($order)) { 38 | $this->filter .= ' ORDER BY '; 39 | $this->filter .= implode(',', $order); 40 | } 41 | 42 | return $this; 43 | } 44 | 45 | public function selectAll() { 46 | $sql = sprintf("select * from `%s` %s", $this->_table, $this->filter); 47 | $sth = $this->_dbHandle->prepare($sql); 48 | $sth->execute(); 49 | 50 | return $sth->fetchAll(PDO::FETCH_ASSOC); 51 | } 52 | 53 | public function select($id, $cols = array()) { 54 | $sql = sprintf("select %s from `%s` where `%s` = :id", $this->formatSelect($cols), $this->_table, $this->_primaryKey); 55 | $sth = $this->_dbHandle->prepare($sql); 56 | $sth->execute(array (':id' => $id)); 57 | return $sth->fetch(PDO::FETCH_ASSOC); 58 | } 59 | 60 | public function delete($id) { 61 | $sql = sprintf("delete from `%s` where `%s` = :id", $this->_table, $this->_primaryKey); 62 | $sth = $this->_dbHandle->prepare($sql); 63 | $sth->execute(array (':id' => $id)); 64 | 65 | return $sth->rowCount(); 66 | } 67 | 68 | public function query($sql) { 69 | $sth = $this->_dbHandle->prepare($sql); 70 | $sth->execute(); 71 | 72 | return $sth->rowCount(); 73 | } 74 | 75 | public function count() { 76 | $sql = sprintf("select count(pid) from `%s`", $this->_table); 77 | $sth = $this->_dbHandle->prepare($sql); 78 | $sth->execute(); 79 | return $sth->fetch(PDO::FETCH_ASSOC); 80 | } 81 | 82 | public function add($data) { 83 | $sql = sprintf("insert into `%s` %s", $this->_table, $this->formatInsert($data)); 84 | return $this->query($sql); 85 | } 86 | 87 | public function update($id, $data) { 88 | $sql = sprintf("update `%s` set %s where `%s` = :id", $this->_table, $this->formatUpdate($data), $this->_primaryKey); 89 | $sth = $this->_dbHandle->prepare($sql); 90 | $sth->execute(array(':id' => $id)); 91 | return $sth->rowCount(); 92 | } 93 | 94 | protected function getFilter($conds, $op, $logic) { 95 | $ret = ''; 96 | switch ($op) { 97 | case Sql::OP_EQ: 98 | $op = '='; 99 | break; 100 | case Sql::OP_LIKE: 101 | $op = 'like'; 102 | break; 103 | default: 104 | break; 105 | } 106 | switch ($logic) { 107 | case Sql::LOGIC_AND: 108 | $logic = ' and '; 109 | break; 110 | case Sql::LOGIC_OR: 111 | $logic = ' or '; 112 | break; 113 | default: 114 | break; 115 | } 116 | foreach ($conds as $key => $value) { 117 | if (!empty($ret)) { 118 | $ret .= $logic; 119 | } 120 | $ret .= '`' . $key . '`' . $op . $this->_dbHandle->quote($value); 121 | } 122 | return $ret; 123 | } 124 | 125 | private function formatSelect($cols) { 126 | $ret = ''; 127 | if (!empty($cols)) { 128 | if (is_array($cols)) { 129 | foreach ($cols as &$col) { 130 | $col = '`' . $col . '`'; 131 | } 132 | $ret = implode(',', $cols); 133 | } else { 134 | $ret = $cols; 135 | } 136 | } else { 137 | $ret = '*'; 138 | } 139 | return $ret; 140 | } 141 | 142 | // Convert array to insertion queries 143 | private function formatInsert($data) { 144 | $fields = array(); 145 | $values = array(); 146 | foreach ($data as $key => $value) { 147 | $fields[] = sprintf("`%s`", $key); 148 | $values[] = (empty($value) && $value!='0') ? "null" : sprintf("'%s'", $value); 149 | } 150 | 151 | $field = implode(',', $fields); 152 | $value = implode(',', $values); 153 | 154 | return sprintf("(%s) values (%s)", $field, $value); 155 | } 156 | 157 | // Convert array to update queries 158 | private function formatUpdate($data) { 159 | $fields = array(); 160 | foreach ($data as $key => $value) { 161 | $fields[] = sprintf("`%s` = %s", $key, $this->_dbHandle->quote($value)); 162 | } 163 | 164 | return implode(',', $fields); 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /application/models/ProjectModel.class.php: -------------------------------------------------------------------------------- 1 | where($this->getFilter($conds, Sql::OP_LIKE, Sql::LOGIC_OR)); 21 | } 22 | $this->order(array('`posttime` desc')); 23 | return $this->selectAll(); 24 | } 25 | 26 | function add($data) { 27 | if (session_status() == PHP_SESSION_NONE) { 28 | session_start(); 29 | } 30 | $data['pid'] = $this->count()['count(pid)'] + 1; 31 | if (isset($data['profpic'])) { 32 | $data['profpic'] = $this->acceptFile($data['profpic']); 33 | } 34 | $data['uname'] = $_SESSION['user']['username']; 35 | $data['curamount'] = '0'; 36 | $data['posttime'] = date("Y-m-d"); 37 | $data['status'] = "crowdfunding"; 38 | return parent::add($data); 39 | } 40 | 41 | function update($pid,$data) { 42 | if (isset($data['profpic'])) { 43 | $data['profpic'] = $this->acceptFile($data['profpic']); 44 | } 45 | if (isset($data['progress'])) { 46 | if ($data['progress'] == '100') { 47 | $data['status'] = 'completed'; 48 | $data['actualcompletiontime'] = date('Y-m-d h-m-s'); 49 | } 50 | } 51 | if (isset($data['sample'])) { 52 | $dst = SAMPLE_PROJ_PATH . $pid . "/"; 53 | if (!is_dir($dst)) { 54 | mkdir($dst, 0777, true); 55 | } 56 | move_uploaded_file($data['sample']["tmp_name"], $dst . $data['sample']['name']); 57 | (new SampleModel())->add(array('pid'=>$pid, 'filename'=>$data['sample']['name'], 'uploadtime'=>date("Y-m-d h:m:s"))); 58 | unset($data['sample']); 59 | } 60 | return parent::update($pid,$data); 61 | } 62 | 63 | function isInvalid($data) { 64 | $errors = array(); 65 | foreach ($data as $type => $value) { 66 | switch ($type) { 67 | case 'pid' : 68 | break; 69 | case 'pname' : 70 | if (empty($value)) { 71 | $errors['pnameError'] = "project name cannot be empty"; 72 | } 73 | break; 74 | case 'uname' : 75 | if (empty($value)) { 76 | $errors['unameError'] = "user name cannot be empty"; 77 | } 78 | break; 79 | case 'description' : 80 | break; 81 | case 'profpic' : 82 | if ((($value["type"] == "image/gif") 83 | || ($value["type"] == "image/jpeg") 84 | || ($value["type"] == "image/pjpeg") 85 | || ($value["type"] == "image/png")) 86 | && ($value["size"] < 100000)) { 87 | } 88 | else { 89 | $errors['profpicError'] = "invalid profpic file"; 90 | } 91 | break; 92 | case 'tag' : 93 | if (! preg_match("/^[a-zA-Z ]*(,[a-zA-Z ]*)*$/", $value)) { 94 | $errors['tagError'] = "invalid tag(s)"; 95 | } 96 | break; 97 | case 'minamount' : 98 | if (empty($value)) { 99 | $errors['minError'] = "min fund amount cannot be empty"; 100 | } else { 101 | if (! is_numeric($value)) { 102 | $errors['minError'] = "invalid min fund amount"; 103 | } 104 | } 105 | break; 106 | case 'maxamount' : 107 | if (empty($value)) { 108 | $errors['maxError'] = "max fund amount cannot be empty"; 109 | } else { 110 | if (! is_numeric($value)) { 111 | $errors['maxError'] = "invalid max fund amount"; 112 | } else { 113 | if (isset($data['minamount'])) { 114 | if (! empty($data['minamount'])) { 115 | if ($value < $data['minamount']) { 116 | $errors['maxError'] = "invalid max fund amount"; 117 | } 118 | } else 119 | $errors['maxError'] = "invalid max fund amount"; 120 | } else 121 | $errors['maxError'] = "invalid max fund amount"; 122 | } 123 | } 124 | 125 | break; 126 | case 'curamount' : 127 | if (empty($value)) { 128 | $errors['curamountError'] = "current fund amount cannot be empty"; 129 | } else { 130 | if (! is_numeric($value)) { 131 | $errors['curamountError'] = "invalid current fund amount"; 132 | } 133 | } 134 | break; 135 | case 'posttime' : 136 | if (empty($value)) { 137 | $errors['posttimeError'] = "post project time cannot be empty"; 138 | } 139 | break; 140 | case 'status' : 141 | if (empty($value)) { 142 | $errors['statusError'] = "project status cannot be empty"; 143 | } 144 | break; 145 | case 'endtime' : 146 | if (empty($value)) { 147 | $errors['endtimeError'] = "funding endtime cannot be empty"; 148 | } else { 149 | if (strtotime($value) < strtotime(date("Y-m-d"))) { 150 | $errors['endtimeError'] = "invalid funding endtime"; 151 | } 152 | } 153 | break; 154 | case 'actualendtime' : 155 | break; 156 | case 'plannedcompletiontime' : 157 | if (empty($value)) { 158 | $errors['pctError'] = "project planned completion time cannot be empty"; 159 | } else { 160 | if (strtotime($value) < strtotime(date("Y-m-d"))) { 161 | $errors['pctError'] = "invalid project planned completion time"; 162 | } 163 | } 164 | break; 165 | case 'actualcompletiontime' : 166 | break; 167 | case 'progressing' : 168 | 169 | break; 170 | } 171 | } 172 | return $errors; 173 | } 174 | 175 | function isNewInvalid($pid,$data) { 176 | $projectModel = new ProjectModel(); 177 | $olddata = $projectModel->select($pid); 178 | $errors = array(); 179 | 180 | foreach ($data as $type => $value) { 181 | switch ($type) { 182 | case 'pid' : 183 | break; 184 | case 'pname' : 185 | if (empty($value)) { 186 | $errors['pnameError'] = "project name cannot be empty"; 187 | } 188 | break; 189 | case 'uname' : 190 | if (empty($value)) { 191 | $errors['unameError'] = "user name cannot be empty"; 192 | } 193 | break; 194 | case 'description' : 195 | break; 196 | case 'profpic' : 197 | if ((($value["type"] == "image/gif") 198 | || ($value["type"] == "image/jpeg") 199 | || ($value["type"] == "image/pjpeg") 200 | || ($value["type"] == "image/png")) 201 | && ($value["size"] < 1000000)) { 202 | } else { 203 | $errors['profpicError'] = "invalid profpic file"; 204 | } 205 | break; 206 | case 'tag' : 207 | if (! preg_match("/^[a-zA-Z ]*(,[a-zA-Z ]*)*$/", $value)) { 208 | $errors['tagError'] = "invalid tag(s)"; 209 | } 210 | break; 211 | case 'minamount' : 212 | if (empty($value)) { 213 | $errors['minError'] = "min fund amount cannot be empty"; 214 | } else { 215 | if (! is_numeric($value)) { 216 | $errors['minError'] = "invalid min fund amount"; 217 | } 218 | } 219 | break; 220 | case 'maxamount' : 221 | if (empty($value)) { 222 | $errors['maxError'] = "max fund amount cannot be empty"; 223 | } else { 224 | if (! is_numeric($value)) { 225 | $errors['maxError'] = "invalid max fund amount"; 226 | } else { 227 | if (isset($data['minamount'])) { 228 | if (! empty($data['minamount'])) { 229 | if ($value < $data['minamount']) { 230 | $errors['maxError'] = "invalid max fund amount"; 231 | } 232 | } else 233 | $errors['maxError'] = "invalid max fund amount"; 234 | } else 235 | $errors['maxError'] = "invalid max fund amount"; 236 | } 237 | } 238 | 239 | break; 240 | case 'curamount' : 241 | if (empty($value)) { 242 | $errors['curamountError'] = "current fund amount cannot be empty"; 243 | } else { 244 | if (! is_numeric($value)) { 245 | $errors['curamountError'] = "invalid current fund amount"; 246 | } 247 | } 248 | break; 249 | case 'posttime' : 250 | if (empty($value)) { 251 | $errors['posttimeError'] = "post project time cannot be empty"; 252 | } 253 | break; 254 | case 'status' : 255 | if (empty($value)) { 256 | $errors['statusError'] = "project status cannot be empty"; 257 | } 258 | break; 259 | case 'endtime' : 260 | if (empty($value)) { 261 | $errors['endtimeError'] = "funding endtime cannot be empty"; 262 | } else { 263 | if (strtotime($value) < strtotime(date("Y-m-d"))) { 264 | $errors['endtimeError'] = "invalid funding endtime"; 265 | } 266 | } 267 | break; 268 | case 'actualendtime' : 269 | break; 270 | case 'plannedcompletiontime' : 271 | if (empty($value)) { 272 | $errors['pctError'] = "project planned completion time cannot be empty"; 273 | } else { 274 | if (strtotime($value) < strtotime(date("Y-m-d"))) { 275 | $errors['pctError'] = "invalid project planned completion time"; 276 | } 277 | } 278 | break; 279 | case 'actualcompletiontime' : 280 | break; 281 | case 'progress' : 282 | if ($value < $olddata['progress'] || $value < 0 || $value > 100) { 283 | $errors['progressError'] = "invalid progress value"; 284 | } 285 | break; 286 | } 287 | } 288 | return $errors; 289 | } 290 | 291 | private function acceptFile($file) { 292 | $uptype = explode(".", $file["name"]); 293 | $newname = date("Y-m-d-h-m-s") . ".".$uptype[1]; 294 | move_uploaded_file($file["tmp_name"], IMG_PROJ_PATH . "profile/" . $newname); 295 | return $newname; 296 | } 297 | } 298 | -------------------------------------------------------------------------------- /application/controllers/UserController.class.php: -------------------------------------------------------------------------------- 1 | getInput($_POST['usrname']); 9 | $data['upwd'] = $this->getInput($_POST['pwd']); 10 | 11 | $userModel = new UserModel(); 12 | $user = $userModel->login($data['uname'], $data['upwd']); 13 | if (empty($user)) { 14 | $this->assign('errors', array('error' => 'wrong username or password')); 15 | $this->assign('mode', 'failed'); 16 | } else { 17 | if (!empty($user)) { 18 | // successfully logged in 19 | session_start(); 20 | $_SESSION['user'] = $user; 21 | if (!empty($_POST['remember'])) { 22 | setcookie("username", $data['uname'], time() + UserController::EXPIRE_SEC); 23 | setcookie("password", $data['upwd'], time() + UserController::EXPIRE_SEC); 24 | } 25 | $this->assign('mode', 'succeeded'); 26 | } else { 27 | // failed to log in 28 | $this->assign('mode', 'failed'); 29 | } 30 | } 31 | } else { 32 | if ((new UserModel())->checkLogin()) { 33 | // login page can only be accessed by guests 34 | header('location:' . APP_URL); 35 | } else { 36 | $this->assign('mode', 'login'); 37 | } 38 | } 39 | $this->assign('title', 'Login'); 40 | $this->render(); 41 | } 42 | 43 | function logout() { 44 | if (session_status() == PHP_SESSION_NONE) { 45 | session_start(); 46 | } 47 | if (isset($_SESSION['user'])) { 48 | unset($_SESSION['user']); 49 | if(!empty($_COOKIE['username']) || !empty($_COOKIE['password'])){ 50 | setcookie("username", null, time() - UserController::EXPIRE_SEC); 51 | setcookie("password", null, time() - UserController::EXPIRE_SEC); 52 | } 53 | } 54 | header('location:' . APP_URL); 55 | } 56 | 57 | function register() { 58 | if ((new UserModel())->checkLogin()) { 59 | // register page can only be accessed by guests 60 | header('location:' . APP_URL); 61 | } else { 62 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 63 | $data = $this->getInsertData(); 64 | // 1. validate input data 2. assign error message 65 | $userModel = new UserModel(); 66 | if ($res = $userModel->isInvalidInsert($data)) { 67 | $this->assign('errors', $res); 68 | $this->assign('mode', 'failed'); 69 | } else { 70 | $data['upwd'] = password_hash($data['upwd'], PASSWORD_DEFAULT); 71 | if ($userModel->add($data)) { 72 | // successfully registered 73 | $this->assign('mode', 'succeeded'); 74 | } else { 75 | // failed to register 76 | $this->assign('mode', 'failed'); 77 | } 78 | } 79 | } else { 80 | $this->assign('mode', 'register'); // show register page 81 | } 82 | } 83 | $this->assign('title', 'Register'); 84 | $this->render(); 85 | } 86 | 87 | function home() { 88 | $userModel = new UserModel(); 89 | if ($userModel->checkLogin()) { 90 | $uname = $_SESSION['user']['username']; 91 | if (!empty($followingPledges = (new FollowModel())->getFollowingPledges($uname))) { 92 | $this->assign('followingPledges', $followingPledges); 93 | } 94 | if (!empty($followingRates = (new FollowModel())->getFollowingRates($uname))) { 95 | $this->assign('followingRates', $followingRates); 96 | } 97 | if (!empty($followingProjects = (new FollowModel())->getFollowingProjects($uname))) { 98 | $this->assign('followingProjects', $followingProjects); 99 | } 100 | if (!empty($followingLikes = (new FollowModel())->getFollowingLikes($uname))) { 101 | $this->assign('followingLikes', $followingLikes); 102 | } 103 | if (!empty($followingComments = (new FollowModel())->getFollowingComments($uname))) { 104 | $this->assign('followingComments', $followingComments); 105 | } 106 | $this->render(); 107 | } else { 108 | header("location:" . APP_URL . "/user/login"); 109 | } 110 | } 111 | 112 | function profile() { 113 | $userModel = new UserModel(); 114 | if ($userModel->checkLogin()) { 115 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 116 | $data = $this->getUpdateData(); 117 | $res = array(); 118 | if (empty($userModel->login($data['uname'], $data['upwd'])) || $res = $userModel->isInvalidUpdate($data)) { 119 | if (empty($res)) { 120 | $res['upwdError'] = "wrong password"; 121 | } 122 | $this->assign('errors', $res); 123 | $this->assign('mode', 'failed'); 124 | } else { 125 | if (isset($data['newpwd'])) { 126 | $data['upwd'] = $data['newpwd']; 127 | unset($data['newpwd']); 128 | } 129 | $data['upwd'] = password_hash($data['upwd'], PASSWORD_DEFAULT); 130 | if ($userModel->update($data['uname'], $data)) { 131 | // successfully updated 132 | $this->assign('mode', 'succeeded'); 133 | } else { 134 | // failed to update 135 | $this->assign('mode', 'failed'); 136 | } 137 | } 138 | } else { 139 | $this->assign('mode', 'profile'); 140 | } 141 | if (session_status() == PHP_SESSION_NONE) { 142 | session_start(); 143 | } 144 | $data = $userModel->select($_SESSION['user']['username']); 145 | $this->assign('data', $data); 146 | $this->assign('title', 'Profile'); 147 | $this->render(); 148 | } else { 149 | header("location:" . APP_URL . "/user/login"); 150 | } 151 | } 152 | 153 | function view($uname) { 154 | if (empty($uname) || empty($row = (new UserModel())->select($uname))) { 155 | header("location:" . APP_URL); 156 | } 157 | $guest = ""; 158 | if ((new UserModel())->checkLogin()) { 159 | if (session_status() == PHP_SESSION_NONE) { 160 | session_start(); 161 | } 162 | $guest = $_SESSION['user']['username']; 163 | } 164 | if (empty($guest)) { 165 | $this->assign('mode', 'guest'); 166 | } else if ($guest == $row['uname']) { 167 | header("location:" . APP_URL . "/user/profile"); 168 | } else { 169 | $this->assign('hasFollowed', (new FollowModel())->hasFollowed($guest, $row['uname'])); 170 | $this->assign('mode', 'user'); 171 | } 172 | $this->assign('row', $row); 173 | $this->render(); 174 | } 175 | 176 | function follow($uname) { 177 | if (empty($uname) || empty($row = (new UserModel())->select($uname, array('uname')))) { 178 | header("location:" . APP_URL); 179 | } 180 | $guest = ""; 181 | if ((new UserModel())->checkLogin()) { 182 | if (session_status() == PHP_SESSION_NONE) { 183 | session_start(); 184 | } 185 | $guest = $_SESSION['user']['username']; 186 | } 187 | if (empty($guest)) { 188 | header("location:" . APP_URL . "/user/login"); 189 | } else if ($guest == $row['uname']) { 190 | header("location:" . APP_URL . "/user/profile"); 191 | } else { 192 | $followModel = new FollowModel(); 193 | $this->assign('uname2', $row['uname']); 194 | if ($followModel->hasFollowed($guest, $row['uname'])) { 195 | $this->assign('mode', 'followed'); 196 | } else { 197 | if ($followModel->add(array('uname1'=>$guest, 'uname2'=>$row['uname']))) { 198 | $this->assign('mode', 'succeeded'); 199 | } else { 200 | $this->assign('mode', 'failed'); 201 | } 202 | } 203 | } 204 | $this->render(); 205 | } 206 | 207 | function unfollow($uname) { 208 | if (empty($uname) || empty($row = (new UserModel())->select($uname, array('uname')))) { 209 | header("location:" . APP_URL); 210 | } 211 | $guest = ""; 212 | if ((new UserModel())->checkLogin()) { 213 | if (session_status() == PHP_SESSION_NONE) { 214 | session_start(); 215 | } 216 | $guest = $_SESSION['user']['username']; 217 | } 218 | if (empty($guest)) { 219 | header("location:" . APP_URL . "/user/login"); 220 | } else if ($guest == $row['uname']) { 221 | header("location:" . APP_URL . "/user/profile"); 222 | } else { 223 | $followModel = new FollowModel(); 224 | $this->assign('uname2', $row['uname']); 225 | if (!$followModel->hasFollowed($guest, $row['uname'])) { 226 | $this->assign('mode', 'notfollowed'); 227 | } else { 228 | if ($followModel->delete(array('uname1'=>$guest, 'uname2'=>$row['uname']))) { 229 | $this->assign('mode', 'succeeded'); 230 | } else { 231 | $this->assign('mode', 'failed'); 232 | } 233 | } 234 | } 235 | $this->render(); 236 | } 237 | 238 | function history() { 239 | $userModel = new UserModel(); 240 | if ($userModel->checkLogin()) { 241 | if (session_status() == PHP_SESSION_NONE) { 242 | session_start(); 243 | } 244 | $uname = $_SESSION['user']['username']; 245 | if (!empty($rateHistory = (new RateModel())->getHistory($uname))) { 246 | $this->assign('rateHistory', $rateHistory); 247 | } 248 | if (!empty($pledgeHistory = (new PledgeModel())->getHistory($uname))) { 249 | $this->assign('pledgeHistory', $pledgeHistory); 250 | } 251 | if (!empty($searchHistory = (new SearchhistoryModel())->getHistory($uname))) { 252 | $this->assign('searchHistory', $searchHistory); 253 | } 254 | if (!empty($likeHistory = (new LikeModel())->getHistory($uname))) { 255 | $this->assign('likeHistory', $likeHistory); 256 | } 257 | } else { 258 | header("location:" . APP_URL . "/user/login"); 259 | } 260 | $this->render(); 261 | } 262 | 263 | function clearSearch() { 264 | $userModel = new UserModel(); 265 | if ($userModel->checkLogin()) { 266 | if (session_status() == PHP_SESSION_NONE) { 267 | session_start(); 268 | } 269 | $searchHistory = new SearchhistoryModel(); 270 | $searchHistory->clear($_SESSION['user']['username']); 271 | header("location:".APP_URL."/user/history"); 272 | } 273 | $this->render(); 274 | } 275 | 276 | function getInsertData() { 277 | $data['uname'] = $this->getInput($_POST['usrname']); 278 | $data['upwd'] = $this->getInput($_POST['pwd']); 279 | $data['name'] = $this->getInput($_POST['realname']); 280 | if (isset($_POST['newpwd']) && !empty($_POST['newpwd'])) { 281 | $data['newpwd'] = $this->getInput($_POST['newpwd']); 282 | } 283 | if (isset($_POST['creditcardnum']) && !empty($_POST['creditcardnum'])) { 284 | $data['ccn'] = $this->getInput($_POST['creditcardnum']); 285 | } 286 | if (isset($_POST['email']) && !empty($_POST['email'])) { 287 | $data['email'] = $this->getInput($_POST['email']); 288 | } 289 | if (isset($_POST['addr']) && !empty($_POST['addr'])) { 290 | $data['addr'] = $this->getInput($_POST['addr']); 291 | } 292 | if (isset($_POST['interest']) && !empty($_POST['interest'])) { 293 | $data['interest'] = $this->getInput($_POST['interest']); 294 | } 295 | return $data; 296 | } 297 | 298 | function getUpdateData() { 299 | $data['uname'] = $this->getInput($_POST['usrname']); 300 | $data['upwd'] = $this->getInput($_POST['pwd']); 301 | $data['name'] = $this->getInput($_POST['realname']); 302 | if (isset($_POST['newpwd']) && !empty($_POST['newpwd'])) { 303 | $data['newpwd'] = $this->getInput($_POST['newpwd']); 304 | } 305 | $data['ccn'] = $this->getInput($_POST['creditcardnum']); 306 | $data['email'] = $this->getInput($_POST['email']); 307 | $data['addr'] = $this->getInput($_POST['addr']); 308 | $data['interest'] = $this->getInput($_POST['interest']); 309 | return $data; 310 | } 311 | } -------------------------------------------------------------------------------- /application/controllers/ProjectController.class.php: -------------------------------------------------------------------------------- 1 | getInput($_POST['keyword']); 9 | } 10 | $this->assign('result', $projectModel->selectKeyword($keyword, $type)); 11 | 12 | if ((new UserModel())->checkLogin()) { 13 | if (session_status() == PHP_SESSION_NONE) { 14 | session_start(); 15 | } 16 | if (!empty($keyword)) { 17 | (new SearchhistoryModel())->add(array('uname'=>$_SESSION['user']['username'], 'keyword'=>$keyword)); 18 | } 19 | $this->assign('user', $_SESSION['user']['username']); 20 | $this->assign('likeModel', new LikeModel()); 21 | } 22 | 23 | $this->render(); 24 | } 25 | 26 | function user($uname="") { 27 | $projectModel = new ProjectModel(); 28 | $this->assign('result', $projectModel->selectKeyword($uname, 'user')); 29 | 30 | if ((new UserModel())->checkLogin()) { 31 | if (session_status() == PHP_SESSION_NONE) { 32 | session_start(); 33 | } 34 | $this->assign('user', $_SESSION['user']['username']); 35 | $this->assign('likeModel', new LikeModel()); 36 | } 37 | 38 | $this->render(); 39 | } 40 | 41 | function comment($pid="") { 42 | if (empty($pid)) { 43 | header("location:" . APP_URL . "/project/search"); 44 | } 45 | if (!(new UserModel())->checkLogin()) { 46 | header("location:" . APP_URL . "/user/login"); 47 | } else { 48 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 49 | if (session_status() == PHP_SESSION_NONE) { 50 | session_start(); 51 | } 52 | $data['uname'] = $this->getInput($_SESSION['user']['username']); 53 | $data['pid'] = $this->getInput($pid); 54 | $data['content'] = $this->getInput($_POST['comment']); 55 | $commentModel = new CommentModel(); 56 | if (!$commentModel->isInvalid($data)) { 57 | $commentModel->add($data); 58 | } 59 | } 60 | header("location:" . APP_URL . "/project/view/" . $pid); 61 | } 62 | } 63 | 64 | function pledge() { 65 | $userModel = new UserModel(); 66 | if ($userModel->checkLogin()) { 67 | if (session_status() == PHP_SESSION_NONE) { 68 | session_start(); 69 | } 70 | $data = $userModel->select($_SESSION['user']['username'], array('uname', 'ccn')); 71 | if (empty($data['ccn'])) { 72 | $this->assign('mode', 'noccn'); 73 | } else { 74 | unset($data['ccn']); 75 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 76 | if (isset($_POST['pid']) && isset($_POST['pledge'])) { 77 | $data['pid'] = $_POST['pid']; 78 | $data['amount'] = $_POST['pledge']; 79 | $pledgeModel = new PledgeModel(); 80 | if ($pledgeModel->add($data)) { 81 | $this->assign('data', $data); 82 | $this->assign('mode', 'succeeded'); 83 | } else { 84 | $this->assign('mode', 'failed'); 85 | } 86 | } else { 87 | $this->assign('mode', "failed"); 88 | } 89 | } 90 | } 91 | } else { 92 | header("location:" . APP_URL . "user/login"); 93 | } 94 | $this->render(); 95 | } 96 | 97 | function rate() { 98 | $userModel = new UserModel(); 99 | if ($userModel->checkLogin()) { 100 | if (session_status() == PHP_SESSION_NONE) { 101 | session_start(); 102 | } 103 | $data = $userModel->select($_SESSION['user']['username'], array('uname')); 104 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 105 | if (isset($_POST['pid']) && isset($_POST['rate'])) { 106 | $data['pid'] = $_POST['pid']; 107 | $data['score'] = $_POST['rate']; 108 | $pledgeModel = new PledgeModel(); 109 | $rateModel = new RateModel(); 110 | // TODO check the project status 111 | if ($pledgeModel->exists($data['uname'], $data['pid']) && !$rateModel->exists($data['uname'], $data['pid'])) { 112 | if ($rateModel->add($data)) { 113 | $this->assign('mode', 'succeeded'); 114 | } else { 115 | $this->assign('mode', 'failed'); 116 | } 117 | } else { 118 | $this->assign('mode', 'denied'); 119 | } 120 | } else { 121 | $this->assign('mode', 'failed'); 122 | } 123 | $this->assign('data', $data); 124 | } 125 | $this->render(); 126 | } else { 127 | header("location:" . APP_URL . "user/login"); 128 | } 129 | } 130 | 131 | function create() { 132 | if (!(new UserModel())->checkLogin()) { 133 | // create page can only be accessed by users 134 | header('location:' . APP_URL); 135 | } else { 136 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 137 | $data = $this->getData(); 138 | $projectModel = new ProjectModel(); 139 | if ($res = $projectModel->isInvalid($data)) { 140 | $this->assign('errors', $res); 141 | $this->assign('mode', 'failed'); 142 | } else { 143 | if ($projectModel->add($data)) { 144 | // successfully created a project 145 | $this->assign('mode', 'succeeded'); 146 | } else { 147 | // failed to create a project 148 | $this->assign('mode', 'failed'); 149 | } 150 | } 151 | } else { 152 | $this->assign('mode', 'create'); // show create project page 153 | } 154 | } 155 | $this->assign('title', 'New Project'); 156 | $this->render(); 157 | } 158 | 159 | function edit($pid) { 160 | $userModel = new UserModel(); 161 | $projectModel = new ProjectModel(); 162 | if ($userModel->checkLogin()) { 163 | if ($_SERVER["REQUEST_METHOD"] == "POST") { 164 | $data = $this->getData(); 165 | $res = array(); 166 | if ($res = $projectModel->isNewInvalid($pid,$data)) { 167 | $this->assign('errors', $res); 168 | $this->assign('mode', 'failed'); 169 | } else { 170 | if ($projectModel->update($pid, $data)) { 171 | // successfully updated 172 | $this->assign('mode', 'succeeded'); 173 | } else { 174 | // failed to update 175 | $this->assign('mode', 'failed'); 176 | } 177 | } 178 | } else { 179 | $this->assign('mode', 'edit'); 180 | } 181 | $olddata = $projectModel->select($pid); 182 | $this->assign('data', $olddata); 183 | $this->assign('title', 'Project Edit'); 184 | $this->render(); 185 | } else { 186 | header("location:" . APP_URL . "/user/login"); 187 | } 188 | } 189 | 190 | function deleteSample($data) { 191 | $data = explode(' ', $data); 192 | if (!unlink(SAMPLE_PROJ_PATH . $data[0] . "/" . $data[1])) { 193 | 194 | } 195 | (new SampleModel())->delete($data); 196 | header("location:" . APP_URL . "/project/view/" . $data[0]); 197 | } 198 | 199 | function view($pid) { 200 | if (empty($pid)) { 201 | header("location:" . APP_URL . "/project/search"); 202 | } 203 | // mode: guest, user, owner 204 | $projectModel = new ProjectModel(); 205 | $mode = 'guest'; 206 | if (empty($row = $projectModel->select($pid))) { 207 | // project doesn't exist 208 | $mode = 'notfound'; 209 | } else { 210 | $this->assign('row', $row); 211 | if ((new UserModel())->checkLogin()) { 212 | // user or owner 213 | if (session_status() == PHP_SESSION_NONE) { 214 | session_start(); 215 | } 216 | if ($row['uname'] == $_SESSION['user']['username']) { 217 | $mode = 'owner'; 218 | } else { 219 | $mode = 'user'; 220 | } 221 | } 222 | $likeModel = new LikeModel(); 223 | $this->assign('likeCount', $likeModel->countLiked($pid)); 224 | $rateModel = new RateModel(); 225 | $pledgeModel = new PledgeModel(); 226 | if ((new UserModel())->checkLogin()) { 227 | if (session_status() == PHP_SESSION_NONE) { 228 | session_start(); 229 | } 230 | $this->assign('hasLiked', $likeModel->hasLiked($_SESSION['user']['username'], $pid)); 231 | $this->assign('hasPledged', $pledgeModel->exists($_SESSION['user']['username'], $pid)); 232 | $this->assign('hasRated', $rateModel->exists($_SESSION['user']['username'], $pid)); 233 | } 234 | 235 | $this->assign('backerCount', $pledgeModel->countBackers($pid)); 236 | 237 | $this->assign('rateCount', $rateModel->countRate($pid)); 238 | $this->assign('avgScore', number_format($rateModel->avgScore($pid), 1)); 239 | 240 | // get samples 241 | if (!empty($samples = (new SampleModel())->getSample($pid))) { 242 | $this->assign('hasSample', true); 243 | $this->assign('samples', $samples); 244 | } else { 245 | $this->assign('hasSample', false); 246 | } 247 | 248 | // get comments 249 | if (!empty($comments = (new CommentModel())->getComment($pid))) { 250 | $this->assign('hasComment', true); 251 | $this->assign('comments', $comments); 252 | } else { 253 | $this->assign('hasComment', false); 254 | } 255 | } 256 | $this->assign('mode', $mode); 257 | $this->render(); 258 | } 259 | 260 | function like($pid) { 261 | if (empty($pid) || empty($row = (new ProjectModel())->select($pid, array('pid', 'pname', 'uname')))) { 262 | header("location:" . APP_URL); 263 | } 264 | $guest = ""; 265 | if ((new UserModel())->checkLogin()) { 266 | if (session_status() == PHP_SESSION_NONE) { 267 | session_start(); 268 | } 269 | $guest = $_SESSION['user']['username']; 270 | } 271 | if (empty($guest)) { 272 | header("location:" . APP_URL . "/user/login"); 273 | } else { 274 | $likeModel = new LikeModel(); 275 | $this->assign('pid', $row['pid']); 276 | $this->assign('pname', $row['pname']); 277 | if ($likeModel->hasLiked($guest, $pid)) { 278 | $this->assign('mode', 'liked'); 279 | } else { 280 | if ($likeModel->add(array('uname'=>$guest, 'pid'=>$pid))) { 281 | $this->assign('mode', 'succeeded'); 282 | } else { 283 | $this->assign('mode', 'failed'); 284 | } 285 | } 286 | } 287 | $this->render(); 288 | } 289 | 290 | function unlike($pid) { 291 | if (empty($pid) || empty($row = (new ProjectModel())->select($pid, array('pid', 'pname', 'uname')))) { 292 | header("location:" . APP_URL); 293 | } 294 | $guest = ""; 295 | if ((new UserModel())->checkLogin()) { 296 | if (session_status() == PHP_SESSION_NONE) { 297 | session_start(); 298 | } 299 | $guest = $_SESSION['user']['username']; 300 | } 301 | if (empty($guest)) { 302 | header("location:" . APP_URL . "/user/login"); 303 | } else { 304 | $likeModel = new LikeModel(); 305 | $this->assign('pid', $row['pid']); 306 | $this->assign('pname', $row['pname']); 307 | if (!$likeModel->hasLiked($guest, $pid)) { 308 | $this->assign('mode', 'notliked'); 309 | } else { 310 | if ($likeModel->delete(array('uname'=>$guest, 'pid'=>$pid))) { 311 | $this->assign('mode', 'succeeded'); 312 | } else { 313 | $this->assign('mode', 'failed'); 314 | } 315 | } 316 | } 317 | $this->render(); 318 | } 319 | 320 | function getData() { 321 | $data['pname'] = $this->getInput($_POST['pname']); 322 | $data['description'] = $this->getInput($_POST['description']); 323 | if (isset($_POST['minamount'])) { 324 | $data['minamount'] = $this->getInput($_POST['minamount']); 325 | } 326 | if (isset($_POST['maxamount'])) { 327 | $data['maxamount'] = $this->getInput($_POST['maxamount']); 328 | } 329 | if (isset($_POST['endtime'])) { 330 | $data['endtime'] = $this->getInput($_POST['endtime']); 331 | } 332 | if (isset($_POST['plannedcompletiontime'])) { 333 | $data['plannedcompletiontime'] = $this->getInput($_POST['plannedcompletiontime']); 334 | } 335 | if (isset($_POST['progress']) && !empty($_POST['progress'])) { 336 | $data['progress'] = $this->getInput($_POST['progress']); 337 | } 338 | if (!empty($_FILES['profpic']['tmp_name'])) { 339 | $data['profpic'] = $_FILES['profpic']; 340 | } 341 | if (!empty($_FILES['sample']['tmp_name'])) { 342 | $data['sample'] = $_FILES['sample']; 343 | } 344 | if (!empty($_POST['tag'])) { 345 | $data['tag'] = $this->getInput($_POST['tag']); 346 | } 347 | return $data; 348 | } 349 | } 350 | -------------------------------------------------------------------------------- /application/views/project/view.php: -------------------------------------------------------------------------------- 1 | 22 | 26 | 31 | 32 | 33 |
34 | 35 |
36 |
37 |
38 |

39 |
40 |
41 |

By ">

42 |
43 |
44 | 45 | 46 | 47 | 53 | 54 |
48 |
49 | 50 |

51 |
52 |
55 | 56 |
57 |
58 |
59 | 60 |
61 |
62 | " alt="Project Profile Picture"> 63 |
64 | 65 |
66 |
67 |
68 | 100) $progress = 100; 72 | $msg = "$" . $row['curamount'] . " pledged of $" . $row['minamount'] . " goal"; 73 | } else if ($row['status']=='progressing' || $row['status']=='completed') { 74 | $progress = (int)$row['progress']; 75 | $msg = $row['progress'] . "% finished"; 76 | } else { 77 | $progress = 100; 78 | $msg = "failed"; 79 | $failed = true; 80 | } 81 | ?> 82 |
" role="progressbar" aria-valuenow="" aria-valuemin="0" aria-valuemax="100" style="width: %"> 83 |
84 |
85 |
86 | 87 |
88 | 89 |

$

90 |

pledged of $ goal

91 | 92 |

%

93 |

of the project is completed

94 | 95 |

Completed

96 |

this project is completed on

97 | 98 |

Failed

99 |

this project failed

100 | 101 |

102 |

backers

103 |
104 |
105 |

106 |

pledge deadline

107 |
108 |
109 |

110 |

planned completion deadline

111 |
112 | 113 |
114 |

This project will only be funded if it reaches its goal by

115 |
116 | 117 |
118 | 119 | 120 |
121 |
122 |
123 | 124 |
$
125 | 126 |
.00
127 |
128 | 129 | 130 | 131 |
132 |

133 |
134 | 135 | 136 |

Back this project

137 | 138 | 139 | 140 |

141 | 142 |

--

143 | 144 |

average score from people

145 | 146 |
147 |
148 |
149 | 150 |
151 | 154 | 157 | 160 | 163 | 166 |
167 |
168 | 169 | 170 | 171 |
172 |

173 |
174 | 175 | 176 | 177 | 178 | Liked 179 | 180 | Like this project 181 | 182 | 183 | " class="btn btn-lg btn-default btn-block" role="button">Edit this project 184 | 185 | Liked 186 | 187 | Like this project 188 | 189 | 190 |

people liked this project

191 |
192 | 193 |
194 |
195 | 196 |
197 | 200 |

201 |
202 | 203 |
204 | 207 | 208 | 209 |

"> 210 | 211 | 212 | ">delete 213 | 214 |

215 | 216 | 217 |

No sample yet 218 | 219 |

220 | 221 |
222 | 225 |
226 | 227 |
228 |
229 | 230 | 231 |
232 |
233 |
234 |
235 | 236 | 237 |
238 |

"> 239 |

240 | 241 |

242 |
243 | 244 | 245 |

No comment yet 246 | 247 |

248 | 249 |
250 | -------------------------------------------------------------------------------- /assets/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.7 (http://getbootstrap.com) 3 | * Copyright 2011-2016 Twitter, Inc. 4 | * Licensed under the MIT license 5 | */ 6 | if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------