static function authAPICall($dbh, $output_on_error = true, $output_type = "json") { require_once "Token.php"; $token_data = Token::check($dbh, Token::getToken()); if (isset($token_data["organization_user_id"])) { $user = $dbh->query("SELECT * FROM organization_user WHERE id = ?", array($token_data["organization_user_id"])); if (count($user)) { $user = $user[0]; $user["token_data"] = $token_data; return $user; } } if ($output_on_error) { $status = "401 Unauthorized"; output($output_type, array("status" => $status, "success" => false, "error" => array("Invalid token")), $status); exit; } }
public function initForm($action, $method = 'post', array $data = array(), $samePageToken = false) { if (strtolower($method) !== 'post' && strtolower($method) !== 'get') { $ajax = "\$.ajax({method: \"POST\", url: \"{$action}\","; $ajax .= "data: {"; $ajax .= "_method: \"{$method}\","; } else { $method = strtoupper($method); $ajax = "\$.ajax({method: \"{$method}\", url: \"{$action}\","; $ajax .= "data: {"; } foreach ($data as $k => $v) { $ajax .= "{$k}: \"{$v}\","; } if (strtolower($method) !== 'get') { $token = Token::getToken($samePageToken); $ajax .= "_token: \"{$token}\""; } $ajax .= "}})"; $this->output = $ajax; return $this; }
function accept(Token $token) { if ($token->isA(T_FUNCTION)) { $this->state = 1; } elseif ($this->state === 1 && $token->getText() === '(') { $this->signature = array(); $this->signature[] = array($token->getText(), $token->getToken()); $this->paren_count = 1; $this->state = 2; if (is_callable($this->on_signature_begin)) { call_user_func($this->on_signature_begin); } } elseif ($this->state === 2) { $this->signature[] = array($token->getText(), $token->getToken()); if ($token->getText() === '(') { $this->paren_count++; } elseif ($token->getText() === ')') { $this->paren_count--; } if ($this->paren_count === 0) { $this->state = 0; if (is_callable($this->on_signature_end)) { call_user_func($this->on_signature_end); } } } }
/** * Return an opaque, url-safe token representing this mosaic * @access public */ function getToken() { $token = new Token(); $token->setValue("x", $this->map_x); $token->setValue("y", $this->map_y); $token->setValue("w", $this->image_w); $token->setValue("h", $this->image_h); $token->setValue("s", $this->pixels_per_km); $token->setValue("f", $this->mosaic_factor); if ($this->palette) { $token->setValue("p", $this->palette); } if (!empty($this->type_or_user)) { $token->setValue("t", $this->type_or_user); } return $token->getToken(); }
/** * Main function: does the backup */ private function go() { $this->phpflickr = new oPhpFlickr($this->appid, $this->secret, true); // Check for Flickr username if ($this->flickr_username != false) { $this->dialog->info(1, "Looking for Flickr id for username {$this->flickr_username}"); $r = $this->phpflickr->people_findByUsername($this->flickr_username); $this->flickr_id = $r['nsid']; } // Check for Flickr ID if (!$this->flickr_id) { $this->dialog->error("Missing Flickr ID"); exit(1); } // Create phpFlickr object $ini_array = parse_ini_file($this->configuration_file, true); if (!is_array($ini_array) || !is_array($ini_array[$this->flickr_id]) || !$ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN] || !$ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN_SECRET]) { $this->dialog->info(1, "No information about Flickr id {$this->flickr_id} in configuration file {$this->configuration_file}"); $token = $this->authorize(); } else { $token = new Token($ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN], $ini_array[$this->flickr_id][CONFIG_ACCESS_TOKEN_SECRET]); } if (!$token || $token->getToken() == '' || $token->getSecret() == '') { $this->dialog->error("No access token for Flickr id {$this->flickr_id} in configuration file {$this->configuration_file}: " . $token->__toString()); exit(1); } $this->phpflickr->setToken($token); // Do the backup if ($this->backup_all_photos) { $this->get_photo_list(); } $this->backup_photos(); if ($this->backup_all_sets) { $this->get_set_list(); } $this->backup_sets(); }
$images->images[$i]->distance = sprintf("%0.2f", sqrt(pow($images->images[$i]->grid_square->nateastings - $images->images[$i]->viewpoint_eastings - $correction, 2) + pow($images->images[$i]->grid_square->natnorthings - $images->images[$i]->viewpoint_northings - $correction, 2)) / 1000); if (intval($images->images[$i]->grid_square->nateastings / 1000) != intval($images->images[$i]->viewpoint_eastings / 1000) || intval($images->images[$i]->grid_square->natnorthings / 1000) != intval($images->images[$i]->viewpoint_northings / 1000)) { $images->images[$i]->different_square_true = true; } if ($images->images[$i]->different_square_true && $images->images[$i]->subject_gridref_precision == 1000) { $images->images[$i]->distance -= 0.5; } if ($images->images[$i]->different_square_true && $images->images[$i]->distance > 0.1) { $images->images[$i]->different_square = true; } $token->setValue("p", $images->images[$i]->getPhotographerGridref(true)); } if (isset($image->view_direction) && strlen($image->view_direction) && $image->view_direction != -1) { $token->setValue("v", $image->view_direction); } $images->images[$i]->reopenmaptoken = $token->getToken(); if ($fix6fig) { $images->images[$i]->subject_gridref = ''; //kill the cache so will be done again with use6fig; $images->images[$i]->photographer_gridref = ''; $images->images[$i]->use6fig = 1; } $db->Execute("REPLACE INTO gridsquare_moderation_lock SET user_id = {$USER->user_id}, gridsquare_id = {$image->gridsquare_id}"); $fullpath = $images->images[$i]->_getFullpath(); list($width, $height, $type, $attr) = getimagesize($_SERVER['DOCUMENT_ROOT'] . $fullpath); if (max($width, $height) < 500 || min($width, $height) < 100) { $images->images[$i]->sizestr = $attr; } } ############################# $db->Execute("UNLOCK TABLES");
$endtime = (double) $usec + (double) $sec; $timetaken = $endtime - $STARTTIME; if ($timetaken > 15) { //mysql might of closed the connection in the meantime unset($square->db); //so get a new one... $square->_getDB(); } //find a possible place within 25km $smarty->assign('place', $square->findNearestPlace(25000)); if (!empty($_REQUEST['grid_reference'])) { $token = new Token(); $token->setValue("g", !empty($_REQUEST['grid_reference']) ? $_REQUEST['grid_reference'] : $square->grid_reference); $token->setValue("p", $_REQUEST['photographer_gridref']); $token->setValue("v", $_REQUEST['view_direction']); $smarty->assign('reopenmaptoken', $token->getToken()); $smarty->assign_by_ref('square', $square); } if ($_REQUEST['imagetaken'] && $_REQUEST['imagetaken'] != '0000-00-00') { $smarty->assign('imagetaken', stripslashes($_REQUEST['imagetaken'])); } elseif ($smarty->get_template_vars('imagetaken')) { //already set } elseif (isset($uploadmanager->exifdate)) { $smarty->assign('imagetaken', $uploadmanager->exifdate); //$smarty->assign('imagetakenmessage', ' ('.$uploadmanager->exifdate.' stated in exif header)'); } else { $smarty->assign('imagetaken', '--'); } if (isset($_SESSION['last_imagetaken'])) { $smarty->assign('last_imagetaken', $_SESSION['last_imagetaken']); }
$dataarray['orderby'] = ''; } $orderby = $dataarray['orderby']; if ($dataarray['reverse_order_ind']) { $orderby = preg_replace('/(,|$)/', ' desc$1', $orderby); } $sql .= ",orderby = " . $db->Quote($orderby); if (!empty($dataarray['breakby'])) { $sql .= ",breakby = " . $db->Quote($dataarray['breakby']); } $sql .= " WHERE id = " . intval($i); $ok = $db->Execute($sql); if ($ok) { $token = new Token(); $token->setValue("i", $i); $smarty->assign('token', $token->getToken()); $smarty->display('search_refine.tpl'); exit; } } $display = $engine->getDisplayclass(); if (isset($_GET['displayclass']) && preg_match('/^\\w+$/', $_GET['displayclass'])) { $display = $_GET['displayclass']; if ($USER->registered && $USER->user_id == $engine->criteria->user_id && $_GET['displayclass'] != 'search' && $_GET['displayclass'] != 'searchtext') { $engine->setDisplayclass($_GET['displayclass']); } else { //don't store search override permently $engine->temp_displayclass = $display; } } if (empty($display)) {
$imagelist->_getImagesBySql($sql); if (count($imagelist->images)) { foreach ($imagelist->images as $i => $image) { $imagelist->images[$i]->imagetakenString = getFormattedDate($image->imagetaken); } $smarty->assign_by_ref('images', $imagelist->images); $first = $imagelist->images[0]; $smarty->assign('criteria', $first->submitted); $last = $imagelist->images[count($imagelist->images) - 1]; $max_gridimage_id = $last->gridimage_id; $count++; if ($count < 10 && count($imagelist->images) == 20) { $token = new Token(); $token->setValue("id", intval($max_gridimage_id)); $token->setValue("c", intval($count)); $smarty->assign('next', $token->getToken()); } } if ($max_gridimage_id && isset($_SERVER['HTTP_REFERER'])) { $ref = @parse_url($_SERVER['HTTP_REFERER']); if (!empty($ref['query'])) { $ref_query = array(); parse_str($ref['query'], $ref_query); if (!empty($ref_query['next'])) { $smarty->assign('prev', $ref_query['next']); } } elseif ($ref['path'] == '/submissions.php') { $smarty->assign('prev', 1); } } }
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once 'geograph/global.inc.php'; init_session(); $smarty = new GeographPage(); $USER->mustHavePerm("basic"); $template = 'admin_mykey.tpl'; $cacheid = ''; function smarty_block_highlight($params, $content, &$smarty, &$repeat) { return highlight_string(str_replace("\r", '', $content), true); } $smarty->register_block('highlight', 'smarty_block_highlight'); $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } if (!empty($_GET['apikey'])) { //load the info for editing the record if ($_GET['apikey'] != '-new-') { $arr = $db->GetRow("select *,INET_NTOA(ip) as ip_text from apikeys where enabled = 1 and apikey = " . $db->Quote($_GET['apikey'])); $smarty->assign($arr); $token = new Token(); $token->setValue("i", $arr['id']); $smarty->assign('access', $token->getToken()); $smarty->assign('shared', md5($CONF['token_secret'] . $arr['apikey'])); } } $smarty->display($template, $cacheid);
/** * Return an opaque, url-safe token representing this map * @access public */ function getToken() { $token = new Token(); $token->setValue("e", floor($this->nateastings / $this->divisor[$this->service])); $token->setValue("n", floor($this->natnorthings / $this->divisor[$this->service])); $token->setValue("s", $this->service); if ($this->epoch != 'latest') { $token->setValue("r", $this->epoch); } return $token->getToken(); }
<title>安装向导</title> <link href="res/cotrip.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="res/cotrip.js"></script> </head> <body> <?php require_once 'Token.php'; require_once 'Menu.class.php'; if (empty($_POST['AppID']) || empty($_POST['AppSecret'])) { echo "非法访问"; } $AppID = $_POST['AppID']; $AppSecret = $_POST['AppSecret']; $token = new Token(); $access_token = $token->getToken($AppID, $AppSecret); if ($access_token != false) { $ticket = getTicket($access_token); if ($ticket != false) { $menu = new Menu($access_token); $res = $menu->createDefaultMenu() ? "菜单创建成功" : "菜单创建失败"; echo $res . "<br/>"; echo "以下为你的微信公众账号的永久二维码访问链接和图片,请妥善保存<br/>"; echo "<font color=\"red\">[重要提示]:由于微信服务器每天限制动态获取二维码,请不要频繁刷新本页面,以免造成微信服务器拒绝服务</font></br>"; echo "<font color=\"blue\">若要分享你的微信公众账号,请复制下面图片或者分享下面链接即可获取公众号永久二维码</font></br>"; echo "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$ticket}"; echo "<img src=\"https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket={$ticket}\"/>"; } else { echo "系统初始化失败,请检查微信“AppID”和“AppSecret”是否正确。"; } }
/** * load all change items * @access public */ function loadItems() { $db =& $this->_getDB(); if ($this->isValid()) { $this->changes = $db->GetAll("select * from gridimage_ticket_item where gridimage_ticket_id={$this->gridimage_ticket_id}"); if (count($this->changes)) { $token = new Token(); foreach ($this->changes as $i => $row) { if (!empty($row['newvalue']) && $row['newvalue'] != -1) { switch ($row['field']) { case 'grid_reference': $token->setValue("g", $row['newvalue']); break; case 'photographer_gridref': $token->setValue("p", $row['newvalue']); break; case 'view_direction': $token->setValue("v", $row['newvalue']); break; } } } $count = count($token->data); if ($count > 0 && !($count == 1 && $token->hasValue('v'))) { $this->reopenmaptoken = $token->getToken(); } } } }
/** * @depends testGetToken */ public function testSetToken() { $token = new Token(); $token->setToken('test'); $this->assertSame('test', $token->getToken()); }
if ($token->parse($_REQUEST['t'])) { if ($token->hasValue("i")) { $i = $token->getValue("i"); } if ($token->hasValue("p")) { $_GET['page'] = $token->getValue("p"); } } } if (isset($_REQUEST['debug']) && $USER->hasPerm("admin")) { $token = new Token(); $token->setValue("i", $i); if (!empty($_GET['page'])) { $token->setValue("p", $_GET['page']); } print $token->getToken(); } if (isset($_GET['l']) && isset($_SESSION['gameToken'])) { unset($_SESSION['gameToken']); } $game = new Game(); if (isset($_REQUEST['token'])) { $game->setToken($_REQUEST['token']); } elseif (isset($_SESSION['gameToken'])) { $game->setToken($_SESSION['gameToken']); } if (isset($_REQUEST['debug']) && $USER->hasPerm("admin") && $game->i) { print "<br>{$game->i}"; } if (isset($_REQUEST['autoload'])) { switch (rand(1, 3)) {
/** * Return an opaque, url-safe token representing this mosaic * @access public */ function getToken() { $token = new Token(); $token->setValue("x", $this->map_x); $token->setValue("y", $this->map_y); $token->setValue("w", $this->image_w); $token->setValue("h", $this->image_h); $token->setValue("s", $this->pixels_per_km); if (!empty($this->type_or_user)) { $token->setValue("t", $this->type_or_user); } if (isset($this->reference_index)) { $token->setValue("r", $this->reference_index); } if ($this->palette) { $token->setValue("p", $this->palette); } return $token->getToken(); }
if (!$db) { die('Database connection failed'); } if (!($apikey = $db->GetOne("select apikey from apikeys where enabled = 1 and id = " . $db->Quote($id)))) { die("invalid 'API Key', if you are not the developer you should contact them to correct this"); } } else { die("invalid 'Access Key', if you are not the developer you should contact them to correct this"); } $token = new Token(); $token->magic = md5($CONF['token_secret'] . $apikey); if (isset($_GET['t']) && $token->parse($_GET['t']) && $token->hasValue('callback')) { $callback = $token->getValue('callback'); $action = $token->getValue('action'); $smarty->assign('callback', $callback); $smarty->assign('action', $action); $token = new Token(); $token->magic = md5($CONF['token_secret'] . $apikey); $token->setValue("k", $apikey); //just to prove to THEM we know who they are $token->setValue("user_id", $USER->user_id); $token->setValue("realname", $USER->realname); if (!empty($USER->nickname)) { $token->setValue("nickname", $USER->nickname); } $final_url = "{$callback}?t=" . $token->getToken(); $smarty->assign('final_url', $final_url); } else { die("invalid request, if you are not the developer you should contact them to correct this"); } $smarty->display($template);