Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2013, 03:48 PM
pachoofoosh's Avatar
pachoofoosh pachoofoosh is offline
Artist
 
Join Date: Dec 2012
Location: New York
Posts: 98
Gender: Unknown/Other
Credits: 18,332
pachoofoosh is on a distinguished road
Default Troubles with queries

I've been trying to code an anti brute-force function, however without success. I can't seem to get the queries to execute correctly, and the page is returning the error "Database error 1054 - Unknown column '0' in 'field list'". Does anyone have an idea of how to make the queries execute correctly? Any help is greatly appreciated! I hope to post the code as a mod for 1.3.3 once everything works correctly. ^^

Here's the function:
PHP Code:
function logAttempt($attempts$ip$delay_time) {
                        
$mysidia Registry::get("mysidia");
                        
$ip $_SERVER['REMOTE_ADDR'];
                    
$attempts $mysidia->db->select("login_attempts", array("num_attempts"), "ip = '{$ip}'");
                    
$newattempts $attempts->rowCount() + 1;
                    
$now time();
                    
$stmt $mysidia->db->insert("login_attempts", array("num_attempts""ip""delay_time"), "VALUES ('$newattempts', '$ip', '$now')");
                      if( 
$newattempts <= ) {
                          
$delay_time 0;
                      }
                      elseif( 
$newattempts == || $newattempts == ) {
                          
$delay_time 5;
                      }
                      elseif( 
$newattempts == ) {
                          
$delay_time 10;
                      }
                      elseif( 
$newattempts == ) {
                          
$delay_time 30;
                      }
                      elseif( 
$newattempts == ) {
                          
$delay_time 60;
                      }
                      elseif( 
$newattempts >= 10 ) {
                          
$delay_time 120;
                      } else { echo 
'We\'re sorry, but there\'s been a serious error...'; } // A wild error appears!
                                   
return $delay_time;      } // End logAttempt function. 

Last edited by pachoofoosh; 08-05-2013 at 09:19 AM.
Reply With Quote
  #2  
Old 08-04-2013, 04:44 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,645
Hall of Famer is on a distinguished road
Default

Well I see two problems:

1. The database insert query is clearly incorrect, the syntax should be:
PHP Code:
$mysidia->db->insert("login_attempts", array("num_attempts" => $newattempts"ip" => $ip"delay_time" => $now)); 
2. You should not attempt to output text with echo in Mysidia Adoptables, as the string will be displayed on the header, which does not make sense. Instead, use this:

PHP Code:
$document $mysidia->frame->getDocument();
$document->addLangvar('We\'re sorry, but there\'s been a serious error...'); 
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 08-05-2013, 10:46 AM
pachoofoosh's Avatar
pachoofoosh pachoofoosh is offline
Artist
 
Join Date: Dec 2012
Location: New York
Posts: 98
Gender: Unknown/Other
Credits: 18,332
pachoofoosh is on a distinguished road
Default

Thanks HoF! The data's inserting into the database now, and the errors are gone. :D
Reply With Quote
  #4  
Old 08-05-2013, 11:45 AM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 488,645
Hall of Famer is on a distinguished road
Default

Great, glad I can help. Lemme know if you encounter any further issues. ^^
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #5  
Old 08-05-2013, 12:32 PM
Nemesis's Avatar
Nemesis Nemesis is offline
Member
 
Join Date: Mar 2011
Location: Ohio, United States
Posts: 641
Gender: Male
Credits: 57,234
Nemesis is on a distinguished road
Default

I would change the error message from serious error to "too many invalid log ins, try again later"

Saying there has been a serious error will make the user think something is wrong with your site. Furthermore when they report this error the admin may have no idea how it was generated in the first place.
__________________
https://gemnode.com
Free Hosting for Mysidia Adopt Sites
Just join our forum and request your free hosting account
Reply With Quote
Reply

Tags
bruteforce, database, errors, queries


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Login troubles & other things SmaffyBuns Questions and Supports 7 11-21-2012 03:44 PM
Having troubles Finding the Right Host and How to Install the Mys Script. Aasixx Questions and Supports 7 12-13-2011 03:16 PM
Question about Queries? Tsuntsun Questions and Supports 2 11-03-2011 02:57 PM
Anyone care to enlighten me as to why 188 queries are used on a page? Arianna Questions and Supports 5 05-14-2010 10:21 AM
MySQL queries ..? Quillink Questions and Supports 3 07-11-2009 12:47 PM


All times are GMT -5. The time now is 01:19 PM.

Currently Active Users: 1134 (0 members and 1134 guests)
Threads: 4,081, Posts: 32,031, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636