Exemplo n.º 1
0
function get_basket($argument1, $argument2 = NULL)
{
    global $connection;
    // If we received two arguments, they are $member_id and $delivery_id
    if (is_numeric($argument1) && is_numeric($argument2)) {
        $query_where = 'WHERE
          member_id = "' . mysql_real_escape_string($argument1) . '"
          AND delivery_id = "' . mysql_real_escape_string($argument2) . '"';
    } elseif (is_numeric($argument1)) {
        $query_where = 'WHERE
          basket_id = "' . mysql_real_escape_string($argument1) . '"';
    }
    $basket_fields = array('basket_id', 'member_id', 'delivery_id', NEW_TABLE_BASKETS . '.site_id', 'site_short', 'site_long', NEW_TABLE_BASKETS . '.delivery_postal_code', NEW_TABLE_BASKETS . '.delivery_type', 'delivery_cost', 'order_cost', 'order_cost_type', 'customer_fee_percent', 'order_date', 'checked_out', 'locked');
    // Get the basket information...
    $query = '
      SELECT
        ' . implode(",\n        ", $basket_fields) . '
      FROM ' . NEW_TABLE_BASKETS . '
      LEFT JOIN ' . NEW_TABLE_SITES . ' USING(site_id)
      ' . $query_where;
    $result = mysql_query($query, $connection) or die(debug_print("ERROR: 892305 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row = mysql_fetch_array($result)) {
        return $row;
    } else {
        // Error... no basket found
        // die(debug_print('ERROR: 502 ', 'basket does not exist', basename(__FILE__).' LINE '.__LINE__));
    }
}
Exemplo n.º 2
0
function get_basket_item($argument1, $product_id = NULL, $delivery_id = NULL)
{
    global $connection;
    $selected_fields = array('bpid', 'basket_id', 'product_id', 'product_version', 'quantity', 'total_weight', NEW_TABLE_BASKET_ITEMS . '.product_fee_percent', NEW_TABLE_BASKET_ITEMS . '.subcategory_fee_percent', NEW_TABLE_BASKET_ITEMS . '.producer_fee_percent', 'taxable', 'out_of_stock', 'date_added', 'producer_id', 'product_name', 'product_description', 'subcategory_id', 'unit_price', 'pricing_unit', 'ordering_unit', 'random_weight', 'meat_weight_type', 'minimum_weight', 'maximum_weight', 'extra_charge', 'image_id', 'listing_auth_type', 'created', 'modified', 'tangible', 'sticky', 'storage_id', 'checked_out', 'message');
    if (is_numeric($argument1) && is_numeric($product_id) && is_numeric($delivery_id)) {
        $query_where = 'RIGHT JOIN ' . NEW_TABLE_BASKETS . ' USING (basket_id)
        WHERE
          member_id = "' . mysql_real_escape_string($argument1) . '"
          AND product_id = "' . mysql_real_escape_string($product_id) . '"
          AND delivery_id = "' . mysql_real_escape_string($delivery_id) . '"';
    } elseif (is_numeric($argument1) && is_numeric($product_id)) {
        $query_where = 'WHERE
          basket_id = "' . mysql_real_escape_string($argument1) . '"
          AND product_id = "' . mysql_real_escape_string($product_id) . '"';
    } elseif (is_numeric($argument1)) {
        $query_where = 'WHERE
          bpid = "' . mysql_real_escape_string($argument1) . '"';
    } else {
        die(debug_print('ERROR: 101 ', 'unexpected request', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    $query = '
      SELECT
        ' . implode(",\n        ", $selected_fields) . '
      FROM ' . NEW_TABLE_BASKET_ITEMS . '
      LEFT JOIN ' . NEW_TABLE_PRODUCTS . ' USING(product_id,product_version)
      LEFT JOIN ' . NEW_TABLE_MESSAGES . ' ON
        (' . NEW_TABLE_MESSAGES . '.message_type_id = 1
        AND ' . NEW_TABLE_BASKET_ITEMS . '.bpid = ' . NEW_TABLE_MESSAGES . '.referenced_key1)
      ' . $query_where;
    $result = mysql_query($query, $connection) or die(debug_print("ERROR: 799031 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row = mysql_fetch_array($result)) {
        return $row;
    }
}
Exemplo n.º 3
0
function execute($request)
{
    $language_info = api_autograder_get_language_info($request['path_parts'][1]);
    if ($language_info == null) {
        return build_response_not_found("Language not found.");
    }
    $language_key = $language_info['key'];
    $language_id = $language_info['language_id'];
    $problems = api_autograder_menu_get_problems($request['user_id'], 'practice', 0, $language_id);
    debug_print($problems);
    if ($problems['OK']) {
        $output = array('<h1>' . htmlspecialchars($language_info['name']) . ' Practice Problems</h1>');
        if (count($problems['ordered_problem_ids']) == 0) {
            array_push($output, "<div>Empty!</div>");
        }
        foreach ($problems['ordered_problem_ids'] as $problem_id) {
            $problem_info = $problems['problem_' . $problem_id];
            array_push($output, '<div><a href="/practice/' . $language_key . '/' . $problem_id . '">');
            array_push($output, htmlspecialchars($problem_info['title']));
            array_push($output, '</a></div>');
        }
        return build_response_ok($language_info['title'] . " Practice Problems", implode("\n", $output));
    } else {
        if ($problems['message'] == 'INVALID_LANGUAGE') {
            return build_response_not_found("Language not found.");
        }
    }
}
Exemplo n.º 4
0
 /**
  *
  * */
 public function later()
 {
     $this->useModel('later');
     $data = Request::post();
     $data['ipAddress'] = $_SERVER['REMOTE_ADDR'];
     $data['createdAt'] = date('Y-m-d H:i:s');
     $save = $this->model->later->saveData($data, true);
     debug_print($save, true);
 }
Exemplo n.º 5
0
function prdcr_contact_info($start, $half)
{
    global $connection;
    $query = '
      SELECT
        ' . TABLE_PRODUCER . '.producer_id,
        ' . TABLE_PRODUCER . '.business_name,
        ' . TABLE_PRODUCER . '.member_id,
        ' . TABLE_MEMBER . '.first_name,
        ' . TABLE_MEMBER . '.first_name,
        ' . TABLE_MEMBER . '.last_name,
        ' . TABLE_MEMBER . '.address_line1,
        ' . TABLE_MEMBER . '.address_line2,
        ' . TABLE_MEMBER . '.city,
        ' . TABLE_MEMBER . '.state,
        ' . TABLE_MEMBER . '.zip,
        ' . TABLE_PRODUCER . '.unlisted_producer
      FROM
        ' . TABLE_PRODUCER . ',
        ' . TABLE_MEMBER . '
      WHERE
        ' . TABLE_PRODUCER . '.member_id = ' . TABLE_MEMBER . '.member_id
        AND ' . TABLE_PRODUCER . '.unlisted_producer = "0"
        AND ' . TABLE_MEMBER . '.membership_discontinued != "1"
      ORDER BY
        ' . TABLE_PRODUCER . '.business_name ASC
      LIMIT ' . mysql_real_escape_string($start) . ', ' . mysql_real_escape_string($half);
    $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 869302 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    while ($row = mysql_fetch_array($result)) {
        $producer_id = $row['producer_id'];
        $business_name = $row['business_name'];
        $first_name = $row['first_name'];
        $last_name = $row['last_name'];
        $address_line1 = $row['address_line1'];
        $address_line2 = $row['address_line2'];
        $city = $row['city'];
        $state = $row['state'];
        $zip = $row['zip'];
        $display .= $business_name . '</b><br>';
        $display .= $first_name . ' ' . $last_name . '</b><br>';
        $display .= $address_line1 . '<br>';
        if ($address_line2) {
            $display .= $address_line2 . '<br>';
        }
        $display .= $city . ', ' . $state . ' ' . $zip . '<br>';
        $display .= '<br>';
    }
    return $display;
}
Exemplo n.º 6
0
function get_member($member_id)
{
    global $connection;
    // Expose additional parameters as they become needed.
    $selected_fields = array('pending', 'username', 'password', 'auth_type', 'business_name', 'preferred_name', 'membership_type_id', 'membership_date', 'last_renewal_date', 'membership_discontinued', 'mem_taxexempt', 'mem_delch_discount', 'notes', 'order_cost', 'order_cost_type');
    $query = '
      SELECT
        ' . implode(",\n        ", $selected_fields) . '
      FROM ' . TABLE_MEMBER . '
      LEFT JOIN ' . TABLE_MEMBERSHIP_TYPES . ' USING(membership_type_id)
      WHERE
        member_id = "' . mysql_real_escape_string($member_id) . '"';
    $result = mysql_query($query, $connection) or die(debug_print("ERROR: 740293 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row = mysql_fetch_array($result)) {
        return $row;
    }
}
Exemplo n.º 7
0
function get_producer($producer_id)
{
    // Expose additional parameters as they become needed.
    global $connection;
    $producer_fields = array('producer_id', 'producer_link', 'pending', 'member_id', 'business_name', 'producer_fee_percent', 'unlisted_producer', 'pub_address', 'pub_email', 'pub_email2', 'pub_phoneh', 'pub_phonew', 'pub_phonec', 'pub_phonet', 'pub_fax', 'pub_web');
    $query = '
      SELECT
        ' . implode(",\n        ", $producer_fields) . ',
        (SELECT GROUP_CONCAT(site_id)
         FROM ' . TABLE_AVAILABILITY . '
         WHERE producer_id = ' . TABLE_PRODUCER . '.producer_id) AS available_site_ids
      FROM ' . TABLE_PRODUCER . '
      WHERE producer_id = "' . mysql_real_escape_string($producer_id) . '"';
    $result = mysql_query($query, $connection) or die(debug_print("ERROR: 895053 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row = mysql_fetch_array($result)) {
        return $row;
    }
}
Exemplo n.º 8
0
function codesword_macd($real, $fastPeriod = 12, $slowPeriod = 26)
{
    $fastEma = codesword_ema($real, $fastPeriod);
    $slowEma = codesword_ema($real, $slowPeriod);
    $ctrFastOffset = 0;
    $macd = [];
    for ($i = 0; $i < count($slowEma); $i++) {
        if ($i == 0) {
            for ($j = 0; $j < $slowPeriod; $j++) {
                if ($fastEma[$j][0] == $slowEma[0][0]) {
                    $ctrFastOffset = $j;
                    debug_print("start of comparison: {$ctrFastOffset} <Br>");
                    break;
                }
            }
        }
        $macd[$i][0] = $slowEma[$i][0];
        $macd[$i][1] = $fastEma[$i + $ctrFastOffset][1] - $slowEma[$i][1];
    }
    // The signal is a 9-day EMA
    $signal = codesword_ema($macd, 9);
    $ctrMacdOffset = 0;
    $histogram = [];
    $macdFull = [];
    for ($i = 0; $i < count($signal); $i++) {
        if ($i == 0) {
            for ($j = 0; $j < $slowPeriod; $j++) {
                if ($macd[$j][0] == $signal[0][0]) {
                    $ctrMacdOffset = $j;
                    debug_print("start of comparison: {$ctrMacdOffset} <Br>");
                    break;
                }
            }
        }
        $histogram[$i][0] = $signal[$i][0];
        $histogram[$i][1] = $macd[$i + $ctrMacdOffset][1] - $signal[$i][1];
        $macdFull[$i][0] = $signal[$i][0];
        $macdFull[$i][1] = $macd[$i + $ctrMacdOffset][1];
        $macdFull[$i][2] = $signal[$i][1];
        $macdFull[$i][3] = $macd[$i + $ctrMacdOffset][1] - $signal[$i][1];
    }
    return $macdFull;
}
Exemplo n.º 9
0
function sql_query($query, $print = false)
{
    $db = sql_get_db();
    if ($print) {
        debug_print($query);
    }
    $start = microtime(true);
    $output = $db->query(trim($query));
    $end = microtime(true);
    $diff = $end - $start;
    sql_log_query($query, $end - $start);
    if ($db->errno == 0) {
        return $output;
    }
    echo '<div style="padding:8px; background-color:#f88; color:#400; font-weight:bold; font-size:12px; font-family: &quot;Courier New&quot;, monospace;">';
    echo htmlspecialchars($db->error);
    echo '<br /><br />';
    echo nl2br(str_replace(' ', '&nbsp;', htmlspecialchars($query)));
    echo '</div>';
    exit;
}
Exemplo n.º 10
0
function get_account_name($account_type, $account_key)
{
    global $connection;
    switch ($account_type) {
        case 'member':
            $query = '
          SELECT preferred_name AS name
          FROM ' . TABLE_MEMBER . '
          WHERE member_id = "' . mysql_real_escape_string($account_key) . '"';
            break;
        case 'producer':
            $query = '
          SELECT business_name AS name
          FROM ' . TABLE_PRODUCER . '
          WHERE producer_id = "' . mysql_real_escape_string($account_key) . '"';
            break;
        case 'tax':
            $query = '
          SELECT CONCAT_WS(" ", postal_code, region_name, region_type) AS name
          FROM ' . NEW_TABLE_TAX_RATES . '
          WHERE tax_id = "' . mysql_real_escape_string($account_key) . '"';
            break;
        case 'internal':
            $query = '
          SELECT description AS name
          FROM ' . NEW_TABLE_ACCOUNTS . '
          WHERE account_id = "' . mysql_real_escape_string($account_key) . '"';
            break;
    }
    $result = mysql_query($query, $connection) or die(debug_print("ERROR: 753093 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row = mysql_fetch_array($result)) {
        return $row['name'];
    } else {
        die(debug_print("ERROR: 786304 ", "Account {$account_type}::{$account_key} was not found", basename(__FILE__) . ' LINE ' . __LINE__));
    }
}
Exemplo n.º 11
0
 $tpl['data']['currency_name'] = $tpl['currency_list'][$tpl['data']['currency_id']];
 // проверим, не голосовали ли мы за это в последние 30 минут
 $repeated = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `id`\n\t\t\t\tFROM `" . DB_PREFIX . MY_PREFIX . "my_tasks`\n\t\t\t\tWHERE `type` = 'promised_amount' AND\n\t\t\t\t\t\t\t `id` = {$tpl['data']['id']} AND\n\t\t\t\t\t\t\t `time` > " . (time() - TASK_TIME) . "\n\t\t\t\t", 'fetch_one');
 //print '<!--'.$db->printsql()."\n".TASK_TIME."-->";
 if ($repeated) {
     //print '<!--repeated-->';
     require_once ABSPATH . 'templates/tasks.tpl';
     break;
 }
 // если нету видео на ютубе, то получаем host юзера, где брать видео
 if ($tpl['data']['video_url_id'] == 'null') {
     $tpl['data']['host'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `host`\n\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\tWHERE `user_id` = {$tpl['data']['user_id']}\n\t\t\t\tLIMIT 1\n\t\t\t\t", 'fetch_one');
 }
 // каждый раз обязательно проверяем, где находится юзер
 $tpl['data']['user_info'] = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `latitude`,\n\t\t\t\t\t\t\t `user_id`,\n\t\t\t\t\t\t\t `longitude`,\n\t\t\t\t\t\t\t `photo_block_id`,\n\t\t\t\t\t\t\t `photo_max_miner_id`,\n\t\t\t\t\t\t\t `miners_keepers`,\n\t\t\t\t\t\t\t `host`\n\t\t\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\t\t\tWHERE `user_id` = {$tpl['data']['user_id']}\n\t\t\t\tLIMIT 1\n\t\t\t\t", 'fetch_array');
 debug_print($tpl['data']['user_info'], __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
 // получим ID майнеров, у которых лежат фото нужного нам юзера
 /*$miners_ids = ParseData::get_miners_keepers($tpl['data']['user_info']['photo_block_id'], $tpl['data']['user_info']['photo_max_miner_id'],  $tpl['data']['user_info']['miners_keepers'], true);
 		debug_print($miners_ids, __FILE__, __LINE__,  __FUNCTION__,  __CLASS__, __METHOD__);
 		// берем 1 случайный из 10-и ID майнеров
 		$r = array_rand($miners_ids, 1);
 		$miner_id = $miners_ids[$r];
 		// получаем хост, где будем брать фото лица проверяемого нами майнера
 		$tpl['data']['miner_host'] = $db->query( __FILE__, __LINE__,  __FUNCTION__,  __CLASS__, __METHOD__, "
 				SELECT `host`
 				FROM `".DB_PREFIX."miners_data`
 				WHERE `miner_id` = {$miner_id}
 				", 'fetch_one' );*/
 // получим ID майнеров, у которых лежат фото нужного нам юзера
 $miners_ids = ParseData::get_miners_keepers($tpl['data']['user_info']['photo_block_id'], $tpl['data']['user_info']['photo_max_miner_id'], $tpl['data']['user_info']['miners_keepers'], true);
 if ($miners_ids) {
Exemplo n.º 12
0
$binary_tx = $aes->decrypt($encrypted_tx_set);
unset($aes);
debug_print('$binary_tx=' . $binary_tx, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
// разберем полученные тр-ии
do {
    $tx_size = ParseData::decode_length($binary_tx);
    $tx_binary_data = ParseData::string_shift($binary_tx, $tx_size);
    debug_print('$tx_binary_data=' . $tx_binary_data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    list(, $tx_hex) = unpack("H*", $tx_binary_data);
    if (!$tx_binary_data) {
        continue;
    }
    // проверим размер
    if (strlen($tx_binary_data) > $variables['max_tx_size']) {
        debug_print('strlen($binary_tx) > $variables[max_tx_size]', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        die("error tx size");
    }
    // точно ли выдали то
    /*if ( md5($tx_binary_data) != $new_data['tx_hash'] ) {
    		debug_print("error tx_hash (".md5($tx_binary_data)."!={$new_data['tx_hash']})", __FILE__, __LINE__,  __FUNCTION__,  __CLASS__, __METHOD__);
    		die ("error tx_hash (".md5($tx_binary_data)."!={$new_data['tx_hash']})");
    	}*/
    // временно для тестов
    $new_data['high_rate'] = 0;
    $tx_hash = md5($tx_binary_data);
    // заливаем тр-ию в БД
    $file = save_tmp_644('FTB', "{$tx_hash}\t{$new_data['high_rate']}\t{$tx_hex}");
    debug_print("hash={$tx_hash}\ndata={$tx_hex}", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tLOAD DATA LOCAL INFILE  '{$file}'\n\t\t\tIGNORE INTO TABLE `" . DB_PREFIX . "queue_tx`\n\t\t\tFIELDS TERMINATED BY '\t'\n\t\t\t(@hash, `high_rate`, @data)\n\t\t\tSET  `hash` = UNHEX(@hash),\n\t\t\t\t    `data` = UNHEX(@data)\n\t\t\t");
    unlink($file);
} while ($binary_tx);
Exemplo n.º 13
0
function open_basket(array $data)
{
    global $connection;
    // Expose additional parameters as they become needed. Call with:
    $basket_fields = array('basket_id', 'member_id', 'delivery_id', 'site_id', 'delivery_type', 'delivery_postal_code', 'delivery_cost', 'order_cost', 'order_cost_type', 'customer_fee_percent', 'order_date', 'checked_out', 'locked');
    // At a minimum, we need to know the member_id and the delivery_id
    if (!$data['member_id'] || !$data['delivery_id']) {
        die(debug_print('ERROR: 504 ', 'call to create basket without all parameters', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    // See if a basket already exists
    $query_basket_info = '
      SELECT
        ' . implode(",\n        ", $basket_fields) . '
      FROM ' . NEW_TABLE_BASKETS . '
      WHERE
        member_id = "' . mysql_real_escape_string($data['member_id']) . '"
        AND delivery_id = "' . mysql_real_escape_string($data['delivery_id']) . '"';
    $result_basket_info = mysql_query($query_basket_info, $connection) or die(debug_print("ERROR: 892122 ", array($query_basket_info, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row_basket_info = mysql_fetch_array($result_basket_info)) {
        // Done with nothing to do. Return the information...
        return $row_basket_info;
    }
    // Now we need site_id and delivery_type. If we already have them, good. Otherwise make a best-guess
    if (!$data['site_id']) {
        // See what site_id this member used prior to the target delivery_id
        $query_site_guess = '
          SELECT
            ' . NEW_TABLE_BASKETS . '.site_id,
            ' . NEW_TABLE_BASKETS . '.delivery_type
          FROM ' . NEW_TABLE_BASKETS . '
          LEFT JOIN ' . NEW_TABLE_SITES . ' USING(site_id)
          WHERE
            ' . NEW_TABLE_BASKETS . '.delivery_id < "' . mysql_real_escape_string($data['delivery_id']) . '"
            AND ' . NEW_TABLE_BASKETS . '.member_id = "' . mysql_real_escape_string($data['member_id']) . '"
            AND ' . NEW_TABLE_SITES . '.inactive = 0
            AND ' . NEW_TABLE_SITES . '.site_type = "customer"
          ORDER BY ' . NEW_TABLE_BASKETS . '.delivery_id DESC
          LIMIT 1';
        $result_site_guess = mysql_query($query_site_guess, $connection) or die(debug_print("ERROR: 902524 ", array($query_site_guess, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
        // If we get a result back, then we will use it
        if ($row_site_guess = mysql_fetch_array($result_site_guess)) {
            $data['site_id'] = $row_site_guess['site_id'];
            // If we already have a delivery_type value, then do not clobber it
            if (!$data['delivery_type']) {
                $data['delivery_type'] = $row_site_guess['delivery_type'];
            }
            $data['site_selection'] = 'revert';
        } else {
            // We could try some other things to make successively poor guesses, but for now
            // this will be the end of the line
            $data['site_selection'] = 'unset';
            return $data;
            // die(debug_print('ERROR: 505 ', 'create basket with no remaining good guesses', basename(__FILE__).' LINE '.__LINE__));
        }
    }
    // Get additional basket data for opening this basket
    $query_basket_data = '
      SELECT
        ' . NEW_TABLE_SITES . '.delivery_postal_code,
        ' . NEW_TABLE_SITES . '.delivery_charge AS delivery_cost,
        ' . NEW_TABLE_SITES . '.site_long,
        ' . TABLE_MEMBERSHIP_TYPES . '.order_cost,
        ' . TABLE_MEMBERSHIP_TYPES . '.order_cost_type,
        ' . TABLE_MEMBER . '.customer_fee_percent,
        ' . TABLE_MEMBER . '.zip AS home_zip,
        ' . TABLE_MEMBER . '.work_zip
      FROM ' . NEW_TABLE_SITES . '
      INNER JOIN ' . TABLE_MEMBER . '
      LEFT JOIN ' . TABLE_MEMBERSHIP_TYPES . ' USING(membership_type_id)
      WHERE
        ' . NEW_TABLE_SITES . '.site_id = "' . mysql_real_escape_string($data['site_id']) . '"
        AND ' . TABLE_MEMBER . '.member_id = "' . mysql_real_escape_string($data['member_id']) . '"';
    $result_basket_data = mysql_query($query_basket_data, $connection) or die(debug_print("ERROR: 983134 ", array($query_basket_data, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row_basket_data = mysql_fetch_array($result_basket_data)) {
        $data['delivery_postal_code'] = $row_basket_data['delivery_postal_code'];
        $data['delivery_cost'] = $row_basket_data['delivery_cost'];
        $data['order_cost'] = $row_basket_data['order_cost'];
        $data['order_cost_type'] = $row_basket_data['order_cost_type'];
        $data['customer_fee_percent'] = $row_basket_data['customer_fee_percent'];
        $data['site_long'] = $row_basket_data['site_long'];
        $home_zip = $row_basket_data['home_zip'];
        $work_zip = $row_basket_data['work_zip'];
    } else {
        die(debug_print('ERROR: 506 ', 'create basket failure to gather information', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    // If the delivery is not 'P' (pickup) then set the clobber $delivery_postal_code with the correct value
    if ($data['delivery_type'] == 'H') {
        $data['delivery_postal_code'] = $home_zip;
    } elseif ($data['delivery_type'] == 'W') {
        $data['delivery_postal_code'] = $work_zip;
    } elseif ($data['delivery_type'] != 'P') {
        die(debug_print('ERROR: 507 ', 'create basket invalid delivery_type', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    // Check if there is a delivery_postal code provided This should possibly check against
    // the tax_rates table to see that the postal code is included there...?
    if (!$data['delivery_postal_code']) {
        die(debug_print('ERROR: 508 ', 'create basket invalid delivery_postal_code', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    // Now open a basket with the provided (or guessed) information
    $query_open_basket = '
    INSERT INTO ' . NEW_TABLE_BASKETS . '
    SET
      /*basket_id (auto_increment )*/
      member_id = "' . mysql_real_escape_string($data['member_id']) . '",
      delivery_id = "' . mysql_real_escape_string($data['delivery_id']) . '",
      site_id = "' . mysql_real_escape_string($data['site_id']) . '",
      delivery_type = "' . mysql_real_escape_string($data['delivery_type']) . '",
      delivery_postal_code = "' . mysql_real_escape_string($data['delivery_postal_code']) . '",
      delivery_cost = "' . mysql_real_escape_string($data['delivery_cost']) . '",
      order_cost = "' . mysql_real_escape_string($data['order_cost']) . '",
      order_cost_type = "' . mysql_real_escape_string($data['order_cost_type']) . '",
      customer_fee_percent = "' . mysql_real_escape_string($data['customer_fee_percent']) . '",
      /*order_date (timestamp) */
      checked_out = "0",
      locked = "0"';
    $result_open_basket = mysql_query($query_open_basket, $connection) or die(debug_print("ERROR: 895237 ", array($query_basket_data, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    $data['basket_id'] = mysql_insert_id();
    $data['checked_out'] = 0;
    // Manually set rather than queried
    $data['locked'] = 0;
    // Manually set rather than queried
    $data['order_date'] = date("Y-m-d H:i:s");
    // Approximate, since it did not come from the database
    return $data;
}
Exemplo n.º 14
0
    // для тестов получим что там есть
    $tmp_testblock_data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tSELECT *\n\t\t\tFROM `" . DB_PREFIX . "testblock`\n\t\t\t", 'fetch_array');
    debug_print($tmp_testblock_data, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    debug_print("LOAD DATA LOCAL INFILE  '{$file}' REPLACE INTO TABLE `" . DB_PREFIX . "testblock`", __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    // т.к. эти данные создали мы сами, то пишем их сразу в таблицу проверенных данных, которые будут отправлены другим нодам
    $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\tLOAD DATA LOCAL INFILE  '{$file}' REPLACE INTO TABLE `" . DB_PREFIX . "testblock`\n\t\t\tFIELDS TERMINATED BY '\t'\n\t\t\t(`block_id`,`time`,`level`,`user_id`, @header_hash, @signature, @mrkl_root)\n\t\t\tSET `header_hash` = UNHEX(@header_hash),\n\t\t\t\t   `signature` = UNHEX(@signature),\n\t\t\t\t   `mrkl_root` = UNHEX(@mrkl_root)\n\t\t\t");
    unlink($file);
    // иногда не вставлялось, т.к. уже что-то было в testblock . добавил REPLACE
    debug_print('AffectedRows=' . $db->getAffectedRows(), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    /// #######################################
    // Отмечаем транзакции, которые попали в transactions_testblock
    // Пока для эксперимента
    // если не отмечать, то получается, что и в transactions_testblock и в transactions будут провернные тр-ии, которые откатятся дважды
    if ($used_transactions) {
        $used_transactions = substr($used_transactions, 0, -1);
        $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tUPDATE `" . DB_PREFIX . "transactions`\n\t\t\t\tSET `used`=1\n\t\t\t\tWHERE `hash` IN ({$used_transactions})\n\t\t\t\t");
        // для теста тупо удаляем, т.к. она уже есть в transactions_testblock
        /*  $db->query( __FILE__, __LINE__,  __FUNCTION__,  __CLASS__, __METHOD__, "
        				DELETE FROM `".DB_PREFIX."transactions`
        				WHERE `hash` IN ({$used_transactions})
        				");*/
    }
    // ############################################
    main_unlock();
    debug_print('end<<<<<<<<<<<<<<<<<<<<<<<', __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
    unset($testBlock, $data, $for_sign, $mrkl_root_binary, $mrkl_root, $mrkl_array, $data_hex, $row, $transactions);
    //ob_save();
    sleep(1);
    // временно
    //exit;
} while (true);
Exemplo n.º 15
0
            debug_print($urls, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
            $rez = m_curl($urls, $to_be_sent, $db, 'data', 20, true);
            debug_print($rez, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        }
    } else {
        // если просто юзер или работаю в защищенном режиме, то шлю тр-ии целиком. слать блоки не имею права.
        if ($my_config['local_gate_ip']) {
            $gate = 'protected_gate_tx.php';
            // Чтобы protected_gate_tx.php мог понять, какому ноду слать эту тр-ию, пишем в первые 100 байт host
            $remote_node_host = $node_data['host'];
        } else {
            $gate = 'gate_tx.php';
            $remote_node_host = '';
        }
        for ($i = 0; $i < sizeof($hosts); $i++) {
            $urls[$i] = array('url' => $hosts[$i]['host'] . $gate, 'node_public_key' => $hosts[$i]['node_public_key'], 'user_id' => $hosts[$i]['user_id']);
        }
        debug_print($urls, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        // возьмем хэши и сами тр-ии
        $tx_data = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\tSELECT `hash`, `data`\n\t\t\t\tFROM `" . DB_PREFIX . "transactions`\n\t\t\t\tWHERE `sent` = 0\n\t\t\t\t", 'fetch_array');
        debug_print('$tx_data: ' . print_r_hex($tx_data), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        if ($tx_data['hash']) {
            $hex_hash = bin2hex($tx_data['hash']);
            $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\t\t\t\tUPDATE `" . DB_PREFIX . "transactions`\n\t\t\t\t\tSET `sent` = 1\n\t\t\t\t\tWHERE `hash` = 0x{$hex_hash}\n\t\t\t\t\t");
            // в первые 5 байт tx_data['data'] m_curl допишет user_id получателя, если вдруг там пул
            $rez = m_curl($urls, $tx_data['data'], $db, 'data', 20, true, true, $remote_node_host);
            debug_print($rez, __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
        }
    }
    sleep(1);
}
Exemplo n.º 16
0
 $fax = $row['fax'];
 $membership_date = $row['membership_date'];
 $member_type = $row['membership_class'];
 $preferred_name = $row['preferred_name'];
 $basket_id = '';
 $sql2 = '
   SELECT
     ' . NEW_TABLE_BASKETS . '.member_id,
     ' . NEW_TABLE_BASKETS . '.delivery_id,
     ' . NEW_TABLE_BASKETS . '.basket_id
   FROM
     ' . NEW_TABLE_BASKETS . '
   WHERE
     ' . NEW_TABLE_BASKETS . '.member_id = "' . mysql_real_escape_string($member_id) . '"
     AND ' . NEW_TABLE_BASKETS . '.delivery_id = "' . mysql_real_escape_string($delivery_id) . '"';
 $rs2 = @mysql_query($sql2, $connection) or die(debug_print("ERROR: 785033 ", array($sql2, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
 $num2 = mysql_numrows($rs2);
 while ($row = mysql_fetch_array($rs2)) {
     $basket_id = $row['basket_id'];
 }
 $display .= 'Member ID: ' . $member_id . ' (' . $member_type . ')<br>';
 $display .= 'Membership Date: ' . $membership_date . '<br>';
 $display .= '<b>' . $preferred_name . '</b><br>';
 $display .= $address_line1 . '<br>';
 if ($address_line2) {
     $display .= $address_line2 . '<br>';
 }
 $display .= "{$city}, {$state} {$zip}<br>";
 if ($email_address) {
     $display .= '<a href="mailto:' . $email_address . '">' . $email_address . '</a><br>';
 }
Exemplo n.º 17
0
function debug_post()
{
    debug_print(serialize($_POST));
}
Exemplo n.º 18
0
function open_update_basket(array $data)
{
    global $connection;
    // Expose additional parameters as they become needed. Call with:
    $basket_fields = array('basket_id', 'member_id', 'delivery_id', 'site_id', 'delivery_type', 'delivery_postal_code', 'delivery_cost', 'order_cost', 'order_cost_type', 'customer_fee_percent', 'order_date', 'checked_out', 'locked');
    // At a minimum, we need to know the member_id and the delivery_id
    if (!$data['member_id'] || !$data['delivery_id']) {
        die(debug_print('ERROR: 504 ', 'call to create basket without all parameters', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    // See if a basket already exists
    $query_basket_info = '
      SELECT
        ' . implode(",\n        ", $basket_fields) . '
      FROM ' . NEW_TABLE_BASKETS . '
      WHERE
        member_id = "' . mysql_real_escape_string($data['member_id']) . '"
        AND delivery_id = "' . mysql_real_escape_string($data['delivery_id']) . '"';
    $result_basket_info = mysql_query($query_basket_info, $connection) or die(debug_print("ERROR: 892122 ", array($query_basket_info, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row_basket_info = mysql_fetch_array($result_basket_info)) {
        // If site_id or delivery_type are set and same as existing values (then we are done)...
        if ((!$data['site_id'] || $data['site_id'] == $row_basket_info['site_id']) && (!$data['delivery_type'] || $data['delivery_type'] == $row_basket_info['delivery_type'])) {
            // Done with nothing to do. Return the information...
            return $row_basket_info;
        } elseif ($row_basket_info['basket_id']) {
            $data['basket_id'] = $row_basket_info['basket_id'];
            // Change in an existing basket means we need to re-checkout to catch
            // things like taxes and changed delivery fees
            $initiate_checkout = true;
        }
    }
    // See if we are missing either site_id or delivery_type. If not, make a best-guess from the person's prior order
    if (!$data['site_id'] || !$data['delivery_type']) {
        // See what site_id this member used prior to the target delivery_id
        $query_site_guess = '
          SELECT
            site_id,
            delivery_type
          FROM ' . NEW_TABLE_BASKETS . '
          WHERE
            delivery_id < "' . mysql_real_escape_string($data['delivery_id']) . '"
            AND member_id = "' . mysql_real_escape_string($data['member_id']) . '"
            AND inactive = "0"
          ORDER BY delivery_id DESC
          LIMIT 1';
        $result_site_guess = mysql_query($query_site_guess, $connection) or die(debug_print("ERROR: 902524 ", array($query_site_guess, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
        // If we get a result back, then we will use it
        if ($row_site_guess = mysql_fetch_array($result_site_guess)) {
            $data['site_id'] = $row_site_guess['site_id'];
            // If we already have a delivery_type value, then do not clobber it
            if (!$data['delivery_type']) {
                $data['delivery_type'] = $row_site_guess['delivery_type'];
            }
        } else {
            // we will allow creation of a non-homed cart because it will be caught at checkout
            // so set some "blank" default values
            $data['site_id'] = '';
            $data['delivery_type'] = 'P';
            $basket_adrift = true;
        }
    }
    // Get additional basket data for opening this basket
    $query_basket_data = '
      SELECT
        ' . NEW_TABLE_SITES . '.delivery_postal_code,
        ' . NEW_TABLE_SITES . '.delivery_charge AS delivery_cost,
        ' . TABLE_MEMBERSHIP_TYPES . '.order_cost,
        ' . TABLE_MEMBERSHIP_TYPES . '.order_cost_type,
        ' . TABLE_MEMBER . '.customer_fee_percent,
        ' . TABLE_MEMBER . '.zip AS home_zip,
        ' . TABLE_MEMBER . '.work_zip
      FROM ' . NEW_TABLE_SITES . '
      INNER JOIN ' . TABLE_MEMBER . '
      LEFT JOIN ' . TABLE_MEMBERSHIP_TYPES . ' USING(membership_type_id)
      WHERE
        ' . NEW_TABLE_SITES . '.site_id = "' . mysql_real_escape_string($data['site_id']) . '"
        AND ' . TABLE_MEMBER . '.member_id = "' . mysql_real_escape_string($data['member_id']) . '"';
    $result_basket_data = mysql_query($query_basket_data, $connection) or die(debug_print("ERROR: 983134 ", array($query_basket_data, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    if ($row_basket_data = mysql_fetch_array($result_basket_data)) {
        $data['delivery_postal_code'] = $row_basket_data['delivery_postal_code'];
        $data['delivery_cost'] = $row_basket_data['delivery_cost'];
        $data['order_cost'] = $row_basket_data['order_cost'];
        $data['order_cost_type'] = $row_basket_data['order_cost_type'];
        $data['customer_fee_percent'] = $row_basket_data['customer_fee_percent'];
        $home_zip = $row_basket_data['home_zip'];
        $work_zip = $row_basket_data['work_zip'];
    } else {
        // Since we allow creation of carts without assigned delivery_codes, set some "blank" default values
        $data['delivery_postal_code'] = '';
        $data['delivery_cost'] = '';
        $data['order_cost'] = '';
        $data['order_cost_type'] = '';
        $data['customer_fee_percent'] = '';
        $data['order_date'] = date('Y-m-d H:i:s', time());
        $data['checked_out'] = '0';
        $data['locked'] = '0';
    }
    // If the delivery is not 'P' (pickup) then set the clobber $delivery_postal_code with the correct value
    if ($data['delivery_type'] == 'H') {
        $data['delivery_postal_code'] = $home_zip;
    } elseif ($data['delivery_type'] == 'W') {
        $data['delivery_postal_code'] = $work_zip;
    }
    // Check if there is a delivery_postal code provided This should possibly check against
    // the tax_rates table to see that the postal code is included there...?
    if (!$data['delivery_postal_code']) {
        die(debug_print('ERROR: 508 ', 'Requested basket has invalid delivery_postal_code', basename(__FILE__) . ' LINE ' . __LINE__));
    }
    // Now open a basket with the provided (or guessed) information
    $query_open_basket = '
    REPLACE INTO ' . NEW_TABLE_BASKETS . '
    SET' . ($data['basket_id'] ? '
      basket_id = "' . mysql_real_escape_string($data['basket_id']) . '",' : '') . ' /* basket_id OR auto_increment */
      member_id = "' . mysql_real_escape_string($data['member_id']) . '",
      delivery_id = "' . mysql_real_escape_string($data['delivery_id']) . '",
      site_id = "' . mysql_real_escape_string($data['site_id']) . '",
      delivery_type = "' . mysql_real_escape_string($data['delivery_type']) . '",
      delivery_postal_code = "' . mysql_real_escape_string($data['delivery_postal_code']) . '",
      delivery_cost = "' . mysql_real_escape_string($data['delivery_cost']) . '",
      order_cost = "' . mysql_real_escape_string($data['order_cost']) . '",
      order_cost_type = "' . mysql_real_escape_string($data['order_cost_type']) . '",
      customer_fee_percent = "' . mysql_real_escape_string($data['customer_fee_percent']) . '",
      order_date = "' . mysql_real_escape_string($data['order_date']) . '",
      checked_out = "' . mysql_real_escape_string($data['checked_out']) . '",
      locked = "' . mysql_real_escape_string($data['locked']) . '"';
    $result_open_basket = mysql_query($query_open_basket, $connection) or die(debug_print("ERROR: 895237 ", array($query_open_basket, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    $data['basket_id'] = mysql_insert_id();
    // Now do a re-checkout if necessary
    if ($initiate_checkout == true) {
        $basket_info = update_basket(array('action' => 'synch_ledger_items', 'basket_id ' => $data['basket_id'], 'delivery_id' => $data['delivery_id'], 'member_id' => $data['member_id'], 'site_id' => $data['site_id'], 'delivery_type' => $data['delivery_type']));
        // Replace any information in the $data array with info returned from update_basket()
        foreach (array_keys($basket_info) as $key) {
            $data[$key] = $basket_info[$key];
        }
    }
    return $data;
}
Exemplo n.º 19
0
      <dt>' . $row->prodtype . '</dt>
      <dd>' . $row->proddesc . '</dd>';
    $product_types_options .= '
      <option value="' . $row->production_type_id . '"' . $selected . '>' . $row->prodtype . '</option>';
}
// Generate the storage_types_options and create a drop-down list
$storage_types_options = '<option value="">Choose One</option>';
$query = '
  SELECT
    storage_id,
    storage_type
  FROM
    ' . TABLE_PRODUCT_STORAGE_TYPES . '
    ORDER BY
        storage_type';
$sql = @mysql_query($query, $connection) or die(debug_print("ERROR: 616609 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
while ($row = mysql_fetch_object($sql)) {
    $selected = '';
    if ($product_info['storage_id'] == $row->storage_id) {
        $selected = ' selected';
    }
    $store_types_display .= '
            <dt>' . $row->storage_type . '</dt>';
    $storage_types_options .= '
            <option value="' . $row->storage_id . '"' . $selected . '>' . $row->storage_type . '</option>';
}
// Generate the meat_weight_type and create a drop-down list
if ($product_info['meat_weight_type']) {
    $meat_first = '
      <option value="' . $product_info['meat_weight_type'] . '">' . $product_info['meat_weight_type'] . '</option>';
    $display_meat .= '
Exemplo n.º 20
0
function receive_payments_detail($argument)
{
    global $connection;
    switch ($argument['request']) {
        // BASKET TOTAL AND PAYMENTS ******************************************************
        case 'basket_total_and_payments':
            $non_payment_total = 0;
            $non_payment_count = 0;
            $payment_total = 0;
            $payment_count = 0;
            $query = '
            SELECT
              text_key,
              SUM(amount) AS total,
              COUNT(amount) AS count
            FROM ' . NEW_TABLE_LEDGER . '
            WHERE
              basket_id = "' . mysql_real_escape_string($argument['basket_id']) . '"
              AND (source_type = "member"
                OR target_type = "member")
              AND replaced_by IS NULL
            GROUP BY
              text_key';
            $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 768933 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
            while ($row = mysql_fetch_array($result)) {
                // Is this a payment -- something we want to show explicitly?
                if ($row['text_key'] == 'payment received') {
                    $payment_total = $row['total'];
                    $payment_count = $row['count'];
                } else {
                    $non_payment_total += $row['total'];
                    $non_payment_count += $row['count'];
                    $non_payment_text_key = $row['text_key'];
                }
            }
            // We return (possibly) two rows...
            // The "everything else" row
            if ($non_payment_count == 0) {
            } elseif ($non_payment_count == 1) {
                $return_data = '
            <div id="non_payment' . $argument['basket_id'] . '" class="data_row">
              <span id="non_payment' . $argument['basket_id'] . '" class="description">' . $non_payment_text_key . '</span>
              <span class="total">' . number_format($non_payment_total, 2) . '</span>
            </div>';
            } else {
                // non_payment_count > 1
                $return_data = '
            <div id="non_payment' . $argument['basket_id'] . '" class="data_row">
              <span class="description">summary total</span>
              <span class="total">' . number_format($non_payment_total, 2) . '</span>
            </div>';
            }
            // Now the "payments" row
            if ($payment_count == 0) {
            } elseif ($payment_count == 1) {
                $return_data .= '
            <div id="payment' . $argument['basket_id'] . '" class="data_row">
              <span id="payment' . $argument['basket_id'] . '" class="description">payment</span>
              <span class="total">' . number_format($payment_total, 2) . '</span>
            </div>';
            } else {
                // payment_count > 1
                $return_data .= '
            <div id="payment' . $argument['basket_id'] . '" class="data_row">
              <span class="description">payment total</span>
              <span class="total">' . number_format($payment_total, 2) . '</span>
            </div>';
            }
            return $return_data;
            break;
            // BASKET TOTAL ONLY ******************************************************
        // BASKET TOTAL ONLY ******************************************************
        case 'basket_total_only':
            break;
            // BASKET TOTAL ONLY ******************************************************
        // BASKET TOTAL ONLY ******************************************************
        case 'basket_summary':
            break;
    }
}
Exemplo n.º 21
0
// наш последний блок-1
$block_id = get_block_id($db) - 1;
if ($block_id < 1) {
    exit;
}
$hash = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `hash`\n\t\tFROM `" . DB_PREFIX . "block_chain`\n\t\tWHERE `id`= {$block_id}\n\t\t", 'fetch_one');
$res = $db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tSELECT `host`,\n\t\t\t\t\t `user_id`\n\t\tFROM `" . DB_PREFIX . "miners_data`\n\t\tWHERE `miner_id`> 0\n\t\tGROUP BY `host`\n\t\tORDER BY RAND()\n\t\tLIMIT " . COUNT_CONFIRMED_NODES . "\n\t\t");
$i = 0;
$urls = array();
while ($row = $db->fetchArray($res)) {
    $urls[$i]['url'] = $row['host'] . 'tools/check_node.php?block_id=' . $block_id;
    $urls[$i]['user_id'] = $row['user_id'];
    $i++;
}
if (empty($urls)) {
    exit;
}
print_R($urls);
$result = m_curl($urls, '', '', '', 10, true, false);
debug_print("result=" . print_r_hex($result), __FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__);
print_R($result);
$status[0] = 0;
$status[1] = 0;
foreach ($result as $user_id => $answer) {
    if ($answer != $hash) {
        $status[0]++;
    } else {
        $status[1]++;
    }
}
$db->query(__FILE__, __LINE__, __FUNCTION__, __CLASS__, __METHOD__, "\n\t\tINSERT INTO `" . DB_PREFIX . "confirmations` (\n\t\t\t`block_id`,\n\t\t\t`good`,\n\t\t\t`bad`,\n\t\t\t`time`\n\t\t)\n\t\tVALUES (\n\t\t\t{$block_id},\n\t\t\t" . intval($status[1]) . ",\n\t\t\t" . intval($status[0]) . ",\n\t\t\t" . time() . "\n\t\t)\n\t\tON DUPLICATE KEY UPDATE  `good` = {$status[1]}, `bad` = {$status[0]}, `time` = " . time() . "\n\t\t");
Exemplo n.º 22
0
function prdcr_contact_info($start, $half)
{
    global $connection;
    $sqlp = '
      SELECT
        ' . TABLE_PRODUCER . '.producer_id,
        ' . TABLE_PRODUCER . '.member_id,
        ' . TABLE_PRODUCER . '.business_name,
        ' . TABLE_MEMBER . '.first_name,
        ' . TABLE_MEMBER . '.first_name,
        ' . TABLE_MEMBER . '.last_name,
        ' . TABLE_MEMBER . '.address_line1,
        ' . TABLE_MEMBER . '.address_line2,
        ' . TABLE_MEMBER . '.city,
        ' . TABLE_MEMBER . '.state,
        ' . TABLE_MEMBER . '.zip,
        ' . TABLE_MEMBER . '.email_address,
        ' . TABLE_MEMBER . '.email_address_2,
        ' . TABLE_MEMBER . '.home_phone,
        ' . TABLE_MEMBER . '.work_phone,
        ' . TABLE_MEMBER . '.mobile_phone,
        ' . TABLE_MEMBER . '.fax,
        ' . TABLE_MEMBER . '.toll_free,
        ' . TABLE_MEMBER . '.home_page,
        ' . TABLE_MEMBER . '.membership_date,
        ' . TABLE_PRODUCER . '.unlisted_producer
      FROM
        ' . TABLE_PRODUCER . '
      LEFT JOIN
        ' . TABLE_MEMBER . ' ON ' . TABLE_MEMBER . '.member_id = ' . TABLE_PRODUCER . '.member_id
      WHERE
        ' . TABLE_PRODUCER . '.unlisted_producer != 2
        AND ' . TABLE_MEMBER . '.membership_discontinued != 1
      ORDER BY
        ' . TABLE_PRODUCER . '.business_name ASC
      LIMIT ' . mysql_real_escape_string($start) . ', ' . mysql_real_escape_string($half) . '';
    $resultp = @mysql_query($sqlp, $connection) or die(debug_print("ERROR: 572929 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    while ($row = mysql_fetch_array($resultp)) {
        $producer_id = $row['producer_id'];
        $business_name = $row['business_name'];
        $unlisted_producer = $row['unlisted_producer'];
        $first_name = $row['first_name'];
        $last_name = $row['last_name'];
        $address_line1 = $row['address_line1'];
        $address_line2 = $row['address_line2'];
        $city = $row['city'];
        $state = $row['state'];
        $zip = $row['zip'];
        $email_address = $row['email_address'];
        $email_address_2 = $row['email_address_2'];
        $home_phone = $row['home_phone'];
        $work_phone = $row['work_phone'];
        $mobile_phone = $row['mobile_phone'];
        $fax = $row['fax'];
        $toll_free = $row['toll_free'];
        $home_page = $row['home_page'];
        $membership_date = $row['membership_date'];
        $display .= '<div class="' . ($unlisted_producer == 0 ? 'listed' : 'unlisted') . '">';
        $display .= $business_name . '<br />';
        $display .= $first_name . ' ' . $last_name . '<br />';
        $display .= $address_line1 . '<br />';
        if ($address_line2) {
            $display .= $address_line2 . '<br />';
        }
        $display .= $city . ', ' . $state . ' ' . $zip . '<br />';
        if ($email_address) {
            $display .= '<a href="mailto:' . $email_address . '">' . $email_address . '</a><br />';
        }
        if ($email_address_2) {
            $display .= '<a href="mailto:' . $email_address_2 . '">' . $email_address_2 . '</a><br />';
        }
        if ($home_phone) {
            $display .= $home_phone . ' (home)<br />';
        }
        if ($work_phone) {
            $display .= $work_phone . ' (work)<br />';
        }
        if ($mobile_phone) {
            $display .= $mobile_phone . ' (cell)<br />';
        }
        if ($fax) {
            $display .= $fax . ' (fax)<br />';
        }
        if ($toll_free) {
            $display .= $toll_free . ' (toll free)<br />';
        }
        if ($home_page) {
            $display .= $home_page . '<br />';
        }
        $year = substr($membership_date, 0, 4);
        $month = substr($membership_date, 5, 2);
        $day = substr($membership_date, 8);
        $member_since = date('F j, Y', mktime(0, 0, 0, $month, $day, $year));
        $display .= 'Member since ' . $member_since . '<br />';
        $display .= '<br /></div>';
    }
    return $display;
}
Exemplo n.º 23
0
function debug($text, $level = "pinp", $stream = "all", $indent = "")
{
    global $DB, $DB_INDENT;
    if (!isset($DB[$level])) {
        $level = "pinp";
    }
    if ($DB["level"] >= $DB[$level] && ($DB["stream"] == "all" || $DB["stream"] == $stream)) {
        /* format the message */
        $message = "[" . $level . "][" . $stream . "] " . $text;
        $timestamping = date("H:i:s");
        /* handle indentation */
        if ($indent == "OUT") {
            $DB_INDENT = substr($DB_INDENT, 0, -2);
        }
        if ($indent == "IN") {
            $DB_INDENT .= "  ";
        }
        if ($DB["method"]["file"] && $DB["fp"]) {
            @fwrite($DB["fp"], "(" . $timestamping . ")" . $DB_INDENT . $message . "\n");
            @fflush($DB["fp"]);
        }
        /* Check if we're debugging to the loader debug_print function and
        			   the loader is capable of debugging.
        			*/
        if ($DB["method"]["loader"] && function_exists("debug_print")) {
            debug_print("(" . $timestamping . ")" . $DB_INDENT . $message . "\n");
        }
        if ($DB["method"]["syslog"]) {
            syslog(LOG_NOTICE, "(Ariadne) " . $DB_INDENT . $message);
        }
        if ($DB["method"]["firebug"]) {
            ar('beta/firebug')->log($text, "[" . $level . "][" . $stream . "]");
        }
    }
}
Exemplo n.º 24
0
function add_transaction_messages($transaction_id, $messages)
{
    // debug_print ("INFO: 6 ", array ($transaction_id, $messages), basename(__FILE__).' LINE '.__LINE__);
    global $connection;
    // Are there any messages to add?
    if (is_array($messages)) {
        $count = 0;
        foreach ($messages as $message_type => $message) {
            // If there is a message, then add the message or replace an existing one
            if (strlen($message) > 0) {
                // Use [0]:orphaned message in case the description is not found
                $query = '
                  REPLACE INTO ' . NEW_TABLE_MESSAGES . '
                  SET
                    message = "' . mysql_real_escape_string($message) . '",
                    message_type_id = 
                      COALESCE((
                        SELECT message_type_id
                        FROM ' . NEW_TABLE_MESSAGE_TYPES . '
                        WHERE description = "' . mysql_real_escape_string($message_type) . '"
                        LIMIT 1
                        ),0),
                    referenced_key1 = "' . mysql_real_escape_string($transaction_id) . '"';
            } else {
                $query = '
                  DELETE FROM ' . NEW_TABLE_MESSAGES . '
                  WHERE
                    message_type_id = 
                      COALESCE((
                        SELECT message_type_id
                        FROM ' . NEW_TABLE_MESSAGE_TYPES . '
                        WHERE description = "' . mysql_real_escape_string($message_type) . '"
                        LIMIT 1
                        )
                      ,0)
                    AND referenced_key1 = "' . mysql_real_escape_string($transaction_id) . '"';
            }
            $result = mysql_query($query, $connection) or die(debug_print("ERROR: 850234 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
            $count++;
        }
    }
    // Return the number of messages changed
    return $count;
}
Exemplo n.º 25
0
 // source_preferred_name,   transaction_id,           pricing_unit,
 // Check if this account is the SOURCE account
 if ($row['source_type'] == $account_type && $row['source_key'] == $account_id) {
     $other_account_type = $row['target_type'];
     $other_account_key = $row['target_key'];
     $other_account = 'target';
     $amount = 0 - $row['amount'];
     // Invert the sense of payments *from* the account
 } elseif ($row['target_type'] == $account_type && $row['target_key'] == $account_id) {
     $other_account_type = $row['source_type'];
     $other_account_key = $row['source_key'];
     $other_account = 'source';
     $amount = $row['amount'];
 } else {
     // TO and FROM the same account... should not happen
     die(debug_print("error 203: ", "could not determine disposition of transaction" . print_r($row, true), basename(__FILE__) . ' LINE ' . __LINE__));
 }
 $balance += $amount;
 if ($other_account_type == 'producer') {
     $display_to_from = 'Producer #' . $other_account_key . ': ' . $row[$other_account . '_business_name'];
 } elseif ($other_account_type == 'member') {
     $display_to_from = 'Member #' . $other_account_key . ': ' . $row[$other_account . '_preferred_name'];
 } elseif ($other_account_type == 'internal') {
     $display_to_from = ORGANIZATION_ABBR . ': ' . $row[$other_account . '_account_number'] . ' (' . $row[$other_account . '_description'] . ')';
 } elseif ($other_account_type == 'tax') {
     $display_to_from = 'Tax: ' . $row[$other_account . '_tax_code'];
 } else {
     $display_to_from = '[' . $other_account_type . '::' . $other_account_key . ']';
 }
 if ($row['text_key'] == 'weight cost') {
     $display_quantity = $row['quantity'] . ' ' . $row['ordering_unit'] . ' @ ' . ($row['total_weight'] + 0) . ' ' . $row['pricing_unit'];
Exemplo n.º 26
0
 <body>
  <div id="header"><h1>PHP & MySQL: The Missing Manual</h1></div>
  <div id="example">Uh oh... sorry!</div>
  <div id="content">
    <h1>We're really sorry...</h1>
    <p><img src="../images/error.jpg" class="error" />
      <?php 
echo $error_message;
?>
      <span></p>
    <p>Don't worry, though, we've been notified that there's a 
problem, and we take these things seriously. In fact, if you want to 
contact us to find out more about what's happened, or you have any 
concerns, just <a href="mailto:info@yellowtagmedia.com">email us</a> 
and we'll be happy to get right back to you.</p>
    <p>In the meantime, if you want to go back to the page that caused 
the problem, you can do that <a href="javascript:history.go(-1);">by 
clicking here.</a> If the same problem occurs, though, you may 
want to come back a bit later. We bet we'll have things figured 
out by then. Thanks again... we'll see you soon. And again, we're 
really sorry for the inconvenience.</p>
    <?php 
debug_print("<hr />");
debug_print("<p>The following system-level message was received: <b>{$system_error_message}</b></p>");
?>
  </div>
  <div id="footer"></div> 
 </body>
</html>
Exemplo n.º 27
0
 function getFilteredResultSet(&$resultSet)
 {
     global $g_sqlComparisonOperators;
     for ($i = 0; $i < $this->getChildCount(); ++$i) {
         $child = $this->childs[$i];
         $this->resultSetsFromChilds[] = $child->getFilteredResultSet($resultSet);
     }
     $sp = new StringParser();
     //$or_expr=explode_resp_quotes(" OR ",$this->expr_str);
     $sp->setConfig(array("'", "\""), "\\", array(), array(" OR "), false, false);
     $sp->setString($this->expr_str);
     $or_expr = $sp->splitWithSpecialElements();
     $andResultSets = array();
     for ($i = 0; $i < count($or_expr); ++$i) {
         $fieldValuePair = array();
         $fields = array();
         $values = array();
         $operators = array();
         $childsToInclude = 0;
         //$and_expr=explode_resp_quotes(" AND ",$or_expr[$i]);
         $sp->setConfig(array("'", "\""), "\\", array(), array(" AND "), false, false);
         $sp->setString($or_expr[$i]);
         $and_expr = $sp->splitWithSpecialElements();
         array_walk($and_expr, "array_walk_trim");
         for ($j = 0; $j < count($and_expr); ++$j) {
             if ($and_expr[$j] == "%") {
                 $childsToInclude++;
             } else {
                 //$operators[]=explode_resp_quotes_multisep($g_sqlComparisonOperators,$and_expr[$j],$fieldValuePair);
                 $usedOps = array();
                 $sp->setConfig(array("'", "\""), "\\", array(), $g_sqlComparisonOperators, false, false);
                 $sp->setString($and_expr[$j]);
                 $fieldValuePair = $sp->splitWithSpecialElementsRetUsed($usedOps);
                 $operators[] = trim($usedOps[0]);
                 // Remove escape chars (because parseNextElementRaw() was used
                 // to parse Where Statements)
                 list($field, $value) = $fieldValuePair;
                 $fields[] = stripslashes(trim($field));
                 // like bugfix: don't remove escape chars on the LIKE value
                 if (strtoupper(trim($operators[count($operators) - 1])) == "LIKE") {
                     $values[] = trim($value);
                 } else {
                     $values[] = stripslashes(trim($value));
                 }
             }
         }
         if (TXTDBAPI_DEBUG) {
             echo "<br>fields and values to use for AND filter:<br>";
             print_r($fields);
             echo "<br>";
             print_r($values);
             echo "<br>";
             print_r($operators);
             echo "<br>";
             echo "childsToInclude:  " . $childsToInclude . "<br>";
         }
         $andResultSets[] = $resultSet->filterRowsByAndConditions($fields, $values, $operators);
         debug_print("filterRowsByAndConditions done<br>");
         for ($j = 0; $j < $childsToInclude; ++$j) {
             $andResultSets[$i]->filterResultSetAndWithAnother($this->resultSetsFromChilds[$this->childResultSetPos++]);
         }
         if (TXTDBAPI_DEBUG) {
             echo "Filtered ResultSet:<br>";
             $andResultSets[$i]->dump();
         }
     }
     $finalResultSet = $andResultSets[0];
     for ($i = 1; $i < count($andResultSets); ++$i) {
         $andResultSets[$i]->reset();
         while ($andResultSets[$i]->next()) {
             $finalResultSet->appendRow($andResultSets[$i]->getCurrentValues(), $andResultSets[$i]->getCurrentRowId());
         }
     }
     if (TXTDBAPI_DEBUG) {
         echo "<br><br>FINAL RESULT SET:<br>";
         $finalResultSet->dump();
     }
     return $finalResultSet;
 }
Exemplo n.º 28
0
// Get the actual transactions
$result_data = mysql_query($query_data, $connection) or die(debug_print("ERROR: 567289 ", array($query_data, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
// Get the total number of rows (for pagination) -- not counting the LIMIT condition
$query_found_rows = '
  SELECT
    FOUND_ROWS() AS found_rows';
$result_found_rows = @mysql_query($query_found_rows, $connection) or die(debug_print("ERROR: 759323 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
$row_found_rows = mysql_fetch_array($result_found_rows);
$found_rows = $row_found_rows['found_rows'];
$found_pages = ceil($found_rows / $per_page);
// Apply the
$limit_running_total = 'LIMIT ' . mysql_real_escape_string(floor($limit_begin_row) . ', ' . floor($found_rows - $limit_begin_row));
$query_balance = str_replace("LIMIT", "{$limit_running_total}", $query_balance);
//echo "<pre>$query_balance</pre>";
// Get the running total for this set of transactions
$result_balance = mysql_query($query_balance, $connection) or die(debug_print("ERROR: 567392 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
if ($row_balance = mysql_fetch_array($result_balance)) {
    $running_total = $row_balance['running_total'];
}
while ($row = mysql_fetch_array($result_data)) {
    // Keep the desired account information on the "source" side...
    $row['delivery_id'] = $row['delivery_id_source'];
    $row['site_id'] = $row['site_id_source'];
    $row['pvid_id'] = $row['pvid_id_source'];
    // If necessary, invert sense of the source and target accounts
    if ($row['target_type'] != $account_type || $row['target_key'] != $account_key) {
        $temp = $row['source_type'];
        $row['source_type'] = $row['target_type'];
        $row['target_type'] = $temp;
        $temp = $row['source_key'];
        $row['source_key'] = $row['target_key'];
Exemplo n.º 29
0
    $content .= '
            </div>';
}
// Only show the button for including the old configuration if the file exists
if (stream_resolve_include_path('config_foodcoop.php')) {
    $content .= '
            <input type="submit" name="action" value="' . $import_button_text . '">';
}
// and close the page form
$content .= '
            <input type="submit" name="action" value="' . $save_button_text . '">
          </form>';
// Now that we're almost done, go back and post all new data values
if (count($update_queries) > 0) {
    while ($query = array_shift($update_queries)) {
        $result = @mysql_query($query, $connection) or die(debug_print("ERROR: 758932 ", array($query, mysql_error()), basename(__FILE__) . ' LINE ' . __LINE__));
    }
}
$page_specific_css = '
  <style type="text/css">
    .status_message {
      color:#000;
      background-color:#fff;
      margin:0.5em 5em;
      }
    .ofs_config {
      clear:both;
      display:table;
      width:100%;
      border:1px solid #000;
      margin-bottom: 10px;
Exemplo n.º 30
0
            ?>
</h3>
				</td>
				<td style="width:250px; padding-left:10px; border:2px; border-style:solid; border-color:#000000;">
					<h3><?php 
            echo $dbRow[3];
            ?>
</h3>
				</td>
			</tr><br>
<?php 
        }
        ?>
		</table>	

			<form method="post" action="<?php 
        debug_print($URLstring);
        echo $URLstring;
        ?>
">
				<textarea style="display:block; position:absolute; top:620px; left:600px;" name="comment_val" rows="2" cols="40" placeholder="Post comment here..."></textarea>	
				<input style="position:absolute; left:960px; top:630px; width:200px; height:40px;" type='submit' name='comment' value="Comment">
			</form>
<?php 
    }
}
?>


<?php 
include SERVER_ROOT . '/views/footer.php';