<?php

/**

* @version		1.1

* @package		DJ Classifieds

* @subpackage	DJ Classifieds Component

* @copyright	Copyright (C) 2010 Blue Constant Media LTD, All rights reserved.

* @license		http://www.gnu.org/licenses GNU/GPL

* @autor url    http://design-joomla.eu

* @autor email  contact@design-joomla.eu

* @Developer    Lukasz Ciastek - lukasz.ciastek@design-joomla.eu

* 

* 

* DJ Classifieds is free software: you can redistribute it and/or modify

* it under the terms of the GNU General Public License as published by

* the Free Software Foundation, either version 3 of the License, or

* (at your option) any later version.

*

* DJ Classifieds is distributed in the hope that it will be useful,

* but WITHOUT ANY WARRANTY; without even the implied warranty of

* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the

* GNU General Public License for more details.

*

* You should have received a copy of the GNU General Public License

* along with DJ Classifieds. If not, see <http://www.gnu.org/licenses/>.

* 

*/

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



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



JTable::addIncludePath(JPATH_COMPONENT.DS.'tables');



class DjclassifiedsModelAddItempaypal extends JModel

{	



		

	function randomkeys($length)

	{

   		global $mainframe;

		$pattern = "1234567890aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ";

   		$key='';

   		for($i=0;$i<$length;$i++){

     		$key .= $pattern{rand(0,61)};

   		}		

   		return $key;

	}

	

	function getItem($s_id){

				

		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');

    	$row = & JTable::getInstance('items', 'table');

		$row->load(JRequest::getVar('id', 0, '', 'int'));

		$row->paypal_token=$s_id;

	

	    if (!$row->store()){

        	echo "<script> alert('".$row->getError()."');

			window.history.go(-1); </script>\n";

        	exit ();

    	}

		return $row;

	}

	

	function getCat($id){

		$db= &JFactory::getDBO();

		$query = "SELECT name, price FROM #__djcf_categories WHERE id=".$id;

		$db->setQuery($query);

		return $db->loadObject();

	}

	

}



