Jump to content
Дизайн и модификация Invision Community IPBSkinsBETA
Search In
  • More options...
Find results that contain...
Find results in...
Sign in to follow this  
NTFS

php-скрипт создания тем в ipb 2.2.2

Recommended Posts

Всем привет! У себя на сайте я сделал скрипт который ведет статистику, я хочу что бы етот скрипт сам создавал темы в форуме при некоторых условиях. У меня возникла проблема с созданием новых тем в форуме через пхп скрипт а не через сам форум, от сюда вопрос есть ли php-скрипты которые могут создавать темы в форумах? если есть то поделитесь кодом)

Share this post


Link to post

/sources/api/

 

там неободиме классы. Подключили - создаем.

Share this post


Link to post

Посмотрел, сделал, выходил что из за строчки $api->ipsclass =& $this->ipsclass; дает ошибку: Fatal error: Using $this when not in object context in /home2/world/www/forum/add_topic.php on line 4

Edited by NTFS

Share this post


Link to post

Угу, там ерунда какая-то написана. Припоминаю.

 

Вот так должно начинаться:

$api = new api_topics_and_posts();
$api->api_init();
$api->set_author_by_name('matt');

 

и т.д.

 

api_init должен вызываться.

Share this post


Link to post

Спасибо, но я все уже сделал через бд) Так убил пол дня на что что бы красиво было а он все:

 

Warning: api_core::require_once(../../init.php) [function.api-core-require-once]: failed to open stream: No such file or directory in /home2/world/www/forum/sources/api/api_core.php on line 141

 

Fatal error: api_core::require_once() [function.require]: Failed opening required '../../init.php' (include_path='.:/php/includes:/usr/local/lib/php') in /home2/world/www/forum/sources/api/api_core.php on line 141

 

если кому то понадобится

 

<?php
////////подключаем конфиг
//и базу
require_once ("./forum/conf_global.php");
$pref = $INFO['sql_tbl_prefix'];
$db = mysql_pconnect($INFO['sql_host'], $INFO['sql_user'], $INFO['sql_pass']);
mysql_select_db($INFO['sql_database']);
//////////


//////параметры
$date = date("U");
//$post = addslashes($_POST['text_topic']);
//$title = addslashes($_POST['title_topic']);
//$descr = addslashes($_POST['desc_topic']);

$post = addslashes('POST text');
$title = addslashes('TOPIC TITLE');
$descr = addslashes('.......');	

$autorid = 1;  //id пользователя
$autorname = "admin"; //имя пользователя от которого будет тема
$forumid =10;   // id форума  в котором будет тема
///////////////////

//начнем с поста
//$q = "INSERT INTO ".$pref."posts VALUES (NULL, 0, NULL, $autorid, '$autorname', '1', '1', '88.88.88.88', $date, 0, '$post', 0, '', '$title', 0, NULL, 0, 0, 0)";

$q = "INSERT INTO ".$pref."posts VALUES (NULL , '0', NULL , '$autorid', '$autorname', '1', '1', '87.110.168.193', '$date', '13', '$post', '0', '$autorid', NULL , '0', NULL , '0', '0', '0', '');";
$r = mysql_query($q);

//вытягиваем id поста и записываем в топик
$post_id = mysql_insert_id();
$q = "INSERT INTO ".$pref."topics VALUES (NULL, '$title', '$descr', 'open', 1, '$autorid', '$date', '$autorid', '$date', 1, '$autorname', '$autorname', 0, 0, 1, $forumid, 1, 1, 0, NULL, 0, 0, $post_id, '', '', '', '', '')";
$r = mysql_query($q);

//теперь берем id топика и заносим в пост
$topic_id = mysql_insert_id();
$q = "update ".$pref."posts set topic_id='$topic_id' where pid=".$post_id;
$r = mysql_query($q);

//ну а теперь обновим таблицу forums
$q = "update ".$pref."forums set topics=topics+1, posts=posts+1, last_post='$date', last_poster_id='$autorid', last_poster_name='$autorname', last_title='$title', last_id='$topic_id'  where id='$forumid'";
$r = mysql_query($q);
////////////////////////////
?>

Share this post


Link to post
Warning: api_core::require_once(../../init.php) [function.api-core-require-once]: failed to open stream: No such file or directory in /home2/world/www/forum/sources/api/api_core.php on line 141

 

Надо подвигать эту строчку в api_core, чтобы находило init.php.

По всей видимости, он у вас пытается его искать относительно скрипта, который подключает api.

 

Собственно, да - у IPS вот такое кривое api. Типа, "разработчики разберутся".

 

Код, который привели - полный фейл. Не обновляется ни один кеш, счетчики постов. Не говоря уже о том, что порядок следования колонок в таблицах может быть на самом деле любой. Если форум обновлялся, то они могут быть перемешаны.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...