/** * @param string $str * String contents of token. * @param TokenNode $token * The token returned from Token class method. * @param bool $check_contents * (optional) TRUE check the contents. */ protected function assertPhpToken($str, $token, $check_contents = TRUE) { $expected = $this->parsePhpToken($str); $actual = Token::parse($str); $this->assertToken($expected, $actual, $check_contents); $this->assertToken($expected, $token, $check_contents); }
/** * Initialise class from a token * @access public */ function setToken($tokenstr) { $ok = false; $token = new Token(); if ($token->parse($tokenstr)) { $ok = $token->hasValue("x") && $token->hasValue("y") && $token->hasValue("w") && $token->hasValue("h") && $token->hasValue("s"); if ($ok) { $this->setOrigin($token->getValue("x"), $token->getValue("y")); $this->setImageSize($token->getValue("w"), $token->getValue("h")); $this->setScale($token->getValue("s")); $this->type_or_user = $token->hasValue("t") ? $token->getValue("t") : 0; if ($token->hasValue("r")) { $this->reference_index = $token->getValue("r"); } if ($token->hasValue("p")) { $this->setPalette($token->getValue("p")); } } } return $ok; }
/** * Initialise class from a token * @access public */ function setToken($tokenstr, $allowWithoutMosaic = false) { $ok = false; $token = new Token(); if ($token->parse($tokenstr)) { $ok = $token->hasValue("x") && $token->hasValue("y") && $token->hasValue("w") && $token->hasValue("h") && $token->hasValue("s") && ($allowWithoutMosaic || $token->hasValue("f")); if ($ok) { $this->setOrigin($token->getValue("x"), $token->getValue("y")); $this->setMosaicSize($token->getValue("w"), $token->getValue("h")); $this->setScale($token->getValue("s")); $this->setMosaicFactor($token->hasValue("f") ? $token->getValue("f") : 2); $this->type_or_user = $token->hasValue("t") ? $token->getValue("t") : 0; $this->palette = $token->hasValue("p") ? $token->getValue("p") : 0; } else { $info = ""; foreach ($token->data as $name => $value) { $info .= "{$name}={$value} "; } $this->_err("setToken: missing elements ({$info})"); } } else { $this->_err("setToken: parse failure"); } return $ok; }
require_once "3rdparty/xmlHandler.class.php"; $smarty = new GeographPage(); //you must be logged in to request changes $USER->mustHavePerm("basic"); $template = 'puploader.tpl'; $cacheid = ''; if (isset($_REQUEST['submit2'])) { $cacheid .= 'submit2'; $smarty->assign('submit2', 1); if (isset($_REQUEST['upload_id'])) { $smarty->assign('upload_id', $_REQUEST['upload_id']); } } if (isset($_GET['success'])) { $token = new Token(); if ($token->parse($_GET['t'])) { $template = 'puploader_success.tpl'; $smarty->assign('status', unserialize($token->getValueBinary("s"))); $smarty->assign('filenames', unserialize($token->getValueBinary("f"))); } } elseif (isset($_POST['selected'])) { //we dont get the button :( $status = array(); $filenames = array(); foreach ($_POST['field'] as $key => $value) { $uploadmanager = new UploadManager(); $square = new GridSquare(); $files_key = str_replace('.', '_', $value); $filenames[$key] = $_FILES[$files_key]['name']; $ok = $square->setByFullGridRef($_POST['grid_reference'][$key]); if ($ok) {
/** * Initialise class from a token * @access public */ function setToken($tokenstr) { $ok = false; $token = new Token(); if ($token->parse($tokenstr)) { $ok = $token->hasValue("e") && $token->hasValue("n") && $token->hasValue("s"); if ($ok) { $this->service = $token->getValue("s"); $this->nateastings = $token->getValue("e") * $this->divisor[$this->service]; $this->natnorthings = $token->getValue("n") * $this->divisor[$this->service]; $this->width = $this->tilewidth[$this->service]; if ($token->hasValue("r")) { $this->epoch = $token->getValue("r"); } } } return $ok; }
function serveImageFromToken($tokenstr) { $token = new Token(); if ($token->parse($tokenstr)) { $this->width = $token->getValue("w"); $this->height = $token->getValue("h"); $this->gridimage_id = $token->getValue("i"); $image = new GridImage($this->gridimage_id); } else { header("HTTP/1.0 403 Bad Token"); } }
* 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'; require_once 'geograph/gridimage.class.php'; require_once 'geograph/gridsquare.class.php'; require_once 'geograph/searchcriteria.class.php'; init_session(); $rater = inEmptyRequestInt('rater', 0); $i = inEmptyRequestInt('i', 0); $l = inEmptyRequestInt('l', 0); if (isset($_REQUEST['t'])) { $ok = false; $token = new Token(); 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();
$result->outputEnd(); break; /* * 激活验证邮箱 */ /* * 激活验证邮箱 */ case 'verifyMail': if (!array_key_exists('active', $_GET)) { $result->outputErrResult('001'); } $active = $_GET['active']; //获取用户ID $tokenObj = new Token(); if ($tokenObj->parse($active) == FALSE) { $result->outputErrResult('005'); } $user_id = $tokenObj->m_userid; //验证token是否存在 $db = new WebTrainDBConnection(); $emailTokenRS = $db->query("SELECT email_token,user_type FROM pineapple_user WHERE email_token='{$active}' AND user_id='{$tokenObj->m_userid}' LIMIT 1"); if ($emailTokenRS == FALSE) { $db->close(); $result->outputErrResult('004'); } $emailTokenObj = $emailTokenRS->fetch_object(); if ($emailTokenObj == NULL) { $db->close(); $result->outputErrResult('005'); }
$ab = floor($i % 10000); $cacheid = "search|{$ab}|{$i}.{$pg}"; if (!empty($_GET['count'])) { $engine->countOnly = 1; $cacheid .= "."; } //what style should we use? $style = $USER->getStyle(); $cacheid .= $style; if (!empty($_GET['legacy'])) { $cacheid .= "X"; $smarty->assign('legacy', 1); } if (!empty($_GET['t'])) { $token = new Token(); if ($token->parse($_GET['t']) && $token->getValue("i") == $i) { $smarty->clear_cache($template, $cacheid); } } if (!$smarty->is_cached($template, $cacheid)) { dieUnderHighLoad(3, 'search_unavailable.tpl'); $smarty->assign_by_ref('google_maps_api_key', $CONF['google_maps_api_key']); $smarty->register_function("searchbreak", "smarty_function_searchbreak"); $smarty->register_function("votestars", "smarty_function_votestars"); $smarty->assign('maincontentclass', 'content_photo' . $style); if ($display == 'reveal') { $engine->noCache = true; $engine->criteria->limit4 = 1; //only works in GB } $smarty->assign('querytime', $engine->Execute($pg));
* 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'; require_once 'geograph/imagelist.class.php'; init_session(); $smarty = new GeographPage(); customGZipHandlerStart(); $USER->mustHavePerm("basic"); $template = 'submissions.tpl'; $max_gridimage_id = 0; $count = 0; if (!empty($_GET['next'])) { $token = new Token(); if ($token->parse($_GET['next']) && $token->hasValue("id")) { $max_gridimage_id = intval($token->getValue("id")); $count = intval($token->getValue("c")); } else { die("invalid token"); } } $ab = floor($USER->user_id / 10000); $cacheid = "user{$ab}|{$USER->user_id}|{$max_gridimage_id}"; //what style should we use? $style = $USER->getStyle(); if ($smarty->caching) { $smarty->caching = 2; // lifetime is per cache $smarty->cache_lifetime = 300; customExpiresHeader(300, false, true);
$token = new Token(); if (isset($_GET['a']) && $token->parse($_GET['a']) && $token->hasValue('i')) { $id = $token->getValue('i'); $db = NewADOConnection($GLOBALS['DSN']); 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);