public function Execute($db, $params) { if (isset($params["SceneID"]) && UUID::TryParse($params["SceneID"], $this->SceneID)) { $sql = "DELETE FROM Scenes WHERE ID='" . $this->SceneID . "'"; } else { if (isset($params["Name"])) { $sql = "DELETE FROM Scenes WHERE Name='" . $params["Name"] . "'"; } else { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } } $sth = $db->prepare($sql); if ($sth->execute()) { header("Content-Type: application/json", true); echo '{ "Success": true }'; exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
public function Execute($db, $params) { // TODO: Sanity check the expiration date // TODO: Also run a regex on Resource to make sure it's a valid (relative or absolute) URL if (!isset($params["OwnerID"], $params["Resource"], $params["Expiration"]) || !UUID::TryParse($params["OwnerID"], $this->OwnerID)) { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } if (!isset($params["CapabilityID"]) || !UUID::TryParse($params["CapabilityID"], $this->CapabilityID)) { $this->CapabilityID = UUID::Random(); } $resource = $params["Resource"]; $expiration = $params["Expiration"]; $sql = "INSERT INTO Capabilities (ID, OwnerID, Resource, ExpirationDate) VALUES (:ID, :OwnerID, :Resource, :ExpirationDate)\n ON DUPLICATE KEY UPDATE OwnerID=VALUES(OwnerID), Resource=VALUES(Resource), ExpirationDate=VALUES(ExpirationDate)"; $sth = $db->prepare($sql); if ($sth->execute(array(':ID' => $this->CapabilityID, ':OwnerID' => $this->OwnerID, ':Resource' => $resource, ':ExpirationDate' => $expiration))) { header("Content-Type: application/json", true); echo sprintf('{"Success": true, "CapabilityID": "%s"}', $this->CapabilityID); exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
function save_products($link, $prenote_uuid, $product, $id_employee, $lastUpdate) { include 'config.php'; include_once '../class.uuid.php'; $handle = $link->prepare('INSERT INTO ' . $table_prenoteDetails . ' (ID, UUID, LastUpdate, CreationUserID, LastUpdateUserID, OperationOnHoldUUID, ItemUUID, ItemCombinationID, ItemCombinationUUID, ItemSerialID, ItemBarcode, UnitID, Quantity, UnitPrice, SalesPersonUserID, ParentID) VALUES (0, :UUID, :last_update, :create_id, :update_id, :prenote_uuid, :ItemUUID, :combinationID, :combinationUUID, :serialID, :barcode, :unitID, :Quantity, :Price, :id_employee, 0)'); $handle->bindParam(':UUID', $prenoteDetails_uuid); $handle->bindParam(':last_update', $lastUpdate); $handle->bindParam(':id_employee', $id_employee, PDO::PARAM_INT); $handle->bindParam(':create_id', $id_employee, PDO::PARAM_INT); $handle->bindParam(':update_id', $id_employee, PDO::PARAM_INT); $handle->bindParam(':prenote_uuid', $prenote_uuid); $handle->bindParam(':ItemUUID', $UUID); $handle->bindParam(':unitID', $UnitID, PDO::PARAM_INT); $handle->bindParam(':Quantity', $Quantity); $handle->bindParam(':Price', $Price); $handle->bindParam(':serialID', $serialID); $handle->bindParam(':barcode', $barcode); $handle->bindParam(':combinationID', $combinationID); $handle->bindParam(':combinationUUID', $combinationUUID); $lenght = count($product); for ($i = 0; $i < $lenght; $i++) { $prenoteDetails_uuid = UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING); $UUID = $product[$i]->UUID; $Quantity = $product[$i]->Quantity; $Price = $product[$i]->Price; $UnitID = $product[$i]->UnitID; $serialID = $product[$i]->SerialID; $barcode = $product[$i]->barcode; $combinationID = $product[$i]->optionID; $combinationUUID = $product[$i]->optionUUID; $handle->execute(); } }
public function Execute($db, $params) { if (!isset($params["OwnerID"], $params["Resource"], $params["Expiration"]) || !UUID::TryParse($params["OwnerID"], $this->OwnerID)) { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } if (!isset($params["CapabilityID"]) || !UUID::TryParse($params["CapabilityID"], $this->CapabilityID)) { $this->CapabilityID = UUID::Random(); } $resource = $params["Resource"]; $expiration = intval($params["Expiration"]); // Sanity check the expiration date if ($expiration <= time()) { header("Content-Type: application/json", true); echo '{ "Message": "Invalid expiration date ' . $expiration . '" }'; exit; } log_message('debug', "Creating capability " . $this->CapabilityID . " owned by " . $this->OwnerID . " mapping to {$resource} until {$expiration}"); $sql = "INSERT INTO Capabilities (ID, OwnerID, Resource, ExpirationDate) VALUES (:ID, :OwnerID, :Resource, FROM_UNIXTIME(:ExpirationDate))\n ON DUPLICATE KEY UPDATE ID=VALUES(ID), Resource=VALUES(Resource), ExpirationDate=VALUES(ExpirationDate)"; $sth = $db->prepare($sql); if ($sth->execute(array(':ID' => $this->CapabilityID, ':OwnerID' => $this->OwnerID, ':Resource' => $resource, ':ExpirationDate' => $expiration))) { header("Content-Type: application/json", true); echo sprintf('{"Success": true, "CapabilityID": "%s"}', $this->CapabilityID); exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
public function Execute($db, $params) { if (!isset($params["CapabilityID"]) || !UUID::TryParse($params["CapabilityID"], $this->CapabilityID)) { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } $sql = "SELECT OwnerID,Resource,UNIX_TIMESTAMP(ExpirationDate) AS ExpirationDate FROM Capabilities WHERE ID=:ID AND UNIX_TIMESTAMP(ExpirationDate) > UNIX_TIMESTAMP() LIMIT 1"; $sth = $db->prepare($sql); if ($sth->execute(array(':ID' => $this->CapabilityID))) { if ($sth->rowCount() > 0) { $obj = $sth->fetchObject(); header("Content-Type: application/json", true); echo sprintf('{"Success": true, "CapabilityID": "%s", "OwnerID": "%s", "Resource": "%s", "Expiration": %u}', $this->CapabilityID, $obj->OwnerID, $obj->Resource, $obj->ExpirationDate); exit; } else { header("Content-Type: application/json", true); echo '{ "Message": "Capability not found" }'; exit; } } log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; }
public function locateObject($slug, $parent = null, $kind = null, $universe = null) { $query = array(); $query['limit'] = 1; if ($parent !== false) { $query['parent'] = $parent; } if ($kind !== null) { $query['kind'] = $kind; } if ($universe !== null) { $query['universe'] = $universe; } if (null !== ($uuid = UUID::isUUID($slug))) { $query['uuid'] = $uuid; } else { if (strpos($slug, ':') !== false) { $query['iri'] = $slug; } else { $query['tag'] = $slug; } } $rs = $this->query($query); foreach ($rs as $obj) { return $obj; } return null; }
public function post_createPet() { $this->data = Input::all(); if ($this->data["clase_mascota"] == "Mini pig") { $this->data["raza"] = "Mini pig"; } $certificados = ""; $vacunas = ""; if (is_array($this->data["certificado"])) { foreach ($this->data["certificado"] as $key => $certificado) { $certificados .= $certificado . ", "; } $this->data["certificado"] = $certificados; } else { $this->data["certificado"] = "No tiene"; } if (is_array($this->data["vacunas_cuales"])) { foreach ($this->data["vacunas_cuales"] as $key => $vacuna) { $vacunas .= $vacuna . ", "; } $this->data["vacunas_cuales"] = $vacunas; } else { $this->data["vacunas_cuales"] = "No tiene"; } //print_r($this->data);die; //$this->data["raza"] = empty($this->data["perro"]) ? $this->data["gato"] : $this->data["perro"]; //list($mes, $dia, $anio) = preg_split('/\//', $this->data["fecha_nacimiento"]); //$this->data["fecha_nacimiento"] = strtotime($dia."-".$mes."-".$anio); $this->data["uuid"] = UUID::getUUID(); if ($this->connection->mSave($this->data)) { return json_encode(array("message" => "Mascota creada", "type" => 201, "error" => 0, "uuid" => $this->data["uuid"])); } else { return json_encode(array("message" => "Error al crear mascota", "type" => 500, "error" => 1)); } }
public function Execute($db, $params) { if (isset($params["Identifier"], $params["Credential"], $params["Type"], $params["UserID"]) && UUID::TryParse($params["UserID"], $this->UserID)) { if (isset($params["Enabled"]) && $params["Enabled"] == False) { $parameters = array(':Identifier' => $params["Identifier"], ':Credential' => $params["Credential"], ':Type' => $params["Type"], ':UserID' => $this->UserID); $sql = "INSERT INTO Identities (Identifier, Credential, Type, UserID, Enabled)\n VALUES (:Identifier, :Credential, :Type, :UserID, False)\n ON DUPLICATE KEY UPDATE Credential=VALUES(Credential), Type=VALUES(Type), UserID=VALUES(UserID), Enabled=VALUES(Enabled)"; } else { $parameters = array(':Identifier' => $params["Identifier"], ':Credential' => $params["Credential"], ':Type' => $params["Type"], ':UserID' => $this->UserID); $sql = "INSERT INTO Identities (Identifier, Credential, Type, UserID)\n VALUES (:Identifier, :Credential, :Type, :UserID)\n ON DUPLICATE KEY UPDATE Credential=VALUES(Credential), Type=VALUES(Type), UserID=VALUES(UserID), Enabled=1"; } $sth = $db->prepare($sql); if ($sth->execute($parameters)) { header("Content-Type: application/json", true); echo '{ "Success": true }'; exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } } else { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } }
function tweet_post() { $args = func_get_args(); $cate = $args[2]; $content = format_str($_POST['text'], false); if (!$cate or !$content) { die("Invalid argument!"); } include_once 'sinaoauth.inc.php'; $c = new WeiboClient(SINA_AKEY, SINA_SKEY, $GLOBALS['user']['sinakey']['oauth_token'], $GLOBALS['user']['sinakey']['oauth_token_secret']); if ($_FILES['upload']['tmp_name']) { $msg = $c->upload($content, $_FILES['upload']['tmp_name']); } else { $msg = $c->update($content); } if ($msg === false || $msg === null) { echo "Error occured"; return false; } if (isset($msg['error_code']) && isset($msg['error'])) { echo 'Error_code: ' . $msg['error_code'] . '; Error: ' . $msg['error']; return false; } include_once "uuid.inc.php"; $v4uuid = str_replace("-", "", UUID::v4()); connect_db(); $add = "INSERT INTO pending_tweets (\r\n site_id, tweet_id, user_site_id, content, post_datetime,\r\n type, tweet_site_id,\r\n post_screenname, profile_image_url, source)\r\n VALUES (1, '{$v4uuid}', '" . $msg['user']['id'] . "', '{$content}', '" . date("Y-m-d H:i:s", strtotime($msg["created_at"])) . "',\r\n {$cate}, '" . $msg['id'] . "', '" . $msg["user"]["name"] . "', '" . $msg["user"]["profile_image_url"] . "', '" . $msg["source"] . "')"; if ($msg['thumbnail_pic']) { $add = "INSERT INTO pending_tweets (\r\n site_id, tweet_id, user_site_id, content, post_datetime,\r\n type, tweet_site_id,\r\n post_screenname, profile_image_url, source, thumbnail)\r\n VALUES (1, '{$v4uuid}', '" . $msg['user']['id'] . "', '{$content}', '" . date("Y-m-d H:i:s", strtotime($msg["created_at"])) . "',\r\n {$cate}, '" . $msg['id'] . "', '" . $msg["user"]["name"] . "', '" . $msg["user"]["profile_image_url"] . "', '" . $msg["source"] . "', '" . $msg['thumbnail_pic'] . "')"; } $added = mysql_query($add) or die("Could not add entry!"); echo "0"; }
public static function fromStorageRow(array $row, $obj = null) { /** @var $obj AbstractSummary */ $obj = parent::fromStorageRow($row, $obj); $obj->summaryTargetId = UUID::create($row['rev_type_id']); return $obj; }
/** * Update the sign-in credentials for the specific user. * * @param UserRecord $user The user to update the credentials for * @return Boolean True on success */ public function assignCredentials(UserRecord $user) { $db = new DatabaseConnection(); // Generate a new salt and hash the password $salt = $this->generateSalt(); // What hashing algorithm to use $ha = config::get('lepton.user.hashalgorithm', 'md5'); $ps = $user->password . $salt; $hp = hash($ha, $ps); if ($user->userid == null) { $uuid = UUID::v4(); try { $id = $db->insertRow("REPLACE INTO " . LEPTON_DB_PREFIX . "users (username,salt,password,email,flags,registered,uuid) VALUES (%s,%s,%s,%s,%s,NOW(),%s)", $user->username, $salt, $hp, $user->email, $user->flags, $uuid); $user->userid = $id; } catch (Exception $e) { throw $e; // TODO: Handle exception } } else { try { $db->updateRow("UPDATE " . LEPTON_DB_PREFIX . "users SET username=%s,salt=%s,password=%s,email=%s,flags=%s WHERE id=%d", $user->username, $salt, $hp, $user->email, $user->flags, $user->userid); } catch (Exception $e) { throw $e; // TODO: Handle exception } } return true; }
public function EditEntity($bo) { $db = new Database(); $newID = UUID::newID(); $ID = str_replace("sys", "", $bo["EntityName"]) . "id"; if ($bo[$ID] != null) { $values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo); $sql = 'UPDATE ' . $bo["EntityName"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"'; } else { // $fields = str_replace($ID . ",", "", $bo["EntityFields"]); $values = SqlHelper::GetValues(explode(",", $fields), $bo); $sql = 'INSERT INTO ' . $bo["EntityName"] . '(' . $ID . ',' . $fields . ')' . ' VALUES("' . $newID . '",' . $values . ')'; //table if ($bo["EntityName"] == 'sysentity') { $table = ';CREATE TABLE IF NOT EXISTS ' . $bo["Name"] . '(' . $bo["Name"] . 'ID INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (' . $bo["Name"] . 'ID))ENGINE = InnoDB'; $sql .= $table; } if ($bo["EntityName"] == 'sysproperty') { $result = $db->RunSQL('SELECT Name FROM SysEntity WHERE EntityID = ' . $bo["EntityID"]); $table = ';ALTER TABLE ' . $result[0]['Name'] . ' ADD COLUMN ' . $bo["Name"] . ' VARCHAR(45) NULL '; $sql .= $table; } } $result = $db->ExecuteSQL($sql); return $this->GetEntityView($bo["RefreshEntityViewID"], array("id" => $newID)); }
public function Execute($db, $params) { $sql = "SELECT Identifier, Type, Credential, UserID, Enabled FROM Identities WHERE"; $id = null; if (isset($params["UserID"]) && UUID::TryParse($params["UserID"], $id)) { $sql .= " UserID=:ID"; } else { if (isset($params["Identifier"])) { $id = $params["Identifier"]; $sql .= " Identifier=:ID"; } else { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } } $sth = $db->prepare($sql); if ($sth->execute(array(':ID' => $id))) { $found = array(); while ($obj = $sth->fetchObject()) { $found[] = sprintf('{"Identifier":"%s","Credential":"%s","Type":"%s","UserID":"%s","Enabled":%s}', $obj->Identifier, $obj->Credential, $obj->Type, $obj->UserID, $obj->Enabled ? 'true' : 'false'); } header("Content-Type: application/json", true); echo '{"Success":true,"Identities":[' . implode(',', $found) . ']}'; exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
public function Execute($db, $params) { $asset = null; $assetID = null; if (isset($params["ID"]) && UUID::TryParse($params["ID"], $assetID)) { log_message('debug', "xGetAsset asset: {$assetID}"); $assets = new SQLAssets($db); $asset = $assets->GetAsset($assetID); } $response = array(); if (!empty($asset)) { $response['Success'] = TRUE; $response['SHA256'] = $asset->SHA256; $response['Last-Modified'] = gmdate(DATE_RFC850, $asset->CreationDate); $response['CreatorID'] = $asset->CreatorID; $response['ContentType'] = $asset->ContentType; $response['ContentLength'] = $asset->ContentLength; $response['EncodedData'] = base64_encode($asset->Data); $response['Temporary'] = $asset->Temporary; } else { log_message('info', "Asset {$assetID} not found"); $response['Success'] = FALSE; $response['Message'] = "Asset {$assetID} not found"; } header("Content-Type: application/json", true); echo json_encode($response); exit; }
public function Execute($db, $params) { if (isset($params["SceneID"], $params["Enabled"]) && UUID::TryParse($params["SceneID"], $this->SceneID)) { $sql = "UPDATE Scenes SET Enabled=:Enabled WHERE ID='" . $this->SceneID . "'"; } else { if (isset($params["Name"], $params["Enabled"])) { $sql = "UPDATE Scenes SET Enabled=:Enabled WHERE Name='" . $params["Name"] . "'"; } else { log_message('error', sprintf("AddScene: Unable to parse passed parameters or parameter missing: '%s'", print_r($params, true))); header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } } $sth = $db->prepare($sql); if ($sth->execute(array(':Enabled' => $params["Enabled"]))) { if ($sth->rowCount() > 0) { header("Content-Type: application/json", true); echo '{ "Success": true }'; exit; } else { log_message('error', "Failed updating the database"); header("Content-Type: application/json", true); echo '{ "Message": "Database update failed" }'; exit; } } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
protected function getObject() { $this->title = $this->object->title; $this->crumbName = $this->object->title; $this->addCrumb(); if (null !== ($tag = $this->request->consume())) { $obj = null; if (null !== ($uuid = UUID::isUUID($tag))) { $rs = $this->model->query(array('uuid' => $uuid, 'parent' => $this->object->uuid)); $obj = $rs->next(); } else { $rs = $this->model->query(array('tag' => $tag, 'parent' => $this->object->uuid)); $obj = $rs->next(); } if (!$obj) { return $this->error(Error::OBJECT_NOT_FOUND); } switch ($obj->kind) { case 'episode': require_once dirname(__FILE__) . '/browse-episode.php'; $inst = new MediaBrowseEpisode(); $inst->object = $obj; $inst->process($this->request); return false; } print_r($obj); die('-- unhandled object --'); } $this->object->merge(); $this->episodes = $this->model->query(array('kind' => 'episode', 'parent' => $this->object->uuid)); if ($this->episodes->EOF) { $this->episodes = null; } return true; }
public function Execute($db, $params) { $this->inventory = new ALT($db); $folderid = ''; if (!isset($params["FolderID"]) || !UUID::TryParse($params["FolderID"], $folderid)) { $folderid = UUID::Random(); } $this->Folder = new InventoryFolder($folderid); if (!isset($params, $params["Name"], $params["ParentID"], $params["OwnerID"]) || !UUID::TryParse($params["ParentID"], $this->Folder->ParentID) || !UUID::TryParse($params["OwnerID"], $this->Folder->OwnerID)) { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } $this->Folder->Name = trim($params["Name"]); $this->Folder->ContentType = isset($params["ContentType"]) && trim($params["ContentType"]) != '' ? trim($params["ContentType"]) : 'application/octet-stream'; $this->Folder->ExtraData = isset($params["ExtraData"]) ? trim($params["ExtraData"]) : ''; try { $result = $this->inventory->InsertNode($this->Folder); if ($result != FALSE) { header("Content-Type: application/json", true); echo sprintf('{ "Success": true, "FolderID": "%s" }', $result); exit; } else { header("Content-Type: application/json", true); echo '{ "Message": "Folder creation failed" }'; exit; } } catch (Exception $ex) { log_message('error', sprintf("Error occurred during query: %s", $ex)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
public function Execute($db, $params) { $sql = "DELETE FROM Sessions"; if (isset($params['SessionID']) && UUID::TryParse($params['SessionID'], $this->ID)) { $sql .= " WHERE SessionID=:ID"; } else { if (isset($params['UserID']) && UUID::TryParse($params['UserID'], $this->ID)) { $sql .= " WHERE UserID=:ID"; } else { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } } $sth = $db->prepare($sql); if ($sth->execute(array(':ID' => $this->ID))) { header("Content-Type: application/json", true); echo '{ "Success": true }'; exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
/** * Returns an instance of type UUID * * @return UUID */ public static function getInstance() { if (self::$instance === null) { self::$instance = new UUID(); } return self::$instance; }
public function indexAction() { if ($this->request->isPost()) { $register = new Users(); $register->id = UUID::v4(); $register->password = $this->security->hash($this->request->getPost('password')); $register->phonenumber = $this->request->getPost('phonenumber'); $register->email = $this->request->getPost('email'); $register->name = $this->request->getPost('name'); $register->created_date = Carbon::now()->now()->toDateTimeString(); $register->updated_date = Carbon::now()->now()->toDateTimeString(); $user = Users::findFirstByEmail($register->email); if ($user) { $this->flash->error("can not register, User " . $register->email . " Alredy Registerd! "); return true; } if ($register->save() === true) { $this->session->set('user_name', $register->name); $this->session->set('user_email', $register->email); $this->session->set('user_id', $register->id); $this->flash->success("Your " . $register->email . " has been registered Please Login for booking court"); $this->response->redirect('dashboard'); } } }
public function Execute($db, $params) { if (!isset($params["OwnerID"]) || !UUID::TryParse($params["OwnerID"], $this->OwnerID)) { header("Content-Type: application/json", true); echo '{ "Message": "Invalid parameters" }'; exit; } $sql = "SELECT ID,Resource,UNIX_TIMESTAMP(ExpirationDate) AS ExpirationDate FROM Capabilities WHERE OwnerID=:OwnerID AND UNIX_TIMESTAMP(ExpirationDate) > UNIX_TIMESTAMP()"; $sth = $db->prepare($sql); if ($sth->execute(array(':OwnerID' => $this->OwnerID))) { $caplist = array(); while ($obj = $sth->fetchObject()) { $cap = sprintf('{"CapabilityID":"%s","Resource":"%s","Expiration":"%s"}', $obj->ID, $obj->Resource, $obj->ExpirationDate); $caplist[] = $cap; } header("Content-Type: application/json", true); echo '{ "Success":true,"Capabilities":[' . implode(',', $caplist) . ']}'; exit; } else { log_message('error', sprintf("Error occurred during query: %d %s", $sth->errorCode(), print_r($sth->errorInfo(), true))); log_message('debug', sprintf("Query: %s", $sql)); header("Content-Type: application/json", true); echo '{ "Message": "Database query error" }'; exit; } }
public function action_ajax_update($handler) { $users = Users::get(); $payload = $handler->handler_vars->raw('payload'); $decoded_payload = json_decode($payload); if (isset($decoded_payload)) { // Invalid decoded JSON is NULL. $commit_sha = $decoded_payload->after; $owner = isset($decoded_payload->repository->organization) ? $decoded_payload->repository->organization : $decoded_payload->repository->owner->name; $repo_URL = $decoded_payload->repository->url; $tree_URL = "https://api.github.com/repos/" . $owner . "/" . $decoded_payload->repository->name . "/git/trees/{$commit_sha}"; $decoded_tree = json_decode(file_get_contents($tree_URL, 0, null, null)); $xml_urls = array_map(function ($a) { if (strpos($a->path, ".plugin.xml") !== false || $a->path === 'theme.xml') { return $a->url; // path was just the filename, url is the API endpoint for the file itself } }, $decoded_tree->tree); $xml_urls = array_filter($xml_urls); // remove NULLs if (count($xml_urls) === 1) { $xml_URL = array_pop($xml_urls); $decoded_blob = json_decode(file_get_contents($xml_URL, 0, null, null)); if ($decoded_blob->encoding === 'base64') { $xml_data = base64_decode($decoded_blob->content); } else { if ($decoded_blob->encoding === 'utf-8') { // does it need to be decoded? } else { // there's an invalid encoding. return; } } $xml_object = simplexml_load_string($xml_data, 'SimpleXMLElement'); /* can't hurt to hold onto these */ $xml_object->addChild("xml_string", $xml_object->asXML()); /* won't always need these */ $xml_object->addChild("tree_url", $tree_URL); $xml_object->addChild("blob_url", $xml_URL); $xml_object->addChild("ping_contents", $payload); /* might need this. Or should it go in downloadurl? */ $xml_object->addChild("repo_url", $repo_URL); /* need to check if there's already a posts with this guid */ if (!isset($xml_object->guid) || trim($xml_object->guid) == '') { // You must have a GUID or we can't find your plugin... // @todo Send the owner an error message/file an issue on the repo $this->file_issue($owner, $decoded_payload->repository->name, 'Info XML needs a GUID', "Habari addons require a GUID to be listed in the Addons Directory.<br>Please create and add a GUID to your xml file. You can use this one, which is new:<br><b>" . UUID::get() . "</b>"); } else { EventLog::log(_t('Making post for GUID %s', array(trim($xml_object->guid))), 'info'); self::make_post_from_XML($xml_object); } } else { // Wrong number of xml files. $this->file_issue($owner, $decoded_payload->repository->name, 'Too many XML files', "Habari addons should have a single XML file containing addon information.<br>"); } } else { // Something has gone wrong with the json_decode. Do nothing, since there is nothing that can really be done. } }
/** * Do general tasks used application whide */ protected function doBaseTasks() { $this->showTestHeadline("Checking application base structure"); if (HSetting::Get('secret') == "" || HSetting::Get('secret') == null) { HSetting::Set('secret', UUID::v4()); $this->showFix('Setting missing application secret!'); } }
public static function generateUUID() { $uuid = UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING); while (!self::uniqueUUID($uuid)) { $uuid = UUID::generate(UUID::UUID_RANDOM, UUID::FMT_STRING); } return $uuid; }
/** * @param mixed $id * @return WeLearn_DTO_IDTO */ public function remover($id) { $UUID = UUID::import($id); $respostaRemovida = $this->recuperar($id); $this->_cf->remove($UUID->bytes); $respostaRemovida->setPersistido(false); return $respostaRemovida; }
/** * Create a LockTocken from a string * * @param string str * @return util.webdav.LockTocken * @throws lang.FormatException in case the string is not a valid opaquelocktoken */ public static function fromString($str) { list($prefix, $uuidstr) = explode(':', $str, 2); if (LOCKTOKEN_PREFIX !== $prefix || FALSE === ($uuid = UUID::fromString($uuidstr))) { throw new FormatException($str . ' is not a valid opaquelocktoken string'); } return new OpaqueLockTocken($uuid); }
/** * Before Save Addons * * @return type */ protected function beforeSave() { if ($this->isNewRecord) { // Create GUID for new files $this->guid = UUID::v4(); } return parent::beforeSave(); }
function Write($head, $message) { self::DeleteOld(); $guid = UUID::v4(); $date = date("Y-m-d H:i:s"); $user = Session::GetUserId($this->session); $this->db->Exec("INSERT INTO `Logs`(`id`,`UserId`,`DateTime`,`Head`,`Message`)\n VALUE ('{$guid}','{$user}','{$date}','{$head}','{$message}'); "); }
/** * @param WeLearn_DTO_IDTO $dto * @return void */ protected function _adicionar(WeLearn_DTO_IDTO &$dto) { $UUID = UUID::mint(); $dto->setId($UUID->string); $this->_cf->insert($UUID->bytes, $dto->toCassandra()); $uuidFeed = CassandraUtil::import($dto->getCompartilhamento()->getId())->bytes; $this->_comentarioPorCompartilhamentoCF->insert($uuidFeed, array($UUID->bytes => '')); }
public function EditEntity($bo) { $db = new Database(); $newID = UUID::newID(); $propertyID = UUID::newID(); $ID = str_replace("sys", "", $bo["entityname"]) . "id"; $ID_Field = str_replace("sys", "", $bo["name"]) . "id"; //$sql = "START TRANSACTION;"; if ($bo[$ID] != null) { $values = SqlHelper::GetUpdates(explode(",", $bo["EntityFields"]), $bo); $sql .= 'UPDATE ' . $bo["entityname"] . ' SET ' . $values . ' WHERE ' . $ID . ' = "' . $bo[$ID] . '"'; //echo $sql; } else { // $fields = str_replace("," . $ID . ",", ",", "," . $bo["EntityFields"] . ","); $fields = substr($fields, 1, $fields . length - 1); $values = SqlHelper::GetValues(explode(",", $fields), $bo); $sql .= 'INSERT INTO ' . $bo["entityname"] . '(' . $ID . ',' . $fields . ') VALUES("' . $newID . '",' . $values . ')'; //echo $sql; //table if ($bo["entityname"] == 'sysentity') { $sql .= ';INSERT INTO sysproperty(propertyid, entityid, name) VALUES("' . $propertyID . '","' . $newID . '", "' . $ID_Field . '")'; $table = ';CREATE TABLE IF NOT EXISTS ' . $bo["name"] . '(' . $ID_Field . ' VARCHAR(100) NOT NULL, ' . ' createddate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, ' . 'PRIMARY KEY (' . $ID_Field . '))ENGINE = InnoDB'; $sql .= $table; //echo $sql; } if ($bo["entityname"] == 'sysproperty' && !$bo["isonlyview"]) { $columnType = ' VARCHAR(255) NULL'; if ($bo["xtype"] == "numberfield") { $columnType = ' INT NULL'; } else { if ($bo["xtype"] == "datefield") { $columnType = ' DATETIME NULL'; } else { if ($bo["xtype"] == "textareafield") { $columnType = ' TEXT NULL'; } else { if ($bo["xtype"] == "checkboxfield") { $columnType = ' BOOL NULL'; } else { if ($bo["xtype"] == "htmleditor") { $columnType = ' TEXT NULL'; } } } } } $result = $db->RunSQL('SELECT name FROM sysentity WHERE entityid = "' . $bo["entityid"] . '"'); $table = ';ALTER TABLE ' . $result[0]['name'] . ' ADD COLUMN ' . $bo["name"] . ' ' . $columnType; $sql .= $table; } } //$sql .= ';COMMIT;'; //echo $sql; $entity = array("entityViewID" => $bo["RefreshEntityViewID"]); $result = $db->ExecuteSQL($sql); return $this->GetEntityView($entity); }