Ejemplo n.º 1
0
$userDateBaseManager->Connect();
$dataBaseManager->Connect();
if ($userDateBaseManager->connectSucessDataBase && $dataBaseManager->connectSucessDataBase) {
    $arrayCreadit = filter_input(INPUT_POST, 'arrayCredit', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
    $token = filter_input(INPUT_POST, 'token');
    $folder = filter_input(INPUT_POST, 'folder');
    if (!isset($arrayCreadit) || !isset($folder)) {
        echo 0;
    } else {
        $token = mysqli_real_escape_string($dataBaseManager->conn, $token);
        $folder = mysqli_real_escape_string($dataBaseManager->conn, $folder);
        $userInfo = $dataBaseManager->GetCredit($token);
        if ($userInfo !== 0) {
            if ($userInfo['CREDIT'] > 0) {
                $canInsert = min($userInfo['CREDIT'], count($arrayCreadit));
                $sql = "INSERT IGNORE INTO " . emailToNameTable($userInfo['ID']) . "(ID,FOLDER) VALUES ";
                foreach ($arrayCreadit as $id) {
                    if ($canInsert <= 0) {
                        break;
                    }
                    $sql .= "({$id},'{$folder}'),";
                    $canInsert--;
                }
                //echo rtrim($sql, ",");
                $count = $userDateBaseManager->InsertNewValue(rtrim($sql, ","));
                $result = $dataBaseManager->UpdateCredit($count, $userInfo['ID']);
                if ($result) {
                    echo $count;
                } else {
                    echo 0;
                }
Ejemplo n.º 2
0
 function GetFolderInfo($name)
 {
     if ($this->connectSucessDataBase) {
         $arrayResult = array();
         $sql = "SELECT DISTINCT FOLDER, COUNT(FOLDER) AS COUNT FROM " . emailToNameTable($name) . " GROUP BY FOLDER";
         $result = $this->conn->query($sql);
         while ($row = $result->fetch_assoc()) {
             array_push($arrayResult, $row);
         }
         return $arrayResult;
     } else {
         return [];
     }
 }