| version 1.10, 2011/08/11 08:50:54 |
version 1.11, 2011/08/11 08:53:09 |
|
|
| * |
* |
| */ |
*/ |
| |
|
| /* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.9 2010-08-11 20:43:14 nepto Exp $ */ |
/* $Platon: scripts/php/sk-nic/SK-NIC.php,v 1.10 2011-08-11 08:50:54 nepto Exp $ */ |
| |
|
| require_once 'DB.php'; |
require_once 'DB.php'; |
| |
|
|
|
| |
|
| /* |
/* |
| * Revenue queries |
* Revenue queries |
| |
* |
| |
* NOTE: Clause "GROUP BY 1, 2, 3" below is not absolutelly |
| |
* neccessary, since without that clause it works well on MySQL |
| |
* 5.0.84-1-log, but on 5.0.51a-24+lenny4-log it creates this |
| |
* error: ERROR 1140 (42000): Mixing of GROUP columns |
| |
* (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if |
| |
* there is no GROUP BY clause |
| */ |
*/ |
| |
|
| // Registrars with 0-100 domains |
// Registrars with 0-100 domains |
|
|
| WHERE status IN ("DOM_OK","DOM_WARN","DOM_LNOT","DOM_TRAN") |
WHERE status IN ("DOM_OK","DOM_WARN","DOM_LNOT","DOM_TRAN") |
| GROUP BY dt_changed, id_reg |
GROUP BY dt_changed, id_reg |
| HAVING (COUNT(*) <= 100) |
HAVING (COUNT(*) <= 100) |
| ) AS X'; |
) AS X |
| |
GROUP BY 1, 2, 3'; |
| // Registrars with 101-1000 domains |
// Registrars with 101-1000 domains |
| $queries[] = 'INSERT INTO sknic_domains_stats |
$queries[] = 'INSERT INTO sknic_domains_stats |
| SELECT dt_changed, "revenue" AS name, "DOM-100", ROUND(SUM(revenue),0) AS revenue |
SELECT dt_changed, "revenue" AS name, "DOM-100", ROUND(SUM(revenue),0) AS revenue |
|
|
| WHERE status IN ("DOM_OK","DOM_WARN","DOM_LNOT","DOM_TRAN") |
WHERE status IN ("DOM_OK","DOM_WARN","DOM_LNOT","DOM_TRAN") |
| GROUP BY dt_changed, id_reg |
GROUP BY dt_changed, id_reg |
| HAVING (COUNT(*) > 100 AND COUNT(*) <= 1000) |
HAVING (COUNT(*) > 100 AND COUNT(*) <= 1000) |
| ) AS X'; |
) AS X |
| |
GROUP BY 1, 2, 3'; |
| // Registrars with 1001-10000 domains |
// Registrars with 1001-10000 domains |
| $queries[] = 'INSERT INTO sknic_domains_stats |
$queries[] = 'INSERT INTO sknic_domains_stats |
| SELECT dt_changed, "revenue" AS name, "DOM-1000", ROUND(SUM(revenue)) AS revenue |
SELECT dt_changed, "revenue" AS name, "DOM-1000", ROUND(SUM(revenue)) AS revenue |
|
|
| WHERE status IN ("DOM_OK","DOM_WARN","DOM_LNOT","DOM_TRAN") |
WHERE status IN ("DOM_OK","DOM_WARN","DOM_LNOT","DOM_TRAN") |
| GROUP BY dt_changed, id_reg |
GROUP BY dt_changed, id_reg |
| HAVING (COUNT(*) > 1000) |
HAVING (COUNT(*) > 1000) |
| ) AS X'; |
) AS X |
| |
GROUP BY 1, 2, 3'; |
| // Fee for changing registrar |
// Fee for changing registrar |
| $queries[] = 'INSERT INTO sknic_domains_stats |
$queries[] = 'INSERT INTO sknic_domains_stats |
| SELECT dt_changed, "revenue" AS name, "CHANGEREG", ROUND(SUM(revenue)) AS revenue |
SELECT dt_changed, "revenue" AS name, "CHANGEREG", ROUND(SUM(revenue)) AS revenue |
|
|
| FROM sknic_domains_import |
FROM sknic_domains_import |
| WHERE status IN ("DOM_TRAN") |
WHERE status IN ("DOM_TRAN") |
| GROUP BY dt_changed, id_reg |
GROUP BY dt_changed, id_reg |
| ) AS X'; |
) AS X |
| |
GROUP BY 1, 2, 3'; |
| } |
} |
| |
|
| foreach ($queries as $query) { |
foreach ($queries as $query) { |