Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```
- <?php
- require_once('../bimadb.php');
- function RandomString()
- {
- $characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
- $randstring = '';
- for ($i = 0; $i < 6; $i++) {
- $randstring = $randstring.$characters[rand(0, strlen($characters))];
- }
- return $randstring;
- }
- $sql = "SELECT * FROM aktif";
- $result = $conn->query($sql);
- if ($result->num_rows > 0) {
- // output data of each row
- while($row = $result->fetch_assoc()) {
- $tokentime = $row['tokentime'];
- $token = $row['token'];
- }
- } else {
- }
- $token_updated = date("Y-m-d H:i",time());
- $to_time = strtotime($token_updated);
- $from_time = strtotime($tokentime);
- $minutes = round(abs($to_time - $from_time) / 60,2);
- if ($minutes>15) {
- $token = RandomString();
- $sql = "UPDATE `aktif` SET `token` = '".$token."',`tokentime` = '".$token_updated."'";
- $stmt = $conn->prepare($sql);
- $stmt->execute();
- $stmt->close();
- $token_updated = date("d-m-Y H:i",time());
- echo $token . ' - Updated : '. $token_updated .' - Interval : 15 menit';
- } else {
- echo $token . ' - Updated : '. date("d-m-Y H:i",strtotime($tokentime)) .' - Interval : 15 menit';
- }
- ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement