<?php
{
include_once __DIR__ . '/defines.php' ;
}
{
define ( 'JPATH_BASE' , __DIR__
) ; require_once JPATH_BASE . '/includes/defines.php' ;
}
require_once JPATH_BASE . '/includes/framework.php' ;
require_once JPATH_BASE . '/libraries/joomla/factory.php' ;
//ARTICLE'S INPUTS
$title = 'test' ;
$category = 'Сайты' ;
$fulltext = <<<EOD
EOD ;
$state = 1 ;
$access = 1 ;
//END ARTICLE'S INPUTS
$db = JFactory:: getDbo ( ) ;
$query = $db -> getQuery ( true ) ;
$query
-> select ( $db -> quoteName ( 'id' ) )
-> from ( $db -> quoteName ( '#__users' ) )
-> where ( $db -> quoteName ( 'name' ) . ' = ' . $db -> quote ( 'Super User' ) ) ;
$db -> setQuery ( $query ) ;
$userId = $db -> loadResult ( ) ;
$query = $db -> getQuery ( true ) ;
$query
-> select ( $db -> quoteName ( 'id' ) )
-> from ( $db -> quoteName ( '#__categories' ) )
-> where ( $db -> quoteName ( 'title' ) . ' = ' . $db -> quote ( $category ) ) ;
$db -> setQuery ( $query ) ;
$catId = $db -> loadResult ( ) ;
$query = $db -> getQuery ( true ) ;
$columns = array ( 'title' , 'alias' , 'fulltext' , 'state' , 'catid' , 'created' , 'created_by' , 'access' , 'language' ) ;
$db -> quote ( $title ) ,
$db -> quote ( JFilterOutput:: stringURLSafe ( $title ) ) ,
$db -> quote ( $fulltext ) ,
$state ,
$db -> quote ( $catId ) ,
$db -> quote ( JFactory
:: getDate ( ) -> toSQL ( ) ) , $db -> quote ( $userId ) ,
$access ,
$db -> quote ( '*' )
) ;
$query
-> insert ( $db -> quoteName ( '#__content' ) )
-> columns ( $db -> quoteName ( $columns ) )
$db -> setQuery ( $query ) ;
$result = $db -> query ( ) ;
PD9waHAKCmRlZmluZSgnX0pFWEVDJywgMSk7CgppZiAoZmlsZV9leGlzdHMoX19ESVJfXyAuICcvZGVmaW5lcy5waHAnKSkKewogIGluY2x1ZGVfb25jZSBfX0RJUl9fIC4gJy9kZWZpbmVzLnBocCc7Cn0K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