Example #1
0
             Error::generate('prod_debug', $args);
         } else {
             $_SESSION['loading_screen_count' . $icrs->cid]++;
         }
     }
     ob_start();
     include $page;
     $contents = ob_get_contents();
     ob_end_clean();
     header("Connection: close");
     header("Content-Length: " . strlen($contents));
     echo $contents;
     flush();
     session_write_close();
     // this will spinlock if the course is locked
     $job_taken = db_start_transaction("comments", $icrs->cid);
     $lock_acquired = true;
 } else {
     $lock_acquired = false;
 }
 if (!$exists && $job_taken) {
     // course not cached
     async_cache_connect(1);
     async_cache_connect(2);
     async_cache_connect(3);
     //Comment::enableInitMode();
     $procd_descr = process_description($icrs->descr);
     if (count($procd_descr) == 0) {
         $procd_descr[] = 'N/A';
     }
     $ids = $desicrs = $tagss = array();
Example #2
0
                }
            }
        }
    }
}
$download->show_errors();
$download->show_messages();
$download->selectInput('currency', 'Currency', 1, false, false, 'currencies', array('currency'));
$download->submitButton('Download', 'Download Withdrawals CSV');
$download->display();
$CFG->form_legend = 'Account For Widtdrawals From Escrows';
$withdraw = new Form('withdraw', false, false, 'form1');
$withdraw->verify();
if ($_REQUEST['withdraw'] && !is_array($withdraw->errors)) {
    if ($withdraw->info['currency'] > 0 && $withdraw->info['amount'] > 0) {
        db_start_transaction();
        $currency_info = DB::getRecord('currencies', $withdraw->info['currency'], 0, 1, false, false, false, 1);
        if (!$currency_info) {
            $withdraw->errors[] = 'Invalid currency.';
        } elseif (!($currency_info[strtolower($currency_info['currency']) . '_escrow'] - $withdraw->info['amount'] > 0)) {
            $withdraw->errors[] = 'Balance too low to satisfy withdrawal.';
        } else {
            $status = DB::getRecord('status', 1, 0, 1, false, false, false, 1);
            $sql = 'UPDATE status SET ' . strtolower($currency_info['currency']) . '_escrow = ' . strtolower($currency_info['currency']) . '_escrow - ' . $withdraw->info['amount'] . ' WHERE id = 1';
            db_query($sql);
            $withdraw->messages[] = $withdraw->info['amount'] . ' subtracted from ' . $currency_info['currency'];
        }
        db_commit();
    }
}
$withdraw->show_errors();
Example #3
0
 public static function deleteAll()
 {
     global $CFG;
     if (!$CFG->session_active) {
         return false;
     }
     db_start_transaction();
     $sql = 'SELECT log_id FROM orders WHERE site_user = '******'id'] . ' FOR UPDATE';
     $result = db_query_array($sql);
     if (!$result) {
         db_commit();
         return false;
     }
     $orders_info = self::getStatus(false, 1);
     if (!$orders_info) {
         db_commit();
         return false;
     }
     $sql = 'UPDATE order_log LEFT JOIN orders ON (order_log.id = orders.log_id) SET status = "CANCELLED_USER" WHERE orders.site_user = '******'id'];
     $updated = db_query($sql);
     if ($updated) {
         $sql = 'DELETE FROM orders WHERE site_user = '******'id'];
         db_query($sql);
         foreach ($orders_info as $i => $order) {
             $orders_info[$i]['status'] = 'CANCELLED_USER';
         }
     }
     db_commit();
     return $orders_info;
 }
Example #4
0
     db_end_transaction('primitive_cache', $md5top);
     curl_multi_remove_handle($mch, $ch);
     curl_close($ch);
     $n_reqs_procd++;
     fputs($fp, "Daemon {$GLOBALS['client']} processed {$top}\r\n");
     Error::generate('debug', "Processed {$top}");
 } else {
     if (count($in_progress) < $max_simult_queries && $curl_stack->size() > 0) {
         $ch = $curl_stack->pop();
         $top = $completed->pop();
         $md5top = md5($top);
         db_query("INSERT IGNORE INTO primitive_cache_lock (id,locked) VALUES ('%s','0')", $md5top);
         $exists = db_affected_rows() == 0;
         // TODO: CURLOPT_TIMEVALUE and CURLOPT_TIMECONDITION on cache timestamp for Last-Modified if exists
         if (!$exists) {
             $locked = db_start_transaction('primitive_cache', $md5top, $blocking);
         } else {
             $locked = false;
         }
         if ($locked) {
             // we've got a lock, we can either start or finish
             $in_progress[] = array('ch' => $ch, 'top' => $top);
             curl_multi_add_handle($mch, $ch);
             $mcr = curl_multi_exec($mch, $active);
             Error::generate('debug', 'starting');
         } else {
             // preempted
             // lock *was* acquired if blocking
             if ($blocking) {
                 db_end_transaction('primitive_cache', $md5top);
             }