PDA

View Full Version : Help me understand getdaily, getnew, etc. please


Gutspiller
03-23-2003, 01:57 AM
I have heard of them and I even use getnew, but is there a page that I can see all the features of these functions?

I've read you can use the getdaily and tell it how many days you want it to go back and look for, so if you want the posts for the last 2 days, etc. you can do it.

How would I go about making it search for yesterday posts ONLY? So instead of including today and yesterday, or today, yesterday, and the day before, I just want the single days.

I use my forum for news and want to get something that will allow users to view Monday - Fridays news. Something like this possible? If not monday-friday, possibily the last 5 days. A link to each one. So people can view posts in only my news forum from 5 days ago.

Can somebody help me?

N!ck
03-23-2003, 02:52 AM
You'd make a variable with mktime(0,0,0,[today's month, day, year]) and then subtract 86400 from it. Then it's just a matter of reworking the WHERE conditional.

Gutspiller
03-23-2003, 03:27 AM
OK, now turn on your noobie translater and say that again. :)

I didn't understand any of that. I was hoping there was just stuff I could an to the url link and it would work? You know like those "actions" and switches?

BTW howd you create that swanky sig with your forum stats in it? :D

N!ck
03-23-2003, 03:52 AM
Sorry. :) I was just giving a quickie response. I'll take a look at the code and see what I see.

PM me if you want the file I use for my sig (uses cron job).

N!ck
03-23-2003, 04:02 AM
OK, in search.php, you have a block like this:


// ###################### Start get daily #######################
if ($action=="getdaily") {
// get allowable forums:
$forumsql=getallforumsql();

if (isset($forumid)) {
$forums=$DB_site->query("SELECT forumid FROM forum WHERE INSTR(CONCAT(',',parentlist,','),',".addslashes($forumid).",')>0");
$forumsql.=" AND forumid IN (0";
while ($forum=$DB_site->fetch_array($forums)) {
$forumsql.=",$forum[forumid]";
}
$forumsql.=") ";
}

// get date:
$days = intval($days);
if ($days < 1) {
$days = 1;
}
$datesql=" AND thread.lastpost>=".(time() - (24 * 60 *60 * $days));

$wheresql="1=1".$forumsql.$datesql;
$wheresql.=" AND thread.open<>10";

// insert query into db
$DB_site->query("INSERT INTO search (searchid,query,dateline,querystring,showposts,use rid,ipaddress) VALUES (NULL,'".addslashes($wheresql)."',".time().",'".addslashes($query)."',0,$bbuserinfo[userid],'".addslashes($ipaddress)."')");
$searchid=$DB_site->insert_id();

eval("standardredirect(\"".gettemplate("redirect_search")."\",\"search.php?s=$session[sessionhash]&action=showresults&getnew=true&searchid=$searchid\");");
}


After it, add:


// ###################### Start get yesterday #######################
if ($action=="getyesterday") {
// get allowable forums:
$forumsql=getallforumsql();

if (isset($forumid)) {
$forums=$DB_site->query("SELECT forumid FROM forum WHERE INSTR(CONCAT(',',parentlist,','),',".addslashes($forumid).",')>0");
$forumsql.=" AND forumid IN (0";
while ($forum=$DB_site->fetch_array($forums)) {
$forumsql.=",$forum[forumid]";
}
$forumsql.=") ";
}

// get midnight last night and the night before:
$thismidnight=mktime(0,0,0,vbdate("m"),vbdate("d"),vbdate("Y"));
$lastmidnight=$thismidnight-86400;
$datesql=" AND thread.lastpost>=".$lastmidnight);

$wheresql="1=1".$forumsql.$datesql;
$wheresql.=" AND thread.open<>10";

// insert query into db
$DB_site->query("INSERT INTO search (searchid,query,dateline,querystring,showposts,use rid,ipaddress) VALUES (NULL,'".addslashes($wheresql)."',".time().",'".addslashes($query)."',0,$bbuserinfo[userid],'".addslashes($ipaddress)."')");
$searchid=$DB_site->insert_id();

eval("standardredirect(\"".gettemplate("redirect_search")."\",\"search.php?s=$session[sessionhash]&action=showresults&getnew=true&searchid=$searchid\");");
}


Then access http://your.forums/search.php?s=&action=getyesterday . I see no reason why it shouldn't work, but note that I didn't test it.

Hope that helps you.

N!ck
03-23-2003, 07:37 PM
so did that help?