123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- <!DOCTYPE html>
- <html>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <link rel="stylesheet" type="text/css" href="css/style.css">
- <head>
- <title>An African Language Short Story Competition</title>
- </head>
- <body>
- <?php include 'submitdatabaseinfo1.php';?>
- <?php
- $permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-
- function generate_string($input, $strength = 18) {
- $input_length = strlen($input);
- $random_string = '';
- for($i = 0; $i < $strength; $i++) {
- $random_character = $input[mt_rand(0, $input_length - 1)];
- $random_string .= $random_character;
- }
-
- return $random_string;
- }
- if (isset($_POST['createandmailids'])) {
- // Create connections
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- mysqli_set_charset($conn, "utf8");
- // Check connection
- if (!$conn) {
- die("Database connection failed: " . mysqli_connect_error());
- }
- $connvoteid = mysqli_connect($servername, $username, $password, $dbvoteid);
- mysqli_set_charset($connvoteid, "utf8");
- // Check connection
- if (!$connvoteid) {
- die("Database connection failed: " . mysqli_connect_error());
- }
- $sql = "SELECT DISTINCT email FROM originalstories WHERE checked = 'yes'";
- $result = mysqli_query($conn,$sql);
- $rows = mysqli_num_rows($result);
- if ( $rows > 0 ) {
- while($row = mysqli_fetch_array($result)){
- $rows2 = 1;
- while ($rows2 > 0){
- $voteid = generate_string($permitted_chars, 180);
- $sql2 = "SELECT PrimaryKey FROM voteid WHERE voteid = '.$voteid.'";
- $result2 = mysqli_query($connvoteid,$sql2);
- $rows2 = mysqli_num_rows($result2);
- }
- $sql2 = "SELECT DISTINCT language FROM originalstories WHERE email = '".$row["email"]."'";
- $result2 = mysqli_query($conn,$sql2);
- $numlangs = mysqli_num_rows($result2);
- $languages = "";
- while( $row2 = mysqli_fetch_array($result2)){
- $languages .= $row2["language"] . " ";
- }
- $email = $row["email"];
- $sql2 = "INSERT INTO voteid (email, voteid, languages) VALUES ('" . $row["email"] . "','" . $voteid . "','" .$languages . "')";
- if (mysqli_query($connvoteid, $sql2)) {
- echo "New record created successfully";
- $to = $email;
- $subject = "Story Evaluation";
- $txt = "The evaluation phase has begun. You may evaluate stories in languages in which you have made a submission. Please go to https://tuvutepamoja.africa/evaluate.php and enter your personal and private voting code:\n" . $voteid . "\n to find stories you can evaluate. If you submit multiple evaluations of the same story, your last evaluation for each story will be the one that is counted, so please save this email with your voter identification number. In some languages, only a few stories were submitted, so it will not be possible for your evaluation to be anonymous. In cases where several submissions were made, competition organizers do have access to voting information, but will only make average scores and comments public. We hope to implement fully anonymous voting in future. Please also let us know if you have any other suggestions for improvements as we will shortly be running this competition again. Should you have any questions, please contact us at \n lugha@tuvutepamoja.africa \n Sincerely,\nThe organizing committee.\n\n";
- $txt = wordwrap($txt , 70);
- $headers = "From: lugha@tuvutepamoja.africa" . "\r\nContent-Type: text/plain; charset=UTF-8";
- mail($to,$subject,$txt,$headers);
- } else {
- echo "Error creating database record, please contact lugha@tuvutepamoja.africa.";
- //echo $sql2 . "<br>" . mysqli_error($connvoteid);
- }
- }
- }
- mysqli_close($connvoteid);
- mysqli_close($conn);
- exit;
- }
- ?>
- <header>
- <h1>Tuvute Pamoja
- <a href="https://deeplearningindaba.com">
- <img src="images/deeplearningindaba.svg" alt="Deeplearning Indaba" style="height:60px">
- </a></h1>
- </header>
- <form method="post">
- <input type="submit" name="createandmailids" value="Create and Mail Ids"/>
- </form>
- </body>
- </html>
|