本文整理汇总了PHP中json::prepStr方法的典型用法代码示例。如果您正苦于以下问题:PHP json::prepStr方法的具体用法?PHP json::prepStr怎么用?PHP json::prepStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类json
的用法示例。
在下文中一共展示了json::prepStr方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportXML
function exportXML($forceProtocol = '')
{
global $CONF_server_id, $CONF_photosPerFlight, $CONF;
if ($forceProtocol == '') {
if ($CONF['sync']['protocol']['format'] == 'JSON') {
$useJSON = 1;
require_once dirname(__FILE__) . '/lib/json/CL_json.php';
} else {
$useJSON = 0;
}
} else {
if ($forceProtocol == 'XML') {
$useJSON = 0;
} else {
$useJSON = 1;
}
}
$link = htmlspecialchars("http://" . $_SERVER['SERVER_NAME'] . getLeonardoLink(array('op' => 'show_waypoint', 'waypointIDview' => $this->waypointID)));
if (!$useJSON) {
return "<waypoint>\n<id>" . htmlspecialchars($this->waypointID) . "</id>\n<name>" . htmlspecialchars($this->name) . "</name>\n<intName>" . htmlspecialchars($this->intName) . "</intName>\n<location>" . htmlspecialchars($this->location) . "</location>\n<intLocation>" . htmlspecialchars($this->intLocation) . "</intLocation>\n<countryCode>" . htmlspecialchars($this->countryCode) . "</countryCode>\n<type>" . htmlspecialchars($this->type) . "</type>\n<lat>" . htmlspecialchars($this->lat()) . "</lat>\n<lon>" . htmlspecialchars($this->lon()) . "</lon>\n<link>" . htmlspecialchars($this->link) . "</link>\n<displayLink>" . $link . "</displayLink>\n<description>" . htmlspecialchars($this->description) . "</description>\n<modifyDate>" . htmlspecialchars($this->modifyDate) . "</modifyDate>\n</waypoint>";
} else {
return '{
"waypoint": {
"id" : ' . ($this->waypointID + 0) . ',
"name" : "' . json::prepStr($this->name) . '",
"intName" : "' . json::prepStr($this->intName) . '",
"location" : "' . json::prepStr($this->location) . '",
"intLocation" : "' . json::prepStr($this->intLocation) . '",
"countryCode" : "' . json::prepStr($this->countryCode) . '",
"type" : ' . ($this->type + 0) . ',
"lat" : ' . $this->lat() . ',
"lon" : ' . $this->lon() . ',
"link" : "' . json::prepStr($this->link) . '",
"displayLink" : "' . json::prepStr($link) . '",
"description" : "' . json::prepStr($this->description) . '",
"modifyDate" : "' . json::prepStr($this->modifyDate) . '"
}
}';
}
}
示例2: renameTracklog
function renameTracklog($newName, $oldName = '')
{
global $db;
global $flightsTable;
global $CONF_server_id;
if ($oldName) {
$orgFilename = $this->filename;
$this->filename = $oldName;
}
$this->deleteSecondaryFiles();
$this->deleteFile($this->getMapFilename());
for ($metric_system = 1; $metric_system <= 2; $metric_system++) {
for ($raw = 0; $raw <= 1; $raw++) {
$this->deleteFile($this->getChartFilename("alt", $metric_system, $raw));
$this->deleteFile($this->getChartFilename("speed", $metric_system, $raw));
$this->deleteFile($this->getChartFilename("vario", $metric_system, $raw));
$this->deleteFile($this->getChartFilename("takeoff_distance", $metric_system, $raw));
}
}
$oldFilename = $this->getIGCFilename();
$oldFilenameSaned = $this->getIGCFilename(1);
$oldFilenameSanedFull = $this->getIGCFilename(2);
$oldOLCfile = $this->getIGCFilename(0) . ".olc";
$this->filename = $newName;
@rename($oldFilename, $this->getIGCFilename());
@rename($oldFilenameSaned, $this->getIGCFilename(1));
@rename($oldFilenameSanedFull, $this->getIGCFilename(2));
@rename($oldOLCfile, $this->getIGCFilename(0) . ".olc");
$query = "UPDATE {$flightsTable} SET filename='" . $this->filename . "' WHERE ID=" . $this->flightID;
// echo $query."<HR>";
$res = $db->sql_query($query);
if ($res <= 0) {
echo "Error renaming IGC file for flight " . $this->flightID . " : {$query}<BR>";
}
require_once dirname(__FILE__) . '/lib/json/CL_json.php';
require_once dirname(__FILE__) . '/CL_actionLogger.php';
$log = new Logger();
$log->userID = $this->userID;
$log->ItemType = 1;
// flight;
$log->ItemID = $this->serverID && $this->serverID != $CONF_server_id ? $this->original_ID : $this->flightID;
// 0 at start will fill in later if successfull
$log->ServerItemID = $this->serverID ? $this->serverID : $CONF_server_id;
$log->ActionID = 16;
//1 => add 2 => edit; 4 => delete ; 16 -> rename trackog
$log->ActionXML = '{
"serverID": ' . ($this->serverID ? $this->serverID : $CONF_server_id) . ',
"id": ' . ($isLocal ? $this->flightID : $this->original_ID) . ',
"linkIGC": "' . $this->getIGC_URL() . '",
"linkIGCzip": "' . $this->getZippedIGC_URL() . '",
"newFilename": "' . json::prepStr($this->filename) . '",
"oldFilename": "' . json::prepStr($oldName) . '"
}';
$log->Modifier = 0;
$log->ModifierID = 0;
$log->ServerModifierID = 0;
$log->Result = 1;
if (!$log->Result) {
$log->ResultDescription = "Problem in deleting flight {$query}";
}
if (!$log->put()) {
echo "Problem in logger<BR>";
}
}
示例3: getPilotPhotoRelFilename
if ($row['PilotPhoto'] > 0) {
//checkPilotPhoto($serverIDview,$pilotIDview);
$imgBigRel = getPilotPhotoRelFilename($serverIDview, $pilotIDview);
$imgBig = getPilotPhotoFilename($serverIDview, $pilotIDview);
// echo $imgBig."<BR>";
list($width, $height, $type, $attr) = getimagesize($imgBig);
//echo $imgBig." $CONF['photos']['mid']['max_width'], $CONF['photos']['mid']['max_height'], $width, $height <br>";
list($width, $height) = CLimage::getJPG_NewSize($CONF['photos']['mid']['max_width'], $CONF['photos']['mid']['max_height'], $width, $height);
$photo = "<a href='{$imgBigRel}' target='_blank'><img src='" . getPilotPhotoRelFilename($serverIDview, $pilotIDview, 1) . "'\n\t\t\tonmouseover=\"trailOn('{$imgBigRel}','','','','','','1','{$width}','{$height}','','.');\" onmouseout=\"hidetrail();\"\n\t\t\t border=0></a>";
$photo = "<img src='" . getPilotPhotoRelFilename($serverIDview, $pilotIDview, 1) . "'>";
}
if ($_GET['json']) {
$photo = json::prepStr($photo);
}
if ($_GET['json']) {
$json = ' { "firstName":"' . json::prepStr($row["FirstName"]) . '", "lastName":"' . json::prepStr($row["LastName"]) . '", ' . ' "name":"' . json::prepStr($name) . '",' . ' "flag":"' . json::prepStr($flagIcon) . '",' . ' "photo":"' . $photo . '", ' . ' "sex":"' . json::prepStr($sexIcon) . '", "userID":"' . json::prepStr($row["serverID"] . 'u' . $row["pilotID"]) . '" } ';
} else {
$jsom = '';
}
//$pilots[]=array("score"=>$dmax,"text"=>$html,"json"=>$json);
$pilots[] = array("id" => $pilotIDview, "name" => $name, "score" => $dmax);
}
if (count($pilots) > 0) {
usort($pilots, "cmp");
$i = 0;
$count = $_GET['count'];
if (!$count) {
$count = 15;
}
foreach ($pilots as $pilot) {
$pilotsFinal[] = $pilot;
示例4: array
//$readonly_fields=array('LastName', 'FirstName');
if ($CONF_use_NAC) {
$readonly_fields = array();
$list1 = $list2 = $list3 = '';
$possible_readonly_fields = array('NACmemberID', 'LastName', 'FirstName', 'Birthdate', 'CIVL_ID');
$list4 = "var all_readonly_fields = '" . implode(',', $possible_readonly_fields) . "';\n";
foreach ($CONF_NAC_list as $NACid => $NAC) {
$NAC_input_url = $NAC['input_url'];
if (preg_match_all("/#([^#]+)#/", $NAC_input_url, $matches_tmp1)) {
//print_r($matches_tmp1);
foreach ($matches_tmp1[1] as $paramName) {
//echo "!!$NAC_input_url@@$paramName@@".$pilot[$paramName]."^^";
$NAC_input_url = str_replace('#' . $paramName . '#', $pilot[$paramName], $NAC_input_url);
}
}
$list1 .= "NAC_input_url[{$NACid}] = '" . json::prepStr($NAC_input_url) . "';\n";
$ext_input = empty($NAC['external_input']) ? 0 : 1;
$list2 .= "NAC_external_input[{$NACid}] = {$ext_input};\n";
$use_clubs = $NAC['use_clubs'] + 0;
$list2 .= "NAC_use_clubs[{$NACid}] = {$use_clubs};\n";
$list2 .= "NAC_select_clubs[{$NACid}] = " . ($NAC['club_change_period_active'] || $NAC['add_to_club_period_active'] && !$pilot['NACclubID'] || L_auth::isAdmin($userID) || L_auth::isModerator($userID) ? 1 : 0) . ";\n";
$externalfields = !empty($NAC['external_fields']) ? $NAC['external_fields'] : '';
if ($ext_input && !empty($NAC['external_fields'])) {
$list3 .= "NAC_external_fields[{$NACid}] = '{$externalfields}';\n";
if ($pilot['NACid'] == $NACid) {
$tmp_fields = explode(',', $externalfields);
foreach ($tmp_fields as $fld) {
if (in_array($fld, $possible_readonly_fields)) {
$readonly_fields[] = $fld;
}
}
示例5: formatVario
$MIN_VARIO = formatVario($row['MIN_VARIO']);
if ($singleFlight) {
$flightID = $row['ID'] + 0;
$flight = new flight();
$flight->getFlightFromDB($flightID, 0);
//$flight->makeJSON(0); // no force
$mapUrl = $flight->createStaticMap(0);
}
// $pref="http://xc.dhv.de/xc/modules/leonardo";
$pref = "http://" . $_SERVER['SERVER_NAME'];
$JSON_str .= ' {"flightID": "' . $row["ID"] . '", "date": "' . json::prepStr($row["DATE"]) . '", ' . '"DURATION": "' . json::prepStr($duration) . '", ' . '"START_TIME": "' . json::prepStr($START_TIME) . '", ' . '"END_TIME": "' . json::prepStr($END_TIME) . '", ' . '"MAX_ALT": "' . json::prepStr($MAX_ALT) . '", ' . '"MAX_VARIO": "' . json::prepStr($MAX_VARIO) . '", ';
'"MIN_VARIO": "' . json::prepStr($MIN_VARIO) . '", ';
if ($singleFlight) {
$JSON_str .= '"g1": "' . json::prepStr($pref . substr($flight->getChartRelPath('alt', 1, 0), 0)) . '", ' . '"g2": "' . json::prepStr($pref . substr($flight->getChartRelPath('vario', 1, 0), 0)) . '" , ' . '"g3": "' . json::prepStr($pref . substr($flight->getChartRelPath('speed', 1, 0), 0)) . '" , ' . '"g4": "' . json::prepStr($pref . substr($flight->getChartRelPath('takeoff_distance', 1, 0), 0)) . '" , ' . '"firstLat": "' . json::prepStr($row["firstLat"]) . '", ' . '"firstLon": "' . json::prepStr($row["firstLon"]) . '", ' . '"lastLat": "' . json::prepStr($row["lastLat"]) . '", ' . '"lastLon": "' . json::prepStr($row["lastLon"]) . '", ' . '"map": "' . json::prepStr($pref . substr($mapUrl, 0)) . '" , ';
}
$JSON_str .= '"linearDistance": "' . json::prepStr($linearDistance) . '", ' . '"olcDistance": "' . json::prepStr($olcDistance) . '", ' . '"olcScore": "' . json::prepStr($olcScore) . '", ' . '"scoreSpeed": "' . json::prepStr($scoreSpeed) . '", ' . '"olcScoreType": "' . json::prepStr($olcScoreType) . '", ' . '"glider": "' . json::prepStr($row['glider']) . '", ' . '"gliderBrandImg": "' . json::prepStr($gliderBrandImg) . '", ' . '"gliderCat": "' . json::prepStr($gliderCat) . '", ' . '"categoryImg": "' . json::prepStr($categoryImg) . '", ' . '"pilotName": "' . json::prepStr($name) . '", ' . '"takeoff": "' . json::prepStr($location) . '" } ';
$i++;
}
//$JSON_str='{"totalCount":"'.$i.'","flights":[ '. $JSON_str." ] } ";
$JSON_str = '{ ' . ' "flights":[ ' . $JSON_str . ' ] } ';
sendJson($JSON_str);
}
}
}
}
}
}
}
function sendJson($JSON_str)
{
if (ini_get('zlib.output_compression')) {
示例6: formatOLCScoreType
}
$olcScoreType = leoHtml::img($olcScoreTypeImg, 16, 16, 'top', formatOLCScoreType($olcScoreType, 0), 'icons1');
$gliderType = $row["cat"];
// 1=pg 2=hg flex 4=hg rigid 8=glider
$gliderBrandImg = brands::getBrandImg($row["gliderBrandID"], $row['flight_glider'], $gliderType);
$gliderTypeDesc = $gliderCatList[$row["cat"]];
if ($row["category"]) {
$gliderTypeDesc .= " - " . $CONF['gliderClasses'][$row["cat"]]['classes'][$row["category"]];
$categoryImg = leoHtml::img("icon_class_" . $row["category"] . ".png", 0, 0, 'top', $gliderTypeDesc, 'icons1', '');
} else {
$categoryImg = '';
}
$gliderCat = leoHtml::img("icon_cat_" . $row["cat"] . ".png", 0, 0, 'top', $gliderTypeDesc, 'icons1 catListIcon');
$MAX_ALT = formatAltitude($row['MAX_ALT']);
$MAX_VARIO = formatVario($row['MAX_VARIO']);
$JSON_str .= ' {"flightID": "' . $row["ID"] . '", "date": "' . json::prepStr($row["DATE"]) . '", ' . '"firstLat": "' . json::prepStr($row["firstLat"]) . '", ' . '"firstLon": "' . json::prepStr($row["firstLon"]) . '", ' . '"lastLat": "' . json::prepStr($row["lastLat"]) . '", ' . '"lastLon": "' . json::prepStr($row["lastLon"]) . '", ' . '"DURATION": "' . json::prepStr($duration) . '", ' . '"START_TIME": "' . json::prepStr($START_TIME) . '", ' . '"END_TIME": "' . json::prepStr($END_TIME) . '", ' . '"MAX_ALT": "' . json::prepStr($MAX_ALT) . '", ' . '"MAX_VARIO": "' . json::prepStr($MAX_VARIO) . '", ' . '"linearDistance": "' . json::prepStr($linearDistance) . '", ' . '"olcDistance": "' . json::prepStr($olcDistance) . '", ' . '"olcScore": "' . json::prepStr($olcScore) . '", ' . '"scoreSpeed": "' . json::prepStr($scoreSpeed) . '", ' . '"olcScoreType": "' . json::prepStr($olcScoreType) . '", ' . '"gliderBrandImg": "' . json::prepStr($gliderBrandImg) . '", ' . '"gliderCat": "' . json::prepStr($gliderCat) . '", ' . '"categoryImg": "' . json::prepStr($categoryImg) . '", ' . '"pilotName": "' . json::prepStr($name) . '", ' . '"takeoff": "' . json::prepStr($location) . '" } ';
$i++;
}
//$JSON_str='{"totalCount":"'.$i.'","flights":[ '. $JSON_str." ] } ";
$JSON_str = '{ "flights":[ ' . $JSON_str . " ] } ";
if (!empty($HTTP_SERVER_VARS['SERVER_SOFTWARE']) && strstr($HTTP_SERVER_VARS['SERVER_SOFTWARE'], 'Apache/2')) {
header('Cache-Control: no-cache, pre-check=0, post-check=0, max-age=0');
} else {
header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
}
header('Expires: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Content-Type: text/html');
//$callbackFunction=$_GET['callback'];
//echo $callbackFunction."(".$JSON_str.")";
echo $JSON_str;
示例7: foreach
foreach ($AirspaceArea as $i => $area) {
if ($i > 0) {
$res .= " ,\n";
}
$points = "";
if ($area->Shape == 1) {
// area
for ($j = 0; $j < $area->NumPoints; $j++) {
if ($j > 0) {
$points .= " ,";
}
$points .= $area->Points[$j]->Latitude . "," . $area->Points[$j]->Longitude . "";
}
} else {
if ($area->Shape == 2) {
// cirle
$pointsArray = CalculateCircle($area->Latitude, $area->Longitude, $area->Radius);
for ($j = 0; $j < count($pointsArray); $j++) {
if ($j > 0) {
$points .= " ,";
}
$points .= $pointsArray[$j]->lat . "," . $pointsArray[$j]->lng;
}
}
}
$res .= ' { "type":"' . json::prepStr($area->Type) . '", "name":"' . json::prepStr($area->Name) . '", "base":"' . json::prepStr(floor($area->Base->Altitude)) . '", "top":"' . json::prepStr(floor($area->Top->Altitude)) . '", "color":"' . json::prepStr($airspace_color[$area->Type]) . '", "points": [' . $points . '] } ';
$i++;
}
$res .= ' ] }';
echo $res;
}
示例8: cmp
$photo="<a href='$imgBigRel' target='_blank'><img src='".getPilotPhotoRelFilename($serverIDview,$pilotIDview,1)."'
onmouseover=\"trailOn('$imgBigRel','','','','','','1','$width','$height','','.');\" onmouseout=\"hidetrail();\"
border=0></a>";
$photo="<img src='".getPilotPhotoRelFilename($serverIDview,$pilotIDview,1)."'>";
}
if( $_GET['json'] ){
$photo=json::prepStr($photo);
}
if ($_GET['json']) {
$json=' { "firstName":"'.json::prepStr($row["FirstName"]).'", "lastName":"'.json::prepStr($row["LastName"]).'", '.
' "name":"'.json::prepStr($name).'",'.
' "flag":"'.json::prepStr($flagIcon).'",'.
' "photo":"'.$photo.'", '.
' "sex":"'.json::prepStr($sexIcon).'", "userID":"'.json::prepStr($row["serverID"].'u'.$row["pilotID"]).'" } ';
} else {
$jsom='';
}
$pilots[]=array("score"=>$dmax,"text"=>$html,"json"=>$json);
}
function cmp($a0, $b0)
{
$a=$a0['score'];
$b=$b0['score'];
if ($a == $b) {
return 0;
}