public function testPut() { $key = 'tmp/testPut' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); list($ret, $err) = Qiniu_RS_Put($this->client, $this->bucket, $key, 'hello world!', null); $this->assertNull($err); $this->assertArrayHasKey('hash', $ret); var_dump($ret); list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
public function testPut() { $key = 'testPut' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new Qiniu_RS_PutPolicy($this->bucket); $upToken = $putPolicy->Token(null); list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null); $this->assertNull($err); $this->assertArrayHasKey('hash', $ret); var_dump($ret); list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
public function testLargePut() { $key = 'testRioLargePut' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new Qiniu_RS_PutPolicy($this->bucket); $upToken = $putPolicy->Token(null); $putExtra = new Qiniu_Rio_PutExtra($this->bucket); $reader = new MockReader(); list($ret, $err) = Qiniu_Rio_Put($upToken, $key, $reader, QINIU_RIO_BLOCK_SIZE + 5, $putExtra); $this->assertNull($err); $this->assertEquals($ret['hash'], "lgQEOCZ8Ievliq8XOfZmWTndgOll"); var_dump($ret); list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
public function testPutWithPersistentOps() { $key = 'testPutWithPersistentOps' . getTid(); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new Qiniu_RS_PutPolicy($this->bucket); $putPolicy->PersistentOps = 'avthumb/mp3'; $putPolicy->PersistentNotifyUrl = 'http://someurl/abc'; $upToken = $putPolicy->Token(null); list($ret, $err) = Qiniu_Put($upToken, $key, "hello world!", null); $this->assertNull($err); $this->assertArrayHasKey('hash', $ret); $this->assertArrayHasKey('persistentId', $ret); var_dump($ret); list($ret, $err) = Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
public function testLargePut() { if (getTestEnv() == "travis") { return; } $key = 'testRioLargePut' . getTid(); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new QiniuRSPutPolicy($this->bucket); $upToken = $putPolicy->Token(null); $putExtra = new QiniuRioPutExtra($this->bucket); $putExtra->Params = array('x:test' => 'test'); $reader = new \MockReader(); list($ret, $err) = QiniuRioUploadClient::Qiniu_Rio_Put($upToken, $key, $reader, QiniuRioPutExtra::QINIU_RIO_BLOCK_SIZE() + 5, $putExtra); $this->assertNull($err); $this->assertEquals($ret['hash'], "lgQEOCZ8Ievliq8XOfZmWTndgOll"); $this->assertEquals($ret['x:test'], "test"); var_dump($ret); list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
public function testBatchDeleteMoveCopy() { $key2 = 'testOp2' . getTid(); $key3 = 'testOp3' . getTid(); $key4 = 'testOp4' . getTid(); $e1 = new Qiniu_RS_EntryPath($this->bucket, $this->key); $e2 = new Qiniu_RS_EntryPath($this->bucket, $key2); $e3 = new Qiniu_RS_EntryPath($this->bucket, $key3); $e4 = new Qiniu_RS_EntryPath($this->bucket, $key4); Qiniu_RS_BatchDelete($this->client, array($e2, $e3, $e4)); $entryPairs = array(new Qiniu_RS_EntryPathPair($e1, $e2), new Qiniu_RS_EntryPathPair($e1, $e3)); list($ret, $err) = Qiniu_RS_BatchCopy($this->client, $entryPairs); $this->assertNull($err); $this->assertEquals($ret[0]['code'], 200); $this->assertEquals($ret[1]['code'], 200); list($ret, $err) = Qiniu_RS_BatchMove($this->client, array(new Qiniu_RS_EntryPathPair($e2, $e4))); $this->assertNull($err); $this->assertEquals($ret[0]['code'], 200); list($ret, $err) = Qiniu_RS_BatchDelete($this->client, array($e3, $e4)); $this->assertNull($err); $this->assertEquals($ret[0]['code'], 200); $this->assertEquals($ret[1]['code'], 200); Qiniu_RS_BatchDelete($this->client, array($e2, $e3, $e4)); }
function doCreateTeam($login, $teamName, $editpassword, $editpassword2, $joinpassword, $joinpassword2, $blurb, $website) { if (stristr($teamName, "'") != false || stristr($teamName, "\"") != false || stristr($teamName, "\\") != false) { return "Sorry, team names can not contain \\ or ' or \" in them."; } $teamName = strip_tags($teamName); $teamName = trim($teamName); $teamName = normalize_whitespace($teamName); $teamName = chop($teamName); $editpassword = stripslashes($editpassword); $editpassword2 = stripslashes($editpassword2); $joinpassword = stripslashes($joinpassword); $joinpassword2 = stripslashes($joinpassword2); $blurb = stripslashes($blurb); if (trim($teamName) == "" || trim($joinpassword) == "" || trim($editpassword) == "") { return "Missing required information"; } if ($joinpassword != $joinpassword2) { return "Join passwords do not match"; } if ($editpassword != $editpassword2) { return "Edit passwords do not match"; } if (strlen($teamName) > 32) { return "Your team name is too long"; } if (doesTeamExist($teamName) == true) { return "Team with this name already exists"; } $pid = getPid($login); if ($pid == 0) { return "Unexpected error"; } $website = trim($website); if (substr(strtolower($website), 0, 7) != "http://") { $website = "http://" . $website; } if ($website == "http://") { $website = ""; } $sqlTeamName = mysql_escape_string($teamName); $joinpassword = mysql_escape_string($joinpassword); $editpassword = mysql_escape_string($editpassword); $blurb = mysql_escape_string($blurb); $website = mysql_escape_string($website); $regdate = date("M d, Y"); $sql = "insert into stats_team (name, owner_password, join_password, owner, blurb, website, regdate, tourn_score, strict_score) values ('{$sqlTeamName}', '{$editpassword}', '{$joinpassword}', '{$pid}', '{$blurb}', '{$website}', '{$regdate}', 1600, 1600)"; if (!mysql_query($sql)) { return "Database error"; } $tid = getTid($teamName); $sql = "insert into team_members values ('{$tid}', '{$pid}')"; if (!mysql_query($sql)) { return "Database Error 2"; } $sql = "insert into view_team (id, view_count) values ({$tid}, 0)"; if (!mysql_query($sql)) { return "Database error"; } return "OK"; }
if ($playerB != "") { if (getPid($playerB) != 0) { $listB = array(); $listB[0] = $playerB; } else { $listB = getPlayers($playerB, 50); } } } if (sizeof($listA) == 1 && sizeof($listB) == 1) { if ($listA[0] == $playerA && $listB[0] == $playerB) { #We have found a match $found = true; if ($isTeam == true) { $idA = getTid($listA[0]); $idB = getTid($listB[0]); } else { $idA = getPid($listA[0]); $idB = getPid($listB[0]); } $scoreA = getScore($idA, $gt, $isTeam); $scoreB = getScore($idB, $gt, $isTeam); $newScoreA_1 = floor(calculateElo($scoreA, $scoreB, true)); $newScoreB_1 = floor(calculateElo($scoreB, $scoreA, false)); $newScoreA_2 = floor(calculateElo($scoreA, $scoreB, false)); $newScoreB_2 = floor(calculateElo($scoreB, $scoreA, true)); } } } if ($found == true) { include "{$BASE_FILES}/inc_whatif_results.php";
<?php require "../php/header.php"; ob_start(); $name = $HTTP_GET_VARS['name']; if ($name == null) { header("Location: index.php"); exit; } openDatabase(false); $teams = getTeams($name, 50); if (count($teams) == 1) { if (getTid($name) != -1) { header("Location: teaminfo.php?name=" . urlencode($name)); closeDatabase(); exit; } } ob_end_flush(); include "{$BASE_FILES}/inc_top.php"; $error_heading = "Search Results"; if (count($teams) == 0) { $error_body = "Sorry, no matches to your query."; } else { $error_body = "Search Results (Limit 50 matches)<P>"; $count = 0; while ($count < count($teams)) { $error_body .= "<a href=\"teaminfo.php?name=" . urlencode($teams[$count]) . "\">" . $teams[$count] . "</A><BR>"; $count++; } }
public function testPut_mimeLimit() { $key = 'testPut_mimeLimit' . getTid(); $scope = $this->bucket . ':' . $key; $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new QiniuRSPutPolicy($scope); $putPolicy->MimeLimit = "image/*"; $upToken = $putPolicy->Token(null); list($ret, $err) = QiniuPutExtra::Qiniu_PutFile($upToken, $key, __FILE__, null); $this->assertNull($ret); $this->assertEquals($err->Err, "limited mimeType: this file type is forbidden to upload"); var_dump($err); }