Uutiset:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu
Advertisement:

Having trouble with query and $smcFunc

Aloittaja Randem, joulukuu 30, 2013, 02:58:52 AP

« edellinen - seuraava »

Randem

Having a tough time with this one query. It states "Hacking Attempt...". I change the variables and get other errors. A straight query gets a hacking attempt. What must be done to this query to get it accepted. the query works in mySQL.


function GetTopicVisitsDownloadsPerHour($selecteddate)
{
global $smcFunc,$context;

$query = "Select  a.Segment as Segment, Count(a.Segment) as Downloads from
(Select hour(`updated`) as Segment FROM {db_prefix}log_downloads
   where updated = {date:selected})) `a`
group by Segment";


$segment_result = $smcFunc['db_query']('',
$query,
array('selected' => $selecteddate
)
);


Original Query


function GetTopicVisitsDownloadsPerHour($selecteddate)
{
global $smcFunc,$context;

$query = "Select  a.Segment as Segment, Count(a.Segment) as Downloads from
(Select hour(`updated`) as Segment FROM {db_prefix}log_downloads
   where (cast(`updated` as date) = '" . $selecteddate . "')) `a`
group by Segment";
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

emanuele

$smcFunc doesn't allow sub SELECTs (unless (maybe, at the moment I don't remember the details) you disable the security checks).


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Randem

How would one disable the security checks for one call? I did not see anything on the $smcFunc page about this.
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Sorck

$disableQueryCheckBack = $modSettings['disableQueryCheck'];

$modSettings['disableQueryCheck'] = true;

// do query here

$modSettings['disableQueryCheck'] = $disableQueryCheckBack;


Line 301 of Subs-Db-mysql.php is where the checks start. The sub-query check is on lines 345-347.

Randem

Thanks Sorck. That worked.

Thanks emanuele for your help.
BotBanish - The Ultimate Bot Firewall
Scams - How to Protect Yourself
Why Professionals Should Not Use Free Email Accounts

Always ignore those who attempt to tell you what to think and believe those who will allow you think for yourself

Advertisement: