The best way to help would probably be by logging in to my admin cpanel of my test website and just look at what's up yourself... But I will try to explain it here...
That is the error message that I get when trying to use FCKeditor in the browser... I dont have any PHP experience and I do not know how to create that function in that file correctly... So, If anyone could help that would be great... Here is the code to the other page:
Missing Method in PagesController
Error: The action admin_js is not defined in controller PagesController
Error: Create PagesController::admin_js() in file: app/controllers/pages_controller.php.
<?php
class PagesController extends AppController {
var $name = 'Pages';
function admin_js() {
}
}
?>
Notice: If you want to customize this error message, create app/views/errors/missing_action.ctp.That is the error message that I get when trying to use FCKeditor in the browser... I dont have any PHP experience and I do not know how to create that function in that file correctly... So, If anyone could help that would be great... Here is the code to the other page:
<?php
class AuctionsController extends AppController {
var $name = 'Auctions';
var $uses = array('Auction', 'Setting');
var $helpers = array('Fck');
function beforeFilter(){
parent::beforeFilter();
if(!empty($this->Auth)) {
$this->Auth->allow('test', 'index', 'getstatus', 'view', 'live', 'home', 'future', 'closed', 'winners', 'getcount', 'ipn', 'latestwinner');
}
}
function _getStringTime($timestamp){
$diff = $timestamp - time();
if($diff < 0) $diff = 0;
$day = floor($diff / 86400);
if($day < 1){
$day = '';
}else{
$day = $day.'d';
}
$diff -= $day * 86400;
$hour = floor($diff / 3600);
if($hour < 10) $hour = '0'.$hour;
$diff -= $hour * 3600;
$minute = floor($diff / 60);
if($minute < 10) $minute = '0'.$minute;
$diff -= $minute * 60;
$second = $diff;
if($second < 10) $second = '0'.$second;
return trim($day.' '.$hour.':'.$minute.':'.$second);
}
/**
* Function to get the status of auction(s)
*
* @param boolean $includeBidHistories If the value is other than false it will include the 10 last bid histories
*/
function getstatus($includeBidHistories = false){
$this->helpers = array('Javascript');
Configure::write('debug', 0);
$this->layout = 'js/ajax';
$auctions = array();
$options = array();
$isPeakNow = $this->isPeakNow();
$options['includeBidHistories'] = $includeBidHistories;
$data = $_POST;
if(empty($data)) {
$data = array('auction_8' => 8, 'auction_9' => 9);
}
foreach($data as $key => $value) {
if(!empty($options['includeBidHistories'])) {
$auction = Cache::read('auction_view_'.$value);
} else {
$auction = Cache::read('auction_'.$value);
}
if(empty($auction)) {
// Importing the helper
// Yeah, I know helper is for view, but it's for avoiding code duplication
App::import('Helper', array('Number', 'Time'));
$number = new NumberHelper();
$time = new TimeHelper();
$auction = $this->Auction->getStatus($key, $value, $options);
// Formating the price
$auction['Auction']['start_price'] = $number->currency($auction['Auction']['start_price'], $this->appConfigurations['currency']);
$auction['Auction']['savings']['price'] = $number->currency($auction['Auction']['savings']['price'], $this->appConfigurations['App.currency']);
$auction['Auction']['savings']['percentage'] = $number->toPercentage($auction['Auction']['savings']['percentage']);
// Formating last bid and closes
$auction['LastBid']['created'] = $time->niceShort($auction['LastBid']['created']);
$auction['Auction']['closes_on'] = $time->niceShort($auction['Auction']['closes_on']);
foreach($auction['Histories'] as $subkey => $history) {
$auction['Histories'][$subkey]['Bid']['created'] = $time->niceShort($history['Bid']['created']);
}
if(!empty($options['includeBidHistories'])) {
Cache::write('auction_view_'.$value, $auction, '+1 day');
} else {
Cache::write('auction_'.$value, $auction, '+1 day');
}
}
$auction['Auction']['end_time_string'] = $this->_getStringTime($auction['Auction']['end_time']);
$auction['Auction']['time_left'] = $auction['Auction']['end_time'] - time();
if($isPeakNow) {
$auction['Auction']['isPeakNow'] = 1;
} else {
$auction['Auction']['isPeakNow'] = 0;
}
$auctions[$key] = $auction;
}
$this->set('data', $auctions);
}
function getcount($type = null) {
$this->Auction->recursive = -1;
if($type == 'live') {
$count = $this->Auction->find('count', array('conditions' => "start_time < '" . date('Y-m-d H:i:s') . "' AND end_time > '" . date('Y-m-d H:i:s') . "'"));
} elseif($type == 'comingsoon') {
$count = $this->Auction->find('count', array('conditions' => "start_time > '" . date('Y-m-d H:i:s') . "'"));
} elseif($type == 'closed') {
$count = $this->Auction->find('count', array('conditions' => array('closed' => 1)));
}
return $count;
}
function bid($id = null){
$this->layout = 'json/default';
Configure::write('debug', 0);
$message = '';
$data = array();
$data['bid_debit'] = $this->Setting->get('bid_debit');
$data['auction_price_increment'] = $this->Setting->get('auction_price_increment');
$data['auction_time_increment'] = $this->Setting->get('auction_time_increment');
// Add more information
$data['auction_id'] = $id;
$data['user_id'] = $this->Auth->user('id');
$data['isPeakNow'] = $this->isPeakNow();
// Bid the auction
$auction = $this->Auction->bid($data);
// Put the message on view
$this->set('auction', $auction);
}
function latestwinner() {
return $this->Auction->find('first', array('conditions' => array('Auction.winner_id >' => 0), 'order' => array('Auction.end_time' => 'desc'), 'contain' => array('Winner', 'AuctionImage')));
}
function home() {
// Get 15 auction for the frontpage
$auctions = $this->Auction->getAuctions(array("Auction.start_time < '" . date('Y-m-d H:i:s') . "' AND Auction.end_time > '" . date('Y-m-d H:i:s') . "'"), 15, 'Auction.end_time ASC');
$auctions_end_soon = array_slice($auctions, 0, 5);
$auctions_live = array_slice($auctions, 5);
$this->set('auctions_end_soon', $auctions_end_soon);
$this->set('auctions_live', $auctions_live);
}
function index() {
$this->Auction->contain();
$this->paginate = array('conditions' => array("start_time < '" . date('Y-m-d H:i:s') . "' AND end_time > '" . date('Y-m-d H:i:s') . "'"), 'limit' => 25, 'order' => array('Auction.end_time' => 'asc'));
$auctions = $this->paginate();
if(!empty($auctions)) {
foreach($auctions as $key => $auction) {
$auction = $this->Auction->getAuctions(array('Auction.id' => $auction['Auction']['id']), 1);
$auctions[$key]['Auction'] = $auction['Auction'];
}
}
$this->set('auctions', $auctions);
$this->pageTitle = __('Live Auctions', true);
}
function future() {
$this->Auction->contain();
$this->paginate = array('conditions' => array("start_time > '" . date('Y-m-d H:i:s') . "'"), 'limit' => 25, 'order' => array('Auction.end_time' => 'asc'));
$auctions = $this->paginate();
if(!empty($auctions)) {
foreach($auctions as $key => $auction) {
$auction = $this->Auction->getAuctions(array('Auction.id' => $auction['Auction']['id']), 1);
$auctions[$key]['Auction'] = $auction['Auction'];
}
}
$this->set('auctions', $auctions);
$this->pageTitle = __('Coming Soon Auctions', true);
}
function closed() {
$this->Auction->contain();
$this->paginate = array('conditions' => array('closed' => 1), 'limit' => 25, 'order' => array('Auction.end_time' => 'desc'));
$auctions = $this->paginate();
if(!empty($auctions)) {
foreach($auctions as $key => $auction) {
$auction = $this->Auction->getAuctions(array('Auction.id' => $auction['Auction']['id']), 1);
$auctions[$key]['Auction'] = $auction['Auction'];
}
}
$this->set('auctions', $auctions);
$this->pageTitle = __('Closed Auctions', true);
}
function winners() {
$this->Auction->contain();
$this->paginate = array('conditions' => array('winner_id >' => 0, 'Auction.closed' => 1), 'limit' => 25, 'order' => array('Auction.end_time' => 'desc'));
$auctions = $this->paginate();
if(!empty($auctions)) {
foreach($auctions as $key => $auction) {
$auction = $this->Auction->getAuctions(array('Auction.id' => $auction['Auction']['id']), 1);
$auctions[$key]['Auction'] = $auction['Auction'];
}
}
$this->set('auctions', $auctions);
$this->pageTitle = __('Winners', true);
}
function view($id = null) {
if(empty($id)) {
$this->Session->setFlash(__('Invalid Auction.', true));
$this->redirect(array('action' => 'index'));
}
$auction = $this->Auction->getAuctions(array('Auction.id' => $id), 1);
if (empty($auction)) {
$this->Session->setFlash(__('Invalid Auction.', true));
$this->redirect(array('action' => 'index'));
}
$this->set('auction', $auction);
$this->set('bidHistories', $this->Auction->Bid->histories($auction['Auction']['id'], $this->appConfigurations['bidHistoryLimit']));
$this->set('parents', $this->Auction->Category->getpath($auction['Auction']['category_id']));
$this->set('bidIncrease', $this->Setting->get('auction_price_increment'));
$this->set('timeIncrease', $this->Setting->get('auction_time_increment'));
$this->set('endingSoonAuctions', $this->Auction->getAuctions(array('Auction.id <> '.$id, "Auction.start_time < '" . date('Y-m-d H:i:s') . "' AND Auction.end_time > '" . date('Y-m-d H:i:s') . "'"), 4, array('Auction.end_time ASC')));
$this->pageTitle = $auction['Auction']['title'];
if(!empty($auction['Auction']['meta_description'])) {
$this->set('meta_description', $auction['Auction']['meta_description']);
}
if(!empty($auction['Auction']['meta_keywords'])) {
$this->set('meta_keywords', $auction['Auction']['meta_keywords']);
}
}
function won() {
$this->layout = 'user';
$this->paginate = array('conditions' => array('Auction.winner_id' => $this->Auth->user('id')), 'limit' => 50, 'order' => array('Auction.end_time' => 'desc'));
$this->set('auctions', $this->paginate());
$this->pageTitle = __('Won Auctions', true);
}
function pay($id = null) {
$this->layout = 'user';
$this->pageTitle = __('Pay for an Auction', true);
if (empty($id)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'won'));
}
$auction = $this->Auction->read(null, $id);
if(empty($auction)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'won'));
}
if($auction['Auction']['winner_id'] !== $this->Auth->user('id')) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'won'));
}
if($auction['Auction']['status_id'] != 1) {
$this->Session->setFlash(__('You have already paid for this auction.', true));
$this->redirect(array('action'=>'won'));
}
$this->set('auction', $auction);
$user = $this->Auction->Winner->read(null, $this->Auth->user('id'));
$this->set('user', $user);
$this->Auction->Winner->Address->AddressType->recursive = -1;
$addresses = $this->Auction->Winner->Address->AddressType->find('all');
$userAddress = array();
$addressRequired = 0;
if(!empty($addresses)) {
foreach($addresses as $address) {
$userAddress[$address['AddressType']['name']] = $this->Auction->Winner->Address->find('first', array('conditions' => array('Address.user_id' => $this->Auth->user('id'), 'Address.address_type_id' => $address['AddressType']['id'])));
if(empty($userAddress[$address['AddressType']['name']])) {
$addressRequired = 1;
}
}
}
$this->set('address', $userAddress);
$this->set('addressRequired', $addressRequired);
if(empty($addressRequired)) {
if($auction['Auction']['fixed_price'] > 0) {
$total = $auction['Auction']['fixed_price'] + $auction['Auction']['delivery_cost'];
} else {
$total = $auction['Auction']['start_price'] + $auction['Auction']['delivery_cost'];
}
if(!empty($this->data)) {
if($this->appConfigurations['gateway']) {
// Formating the data
$paypal['url'] = Configure::read('Paypal.url');
$paypal['business'] = Configure::read('Paypal.email');
$paypal['lc'] = Configure::read('Paypal.lc');
$paypal['currency_code'] = $this->appConfigurations['currency'];
$paypal['item_name'] = $auction['Auction']['title'];
$paypal['item_number'] = $auction['Auction']['id'];
$paypal['amount'] = number_format($total, 2);
$paypal['return'] = $this->appConfigurations['url'] . '/auctions/returning';
$paypal['notify_url'] = $this->appConfigurations['url'] . '/auctions/ipn';
$paypal['custom'] = $user['User']['id'];
$paypal['first_name'] = $user['User']['first_name'];
$paypal['last_name'] = $user['User']['last_name'];
$paypal['email'] = $user['User']['email'];
$paypal['address1'] = $userAddress['Billing']['Address']['address_1'];
$paypal['address2'] = $userAddress['Billing']['Address']['address_2'];
$paypal['city'] = $userAddress['Billing']['Address']['city'];
$paypal['zip'] = $userAddress['Billing']['Address']['postcode'];
$this->Paypal->configure($paypal);
$paypalData = $this->Paypal->getFormData();
$this->set('paypalData', $paypalData);
} else {
// the gateway is not set
$auction['Auction']['status_id'] = 2;
$this->Auction->save($auction);
// lets check to see if we this is the first time they have added bids
$wonBefore = $this->Auction->find('count', array('conditions' => array('Auction.winner_id' => $this->Auth->user('id'))));
if($wonBefore == 1) {
$setting = $this->Setting->get('free_won_auction_bids');
if((is_numeric($setting)) && $setting > 0) {
$freeBidData['Bid']['user_id'] = $this->Auth->user('id');
$freeBidData['Bid']['description'] = __('Free bids given for winning your first auction.', true);
$freeBidData['Bid']['credit'] = $setting;
$this->User->Bid->create();
$this->User->Bid->save($freeBidData);
}
}
$this->redirect(array('action' => 'returning'));
}
}
$this->set('total', $total);
}
}
function returning() {
$this->Session->setFlash(__('Your payment was successfully. We will notify you when your item has been shipped.', true));
$this->redirect(array('action' => 'won'));
}
function ipn(){
$this->layout = 'js/ajax';
$this->Paypal->configure(array('url' => Configure::read('Paypal.url')));
if($this->Paypal->validate_ipn()){
// Get user auction
$auction = $this->Auction->findById($this->Paypal->ipn_data['item_number']);
if(!empty($auction)){
// Variable to hold auction total
$total = 0;
// Get auction total
if($auction['Auction']['fixed_price'] > 0) {
$total = $auction['Auction']['fixed_price'] + $auction['Auction']['delivery_cost'];
} else {
$total = $auction['Auction']['start_price'] + $auction['Auction']['delivery_cost'];
}
$total = number_format($total, 2);
// Fraud detection
if($this->Paypal->ipn_data['mc_gross'] == $total){
$auction['Auction']['status_id'] = 2;
$this->Auction->save($auction);
// lets check to see if we this is the first time they have added bids
$wonBefore = $this->Auction->find('count', array('conditions' => array('Auction.winner_id' => $this->Paypal->ipn_data('custom'))));
if($wonBefore == 1) {
$setting = $this->Setting->get('free_won_auction_bids');
if((is_numeric($setting)) && $setting > 0) {
$freeBidData['Bid']['user_id'] = $this->Auth->user('id');
$freeBidData['Bid']['description'] = __('Free bids given for winning your first auction.', true);
$freeBidData['Bid']['credit'] = $setting;
$this->User->Bid->create();
$this->User->Bid->save($freeBidData);
$this->log('free bids added');
}
}
}else{
$this->log('Fraud detected on auction #'. $auction['Auction']['id'] . ', db total : ' . $total . ', paypal total : ' . $this->Paypal->ipn_data['mc_gross']);
return false;
}
}else{
$this->log('User auction id:'.$this->Paypal->ipn_data['item_number'].' not found');
return false;
}
}else{
$this->log('ipn verification failed');
}
}
function offline() {
}
function admin_index() {
$this->paginate = array('limit' => $this->appConfigurations['pageLimit'], 'order' => array('Auction.end_time DESC', 'Auction.closed ASC'));
$this->set('auctions', $this->paginate('Auction'));
}
function admin_live() {
$this->paginate = array('conditions' => "start_time < '" . date('Y-m-d H:i:s') . "' AND end_time > '" . date('Y-m-d H:i:s') . "'", 'limit' => $this->appConfigurations['pageLimit'], 'order' => array('closed' => 'asc', 'end_time' => 'asc'));
$this->set('auctions', $this->paginate('Auction'));
$this->set('extraCrumb', array('title' => 'Live Auctions', 'url' => 'live'));
$this->render('admin_index');
}
function admin_comingsoon(){
$this->paginate = array('conditions' => "start_time > '" . date('Y-m-d H:i:s') . "'", 'limit' => $this->appConfigurations['pageLimit'], 'order' => array('end_time' => 'asc'));
$this->set('auctions', $this->paginate('Auction'));
$this->set('extraCrumb', array('title' => 'Coming Soon', 'url' => 'comingsoon'));
$this->render('admin_index');
}
function admin_closed(){
$this->paginate = array('conditions' => array('closed' => 1), 'limit' => $this->appConfigurations['pageLimit'], 'order' => array('end_time' => 'desc'));
$this->set('auctions', $this->paginate('Auction'));
$this->set('extraCrumb', array('title' => 'Closed Auctions', 'url' => 'closed'));
$this->render('admin_index');
}
function admin_won($status_id = null) {
if(!empty($status_id)){
$conditions = array('winner_id >' => 0, 'Winner.autobidder' => 0, 'Auction.status_id' => $status_id);
}else{
$conditions = array('winner_id >' => 0, 'Winner.autobidder' => 0);
}
$this->paginate = array('conditions' => $conditions, 'limit' => $this->appConfigurations['pageLimit'], 'order' => array('end_time' => 'asc'));
$this->set('auctions', $this->paginate('Auction'));
$this->set('statuses', $this->Auction->Status->find('list'));
$this->set('selected', $status_id);
$this->set('extraCrumb', array('title' => 'Won Auctions', 'url' => 'won'));
$this->render('admin_index');
}
function admin_user($user_id = null) {
if(empty($user_id)) {
$this->Session->setFlash(__('Invalid User.', true));
$this->redirect(array('controller' => 'users', 'action' => 'index'));
}
$user = $this->Auction->Winner->read(null, $user_id);
if(empty($user)) {
$this->Session->setFlash(__('Invalid User.', true));
$this->redirect(array('controller' => 'users', 'action' => 'index'));
}
$this->set('user', $user);
$this->paginate = array('conditions' => array('Auction.winner_id' => $user_id), 'limit' => $this->appConfigurations['pageLimit'], 'order' => array('Auction.end_time' => 'asc'));
$this->set('auctions', $this->paginate());
}
function admin_winner($id = null) {
if (empty($id)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'index'));
}
$auction = $this->Auction->read(null, $id);
if(empty($auction)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'index'));
}
if(!empty($this->data)) {
$this->Auction->save($this->data);
if($this->data['Auction']['inform'] == 1) {
$data = $this->Auction->findbyId($id);
$data['Status']['comment'] = $this->data['Auction']['comment'];
$data['to'] = $auction['Winner']['email'];
$data['subject'] = sprintf(__('%s - Auction Status Updated', true), $this->appConfigurations['name']);
$data['template'] = 'auctions/status';
$this->_sendEmail($data);
}
$this->Session->setFlash(__('The auction status was successfully updated.', true));
$this->redirect(array('action' => 'winner', $auction['Auction']['id']));
}
$this->set('auction', $auction);
$user = $this->Auction->Winner->read(null, $auction['Auction']['winner_id']);
$this->set('user', $user);
$this->Auction->Winner->Address->AddressType->recursive = -1;
$addresses = $this->Auction->Winner->Address->AddressType->find('all');
$userAddress = array();
$addressRequired = 0;
if(!empty($addresses)) {
foreach($addresses as $address) {
$userAddress[$address['AddressType']['name']] = $this->Auction->Winner->Address->find('first', array('conditions' => array('Address.user_id' => $auction['Auction']['winner_id'], 'Address.address_type_id' => $address['AddressType']['id'])));
}
}
$this->set('address', $userAddress);
$this->set('selectedStatus', $auction['Auction']['status_id']);
$this->set('statuses', $this->Auction->Status->find('list'));
}
function admin_add($id = null) {
if (!empty($this->data)) {
if(empty($this->data['Auction']['rrp'])) {
$this->data['Auction']['rrp'] = 0;
}
if(empty($this->data['Auction']['delivery_cost'])) {
$this->data['Auction']['delivery_cost'] = 0;
}
if(empty($this->data['Auction']['fixed_price'])) {
$this->data['Auction']['fixed_price'] = 0;
}
$this->Auction->create();
if ($this->Auction->save($this->data)) {
$this->Session->setFlash(__('The auction has been added successfully. <a href="/admin/auction_images/index/'.$this->Auction->getInsertID().'">Click here to add the auction images</a>.', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('There was a problem adding the auction please review the errors below and try again.', true));
}
} else {
if (!empty($id)) {
$this->data = $this->Auction->read(null, $id);
}
}
$this->set('categories', $this->Auction->Category->generatetreelist(null, null, null, '-'));
}
function admin_edit($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if(empty($this->data['Auction']['rrp'])) {
$this->data['Auction']['rrp'] = 0;
}
if(empty($this->data['Auction']['delivery_cost'])) {
$this->data['Auction']['delivery_cost'] = 0;
}
if(empty($this->data['Auction']['fixed_price'])) {
$this->data['Auction']['fixed_price'] = 0;
}
if ($this->Auction->save($this->data)) {
$this->Session->setFlash(__('The auction has been updated successfully.', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('There was a problem updating the auction please review the errors below and try again.', true));
}
}
if (empty($this->data)) {
$this->data = $this->Auction->read(null, $id);
if(empty($this->data)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'index'));
}
}
$this->set('categories', $this->Auction->Category->generatetreelist(null, null, null, '-'));
}
function admin_refund($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Auction.', true));
$this->redirect(array('action' => 'index'));
}
$this->Auction->Bid->deleteAll(array('Bid.auction_id' => $id));
$this->Session->setFlash(__('The bids were successfully refunded.', true));
$this->redirect(array('action' => 'index'));
}
function admin_delete($id = null) {
if (!$id) {
$this->Session->setFlash(__('Invalid id for Auction.', true));
}
if ($this->Auction->del($id)) {
// future code here for bidchopper bid butler - will need to refund BB's not yet run
$this->Session->setFlash(__('The auction was deleted successfully.', true));
} else {
$this->Session->setFlash(__('There was a problem deleting this auction.', true));
}
$this->redirect(array('action' => 'index'));
}
function admin_extension($id = null) {
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
$this->Auction->set($this->data);
if($this->Auction->validates()) {
$this->Auction->save($this->data, false);
$this->Session->setFlash(__('The auction\'s auto extend has been updated successfully.', true));
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash(__('There was a problem updating the auction\'s auto extend please review the errors below and try again.', true));
}
} else {
$this->data = $this->Auction->read(null, $id);
if(empty($this->data)) {
$this->Session->setFlash(__('Invalid Auction', true));
$this->redirect(array('action'=>'index'));
}
if($this->data['Auction']['minimum_price'] == 0) {
$this->data['Auction']['minimum_price'] = '';
}
if($this->data['Auction']['time_extended'] == 0) {
$this->data['Auction']['time_extended'] = '';
}
if($this->data['Auction']['time_before_extend'] == 0) {
$this->data['Auction']['time_before_extend'] = '';
}
}
$this->set('autobidders', $this->User->find('count', array('conditions' => array('User.active' => 1, 'User.autobidder' => 1))));
}
}
?>