EliteConf
 All Data Structures Namespaces Files Functions Variables Pages
SiteController.php
Go to the documentation of this file.
1 <?php
2 
3 class SiteController extends Controller {
4 
8  public function actions() {
9  return array(
10  // captcha action renders the CAPTCHA image displayed on the contact page
11  'captcha' => array(
12  'class' => 'CCaptchaAction',
13  'backColor' => 0xFFFFFF,
14  ),
15  // page action renders "static" pages stored under 'protected/views/site/pages'
16  // They can be accessed via: index.php?r=site/page&view=FileName
17  'page' => array(
18  'class' => 'CViewAction',
19  ),
20  );
21  }
22 
27  public function actionIndex() {
28  // renders the view file 'protected/views/site/index.php'
29  // using the default layout 'protected/views/layouts/main.php'
30  //$this->render('index');
31  $model = new LoginForm;
32 
33  // if it is ajax validation request
34  if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
35  echo CActiveForm::validate($model);
36  Yii::app()->end();
37  }
38 
39  // collect user input data
40  if (isset($_POST['LoginForm'])) {
41  $model->attributes = $_POST['LoginForm'];
42  // validate user input and redirect to the previous page if valid
43  if ($model->validate() && $model->login())
44  //$this->redirect(Yii::app()->user->returnUrl);
45  $this->redirect('index.php?r=home');
46  }
47  // display the login form
48  $this->render('login', array('model' => $model));
49  }
50 
54  public function actionError() {
55  if ($error = Yii::app()->errorHandler->error) {
56  if (Yii::app()->request->isAjaxRequest)
57  echo $error['message'];
58  else
59  $this->render('error', $error);
60  }
61  }
62 
66  public function actionContact() {
67  $model = new ContactForm;
68  if (isset($_POST['ContactForm'])) {
69  $model->attributes = $_POST['ContactForm'];
70  if ($model->validate()) {
71  $name = '=?UTF-8?B?' . base64_encode($model->name) . '?=';
72  $subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?=';
73  $headers = "From: $name <{$model->email}>\r\n" .
74  "Reply-To: {$model->email}\r\n" .
75  "MIME-Version: 1.0\r\n" .
76  "Content-type: text/plain; charset=UTF-8";
77 
78  mail(Yii::app()->params['adminEmail'], $subject, $model->body, $headers);
79  Yii::app()->user->setFlash('contact', 'Thank you for contacting us. We will respond to you as soon as possible.');
80  $this->refresh();
81  }
82  }
83  $this->render('contact', array('model' => $model));
84  }
85 
89  public function actionLogin() {
90  $model = new LoginForm;
91 
92  // if it is ajax validation request
93  if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
94  echo CActiveForm::validate($model);
95  Yii::app()->end();
96  }
97 
98  // collect user input data
99  if (isset($_POST['LoginForm'])) {
100  $model->attributes = $_POST['LoginForm'];
101  // validate user input and redirect to the previous page if valid
102  if ($model->validate() && $model->login())
103  $this->redirect(Yii::app()->user->returnUrl);
104  }
105  // display the login form
106  $this->render('login', array('model' => $model));
107  }
108 
112  public function actionLogout() {
113  Yii::app()->user->logout();
114  $this->redirect(Yii::app()->homeUrl);
115  }
116 /*
117  public function actionRegister() {
118  $model = new Users('register');
119 
120 
121  if (isset($_POST['Users'])) {
122  $model->attributes = $_POST['Users'];
123  if ($model->validate()) {
124  // form inputs are valid, do something here
125  $model->save();
126  $this->redirect('index.php');
127  return;
128  }
129  }
130  $this->render('register', array('model' => $model));
131  }
132 */
133 
134  public function actionRegister() {
135  $model = new Users('register');
136 
137  Yii::import('application.extensions.phpmailer.JPhpMailer');
138 
139 
140  if (isset($_POST['Users'])) {
141  $model->attributes = $_POST['Users'];
142 
143 
144  if ($model->validate()) {
145  // form inputs are valid, do something here
146  $model->save();
147 
148  $usermail=$model->email;
149 
150  $mail = new JPhpMailer;
151  $mail->IsSMTP();
152  $mail->Host = 'smtp.googlemail.com:465';
153  $mail->SMTPSecure = "ssl";
154  $mail->SMTPAuth = true;
155  $mail->Username = 'jjjuk7@gmail.com';
156  $mail->Password = 'klizma23';
157  $mail->SetFrom('jjjuk7@gmail.com', 'HackedHard');
158  $mail->Subject = 'Welcome To EliteConf';
159  $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
160  $mail->MsgHTML('<h1>You have successfully registered to EliteConf Conference Managagement System.</h1>');
161  $mail->AddAddress($usermail, 'Hacked Hard');
162  $mail->Send();
163 
164 
165  $this->redirect('index.php');
166  return;
167  }
168  }
169  $this->render('register', array('model' => $model));
170  }
171 
172  public function actionRequest_conference() {
173  $model = new Conference('request');
174 
175  // uncomment the following code to enable ajax-based validation
176  /*
177  if(isset($_POST['ajax']) && $_POST['ajax']==='conference-request_conference-form')
178  {
179  echo CActiveForm::validate($model);
180  Yii::app()->end();
181  }
182  */
183 
184  if (isset($_POST['Conference'])) {
185  $model->attributes = $_POST['Conference'];
186  $uid = Yii::app()->user->id;
187  $command = Yii::app()->db->createCommand();
188 
189  if ($model->validate()) {
190  // form inputs are valid, do something here
191  $model->save();
192  $cid = $model->conferenceid;
193  $command->insert('conference_user', array(
194  'userid' => $uid,
195  'conferenceid' => $cid,
196  ));
197  $command->insert('conference_user_type', array(
198  'userid' => $uid,
199  'usertype' => 1,
200  'conferenceid' => $cid,
201  ));
202 
203  $this->redirect('index.php?r=home/index');
204  return;
205  }
206  }
207  $this->render('request_conference', array('model' => $model));
208  }
209 
210  function actionDownload() {
211  $filecontent = file_get_contents(Yii::getPathOfAlias('application.uploads') . '/' . 'schedule.pdf');
212  header("Content-Type: application/pdf");
213  header("Content-disposition: attachment; filename='schedule.pdf'");
214  header("Pragma: no-cache");
215  echo $filecontent;
216  exit;
217  }
218 
219 }