コード例 #1
0
function uploadTrack($track_filepath, $user_id, $task_date)
{
    //Upload track to Doarama (create new activity)
    $data = array('gps_track' => "@{$track_filepath}");
    $response = doCurl("activity", $data, $user_id);
    $data = json_decode($response, true);
    $activity_id = $data["id"];
    //Next set activity info https://api.doarama.com/api/0.2/activityType
    /* 27	Fly - Hang Glide
       28	Fly - Sailplane / Glider
       29	Fly - Paraglide	*/
    $data = '{"activityTypeId":29}';
    //TODO: refactor to not just be paragliding
    doCurl("activity/{$activity_id}", $data, $user_id);
    //TODO: replace with your own DB initialization.  I set mine to transactional since I don't want to populate
    //it with bad entries if the track upload fails.
    $conn = initDB();
    $conn->autocommit(FALSE);
    //Create a key for our local DB that we can use to link to a visualization.
    //I use a key that given a date and a competition name will map to one specific visualization for that day
    $league_key = "socal-{$task_date}";
    //TODO: factor out for other leagues.
    //Create an entry in the DB that maps a doarama activity_id to a unique_user_id in your local DB
    //Since naming pilots in the API is done in the order of upload, if you want to name the tracks with
    //user names make sure to be able to query your DB for activities that map to the end visualization
    //and can be sorted in the order they were created.  I've setup my DB to populate date_created automatically
    $sql = "INSERT INTO user_activities (USER_ID, ACTIVITY_ID, LEAGUE_KEY) VALUES (?, ?, ?)";
    $types = "iis";
    $params = array($user_id, $activity_id, $league_key);
    insert_row($conn, $sql, $types, $params);
    //TODO replace with your own DB implementation
    //TODO: update with your own DB implementation
    //Try to find the doarama_key in our DB from our league_key, if we don't get any results it means we haven't
    //yet created a visualization so we'll need to make one and save the Doarama Key in our DB
    $sql = "SELECT doarama_key FROM doaramas WHERE league_key = ?";
    $rows = run_stmt_query($conn, $sql, "s", array($league_key));
    if (count($rows) < 1) {
        // Create Visualization
        $data = '{"activityIds":[' . $activity_id . ']}';
        $response = doCurl("visualisation", $data, $user_id);
        //get doarama_key
        $data = json_decode($response, true);
        $doarama_key = $data["key"];
        //TODO: update with your own DB implementation
        //insert into DB
        $sql = "INSERT INTO doaramas (league_key, doarama_key) VALUES (?, ?)";
        $types = "ss";
        $params = array($league_key, $doarama_key);
        insert_row($conn, $sql, $types, $params);
    } else {
        $doarama_key = $rows[0]['doarama_key'];
        // Add activity to visualization
        $data = '{"visualisationKey" : "' . $doarama_key . '", "activityIds": [' . $activity_id . ']}';
        doCurl("visualisation/addActivities", $data, $user_id);
    }
    //TODO: update with your DB implementation
    //all done now, can commite the transaction
    $conn->commit();
    $conn->close();
}
コード例 #2
0
ファイル: common.php プロジェクト: apelburg/test
function add_rows_to_rt($row_id, $type_row, $num, $control_num)
{
    global $db;
    global $client_id;
    global $user_id;
    function insert_row($row_id, $type_row, $date, $client_id, $user_id, $db)
    {
        $query_enlarge = "UPDATE `" . CALCULATE_TBL . "` SET `id` = `id` + 1  WHERE `id` >= '" . $row_id . "' ORDER BY `id` DESC";
        $result_enlarge = mysql_query($query_enlarge, $db) or die(mysql_error());
        $query = "INSERT INTO `" . CALCULATE_TBL . "` SET `id` = '" . $row_id . "', `type` = '" . $type_row . "', `order_num` = '', `date` = '" . $date . "', `client_id` = '" . $client_id . "', `manager_id` = '" . $user_id . "' ";
        $result = mysql_query($query, $db);
        if (!$result) {
            exit(mysql_error());
        } else {
            make_note_to_rt_protocol('insert', $type_row, mysql_insert_id($db), $user_id, $client_id);
        }
    }
    // схема:
    //  1).   блокируем таблицу CALCULATE_TBL
    //  2).   производим изменения в таблице CALCULATE_TBL
    //  3).   разболкируем таблицы CALCULATE_TBL
    //  1)
    mysql_query("LOCK TABLES " . CALCULATE_TBL . " WRITE, " . CALCULATE_TBL_PROTOCOL . " WRITE ") or die(mysql_error());
    $row_id = check_changes_to_rt_protocol($control_num, $row_id);
    if ($row_id == false) {
        mysql_query("UNLOCK TABLES") or die(mysql_error());
        return;
    }
    //  2)
    for ($i = 0; $i < $num; $i++) {
        insert_row($row_id++, $type_row, '', $client_id, $user_id, $db);
    }
    //  3)
    mysql_query("UNLOCK TABLES") or die(mysql_error());
    header('Location:?' . addOrReplaceGetOnURL('', 'add_rows_to_rt&add_print_row&type_row&num&id&control_num'));
    exit;
}
コード例 #3
0
ファイル: data.php プロジェクト: silvadelphi/firebirdwebadmin
                    $bindargs[] = $bstr;
                } else {
                    $bindargs[] = NULL;
                }
                break;
            default:
                if ($value === '') {
                    $value = NULL;
                }
                $bindargs[] = $value;
        }
        $cols[] = $field['name'];
        $idx++;
    }
    if (count($cols) > 0) {
        $ib_error = insert_row($s_enter_name, $cols, $bindargs);
        if (empty($ib_error)) {
            $s_watch_buffer = '';
            $s_enter_values = $s_cust['enter']['another_row'] == FALSE ? array() : init_enter_values($s_fields[$s_enter_name]);
        }
    }
}
//
// the Ready button on the dt_enter-panel was pushed
//
if (isset($_POST['dt_enter_ready']) || isset($_POST['dt_enter_insert']) && $s_cust['enter']['another_row'] == FALSE && empty($ib_error)) {
    $s_enter_name = '';
    $s_enter_values = array();
}
//
// the Export button on the csv-panel was pushed
コード例 #4
0
        throw new Exception(_("File delle stazioni non trovato"), 2);
    }
    if (!($handle = fopen(FILENAME_STATIONS, 'r'))) {
        throw new Exception(_("Impossibile aprire il file delle stazioni"), 3);
    }
    // Waste first 2 lines
    fgetcsv($handle);
    fgetcsv($handle);
    while ($data = fgetcsv($handle, 512, ';')) {
        get_station_ID((int) $data[0], $data[4], $data[3], $data[5], (double) $data[8], (double) $data[9], get_comune_ID(generate_slug($data[6]), $data[6], $data[7]), get_stationowner_ID(generate_slug($data[1]), $data[1]), get_fuelprovider_ID(generate_slug($data[2]), $data[2]));
    }
    fclose($handle);
    // Prices
    if (!file_exists(FILENAME_PRICES)) {
        throw new Exception(_("File dei prezzi non trovato"), 4);
    }
    if (!($handle = fopen(FILENAME_PRICES, 'r'))) {
        throw new Exception(_("Impossibile aprire il file dei prezzi"), 5);
    }
    // Waste first 2 lines
    fgetcsv($handle);
    fgetcsv($handle);
    while ($data = fgetcsv($handle, 255, ';')) {
        insert_row('price', [new DBCol('price_value', (double) $data[2], 'f'), new DBCol('price_self', (int) $data[3], 'd'), new DBCol('price_date', itdate2datetime($data[4]), 's'), new DBCol('fuel_ID', get_fuel_ID(generate_slug($data[1]), $data[1]), 'd'), new DBCol('station_ID', get_station_ID((int) $data[0]), 'd')]);
    }
    fclose($handle);
} catch (Exception $e) {
    printf(_("Errore: %s."), $e->getMessage());
    echo "\n";
    exit($e->getCode());
}
コード例 #5
0
ファイル: function.inc.php プロジェクト: pzotov/domkam
function saveAnalogs()
{
    global $message, $db;
    $db->query("DELETE FROM Stone_Analogs WHERE Stone1_ID={$message} OR Stone2_ID={$message}");
    if (is_array($_POST['analogs'])) {
        foreach ($_POST['analogs'] as $a) {
            insert_row("Stone_Analogs", array("Stone1_ID" => $message, "Stone2_ID" => $a));
            insert_row("Stone_Analogs", array("Stone2_ID" => $message, "Stone1_ID" => $a));
        }
    }
}
コード例 #6
0
ファイル: index.php プロジェクト: wanzola/SpottedUnito
 $last_name =& $update['message']['from']['last__name'];
 $username =& $update['message']['from']['username'];
 if (is_command($text, '/start')) {
     // Exists?
     $exists = query_row(sprintf("SELECT 1 FROM {$T('spotter')} " . "WHERE spotter_chat_ID = %d", $update['message']['chat']['id']));
     // Insert if not exists
     $exists || insert_row('spotter', [new DBCol('spotter_chat_id', $update['message']['chat']['id'], 'd'), new DBCol('spotter_datetime', 'NOW()', '-')]);
     apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => "Benvenuto sul bot di <b>Spotted Unito</b>\n\n" . "Con questo bot, potrai inviare i tuoi appelli o confessioni anonimamente, a tutti coloro che seguono questo bot.\n" . "Per inviare uno spot, non ti resta altro che scrivere (indifferente se maiuscolo o minuscolo) <code>spotted messaggio</code>, dove al posto di <code>messaggio</code> dovrete scrivere" . " il testo desiderato. (Es. <code>spotted Un saluto a tutti!</code>)\n\nNB: attualmente non sono supportate le emoticon", 'parse_mode' => "HTML", 'disable_web_page_preview' => true]);
     apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => "Un messaggio di conferma apparirà successivamente. Da quel momento, il messaggio, appena " . "i moderatori avranno verificato che non contenga parole inappropriate (bestemmie, minacce, offese, ecc...), verrà pubblicato." . "\n\nIn caso di necessità, premere su /help , oppure inviare un messaggio con <code>/help messaggio</code>.", 'parse_mode' => "HTML", 'disable_web_page_preview' => true]);
 } elseif (stripos($text, 'spotted') === 0) {
     $spotted = ltrim(str_ireplace('spotted', '', $text));
     if (strlen($spotted) === 0) {
         apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => _("Il comando <code>spotted</code> è esatto. Tuttavia, per inviare uno spot, deve essere seguito da un messaggio.\n" . "Es. Spotted Chi da l'esame al posto mio domani?"), 'parse_mode' => 'HTML']);
     } else {
         $spotted = str_truncate($spotted, 1000, '...');
         insert_row('spotted', [new DBCol('spotted_datetime', 'NOW()', '-'), new DBCol('spotted_message', $spotted, 's'), new DBCol('spotted_chat_id', $update['message']['chat']['id'], 'd'), new DBCol('spotted_approved', 0, '-')]);
         refresh_admin_keyboard($update['message']['chat']['id'], $spotted, $first_name, $last_name, $username);
         $spotters = query_value("SELECT COUNT(*) as count FROM {$T('spotter')}", 'count');
         apiRequest('sendMessage', ['chat_id' => $update['message']['chat']['id'], 'text' => sprintf(_("Il messaggio\n<code>" . $spotted . "</code>\ne' stato acquisito ed ora è in coda di moderazione per esser mandato a <b>%d</b> persone.\n"), $spotters), 'parse_mode' => 'HTML']);
     }
 } elseif (is_command($text, 'Pubblica')) {
     $spotted_ID = (int) trim(str_replace('Pubblica', '', $text));
     if ($spotted_ID) {
         query(sprintf("UPDATE {$T('spotted')} " . "SET " . "spotted_approved = 1 " . "WHERE " . "spotted_ID = %d", $spotted_ID));
         $spotters = query_results("SELECT spotter_ID FROM {$T('spotter')}", 'Spotter');
         $fifo_rows = [];
         foreach ($spotters as $spotter) {
             $fifo_rows[] = [$spotted_ID, $spotter->spotter_ID];
         }
         insert_values('fifo', ['spotted_ID' => 'd', 'spotter_ID' => 'd'], $fifo_rows);
     }
コード例 #7
0
ファイル: form-submit.php プロジェクト: CODAME/codame-website
         if ($table == 'artists') {
             $row_array = array('name' => $name, 'slug' => $slug, 'pic' => $pic, 'description' => $_POST['description'], 'twitter' => $_POST['twitter'], 'website' => $_POST['website'], 'email' => $_POST['email'], 'old_url' => $_POST['old-url'], 'edited' => $now);
         }
         // project row
         if ($table == 'projects') {
             $row_array = array('name' => $name, 'slug' => $slug, 'pic' => $pic, 'description' => $_POST['description'], 'twitter' => $_POST['twitter'], 'website' => $_POST['website'], 'artists_array' => $_POST['artists-array'], 'old_url' => $_POST['old-url'], 'edited' => $now);
         }
         // page row
         if ($table == 'pages') {
             $row_array = array('name' => $name, 'slug' => $slug, 'pic' => $pic, 'description' => $_POST['description'], 'old_url' => $_POST['old-url']);
         }
         // sponsor row
         if ($table == 'sponsors') {
             $row_array = array('name' => $name, 'slug' => $slug, 'pic' => $pic, 'website' => $_POST['website']);
         }
         insert_row($table, $row_array);
     } else {
         $error = "A post with this name already exists.";
     }
 }
 // edit row
 if ($_POST['action'] == 'edit') {
     $old_slug = $_POST['slug'];
     // event row
     if ($table == 'events') {
         $row_array = array('name' => $name, 'slug' => $slug, 'date' => $_POST['date'], 'pic' => $pic, 'description' => $_POST['description'], 'artists_array' => $_POST['artists-array'], 'projects_array' => $_POST['projects-array'], 'sponsors_array' => $_POST['sponsors-array'], 'old_url' => $_POST['old-url']);
     }
     // artist row
     if ($table == 'artists') {
         $row_array = array('name' => $name, 'pic' => $pic, 'description' => $_POST['description'], 'twitter' => $_POST['twitter'], 'website' => $_POST['website'], 'email' => $_POST['email'], 'slug' => $slug, 'old_url' => $_POST['old-url'], 'edited' => $now);
     }
function get_provincia_ID($provincia_uid, $provincia_name)
{
    global $provincie;
    if (isset($provincie[$provincia_uid])) {
        return $provincie[$provincia_uid];
    }
    insert_row('provincia', [new DBCol('provincia_uid', $provincia_uid, 's'), new DBCol('provincia_name', $provincia_name, 's')]);
    $provincia = query_row(sprintf("SELECT provincia_ID, provincia_uid " . "FROM {$GLOBALS[T]('provincia')} " . "WHERE provincia_ID = %d", last_inserted_ID()), 'Provincia');
    return $provincie[$provincia->provincia_uid] = $provincia->provincia_ID;
}
コード例 #9
0
ファイル: run.php プロジェクト: sujaisd/sample-app
<?php

session_start();
include_once 'common.php';
db_init();
date_default_timezone_set("Asia/Kolkata");
$size = $_POST['size'];
for ($i = 0; $i < $size; $i++) {
    // add record
    insert_row('samples', array('value' => rand(1, 10000), 'created_at' => date('Y-m-d H:i:s')));
    // sleep for a rand number of seconds
    //sleep(rand(1, 3));
    sleep(1);
}
redirect('/index.php');
コード例 #10
0
                     $bindargs[] = $bstr;
                 } else {
                     $bindargs[] = NULL;
                 }
                 break;
             default:
                 if ($value == '') {
                     $value = NULL;
                 }
                 $bindargs[] = empty($field['notnull']) && strlen($value) == 0 ? NULL : $value;
         }
         $cols[] = $field['name'];
         $k++;
     }
     if (count($bindargs) > 0) {
         $ib_error = $s_cust['enter']['as_new'] == TRUE ? insert_row($table, $cols, $bindargs) : update_row($table, $cols, $bindargs, substr($s_edit_where[$instance]['where'], 6));
         if (empty($ib_error)) {
             $success = TRUE;
             $s_enter_values = array();
             $s_watch_buffer = '';
             // cleanup the watchtable output buffer
             $s_watch_buffer = '';
         }
     }
 }
 $panels_arrayname = get_panel_array($_SERVER['SCRIPT_NAME']);
 if ($success || $job == 'cancel') {
     // remove the dt_edit panel
     $name = 'dt_edit' . $instance;
     $idx = get_panel_index(${$panels_arrayname}, $name);
     array_splice(${$panels_arrayname}, $idx, 1);
コード例 #11
0
ファイル: new.php プロジェクト: jcfischer/AvatarHotel
                        } else {
                            if ($table == 'Reserved_Rooms') {
                                $values = array('Reservied_Date' => array('type' => 'string', 'value' => params('Reservied_Date')), 'Customer_ID' => array('type' => 'number', 'value' => params('Customer_ID')), 'Rent_Rate' => array('type' => 'number', 'value' => params('Rent_Rate')));
                            } else {
                                if ($table == 'Room_Types') {
                                    $values = array('Desc_EN' => array('type' => 'string', 'value' => params('Desc_EN')));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    open_db();
    insert_row($table, $values);
    close_db();
    $posted = TRUE;
}
?>
          <?php 
if ($posted == FALSE) {
    ?>
          <?php 
    form_add($table);
    ?>
          <?php 
} else {
    ?>
          <p>
            Addition complete