Новости Joomla

0 Пользователей и 1 Гость просматривают эту тему.
  • 1 Ответов
  • 1416 Просмотров
*

melhior

  • Новичок
  • 4
  • 0 / 0
Это моя первая попытка написать свою копмоненту  под Joomla.
На локальном сервере все работает хорошо, с хостингом возникают проблемы.
http://walletit.cqhost.net/index.php?option=com_accountman&view=account&Itemid=53
При нажатии на кнопку, вываливается пустая страничка:(
Права на доступ к файлам и папкам проверял.

Код темплейта с которого идет переход:
Цитировать
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<h1>Your Credit Score now   <?php echo $this->greeting; ?> $</h1>
<form action="index.php" method="post" name="buyForm" id="buyForm">

<table>
   <tr>
      <td>
      <h2>Enter ammount of credits you want to buy</h>
      </td>
      <td align="center">
         <input name="ammount" value="" />
     </td>
      <td align="center" >
         <input type="submit" name="buy_but" value="Buy"  />
         <!--<input type="submit" name="buy_but" value="Buy" onclick='index.php?option=com_accountman>controller=account>task=buy' /> -->
     </td>
   </tr>
</table>
<form>
<input type="hidden" name="option" value="com_accountman" />
<input type="hidden" name="task" value="buy" />
<input type="hidden" name="controller" value="Buy" />

</form>

Код контроллера:
Код
<?php
/**
  */

// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport('joomla.application.component.controller');
require_once( JPATH_COMPONENT.DS.'views\\vbuy\\view.html.php' );


/**
 * Hello World Component Controller
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class AccountControllerBuy extends JController
{
    /**
     * Method to display the view
     *
     * @access    public
     */
function display()
    {
        parent::display();
    }

function __construct()
{
    parent::__construct();

    $this->registerTask( 'buy'  , 'buy' );
}    
function buy()
    {
    
 
  JRequest::setVar( 'view', 'Vbuy' );
  $view = JRequest::getVar('view', 'Vbuy');
  $inp = JRequest::getInt('ammount');
  if ($inp >0){
  $vn = 'AccountView'.$view ;
  $model = &$this->getModel( $view ) ;
if (!JError::isError( $model )) {
$v = new $vn( $inp) ;
$v->setModel( $model, true );
$v->display();
}
}
    }

}
?>
Код модели:
Код

<?php

// Check to ensure this file is included in Joomla!

defined
('_JEXEC')
or
die();

jimport( 'joomla.application.component.model' );

/**
 * Hello Model
 *
 * @package    Автор
 * @subpackage Components
 */
class AccountModelVbuy extends JModel
{
    /**
    * Gets the greeting
    * @return string The greeting to be displayed to the user
    */
   // public $user ;

   /* function getUser(){
     return $this->user;
    }
    */
    function getScore()
    {
    $db = JFactory::getDBO();

   $query = 'SELECT summ FROM account';
   $db->setQuery( $query );
   $greeting = $db->loadResult();

  return $greeting;
}
    function setScore($sco)
    {
    $db = JFactory::getDBO();
    $sum = AccountModelVbuy::getScore();
if ($sum < $sco){
  $query = 'UPDATE account SET summ = 10000';
   $db->setQuery( $query );
   $res = $db->query();
} else {
 $sum -=$sco;
  $query = 'UPDATE account SET summ ='.$sum ;
   $db->setQuery( $query );
   $res = $db->query();
}
  return $res;
}

    function buy($cred)
    {
     $score = AccountModelVbuy::setScore($cred);

  $db = JFactory::getDBO();
$date = date("j.F.Y.") ;
$time = date("h:i:s") ;
$pass = mt_rand(1,100000);
  $user = array ("id" => 0, "time" => $time, "date" => $date, "pass" => $pass, "cred" => $cred);
  //$this->user = $user;
   $query = 'INSERT INTO user_c (time, pass, cred) VALUES(CURDATE(),'.$pass.','.$cred.')';
   $db->setQuery( $query );
  if (!$db->query()) {
   echo $db->stderr();
} else {
   $id = $db->insertid();
   $sc = AccountModelVbuy::getScore();
   $user = array ("id" => $id, "time" => $time, "date" => $date, "pass" => $pass, "cred" => $cred, "score" => $sc);
   // $this->user = $user;
}
  return $user;
    }
}
?>

Код вьюхи:
Цитировать
<?php
/**
 * @package    Joomla.Tutorials
 * @subpackage Components
 * @link http://dev.joomla.org/component/option,com_jd-wiki/Itemid,31/id,tutorials:modules/
 * @license    GNU/GPL
*/

// no direct access

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');

/**
 * HTML View class for the HelloWorld Component
 *
 * @package    HelloWorld
 */

class AccountViewVbuy extends JView
{
 var $score;
 public $user = array();
       function AccountViewVbuy($in) {
         parent::__construct();
         $this->score = $in ;
     }

    public function getScore(){
       return $this->score;
    }
      
    function display($tpl = null)
    {
        $model = $this->getModel('vbuy');
        $user = $model->buy($this->score) ;
        $sc = $model->getScore();
        $this->assignRef( 'user',   $user['id']);
        $this->assignRef( 'time',   $user['time']);
        $this->assignRef( 'pass',   $user['pass']);
        $this->assignRef( 'cred',   $user['cred']);
        $this->assignRef( 'date',   $user['date']);
        $this->assignRef( 'score', $sc);
        
        parent::display($tpl);
    }
}
?>

« Последнее редактирование: 14.08.2010, 22:24:19 от melhior »
*

melhior

  • Новичок
  • 4
  • 0 / 0
Вопрос снят.
Просто немного потупил:)
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Что-то вызывает перегрузку процессора на хостинге hc.ru

Автор skyvlad

Ответов: 9
Просмотров: 1312
Последний ответ 02.02.2017, 09:42:53
от skyvlad
Ошибка 404. Может банально, а может и нет

Автор Ihtus

Ответов: 0
Просмотров: 944
Последний ответ 04.04.2015, 11:07:47
от Ihtus
К URL приписывается какой то x.vindicosuite.com/click/fbfpc=1;v=

Автор zzzan

Ответов: 0
Просмотров: 1210
Последний ответ 29.03.2015, 10:50:32
от zzzan
как узнать IP адрес пользователя, какой раздел сейчас смотрит, что делал, что делает... и т.д.

Автор asilbeko

Ответов: 3
Просмотров: 4766
Последний ответ 22.12.2014, 06:09:23
от arturk
Как отправить письмо? Ошибка: Письмо не может быть отправлено (com_mailto)

Автор Alexpro2011

Ответов: 11
Просмотров: 3985
Последний ответ 17.11.2014, 13:40:17
от sergeosn