<?php
define("IN_MYBB",1);
require_once("***************/new/forumupdate/global.php");
require_once("***************/new/forumupdate/inc/datahandlers/pm.php");
require_once("***************/new/forumupdate/inc/functions_modcp.php");
require_once("***************/new/forumupdate/inc/datahandlers/post.php");
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// LOG schreiben mrschmock 07.10.2018
$log = fopen("***************/forumupdate/custom/LOG_mrschmock.txt", "a");
//Konfiguration:
// 11 = High Yield Investments
// 10 = Adshares, GPTs & Matrix
// 13 = MLM- & Hybrid-Programme
// 383 = ICOs, Miner, Pools, MLM-Coins
// 359 = Prelaunches & Sleeper
$progfid=array(10,11,13,359,383,129,143); // alle prüfen
$progfid1=array(11); //FID Programmüberforum 7 Tage
$progfid2=array(10,13,383,129,143); //FID Programmüberforum 14 Tage
$progfid4=array(359); //FID Programmüberforum 28 Tage
// $progfid2=array(); //FID Programmüberforum 14 Tage
//entfällt$leftthreads=array(116,140,49); //Komma separierte liste von Threads, die nicht berücksichtigt werden sollen (im Programme Forum)
$checktime=7; //Zeit in Tagen, ab wann gepostet wird, dass kein Bericht vorhanden ist.
$postmessage="[update]";
//Funktionen:
function sendPM($fromuid,$touid,$message,$subject){
$pmhandler = new PMDataHandler();
$pmhandler->admin_override = true;
$pm = array(
"subject" => $subject,
"message" => $message,
"icon" => 0,
"fromid" => $fromuid,
"do" => '',
"pmid" => '',
"toid" => $touid,
"saveasdraft" => 0
);
$pm['options'] = array(
"signature" => 1,
"disablesmilies" => 0,
"savecopy" => 0,
"readreceipt" => 0
);
$pmhandler->set_data($pm);
$pmhandler->validate_pm();
$pmhandler->insert_pm();
}
function sendPost($message,$forumid,$threadid,$db){
$stickyquery = $db->simple_select("threads", "*", "tid=".$threadid);
$sticky = $db->fetch_field($stickyquery, "sticky");
$posthandler = new PostDataHandler("insert");
$userarray=get_user($uid);
$new_post = array(
"tid" => $threadid, //1468
"fid" => $forumid, //134
"subject" => "",
"icon" => 16,
"uid" => 1,
"username" => "Nummer1",
"dateline" => TIME_NOW,
"message" => $message,
"ipaddress" => ""
);
$new_post['options']=array(
"signature" => 1,
"subscriptionmethod" => 0,
"disablesmilies" => 0
);
$posthandler->set_data($new_post);
$valid_post = $posthandler->validate_post();
if($valid_post) $posthandler->insert_post();
$db->update_query("threads",array('sticky'=>$sticky),"tid=$threadid");
}
/* function zwischenstring ($start, $ende, $string) {
return reset (explode ($ende, end (explode ($start, $string))));
}*/
//Zeit in datetime Format umrechnen
$checktimen=TIME_NOW - ($checktime * 24 * 60 * 60);
$checktimenn=TIME_NOW - ($checktime * 2 * 24 * 60 * 60);
//Get all threads with link to azthread
$progthreadids=array(); $firstposts=array(); $forumsids=array(); $userids=array();$pids=array();
//message like '%\[azb=%\]%' AND
// Änderung 10.09.2018:
// $querytext="SELECT firstpost,tid,uid,fid FROM mybb_threads WHERE (fid IN (".implode(",", $progfid1).") or fid IN (".implode(",",$progfid2).")) AND visible>0 AND closed = ''"; //icon IN (2,3) AND
// Änderung 10.10.2018:
// $querytext="SELECT firstpost,tid,uid,fid FROM mybb_threads WHERE (fid IN (".implode(",", $progfid1).")) AND visible>0 AND closed = ''"; //icon IN (2,3) AND
$querytext="SELECT firstpost,tid,uid,fid FROM mybb_threads WHERE (fid IN (".implode(",", $progfid).")) AND visible>0 AND closed = ''"; //icon IN (2,3) AND
$query = $db->query($querytext);
while($result = $db->fetch_array($query)){
//Zeit in datetime Format umrechnen
$checktimen=TIME_NOW - ($checktime * 24 * 60 * 60);
if(in_array($result['fid'],$progfid2)) $checktimen=TIME_NOW - ($checktime * 2 * 24 * 60 * 60);
if(in_array($result['fid'],$progfid4)) $checktimen=TIME_NOW - ($checktime * 4 * 24 * 60 * 60);
//$querytext2 = "SELECT tid,fid,dateline FROM mybb_posts WHERE tid = ".$result['tid']." AND uid=".$result['uid']." order by dateline DESC limit 1 ";//$db->simple_select("posts", "tid,fid", "lastpost<$checktimen AND tid=$temptid", array("order_dir" => 'DESC',"limit" => 1));
$querytext2 = "SELECT pid, tid,fid,dateline FROM mybb_posts WHERE tid = ".$result['tid']." AND (uid=".$result['uid']." OR uid=1 AND message LIKE '[update]') order by dateline DESC limit 1 ";
$query2 = $db->query($querytext2);
$result2 = $db->fetch_array($query2);
if($result2['dateline']<$checktimen){
$progthreadids[]=(int)$result['tid'];
$forumsids[]=(int)$result2['fid'];
$userids[]=(int)$result['uid'];
$pids[]=(int)$result['firstpost'];
}
}
// 30.10.2018 Außnahme für Nummer 1 und Ungepflegt durch mrschmock
// ALT:
// $leavetids=array(16121); /* TIDs Ausschließen */
// for($i=0;$i<count($progthreadids);$i++){
// if (!in_array($progthreadids[$i], $leavetids)) {
// ALT ENDE
// NEU:
$leaveuids=array(1,10538,10743); /* UIDs Ausschließen */
for($i=0;$i<count($progthreadids);$i++){
if (!in_array($userids[$i], $leaveuids)) {
// NEU ENDE
// 30.10.2018 ENDE
/* TEXT PETER ANPASSEN: (vor kommt vor [update] und nach danach) */
$petertextvor='Bitte poste innerhalb der nächsten 72 Stunden deinen Bericht [url=https://x-invest.net/new/forumupdate/showthread.php?tid='.$progthreadids[$i].'&action=lastpost]in diesem Thema von dir[/url]!
';
$petertextnach="";
$subject="Erinnerung für deinen Bericht + 7 Tipps was du schreiben kannst";
//PM senden
$message=$petertextvor.$postmessage.$petertextnach;
sendPM(1,$userids[$i],$message,$subject);
// LOG schreiben mrschmock 07.10.2018
fwrite($log, date('d.m.Y H:i:s').", ".$pids[$i].", ".$progthreadids[$i].", ".$forumids[$i].", ".$userids[$i].", ".$message.", ".$subject."\r\n");
/* modcp hinzufügen */
$new_report = array(
'id' => $pids[$i],
'id2' => $progthreadids[$i],
'id3' => $forumsids[$i],
'uid' => $userids[$i],
'reportstatus' => 0,
'reason' => $db->escape_string("Thema ohne Bericht"),
'type' => $db->escape_string('post'),
'reports' => 1,
'dateline' => TIME_NOW,
'lastreport' => TIME_NOW,
'reporters' => $db->escape_string(my_serialize(array(1)))
);
add_report($new_report, $db->escape_string('post'));
//sendPost($postmessage,$forumsids[$i],$progthreadids[$i],$db);
//echo '<a href="https://x-invest.net/forum/showthread.php?tid='.$progthreadids[$i].'&action=lastpost">Thread '.$progthreadids[$i].'</a><br>';
//echo $progthreadids[$i]."<br>".$pids[$i]."<br>".$forumsids[$i]."<br>".$userids[$i];
}
}
// LOG schreiben mrschmock 07.10.2018
fclose($log);
?>