Пример #1
0
 function save()
 {
     $post = JRequest::get('post');
     $post['eventdescription'] = JRequest::getVar('eventdescription', '', 'POST', 'string', JREQUEST_ALLOWRAW);
     ## Make a proper date of the event date and closing date.
     jimport('joomla.utilities.date');
     $date = new JDate($post['closingdate']);
     $post['closingdate'] = $date->Format('Y-m-d');
     $date = new JDate($post['eventdate']);
     $post['eventdate'] = $date->Format('Y-m-d');
     if (JRequest::getVar('venue', 0)) {
         $msg = JText::_('COM_TICKETMASTER_EVENT_NOT_SAVED_ERROR_VENUE');
         $link = 'index.php?option=com_ticketmaster&controller=events';
         $this->setRedirect($link, $msg);
     }
     $model =& $this->getModel('events');
     if ($model->store($post)) {
         $msg = JText::_('COM_TICKETMASTER_EVENT_SAVED');
     } else {
         $msg = JText::_('COM_TICKETMASTER_EVENT_NOT_SAVED');
     }
     $link = 'index.php?option=com_ticketmaster&controller=events';
     $this->setRedirect($link, $msg);
 }
Пример #2
0
 if (!$item->lastvisit_html) {
     $htmlDate = JText::_('Date_Never');
 } elseif ($item->lastvisit_html > $now - 3600) {
     // Less than one hour
     $htmlDate = JText::sprintf('Date_Minutes_Ago', intval(($now - $item->lastvisit_html) / 60));
 } elseif ($item->lastvisit_html > $now - 86400) {
     // Less than one day
     $hours = intval(($now - $item->lastvisit_html) / 3600);
     $htmlDate = JText::sprintf('Date_Hours_Minutes_Ago', $hours, ($now - $hours * 3600 - $item->lastvisit_html) / 60);
 } elseif ($item->lastvisit_html > $now - 259200) {
     // Less than three days
     $days = intval(($now - $item->lastvisit_html) / 86400);
     $htmlDate = JText::sprintf('Date_Days_Hours_Ago', $days, intval(($now - $days * 86400 - $item->lastvisit_html) / 3600));
 } else {
     $date = new JDate($item->lastvisit_html);
     $htmlDate = $date->Format('%Y-%m-%d %H:%M');
 }
 if (!$item->lastvisit_xml) {
     $xmlDate = JText::_('Date_Never');
 } elseif ($item->lastvisit_xml > $now - 3600) {
     // Less than one hour
     $xmlDate = JText::sprintf('Date_Minutes_Ago', intval(($now - $item->lastvisit_xml) / 60));
 } elseif ($item->lastvisit_xml > $now - 86400) {
     // Less than one day
     $hours = intval(($now - $item->lastvisit_xml) / 3600);
     $xmlDate = JText::sprintf('Date_Hours_Minutes_Ago', $hours, ($now - $hours * 3600 - $item->lastvisit_xml) / 60);
 } elseif ($item->lastvisit_xml > $now - 259200) {
     // Less than three days
     $days = intval(($now - $item->lastvisit_xml) / 86400);
     $xmlDate = JText::sprintf('Date_Days_Hours_Ago', $days, intval(($now - $days * 86400 - $item->lastvisit_xml) / 3600));
 } else {
 <?php 
echo $this->item->introtext;
?>
</div>
<?php 
// echo "<pre>";
// print_r($this->item);
// echo "</pre>";
?>

<div class="right-section">
<div class="location">
<div class="date">
<?php 
$pub_date = new JDate($this->item->publish_up);
echo $pub_date->Format("j M Y h:i:a");
?>
</div>
<?php 
$metinfo = new JRegistry();
$metinfo->loadString($this->item->metadata);
?>
<div class="city">
<?php 
echo $metinfo->get("xreference");
?>
</div>
<div class="suburb">
<?php 
echo $metinfo->get("rights");
?>
Пример #4
0
 function save()
 {
     ## Check for request forgeries.
     JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     ## Pattern to check users email address
     $pattern = "^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,4})\$";
     $urlregex = "^(https?|ftp)\\:\\/\\/([a-z0-9+!*(),;?&=\$_.-]+(\\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?[a-z0-9+\$_-]+(\\.[a-z0-9+\$_-]+)*(\\:[0-9]{2,5})?(\\/([a-z0-9+\$_-]\\.?)+)*\\/?(\\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
     $db = JFactory::getDBO();
     ## Get the config values needed for the signups.
     $sql = "SELECT activation_email, use_automatic_login, auto_username, show_birthday, mailchimp_api, mailchimp_listid, show_mailchimps\n\t\t\t\tFROM #__ticketmaster_config \n\t\t\t\tWHERE configid = 1 ";
     $db->setQuery($sql);
     $config = $db->loadObject();
     ## Register submitted data.
     $requestData = JRequest::get('post');
     ## We do need this again for failed registrations.
     $app->setUserState('com_ticketmaster.registration', $requestData);
     ## If registration is disabled - Redirect to login page.
     if (JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0) {
         $msg = JText::_('COM_TICKETMASTER_USER_REGISTRATION_OFF');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     if (preg_match($pattern, JRequest::getVar('emailaddress'))) {
         $msg = JText::_('COM_TICKETMASTER_USER_EMAIL_INCORRECT');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     if (JRequest::getVar('name') == '') {
         $msg = JText::_('COM_TICKETMASTER_CHECKOUT_NAME_NOT_FILLED');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     if (JRequest::getVar('address') == '') {
         $msg = JText::_('COM_TICKETMASTER_CHECKOUT_ADDRESS_NOT_FILLED');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     if (JRequest::getVar('city') == '') {
         $msg = JText::_('COM_TICKETMASTER_CHECKOUT_CITY_NOT_FILLED');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     if ($config->auto_username == 0) {
         if (JRequest::getVar('username') == '') {
             $msg = JText::_('COM_TICKETMASTER_CHECKOUT_USERNAME_NOT_FILLED');
             $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
             return false;
         }
         ## Check if passwords are the same.
         if (JRequest::getVar('password') != JRequest::getVar('password2')) {
             $msg = JText::_('COM_TICKETMASTER_USER_PASS_INCORRECT');
             $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
             return false;
         }
     }
     if (JRequest::getVar('emailaddress') != JRequest::getVar('email2')) {
         $msg = JText::_('COM_TICKETMASTER_EMAILADDRESSES_DO_NOT_COMPARE');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     ## Get the user id based on user input.
     $db->setQuery('SELECT id FROM #__users WHERE username = '******'username')) . '');
     ## Loading the results of the query
     $userId = (int) $db->loadResult();
     if ($userId) {
         $msg = JText::_('COM_TICKETMASTER_USER_IN_DB');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     $db->setQuery('SELECT email FROM #__users WHERE email = ' . $db->Quote(JRequest::getVar('emailaddress')) . '');
     ## Loading the results of the query
     $email_used = $db->loadResult();
     if ($email_used) {
         $msg = JText::_('COM_TICKETMASTER_EMAIL_IN_DB');
         $app->redirect('index.php?option=com_ticketmaster&view=checkout', $msg);
         return false;
     }
     ##### OK - ALL DATA SEEMS OK #####
     if ($config->show_mailchimps == 1) {
         ## SUBSCRIBE TO MAILING LIST OPTION - ADD TO MAILCHIMP USING API
         if (JRequest::getVar('emailUpdates') == 'Yes') {
             ## Include Mailchimp API class
             $path_include = JPATH_SITE . DS . 'components' . DS . 'com_ticketmaster' . DS . 'assets' . DS . 'helpers' . DS . 'mailchimp.class.php';
             require_once $path_include;
             ## Your API Key: http://admin.mailchimp.com/account/api/
             $api = new MCAPI($config->mailchimp_api);
             ## Your List Unique ID: http://admin.mailchimp.com/lists/ (Click "settings")
             $list_id = $config->mailchimp_listid;
             $merge_vars = array('FNAME' => JRequest::getVar('name'), 'LNAME' => JRequest::getVar('name'));
             ## SUBSCRIBE TO LIST
             if ($api->listSubscribe($list_id, JRequest::getVar('emailaddress'), $merge_vars) === true) {
                 $mailchimp_result = 'Success! Check your email to confirm sign up.';
             } else {
                 $mailchimp_result = 'Error: ' . $api->errorMessage;
             }
         }
     }
     $post = JRequest::get('post');
     $params = JComponentHelper::getParams('com_users');
     $useractivation = $params->get('useractivation');
     if ($config->auto_username == 1) {
         $data['username'] = $post['emailaddress'];
         $chars = '123456789ABCDEFGHJKLMNPQRSTUVWXYZ';
         $data['password'] = self::password(8, $chars);
     } else {
         $to_be_replaced = array("#", "&", "!", "\$", "^", "%", "(", ")", "=", "+", "/", "<", ">", ";", ":", "[", "]", "{", "}", "FROM", "from", "UPDATE", "update", "DELETE", "delete", "+");
         $data['username'] = str_replace($to_be_replaced, "", $post['username']);
         $data['password'] = $post['password'];
     }
     $data['name'] = $post['firstname'] . ' ' . $post['name'];
     $data['firstname'] = $post['firstname'];
     $data['email'] = $post['emailaddress'];
     $model = $this->getModel('checkout');
     ## Attempt to save the data.
     ## receive back the userid.
     $userid = $model->register($data, $config);
     $post['userid'] = $userid;
     $post['ipaddress'] = $_SERVER['REMOTE_ADDR'];
     $post['published'] = 1;
     if ($config->show_birthday == 1) {
         ## Creating the birthday
         $post['birthday'] = $post['year'] . '-' . $post['month'] . '-' . $post['day'];
         ## Make date save:
         jimport('joomla.utilities.date');
         $date = new JDate($post['birthday']);
         $isJ30 = version_compare(JVERSION, '3.0.0', 'ge');
         if ($isJ30) {
             $birthday = $date->Format('Y-m-d');
         } else {
             $birthday = $date->toFormat('Y-m-d');
         }
         $post['birthday'] = $birthday;
     }
     ## Save userdata in Ticketmaster tables.
     $model->store($post);
     ## Flush the data from the session.
     $app->setUserState('com_ticketmaster.registration', null);
     ## Let's change order status now. They are now
     ## connected to a user with an id.
     $model->itemsupdate($userid, $this->ordercode);
     ## Mail the userinformation ot this customer.
     $model->sendconfirmation($userid, $data['password'], $data['username'], $this->email, $this->ordercode, $this->name);
     ## Check what type of registration it is in config.
     $useractivation = $params->get('useractivation');
     if ($useractivation == 1) {
         ## Message for showing redirections
         $msg = JText::_('COM_TICKETMASTER_ACTIVATE_ACCOUNT');
         ## URL to redirect the customer after registration.
         $url = JRoute::_('index.php?option=com_ticketmaster&view=checkout');
         ## Redirect customer to specific page
         $app->redirect($url, $msg);
     } elseif ($useractivation == 2) {
         ## Message for showing redirections
         $msg = JText::_('COM_TICKETMASTER_CANNOT_COMPLETE_ORDER');
         ## URL to redirect the customer after registration.
         $url = JRoute::_('index.php?option=com_ticketmaster&view=checkout');
         ## Redirect customer to specific page
         $app->redirect($url, $msg);
     } else {
         ## Get the config values needed for the signups.
         $sql = "SELECT use_automatic_login, redirect_after_login, send_profile_mail\n\t\t\t\t\tFROM #__ticketmaster_config \n\t\t\t\t\tWHERE configid = 1 ";
         $db->setQuery($sql);
         $config = $db->loadObject();
         ###############################################
         ######### START WITH AUTO LOGIN IF ON #########
         ###############################################
         if ($config->use_automatic_login == 1) {
             $app = JFactory::getApplication();
             // Set the return URL if empty.
             if (empty($data['return'])) {
                 $data['return'] = 'index.php?option=com_users&view=profile';
             }
             // Get the log in options.
             $options = array();
             $options['remember'] = JRequest::getBool('remember', false);
             $options['return'] = $data['return'];
             // Get the log in credentials.
             $credentials = array();
             $credentials['username'] = $data['username'];
             $credentials['password'] = $data['password'];
             // Perform the log in.
             $error = $app->login($credentials, $options);
             // Check if the log in succeeded.
             if (!JError::isError($error)) {
                 $app->setUserState('users.login.form.data', array());
                 ## Check if the user is logged in.
                 $user =& JFactory::getUser();
                 $userid = $user->id;
                 if (!$userid) {
                     ## User has not been logged in, redirect back to the checkout pages.
                     $msg = $msg = JText::_('COM_TICKETMASTER_AUTOLOGIN_LOGIN_FAILURE');
                     $uri = JRoute::_('index.php?option=com_ticketmaster&view=checkout');
                     $app->redirect($uri, $msg);
                 } else {
                     $model =& $this->getModel('checkout');
                     ## Get the model to update the order..
                     $model->itemsupdate($userid, $this->ordercode);
                     ## Mail the userinformation ot this customer.
                     if ($config->send_profile_mail == 1) {
                         $model->sendconfirmation($userid, $data['password'], $data['username'], $user->email, $this->ordercode, $user->name);
                     }
                     ## Redirect to payment page immediatly.
                     $app->redirect(JRoute::_('index.php?option=com_ticketmaster&view=payment'));
                 }
             } else {
                 $data['remember'] = (int) $options['remember'];
                 $app->setUserState('users.login.form.data', $data);
                 $app->redirect(JRoute::_('index.php?option=com_ticketmaster&view=checkout', false));
             }
         }
         #############################################
         ######### END WITH AUTO LOGIN IF ON #########
         #############################################
         ## Message for showing redirections
         $msg = JText::_('COM_TICKETMASTER_YOU_CAN_LOGIN');
         ## URL to redirect the customer after registration.
         $url = JRoute::_('index.php?option=com_ticketmaster&view=checkout');
         ## Redirect customer to specific page
         $app->redirect($url, $msg);
     }
 }