function getvideo($id, $pid = 2) { $hz = '_letv'; $pidarrs[] = '350'; $pidarrs[] = '1000'; $pidarrs[] = '720p'; $stime = 'http://api.letv.com/time?tn=0.' . time(); $str = get_curl_contents($stime); $t = preg_match('|{"stime":(\\d+)}|', $str, $matchs) ? $matchs[1] : false; $content = get_curl_contents('http://api.letv.com/mms/out/video/play?id=' . $id . '&platid=1&splatid=101&domain=http://www.letv.com&tkey=' . getKey($t), 0, 0, 1); $data = preg_match('~<playurl><!\\[cdata\\[(.*)\\]\\]></playurl>~iUs', $content, $matchs) ? $matchs[1] : false; $json = json_decode($data); $pido = ''; if (strpos($data, '"720p"')) { $pido = '3'; } if (!$pido) { if (strpos($data, '"1000"')) { $pido = '2'; } } if (!$pido) { $pido = '1'; } switch ($pido) { case '1': $qvars = __BQ__ . '_' . $id . $hz; break; case '2': $qvars = __BQ__ . '_' . $id . $hz . '|' . __GQ__ . '_' . $id . $hz; break; case '3': $qvars = __BQ__ . '_' . $id . $hz . '|' . __GQ__ . '_' . $id . $hz . '|' . __CQ__ . '_' . $id . $hz; break; default: $qvars = $id . $hz; break; } $pid = min($pid, $pido); $dispatch = $json->dispatch->{$pidarrs}[$pid - 1]; $urllist['urls'][0]['url'] = str_replace('tss=ios', 'tss=no', $dispatch[0]); $urllist['vars'] = '{h->1}{a->' . $qvars . '}{f->' . __HOSTURL__ . '?url=[$pat' . ($pid - 1) . ']}'; return $urllist; }
function getLoginJSONP($type) { require_once "../leader/jsupport.php"; $success = false; $username = ""; $key = ""; //Ignore any messages from the login system that may corrupt our JSON ob_start(); if (array_key_exists("username", $_COOKIE) && array_key_exists("key", $_COOKIE)) { //We may have saved these via javascript. Try loading them $username = strtolower($_COOKIE["username"]); $key = $_COOKIE["key"]; $success = true; } else { if (checkPostLogin() == 7) { //Can we log in with leaderboards? $username = strtolower(getPostValue("username")); $key = getKey($username); $success = true; } else { //Nope $success = false; } } ob_end_clean(); //Return their key formatted as specified if ($success) { if ($type === "JS") { return "webchat.setUser(\"{$username}\", \"{$key}\", \"true\"); webchat.connect();"; } else { if ($type === "JSON") { return json_encode(array("success" => true, "username" => $username, "key" => $key)); } } } else { if ($type === "JS") { return "webchat.enableLogin(true); webchat.setLoginStatus(\"No Saved Login Found\");"; } else { if ($type === "JSON") { return json_encode(array("success" => false)); } } } }
function getServerProfileGroups($userid, $type) { global $user; $key = getKey(array('getServerProfileAdminGroups', $userid, $type)); if (array_key_exists($key, $_SESSION['usersessiondata'])) { return $_SESSION['usersessiondata'][$key]; } $resources = getUserResources(array('serverCheckOut', 'serverProfileAdmin'), array('available', 'administer')); $ids = array_keys($resources['serverprofile']); $inids = implode(',', $ids); if (empty($inids)) { $_SESSION['usersessiondata'][$key] = array(); return array(); } if ($type == 'admin') { $field = 'admingroupid'; } else { $field = 'logingroupid'; } if ($user['showallgroups']) { $query = "SELECT DISTINCT(u.id), " . "CONCAT(u.name, '@', a.name) AS name " . "FROM serverprofile s, " . "usergroup u, " . "affiliation a " . "WHERE s.{$field} = u.id AND " . "u.affiliationid = a.id AND " . "s.id IN ({$inids}) " . "ORDER BY name"; } else { $query = "SELECT DISTINCT(u.id), " . "u.name " . "FROM serverprofile s, " . "usergroup u " . "WHERE s.{$field} = u.id AND " . "s.id IN ({$inids}) " . "ORDER BY name"; } $qh = doQuery($query, 101); $groups = array(); while ($row = mysql_fetch_assoc($qh)) { $groups[$row['id']] = $row['name']; } $_SESSION['usersessiondata'][$key] = $groups; return $groups; }
function getConnectMethods($imageid) { $key = getKey(array('getConnectMethods', $imageid)); if (array_key_exists($key, $_SESSION['usersessiondata'])) { return $_SESSION['usersessiondata'][$key]; } $query = "SELECT DISTINCT c.id, " . "c.description, " . "cm.autoprovisioned " . "FROM connectmethod c, " . "connectmethodmap cm, " . "image i " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN OStype ot ON (ot.name = o.type) " . "WHERE i.id = {$imageid} AND " . "cm.connectmethodid = c.id AND " . "cm.autoprovisioned IS NOT NULL AND " . "(cm.OStypeid = ot.id OR " . "cm.OSid = o.id) " . "ORDER BY c.description"; $methods = array(); $qh = doQuery($query, 101); while ($row = mysql_fetch_assoc($qh)) { $methods[$row['id']] = $row; } $_SESSION['usersessiondata'][$key] = $methods; return $methods; }
function AJsaveResource() { $add = getContinuationVar('add', 0); $data = $this->validateResourceData(); if ($data['error']) { $ret = array('status' => 'error', 'msg' => $data['errormsg']); sendJSON($ret); return; } if ($add) { if (!($data['rscid'] = $this->addResource($data))) { sendJSON(array('status' => 'adderror', 'errormsg' => 'Error encountered while trying to create new management node.<br>Please contact an admin for assistance.')); return; } } else { $olddata = getContinuationVar('olddata'); $updates = array(); # hostname if ($data['name'] != $olddata['hostname']) { $updates[] = "hostname = '{$data['name']}'"; } $tmp = getVariable("timesource|{$olddata['hostname']}", "<unset>"); if ($tmp != "<unset>") { $query = "UPDATE variable " . "SET name = 'timesource|{$data['name']}' " . "WHERE name = 'timesource|{$olddata['hostname']}'"; doQuery($query); } # IPaddress if ($data['ipaddress'] != $olddata['IPaddress']) { $updates[] = "IPaddress = '{$data['ipaddress']}'"; } # ownerid $ownerid = getUserlistID($data['owner']); if ($ownerid != $olddata['ownerid']) { $updates[] = "ownerid = {$ownerid}"; } # stateid if ($data['stateid'] != $olddata['stateid']) { $updates[] = "stateid = '{$data['stateid']}'"; } # checkininterval if ($data['checkininterval'] != $olddata['checkininterval']) { $updates[] = "checkininterval = '{$data['checkininterval']}'"; } # installpath if ($data['installpath'] != $olddata['installpath']) { $updates[] = "installpath = '{$data['installpath']}'"; } # imagelibenable if ($data['imagelibenable'] != $olddata['imagelibenable']) { $updates[] = "imagelibenable = '{$data['imagelibenable']}'"; } # imagelibgroupid if ($data['imagelibgroupid'] != $olddata['imagelibgroupid']) { $updates[] = "imagelibgroupid = '{$data['imagelibgroupid']}'"; } # imagelibuser if ($data['imagelibuser'] != $olddata['imagelibuser']) { $updates[] = "imagelibuser = '******'imagelibuser']}'"; } # imagelibkey if ($data['imagelibkey'] != $olddata['imagelibkey']) { $updates[] = "imagelibkey = '{$data['imagelibkey']}'"; } # keys if ($data['keys'] != $olddata['keys']) { $updates[] = "`keys` = '{$data['keys']}'"; } # sshport if ($data['sshport'] != $olddata['sshport']) { $updates[] = "sshport = '{$data['sshport']}'"; } # publicIPconfiguration if ($data['publicIPconfig'] != $olddata['publicIPconfig']) { $updates[] = "publicIPconfiguration = '{$data['publicIPconfig']}'"; } # publicSubnetMask if ($data['publicnetmask'] != $olddata['publicnetmask']) { $updates[] = "publicSubnetMask = '{$data['publicnetmask']}'"; } # publicDefaultGateway if ($data['publicgateway'] != $olddata['publicgateway']) { $updates[] = "publicDefaultGateway = '{$data['publicgateway']}'"; } # publicDNSserver if ($data['publicdnsserver'] != $olddata['publicdnsserver']) { $updates[] = "publicDNSserver = '{$data['publicdnsserver']}'"; } # sysadminEmailAddress if ($data['sysadminemail'] != $olddata['sysadminemail']) { $updates[] = "sysadminEmailAddress = '{$esc['sysadminemail']}'"; } # sharedMailBox if ($data['sharedmailbox'] != $olddata['sharedmailbox']) { $updates[] = "sharedMailBox = '{$esc['sharedmailbox']}'"; } # availablenetworks if ($data['availablenetworks'] != implode(',', $olddata['availablenetworks'])) { $updates[] = "availablenetworks = '{$data['availablenetworks']}'"; } # federatedauth if ($data['federatedauth'] != $olddata['federatedauth']) { $updates[] = "NOT_STANDALONE = '{$data['federatedauth']}'"; } if (count($updates)) { $query = "UPDATE managementnode SET " . implode(', ', $updates) . " WHERE id = {$data['rscid']}"; doQuery($query); } # time servers if ($data['timeservers'] != $olddata['timeservers']) { $globalval = getVariable('timesource|global'); if ($data['timeservers'] == '' || $data['timeservers'] == $globalval) { deleteVariable("timesource|{$data['name']}"); } else { setVariable("timesource|{$data['name']}", $data['timeservers'], 'none'); } } # NAT host if ($data['nathostenabled'] != $olddata['nathostenabled']) { if ($data['nathostenabled']) { $query = "INSERT INTO nathost " . "(resourceid, " . "publicIPaddress, " . "internalIPaddress) " . "VALUES " . "({$olddata['resourceid']}, " . "'{$data['natpublicIPaddress']}', " . "'{$data['natinternalIPaddress']}') " . "ON DUPLICATE KEY UPDATE " . "publicIPaddress = '{$data['natpublicIPaddress']}', " . "internalIPaddress = '{$data['natinternalIPaddress']}'"; doQuery($query); } else { $query = "DELETE FROM nathost " . "WHERE resourceid = {$olddata['resourceid']}"; doQuery($query); } } elseif ($data['nathostenabled'] && ($olddata['natpublicIPaddress'] != $data['natpublicIPaddress'] || $olddata['natinternalIPaddress'] != $data['natinternalIPaddress'])) { $query = "UPDATE nathost " . "SET publicIPaddress = '{$data['natpublicIPaddress']}', " . "internalIPaddress = '{$data['natinternalIPaddress']}' " . "WHERE resourceid = {$olddata['resourceid']}"; doQuery($query); } } # clear user resource cache for this type $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("administer"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("administer"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("manageGroup"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("manageGroup"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); $tmp = $this->getData(array('includedeleted' => 1, 'rscid' => $data['rscid'], 'alive' => 'neither')); $data = $tmp[$data['rscid']]; $arr = array('status' => 'success'); $arr['data'] = $data; if ($add) { $arr['action'] = 'add'; $arr['data']['name'] = $arr['data']['hostname']; $arr['nogroups'] = 0; $groups = getUserResources(array($this->restype . 'Admin'), array('manageGroup'), 1); if (count($groups[$this->restype])) { $arr['groupingHTML'] = $this->groupByResourceHTML(); } else { $arr['nogroups'] = 1; } } else { $arr['action'] = 'edit'; } sendJSON($arr); }
function buildAdminSubnav($skel, $section, $subsections) { $result = "\t<div class=\"subnavbar\">\n"; $result .= "\t<h2>" . $skel['sectionname'] . "</h2>\n"; for ($i = 0; $i < count($subsections); $i++) { if ('' != trim($subsections[$i])) { $pagekey = getKey($subsections[$i]); $page = getValue($subsections[$i]); if ('#' != $pagekey[0] && '' != trim($page)) { if (isset($skel['page']) && $pagekey == $skel['page']) { $active = ' class="highlight"'; } else { $active = ''; } $result .= "<a href=\"" . $skel['base_uri'] . 'admin/' . $section . '/' . $pagekey . '/"' . $active . '>' . trim($page) . "</a> | "; } } } return $result . "</div>\n"; }
} /*Slim*/ require 'Slim/Slim.php'; \Slim\Slim::registerAutoloader(); //instantiate slim app (might need to provide arguments) $app = new \Slim\Slim(); $app->get('/', function () { echo "error"; }); $app->get('/getkey/:name', function ($name) { echo "" . getKey($name); }); $app->post('/', function () use($app) { $json = $app->request->getBody(); $creds = json_decode($json, true); $username = $creds["username"]; $password = decrypt(getKey($username), $creds["password"]); //echo $creds["password"]." --> $password"; if (comparePassword($username, $password)) { //password is valid $sessionID = createSession($username); $acceptedPage = "<img src=\"success.jpg\" \n \t\t\tclass=\"img-circle img-responsive center-block\" width=\"300\"></br>\n \t\t <h2 class=\"text-center\">Hi there {$username}! Wonderful to see you again!</h2></br></br></br>\n \t\t <form action=\"logout.php\" method=\"post\"> \n \t\t \t<input type=\"hidden\" name=\"sessionid\" value=\"{$sessionID}\">\n\t\t\t\t<button class=\"btn btn-lg btn-warning center-block\" type=\"submit\">Log out</button>\n\t\t\t </form>\n \t\t"; echo $acceptedPage; } else { $refusedPage = "<img src=\"fail.jpg\" \n \t\tclass=\"img-circle img-responsive center-block\"></br>\n \t\t <h2 class=\"text-center\">Unfortunately your credentials were <b>wrong</b>! Don't be sad, just try again!</h2></br></br></br>\n \t\t <form action=\"login.html\"> \n\t\t\t\t<button class=\"btn btn-lg btn-primary center-block\" type=\"submit\">Return to login page</button>\n\t\t\t </form>\n \t\t"; echo $refusedPage; } }); $app->run(); //close db connection $conn->close();
function addResource($vars) { $name = mysql_real_escape_string($vars['name']); if ($vars['type'] == 'Cluster') { $query = "INSERT INTO config " . "(name, " . "ownerid, " . "configtypeid, " . "optional) " . "VALUES " . "('{$name}', " . "{$vars['ownerid']}, " . "(SELECT id FROM configtype WHERE prettyname = '{$vars['type']}'), " . "{$vars['optional']})"; doQuery($query); $id = dbLastInsertID(); $vals = array(); foreach ($vars['subimages'] as $sub) { $item = "({$id}, {$sub['imageid']}, {$sub['min']}, {$sub['max']})"; $vals[] = $item; } $allvals = implode(',', $vals); $query = "INSERT INTO configsubimage " . "(configid, " . "imageid, " . "mininstance, " . "maxinstance) " . "VALUES {$allvals}"; doQuery($query); } else { $data = mysql_real_escape_string($vars['data']); $query = "INSERT INTO config " . "(name, " . "configtypeid, " . "ownerid, " . "optional, " . "data) " . "VALUES " . "('{$name}', " . "{$vars['typeid']}, " . "{$vars['ownerid']}, " . "{$vars['optional']}, " . "'{$data}')"; doQuery($query); $id = dbLastInsertID(); if (count($vars['configvariables'])) { $this->addNewConfigVars($vars['configvariables'], $id); } } $query = "INSERT INTO resource " . "(resourcetypeid, " . "subid) " . "VALUES " . "((SELECT id FROM resourcetype WHERE name = 'config'), " . "{$id})"; doQuery($query); $key = getKey(array(array("{$this->restype}Admin"), array("administer"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array("{$this->restype}Admin"), array("administer"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); $ret = array('status' => 'success', 'action' => 'add'); $ret['item'] = array('id' => $id, 'name' => $vars['name'], 'configtypeid' => $vars['typeid'], 'configtype' => $vars['type'], 'data' => $vars['data'], 'ownerid' => $vars['ownerid'], 'owner' => $vars['owner'], 'optional' => $vars['optional'], 'deleted' => 0); sendJSON($ret); }
function AJsubmitCompScheduleChange() { $schid = getContinuationVar('schid'); $schname = getContinuationVar('schname'); $compids = getContinuationVar('compids'); $complist = getContinuationVar('complist'); $allids = implode(',', $compids); $query = "UPDATE computer " . "SET scheduleid = {$schid} " . "WHERE id in ({$allids})"; doQuery($query); $msg = "The schedule for the following computer(s) was set to "; $msg .= "{$schname}:<br>{$complist}\n"; # clear user resource cache for this type $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); $ret = array('status' => 'success', 'title' => "Change Schedule", 'clearselection' => 1, 'refreshcount' => 1, 'msg' => $msg); sendJSON($ret); }
STATE<br /> ZIP<br /> PHONE<br /> EMAIL_ADDRESS<br /> WHERE_DID_YOU_HEAR_FROM_US<br /> PREFERRED_METHOD_TO_CONTACT<br /> BEST_TIME_TO_CONTACT<br /> COMMENT_QUESTION<br /> <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if ($_POST["g-recaptcha-response"]) { $captchaconfig = new CaptchaConfig(); $reCaptcha = new ReCaptcha($captchaconfig . getKey()); $response = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"]); } if (empty($_POST["name"])) { $nameErr = "Name is required"; } else { $name = test_input($_POST["name"]); // check if name only contains letters and whitespace if (!preg_match("/^[a-zA-Z ]*\$/", $name)) { $nameErr = "Only letters and white space allowed"; } } if (empty($_POST["email"])) { $emailErr = "Email is required"; } else { $email = test_input($_POST["email"]);
<?php function getKey() { if ($handle = opendir('./scripts/resources/')) { while (false !== ($entry = readdir($handle))) { if ($entry != "." && $entry != "..") { $path = "./scripts/resources/" . $entry; } } closedir($handle); } return $key = file_get_contents($path); } $url = "https://data.opentechinstitute.org/api/3/action/"; $auth_key = getKey(); $resource_id = "78377408-b750-4db9-bffb-dec9ef9c9477";
/** * [getKey 根据value得到数组key] * @param [type] $arr [数组] * @param [type] $value [值] * @return [type] [description] */ function getKey($arr, $value) { if (!is_array($arr)) { return null; } foreach ($arr as $k => $v) { $return = getKey($v, $value); if ($v == $value) { return $k; } if (!is_null($return)) { return $return; } } }
<?php require_once "_key.php"; return array('debug' => true, 'url' => 'https://neshto.shantavo.com', 'timezone' => 'EST', 'locale' => 'bg', 'fallback_locale' => 'en', 'key' => getKey(), 'cipher' => MCRYPT_RIJNDAEL_128, 'providers' => array('Illuminate\\Foundation\\Providers\\ArtisanServiceProvider', 'Illuminate\\Auth\\AuthServiceProvider', 'Illuminate\\Cache\\CacheServiceProvider', 'Illuminate\\Session\\CommandsServiceProvider', 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Routing\\ControllerServiceProvider', 'Illuminate\\Cookie\\CookieServiceProvider', 'Illuminate\\Database\\DatabaseServiceProvider', 'Illuminate\\Encryption\\EncryptionServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Html\\HtmlServiceProvider', 'Illuminate\\Log\\LogServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\Database\\MigrationServiceProvider', 'Illuminate\\Pagination\\PaginationServiceProvider', 'Illuminate\\Queue\\QueueServiceProvider', 'Illuminate\\Redis\\RedisServiceProvider', 'Illuminate\\Remote\\RemoteServiceProvider', 'Illuminate\\Auth\\Reminders\\ReminderServiceProvider', 'Illuminate\\Database\\SeedServiceProvider', 'Illuminate\\Session\\SessionServiceProvider', 'Illuminate\\Translation\\TranslationServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'Illuminate\\Workbench\\WorkbenchServiceProvider', 'Roumen\\Feed\\FeedServiceProvider', 'Roumen\\Sitemap\\SitemapServiceProvider', 'Roumen\\Disqus\\DisqusServiceProvider', 'Roumen\\Asset\\AssetServiceProvider', 'Greggilbert\\Recaptcha\\RecaptchaServiceProvider', 'Mews\\Purifier\\PurifierServiceProvider'), 'manifest' => storage_path() . '/meta', 'aliases' => array('App' => 'Illuminate\\Support\\Facades\\App', 'Artisan' => 'Illuminate\\Support\\Facades\\Artisan', 'Auth' => 'Illuminate\\Support\\Facades\\Auth', 'Blade' => 'Illuminate\\Support\\Facades\\Blade', 'Cache' => 'Illuminate\\Support\\Facades\\Cache', 'ClassLoader' => 'Illuminate\\Support\\ClassLoader', 'Config' => 'Illuminate\\Support\\Facades\\Config', 'Controller' => 'Illuminate\\Routing\\Controller', 'Cookie' => 'Illuminate\\Support\\Facades\\Cookie', 'Crypt' => 'Illuminate\\Support\\Facades\\Crypt', 'DB' => 'Illuminate\\Support\\Facades\\DB', 'Eloquent' => 'Illuminate\\Database\\Eloquent\\Model', 'Event' => 'Illuminate\\Support\\Facades\\Event', 'File' => 'Illuminate\\Support\\Facades\\File', 'Form' => 'Illuminate\\Support\\Facades\\Form', 'Hash' => 'Illuminate\\Support\\Facades\\Hash', 'HTML' => 'Illuminate\\Support\\Facades\\HTML', 'Input' => 'Illuminate\\Support\\Facades\\Input', 'Lang' => 'Illuminate\\Support\\Facades\\Lang', 'Log' => 'Illuminate\\Support\\Facades\\Log', 'Mail' => 'Illuminate\\Support\\Facades\\Mail', 'Paginator' => 'Illuminate\\Support\\Facades\\Paginator', 'Password' => 'Illuminate\\Support\\Facades\\Password', 'Queue' => 'Illuminate\\Support\\Facades\\Queue', 'Redirect' => 'Illuminate\\Support\\Facades\\Redirect', 'Redis' => 'Illuminate\\Support\\Facades\\Redis', 'Request' => 'Illuminate\\Support\\Facades\\Request', 'Response' => 'Illuminate\\Support\\Facades\\Response', 'Route' => 'Illuminate\\Support\\Facades\\Route', 'Schema' => 'Illuminate\\Support\\Facades\\Schema', 'Seeder' => 'Illuminate\\Database\\Seeder', 'Session' => 'Illuminate\\Support\\Facades\\Session', 'SoftDeletingTrait' => 'Illuminate\\Database\\Eloquent\\SoftDeletingTrait', 'SSH' => 'Illuminate\\Support\\Facades\\SSH', 'Str' => 'Illuminate\\Support\\Str', 'URL' => 'Illuminate\\Support\\Facades\\URL', 'Validator' => 'Illuminate\\Support\\Facades\\Validator', 'View' => 'Illuminate\\Support\\Facades\\View', 'Asset' => 'Roumen\\Asset\\Asset', 'Feed' => 'Roumen\\Feed\\Facades\\Feed', 'Purifier' => 'Mews\\Purifier\\Facades\\Purifier'));
<?php $input = "iwrupvqb"; echo getKey($input); function getKey($input) { $count = 346386; while (true) { $hash = str_split(md5($input . $count), 6); if ($hash[0] === "000000") { return $count; } $count++; } }
function getCompStateFlow($compid) { $key = getKey(array($compid)); if (array_key_exists($key, $_SESSION['compstateflow'])) { return $_SESSION['compstateflow'][$key]; } # get id for repeat state, useful because several of the calling functions # need this information $query = "SELECT id FROM computerloadstate WHERE loadstatename = 'repeat'"; $qh = doQuery($query, 101); if (!($row = mysql_fetch_assoc($qh))) { return array(); } $loadstates['repeatid'] = $row['id']; $query = "SELECT `type` FROM computer WHERE id = {$compid}"; $qh = doQuery($query, 101); if (!($row = mysql_fetch_assoc($qh))) { return array(); } $type = $row['type']; $query = "SELECT cf.computerloadstateid AS stateid, " . "cs1.prettyname AS state, " . "cs1.loadstatename AS statename, " . "cf.nextstateid, " . "cs2.prettyname AS nextstate, " . "cs1.est AS statetime " . "FROM computerloadstate cs1, " . "computerloadflow cf " . "LEFT JOIN computerloadstate cs2 ON (cf.nextstateid = cs2.id) " . "WHERE cf.computerloadstateid = cs1.id AND " . "cf.type = '{$type}' "; $query2 = $query . "AND cf.computerloadstateid NOT IN " . "(SELECT nextstateid FROM computerloadflow WHERE `type` = '{$type}' " . "AND nextstateid IS NOT NULL)"; $qh = doQuery($query2, 101); if (!($row = mysql_fetch_assoc($qh))) { return array(); } $loadstates['data'][$row['stateid']] = $row; $loadstates['stateids'] = array($row['stateid']); $loadstates['nextstates'] = array($row['stateid'] => $row['nextstateid']); $loadstates['totaltime'] = 0; for ($i = 0; $i < 100; $i++) { # don't want an endless loop $query2 = $query . "AND cf.computerloadstateid = {$row['nextstateid']} " . "AND `type` = '{$type}'"; $qh = doQuery($query2, 101); if (!($row = mysql_fetch_assoc($qh))) { $_SESSION['compstateflow'][$key] = $loadstates; return $loadstates; } else { array_push($loadstates['stateids'], $row['stateid']); $loadstates['nextstates'][$row['stateid']] = $row['nextstateid']; $loadstates['totaltime'] += $row['statetime']; $loadstates['data'][$row['stateid']] = $row; } if (empty($row['nextstateid'])) { $_SESSION['compstateflow'][$key] = $loadstates; return $loadstates; } } $_SESSION['compstateflow'][$key] = $loadstates; return $loadstates; }
function AJremImageConnectMethod() { $imageid = getContinuationVar('imageid'); $methods = getContinuationVar('methods'); $revids = getContinuationVar('revids'); $curmethods = getImageConnectMethods($imageid); $remidlist = mysql_real_escape_string(processInputVar('ids', ARG_STRING)); $remids = explode(',', $remidlist); $revid = processInputVar('revid', ARG_NUMERIC); $newimage = getContinuationVar('newimage'); foreach ($remids as $id) { if (!is_numeric($id)) { $arr = array('error' => 'invalidinput', 'msg' => i("Non-numeric data was submitted for a connection method id.")); sendJSON($arr); return; } } if ($revid != 0 && !in_array($revid, $revids)) { $arr = array('error' => 'invalidrevision', 'msg' => i("Invalid revision id submitted.")); sendJSON($arr); return; } if (!$newimage) { if ($revid == 0) { $revid = getProductionRevisionid($imageid); } # delete any current entries for method and image $query = "DELETE FROM connectmethodmap " . "WHERE imagerevisionid = {$revid} AND " . "connectmethodid IN ({$remidlist}) AND " . "autoprovisioned IS NULL"; doQuery($query, 101); # query to see if enabled for OStype or OS $insvals = array(); foreach ($remids as $id) { $query = "SELECT cm.connectmethodid " . "FROM connectmethodmap cm, " . "image i " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN OStype ot ON (ot.name = o.type) " . "WHERE i.id = {$imageid} AND " . "cm.autoprovisioned IS NULL AND " . "cm.connectmethodid = {$id} AND " . "cm.disabled = 0 AND " . "(cm.OStypeid = ot.id OR " . "cm.OSid = o.id)"; $qh = doQuery($query, 101); if (mysql_num_rows($qh)) { # if so, add disabled entry for image revision and method $insvals[] = "({$id}, {$revid}, 1)"; } } if (count($insvals)) { $allinsvals = implode(',', $insvals); $query = "INSERT INTO connectmethodmap " . "(connectmethodid, " . "imagerevisionid, " . "disabled) " . "VALUES {$allinsvals}"; doQuery($query, 101); } } $cdata = $this->basecdata; $cdata['imageid'] = $imageid; $cdata['methods'] = $methods; $cdata['revids'] = $revids; $cdata['newimage'] = $newimage; $addcont = addContinuationsEntry('AJaddImageConnectMethod', $cdata, 3600, 1, 0); $remcont = addContinuationsEntry('AJremImageConnectMethod', $cdata, 3600, 1, 0); $arr = array('addcont' => $addcont, 'remcont' => $remcont); sendJSON($arr); $key = getKey(array('getImageConnectMethods', (int) $imageid, (int) $revid)); if (array_key_exists($key, $_SESSION['usersessiondata'])) { unset($_SESSION['usersessiondata'][$key]); } $key = getKey(array('getImageConnectMethods', (int) $imageid, 0)); if (array_key_exists($key, $_SESSION['usersessiondata'])) { unset($_SESSION['usersessiondata'][$key]); } }
function checkUserHasPriv($priv, $uid, $node, $privs = 0, $cascadePrivs = 0) { global $user; $key = getKey(array($priv, $uid, $node, $privs, $cascadePrivs)); if (array_key_exists($key, $_SESSION['userhaspriv'])) { return $_SESSION['userhaspriv'][$key]; } if ($user["id"] != $uid) { $_user = getUserInfo($uid); } else { $_user = $user; } $affilUserid = "{$_user['unityid']}@{$_user['affiliation']}"; if (!is_array($privs)) { $privs = getNodePrivileges($node, 'users'); $privs = getNodePrivileges($node, 'usergroups', $privs); } if (!is_array($cascadePrivs)) { $cascadePrivs = getNodeCascadePrivileges($node, 'users'); $cascadePrivs = getNodeCascadePrivileges($node, 'usergroups', $cascadePrivs); } // if user (has $priv at this node) || # (has cascaded $priv && ! have block at this node) return 1 if (array_key_exists($affilUserid, $privs["users"]) && in_array($priv, $privs["users"][$affilUserid]) || array_key_exists($affilUserid, $cascadePrivs["users"]) && in_array($priv, $cascadePrivs["users"][$affilUserid]) && (!array_key_exists($affilUserid, $privs["users"]) || !in_array("block", $privs["users"][$affilUserid]))) { $_SESSION['userhaspriv'][$key] = 1; return 1; } foreach ($_user["groups"] as $groupname) { // if group (has $priv at this node) || # (has cascaded $priv && ! have block at this node) return 1 if (array_key_exists($groupname, $privs["usergroups"]) && in_array($priv, $privs["usergroups"][$groupname]['privs']) || array_key_exists($groupname, $cascadePrivs["usergroups"]) && in_array($priv, $cascadePrivs["usergroups"][$groupname]['privs']) && (!array_key_exists($groupname, $privs["usergroups"]) || !in_array("block", $privs["usergroups"][$groupname]['privs']))) { $_SESSION['userhaspriv'][$key] = 1; return 1; } } $_SESSION['userhaspriv'][$key] = 0; return 0; }
$audioStreamConfig = new AudioStreamConfig(); $audioStreamConfig->bitrate = 128000; $audioStreamConfig->samplerate = 44100; $encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig; /* CREATE ENCODING PROFILE */ $encodingProfile = EncodingProfile::create($encodingProfileConfig); $jobConfig = new JobConfig(); $jobConfig->speed = \bitcodin\JobSpeedTypes::STANDARD; $jobConfig->encodingProfile = $encodingProfile; $jobConfig->input = $input; $jobConfig->manifestTypes[] = ManifestTypes::M3U8; /* CREATE JOB */ $job = Job::create($jobConfig); /* WAIT UNTIL JOB IS FINISHED */ do { $job->update(); sleep(1); } while ($job->status != Job::STATUS_FINISHED && $job->status != Job::STATUS_ERROR); $outputConfig = new FtpOutputConfig(); $outputConfig->name = "TestS3Output"; $outputConfig->host = str_replace('ftp://', '', getKey('ftpServer')); $outputConfig->username = getKey('ftpUser'); $outputConfig->password = getKey('ftpPassword'); $output = Output::create($outputConfig); /* TRANSFER JOB OUTPUT */ $job->transfer($output); /* HELPER FUNCTION */ function getKey($key) { return json_decode(file_get_contents(__DIR__ . '/test/config.json'))->{$key}; }
$db_server = 'nwt-2.l001.51vhost.net'; //'qdm163951542.my3w.com'; $db_account = 'db03152'; //'qdm163951542'; $db_password = '******'; //'Woshizhu3312'; $db_name = 'db03152'; //'qdm163951542_db'; $conn = new mysqli($db_server, $db_account, $db_password, $db_name, '3306'); if ($conn->connect_error) { die('数据库连接失败!' . $conn->connection_error); return; } //插入信息 $userKey = getKey(); function insertUserInfo($conn, $userKey) { $sql = 'insert into game_redbag_data(ip, start_time, userKey) values("' . getIP() . '","' . date('y-m-d H:i:s') . '", "' . $userKey . '")'; $conn->query($sql); } insertUserInfo($conn, $userKey); //生成随机码 function getKey() { return uniqid('user', true); } //获取ip function getIP() { $ip = '未知ip';
<?php include "getKey.php"; $key = getKey(); $file = "https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?champData=all&api_key=" . $key; // header('Content-Type: application/json'); echo file_get_contents($file);
/** * This should mirror database replacements in cloner.php */ function restore_migrate_urls() { // ----- DATABASE REPLACEMENTS /** * Finds all urls that begin with $oldSiteUrl AND * end either with OPTIONAL slash OR with MANDATORY slash following any number of any characters */ // Get all options that contain old urls, then check if we can replace them safely // Now check for old urls without WWW global $restoreParams, $wpdb; $oldSiteUrl = $restoreParams['oldSiteUrl']; $oldUrl = $restoreParams['oldUrl']; $tablePrefix = $restoreParams['tablePrefix']; $newUrl = $restoreParams['newUrl']; if (!isset($oldSiteUrl) || !isset($oldUrl)) { return false; } $parsedOldSiteUrl = parse_url(strpos($oldSiteUrl, '://') === false ? "http://{$oldSiteUrl}" : $oldSiteUrl); $parsedOldUrl = parse_url(strpos($oldUrl, '://') === false ? "http://{$oldUrl}" : $oldUrl); $host = getKey('host', $parsedOldSiteUrl, ''); $path = getKey('path', $parsedOldSiteUrl, ''); $oldSiteUrlNoWww = preg_replace('#^www\\.(.+\\.)#i', '$1', $host) . $path; $parsedOldSiteUrlNoWww = parse_url(strpos($oldSiteUrlNoWww, '://') === false ? "http://{$oldSiteUrlNoWww}" : $oldSiteUrlNoWww); if (isset($parse['scheme'])) { $oldSiteUrlNoWww = "{$parse['scheme']}://{$oldSiteUrlNoWww}"; } // Modify the database for two variants of url, one with and one without WWW $oldUrls = array('oldSiteUrl' => $oldSiteUrl); $tmp1 = @"{$parsedOldUrl['host']}/{$parsedOldUrl['path']}"; $tmp2 = @"{$parsedOldSiteUrlNoWww['host']}/{$parsedOldSiteUrlNoWww['path']}"; if ($oldSiteUrlNoWww != $oldSiteUrl && $tmp1 != $tmp2) { $oldUrls['oldSiteUrlNoWww'] = $oldSiteUrlNoWww; } if (strpos($oldSiteUrl, $oldUrl) !== false && $oldSiteUrl != $oldUrl && $parsedOldUrl['host'] != $parsedOldSiteUrl['host']) { $oldUrls['oldUrl'] = $oldUrl; } foreach ($oldUrls as $key => $url) { if (empty($url) || strlen($url) <= 1) { continue; } if ($key == 'oldSiteUrlNoWww') { $amazingRegex = "~http://{$url}(?=(((/.*)+)|(/?\$)))~"; } else { $amazingRegex = "~{$url}(?=(((/.*)+)|(/?\$)))~"; } // Check options $query = "SELECT option_id, option_value FROM {$tablePrefix}options WHERE option_value LIKE '%{$url}%';"; $selection = $wpdb->get_results($query, ARRAY_A); foreach ($selection as $row) { // Set a default value untouched $replaced = $row['option_value']; if (is_serialized($row['option_value'])) { $unserialized = unserialize($row['option_value']); if (is_array($unserialized)) { array_walk_recursive($unserialized, 'recursiveUrlReplacement', array('newUrl' => $newUrl, 'regex' => $amazingRegex)); $replaced = serialize($unserialized); } } else { $replaced = preg_replace($amazingRegex, $newUrl, $replaced); } $escapedReplacement = $wpdb->_escape($replaced); $optId = $row['option_id']; if ($row['option_value'] != $replaced) { $query = "UPDATE {$tablePrefix}options SET option_value = '{$escapedReplacement}' WHERE option_id = {$optId}"; $wpdb->query($query); } } // Check post meta $query = "SELECT meta_id, meta_value FROM {$tablePrefix}postmeta WHERE meta_value LIKE '%{$url}%'"; $selection = $wpdb->get_results($query, ARRAY_A); foreach ($selection as $row) { $replacement = $row['meta_value']; if (is_serialized($replacement)) { $unserialized = unserialize($replacement); if (is_array($unserialized)) { array_walk_recursive($unserialized, 'recursiveUrlReplacement', array('newUrl' => $newUrl, 'regex' => $amazingRegex)); } $replacement = serialize($unserialized); } else { $replacement = preg_replace($amazingRegex, $newUrl, $replacement); } if ($replacement != $row['meta_value']) { $escapedReplacement = $wpdb->_escape($replacement); $id = $row['meta_id']; $query = "UPDATE {$tablePrefix}postmeta SET meta_value = '{$escapedReplacement}' WHERE meta_id = '{$id}'"; $wpdb->query($query); } } // Do the same with posts $query = "SELECT ID, post_content, guid FROM {$tablePrefix}posts WHERE post_content LIKE '%{$url}%' OR guid LIKE '%{$url}%'"; $selection = $wpdb->get_results($query, ARRAY_A); foreach ($selection as &$row) { $postContent = preg_replace($amazingRegex, $newUrl, $row['post_content']); $guid = preg_replace($amazingRegex, $newUrl, $row['guid']); if ($postContent != $row['post_content'] || $guid != $row['guid']) { $postContent = $wpdb->_escape($postContent); $guid = $wpdb->_escape($guid); $postId = $row['ID']; $q = "UPDATE {$tablePrefix}posts SET post_content = '{$postContent}', guid = '{$guid}' WHERE ID = {$postId}"; $wpdb->query($q); } } } }
/** * [_type 获取信息类型] * @param [type] $_type [数字代码] * @return [type] [description] */ private function _type($_type) { $type = array('未知' => 0, '环岛' => 1, '无属性道路' => 2, '主路' => 3, '高速连接路' => 4, '交叉点内路段' => 5, '连接道路' => 6, '停车场内部道路' => 7, '服务区内部道路' => 8, '桥' => 9, '步行街' => 10, '辅路' => 11, '匝道' => 12, '全封闭道路' => 13, '未定义交通区域' => 14, 'POI连接路' => 15, '隧道' => 16, '步行道' => 17, '公交专用道' => 18, '提前右转道' => 19, '桥' => 100, '收费站' => 101, '服务区,停车场' => 102, '加油站' => 103, '百货商城' => 104, '电器商场' => 105, '大厦' => 106, '五星级酒店' => 107, '超市' => 108, '快餐' => 109, '广场' => 110, '会议中心,展览中心' => 111, '学校(大专院校)' => 112, '村屯、风景名胜' => 113, '限速摄像头' => 200, '交通信号灯摄像头' => 201, '路况监控摄像头' => 202, '雷达测速摄像头' => 203, '单行线摄像头' => 204, '非机动车道摄像头' => 205, '高速/城市高速出入口摄像头' => 206, '公交车道摄像头' => 207, '移动式测速' => 209, '禁止左转摄像头' => 210, '禁止右转摄像头' => 211, '其他' => 214, '主要路段' => '300-349', '红绿灯' => '350-399', '道路出入口' => 400, '终点停车场' => 999); foreach ($type as $k => $v) { if (strstr('-', $v)) { $temp = explode('-', $v); if ($_type > $temp[0] && $_type < $temp[1]) { return getKey($type, $v); } } else { if ($_type == $v) { return getKey($type, $v); } } } }
function toggleDeleteResource($rscid) { if ($this->deletetoggled) { $query = "SELECT deleted " . "FROM `{$this->restype}` " . "WHERE id = {$rscid}"; $qh = doQuery($query); if ($row = mysql_fetch_assoc($qh)) { $newval = (int) (!(int) $row['deleted']); $query = "UPDATE {$this->restype} " . "SET deleted = {$newval} " . "WHERE id = {$rscid}"; doQuery($query); $this->submitToggleDeleteResourceExtra($rscid, $row['deleted']); } else { return 0; } } else { $this->submitToggleDeleteResourceExtra($rscid); $query = "DELETE r " . "FROM resource r, " . "resourcetype rt " . "WHERE r.resourcetypeid = rt.id AND " . "rt.name = '{$this->restype}' AND " . "r.subid = {$rscid}"; doQuery($query); $query = "DELETE FROM `{$this->restype}` " . "WHERE id = {$rscid}"; doQuery($query); } # clear user resource cache for this type $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); return 1; }
$key = getKey($v[1]); $keys[] = $key; } else { if (!empty($v[0])) { $key = getKey($v[0]); $keys[] = $key; } } } } else { $data = file_get_contents($pathResultReadCSV); $keys = json_decode($data); } $allData = readResultFile(); foreach ($allData as $k => $v) { $key = getKey($v); $cek = array_search($key, $keys); if ($cek >= 0) { unset($keys[$cek]); } } $res['msg'] = []; $res['msg_err'] = []; $res['key'] = count($allData); foreach ($keys as $key => $value) { // if(strlen($value)<13){ // $res['msg_err'][] = $value; // }else{ $res['msg'][] = $value; // } }
function AJsaveResource() { $add = getContinuationVar('add', 0); $data = $this->validateResourceData(); if ($data['error']) { $ret = array('status' => 'error', 'msg' => $data['errormsg']); sendJSON($ret); return; } if ($add) { if (!($data['rscid'] = $this->addResource($data))) { sendJSON(array('status' => 'adderror', 'errormsg' => 'Error encountered while trying to create new schedule.<br>Please contact an admin for assistance.')); return; } } else { $ownerid = getUserlistID($data['owner']); $query = "UPDATE schedule " . "SET name = '{$data['name']}', " . "ownerid = {$ownerid} " . "WHERE id = {$data['rscid']}"; doQuery($query); } if (!$add) { $query = "DELETE FROM scheduletimes WHERE scheduleid = {$data['rscid']}"; doQuery($query, 101); } $qvals = array(); foreach ($data['times'] as $time) { $qvals[] = "({$data['rscid']}, {$time['start']}, {$time['end']})"; } $allvals = implode(',', $qvals); $query = "INSERT INTO scheduletimes " . "(scheduleid, start, end) " . "VALUES {$allvals}"; doQuery($query, 101); # clear user resource cache for this type $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin"), array("manageGroup"), 0, 1, 0, 0)); unset($_SESSION['userresources'][$key]); $key = getKey(array(array($this->restype . "Admin"), array("manageGroup"), 0, 0, 0, 0)); unset($_SESSION['userresources'][$key]); $tmp = $this->getData(array('includedeleted' => 0, 'rscid' => $data['rscid'])); $data = $tmp[$data['rscid']]; $arr = array('status' => 'success'); if ($add) { $arr['action'] = 'add'; $arr['nogroups'] = 0; $groups = getUserResources(array($this->restype . 'Admin'), array('manageGroup'), 1); if (count($groups[$this->restype])) { $arr['groupingHTML'] = $this->groupByResourceHTML(); } else { $arr['nogroups'] = 1; } } else { $arr['action'] = 'edit'; } $arr['data'] = $data; sendJSON($arr); }
function getArrOut($calc, $count) { $output = []; $calcOut = ['a' => 0, 'b' => 0, 'c' => 0]; $vesIn = getVes($calc); for ($i = 1; $i <= $count; $i++) { $keyCalc = getKey($calc, $vesIn, $calcOut); foreach ($calc as $key => $arrin) { if ($keyCalc == $key) { $calcOut[$key] = $calcOut[$key] + 1; } } } $output['calc'] = $calcOut; $output['ves'] = $vesIn; $output['vesout'] = getVes($calcOut); return $output; }