저는 PHP에 익숙하지 않습니다. mybb 포럼에서 삭제하기 전에 게시물을 백업하기 위해 triyng입니다.php 파일에 함수 추가 get 정의되지 않은 함수 예외에 대한 호출
나는 다음과 같은 기능 backup_post
를 추가 inc/class_moderation.php
을 편집 할 수 있지만 함수의 호출은 backup_post
라인에 /membri/myforum/inc/class_moderation.php에 정의되지 않은 함수 backup_post()에
통화가 발생하는 경우 485
function delete_post($pid)
{
global $mybb, $db, $cache, $plugins;
$pid = $plugins->run_hooks("class_moderation_delete_post_start", $pid);
// Get pid, uid, fid, tid, visibility, forum post count status of post
$pid = intval($pid);
$query = $db->query("
SELECT p.pid, p.uid, p.fid, p.tid, p.visible, f.usepostcounts, t.visible as threadvisible, message, p.username as p_username, p.subject, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='$pid'
");
$post = $db->fetch_array($query);
// If post counts enabled in this forum and it hasn't already been unapproved, remove 1
if($post['usepostcounts'] != 0 && $post['visible'] != 0 && $post['threadvisible'] != 0)
{
$db->update_query("users", array("postnum" => "postnum-1"), "uid='{$post['uid']}'", 1, true);
}
if(!function_exists("remove_attachments"))
{
require MYBB_ROOT."inc/functions_upload.php";
}
// Remove attachments
remove_attachments($pid);
//Backup the post
backup_post($pid);
// Delete the post
$db->delete_query("posts", "pid='$pid'");
// Remove any reports attached to this post
$db->delete_query("reportedposts", "pid='$pid'");
$num_unapproved_posts = $num_approved_posts = 0;
// Update unapproved post count
if($post['visible'] == 0 || $post['threadvisible'] == 0)
{
++$num_unapproved_posts;
}
else
{
++$num_approved_posts;
}
$plugins->run_hooks("class_moderation_delete_post", $post['pid']);
// Update stats
$update_array = array(
"replies" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
update_thread_counters($post['tid'], $update_array);
// Update stats
$update_array = array(
"posts" => "-{$num_approved_posts}",
"unapprovedposts" => "-{$num_unapproved_posts}"
);
update_forum_counters($post['fid'], $update_array);
return true;
}
function backup_post($pid)
{
global $mybb, $db, $cache, $plugins;
// Get pid, uid, fid, tid, visibility, forum post count status of post
$pid = intval($pid);
$query = $db->query("
SELECT p.pid, p.uid, p.fid, p.tid, p.visible, f.usepostcounts, t.visible as threadvisible, message, p.username as p_username, p.subject, p.dateline
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='$pid'
");
$post = $db->fetch_array($query);
$deletedpost = array(
"username_delete" => $mybb->user['username'],
"username" => $post['p_username'],
"subject" => $post['subject'],
"message" => $post['message'],
"dateline" => TIME_NOW,
"post_dateline" => $post['dateline'],
);
$db->insert_query("posts_deleted", $deletedpost);
//14-06-20016
//ob_start();
//var_dump($mybb);
//$data = ob_get_clean();
//$fp = fopen(MYBB_ROOT."myText.txt","wb");
//fwrite($fp,$data);
//fwrite($fp, "cancellato da ".$mybb->user['username']);
//fwrite($fp, "autore ".$post['p_username']);
//fwrite($fp, "messaggio ".$post['message']);
/*
foreach ($post as $key => $value) {
fwrite($fp, $key);
}
*/
//fclose($fp);
return true;
}