Ejemplo n.º 1
0
function message_len()
{
    global $id;
    $ex = new Exchange(array("action" => "get", "id" => $id));
    $ex_inf = $ex->run();
    $conv = json_decode($ex_inf[0]["messages"], true);
    $conv_d = is_array($conv) ? $conv : array();
    return count($conv_d);
}
Ejemplo n.º 2
0
 /**
  * @param Money    $money
  * @param Currency $counterCurrency
  * @param int      $roundingMode
  *
  * @return Money
  */
 public function convert(Money $money, Currency $counterCurrency, $roundingMode = Money::ROUND_HALF_UP)
 {
     $baseCurrency = $money->getCurrency();
     $ratio = $this->exchange->quote($baseCurrency, $counterCurrency)->getConversionRatio();
     $baseCurrencySubunit = $this->currencies->subunitFor($baseCurrency);
     $counterCurrencySubunit = $this->currencies->subunitFor($counterCurrency);
     $subunitDifference = $baseCurrencySubunit - $counterCurrencySubunit;
     $ratio = $ratio / pow(10, $subunitDifference);
     $counterValue = $money->multiply($ratio, $roundingMode);
     return new Money($counterValue->getAmount(), $counterCurrency);
 }
Ejemplo n.º 3
0
 /**
  * @depends	testInterface
  * @return	null
  */
 public function testDefaultValues()
 {
     $this->assertEquals('', $this->exchange->getExchangeName());
     $this->assertEquals('direct', $this->exchange->getType());
     $this->assertFalse($this->exchange->isPassive());
     $this->assertFalse($this->exchange->isDurable());
     $this->assertTrue($this->exchange->isAutoDelete());
     $this->assertFalse($this->exchange->isInternal());
     $this->assertFalse($this->exchange->isNoWait());
     $this->assertNull($this->exchange->getArguments());
     $this->assertNull($this->exchange->getTicket());
 }
Ejemplo n.º 4
0
 /**
  * Given a team ('A'/'B'), determines new team rating.
  *
  * @param string $team
  * @return float
  */
 protected function getNewTeamRating($team)
 {
     $inputRatingFunction = 'getTeam' . $team . 'Rating';
     if ($this->matchResult->getHigherTeam() == MatchResult::TEAMS_EQUAL) {
         // team's ranking points equal before game
         if ($this->matchResult->getResult() == MatchResult::DRAW) {
             // no change
             return $this->ratingsInput->{$inputRatingFunction}();
         }
         if ($this->matchResult->getResult() == $team) {
             // this team wins and gets points increase
             return $this->ratingsInput->{$inputRatingFunction}() + $this->exchange->getExchangeAmount();
         }
         // team lost
         return $this->ratingsInput->{$inputRatingFunction}() - $this->exchange->getExchangeAmount();
     }
     if ($this->matchResult->getHigherTeam() == $team) {
         // team in question is higher ranked before game
         if ($this->matchResult->getResult() == $team) {
             // team won
             return $this->ratingsInput->{$inputRatingFunction}() + $this->exchange->getExchangeAmount();
         }
         // team lost or drew, as they're higher ranked they lose points
         return $this->ratingsInput->{$inputRatingFunction}() - $this->exchange->getExchangeAmount();
     }
     // if we get here we're dealing with lower-ranked team before game
     if ($this->matchResult->getResult() == $team || $this->matchResult->getResult() == MatchResult::DRAW) {
         // lower ranked team gains points from win or draw
         return $this->ratingsInput->{$inputRatingFunction}() + $this->exchange->getExchangeAmount();
     }
     // lower ranked team lost
     return $this->ratingsInput->{$inputRatingFunction}() - $this->exchange->getExchangeAmount();
 }
Ejemplo n.º 5
0
 public function actionRun()
 {
     // Пересчитываем рейтинги
     $key = 'cron.bot.run.btc_rur';
     if (Yii::app()->cache->get($key) === false) {
         Yii::app()->cache->set($key, true, 60 * 3);
         // Запускаем бота для анализа и сделок
         $btc_rur = Exchange::updatePrices('btc_rur');
         $bot = new Bot($btc_rur);
         $bot->run();
     }
 }
Ejemplo n.º 6
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     foreach (Exchange::whereProcessed(false)->get() as $exchange) {
         if ($exchange->draw_at->isPast()) {
             $this->info('Drawing for exchange "' . $exchange->name . '"');
             // For each user in exchange
             $users = $exchange->participants()->orderByRaw('RAND()')->get();
             $length = count($users);
             foreach ($users as $key => $giver) {
                 if ($key == $length - 1) {
                     $gifty = $users[0];
                 } else {
                     $gifty = $users[$key + 1];
                 }
                 //Store
                 $this->info($giver->id . ' will be giving a gift to ' . $gifty->id);
                 $surprise = new Surprise();
                 $surprise->gifty()->associate($gifty);
                 $surprise->giver()->associate($giver);
                 $exchange->surprises()->save($surprise);
                 //Email
                 Mail::send('emails.exchanges.drawing', array('giver' => $giver, 'gifty' => $gifty, 'exchange' => $exchange), function ($message) use($exchange, $giver) {
                     //Test Emails
                     //$message->to('*****@*****.**', $giver->username)->subject($exchange->name . ' drawing!');
                     $message->to($giver->email, $giver->username)->subject($exchange->name . ' drawing!');
                 });
             }
             // Mark as processed
             $exchange->processed = true;
             $exchange->save();
         } else {
             // Skip
             $this->info($exchange->draw_at->diffInDays() . ' days left on ' . $exchange->name);
         }
     }
     $this->info('Done.');
 }
Ejemplo n.º 7
0
<?php

include_once $_SERVER["DOC_ROOT"] . "/scripts/php/core.php";
if (!isset($_SESSION["userid"])) {
    die;
}
?>

<a href="#postbox" class="icon uk-icon-plus" data-uk-modal></a>

<?php 
$my_exchanges = new Exchange(array("action" => "find"));
$exchange_array = $my_exchanges->run();
?>
<div onclick="display_menu('#exchange_menu', this);" id="exchange_icon" class="<?php 
if (count($exchange_array) != 0) {
    ?>
 static_active <?php 
}
?>
 icon uk-icon-exchange">
	<?php 
if (count($exchange_array) != 0) {
    ?>
			<div class="badge" onclick="display_menu('#exchange_menu', this);"><?php 
    echo count($exchange_array);
    ?>
</div>
	<?php 
}
?>
Ejemplo n.º 8
0
 public function getIndex()
 {
     $this->layout->title = 'Home';
     $exchanges = Exchange::where('hidden', 0)->orderBy('draw_at', 'asc')->paginate(Config::get('settings.per_page'));
     $this->layout->nest('content', 'home', ['exchanges' => $exchanges]);
 }
Ejemplo n.º 9
0
 /**
  * @param string $body
  * @param string $routingKey
  * @param array  $properties
  */
 public function publish($body, $routingKey = null, array $properties = array())
 {
     $this->exchange->publish($body, $routingKey, $properties);
 }
Ejemplo n.º 10
0
 public function actionChart($type = 'btc_rur')
 {
     $buy = new Buy();
     $exch = Exchange::getAllByDt('btc_rur', '2013-12-16', '2014-01-06');
     $data_buy = array();
     $data_sell = array();
     foreach ($exch as $item) {
         $tm = strtotime($item['dt']) * 1000 + 4 * 60 * 60 * 1000;
         $data_buy[] = array($tm, (double) $item['buy']);
         $data_sell[] = array($tm, (double) $item['sell']);
     }
     // Покупки
     $orders = Order::model()->findAll();
     $lastEx = Exchange::getLast();
     $status['total_income'] = Sell::getTotalIncome();
     $status['balance'] = Status::getParam('balance');
     $status['balance_btc'] = Status::getParam('balance_btc');
     $status['total_balance'] = $status['balance'] + $status['balance_btc'] * $lastEx->sell;
     $this->render('chart', array('data_buy' => json_encode($data_buy), 'data_sell' => json_encode($data_sell), 'orders' => $orders, 'status' => $status));
 }
Ejemplo n.º 11
0
// 3) Pickup countdown
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/widget/exchange/pickup.php";
// 4) Rating widget
include_once $_SERVER["DOC_ROOT"] . "/scripts/php/widget/exchange/rater.php";
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
//Connect to MySQL for our non-API related queries
$con = mysqli_connect(host(), username(), password(), mainDb());
//Will remove
if (!isset($_SESSION)) {
    session_start();
}
//Resume the session
//
$oid = $_GET["offerid"];
//Retrieve the offer ID
$currentExchange = new Exchange(array("action" => "get", "id" => $oid));
//Get info about the exchange
$getExchange = $currentExchange->run();
//Read the info into an array
//If no info can be found about the exchange...
if (!is_array($getExchange) || count($getExchange) == 0) {
    header("Location: /notfound.php");
    //...go to a not found page
    exit;
    //Exit
}
//who_ranked keeps info about who has ranked the other thus far. It is stored in an array in the database.
//If the array is null, then just make it empty. If it isn't, store it in the variable.
$who_ranked = is_array(json_decode($getExchange[0]["who_ranked"], true)) ? json_decode($getExchange[0]["who_ranked"], true) : array();
//If the user has already ranked the other user, the exchange (for them) is over
//Take them to a "special page"
Ejemplo n.º 12
0
    function output()
    {
        global $id;
        //Initialize output html and write header to variable
        $html = <<<WAT
\t\t<div class="hdr btxt">Meeting Date</div>
\t\t<div class="head">When are you free?</div>
WAT;
        //Initialize empty set of day columns for the table
        $days = "";
        for ($x = 1; $x <= 7; $x++) {
            $day_of_week = date("l", strtotime("+" . $x . " day"));
            //Calculate the day of week
            $date = date("n/j", strtotime("+" . $x . " day"));
            //Calculate the date
            $days .= "<td>{$day_of_week}<span>{$date}</span></td>";
            //Write html and append to the master date header
        }
        //Initialize empty set of time cells
        $times = "";
        //Get the information for this exchange
        $thisExchange = new Exchange(array("action" => "get", "id" => $id));
        $exchangeInfo = $thisExchange->run();
        //Decode the available dates between users
        $availableArray = json_decode($exchangeInfo[0]["availability"], true);
        //If there is no date array currently on the server...
        if (!is_array($availableArray)) {
            $availableArray = array();
            //Initialize an empty arreay
        }
        //Loop through the next 13 hours, starting at 9 AM
        for ($i = 9; $i < 22; $i++) {
            $class = $i % 2 == 0 ? "odd" : "even";
            //Allows for alternating row colors
            $time_str = date("g A", strtotime($i . ":00"));
            //Calculate a 12-hour time string based on index
            //Begin html for each row, beginning with a time header
            $times .= <<<EOF
\t\t\t\t\t\t<tr class="{$class}">
\t\t\t\t\t\t\t<td class="time_hcell">{$time_str}</td>
EOF;
            //Loop through the next seven days (again) per row
            for ($j = 1; $j <= 7; $j++) {
                //Generate a string in the form Y-m-d H:i:s using the given date/time information
                $calculated_timestring = date("Y-m-d", strtotime("+" . $j . "day")) . " " . date("H:i:s", strtotime($i . ":00"));
                //Generate a timestamp from that string
                $calculated_timestamp = strtotime($calculated_timestring);
                $cell_class = "";
                //By default, the cell will have no additional classes
                $visited_dates = array();
                //An array of dates that the iterator has gone through
                foreach ($availableArray as $user => $dates) {
                    foreach ($dates as $d) {
                        if ($d == $exchangeInfo[0]["date"]) {
                            $cell_class = "selected";
                            //...select it
                        } else {
                            if ($d == $calculated_timestamp) {
                                //Make it bright if it belongs to the current user,
                                //and dull if it belongs to the other user
                                $cell_class = $user == $_SESSION["userid"] ? "bright" : "faded";
                            }
                        }
                    }
                }
                $dt_cell = "<td data-timestamp=\"{$calculated_timestamp}\" class=\"timecell {$cell_class}\"></td>";
                //Write an html string for the cell
                $times .= $dt_cell;
                //Append it to the times row
            }
            $times .= "</tr>";
            //End the times row
        }
        //Finish writing the HTML
        $html .= <<<EOD
\t\t\t\t<table class="btxt" style="font-size:12px;border-spacing:0px;">
\t\t\t\t\t<tr style="text-align:center;">
\t\t\t\t\t\t<td></td>
\t\t\t\t\t\t{$days}
\t\t\t\t\t</tr>
\t\t\t\t\t{$times}
\t\t\t\t</table>
\t\t\t\t<script>
\t\t\t\t</script> 
EOD;
        echo $html;
        //Output the HTML
        return;
        //Return null
    }
Ejemplo n.º 13
0
 /**
  * Получает изображение графика за период - -0+
  * @param  $period - период расчета в сек.
  * @param $name - buy, sell
  */
 public function getGraphImage($curtime, $period, $name, $imp_dif)
 {
     // @todo переделать - диапазоны расчитывать более точно
     $step = round($period / 3);
     $from_tm = $curtime - $period;
     $from = date('Y-m-d H:i:s', $from_tm);
     $to = date('Y-m-d H:i:s', $curtime);
     $track = "";
     $prev = false;
     for ($i = 0; $i <= 3; $i++) {
         $step_ut = $from_tm + $step * $i;
         $step_dt = date('Y-m-d H:i:s', $step_ut);
         // Делим период на 4 точки
         $step_ut_f = date('Y-m-d H:i:s', $step_ut - $step / 2);
         // Вокруг каждой точки отмеряем назад и вперед половину шага
         $step_ut_t = date('Y-m-d H:i:s', $step_ut + $step / 2);
         //$val=Exchange::NOSQL_getAvg($name, $step_ut_f, $step_ut_t);
         $val = Exchange::getAvg($name, $step_ut_f, $step_ut_t);
         if (!$val) {
             //Log::Add('Не нашел данных за период с'.$step_ut_f.' по '.$step_ut_t);
             continue;
         }
         $list[] = array('dtm' => $step_dt, 'val' => $val);
         if (!$prev) {
             $prev = $val;
             continue;
         }
         // Определяем направление
         $dif = 1 - $prev / $val;
         if ($dif < -1 * $imp_dif) {
             $track .= "-";
         } elseif ($dif > $imp_dif) {
             $track .= "+";
         } else {
             $track .= "0";
         }
         $prev = $val;
     }
     $result = array('track' => $track, 'from' => $from, 'step' => $step, 'period' => $period, 'items' => $list);
     return $result;
 }
Ejemplo n.º 14
0
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
App::missing(function ($exception) {
    $layout = View::make("layout.main");
    $layout->title = 'Not Found';
    $layout->content = View::make("errors.missing")->with('exception', $exception->getMessage());
    return Response::make($layout, 404);
});
Route::bind('exchange', function ($value) {
    $exchange = Exchange::where('slug', $value)->first();
    if ($exchange) {
        return $exchange;
    }
    App::abort(404, 'Exchange not found!');
});
Route::bind('user', function ($value, $route) {
    $user = User::where('username', $value)->first();
    if ($user) {
        return $user;
    }
    App::abort(404, 'User not found!');
});
Route::when('*', 'csrf', ['post']);
Route::get('/', ['as' => 'home', 'uses' => 'HomeController@getIndex']);
Route::group(['prefix' => 'dashboard', 'before' => 'auth'], function () {
Ejemplo n.º 15
0
<?php

require_once $_SERVER['DOCUMENT_ROOT'] . '/Source/ExchangeDB.php';
// File with DB functions class
if (!$_SESSION) {
    session_start();
}
// Start the session
$Exchange = new Exchange();
//instantiating class with DB functions
$action = $_REQUEST["action"];
//variable from GET string - shows what action to take
header("Content-type:text/xml");
//setting the content type of the response document to XML
echo '<?xml version="1.0"?><data>';
//setting the root xml tag in the response document
switch ($action) {
    case "FindCabinet":
        $status = $Exchange->FindCabinet($_REQUEST['Cabinet']);
        //
        echo '<status><![CDATA[' . $status[0] . ']]></status>';
        //output login status
        echo '<Name><![CDATA[' . $status[1] . ']]></Name>';
        //output login status
        break;
    case "Swap":
        $status = $Exchange->Swap($_REQUEST['Servers']);
        //
        echo '<status><![CDATA[' . $status[0] . ']]></status>';
        //output login status
        echo '<Name><![CDATA[' . $status[1] . ']]></Name>';
Ejemplo n.º 16
0
 * User: larismendi
 * Date: 21/04/2015
 * Time: 11:38 AM
 */
session_start();
require_once dirname(__FILE__) . '/../config/config.inc.php';
require_once dirname(__FILE__) . '/../neo_exchanges/Exchange.php';
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (isset($_POST['id_usuario'])) {
    $results = array();
    $results2 = array();
    $price = 0;
    $price2 = 0;
    $inter1 = $inter2 = $forma_pago = '';
    $inter = new Exchange();
    $msn = "";
    $nor = array();
    if (isset($_POST['items_sale'])) {
        $results = $inter->getItemSales($_POST['items_sale']);
    }
    if (isset($_POST['items_buy'])) {
        $results2 = $inter->getItemBuys($_POST['items_buy']);
    }
    $valida = $inter->validAvailability($results2);
    foreach ($results as $result) {
        $price += round($result['price']);
    }
    foreach ($results2 as $result2) {
        $price2 += round($result2['price']);
        $nor[] = $result2['id'];
Ejemplo n.º 17
0
 /**
  * Протестировать бота на старых данных
  */
 public function runTest()
 {
     // Получаем статистику за период
     $period_from = date('Y-m-d H:i:s', time() - $this->analize_period);
     $exdata = Exchange::getDataFrom($period_from);
     // Получаем данные биржи
     //$this->balance = 1000;
     //$exdata = Exchange::getTestData();
     Log::Add(0, 'ПОКУПАЕМ: ');
     $this->AnalizeBuy($exdata);
     Log::Add(0, 'ПРОДАЕМ: ');
     $this->AnalizeSell($exdata);
     Status::setParam('balance', $this->balance);
     Status::setParam('balance_btc', $this->balance_btc);
     if ($this->order_cnt > 0) {
         Log::Add(0, 'Баланс (руб.): ' . $this->balance, 1);
         Log::Add(0, 'Всего заработано: ' . $this->total_income, 1);
         Log::Add(0, 'Остаток btc: ' . round($this->balance_btc, 5), 1);
     }
 }
Ejemplo n.º 18
0
 /**
  * Creates an exchange for the collection
  *
  * @param string $name the name of the exchange to create
  * @param array $config the exchange configuration
  *
  * @return Exchange the exchange instance
  */
 protected function createExchange($name, $config = array())
 {
     $exchange = new Exchange();
     foreach ($config as $key => $value) {
         $exchange->{$key} = $value;
     }
     $exchange->name = strtolower($name);
     $exchange->setClient($this->getClient());
     return $exchange;
 }
Ejemplo n.º 19
0
$user_items = array();
if (isset($_SESSION["userid"])) {
    //Get items available for offer
    $user_itemReq = new Item(array("action" => "get", "filter" => array("usr" => $_SESSION["userid"], "status" => "1")));
    $user_items = $user_itemReq->run();
}
//Store the owner's privacy settings in an array
$privacy = is_array(json_decode($userGet[0]["privacy"], true)) ? json_decode($userGet[0]["privacy"], true) : array();
//Get the join date of the user
$jdate = $userGet[0]["join_date"];
//Get the full page URL
$full_url = urlencode("https://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}");
/* * * ACCEPTING AN ITEM * * */
if (isset($_POST["accept"]) && trim($_POST["accept"]) != "") {
    //Create a new exchange
    $acceptExchange = new Exchange(array("action" => "create", "item1" => $_GET["itemid"], "item2" => $_POST["accept"]));
    $acceptExchange->run();
    //Redirect to the new exchange page
    header("Location: /" . $url);
    exit;
}
/* * * WITHDRAWING AN ITEM * * */
if (isset($_POST["withdraw"]) && trim($_POST["withdraw"]) != "") {
    //Get info about the withdrawl item
    $wdRequest = new Item(array("action" => "get", "filter" => array("id" => $_POST["withdraw"])));
    $wdInfo = $wdRequest->run(true);
    //If the user doesn't own this item
    if ($wdInfo[0]["usr"] != $_SESSION["userid"]) {
        //Just refresh the page
        header("Location: /" . $url);
        exit;
Ejemplo n.º 20
0
        $return = $library->run(false);
        break;
    case "login":
        $library = new Login($_GET);
        $return = $library->run();
        break;
    case "listener":
        $library = new Listener($_GET);
        $return = $library->listen();
        break;
    case "messenger":
        $library = new Messenger($_GET);
        $return = $library->run();
        break;
    case "exchange":
        $library = new Exchange($_GET);
        $return = $library->run();
        break;
    case "feed":
        $library = new Feed($_GET);
        $return = $library->run();
        break;
    default:
        $return = 405;
        break;
}
header('Content-type: text/html; charset=UTF-8');
//If the return value isn't still null
if ($return) {
    if (is_array($return)) {
        echo json_encode($return);
Ejemplo n.º 21
0
 public static function updatePrices($pair = 'btc_rur')
 {
     $BTCeAPI = BTCeAPI::get_Instance();
     $ticker = $BTCeAPI->getPairTicker($pair);
     $ticker = $ticker['ticker'];
     $exchange = new Exchange();
     $exchange->buy = $ticker['buy'];
     $exchange->sell = $ticker['sell'];
     $exchange->dtm = date('Y-m-d H:i:s', $ticker['updated']);
     $exchange->pair = $pair;
     $exchange->save();
     return $exchange;
 }
Ejemplo n.º 22
0
 public function postDelete(Exchange $exchange)
 {
     $rules = array('confirm' => 'required|in:' . $exchange->name);
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('exchange.delete', ['exchange' => $exchange->slug])->withErrors($validator)->withInput(Input::all());
     } else {
         $exchange->delete();
         return Redirect::route('home');
     }
 }
Ejemplo n.º 23
0
    $id = '';
    $button = 'Add exchange';
    include 'form.html.php';
    exit;
}
if (isset($_GET['addform'])) {
    Exchange::insertExchange($_POST['name'], $_POST['web']);
    header('Location: .');
    exit;
}
//EDIT
if (isset($_POST['action']) and $_POST['action'] == 'Edit') {
    $arr = Exchange::getExchanges($_POST['id']);
    $row = $arr[0];
    $pageTitle = 'Edit Exchange';
    $action = 'editform';
    $name = $row->_name;
    $web = $row->_web;
    $id = $row->_id;
    $button = 'Update exchange';
    include 'form.html.php';
    exit;
}
if (isset($_GET['editform'])) {
    Exchange::updateExchange($_POST['id'], $_POST['name'], $_POST['web']);
    header('Location: .');
    exit;
}
// SELECT THE LIST OF EXCHANGES //////////////////////////////////////////////////////
$exchanges = Exchange::getExchanges();
include 'exchanges.html.php';
Ejemplo n.º 24
0
 private function makeOrderVirtual($cnt, $pair, $type, $price)
 {
     $bot = Bot::get_Instance();
     $summ = $cnt * $price;
     // Создаем виртуальную заявку на покупку, будет исполнена при следующем запросе
     // Расчитываем баланс
     if ($type == 'buy') {
         $balance_btc = $this->balance_btc;
         $balance = $this->balance - $summ;
     } else {
         $balance_btc = $this->balance_btc - $cnt;
         $balance = $this->balance;
     }
     // Имитация возвращаемых данных
     $result = array('success' => 1, 'return' => array('received' => 0, 'remains' => $cnt, 'order_id' => 87715140 + rand(0, 999) * 10000 + date('m') * 1000 + date('h') * 100 + date('m') * 10 + date('s'), 'funds' => array('btc' => (double) $balance_btc, 'rur' => (double) $balance)));
     // Добавляем заказ в список активных заказов
     $lastEx = Exchange::getLast();
     $this->activeOrders[$result['return']['order_id']] = array('pair' => 'btc_rur', 'type' => $type, 'amount' => $cnt, 'rate' => $price, 'timestamp_created' => $lastEx->dtm, 'status' => 0);
     $this->balance = $balance;
     $this->balance_btc = $balance_btc;
     return $result['return'];
 }
Ejemplo n.º 25
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $exchange = Exchange::find($id);
     $respone = Input::get('respone');
     if (FEUsersHelper::isCurrentUser($exchange->r_user_id && $respone)) {
         if ($respone == 'Đồng ý') {
             Session::flash('messages', array('Đã xác nhận trao đổi'));
             $exchange->status = 1;
         } elseif ($respone == 'Xóa') {
             Session::flash('messages', array('Đã hủy yêu cầu trao đổi'));
             $exchange->status = -1;
         }
         $exchange->save();
         Session::flash('status', true);
         return Redirect::to('exchange?user_id=' . $exchange->r_user_id . '&action=receive');
     } else {
         return Redirect::to('/');
     }
 }
Ejemplo n.º 26
0
    for ($i = 0; $i < $length; $i++) {
        $griditem = BaseController::exchange_factory($featured_stories[$i], 'griditem');
        if (0 === $i && 2 !== $length) {
            $modifiers = array('grid_width' => 'grid_full', 'grid_width_num' => 12);
        } else {
            if (3 === $length) {
                $modifiers = array('grid_width' => 'grid_half', 'grid_width_num' => 6);
            } elseif (4 === $length) {
                $modifiers = array('grid_width' => 'grid_third', 'grid_width_num' => 4);
            } elseif (2 === $length) {
                $modifiers = array('grid_width' => 'grid_half', 'grid_width_num' => 6);
            }
        }
        if (1 === $i && 2 < $length) {
            echo '</div><!-- end row --><div class="row" data-equalizer>';
        }
        Exchange::publish_grid_featured($griditem, 'featuredgrid', $modifiers);
    }
    if ($length > 0) {
        echo '</div>';
    }
    ?>

				</div><!-- section-inner-->

			</section><!-- section--has-grid-->

		</div>

	<?php 
}