示例#1
0
    $result = mysqli_multi_query($con, $sql);
    if ($result) {
        sendPackage($con, $package, true, "", "ATTENDANCE ADDED");
    } else {
        queryFailed($con, 2.1);
    }
} else {
    if (isset($_POST["PostComment"], $_POST["LoginID"], $_POST["LoginPass"], $_POST["Data"], $_POST["To"]) && $_POST["PostComment"] != "" && $_POST["LoginID"] != "" && $_POST["LoginPass"] != "" && $_POST["Data"] != "" && $_POST["To"] != "") {
        #Connect to database
        $con = dbConnect();
        #Get clean variables from POST
        $EventID = mysqli_real_escape_string($con, $_POST["PostComment"]);
        $CommentText = mysqli_real_escape_string($con, $_POST["Data"]);
        $To = mysqli_real_escape_string($con, $_POST["To"]);
        $LoginID = mysqli_real_escape_string($con, $_POST["LoginID"]);
        $LoginPass = mysqli_real_escape_string($con, $_POST["LoginPass"]);
        #Verify User
        verifyUser($con, $LoginID, $LoginPass);
        $CommentDate = currentDate();
        $package = array();
        $sql = "UPDATE comments SET commenttext = '{$CommentText}', commentdate = '{$CommentDate}' WHERE author = '{$LoginID}' AND username = '******' AND eventid = '{$EventID}'";
        $result = mysqli_multi_query($con, $sql);
        if ($result) {
            sendPackage($con, $package, true, "", "COMMENT TEXT ADDED");
        } else {
            queryFailed($con, 2.1);
        }
    } else {
        missingParams();
    }
}
示例#2
0
global $logTxt;
file_put_contents($logTxt, "NEW TRANSMISSION START\n", FILE_APPEND | LOCK_EX);
foreach ($_POST as $param_name => $param_val) {
    file_put_contents($logTxt, '**$_POST** [' . $timestamp . ']' . " Param: {$param_name}; Value: {$param_val}\n", FILE_APPEND | LOCK_EX);
}
#######END OF LOGGING
####CREATE GROUP####
if (isset($_POST["CreateGroup"], $_POST["AdminID"], $_POST["AdminPass"], $_POST["GroupName"], $_POST["GroupDescription"]) && $_POST["AdminID"] != "" && $_POST["AdminPass"] != "" && $_POST["GroupName"] != "" & $_POST["GroupDescription"] != "") {
    #Connect to database
    $con = dbConnect();
    #Get clean variables from POST
    $GroupName = mysqli_real_escape_string($con, $_POST["GroupName"]);
    $GroupDescription = mysqli_real_escape_string($con, $_POST["GroupDescription"]);
    $AdminID = mysqli_real_escape_string($con, $_POST["AdminID"]);
    $AdminPass = mysqli_real_escape_string($con, $_POST["AdminPass"]);
    #Verify User
    verifyUser($con, $AdminID, $AdminPass);
    $package = array();
    $sql = "INSERT INTO groups (description, name) VALUES ('{$GroupDescription}', '{$GroupName}')";
    $result = mysqli_query($con, $sql);
    if (!$result) {
        queryFailed($con, 2.1);
    }
    $result = mysqli_query($con, "SELECT LAST_INSERT_ID()");
    $ChatID = mysqli_fetch_row($result)[0];
    $chatFile = $chatDir . "Group_{$ChatID}.txt";
    file_put_contents($chatFile, "[" . date('Y-m-d H:i:s') . "] {$GroupName} group created!\n", FILE_APPEND | LOCK_EX);
    sendPackage($con, $package, true, "", "GROUP ADDED");
} else {
    missingParams();
}
示例#3
0
    $sql = "INSERT INTO events (`eventname`, `host`, `participantlimit`, `eventtype`, `starttime`, `endtime`, `location`, `description`, `minkarma`, `MinAge`, `Sex`, `MinRating`, `MaxRating`, `Rated`, `PartOf`, `MaxAge`) VALUES ('{$EventName}', '{$LoginID}', '{$ParticipantLimit}', '{$EventType}', '{$StartTime}', '{$EndTime}', '{$EventLocation}', '{$EventDescription}', '{$MinKarma}', '{$MinAge}', '{$Sex}', '{$MinRating}', '{$MaxRating}', '{$Rated}', '{$PartOf}', '{$MaxAge}')";
    $result = mysqli_query($con, $sql);
    if (!$result) {
        queryFailed($con, 2.1);
    }
    $sql = "INSERT INTO eventmembers (username, eventid, hidden, participation) VALUES ('{$LoginID}', LAST_INSERT_ID(), 0, 0)";
    $result = mysqli_query($con, $sql);
    if (!$result) {
        queryFailed($con, 2.2);
    }
    $result = mysqli_query($con, "SELECT LAST_INSERT_ID()");
    $EventID = mysqli_fetch_row($result)[0];
    $sql = "INSERT INTO eventchats (eventid, username) VALUES ('{$EventID}', '{$LoginID}')";
    $result = mysqli_query($con, $sql);
    if (!$result) {
        queryFailed($con, 2.3);
    }
    #Get the name of user
    $sql = "SELECT name FROM user WHERE username = '******'";
    $result = mysqli_query($con, $sql);
    $Name = mysqli_fetch_row($result)[0];
    #Create chat file and send result of event creation
    $result = mysqli_query($con, "SELECT LAST_INSERT_ID()");
    $ChatID = mysqli_fetch_row($result)[0];
    $chatFile = $chatDir . "Event_{$ChatID}.txt";
    file_put_contents($chatFile, "[" . date('Y-m-d H:i:s') . "] {$EventName} event created!\n[" . date('H:i') . "] {$Name} joined event!\n", FILE_APPEND | LOCK_EX);
    $package = array("1" => array("EventID" => $EventID));
    sendPackage($con, $package, true, "", "EVENT CREATED");
} else {
    missingParams();
}
示例#4
0
 $LoginPass = mysqli_real_escape_string($con, $_POST["LoginPass"]);
 #Verify User
 verifyUser($con, $LoginID, $LoginPass);
 $package = array();
 #Update AboutMe
 if ($UpdateProfile == 1) {
     $ColName = 'aboutme';
 } else {
     if ($UpdateProfile == 2) {
         $ColName = 'avatar';
     } else {
         if ($UpdateProfile == 5) {
             $ColName = 'subtext';
         } else {
             $package = array();
             sendPackage($con, $package, false, "1", "INVALID UPDATE PARAMETER!");
         }
     }
 }
 #Execute query
 $sql = "UPDATE profile SET `{$ColName}` = '{$Data}' WHERE username = '******'";
 $result = mysqli_query($con, $sql);
 if ($result) {
     $package = array("0" => array("status" => true, "reason" => $Reason));
     packageLog($package);
     file_put_contents("{$logTxt}", "ABOUT ME UPDATED!\n{$EOT}", FILE_APPEND | LOCK_EX);
     echo json_encode($package);
     fclose($handle);
     exit;
 } else {
     queryFailed($con, 2.1);
示例#5
0
        } else {
            if (isset($_POST["PostChat"], $_POST["LoginID"], $_POST["LoginPass"], $_POST["ChatData"], $_POST["BelongsTo"]) && $_POST["PostChat"] != "" && $_POST["LoginID"] != "" && $_POST["LoginPass"] != "" && $_POST["ChatData"] != "") {
                #Connect to database
                $con = dbConnect();
                #Get clean variables from POST
                $ChatType = mysqli_real_escape_string($con, $_POST["BelongsTo"]);
                $ChatID = mysqli_real_escape_string($con, $_POST["PostChat"]);
                $ChatData = mysqli_real_escape_string($con, $_POST["ChatData"]);
                $LoginID = mysqli_real_escape_string($con, $_POST["LoginID"]);
                $LoginPass = mysqli_real_escape_string($con, $_POST["LoginPass"]);
                #Verify User
                verifyUser($con, $LoginID, $LoginPass);
                $package = array();
                $sql = "SELECT name FROM user WHERE username = '******'";
                $result = mysqli_query($con, $sql);
                $UserName = mysqli_fetch_row($result)[0];
                if ($ChatType == 1) {
                    $chatFile = $chatDir . "Event_{$ChatID}.txt";
                } else {
                    $chatFile = $chatDir . "Group_{$ChatID}.txt";
                }
                $chattime = date('H:i');
                $ChatData = "[" . $chattime . "] {$UserName}: {$ChatData}";
                file_put_contents($chatFile, "{$ChatData}\n", FILE_APPEND | LOCK_EX);
                sendPackage($con, $package, true, "", "CHAT UPDATED");
            } else {
                missingParams();
            }
        }
    }
}
示例#6
0
{
    $data = array('str1' => str_repeat('A', rand(1000, 9000)), 'str2' => str_repeat('B', rand(1000, 9000)), 'str3' => str_repeat('C', rand(1000, 9000)));
    $data['int1'] = rand(100000, 999999);
    $sendStr = serialize($data);
    $sendData = pack('N', strlen($sendStr)) . $sendStr;
    echo "send length=" . strlen($sendData) . ", SerId={$data['int1']}\n";
    $cli->send($sendData);
}
$client->set(array('open_length_check' => 1, 'dispatch_mode' => 1, 'worker_num' => 4, 'package_length_type' => 'N', 'package_length_offset' => 0, 'package_body_offset' => 4, 'package_max_length' => 2000000));
$client->on('connect', function (swoole_client $cli) {
    echo "Connected.\n";
    sendPackage($cli);
});
$client->on('receive', function (swoole_client $cli, $data) {
    $req = unserialize(substr($data, 4));
    echo ">> received length=" . strlen($data) . ", SerId: {$req['int1']}\n";
    $cli->count++;
    if ($cli->count > 10) {
        $cli->close();
    }
    swoole_timer_after(1000, function () use($cli) {
        sendPackage($cli);
    });
});
$client->on('close', function ($cli) {
    echo "Client: Close.\n";
});
$client->on('error', function ($cli) {
    echo "connect failed.\n";
});
$client->connect('127.0.0.1', 9501);
示例#7
0
                        $package = array();
                        $i = 0;
                        $sql = "SELECT username, rating FROM groupmembers WHERE groupid = '{$GroupID}' ORDER BY rating DESC";
                        $result = mysqli_query($con, $sql);
                        if ($result) {
                            while (($row = mysqli_fetch_row($result)) && $i < 10) {
                                $Username = $row[0];
                                $Rating = $row[1];
                                $sql = "SELECT name FROM user WHERE username = '******'";
                                $res = mysqli_query($con, $sql);
                                if ($res) {
                                    $Name = mysqli_fetch_row($res)[0];
                                    $i++;
                                    $tmp = array("{$i}" => array("Name" => $Name, "Rating" => $Rating));
                                    $package = array_merge($package, $tmp);
                                } else {
                                    queryFailed($con, 2.1);
                                }
                            }
                            sendPackage($con, $package, true, "", "LEADERBOARD SENT");
                        } else {
                            queryFailed($con, 2.2);
                        }
                    } else {
                        missingParams();
                    }
                }
            }
        }
    }
}
示例#8
0
         sendPackage($con, $package, true, "", "USER LEFT GROUP");
     } else {
         $participation = mysqli_fetch_row($result)[0];
         $sql = "SELECT starttime FROM events WHERE eventid = '{$EventID}'";
         $result = mysqli_query($con, $sql);
         if ($result) {
             $StartTime = mysqli_fetch_row($result)[0];
             #Remove user from event
             if ($participation == 0 && date('Y-m-d H:i:s', strtotime("+1 day")) < $StartTime) {
                 $sql = "DELETE FROM eventmembers WHERE eventid = '{$EventID}' AND username = '******'; ";
                 $result = mysqli_query($con, $sql);
                 if ($result) {
                     sendPackage($con, $package, true, "", "USER LEFT EVENT");
                 }
             } else {
                 sendPackage($con, $package, false, 4, "EVENT IS PROTECTED");
             }
         } else {
             queryFailed($con, 2.11);
         }
     }
 } else {
     if ($result) {
         $Reason = 13;
         $package = array("0" => array("status" => false, "reason" => $Reason));
         packageLog($package);
         file_put_contents("{$logTxt}", "USER NOT IN EVENT!\n{$EOT}", FILE_APPEND | LOCK_EX);
         echo json_encode($package);
         fclose($handle);
         exit;
     } else {