Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 05-27-2009, 07:58 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default could this work in vb3.8

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.
Code:
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);
}

[edit]
this peace of code is in a user written php file

if needed i could post it here
[/edit]
Reply With Quote
  #2  
Old 05-27-2009, 08:03 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to alter your query syntax. See the vbulletin manual - SQL Query Syntax
Reply With Quote
  #3  
Old 05-27-2009, 08:06 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

is this $db thing also availebel in a user written php file ?
Reply With Quote
  #4  
Old 05-27-2009, 09:54 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yeah, that page is from the manual and shows how you should do queries on vbulletin pages.
Reply With Quote
  #5  
Old 05-29-2009, 03:47 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i tryed somthings but i can't get it to work

this is the code
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
Quote:
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
Quote:
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...&ut=1242763003



this is the php file verplaats.php
Code:
<?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
Code:
<?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...adid}&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...adid}&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'");
}

?>
Reply With Quote
  #6  
Old 05-29-2009, 04:03 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to also replace "mysql_affected_rows" with the correct syntax. I think "$db->num_rows" is the correct synatax.
Reply With Quote
  #7  
Old 05-29-2009, 04:12 PM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oke that could be the problem, but the error is on line 103 and that is the line before that line of code
Reply With Quote
  #8  
Old 05-30-2009, 02:49 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You should use the available vBulletin data managers to alter data.
Reply With Quote
  #9  
Old 05-30-2009, 03:54 AM
ageurtse ageurtse is offline
 
Join Date: Apr 2009
Location: almelo
Posts: 275
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

oke i'm going to google on this to find some examples.
Reply With Quote
  #10  
Old 05-30-2009, 11:20 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

See the manual: Data Managers.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04816 seconds
  • Memory Usage 2,264KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (4)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete