$oPDO->query('UPDATE quizz SET used=0'); purgeQuizzPve(); exit; } // MET A JOUR LE COOLDOWN ET SUPPRIME LES INDICE $oPDO->query('UPDATE cooldown SET status=1, timerNext=' . (microtrue() + COOLDOWN_QUIZZ_LIFETIME * 60) . ' WHERE name="EVENT"'); $oPDO->query('DELETE FROM cooldown WHERE name="QUIZZ_INDICE'); // CREER LE COOLDOWN INDIC $oPDO->query('INSERT INTO cooldown SET timerNext=' . (microtrue() + COOLDOWN_QUIZZ_LIFETIME * 60 / 2) . ', name="QUIZZ_INDICE"'); // ANNONCE mircEXEC('timer 1 ' . QUIZZ_DIRE_TIMER . ' dire [QUIZZ] Le quizz démarre, vous avez ' . COOLDOWN_QUIZZ_LIFETIME . ' minutes pour répondre à la question de ' . $aRandQuestion['auteur'] . ' présente sur le stream en tapant: !quizz <votre réponse>)'); // PREPARE LA QUESTION $oPDO->query('UPDATE quizz SET actual=1 WHERE ID="' . $aRandQuestion['ID'] . '"'); // RECOMPENSE L'AUTEUR $aAuteur = $oPDO->query('SELECT * FROM viewer WHERE name="' . $aRandQuestion['auteur'] . '"')->fetch(PDO::FETCH_ASSOC); $iXP = XPReq($aAuteur['level']) * QUIZZ_AUTEUR_XP; $oPDO->query('UPDATE viewer SET gils=gils+' . calcGILSTotal($aAuteur, QUIZZ_AUTEUR_GILS) . ', xpcurrent=' . calcXPTotal($aAuteur, $iXP)); } // STATUS 1 -> QUIZZ EST PROC, ATTENDS POUR REPONSE if ($aCooldown['status'] == '1') { // RECUP LA QUESTION $aQuizz = $oPDO->query('SELECT * FROM quizz WHERE actual=1')->fetch(PDO::FETCH_ASSOC); // Parcours le fichier quizz.txt if (is_file(PATH_FROM_QUIZZ)) { $oFile = fopen(PATH_FROM_QUIZZ, "r"); $aProfile = array(); while (!feof($oFile)) { $sLine = trim(fgets($oFile, 4096)); // explose la ligne $aLine = explode(',', $sLine); $sName = formatName($aLine[0]);
<?php $aUP = $oPDO->query('SELECT * FROM viewer WHERE xpcurrent>xpreq')->fetchAll(PDO::FETCH_ASSOC); $sLVLUP = ''; $iTotal = 0; foreach ($aUP as $aViewer) { $iTotal++; $iLevel = $aViewer['level']; $iCurrent = $aViewer['xpcurrent']; $iReq = $aViewer['xpreq']; while (true) { $iLevel++; $iCurrent = $iCurrent - $iReq; $iReq = XPReq($iLevel); if ($iCurrent < $iReq) { break; } } // MET A JOUR LA DB $oPDO->query('UPDATE viewer SET xpcurrent=' . $iCurrent . ', xpreq=' . $iReq . ', level=' . $iLevel . ' WHERE name="' . $aViewer['name'] . '"'); // CONSTRUIT LA VAR LVLUP if ($sLVLUP != '') { $sLVLUP .= ', '; } $sLVLUP .= $aViewer['name'] . ' (' . $iLevel . ')'; // DIS LA VAR LVLUP SI ELLE EXCEDE 30 LVL if ($iTotal > 30) { //dire('[LVLUP] ' . $sLVLUP); $sLVLUP = ''; $iTotal = 0; }
// Nombre onlien $iNBOnline = count(file(PATH_FROM_ONLINE)); $iXPPermin = $iNBOnline * PERMIN_XP; if ($iXPPermin < 25) { $iXPPermin = 25; } // Parcours les variable mirc et trie les donnée $oFile = fopen(PATH_FROM_ONLINE, "r"); while (!feof($oFile)) { $sName = formatName(fgets($oFile, 4096)); if ($sName) { // AJOUTE OU MET A JOUR LE VIEWER AVEC SON isOnline $aAccount = $oPDO->query('SELECT * FROM viewer WHERE name="' . $sName . '"')->fetch(PDO::FETCH_ASSOC); if (!$aAccount) { // VERIFIE SI ANCIEN VIEWER $aOld = $oPDO->query('SELECT * FROM viewerOld where name="' . $sName . '"')->fetch(PDO::FETCH_ASSOC); if (!empty($aOld)) { $oPDO->query('INSERT INTO viewer SET name="' . $sName . '", isOnline="' . microtrue() . '", xpreq="' . XPReq($aOld['level']) . '", gils="' . PERMIN_GILS . '", xpcurrent="' . $iXPPermin . '", timetotal=' . $aOld['timetotal'] . ', level=' . $aOld['level']); } else { $oPDO->query('INSERT INTO viewer SET name="' . $sName . '", isOnline="' . microtrue() . '", xpreq="' . XPReq(1) . '", gils="' . PERMIN_GILS . '", xpcurrent="' . $iXPPermin . '", timetotal=1'); } } else { $oPDO->query('UPDATE viewer SET isOnline="' . microtrue() . '", xpcurrent=xpcurrent+' . calcXPTotal($aAccount, $iXPPermin) . ', gils=gils+' . calcGILSTotal($aAccount, PERMIN_GILS) . ', timetotal=timetotal+1 WHERE name="' . $sName . '"'); } } } fclose($oFile); //unlink(PATH_FROM_ONLINE); include './php/levelup.php'; include './php/toplist.php'; $oPDO = null;
$aProfile[$sName]['level'] = intval($aLine[1]); } // RECUPERE LE REBORN if (preg_match('#profile\\.reborn\\.#si', $sLine)) { $aLine = explode('profile.reborn.', $sLine); $aLine = explode(' ', $aLine[1]); $sName = formatName($aLine[0]); $aProfile[$sName]['reborn'] = intval($aLine[1]); } } fclose($oFile); $oPDO->query('TRUNCATE viewer'); $oPDO->query('TRUNCATE viewerOld'); $oPDO->query('TRUNCATE follower'); $oPDO->query('TRUNCATE dislike'); $oPDO->query('TRUNCATE message_viewer'); $oPDO->query('TRUNCATE cooldown'); $iCount = 0; foreach ($aProfile as $sName => $aValue) { if ($aValue['timetotal'] > 30) { $iCount++; if (isset($aValue['reborn']) && $aValue['reborn'] == 2) { $aValue['level'] = 100 + ceil($aValue['level'] / 2); } $oPDO->query('INSERT INTO viewerOld SET name="' . $sName . '", isOnline="' . microtrue() . '", timetotal="' . $aValue['timetotal'] . '", level="' . $aValue['level'] . '", xpreq="' . XPReq($aValue['level']) . '"'); } } echo '<br >'; var_export($iCount); var_dump($aProfile); $oPDO = null;