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; } } }
?> <!doctype html> <html> <head> <meta charset="utf-8"> <title>CT</title> <link rel="stylesheet" href="bower_components/normalize-css/normalize.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <section class="main-body"> <header> <!-- <h1>New products</h1> --> </header> <?php $products = parseAllProducts(0); ?> <section class="main-content"> <div class="row new-product"> <?php $newProduct = array_shift($products); unset($products[0]); ?> <div class="product" id="<?php echo $newProduct['id']; ?> " title="<?php echo $newProduct['title']; ?> - Giá: <?php echo $newProduct['price'];