Beispiel #1
0
function backfill_target($server_cfg, $game_cfg, $target_path, $command, $logger, $content = false)
{
    $command = strtolower($command);
    $xhProfModelObject = new XhProfModel($server_cfg, $game_cfg, false);
    $tmp_file = $_FILES['uploadedfile']['tmp_name'];
    $uploaded_file_name = basename($_FILES['uploadedfile']['name']);
    if (isset($tmp_file)) {
        $content = file_get_contents($tmp_file);
    }
    $timestamp = get_timestamp($uploaded_file_name, $content !== false);
    $result = insert_event($xhProfModelObject, $server_cfg, $game_cfg, $timestamp, $command, $content);
    if ($result) {
        $logger->log("uploader", $content . " has been inserted", Logger::INFO);
        return "\"{$content}\" as a \"{$command}\" event at {$timestamp}";
    }
    $target_file = "{$target_path}/{$timestamp}.{$command}";
    if (isset($tmp_file) && move_uploaded_file($tmp_file, $target_file) || file_put_contents($target_file, $content)) {
        $logger->log("uploader", $target_file . " has been uploaded", Logger::INFO);
        echo "SUCCESS: {$target_file} has been uploaded<br></br>\n";
        touch("{$target_path}/.{$command}");
    } else {
        $logger->log("uploader", "could not move " . $tmp_file . " to " . $target_file, Logger::ERR);
        $target_file = null;
        header("HTTP/1.1 500 Server error");
        echo "FAILED: could not move {$tmp_file} to  {$target_file}<br></br>\n";
    }
    return $target_file;
}
Beispiel #2
0
function input_html($event)
{
    //For each team in the event
    //Insert Player.  Get player id
    //Insert Team. 	Get team id
    //Insert Player_Team.
    insert_teams($event->teams);
    sync_team_ids($event);
    //Insert Basic Event Information.  Get event id
    $event->event_id = insert_event($event);
    //Insert Event Rankings for each team.
    insert_rankings($event->ranking_list, $event->event_id);
    //For each game
    echo "\n\nCount of Games: " . count($event->games);
    insert_games($event->games, $event->event_id);
    //Insert  game with the dates and event_id.  Get game id
    //For each player
    //Insert into player_game: player_id, game_id, percentage, num_shots
    //For each end
    //Insert relevant info
    //Insert winners into game_team table
    //Done!
}
Beispiel #3
0
?>


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>Evénement créé</title>
    </head>
    <body>
	
		<?php 
include "Header.php";
require 'fonctions_crea_event.php';
// On fait appel à la fonction insert_event permettant d'insérer les données récupérées du formulaire
insert_event($_POST['sponsor1'], $_POST['sponsor2'], $_POST['sponsor3'], $_POST['sponsor4'], $_POST['codepostal'], $_POST['numerorue'], nl2br(htmlspecialchars(addslashes($_POST['pays']))), nl2br(htmlspecialchars(addslashes($_POST['rue']))), nl2br(htmlspecialchars(addslashes($_POST['ville']))), $_POST['date_e'], $_POST['date_f'], nl2br(htmlspecialchars(addslashes($_POST['description_e']))), $_POST['heuredebut'], $_POST['heurefin'], nl2br(htmlspecialchars(addslashes($_POST['nb_max_participant']))), nl2br(htmlspecialchars(addslashes($_POST['Nom_e']))), $_POST['privacy'], $_POST['prix'], nl2br(htmlspecialchars(addslashes($_POST['urlsite_event']))));
// On fait une requête permettant de trouver le dernier événement créé, celui-ci est l'événement en cours de création
$id_event = mysqli_fetch_assoc(mysqli_query($connect, "select max(Event_id) as max from event"));
$idevent = $id_event['max'];
// On précise le chemin dans lequel seront sauvegardées les images
$uploaddir = '../reste/photo_event/';
// On attribue un chemin au fichier à télécharger composé du chemin défini au dessus ainsi que du nom du fichier
$uploadfile1 = $uploaddir . $_FILES['photo_principale']['name'];
// On exécute la fonction permettant de télécharger le fichier
upload('photo_principale', $uploadfile1, 20000000, array('png', 'gif', 'jpg', 'jpeg', 'PNG', 'JPG'));
mysqli_query($connect, "insert into multimedia(Event_id, urlimg_event, principale) values ('{$idevent}', '{$uploadfile1}', 1)");
// On vérifie en suite qu'une autre image a été fournie par l'utilisateur et ainsi de suite
if ($_FILES['photo_secondaire']['size'] != 0) {
    $uploadfile2 = $uploaddir . $_FILES['photo_secondaire']['name'];
    upload('photo_secondaire', $uploadfile2, 20000000, array('png', 'gif', 'jpg', 'jpeg', 'PNG', 'JPG'));
    mysqli_query($connect, "insert into multimedia(Event_id, urlimg_event, principale) values ('{$idevent}', '{$uploadfile2}', 0)");
Beispiel #4
0


<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <link type="text/css" rel="stylesheet" href="Header.css"/>
       <?php 
include "Header.php";
?>
        <?php 
require 'fonctions_crea_event.php';
insert_event($_POST['Nom_e'], $_POST['lieu'], $_POST['prix'], $_POST['date_e'], $_POST['heuredebut'], $_POST['heurefin'], $_POST['nb_max_participant'], $_POST['description_e'], $_POST['privacy'], $_SESSION['id_utilisateur']);
?>
        <?php 
header("Refresh:0, url = Accueil.php");
exit;
?>
        
    </body>
</html>
<!-- insert_teacher.php
   A PHP script to insert a new ad event into the test database
  -->
<?php 
require 'db_cn.inc';
require 'db_access.inc';
//This file contains php code that will be executed after the
//insert operation is done.
require 'event_insert_result_ui.inc';
// Main control logic
insert_event();
//-------------------------------------------------------------
function insert_event()
{
    // Connect to the 'test' database
    // The parameters are defined in the db_cn.inc file
    // These are global constants
    connect_and_select_db(DB_SERVER, DB_UN, DB_PWD, DB_NAME);
    // Get the information entered into the webpage by the user
    // These are available in the super global variable $_POST
    // This is actually an associative array, indexed by a string
    $eventCode = mysql_real_escape_string($_POST['eventCode']);
    $eventName = mysql_real_escape_string($_POST['eventName']);
    $startDate = mysql_real_escape_string($_POST['startDate']);
    $endDate = mysql_real_escape_string($_POST['endDate']);
    $description = mysql_real_escape_string($_POST['description']);
    $type = mysql_real_escape_string($_POST['type']);
    // Create a String consisting of the SQL command. Remember that
    // . is the concatenation operator. $varname within double quotes
    // will be evaluated by PHP
Beispiel #6
0
function run_mail_queue()
{
    global $config;
    include_once $config["homedir"] . "/include/functions.php";
    require_once $config["homedir"] . "/include/swiftmailer/swift_required.php";
    $utimestamp = date("U");
    // $current_date = date ("Y/m/d H:i:s");
    if (isset($config["batch_newsletter"])) {
        $limit = " LIMIT " . $config['batch_newsletter'];
    } else {
        $limit = "";
    }
    // get pending mails
    $mails = get_db_all_rows_sql("SELECT * FROM tpending_mail WHERE status = 0" . $limit);
    if ($mails) {
        foreach ($mails as $email) {
            // Use local mailer if host not provided - Attach not supported !!
            //Headers must be comma separated
            if (isset($email["extra_headers"])) {
                $extra_headers = explode(",", $email["extra_headers"]);
            } else {
                $extra_headers = array();
            }
            if ($config["smtp_host"] == "") {
                // Use internal mail() function
                $headers = array();
                $headers[] = "MIME-Version: 1.0";
                $headers[] = "Content-type: text/plain; charset=utf-8";
                $headers = array_merge($headers, $extra_headers);
                if ($email["from"] == "") {
                    $from = $config["mail_from"];
                } else {
                    $from = $email["from"];
                }
                $headers[] = "From: " . $from;
                $headers[] = "Subject: " . safe_output($email["subject"]);
                if ($email["cc"]) {
                    $aux_cc = implode(",", $email["cc"]);
                    $headers[] = "Cc: " . $aux_cc;
                }
                $dest_email = trim(ascii_output($email['recipient']));
                $body = safe_output($email['body']);
                $error = mail($dest_email, safe_output($email["subject"]), $body, implode("\r\n", $headers));
                if (!$error) {
                    process_sql("UPDATE tpending_mail SET status = {$status}, attempts = {$retries} WHERE id = " . $email["id"]);
                } else {
                    // no errors found
                    process_sql("DELETE FROM tpending_mail WHERE id = " . $email["id"]);
                }
            } else {
                // Use swift mailer library to connect to external SMTP
                try {
                    // If SMTP port is not configured, abort mails directly!
                    if ($config["smtp_port"] == 0) {
                        return;
                    }
                    $transport = Swift_SmtpTransport::newInstance($config["smtp_host"], $config["smtp_port"]);
                    $transport->setUsername($config["smtp_user"]);
                    $transport->setPassword($config["smtp_pass"]);
                    $mailer = Swift_Mailer::newInstance($transport);
                    $message = Swift_Message::newInstance($email["subject"]);
                    if ($email["from"] == "") {
                        $message->setFrom($config["mail_from"]);
                    } else {
                        $message->setFrom($email["from"]);
                    }
                    if ($email["cc"]) {
                        $message->setCc($email["cc"]);
                    }
                    $to = trim(ascii_output($email['recipient']));
                    $toArray = array_map('trim', explode(",", $to));
                    if ($toArray) {
                        $to = $toArray;
                    }
                    $message->setTo($to);
                    $message->setBody($email['body'], 'text/plain', 'utf-8');
                    if ($email["attachment_list"] != "") {
                        $attachments = explode(",", $email["attachment_list"]);
                        foreach ($attachments as $attachment) {
                            if (is_file($attachment)) {
                                $message->attach(Swift_Attachment::fromPath($attachment));
                            }
                        }
                    }
                    $message->setContentType("text/plain");
                    $headers = $message->getHeaders();
                    foreach ($extra_headers as $eh) {
                        $aux_header = explode(":", $eh);
                        $headers->addTextHeader($aux_header[0], $aux_header[1]);
                    }
                    //Check if the email was sent at least once
                    if ($mailer->send($message) >= 1) {
                        process_sql("DELETE FROM tpending_mail WHERE id = " . $email["id"]);
                    } else {
                        throw new Exception(__('The mail send failed'));
                    }
                } catch (Exception $e) {
                    $retries = $email["attempts"] + 1;
                    if ($retries > $config["smtp_queue_retries"]) {
                        $status = 1;
                        insert_event('MAIL_FAILURE', 0, 0, $email["recipient"] . " - " . $e);
                    } else {
                        $status = 0;
                    }
                    process_sql("UPDATE tpending_mail SET status = {$status}, attempts = {$retries} WHERE id = " . $email["id"]);
                    integria_logwrite(sprintf("SMTP error sending to %s (%s)"), implode(',', $toArray), $e);
                }
            }
        }
    }
}
    $new_rank = $bs['classId'] * $active / 2;
    $db->query(sprintf("UPDATE `businesses` SET `busYCust` = `busCust`, `busYProfit` = `busProfit`, `busCust` = '%d', `busProfit` = '%d', `busCash` = '%d' WHERE `busId` = '%u'", $new_customers, $new_profit, $new_profit + $bs['busCash'], $bs['busId']));
    $db->query(sprintf("UPDATE `businesses` SET `busDays` = `busDays` + '1'"));
    $db->query(sprintf("UPDATE `users` SET `activedays` = `activedays` + '1' WHERE `active` = '1'"));
    $db->query(sprintf("UPDATE `users` SET `active` = '0' WHERE `active` = '1'"));
    $db->query(sprintf("UPDATE `businesses` SET `brank` = `brank` + '%d' WHERE `busId` = '%u'", $new_rank, $bs['busId']));
    $fetch_members = $db->query(sprintf("SELECT * FROM `businesses_members` LEFT JOIN `users` ON (`userid` = `bmembMember`) LEFT JOIN `businesses_ranks` ON (`rankId` = `bmembRank`) WHERE `bmembBusiness` = '%u'", $bs['busId'])) or die('Cron not run');
    $db->query("UPDATE userstats SET labour = labour + 50, IQ = IQ + 50, strength = strength + 50 WHERE userid = {$bs['busDirector']}");
    $db->query("UPDATE users SET comppoints = comppoints + 1 WHERE userid = {$bs['busDirector']}");
    while ($fm = $db->fetch_row($fetch_members)) {
        $db->query(sprintf("UPDATE `userstats` SET `{$fm['rankPrim']}` = `{$fm['rankPrim']}` + '%.6f', `{$fm['rankSec']}` = `{$fm['rankSec']}` + '%.6f' WHERE (`userid` = '%u')", $fm['rankPGain'], $fm['rankSGain'], $fm['userid'])) or die('Cron not run');
        $db->query(sprintf("UPDATE `users` SET `money` = `money` + '%d' WHERE `userid` = '%u'", $fm['bmembCash'], $fm['userid'])) or die('Cron not run');
        $db->query(sprintf("UPDATE `users` SET `comppoints` = `comppoints` + '1' WHERE `userid` = '%u'", $fm['userid'])) or die('Cron not run');
        if ($bs['busCash'] < $fm['bmembCash']) {
            $text = "Member ID {$fm['bmembMember']} was not paid their \$" . number_format($fm['bmembCash']) . " due to lack of funds." or die('Cron not run');
            $db->query(sprintf("INSERT INTO `businesses_alerts` (`alertId`, `alertBusiness`, `alertText`, `alertTime`) VALUES ('NULL', '%u', '%s', '%d')", $bs['busId'], $text, time())) or die('Cron not run');
            $db->query(sprintf("UPDATE `businesses` SET `busDebt` = `busDebt` + '%d' WHERE `busId` = '%u'", $fm['bmembCash'], $bs['busId'])) or die('Cron not run');
        } else {
            $db->query(sprintf("UPDATE `businesses` SET `busCash` = `busCash` - '%d' WHERE `busId` = '%u'", $fm['bmembCash'], $bs['busId'])) or die('Cron not run');
        }
    }
    if ($bs['busDebt'] > $bs['classCost']) {
        $send_event = $db->query(sprintf("SELECT `bmembMember` FROM WHERE `bmembBusiness` = '%u' ORDER BY `bmembId` DESC", $bs['busId'])) or die('Cron not run');
        while ($se = $db->fetch_row($send_event)) {
            $text = "The {$bs['busName']} business went bankrupt\\, all members have been made redundent." or die('Cron not run');
            insert_event($se['bmembMember'], $text);
        }
        $db->query(sprintf("DELETE FROM `businesses_members` WHERE (`bmembBusiness` = '%u')", $bs['busId'])) or die('Cron not run');
        $db->query(sprintf("DELETE FROM `businesses` WHERE (`busId` = '%u')", $bs['busId'])) or die('Cron not run');
    }
}
Beispiel #8
0
function run_mail_queue()
{
    global $config;
    // Get pending mails
    $filter = array('status' => 0);
    $mails = get_db_all_rows_filter('tpending_mail', $filter);
    // No pending mails
    if ($mails === false) {
        return;
    }
    // Init mailer
    $mailer = null;
    try {
        // Use local mailer if host not provided - Attach not supported !!
        if (empty($config['smtp_host'])) {
            // Empty snmp conf. System sendmail transport
            $transport = mail_get_transport();
            $mailer = mail_get_mailer($transport);
        } else {
            $mailer = mail_get_mailer();
        }
    } catch (Exception $e) {
        integria_logwrite(sprintf("Mail transport failure: %s", $e->getMessage()));
        return;
    }
    foreach ($mails as $email) {
        try {
            //Check if the email was sent at least once
            if (mail_send($email, $mailer) > 0) {
                process_sql_delete('tpending_mail', array('id' => (int) $email['id']));
            } else {
                throw new Exception(__('The mail send failed'));
            }
        } catch (Exception $e) {
            $retries = $email['attempts'] + 1;
            if ($retries > $config['smtp_queue_retries']) {
                $status = 1;
                insert_event('MAIL_FAILURE', 0, 0, $email['recipient'] . ' - ' . $e->getMessage());
            } else {
                $status = 0;
            }
            $values = array('status' => $status, 'attempts' => $retries);
            $where = array('id' => (int) $email['id']);
            process_sql_update('tpending_mail', $values, $where);
            $to = trim(ascii_output($email['recipient']));
            integria_logwrite(sprintf('SMTP error sending to %s (%s)', $to, $e->getMessage()));
        }
    }
}
Beispiel #9
0
    return $result;
}
?>
<!DOCTYPE HTML>
<html>
    <head>        
        <title>Exemple simple de site en PHP </title>
    </head>
    <body>
        <h1>Liste des utilisateurs</h1>
        <?php 
if (isset($_GET['action']) && $_GET['action'] == "save") {
    if (!empty($_GET['Event_id'])) {
        update_event($_GET['nom'], $_GET['description'], $_GET['Event_id']);
    } else {
        insert_event($_GET['nom'], $_GET['description']);
    }
}
if (isset($_GET['action']) && $_GET['action'] == "ajouter" || isset($_GET['action']) && $_GET['action'] == "modifier") {
    $nom = "";
    $description = "";
    $Event_id = "";
    $prix = "";
    if ($_GET['action'] == "modifier") {
        $result = select_one_event($_GET['id']);
        $event = mysqli_fetch_assoc($result);
        $nom = $event['nom'];
        $description = $event['description_e'];
        $Event_id = $event['Event_id'];
    }
    ?>
function bankrupt_business()
{
    global $ir, $inf, $db;
    if (!$_GET['confirm']) {
        echo '

<div class="generalinfo_txt">
<div><img src="images/info_left.jpg" alt="" /></div>
<div class="info_mid"><h2 style="padding-top:10px;"> Declare Bankrupt</h2></div>
<div><img src="images/info_right.jpg" alt="" /></div> </div>
<div class="generalinfo_simple"><br> <br><br>


You are about to bankrupt the ' . stripslashes($inf['busName']) . ' Company. Please confirm this action.<br />
Once this has been confirmed there is no chance to go back.<br /><br />
<a href="business_manage.php?p=bankrupt&confirm=1">Bankrupt the Company</a> </div><div><img src="images/generalinfo_btm.jpg" alt="" /></div><br></div></div></div></div></div> ';
    } else {
        $send_event = $db->query(sprintf("SELECT `bmembMember` FROM businesses_members WHERE `bmembBusiness` = '%u' ORDER BY `bmembId` DESC", $bs['busId']));
        while ($se = $db->fetch_row($send_event)) {
            $text = "The director has chosen to bankrupt the {$inf['busName']} Company\\, all members have been made redundent.";
            insert_event($se['bmembMember'], $text);
        }
        $db->query(sprintf("DELETE FROM `businesses_members` WHERE (`bmembBusiness` = '%u')", $inf['busId']));
        $db->query(sprintf("DELETE FROM `businesses` WHERE (`busId` = '%u')", $inf['busId']));
        $db->query(sprintf("UPDATE `users` SET `business` = '0' WHERE `business` = '%u'", $inf['busId']));
        echo 'You have decided to bankrupt the Company, all members have been made redundent.';
    }
}