Exemple #1
0
/**
* 抛出json回执信息
* 
* @access public
* @param string $message 消息体
* @param string $charset 信息编码
* @return void
*/
function throwJson($message, $charset = NULL)
{
    /** 设置http头信息 */
    header('content-Type: application/json; charset=' . (empty($charset) ? 'UTF-8' : $charset), true);
    echo json::encode($message);
    /** 终止后续输出 */
    exit;
}
Exemple #2
0
 function batch($params)
 {
     $result = $this->request('POST', '/batch', [], $params);
     $array = [];
     foreach ($result as $name => $value) {
         $array[$name] = json::decode(json::encode($value));
         # TODO: Replace with fast solution
     }
     return $array;
 }
Exemple #3
0
 function prepStr($str)
 {
     global $CONF_use_utf, $langEncodings, $nativeLanguage;
     if (!$CONF_use_utf) {
         require_once dirname(__FILE__) . '/../ConvertCharset/ConvertCharset.class.php';
         $NewEncoding = new ConvertCharset();
         $str = $NewEncoding->Convert($str, $langEncodings[$nativeLanguage], "utf-8", $Entities);
     }
     $newStr = json::encode($str);
     if ($newStr[0] == '"') {
         return substr($newStr, 1, -1);
     } else {
         return $newStr;
     }
     // return str_replace('"','\"',$str);
 }
 function fetch_action() {
     $id = front::post('id');
     $tpl = str_replace('#','',$id);
     $tpid = $tpl;
     $tpl = str_replace('_d_','/',$tpl);
     $tpl = str_replace('_html','.html',$tpl);
     $tpl = str_replace('_css','.css',$tpl);
     $tpl = str_replace('_js','.js',$tpl);
     $res = array();
     $res['content'] = file_get_contents(TEMPLATE .'/'.config::get('template_dir') .'/'.$tpl);
     $res['content'] = preg_replace('%</textarea%','<&#47textarea',$res['content']);
     $res['content'] = "<textarea rows=\"20\" cols=\"78\" id=\"{$tpid}_content\" style=\"font-family: Fixedsys,verdana,宋体; font-size: 12px;\" name=\"{$tpid}_content\">$res[content]</textarea>";
     echo json::encode($res);
     exit;
 }
Exemple #5
0
<?php

require_once 'inc.config.php';
logincheck();
if (isset($_POST['order_units'])) {
    addProductions('ship,defence', $_POST['order_units']);
    $arrJson = array(array('eval', "\$('f_order_units').reset();"), array('html', 'div_productionlist', getProductionList('ship,defence')), array('msg', 'Productions added!'));
    foreach (db_select_fields('planet_resources', 'resource_id,amount', 'planet_id = ' . PLANET_ID) as $iResourceId => $iAmount) {
        $arrJson[] = array('html', 'res_amount_' . $iResourceId, nummertje($iAmount));
    }
    exit(json::encode($arrJson));
}
_header();
?>
<div class="header">Production<?php 
if ((int) $GAMEPREFS['havoc_production']) {
    echo ' (<b style="color:red;">HAVOC!</b>)';
}
?>
</div>

<br />

<?php 
echo getProductionForm('ship,defence');
?>

<br />

<div id="div_productionlist">
<?php 
Exemple #6
0
 function json_encode($value)
 {
     $json = new json();
     return $json->encode($value);
 }
 function dbfield_select_action() {
     $res=array();
     $res['content']='&nbsp;&nbsp;没有可以进行替换的字段。';
     $table=front::post('stable');
     if(@class_exists($table)) {
         $table=new $table;
         $_fields=array();
         foreach($table->getFields() as $field) {
             if(preg_match('/text|var/',$field['type']) &&!preg_match('/^[a-zA-Z_]+$/',lang($field['name'])))
                 $_fields[]=$field['name'];
         }
         $fields=array(0=>null);
         foreach($_fields as $field) $fields[$field]=lang($field);
         if(count($_fields)>0)
             $res['content']='&nbsp;&nbsp;字段=>'.form::select('sfield',0,$fields,'style="font-size:16px"');
     }
     $res['id']='fieldlist';
     echo json::encode($res);
     exit;
 }
Exemple #8
0
 public static function run_test()
 {
     $array = array('foo' => array('bar', 'baz' => array(1, 2, 3, 4, 5, 6, 7), array('a', 'b', 'c', 'd')), 'bar' => array(5, 4, 3, 2, 1), 'oop' => 'oxxxbj&%$ect oriented programming', 'baz' => array(1, 2, 3, 4, 5, array('a', array(1, 2, 3), 'b', 'x' => 'c')));
     header('content-type: text/plain');
     $json = new json();
     $string = $json->encode($array);
     $converted = $json->decode($string);
     print_r($converted);
 }
 function json_encode($array) {
     return json::encode($array);
 }
Exemple #10
0
define('SB_POSTED', (int) $GAMEINFO['small_blind'] <= (int) @mysql_result(@MQuery("SELECT bet FROM mpp_players WHERE gid = " . GAMEID . " AND uid = " . SMALLBLINDID . ";"), 0));
define('BB_POSTED', (int) $GAMEINFO['big_blind'] <= (int) @mysql_result(@MQuery("SELECT bet FROM mpp_players WHERE gid = " . GAMEID . " AND uid = " . BIGBLINDID . ";"), 0));
// var_dump(BIGBLINDID);
// Wie is er aan de beurt
define("UID_AAN_DE_BEURT", wie_is_aan_de_beurt());
// Zorgen dat UID Online blijft
MQuery("UPDATE mpp_players SET online=UNIX_TIMESTAMP(NOW()) WHERE uid = " . (int) $_SESSION['mpp']['uid'] . " AND gid = " . (int) $_SESSION['mpp']['gid'] . ";");
// En Offline players op OUT zetten
MQuery("UPDATE mpp_players SET in_or_out = 'out' WHERE gid = " . (int) $_SESSION['mpp']['gid'] . " AND online < " . (time() - 31) . ";");
/** HTML - STATUS WINDOW **/
if (isset($_GET['mode']) && $_GET['mode'] == 'status') {
    // Update keepalive
    MQuery("UPDATE mpp_players SET online = " . time() . " WHERE uid = " . (int) $_SESSION['mpp']['uid'] . " AND gid = " . (int) $_SESSION['mpp']['gid'] . ";");
    $arrGame = mysql_fetch_assoc(MQuery('SELECT * FROM mpp_games WHERE id = ' . (int) $_SESSION['mpp']['gid'] . ';'));
    require_once 'inc.cls.json_php5.php';
    echo json::encode(array('game' => array('dealer' => (int) $arrGame['dealer'], 'turn' => (int) wie_is_aan_de_beurt(), 'pot' => (double) $arrGame['pot'], 'last_win' => (int) $arrGame['last_win']), '_status' => UID_AAN_DE_BEURT == $_SESSION['mpp']['uid'] ? 'IT\'S YOUR TURN' : '...', 'seat_1' => printSeat(1), 'seat_2' => printSeat(2), 'seat_3' => printSeat(3), 'seat_4' => printSeat(4), 'seat_5' => printSeat(5), 'seat_6' => printSeat(6), 'seat_7' => printSeat(7), 'center_flop' => Print_Flop()));
    exit;
    // Let page know it's your turn
    if (UID_AAN_DE_BEURT == $_SESSION['mpp']['uid']) {
        exit('IT\'S YOUR TURN');
    }
    exit('...');
}
/** PROCESS - SMALL BLIND **/
if (isset($_POST['small_blind']) && SMALLBLINDID == USERID && READY_GAME) {
    $bet = (int) $GAMEINFO['small_blind'];
    // Posting small blind
    MQuery("UPDATE mpp_players SET bet = bet+" . $bet . ", balance = balance-" . $bet . ", ready_for_next_round = 'no' WHERE gid='" . GAMEID . "' AND uid='" . USERID . "';");
    MQuery("UPDATE mpp_games SET pot=pot+" . $bet . " WHERE id='" . GAMEID . "' AND player_turn='" . USERID . "';");
    // Beurt naar volgende speler
    beurt_naar_volgende_speler(USERID);
Exemple #11
0
 public function edit()
 {
     $this->assertLoggedIn();
     $this->set('area', 'bots');
     try {
         //how do we find them?
         if ($this->args('id')) {
             $bot = new Bot($this->args('id'));
         } else {
             throw new Exception("Could not find that bot.");
         }
         //did we really get someone?
         if (!$bot->isHydrated()) {
             throw new Exception("Could not find that bot.");
         }
         if (!$bot->isMine()) {
             throw new Exception("You cannot view that bot.");
         }
         $this->setTitle('Edit Bot - ' . $bot->getName());
         $wizard = new Wizard('bot', $this->args());
         if (!$this->args('setup')) {
             $wizard->disableWizardMode();
         }
         // Create our forms
         $infoForm = $this->_createInfoForm($bot);
         $queuesForm = $this->_createQueueForm($bot);
         $slicingForm = $this->_createSlicingForm($bot);
         $driverForm = $this->_createDriverForm($bot);
         // Add them to the wizard
         $wizard->add("Information / Details", $infoForm);
         $wizard->add("Queues", $queuesForm);
         $wizard->add("Slicing Setup", $slicingForm);
         $wizard->add("Driver Configuration", $driverForm);
         //handle our forms
         if ($infoForm->checkSubmitAndValidate($this->args())) {
             $bot->set('name', $infoForm->data('name'));
             $bot->set('manufacturer', $infoForm->data('manufacturer'));
             $bot->set('model', $infoForm->data('model'));
             $bot->set('electronics', $infoForm->data('electronics'));
             $bot->set('firmware', $infoForm->data('firmware'));
             $bot->set('extruder', $infoForm->data('extruder'));
             $bot->save();
             Activity::log("edited the information for bot " . $bot->getLink() . ".");
         } else {
             if ($queuesForm->checkSubmitAndValidate($this->args())) {
                 $sql = "DELETE FROM bot_queues WHERE bot_id = ?";
                 db()->execute($sql, array($bot->id));
                 $priority = 1;
                 $used = array();
                 foreach ($this->args() as $key => $value) {
                     if (substr($key, 0, 6) === "queue-" && $value != 0) {
                         if (in_array($value, $used)) {
                             continue;
                         } else {
                             $used[] = $value;
                         }
                         $sql = "INSERT INTO bot_queues VALUES(?, ?, ?)";
                         $data = array($value, $bot->id, $priority);
                         $priority++;
                         db()->execute($sql, $data);
                     }
                 }
             } else {
                 if ($slicingForm->checkSubmitAndValidate($this->args())) {
                     $bot->set('slice_engine_id', $slicingForm->data('slice_engine_id'));
                     $bot->set('slice_config_id', $slicingForm->data('slice_config_id'));
                     $config = $bot->getDriverConfig();
                     $config->can_slice = (bool) $slicingForm->data('can_slice');
                     $bot->set('driver_config', json::encode($config));
                     $bot->save();
                     Activity::log("edited the slicing info for bot " . $bot->getLink() . ".");
                 } else {
                     if ($driverForm->checkSubmitAndValidate($this->args())) {
                         $bot->set('oauth_token_id', $driverForm->data('oauth_token_id'));
                         $bot->set('driver_name', $driverForm->data('driver_name'));
                         //create and save our config
                         $config = $bot->getDriverConfig();
                         $config->driver = $bot->get('driver_name');
                         if ($bot->get('driver_name') == 'dummy') {
                             if ($this->args('delay')) {
                                 $config->delay = $this->args('delay');
                             }
                         } elseif ($bot->get('driver_name') == 'printcore' || $bot->get('driver_name') == 's3g') {
                             $config->port = $this->args('serial_port');
                             $config->port_id = $this->args('port_id');
                             $config->baud = $this->args('baudrate');
                         }
                         //did we get webcam info?
                         if ($this->args('webcam_device')) {
                             if (!isset($config->webcam)) {
                                 $config->webcam = new stdClass();
                             }
                             $config->webcam->device = $this->args('webcam_device');
                             if ($this->args('webcam_id')) {
                                 $config->webcam->id = $this->args('webcam_id');
                             }
                             if ($this->args('webcam_name')) {
                                 $config->webcam->name = $this->args('webcam_name');
                             }
                             if ($this->args('webcam_brightness')) {
                                 $config->webcam->brightness = (int) $this->args('webcam_brightness');
                             }
                             if ($this->args('webcam_contrast')) {
                                 $config->webcam->contrast = (int) $this->args('webcam_contrast');
                             }
                         } else {
                             unset($config->webcam);
                         }
                         //save it all to the bot as json.
                         $bot->set('driver_config', json::encode($config));
                         $bot->save();
                         Activity::log("edited the driver configuration for bot " . $bot->getLink() . ".");
                     }
                 }
             }
         }
         if ($wizard->isFinished()) {
             $this->forwardToURL($bot->getUrl());
         }
         $this->set('bot_id', $bot->id);
         $this->set('wizard', $wizard);
     } catch (Exception $e) {
         $this->set('megaerror', $e->getMessage());
         $this->setTitle("Bot Edit - Error");
     }
 }
 /**
  * Returns the processed js options
  * @return array
  */
 public function getOptions()
 {
     return $this->options ? json::encode($this->options) : '{}';
 }
    public function run()
    {
        if (isset($this->htmlOptions['id'])) {
            $id = $this->htmlOptions['id'];
        }
        if (isset($this->htmlOptions['name'])) {
            $name = $this->htmlOptions['name'];
        }
        //        if ($this->hasModel()) {
        //            echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions);
        //        }
        echo Html::hiddenInput($this->attribute, $this->value, $this->htmlOptions);
        $fileManagerOptions = ['csrfTokenName' => Yii::$app->request->csrfParam, 'csrfToken' => yii::$app->request->csrfToken, 'pickerSelector' => '#' . $this->fileManagerContainerId . 'Uploader', 'createFileRoute' => Url::toRoute('//fileManager/createFile'), 'createDirectoryRoute' => Url::toRoute('//fileManager/createDirectory'), 'deleteFileRoute' => Url::toRoute('//fileManager/deleteFile'), 'deleteDirectoryRoute' => Url::toRoute('//fileManager/deleteDirectory'), 'listFile' => Url::toRoute('//fileManager/listFile'), 'fileIdInputSelector' => '#' . $id];
        $gOptions = json::encode($fileManagerOptions);
        $js = <<<EOD
jQuery('#{$this->fileManagerContainerId}').fileManager({$gOptions});
EOD;
        $this->getView()->registerJs($js, \yii\web\View::POS_END);
        return $this->render('fileManager/views/view', ['fileManagerContainerId' => $this->fileManagerContainerId]);
    }
<?php

require_once 'inc.config.php';
logincheck();
if (isset($_POST['x'], $_POST['y'], $_POST['z'], $_POST['message'])) {
    $iPlanetId = db_select_one('galaxies g, planets p', 'p.id', 'p.galaxy_id = g.id AND g.x = ' . (int) $_POST['x'] . ' AND g.y = ' . (int) $_POST['y'] . ' AND p.z = ' . (int) $_POST['z']);
    if (false === $iPlanetId) {
        exit(json::encode(array(array('msg', 'Planet not found!'))));
    }
    if (!db_insert('mail', array('to_planet_id' => $iPlanetId, 'from_planet_id' => PLANET_ID, 'utc_sent' => time(), 'myt_sent' => $GAMEPREFS['tickcount'], 'message' => $_POST['message']))) {
        exit(json::encode(array(array('msg', 'Mail delivery failed!'))));
    }
    exit(json::encode(array(array('msg', 'Mail sent!'))));
}
_header();
?>
<div class="header">Communication</div>

<br />

Send mail:<br />
<form action="communication.php" method="post" onsubmit="return postForm(this,H);" autocomplete="off">
<table border="0" cellpadding="2" cellspacing="0">
<tr valign="top">
	<td>To:</td>
	<td>
		<input type="text" id="recip_x" name="x" style="width:30;text-align:center;" value="<?php 
echo isset($_GET['x']) ? (int) $_GET['x'] : 'X';
?>
" onfocus="this.select();"> :
		<input type="text" id="recip_y" name="y" style="width:30;text-align:center;" value="<?php 
Exemple #15
0
}
div.set span.card {
	background-color	: gold;
}
</style>
<script type="text/javascript">
<!--//
var ROWS = 8, COOKIENAME = '<?php 
echo S_NAME . '_balance';
?>
', g_iBalance = Cookie.get(COOKIENAME).toInt();
var g_iBetBase = <?php 
echo max(1, min(10, isset($_GET['base']) ? (int) $_GET['base'] : 1));
?>
, g_arrCards = <?php 
echo json::encode($arrCards);
?>
, g_iMultiplier = 1, g_iRow = 0, g_bGateCard = true, g_bGameOver = false;
function nextRow() {
	if ( 0 === g_iRow ) {
		return initTower();
	}
	return fillAndShowRow(++g_iRow);
}
function burnCard(r, c) {
	$('c'+r+''+c).style.backgroundColor = 'black';
	return false;
}
function unburnCard(r, c) {
	$('c'+r+''+c).style.backgroundColor = '';
	return false;
Exemple #16
0
                        $_SESSION[$sessionname] = $save;
                        if ($arrUser['sleep'] > time()) {
                            db_update('planets', 'nextsleep=' . (time() + 14 * 3600) . ' WHERE id = ' . (int) $arrUser['id'] . ';');
                            $arrUser['nextsleep'] = time() + 14 * 3600;
                        }
                        db_update('planets', 'sleep = 0, lastaction = ' . time() . ', lastlogin = '******'" . $save['unihash'] . "'", 'id = ' . (int) $arrUser['id']);
                        logbook('login', 'unihash=' . $save['unihash'] . '&sleep=' . $arrUser['sleep'] . '&nextsleep=' . $arrUser['nextsleep'], (int) $save['planet_id']);
                        exit(json::encode(array(array('eval', 'document.location.reload()'))));
                    }
                }
            }
        }
    }
    // END 1 === count($arrUser)
    // No records found for this username & password
    exit(json::encode(array(array('msg', 'Invalid login combination!'))));
} else {
    if (isset($_POST['pwdvergeten'])) {
        $q = db_query("SELECT id,email,password FROM planets WHERE email = '{$_POST['email']}';");
        if (0 < mysql_num_rows($q)) {
            $i = mysql_fetch_assoc($q);
            $newpwd = substr(md5(time()), 0, 12);
            db_query("UPDATE planets SET password ='******'id'] . ':' . $newpwd) . "' WHERE id = " . (int) $i['id'] . ";");
            logbook('pwd_reminder', 'email=' . $i['email'] . '&new=' . $newpwd, (int) $i['id']);
            $gameaddress = str_replace("index.php", "misc.php", $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']);
            $gamename0 = str_replace("www.", "", $_SERVER['HTTP_HOST']);
            $gamename = "PS " . $gamename0 . " LOGIN";
            $headers = "From: PornStarS PASSWORD <pornstars@" . $gamename0 . ">\r\n";
            $headers .= "Return-Path: <pornstars@" . $gamename0 . ">\r\n";
            $headers .= "X-Sender: <pornstars@" . $gamename0 . ">\r\n";
            $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
Exemple #17
0
 public function api_devicescanresults()
 {
     //$old_scan_data = json::decode($this->token->get('device_data'));
     $scan_data = json::decode($this->args('scan_data'));
     //var_dump($scan_data);
     if (!empty($_FILES)) {
         // We currently don't want to delete the old data
         //			//delete any old files if we have them.
         //			if (!empty($old_scan_data->camera_files)) {
         //				foreach ($old_scan_data->camera_files AS $id) {
         //					$data_file = Storage::get($id);
         //					$data_file->delete();
         //				}
         //			}
         foreach ($_FILES as $file) {
             if (is_uploaded_file($file['tmp_name'])) {
                 $filename = $file['name'];
                 $filename = str_replace(" ", "_", $filename);
                 $filename = preg_replace("/[^-_.[0-9a-zA-Z]/", "", $filename);
                 $this->ensureGoodFile($file);
                 //okay, we're good.. do it.
                 $data_file = Storage::newFile();
                 $data_file->set('user_id', User::$me->id);
                 $data_file->upload($file['tmp_name'], StorageInterface::getNiceDir($filename));
                 $scan_data->camera_files[] = $data_file->id;
             }
         }
     }
     //var_dump($scan_data);
     //var_dump($_FILES);
     $this->token->set('device_data', json::encode($scan_data));
     $this->token->set('last_seen', date('Y-m-d H:i:s'));
     $this->token->save();
     return True;
 }
Exemple #18
0
 function json_encode($string)
 {
     require_once 'json.class.php';
     $json = new json();
     return $json->encode($string);
 }
 function makeJSON($forceRefresh = 0)
 {
     global $CONF;
     // $forceRefresh=1;
     $filename = $this->getJsonFilename();
     if (is_file($filename) && !$forceRefresh) {
         return;
     }
     // if no file exists do the proccess now
     if (!is_file($this->getPointsFilename(1)) || $forceRefresh) {
         $this->storeIGCvalues();
     }
     $lines = file($this->getPointsFilename(1));
     // get the normalized with constant time step points array
     if (!$lines) {
         return;
     }
     $i = 0;
     $jsTrack['max_alt'] = 0;
     $jsTrack['min_alt'] = 100000;
     // first 3 lines of pointsFile is reserved for info
     for ($k = 3; $k < count($lines); $k++) {
         $line = trim($lines[$k]);
         if (strlen($line) == 0) {
             continue;
         }
         //DEBUG("IGC", 1, "GUS PointsFilename [$k]: $line<br>");
         eval($line);
         //	if ($alt > $this->maxAllowedHeight)  continue;
         //    if ($speed > $this->maxAllowedSpeed) continue;
         //    if (abs($vario) > $this->maxAllowedVario) continue;
         //if ($time < $lastPointTime) continue;
         //$lastPointTime = $time;
         //if (! $time_in_secs ) {
         //	$time = sec2Time($time, 1);
         //}
         $jsTrack['time'][$i] = $time;
         $jsTrack['elev'][$i] = $alt;
         $jsTrack['elevV'][$i] = $altV;
         $jsTrack['lat'][$i] = sprintf('%0.6f', $lat);
         $jsTrack['lon'][$i] = sprintf('%0.6f', -$lon);
         $jsTrack['speed'][$i] = sprintf('%.2f', $speed);
         $jsTrack['vario'][$i] = sprintf('%.2f', $vario);
         if ($CONF['maps']['3d']) {
             require_once dirname(__FILE__) . '/CL_hgt.php';
             $jsTrack['elevGnd'][$i] = $elevGnd[$i] = hgt::getHeight($lat, -$lon);
         } else {
             $jsTrack['elevGnd'][$i] = 0;
         }
         if ($jsTrack['elevGnd'][$i] > $jsTrack['max_alt']) {
             $jsTrack['max_alt'] = $jsTrack['elevGnd'][$i];
         }
         if ($jsTrack['elev'][$i] > $jsTrack['max_alt']) {
             $jsTrack['max_alt'] = $jsTrack['elev'][$i];
         }
         if ($jsTrack['elevGnd'][$i] < $jsTrack['min_alt']) {
             $jsTrack['min_alt'] = $jsTrack['elevGnd'][$i];
         }
         if ($jsTrack['elev'][$i] < $jsTrack['min_alt']) {
             $jsTrack['min_alt'] = $jsTrack['elev'][$i];
         }
         if ($i == 0) {
             $dis = 0;
             $firstLat = $lat;
             $firstLon = $lon;
         }
         $jsTrack['distance'][$i] = sprintf('%.3f', $dis);
         $i++;
     }
     //end for loop
     /*
     		 Change the number of points to CHART_NBPTS
     		for ($i = 0, $idx = 0, $step = ($nbPts - 1) / (CHART_NBPTS - 1); $i < CHART_NBPTS; $i++, $idx += $step) {
     			$jsTrack['elev'][$i] = $track['elev'][$idx];
     			$jsTrack['time']['hour'][$i] = $track['time']['hour'][$idx];
     			$jsTrack['time']['min'][$i] = $track['time']['min'][$idx];
     			$jsTrack['time']['sec'][$i] = $track['time']['sec'][$idx];
     		}
     */
     $nbPts = count($jsTrack['time']);
     $label_num = 8;
     for ($i = 0, $idx = 0, $step = ($nbPts - 1) / ($label_num - 1); $i < $label_num; $i++, $idx += $step) {
         $jsTrack['labels'][$i] = $jsTrack['time'][$idx];
     }
     // 			$jsTrack['labels']=array("11h40","12h6","12h29","12h52","13h15");
     $jsTrack['points_num'] = $nbPts;
     $jsTrack['nbChartPt'] = $nbPts;
     $jsTrack['label_num'] = $label_num;
     $jsTrack['date'] = $this->DATE;
     require_once dirname(__FILE__) . '/lib/json/CL_json.php';
     $JSONstr = json::encode($jsTrack);
     writeFile($filename, 'var flightArray=' . $JSONstr);
 }
    function cut_image_action() {
    	$len = 1;
    	if(config::get('base_url') != '/'){
    		$len = strlen(config::get('base_url'))+1;
    	}
    	if(substr($_POST['pic'],0,4) == 'http'){
    		front::$post['thumb'] = str_ireplace(config::get('site_url'),'',$_POST['pic']);
    	}else{
    		front::$post['thumb'] = substr($_POST['pic'],$len);
    	}
        $thumb=new thumb();
        $thumb->set(front::$post['thumb'],'jpg');
        $img=$thumb->create_image($thumb->im,$_POST['w'],$_POST['h'],0,0,$_POST['x1'],$_POST['y1'],$_POST['x2'] -$_POST['x1'],$_POST['y2'] -$_POST['y1']);
        $new_name=$new_name_gbk=str_replace('.','',Time::getMicrotime()).'.'.end(explode('.',$_POST['pic']));
        $save_file='upload/images/'.date('Ym').'/'.$new_name;
        @mkdir(dirname(ROOT.'/'.$save_file));
        ob_start();
        $thumb->out_image($img,null,85);
        file_put_contents(ROOT.'/'.$save_file,ob_get_contents());
        ob_end_clean();
        $image_url=config::get('base_url').'/'.$save_file;
        //$res['size']=ceil(strlen($img) / 1024);
        $res['code']="
                 //$('#cut_preview').attr('src','$image_url');
                 $('#thumb').val('$image_url');
				 alert('保存成功');
                ";
        echo json::encode($res);
    }
Exemple #21
0
function jsonEncode($ary)
{
    $json = new json();
    return $json->encode($ary);
}
Exemple #22
0
                            $szHTML .= '</td></tr>';
                        }
                        $szHTML .= '</table>';
                        break;
                    default:
                        exit(json::encode(array(array('msg', 'Invalid scan [' . (int) $arrScan['scan_id'] . ']!'), $arrScansLeftAjaxUpdate)));
                        break;
                }
                // PRINT SUCCESS
                exit(json::encode(array($arrScansLeftAjaxUpdate, array('html', 'div_scanresults', $szHTML), array('eval', "\$('div_scanresults').style.border='solid 1px red';\$('div_scanresults').style.marginBottom='15px;';"))));
            }
            // YOU FAILED
            if ((int) $arrTarget['id'] !== PLANET_ID) {
                AddNews(NEWS_SUBJECT_WAVES, '<b>' . $g_arrUser['rulername'] . ' of ' . $g_arrUser['planetname'] . '</b> (' . $g_arrUser['x'] . ':' . $g_arrUser['y'] . ':' . $g_arrUser['z'] . ') tried to <b>' . $arrScan['unit'] . '</b> you, but he failed!', $arrTarget['id']);
            }
            exit(json::encode(array($arrScansLeftAjaxUpdate, array('msg', 'You failed scanning the target!'))));
        }
    }
}
// END if ( isset($_GET['intel_scan_id'], $_GET['x'], $_GET['y'], $_GET['z']) )
_header();
?>
<div id="div_scanresults"></div>

<div class="header">Scans</div>

<br />

<table border="0" cellpadding="4" cellspacing="0" width="600" align="center">
<tr class="bb">
	<th>Type</th>
Exemple #23
0
 public function addAction()
 {
     // Get uid
     $uid = Pi::user()->getId();
     // Check order is active or inactive
     if (!$this->config('order_active')) {
         $this->getResponse()->setStatusCode(401);
         $this->terminate(__('So sorry, At this moment order is inactive'), '', 'error-denied');
         $this->view()->setLayout('layout-simple');
         return;
     }
     // Set template
     $this->view()->setTemplate(false);
     // check order module
     if (Pi::service('module')->isActive('order')) {
         // Get info from url
         $module = $this->params('module');
         $id = $this->params('id');
         // Check id
         if (!$id) {
             $this->getResponse()->setStatusCode(401);
             $this->terminate(__('You need select plan'), '', 'error-denied');
             $this->view()->setLayout('layout-simple');
             return;
         }
         // Get plan
         $plan = Pi::api('plans', 'plans')->getPlan($id);
         // Check plan
         if (!$plan || $plan['status'] != 1) {
             $this->getResponse()->setStatusCode(401);
             $this->terminate(__('You need select plan'), '', 'error-denied');
             $this->view()->setLayout('layout-simple');
             return;
         }
         // Set extra
         $extra = array();
         $extra['view_type'] = 'template';
         $extra['view_template'] = 'order-detail';
         $extra['getDetail'] = true;
         // Set singel Product
         $singleProduct = array('product' => $plan['id'], 'product_price' => $plan['price'], 'discount_price' => 0, 'shipping_price' => 0, 'setup_price' => 0, 'packing_price' => 0, 'vat_price' => $plan['vat'], 'number' => 1, 'title' => $plan['title'], 'extra' => json::encode($extra));
         // Set order array
         $order = array();
         $order['module_name'] = $module;
         $order['module_item'] = $plan['id'];
         $order['type_payment'] = 'recurring';
         $order['type_commodity'] = 'service';
         $order['product'][$plan['id']] = $singleProduct;
         // Set session_order if user not login
         if ($uid == 0) {
             $_SESSION['session_order'] = $singleProduct;
         }
         // Set and go to order
         $url = Pi::api('order', 'order')->setOrderInfo($order);
         Pi::service('url')->redirect($url);
     } else {
         $this->getResponse()->setStatusCode(401);
         $this->terminate(__('Order module not installed'), '', 'error-denied');
         $this->view()->setLayout('layout-simple');
         return;
     }
 }
 static function json_encode_k($array)
 {
     if (function_exists('json_encode')) {
         return json_encode($array);
     } else {
         require_once S_ROOT . 'lib/helper/keke_json_class.php';
         $json_obj = new json();
         return $json_obj->encode($array);
     }
 }
 private function uploadMultipleFile($model, $tempFile = null)
 {
     $files = [];
     $json = '';
     $tempFile = Json::decode($tempFile);
     $UploadedFiles = UploadedFile::getInstances($model, 'docs');
     if ($UploadedFiles !== null) {
         foreach ($UploadedFiles as $file) {
             try {
                 $oldFileName = $file->basename . '.' . $file->extension;
                 $newFileName = md5($file->basename . time()) . '.' . $file->extension;
                 $file->saveAs(Freelance::UPLOAD_FOLDER . '/' . $model->ref . '/' . $newFileName);
                 $files[$newFileName] = $oldFileName;
             } catch (Exception $e) {
             }
         }
         $json = json::encode(ArrayHelper::merge($tempFile, $files));
     } else {
         $json = $tempFile;
     }
     return $json;
 }
Exemple #26
0
 public function edit()
 {
     $this->assertLoggedIn();
     $this->set('area', 'bots');
     try {
         //how do we find them?
         if ($this->args('id')) {
             $bot = new Bot($this->args('id'));
         } else {
             throw new Exception("Could not find that bot.");
         }
         //did we really get someone?
         if (!$bot->isHydrated()) {
             throw new Exception("Could not find that bot.");
         }
         if (!$bot->isMine()) {
             throw new Exception("You cannot view that bot.");
         }
         $this->setTitle('Edit Bot - ' . $bot->getName());
         //load up our form.
         $infoForm = $this->_createInfoForm($bot);
         if ($this->args('setup') != '') {
             $infoForm->setSubmitText('Next');
         }
         $slicingForm = $this->_createSlicingForm($bot);
         if ($this->args('setup') != '') {
             $slicingForm->setSubmitText('Next');
         }
         $driverForm = $this->_createDriverForm($bot);
         if ($this->args('setup') != '') {
             $this->set('active_form', $this->args('setup'));
             $this->set('setup_mode', true);
         } else {
             $this->set('active_form', 'info');
             $this->set('setup_mode', false);
         }
         //handle our form
         if ($infoForm->checkSubmitAndValidate($this->args())) {
             $bot->set('name', $infoForm->data('name'));
             $bot->set('manufacturer', $infoForm->data('manufacturer'));
             $bot->set('model', $infoForm->data('model'));
             $bot->set('electronics', $infoForm->data('electronics'));
             $bot->set('firmware', $infoForm->data('firmware'));
             $bot->set('extruder', $infoForm->data('extruder'));
             $bot->save();
             Activity::log("edited the information for bot " . $bot->getLink() . ".");
             if ($this->args('setup') == 'info') {
                 $this->forwardToURL($bot->getUrl() . "/edit/setup:slicing");
             } else {
                 $this->forwardToURL($bot->getUrl());
             }
         } else {
             if ($slicingForm->checkSubmitAndValidate($this->args())) {
                 $bot->set('queue_id', $slicingForm->data('queue_id'));
                 $bot->set('slice_engine_id', $slicingForm->data('slice_engine_id'));
                 $bot->set('slice_config_id', $slicingForm->data('slice_config_id'));
                 $config = $bot->getDriverConfig();
                 $config->can_slice = (bool) $slicingForm->data('can_slice');
                 $bot->set('driver_config', json::encode($config));
                 $bot->save();
                 Activity::log("edited the slicing info for bot " . $bot->getLink() . ".");
                 if ($this->args('setup') == 'slicing') {
                     $this->forwardToURL($bot->getUrl() . "/edit/setup:driver");
                 } else {
                     $this->forwardToURL($bot->getUrl());
                 }
             } else {
                 if ($driverForm->checkSubmitAndValidate($this->args())) {
                     $bot->set('oauth_token_id', $driverForm->data('oauth_token_id'));
                     $bot->set('driver_name', $driverForm->data('driver_name'));
                     //create and save our config
                     $config = $bot->getDriverConfig();
                     $config->driver = $bot->get('driver_name');
                     if ($bot->get('driver_name') == 'dummy') {
                         if ($this->args('delay')) {
                             $config->delay = $this->args('delay');
                         }
                     } elseif ($bot->get('driver_name') == 'printcore') {
                         $config->port = $this->args('serial_port');
                         $config->port_id = $this->args('port_id');
                         $config->baud = $this->args('baudrate');
                     }
                     //did we get webcam info?
                     if ($this->args('webcam_device')) {
                         $config->webcam->device = $this->args('webcam_device');
                         if ($this->args('webcam_id')) {
                             $config->webcam->id = $this->args('webcam_id');
                         }
                         if ($this->args('webcam_name')) {
                             $config->webcam->name = $this->args('webcam_name');
                         }
                         if ($this->args('webcam_brightness')) {
                             $config->webcam->brightness = (int) $this->args('webcam_brightness');
                         }
                         if ($this->args('webcam_contrast')) {
                             $config->webcam->contrast = (int) $this->args('webcam_contrast');
                         }
                     } else {
                         unset($config->webcam);
                     }
                     //save it all to the bot as json.
                     $bot->set('driver_config', json::encode($config));
                     $bot->save();
                     Activity::log("edited the driver configuration for bot " . $bot->getLink() . ".");
                     $this->forwardToUrl($bot->getUrl());
                 }
             }
         }
         $this->set('bot', $bot);
         $this->set('info_form', $infoForm);
         $this->set('slicing_form', $slicingForm);
         $this->set('driver_form', $driverForm);
     } catch (Exception $e) {
         $this->set('megaerror', $e->getMessage());
         $this->setTitle("Bot Edit - Error");
     }
 }
 public function addAction()
 {
     // Get uid
     $uid = Pi::user()->getId();
     // Get info from url
     $module = $this->params('module');
     // Check order is active or inactive
     if (!$this->config('order_active')) {
         $this->getResponse()->setStatusCode(401);
         $this->terminate(__('So sorry, At this moment order is inactive'), '', 'error-denied');
         $this->view()->setLayout('layout-simple');
         return;
     }
     // Check post
     if ($this->request->isPost()) {
         // Get post
         $data = $this->request->getPost()->toArray();
         // Set number
         if (isset($data['number']) && intval($data['number']) > 0) {
             $number = intval($data['number']);
         } else {
             $number = 1;
         }
         // Check id
         if (!intval($data['id'])) {
             $this->getResponse()->setStatusCode(401);
             $this->terminate(__('You need select event'), '', 'error-denied');
             $this->view()->setLayout('layout-simple');
             return;
         }
         // check order module
         if (Pi::service('module')->isActive('order') && !empty($data)) {
             // Find event
             $event = Pi::api('event', 'event')->getEventSingle(intval($data['id']), 'id', 'full');
             // Check event
             if (!$event || $event['status'] != 1) {
                 $this->getResponse()->setStatusCode(404);
                 $this->terminate(__('The event not found.'), '', 'error-404');
                 $this->view()->setLayout('layout-simple');
                 return;
             }
             // Check can register
             if (!$event['register_can']) {
                 $message = __('This event not available for registration');
                 $this->jump($event['eventUrl'], $message, 'error');
             }
             // Check capacity
             if ($event['register_stock'] === 0 || $event['register_stock'] < $number) {
                 $message = __('This event do not have enough capacity');
                 $this->jump($event['eventUrl'], $message, 'error');
             }
             // Set extra
             $extra = array();
             $extra['view_type'] = 'template';
             $extra['view_template'] = 'order-detail';
             $extra['getDetail'] = true;
             // Set singel Product
             $singleProduct = array('product' => $event['id'], 'product_price' => $event['register_price'], 'discount_price' => 0, 'shipping_price' => 0, 'setup_price' => 0, 'packing_price' => 0, 'vat_price' => 0, 'number' => $number, 'title' => $event['title'], 'extra' => json::encode($extra));
             // Set order array
             $order = array();
             $order['module_name'] = $module;
             $order['module_item'] = $event['id'];
             $order['type_payment'] = 'onetime';
             $order['type_commodity'] = 'service';
             $order['product'][$event['id']] = $singleProduct;
             // Set session_order if user not login
             if ($uid == 0) {
                 $_SESSION['session_order'] = array('module' => 'event', 'value' => $singleProduct);
             }
             // Set and go to order
             $url = Pi::api('order', 'order')->setOrderInfo($order);
             Pi::service('url')->redirect($url);
         } else {
             $this->getResponse()->setStatusCode(401);
             $this->terminate(__('Order module not installed'), '', 'error-denied');
             $this->view()->setLayout('layout-simple');
             return;
         }
     } else {
         $url = array('', 'controller' => 'register', 'action' => 'index');
         return $this->redirect()->toRoute('', $url);
     }
 }
Exemple #28
0
    }
    echo '</td></tr>';
}
?>
    </table>
    </form>
</div>

<script type="text/javascript">
<!--
var itemsData = <?php 
echo json::encode($jsonItems);
?>
;
var fieldOrder = <?php 
echo json::encode(array_keys($fields));
?>
;

function pad(number, length) {
    var str = '' + number;
    while (str.length < length) {
        str = '0' + str;
    }
    return str;
}

var handleCRUDRow = function(row, data)
{
    var children = row.children('td');
    children.eq(0).text(pad(data.id,4));
Exemple #29
0
 private static function digest($mixed)
 {
     return hash_hmac(self::$algorithm, json::encode($mixed), self::$salt);
 }
 public function actionHarga($ID)
 {
     // $location=Locations::find()->where(['zip_code'=>$zipId])->one();
     $location = Kurir::findOne($ID);
     echo json::encode($location);
 }