Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #11  
Old 08-21-2011, 06:22 PM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'd rather set the info in the file itself- it'll have it's own DB. It's all good- you're actually taking the time to help, it's much appreciated my man.
Reply With Quote
  #12  
Old 08-21-2011, 07:00 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

OK, this is kind of bare bones but hopefully it will help:

PHP Code:
<?php

//create a db table called something like "contest_clicks" with two colums:
//ip CHAR length 15, no default, not null, index = 'index'
//clicktime INT no default, not null, unsigned
//(I'm using the types like vbulletin uses them because frankly I don't know if any other way is better).


// Database connect info - change this to your info
$dbname 'name';
$servername 'server';
$port ''// defaults to 3306
$username 'user';
$password 'pass';

$timeperiod 3600// time period in second, 3600 = 1 hour
$max_clicks 2// clicks allowed in time period.

// connect to db
$useport $port $port 3306;
if (
mysql_pconnect("$servername:$useport"$username$password) === false)
    die(
"db connect error: " mysql_error());

if (
mysql_select_db($dbname) === false)
    die(
"db select error: " mysql_error());

// check for click records from this ip within time period
$ip $_SERVER['REMOTE_ADDR'];
$timenow time();
$timelimit $timenow $timeperiod;
$clicks mysql_query("SELECT clicktime FROM contest_clicks WHERE ip = '$ip' AND clicktime > $timelimit ORDER BY clicktime ASC");
if (
$clicks === false)
    die(
"db query error: " mysql_error());

if (
mysql_num_rows($clicks) >= $max_clicks)
{
    
//show error messsage or redirect to error page ???
    // If you want to show time remaining until they can click again, use this code,
    // Otherwise you can commenty out or delete this code
    
$clicktime mysql_fetch_array($clicks);
    
$nextallowed date('g:i:s'$clicktime['clicktime'] + $timeperiod);
    echo 
"Time is now " date('g:i:s'$timenow) . "<BR/>";
    echo 
"Not allowed until $nextallowed<BR/>";
}
else
{
    
//OK, send mail and save click record
    // Insert mail sending code from original script either before or after this.
    
if (mysql_query("INSERT INTO contest_clicks (ip, clicktime) VALUES ('$ip', '$timenow')") === false)
        die(
"db error: " mysql_error());
    echo(
"Sent email<BR/>");
}

Note the instructions for creating the table (which you have to do manually) are at the top. And you need to set your db info. This doesn't have the email code in there, but you can see where you should insert it (pretty much just copying the code form the existing script, or maybe put it in a function. This doesn't really handle errors except printing them out, I don't really know how you'd want to handle them.
Reply With Quote
  #13  
Old 08-21-2011, 07:04 PM
just.b.jealous just.b.jealous is offline
 
Join Date: Aug 2009
Location: Middle of no where.
Posts: 74
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hell yeah, much obliged. Won't have a chance to try it out yet (gotta head to work).. So lites crosses our fingers.
Reply With Quote
Reply

Thread Tools
Display Modes

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 05:09 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08771 seconds
  • Memory Usage 2,192KB
  • Queries Executed 13 (?)
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
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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_postinfo_query
  • fetch_postinfo
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete