ageurtse
05-27-2009, 07:58 PM
whe have a cron job that sends out an email to notifie users who post a advertisment in a forum group.
in this email there is a link which update his advertisment thread.
the old code was written for vb 3.0.3 know i have update to 3.8.2 and this script isn't running anymore
should the code below work or do i have to alter someting.
function updateThread($id, $ut){
mysql_query("UPDATE vb3_thread SET sortdateline = maildateline, mailed = '0', open = '1' WHERE threadid = '$id' AND maildateline = '$ut' AND forumid = '46' ");
return (mysql_affected_rows() == 1);
}
this peace of code is in a user written php file
if needed i could post it here
Lynne
05-27-2009, 08:03 PM
You need to alter your query syntax. See the vbulletin manual - SQL Query Syntax (http://www.vbulletin.com/docs/html/codestandards_sql_query)
ageurtse
05-27-2009, 08:06 PM
is this $db thing also availebel in a user written php file ?
Lynne
05-27-2009, 09:54 PM
Yeah, that page is from the manual and shows how you should do queries on vbulletin pages.
ageurtse
05-29-2009, 03:47 PM
i tryed somthings but i can't get it to work
this is the code
function updateThread($id, $ut){
$db->query_write("UPDATE vb3_thread SET sortdateline = maildateline, mailed = '0', open = '1' WHERE threadid = '$id' AND maildateline = '$ut' AND forumid = '46' ");
return (mysql_affected_rows() == 1);
}
this is the error
Fatal error: Call to a member function on a non-object in /var/www/vhosts/zeewaterforum.info/httpdocs/forums/verkoopfunctions.php on line 103
when i put $vbulletin-> in front of the line of code that also isn't working
this is a php file which is called from a link send by email.
bellow a bit of code from the email
Heeft u uw artikelen nog niet verkocht, dan kunt u met onderstaande url uw advertentie '3 dagen' naar voren plaatsen:
http://www.zeewaterforum.info/forums/verplaats.php?id=63338&ut=1242763003
this is the php file verplaats.php
<?php
require_once('./global.php');
require_once('./verkoopfunctions.php');
if(isset($_GET['id'])&&isset($_GET['ut'])){
if(updateThread($_GET['id'], $_GET['ut'])){
standard_error('Uw bericht is naar voren verplaatst','',0);
}
else{
standard_error('Er is niets gewijzigd, u heeft uw bericht waarschijnlijk al eerder verplaatst.','',0);
}
}
else{
standard_error('Er klopt iets niet met de URL, verzeker u dat de volledige URL is gekopieerd','',0);
}
?>
this is the whole php file verkoopfunctions.php
<?php
require_once('htmlMimeMail.php');
function doall(){
setSortDateLine();
closeOldThreads();
setThreads();
$result = getThreads();
while(($row = mysql_fetch_array($result))==true){
// echo 'postuserid '.$row['postuserid'].' MAILDATELINE'.$row['maildateline'].'<BR>';
sendmail($row['postuserid'],$row['threadid'],$row['maildateline'],$row['title']);
//sendpm($row['postuserid'],$row['threadid'],$row['maildateline'],$row['title']);
//setsend($row['threadid']);
}
}
function sendmail($userid, $threadid, $ut, $threadtitle){
global $mail;
$user = $db->query("SELECT username, email FROM vb3_user WHERE userid = '$userid'");
$user = $db->fetch_array($user);
//$headers = "MIME-Version: 1.0\n";
//$headers .= "From: administratie@zeewaterforum.info\n";
$name = $user['username'];
$email = 'test@steinor.nl'; //$user['email'];
$subject = "Actualiseren aanbieding";
$message = "Hallo ".$name. ",<br/><br/>";
$message .= "\n\nOp zeewaterforum.info heeft u de advertentie \"".$threadtitle."\" geplaatst in het forumdeel \"Particulieren bieden aan\".<br/>\n";
$message .= "Het is nu 3 dagen geleden dat u deze advertentie (voor het laatst naar voren) heeft geplaatst.<br/>\n<br/>\n";
$message .= "Heeft u uw artikelen nog niet verkocht, dan kunt u met onderstaande url uw advertentie '3 dagen' naar voren plaatsen:<br/>\n";
$message .= "<a href =\"http://www.zeewaterforum.info/forums/verplaats.php?id=$threadid&ut=$ut\">http://www.zeewaterforum.info/forums/verplaats.php?id=$threadid&ut=$ut</a><br/>\n<br/>\n";
$message .= "Mocht u uw artikelen reeds hebben verkocht dan kunt u met onderstaande url uw advertentie op slot zetten en naar achter plaatsen:<br/>\n";
$message .= "<a href =\"http://www.zeewaterforum.info/forums/sluit.php?id=$threadid&ut=$ut\">http://www.zeewaterforum.info/forums/sluit.php?id=$threadid&ut=$ut</a><br/>\n<br/>\n";
$message .= "Reageert u niet, dan wordt uw advertentie over twee dagen automatisch op slot gezet.\nU kunt dan alsnog reageren, uw advertentie wordt dan weer van het slot gehaald.<br/>\n<br/>\n";
$message .= "Met vriendelijke groet,<br/>\n<br/>\nHet zeewaterforum.info team";
$mail = new htmlMimeMail();
$mail->setFrom('zeewaterforum.info <noreply@zeewaterforum.info>');
$mail->setSubject($subject);
$mail->setHTML($message);
$mail->setBcc('l.k.h.kwakman@orange.nl');
$mail->send(array($email));
}
function setsend($threadid){
$db->query("UPDATE vb3_thread SET mailed = '1' WHERE threadid = '$threadid'");
}
function sendpm($userid, $threadid, $ut, $threadtitle){
$user = $db->query("SELECT username, email FROM vb3_user WHERE userid = '$userid'");
$user = $db->fetch_array($user);
$username = $user['username'];
$title = "Actualiseren aanbieding";
$message = "Hallo ".$name. ",";
$message .= "\n\nOp zeewaterforum.info heeft u de advertentie \"".$threadtitle."\" geplaatst in het forumdeel \"Particulieren bieden aan\".\n";
$message .= "Het is nu 3 dagen geleden dat u deze advertentie (voor het laatst naar voren) heeft geplaatst.\n\n";
$message .= "Heeft u uw artikelen nog niet verkocht, dan kunt u met onderstaande url uw advertentie '3 dagen' naar voren plaatsen:\n";
$message .= "http://www.zeewaterforum.info/forums/verplaats.php?id={$threadid}&ut={$ut}\n\n";
$message .= "Mocht u uw artikelen reeds hebben verkocht dan kunt u met onderstaande url uw advertentie op slot zetten en naar achter plaatsen:\n";
$message .= "http://www.zeewaterforum.info/forums/sluit.php?id={$threadid}&ut={$ut}\n\n";
$message .= "Reageert u niet, dan wordt uw advertentie over twee dagen automatisch op slot gezet.\nU kunt dan alsnog reageren, uw advertentie wordt dan weer van het slot gehaald.\n\n";
$message .= "Met vriendelijke groet,\n\nHet zeewaterforum.info team";
$tostring = array();
$tostring["$userid"] = $username;
$fusername = "forumbeheer";
$fuserid = "47";
// insert private message text
$db->query("INSERT INTO vb3_pmtext(fromuserid, fromusername, title, message, touserarray, iconid, dateline, showsignature, allowsmilie) VALUES ($fuserid, '$fusername', '$title', '" . addslashes($message) . "', '" . addslashes(serialize($tostring)) . "', 0, " . TIMENOW . ", 0, 0)");
echo mysql_error();
// get the inserted private message id
$pmtextid = mysql_insert_id();
$db->query("INSERT INTO vb3_pm (pmtextid, userid) VALUES ($pmtextid, $userid)");
// update recipient pm totals (with pm-popup)
$db->query("UPDATE vb3_user SET pmtotal=pmtotal+1, pmunread=pmunread+1, pmpopup=2 WHERE userid = '$userid'");
}
function closeThread($id, $ut){
$db->query("UPDATE vb3_thread SET open = '0' WHERE threadid = '$id' AND forumid = '46' AND maildateline = '$ut'");
return (mysql_affected_rows() == 1);
}
function closeOldThreads(){
$db->query("UPDATE vb3_thread SET open = '0', mailed = '0' WHERE open = '1' AND forumid = '46' AND TIMESTAMP(FROM_UNIXTIME( maildateline ) , '48:00:00') < NOW() AND mailed = '1'");
}
function updateThread($id, $ut){
$vbulletin->$db->query_write("UPDATE vb3_thread SET sortdateline = maildateline, mailed = '0', open = '1' WHERE threadid = '$id' AND maildateline = '$ut' AND forumid = '46' ");
return (mysql_affected_rows() == 1);
}
function getThreads(){
return $db->query("SELECT * FROM vb3_thread LEFT JOIN vb3_deletionlog AS deletionlog ON(vb3_thread.threadid = deletionlog.primaryid AND type = 'thread') WHERE maildateline <> sortdateline AND mailed = '0' AND open = '1' AND forumid = 46 AND ISNULL(deletionlog.primaryid) ORDER BY maildateline DESC LIMIT 50");
}
function setThreads(){
$db->query("UPDATE vb3_thread SET maildateline = UNIX_TIMESTAMP(TIMESTAMP( FROM_UNIXTIME( sortdateline ) , '72:00:00')) WHERE sortdateline = maildateline AND TIMESTAMP(FROM_UNIXTIME( sortdateline ) , '72:00:00') < NOW() AND open = '1' AND forumid = 46");
}
function setSortDateLine(){
$db->query("UPDATE vb3_thread SET sortdateline = dateline, maildateline = dateline WHERE sortdateline = '0' AND open = '1' AND forumid = '46'");
}
?>
Lynne
05-29-2009, 04:03 PM
You need to also replace "mysql_affected_rows" with the correct syntax. I think "$db->num_rows" is the correct synatax.
ageurtse
05-29-2009, 04:12 PM
oke that could be the problem, but the error is on line 103 and that is the line before that line of code
Dismounted
05-30-2009, 02:49 AM
You should use the available vBulletin data managers to alter data.
ageurtse
05-30-2009, 03:54 AM
oke i'm going to google on this to find some examples.
Dismounted
05-30-2009, 11:20 AM
See the manual: Data Managers (http://www.vbulletin.com/docs/html/data_managers).
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.