function buildTableCompetitionsMedia()
{
    #----------------------------------------------------------------------
    #--- CompetitionsMedia table: Create it.
    reportAction("CompetitionsMedia", "Create");
    dbCommand("\n    CREATE TABLE CompetitionsMedia (\n      id                 INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,\n      competitionId      VARCHAR(32)      NOT NULL,\n      type               VARCHAR(15)      NOT NULL,\n      text               VARCHAR(100)     NOT NULL,\n      uri                VARCHAR(500)     NOT NULL,\n      submitterName      VARCHAR(50)      NOT NULL,\n      submitterComment   VARCHAR(500)     NOT NULL,\n      submitterEmail     VARCHAR(45)      NOT NULL,\n      timestampSubmitted TIMESTAMP        NOT NULL DEFAULT CURRENT_TIMESTAMP,\n      timestampDecided   TIMESTAMP        NOT NULL,\n      status             VARCHAR(10)      NOT NULL,\n      PRIMARY KEY ( id )\n    )\n ");
    #--- Get the data from the Competitions table.
    $media = dbQuery("\n    SELECT id competitionId, 'report' type, reports data FROM Competitions\n    UNION\n    SELECT id competitionId, 'article' type, articles data FROM Competitions\n    UNION\n    SELECT id competitionId, 'multimedia' type, multimedia data FROM Competitions\n  ");
    #--- Fill the CompetitionsMedia table with the data.
    reportAction("CompetitionsMedia", "Fill with data from table Competitions");
    #  echo "<table>";
    foreach ($media as $data) {
        extract($data);
        # competitionId, type, data
        $competition = getFullCompetitionInfos($competitionId);
        $timestampComp = $competition['year'] . '-' . $competition['month'] . '-' . $competition['day'];
        //noticeBox( true, "One timestamp of comp $competitionId : $timestampComp" );
        preg_match_all('/\\[ \\{ ([^}]+) } \\{ ([^}]+) } ]/x', $data, $matches, PREG_SET_ORDER);
        foreach ($matches as $match) {
            list($all, $text, $uri) = $match;
            #--- Polish the data.
            $text = mysqlEscape($text);
            $uri = mysqlEscape($uri);
            #      echo "<tr><td>";
            #      echo implode( "</td><td>", array( $competitionId, $type, $text, $uri ));
            #      echo "</td></tr>";
            dbCommand("\n        INSERT INTO CompetitionsMedia\n          (competitionId, type, uri, text, submitterComment, submitterEmail, submitterName, timestampSubmitted, timestampDecided, status)\n        VALUES\n          ('{$competitionId}', '{$type}', '{$uri}', '{$text}', '{$comment}', '', '', '{$timestampComp}', '{$timestampComp}', 'accepted')\n      ");
        }
    }
    #  echo "</table>";
}
Example #2
0
/**
 * Write form response to a database.
 *
 * Writes the form response to the database specified at 'CC_FB_DB_ADDRESS'
 * if appropriate.  If the database doesn't it exist, the form_results
 * table doesn't exist or if the form_results table doesn't comply with
 * the structure of the current form then the database will be restructured
 * accordingly.
 * 
 * @param array $preferences the CoffeeCup Flash Form Builder Preferences.
 */
function writeResponseToDatabase($preferences)
{
    // If the CC_FB_DB_ADDRESS constant has been populated, then
    // the user wants to write their data to a database.
    if (CC_FB_DB_ADDRESS != '[ADDRESS]') {
        // First and foremost, lets make sure they have the mysql extension
        // loaded.
        if (!extension_loaded('mysql')) {
            printMessage('Unable to use MySQL', "We're sorry but you must have the MySQL extensions loaded " . 'in your PHP configuration in order to save your form ' . 'results to a MySQL database. Please contact your ' . 'server administrator.');
        } elseif (!($link = mysql_connect(CC_FB_DB_ADDRESS . ':' . CC_FB_DB_PORT, CC_FB_DB_USERNAME, CC_FB_DB_PASSWORD))) {
            printMessage('Unable to Connect to Database Server.', "We're sorry but we were unable to connect to your database " . 'server. Please be sure you have entered your database ' . 'settings correctly.');
        } elseif (!mysql_select_db(CC_FB_DB_NAME, $link)) {
            if (!mysql_query('CREATE DATABASE ' . CC_FB_DB_NAME, $link)) {
                printMessage('Unable to Create Database.', "We're sorry but we were unable to create your database. " . 'If you believe the database already exists, please ' . 'be sure that you have the proper permissions to ' . 'select it.  Otherwise, please be sure that you ' . 'have permissions to create databases.  If you ' . 'are still experiencing troubles, please contact ' . 'your server administrator.');
            } elseif (!mysql_select_db(CC_FB_DB_NAME, $link)) {
                printMessage('Unable to select Database.', "We're sorry but we were unable to select your database. " . 'Please be sure that you have the proper permissions to ' . 'select it.  If you are still experiencing trouble, ' . 'please contact your server administrator.');
            }
        }
        // If a form_results table exists, make sure it is in the
        // proper format.
        if (mysql_num_rows(mysql_query("SHOW TABLES LIKE 'form_results'", $link)) != 0) {
            if (!($results = mysql_query('SHOW COLUMNS FROM `form_results`', $link))) {
                printMessage('Unable to Query Database.', "We're sorry but we were unable to query your database " . 'table. Please be sure that you have the proper ' . 'permissions to select from the form_results ' . 'table. If you are still experiencing trouble, ' . 'please contact your server administrator.');
            }
            while ($row = mysql_fetch_assoc($results)) {
                if ($row['Field'] != 'id' && $row['Field'] != 'created_at') {
                    $columns[$row['Field']] = $row;
                }
            }
            if (!formFieldsEqualsTableFields($preferences['form_fields'], $columns)) {
                archiveOldTable($link);
                createTableFromFormFields($preferences['form_fields'], $link);
            }
        } else {
            createTableFromFormFields($preferences['form_fields'], $link);
        }
        // If all went well, lets attempt to write the form results to
        // the database.
        foreach ($preferences['form_fields'] as $field_name => $field) {
            $query .= "`{$field_name}` = " . mysqlEscape($_POST[$field_name], $link) . ',';
        }
        // Add the uploaded file to the query if necessary
        if (CC_FB_ATTACHMENT_SAVETODB) {
            if ($_POST['Uploaded_File'] != '') {
                if (!($contents = file_get_contents(CC_FB_UPLOADS_DIRECTORY . "/{$_POST['Uploaded_File']}"))) {
                    printMessage('Unable To Open Attachment File', "We're sorry " . 'but we were unable to open your uploaded file to ' . 'attach it for email. Please be sure that you have the ' . 'proper permissions.');
                }
                $query .= '`uploaded_file_name` = ' . mysqlEscape($_POST['Uploaded_File'], $link) . ',' . '`uploaded_file` = ' . mysqlEscape($contents, $link) . ',';
            } else {
                $query .= "`uploaded_file_name` = '',`uploaded_file` = '',";
            }
        }
        if (!mysql_query('INSERT INTO `form_results` SET ' . $query . "`created_at` = NOW()", $link)) {
            printMessage('Unable to Insert Into Database Table.', "We're sorry but we were unable to insert the form results " . 'into your database table. Please be sure that you have ' . 'the proper permissions to insert data into the ' . 'form_results table. If you are still experiencing ' . 'trouble, please contact your server administrator.');
        }
    }
}
Example #3
0
    } else {
        //send staff the notification email
        $notificationMsg = "Name of submitter: " . $name;
        $headers2 = "From: comments@example.com" . "\n";
        $mailRecips = '*****@*****.**' . ', ' . '*****@*****.**';
        $sent2 = mail($mailRecips, 'Flickr upload: Rally', $notificationMsg, $headers2);
        if (!$sent2) {
            $eMore .= "Email notification was not successful.";
        }
        $getStoringInc = (require_once 'storing_data.php');
        if (!$getStoringInc) {
            $eMore .= "Including storing_data.php was not successful.\n";
        }
        $sql = '';
        if ($formname == 'rally') {
            $sql = "INSERT INTO rally (fname, lname, association, city, state, zip, email, photo_filename, photo_title) VALUES (\r\n\t\t\t'" . mysqlEscape($fname) . "',\r\n\t\t\t'" . mysqlEscape($lname) . "',\r\n\t\t\t'" . mysqlEscape($association) . "',\r\n\t\t\t'" . mysqlEscape($city) . "',\r\n\t\t\t'" . mysqlEscape($state) . "',\r\n\t\t\t'" . mysqlEscape($zip) . "',\r\n\t\t\t'" . mysqlEscape($email) . "',\r\n\t\t\t'" . mysqlEscape($photo_filename) . "',\r\n\t\t\t'" . mysqlEscape($title) . "'\r\n\t\t\t)";
        }
        $addRow = storeData($sql, $eMore);
        $eMore .= $addRow;
        if ($eMore != "") {
            $e .= "The photo was (probably) sent to Flickr but was not successfully added to the database.\n" . "Here is some additional information on the subject:\n" . $eMore;
        }
        ?>
		<script type="text/javascript">
		var url = "confirmationPage.html";
		window.location = url;
		</script>
<?php 
    }
}
?>
function getCompetitionDelegates ( $id ) {
#----------------------------------------------------------------------

  #--- Return array of hashes with all delegates data.
  $id = mysqlEscape( $id );
  $results = dbQuery( "SELECT name, email FROM competition_delegates LEFT JOIN users ON users.id=competition_delegates.delegate_id WHERE competition_delegates.competition_id='$id' ORDER BY name" );
  return $results;
}
function adaptResults ( $oldName, $oldCountry, $newName, $newCountry, $newId ) {
#----------------------------------------------------------------------

  #--- Mysql-ify.
  $oldName    = mysqlEscape( $oldName );
  $oldCountry = mysqlEscape( $oldCountry );
  $newName    = mysqlEscape( $newName );
  $newCountry = mysqlEscape( $newCountry );
  $newId      = mysqlEscape( $newId );

  #--- Build the command.  
  $command = "
    UPDATE Results
    SET personName='$newName', countryId='$newCountry', personId='$newId'
    WHERE personName='$oldName' AND countryId='$oldCountry' AND personId=''
  ";
  
  #--- Show the command.
  echo colorize( $command );
  
  #--- Execute the command.
  dbCommand( $command );
}
Example #6
0
        $urlOrig = $rank = $other = "";
        if ("alexa" === $gFileType) {
            if (preg_match('/^([0-9]*),(.*)$/', $line, $aMatches)) {
                $urlOrig = "http://www." . $aMatches[2] . "/";
                $rank = $aMatches[1];
            }
        } else {
            if ("other" === $gFileType) {
                if (preg_match('/^(http[s]*:\\/\\/.*\\/)$/', $line, $aMatches)) {
                    $urlOrig = $aMatches[1];
                    $other = "true";
                }
            }
        }
        if ($urlOrig) {
            $sInsert .= ",('" . mysqlEscape($urlOrig) . "', {$timeAdded}" . ($rank ? ", {$rank}" : "") . ($other ? ", {$other}" : "") . ")";
            $n++;
            if (0 === $n % 1000) {
                // faster to do many inserts at a time
                doSimpleCommand("insert into {$gUrlsTable} (urlOrig, timeAdded" . ($rank ? ", ranktmp" : "") . ($other ? ", other" : "") . ") VALUES " . substr($sInsert, 1) . " ON DUPLICATE KEY UPDATE " . ($rank ? "ranktmp=VALUES(ranktmp)" : "") . ($other ? ($rank ? ", " : "") . "other=VALUES(other)" : ""));
                $sInsert = "";
            }
        }
    }
    // catch any final inserts
    if ($sInsert) {
        doSimpleCommand("insert into {$gUrlsTable} (urlOrig, timeAdded" . ($rank ? ", ranktmp" : "") . ($other ? ", other" : "") . ") VALUES " . substr($sInsert, 1) . " ON DUPLICATE KEY UPDATE " . ($rank ? "ranktmp=VALUES(ranktmp)" : "") . ($other ? ($rank ? ", " : "") . "other=VALUES(other)" : ""));
    }
    fclose($handle);
} else {
    echo "ERROR: Unable to open file \"{$gUrlsFile}\".\n";
Example #7
0
            die("1");
        }
    }
}
$username = null;
if (!is_null(getUsername())) {
    $username = getUsername();
}
$id = "";
if (isset($_GET['id'])) {
    $id = $_GET['id'];
}
$rating = "-1";
if (!is_null($username) && $id != "") {
    $usernamee = mysqlEscape($username);
    $ide = mysqlEscape($id);
    $sql = "SELECT rating FROM ratings WHERE username='******' AND item_id='{$ide}'";
    $result = mysqli_query($conn, $sql);
    if ($result && ($row = mysqli_fetch_assoc($result))) {
        $rating = $row['rating'];
    }
}
?>
<!DOCTYPE html>
<html>

<head>
  <title>Ratings <?php 
echo $version;
?>
</title>