コード例 #1
0
ファイル: Polygon.php プロジェクト: pepin82/geometry
 /**
  * @param \Geometry\Points $points
  * @throws \InvalidArgumentException
  */
 public function __construct(Points $points)
 {
     if (!$points->isClosed()) {
         throw new \InvalidArgumentException("points are not closed");
     }
     $this->points = $points;
 }
コード例 #2
0
 public function bets()
 {
     $param = Input::only('account_id', 'bets');
     $rules = array('bets' => 'required|numeric|min:1,max:1000000', 'account_id' => 'required|exists:acl_users,id');
     //custom error messaging
     $messages = array('buyer_id.exists' => 'Buyer id is not valid.', 'merchant_id.exists' => 'Merchant id is not valid');
     $validator = Validator::make($param, $rules, $messages);
     if ($validator->passes()) {
         $points_conversion = Settings::getSettingValue('points_conversion');
         $points_converted = $param['bets'] / floatval($points_conversion);
         $create = array('account_id' => $param['account_id'], 'added_by' => $this->operator_id, 'bet' => $param['bets'], 'points_conversation' => floatval($points_conversion), 'points_converted' => $points_converted);
         try {
             $player_bet = Playerbets::create($create);
             $retrieve = Points::where('account_id', $param['account_id'])->first();
             $update = $retrieve->increment('credits', $points_converted);
             $message = 'Points has been updated.';
             return Redirect::action('points.player')->with('success', $message);
         } catch (Exception $e) {
             // return false;
             print $e;
         }
     } else {
         $messages = $validator->messages();
         return Redirect::action('points.player')->with('error', $messages->all());
     }
 }
コード例 #3
0
ファイル: StudentsController.php プロジェクト: Kapodastr/grow
 public function actionAddpoint($id)
 {
     $student = Students::model()->findByPk($id);
     $bonus = new Points();
     if (isset($_REQUEST['Points'])) {
         $data = $_REQUEST['Points'];
         $bonus->student = $data['student'];
         $bonus->earned = $data['earned'];
         $bonus->comment = $data['comment'];
         $bonus->by = $data['by'];
         if ($bonus->save()) {
             Yii::app()->notify->add("Бонус добавлен");
         } else {
             Yii::app()->notify->addErrors($bonus->getErrors());
         }
     }
     $this->render('addpoint', array('student' => $student, "point" => $bonus));
 }
コード例 #4
0
 public function post()
 {
     $param = Input::only('player_id', 'points');
     $rules = array('points' => 'required|numeric|min:1,max:1000000', 'player_id' => 'required|exists:acl_users,id');
     //custom error messaging
     $messages = array('points.required' => 'Please fill up the player points redemption.', 'merchant_id.exists' => 'Merchant id is not valid');
     $validator = Validator::make($param, $rules, $messages);
     if ($validator->passes()) {
         $player_points = Points::where('account_id', $param['player_id'])->get()->first();
         $param = array('player_id' => $param['player_id'], 'points' => $param['points'], 'redeem_by' => Auth::user()->id, 'coupon_code' => Utils::generateRandomString(), 'redeemed' => 1);
         try {
             $player_bet = Coupon::create($param);
             $update = $player_points->decrement('credits', $param['points']);
             $message = 'Points has been successfully redeemed.';
             return Redirect::action('points.redeem')->with('success', $message);
         } catch (Exception $e) {
             print $e;
         }
     } else {
         $messages = $validator->messages();
         return Redirect::action('points.redeem')->with('error', $messages->all());
     }
 }
コード例 #5
0
ファイル: logging.php プロジェクト: vuong93st/w-game
 * 
 * @version $Revision: 1285 $
 */
define('CURSCRIPT', 'logging');
require "libraries/common.inc.php";
require "share.inc.php";
require_once LIB_PATH . "session_php.class.php";
require LIB_PATH . "validation.class.php";
require APP_ROOT . 'libraries/sendmail.inc.php';
require LIB_PATH . 'passport.class.php';
$session = new PbSessions();
uses("member", "company", "point");
$validate = new Validation();
$passport = new Passports();
$company = new Companies();
$point = new Points();
$member = new Members();
$referer = "";
capt_check("capt_logging");
if (empty($_GET['forward'])) {
    $_GET['forward'] = $_SERVER['HTTP_REFERER'];
}
if (isset($_POST['action']) && $_POST['action'] == "logging") {
    if (!empty($_POST['data']['login_name']) && !empty($_POST['data']['login_pass'])) {
        unset($_SESSION['authnum_session']);
        $tmpUserName = $_POST['data']['login_name'];
        $tmpUserPass = $_POST['data']['login_pass'];
        $checked = $member->checkUserLogin($tmpUserName, $tmpUserPass);
        $tmp_memberinfo = array();
        if ($checked > 0) {
            $tmp_memberinfo = $member->info;
コード例 #6
0
ファイル: profile.php プロジェクト: kronus7713/web2015
echo $CI->session->userdata('email');
?>
.</p>
						
						<?php 
if (Permissions::is_admin()) {
    ?>
						<p>
							Go to <a href="/admin">your admin panel.</a>
						</p>
						<?php 
}
?>
						
						<p>You have <?php 
Points::echo_pretty_points();
?>
.</p>
					</div>
				</div>
			</div>
			
			<?php 
$this->load->view('include/social_sidebar.php');
?>
		</div>
	</div>
	
	<?php 
$this->load->view('include/footer.php');
$this->load->view('include/bootstrapjs.php');
コード例 #7
0
 function it_gets_points_from_original_fare()
 {
     $this->pay(\Fare::fromString("50"));
     $this->getPoints()->shouldBeLike(\Points::fromString('100'));
 }
コード例 #8
0
 public function upload()
 {
     if (Input::hasFile('playerfile')) {
         $file = Input::file('playerfile');
         $up = Excel::load($file, function ($reader) {
             $results = $reader->get()->toArray();
             foreach ($results as $row) {
                 $player_group_id = Group::where('name', 'Player')->firstOrFail();
                 $days = new DateTime(date('Y-m-d H:i:s', strtotime("+30 days")));
                 $player_account = array('email' => '', 'password' => Hash::make(''), 'confirmed' => 1, 'status' => 1, 'password_expiration_date' => $days, 'account_expiration_date' => $days, 'created_at' => new DateTime(), 'updated_at' => new DateTime());
                 foreach ($row as $key => $value) {
                     $player_account[$key] = $value;
                 }
                 try {
                     $add_account = User::create($player_account);
                     $user_member = array('user_id' => $add_account->id, 'group_id' => $player_group_id->id, 'date_created' => new DateTime());
                     $add_member = UserMember::create($user_member);
                     $player_points = array('account_id' => $add_account->id);
                     $add_points = Points::create($player_points);
                 } catch (Exception $e) {
                     // return false;
                 }
             }
         });
         if ($up) {
             $messages = 'Upload Successful.';
             $status = 'success';
         } else {
             $messages = 'Upload failed.';
             $status = 'error';
         }
         return Redirect::route('player.index')->with($status, $messages);
     } else {
         return Redirect::action('player.index')->with('error', 'Please select a Excel or CSV File.');
     }
 }
コード例 #9
0
ファイル: Lines.php プロジェクト: vokson/scad.constructor.php
 public static function findOverlappingOfTwoLines($line1, $line2, &$overlap1, &$overlap2)
 {
     $isLine1Reversed = FALSE;
     // Check same line or not
     if (!Lines::isTwoPiecesOnSameLine($line1, $line2)) {
         return FALSE;
     }
     // Check same directions or not
     if (!Lines::areTwoVectorHaveSameDirection($line1, $line2)) {
         $line1->reverse();
         $isLine1Reversed = TRUE;
     }
     // Points
     $point1 = $line1->point1;
     $point2 = $line1->point2;
     // Line 1
     $point3 = $line2->point1;
     $point4 = $line2->point2;
     // Line 2
     // Calculate line coordinates from point1
     $x1 = 0;
     $x2 = Points::twoPointsDistance($point1, $point2);
     $x3 = Points::twoPointsDistance($point1, $point3);
     $x4 = Points::twoPointsDistance($point1, $point4);
     // Set sign to coordinates
     if (!Lines::areTwoVectorHaveSameDirection($line1, new \Classes\Utils\AbstractInstance\Line($point1, $point3))) {
         $x3 *= -1;
     }
     // Set sign to coordinates
     if (!Lines::areTwoVectorHaveSameDirection($line1, new \Classes\Utils\AbstractInstance\Line($point1, $point4))) {
         $x4 *= -1;
     }
     // Overlapping length
     $length = min($x2, $x4) - max($x1, $x3);
     // Check if therу is overlapping
     if ($length <= 0) {
         return FALSE;
     }
     // Create coordinate array
     $arrayToSort = array(0 => array('point' => 1, 'value' => $x1), 1 => array('point' => 2, 'value' => $x2), 2 => array('point' => 3, 'value' => $x3), 3 => array('point' => 4, 'value' => $x4));
     $sortedArray = Constant::sortArrayByIndex($arrayToSort, 'value');
     // Check variant of overlapping
     // 1-3-2-4
     if ($sortedArray[0]['point'] == 1 && $sortedArray[1]['point'] == 3 && $sortedArray[2]['point'] == 2 && $sortedArray[3]['point'] == 4) {
         $overlap1 = array($x3, $x2);
         $overlap2 = array(0, $x2 - $x3);
     }
     // 3-1-4-2
     if ($sortedArray[0]['point'] == 3 && $sortedArray[1]['point'] == 1 && $sortedArray[2]['point'] == 4 && $sortedArray[3]['point'] == 2) {
         $overlap1 = array(0, $x4);
         $overlap2 = array($x1 - $x3, $x4 - $x3);
     }
     // 1-3-4-2
     if ($sortedArray[0]['point'] == 1 && $sortedArray[1]['point'] == 3 && $sortedArray[2]['point'] == 4 && $sortedArray[3]['point'] == 2) {
         $overlap1 = array($x3, $x4);
         $overlap2 = array(0, $x4 - $x3);
     }
     // 3-1-2-4
     if ($sortedArray[0]['point'] == 3 && $sortedArray[1]['point'] == 1 && $sortedArray[2]['point'] == 2 && $sortedArray[3]['point'] == 4) {
         $overlap1 = array(0, $x2);
         $overlap2 = array($x1 - $x3, $x2 - $x3);
     }
     // Reverse overlapping of line1
     if ($isLine1Reversed) {
         // $x2 = Length(line1)
         $begin = $x2 - $overlap1[1];
         $end = $x2 - $overlap1[0];
         $overlap1[0] = $begin;
         $overlap1[1] = $end;
     }
     return TRUE;
 }
コード例 #10
0
        $items = $mail['victim']['items'];
        $i = array();
        $destroyedValue = 0;
        $droppedValue = 0;
        $totalValue = processItems($mail['victim']['items'], $date);
        $totalValue += Price::getItemPrice($mail['victim']['shipType']['id'], $date, true);
        $zkb = array();
        if (isset($mail['war']['id']) && $mail['war']['id'] != 0) {
            $kill['warID'] = (int) $mail['war']['id'];
        }
        if (isset($kill['locationID'])) {
            $zkb['locationID'] = $kill['locationID'];
        }
        $zkb['hash'] = $crestmail['hash'];
        $zkb['totalValue'] = (double) $totalValue;
        $zkb['points'] = (int) Points::getKillPoints($kill, $zkb['totalValue']);
        $kill['zkb'] = $zkb;
        $exists = $killmails->count(['killID' => $killID]);
        if ($exists == 0) {
            $killmails->save($kill);
        }
        $oneWeekExists = $mdb->exists('oneWeek', ['killID' => $killID]);
        if (!$oneWeekExists) {
            $mdb->getCollection('oneWeek')->save($kill);
        }
        $queueInfo->push($killID);
        $redis->incr("zkb:totalKills");
        ++$counter;
    }
}
if ($debug && $counter > 0) {
コード例 #11
0
ファイル: offer.php プロジェクト: renduples/alibtob
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2205 $
 */
require "../libraries/common.inc.php";
require "room.share.php";
require PHPB2B_ROOT . 'libraries/page.class.php';
check_permission("offer");
$tpl_file = "offer";
$page = new Pages();
uses("trade", "tradefield", "product", "tag", "attachment", "form", "typeoption", "point", "industry", "area");
$attachment = new Attachment("pic");
$area = new Areas();
$industry = new Industries();
$form = new Forms();
$point = new Points();
$tradefield = new Tradefields();
$tag = new Tags();
$trade = new Trades();
$trade_controller = new Trade();
$typeoption = new Typeoption();
$conditions = array();
$conditions[] = "member_id = " . $the_memberid;
setvar("TradeTypes", $trade_controller->getTradeTypes());
setvar("TradeNames", $trade_controller->getTradeTypeNames());
$tmp_personalinfo = $memberinfo;
setvar("MemberInfo", $tmp_personalinfo);
$expires = $trade_controller->getOfferExpires();
setvar("TradeTypes", $trade_controller->getTradeTypes());
setvar("PhoneTypes", $typeoption->get_cache_type("phone_type"));
setvar("ImTypes", $typeoption->get_cache_type("im_type"));
コード例 #12
0
ファイル: points_helper.php プロジェクト: kronus7713/web2015
 public static function echo_pretty_points()
 {
     echo Points::make_pretty_points();
 }
コード例 #13
0
ファイル: Member.php プロジェクト: sucjun/inkcc
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPoints()
 {
     return $this->hasMany(Points::className(), ['member_id' => 'member_id']);
 }
コード例 #14
0
 /**
  * @covers Classes\Utils\Math\Points::isPointOnLine
  * @todo   Implement testIsPointOnLine().
  */
 public function testIsPointOnLine_7()
 {
     $p1 = new \Classes\Utils\AbstractInstance\Point(0, 3, 0);
     $p2 = new \Classes\Utils\AbstractInstance\Point(0, 3, 5);
     $line = new \Classes\Utils\AbstractInstance\Line($p1, $p2);
     $point = new \Classes\Utils\AbstractInstance\Point(0, 0, 0.5);
     $result = Points::isPointOnLine($point, $line);
     $this->assertEquals($result, 0);
 }
コード例 #15
0
<?php

/* zKillboard
 * Copyright (C) 2012-2013 EVE-KILL Team and EVSCO.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
$info = array();
if ($page == "statistics") {
    $info["kills"] = Storage::retrieve("KillCount");
    $info["ignored"] = Db::queryField("select count(*) count from zz_killmails where processed = 3", "count", array(), 300);
    $info["total"] = Storage::retrieve("ActualKillCount");
    //$info["apicallsprhour"] = json_encode(Db::query("select hour(requestTime) as x, count(*) as y from ( select requestTime from zz_api_log where requestTime >= date_sub(now(), interval 24 hour)) as foo group by 1 order by requestTime", array(), 300));
    //var_dump($info);
}
$info["pointValues"] = Points::getPointValues();
$app->render("information.html", array("pageview" => $page, "info" => $info));
コード例 #16
0
 public function getPoints()
 {
     return \Points::fromString($this->pence / 100);
 }
コード例 #17
0
ファイル: offer.php プロジェクト: vuong93st/w-game
 * Licensed under The Languages Packages Licenses.
 * Support : phpb2b@hotmail.com
 * 
 * @version $Revision: 1393 $
 */
require "../libraries/common.inc.php";
require "room.share.php";
require PHPB2B_ROOT . 'libraries/page.class.php';
require CACHE_PATH . "cache_setting1.php";
check_permission("offer");
$tpl_file = "offer";
$page = new Pages();
uses("trade", "tradefield", "product", "tag", "attachment", "form", "typeoption", "point");
$attachment = new Attachment("pic");
$form = new Forms();
$point = new Points();
$tradefield = new Tradefields();
$tag = new Tags();
$trade = new Trades();
$trade_controller = new Trade();
$typeoption = new Typeoption();
$conditions = array();
$conditions[] = "member_id = " . $_SESSION['MemberID'];
setvar("TradeTypes", $trade_controller->getTradeTypes());
setvar("TradeNames", $trade_controller->getTradeTypeNames());
$tmp_personalinfo = $memberinfo;
setvar("MemberInfo", $tmp_personalinfo);
$expires = $trade_controller->getOfferExpires();
setvar("TradeTypes", $trade_controller->getTradeTypes());
setvar("PhoneTypes", $typeoption->get_cache_type("phone_type"));
setvar("ImTypes", $typeoption->get_cache_type("im_type"));
コード例 #18
0
ファイル: addpoint.php プロジェクト: Kapodastr/grow
		<input type="hidden" name="Points[by]" value="<?php 
echo Yii::app()->my->id;
?>
">

	<?php 
$this->endWidget();
?>


<hr>

<h4>Все поинты студента</h4>

<?php 
$points = Points::model()->findAllByAttributes(array("student" => $student->id));
?>

<!-- Выведем ранее полученные поинты и бонусы -->

<table class="table">

	<?php 
foreach ($points as $point) {
    ?>

		<tr>
			<td><span class="label <?php 
    if ($point->earned > 0) {
        ?>
label-success<?php 
コード例 #19
0
 function it_calculates_points()
 {
     $this->getPoints()->shouldBeLike(\Points::fromString(100));
 }
コード例 #20
0
ファイル: OutJson.php プロジェクト: Pattuns/Server
<?php

require_once '/var/www/html/metoro/Station.php';
require_once '/var/www/html/metoro/Points.php';
require_once '/var/www/html/metoro/StationTemp.php';
# コンシューマーキー
define('CONSKEY', 'c1d257fbcb8c4ccc7065d5f4bc38442d20db87a6efc9995edbd535cfa642fdf0');
# ポストされて送られてきた駅名
$stationNames = array($_GET["station_1"], $_GET["station_2"]);
$points = new Points($stationNames);
$pointsGis = array();
$pointsGis = $points->getPointsGis();
$interPoint = array("lon" => ($pointsGis[0]["lon"] + $pointsGis[1]["lon"]) / 2, "lat" => ($pointsGis[0]["lat"] + $pointsGis[1]["lat"]) / 2);
$pointList = array();
$pointsList = $points->compairByFare();
echo "[";
foreach ($points->stations as $station) {
    echo "{";
    echo "type:point,";
    echo "name:" . $station->getStationName() . ",";
    echo "gis:{";
    foreach ($station->getGisInfo() as $type => $value) {
        echo $type . ":" . $value . ",";
    }
    echo "},";
    echo "fare:0,";
    echo "},";
}
foreach ($pointsList as $midpoint) {
    echo "{";
    echo "type:midpoint,";
コード例 #21
0
ファイル: Parser.php プロジェクト: Covert-Inferno/zKillboard
 public static function parseKills()
 {
     if (Util::isMaintenanceMode()) {
         return;
     }
     $timer = new Timer();
     $maxTime = 65 * 1000;
     Db::execute("set session wait_timeout = 120000");
     Db::execute("create temporary table if not exists zz_participants_temporary select * from zz_participants where 1 = 0");
     $numKills = 0;
     while ($timer->stop() < $maxTime) {
         if (Util::isMaintenanceMode()) {
             self::removeTempTables();
             return;
         }
         Db::execute("delete from zz_participants_temporary");
         //Log::log("Fetching kills for processing...");
         $result = Db::query("select * from zz_killmails where processed = 0 order by killID desc limit 100", array(), 0);
         if (sizeof($result) == 0) {
             $currentSecond = (int) date("s");
             $sleepTime = max(1, 15 - $currentSecond % 15);
             sleep($sleepTime);
             continue;
         }
         //Log::log("Processing fetched kills...");
         $processedKills = array();
         $cleanupKills = array();
         foreach ($result as $row) {
             $numKills++;
             $kill = json_decode($row['kill_json'], true);
             if (!isset($kill["killID"])) {
                 Log::log("Problem with kill " . $row["killID"]);
                 Db::execute("update zz_killmails set processed = 2 where killid = :killid", array(":killid" => $row["killID"]));
                 continue;
             }
             $killID = $kill["killID"];
             Db::execute("insert ignore into zz_killid values(:killID, 0)", array(":killID" => $killID));
             // Cleanup if we're reparsing
             $cleanupKills[] = $killID;
             // Do some validation on the kill
             if (!self::validKill($kill)) {
                 Db::execute("update zz_killmails set processed = 3 where killid = :killid", array(":killid" => $row["killID"]));
                 continue;
             }
             $totalCost = 0;
             $itemInsertOrder = 0;
             $totalCost += self::processItems($kill, $killID, $kill["items"], $itemInsertOrder);
             $totalCost += self::processVictim($kill, $killID, $kill["victim"], false);
             foreach ($kill["attackers"] as $attacker) {
                 self::processAttacker($kill, $killID, $attacker, $kill["victim"]["shipTypeID"], $totalCost);
             }
             $points = Points::calculatePoints($killID, true);
             Db::execute("update zz_participants_temporary set points = :points, number_involved = :numI, total_price = :tp where killID = :killID", array(":killID" => $killID, ":points" => $points, ":numI" => sizeof($kill["attackers"]), ":tp" => $totalCost));
             $processedKills[] = $killID;
         }
         if (sizeof($cleanupKills)) {
             Db::execute("delete from zz_participants where killID in (" . implode(",", $cleanupKills) . ")");
         }
         Db::execute("insert into zz_participants select * from zz_participants_temporary");
         if (sizeof($processedKills)) {
             Db::execute("update zz_killmails set processed = 1 where killID in (" . implode(",", $processedKills) . ")");
         }
         foreach ($processedKills as $killID) {
             Stats::calcStats($killID, true);
             // Add points and total value to the json stored in the database
             $raw = Db::queryField("select kill_json from zz_killmails where killID = :killID", "kill_json", array(":killID" => $killID), 0);
             $json = json_decode($raw, true);
             unset($json["_stringValue"]);
             unset($json["zkb"]);
             $stuff = Db::queryRow("select * from zz_participants where killID = :killID and isVictim = 1", array(":killID" => $killID), 0);
             if ($stuff != null) {
                 $zkb = array();
                 $zkb["totalValue"] = $stuff["total_price"];
                 $zkb["points"] = $stuff["points"];
                 $json["zkb"] = $zkb;
             }
             $raw = json_encode($json);
             Db::execute("update zz_killmails set kill_json = :raw where killID = :killID", array(":killID" => $killID, ":raw" => $raw));
         }
     }
     if ($numKills > 0) {
         Log::log("Processed {$numKills} kills");
     }
     self::removeTempTables();
 }
コード例 #22
0
    $info['apistats'] = [];
    //Db::query("select errorCode, count(*) count from zz_api_log where requestTime >= date_sub(now(), interval 1 hour) group by 1");
    $apitable = '
	<table class="table table-striped table-hover table-bordered">
	  <tr><th>Error</th><th>Count</th></tr>';
    foreach ($info['apistats'] as $data) {
        $apitable .= '<tr>';
        $apitable .= '<td>';
        if ($data['errorCode'] == null) {
            $apitable .= 'No error';
        } else {
            $apitable .= $data['errorCode'];
        }
        $apitable .= '</td>';
        $apitable .= '<td>';
        $apitable .= number_format($data['count']);
        $apitable .= '</td>';
        $apitable .= '</tr>';
    }
    $apitable .= '</table>';
    $output = str_replace('{apitable}', $apitable, $output);
    $info['pointValues'] = Points::getPointValues();
    $pointtable = '<ul>';
    foreach ($info['pointValues'] as $points) {
        $pointtable .= '<li>' . $points[0] . ': ' . $points[1] . '</li>';
    }
    $pointtable .= '</ul>';
    $output = str_replace('{pointsystem}', $pointtable, $output);
}
// Load the information page html, which is just the bare minimum to load base.html and whatnot, and then spit out the markdown output!
$app->render('information.html', array('data' => $output));
コード例 #23
0
 /**
  * @Transform :points
  */
 public function transformPoints($string)
 {
     return Points::fromString($string);
 }