function actPoll() { global $productModel; set_time_limit(0); $reqTime = time(); $reqTimeout = (int) gElement('timeout', $_POST) / 1000; $reqTimeout = $reqTimeout > 30 or $reqTimeout < 0 ? 30 : $reqTimeout; while (true) { clearstatcache(); $lastChangeInDataFile = filemtime('ct_database.db'); if ($lastChangeInDataFile > $reqTime || $reqTime + $reqTimeout < time()) { $content = parseAllProducts($reqTime); $reindex = $productModel->getReindex($reqTime); sResponse(array('code' => 1, 'msg' => 'Success', 'data' => array('products' => $content, 'reindex' => $reindex, 'timestamp' => $lastChangeInDataFile))); break; } else { sleep(1); continue; } } }
<?php require_once 'helper.php'; require_once 'action.php'; $url = 'http://www.chotot.vn/tp-ho-chi-minh/mua-ban/#'; $fncPrefix = 'act'; if ($_POST) { $action = gElement('action', $_POST); $fncName = $fncPrefix . $action; if (function_exists($fncName)) { return call_user_func($fncName); } else { return false; } }