function fetch() { global $config; $ret = array('status' => 'fail'); $dbh = new PDO($config['coolsitebro']['driver'] . ':host=' . $config['coolsitebro']['host'] . ';dbname=' . $config['coolsitebro']['dbname'], $config['coolsitebro']['username'], $config['coolsitebro']['password']); $code = alphaID($_REQUEST['code'], true); $sth = $dbh->prepare("select url from redirects where id=?"); if (!$sth) { $err = $dbh->errorInfo(); $ret['reason'] = $err[2]; // $err is an array full of 2 useless items followed by descriptive text } else { if (!$sth->execute(array($code))) { $err = $sth->errorInfo(); $ret['reason'] = $err[2]; } else { $ret['status'] = 'success'; $url = $sth->fetchColumn(); } } if ($ret['status'] == 'fail') { echo json_encode($ret); } else { header("Location: " . $url); } }
public function saveImg() { Trace::output($this->traceID, "saveImg"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => 1); //---------------------------------------------------------- $img = str_replace('data:image/png;base64,', '', $this->img); $img = str_replace(' ', '+', $img); $data = base64_decode($img); $date = new DateTime(); //---------------------------------------------------------- if (is_null($imgName) || $encrypt) { $imgName = alphaID($date->getTimestamp()) . ".png"; } //---------------------------------------------------------- if (file_exists($this->dir)) { FileFolder::file_put_contents($this->dir . $imgName, $data); $chk["result"] = $this->fullURL . $imgName; } else { $chk['bool'] = false; $chk['message'] = $this->fullURL . " does no exist!!"; } //---------------------------------------------------------- return $chk; }
function get($id) { $this->id = alphaID($id, true); // grab paste from database $sql = ' SELECT *, ( UNIX_TIMESTAMP() - added ) as counter FROM pastes WHERE id = ? LIMIT 1 '; $stmt = $this->db->prepare($sql); $stmt->bind_param('i', $this->id); $stmt->execute(); $res = $stmt->get_result(); if (($paste = $res->fetch_array(MYSQLI_ASSOC)) !== false) { $this->paste = $paste; // assign to class variable // check to see if this paste has expired $expired = $this->has_expired(); if ($expired === false) { return $this->paste; } return $expired; } return EZCRYPT_DOES_NOT_EXIST; }
public static function getNextInsertID($table, $hash = true, $append = "") { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'result' => array(), "func" => "getHash"); //---------------------------------------------------------- $date = date("Y-m-d H:i:s"); //---------------------------------------------------------- $chk = GetTable::getLastID($table); //---------------------------------------------------------- if (!$chk['bool']) { $chk['bool'] = false; $chk['message'] = "getHash() returned NULL"; return $chk; } //---------------------------------------------------------- if ($chk['bool']) { $total = $chk['result']; } //---------------------------------------------------------- $insert_id = $total + 1; //---------------------------------------------------------- return $hash ? alphaID($insert_id . $date . $append) : alphaID($insert_id); }
function get($id) { $id = alphaID($id, true); if (false !== ($paste = db_get($id))) { // check to see if this paste has expired $expired = $this->has_expired($paste); if ($expired === false) { return $paste; } return $expired; } return NCRYPT_DOES_NOT_EXIST; }
public function saveAsJPEG($ba, $imgName, $encrypt = false) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => 1); //---------------------------------------------------------- $data = $ba->data; $date = new DateTime(); //---------------------------------------------------------- if ($encrypt) { $imgName = alphaID($date->getTimestamp()) . ".jpg"; } //return str_replace(".", "", GenFun::escapeString(GenFun::encrypt($imgName+date('l jS \of F Y h:i:s A')))); //---------------------------------------------------------- file_put_contents($this->largeImg_dir . $imgName, $data); //---------------------------------------------------------- $chk["result"] = $this->fullURL . $imgName; //---------------------------------------------------------- $chk["func"] = $this->traceID . ": saveAsJPEG"; //---------------------------------------------------------- return $chk; }
/** * Retrieves user-submitted videos from YouTube and returns the * result as a JSON array. */ public function getObservationDateVideos() { include_once HV_ROOT_DIR . '/../src/Database/MovieDatabase.php'; include_once HV_ROOT_DIR . '/../src/Movie/HelioviewerMovie.php'; include_once HV_ROOT_DIR . '/../lib/alphaID/alphaID.php'; include_once HV_ROOT_DIR . '/../src/Helper/HelioviewerLayers.php'; $movies = new Database_MovieDatabase(); // Default options $defaults = array('num' => 10, 'skip' => 0, 'date' => getUTCDateString()); $opts = array_replace($defaults, $this->_options); // Get a list of recent videos $videos = array(); foreach ($movies->getSharedVideosByTime($opts['num'], $opts['skip'], $opts['date']) as $video) { $youtubeId = $video['youtubeId']; $movieId = (int) $video['movieId']; // Convert id $publicId = alphaID($movieId, false, 5, HV_MOVIE_ID_PASS); // Load movie $movie = new Movie_HelioviewerMovie($publicId); $layers = new Helper_HelioviewerLayers($video['dataSourceString']); $layersArray = $layers->toArray(); $name = ''; if (count($layersArray) > 0) { foreach ($layersArray as $layer) { $name .= $layer['name'] . ', '; } } $name = substr($name, 0, -2); array_push($videos, array('id' => $publicId, 'url' => 'http://www.youtube.com/watch?v=' . $youtubeId, 'thumbnails' => array('small' => $video['thumbnail'], 'medium' => $video['thumbnail']), 'published' => $video['timestamp'], 'title' => $name . ' (' . $video['startDate'] . ' - ' . $video['endDate'] . ' UTC)', 'description' => $video['description'], 'keywords' => $video['keywords'], 'imageScale' => $video['imageScale'], 'dataSourceString' => $video['dataSourceString'], 'eventSourceString' => $video['eventSourceString'], 'movieLength' => $video['movieLength'], 'width' => $video['width'], 'height' => $video['height'], 'startDate' => $video['startDate'], 'endDate' => $video['endDate'])); } $this->_printJSON(json_encode($videos)); }
public function session_CHK($email = NULL, $accounts_id = NULL) { Trace::output($this->traceID, "session_CHK", func_get_args()); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "session_CFG"); $userKey; $last_userKey; //---------------------------------------------------------- if (is_null($email) && !isset($_COOKIE[$this->cookiePrefix . "user"])) { $chk['bool'] = false; } //---------------------------------------------------------- if (!$chk['bool']) { $chk['message'] = "No session or email exist!!!"; return $chk; } //---------------------------------------------------------- if (session_id() == '') { session_start(); } //---------------------------------------------------------- if ($chk['bool'] && isset($_COOKIE[$this->cookiePrefix . "user"]) && is_null($email)) { $chk = $this->getSession($_COOKIE[$this->cookiePrefix . 'user']); if ($chk['bool']) { //Constants::$loggedIN = $chk['result'][0]; $email = $chk['result'][0]['email']; $accounts_id = $chk['result'][0]['id']; } } else { $chk['bool'] = false; } //---------------------------------------------------------- if (!$chk['bool'] && is_null($email)) { $chk['bool'] = false; $chk['message'] = "No session or email exist!!!"; return $chk; } //---------------------------------------------------------- $session_id = GenFun::encrypt(session_id() . $this->salt . $email); //---------------------------------------------------------- $last_userKey = $_COOKIE[$this->cookiePrefix . "user"]; //---------------------------------------------------------- $userKey = $email . "-" . alphaID(time() . rand(0, 13000000)); //---------------------------------------------------------- setcookie($this->cookiePrefix . "user", $userKey, GenFun::getCookieTime()); //---------------------------------------------------------- $this->setAndChk($email); //---------------------------------------------------------- if (!$chk['bool']) { $chk = GetTable::go(Accounts_const::TBL, array("email" => $email)); //------------------------------------------------------ if ($chk['bool'] && sizeof($chk['result']) > 0) { Update::go(SessionLog_const::TBL, array("disabled" => "{function}NOW()"), array("accounts_id" => $chk['result'][0]['id'])); } //------------------------------------------------------ session_regenerate_id(); $session_id = GenFun::encrypt(session_id() . $this->salt . $email); if ($chk['bool']) { $chk = InsertINTO::go(SessionLog_const::TBL, array("userKey" => $userKey, "accounts_id" => $chk['result'][0]['id'], "session_id" => $session_id)); } //------------------------------------------------------ $session = $this->getSession($userKey); //------------------------------------------------------ if ($session['bool']) { Constants::$loggedIN = $session['result'][0]; } } else { setcookie("shit", $userKey, GenFun::getCookieTime()); $chk = Update::go(SessionLog_const::TBL, array("userKey" => $userKey), array("userKey" => $last_userKey)); Constants::$loggedIN['userKey'] = $userKey; if ($chk['bool']) { $chk['message'] = "session for this user has already been established!!!"; } } //---------------------------------------------------------- return $chk; }
/** * Soft Delete the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function delete(Request $request) { $swatch = Swatch::find(alphaID($request->input('slug'), true)); $result = $swatch->deleteBlock($request->input('slug'), $request->input('block')); App::make('Pusher')->trigger('swatch_update_trigger_' . $request->input('slug'), 'update', ['message' => 'update transmitted']); return $result; }
private function _loadFromDB($publicId, $format) { $this->_dbSetup(); $id = alphaID($publicId, true, 5, HV_MOVIE_ID_PASS); $info = $this->_db->getMovieInformation($id); if (is_null($info)) { throw new Exception('Unable to find the requested movie: ' . $id, 24); } return $info; }
public function insertINTO() { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'function' => "insertINTO"); $this->updateArr = array(); //---------------------------------------------------------- $chk = GenFun::errorKey_chk($this->setArr, NULL, true); //---------------------------------------------------------- $this->setArr = $chk['valueArr']; //---------------------------------------------------------- if (!$chk['bool']) { return $chk; } //---------------------------------------------------------- $this->tableID = Constants::$mysqli->real_escape_string($this->tableID); //---------------------------------------------------------- $this->queryString = $this->insertType . " " . $this->tableID . " ("; foreach ($this->setArr as $i => $value) { if (strrpos($value, "{hash}") === 0) { $this->updateArr[$i] = $value; } else { $this->queryString .= $i . ","; } } //---------------------------------------------------------- foreach ($this->updateArr as $i => $value) { unset($this->setArr[$i]); } //---------------------------------------------------------- $this->queryString = substr($this->queryString, 0, -1); $this->queryString .= ") "; //---------------------------------------------------------- $keys = array_keys($this->setArr); $this->queryString .= "VALUES "; //---------------------------------------------------------- $high = sizeof($this->setArr[$keys[0]]); for ($i = 1; $i < sizeof($this->setArr); $i++) { if (is_array($this->setArr[$keys[$i]])) { $cur = sizeof($this->setArr[$keys[$i]]); if ($high < $cur) { $high = $cur; } } } //---------------------------------------------------------- for ($i = 0; $i < 1; $i++) { $value = $this->setArr[$keys[$i]]; $num = is_array($value) ? sizeof($value) : 1; for ($j = 0; $j < $high; $j++) { if (is_array($this->setArr[$keys[$i]])) { $value = $this->setArr[$keys[$i]][$j]; } if ($i == 0) { $this->queryString .= "("; } if (strrpos($value, "(") !== false && strrpos($value, "(") == 0 && !$this->ignore) { $this->queryString .= $value; //$this->queryString .= ","; } else { if ($value == "DEFAULT") { $this->queryString .= $value; } else { $this->queryString .= "'" . Constants::$mysqli->escape_string($value) . "'"; } } //------------------------------------------------- for ($k = 0; $k < sizeof($this->setArr); $k++) { if ($keys[$k] != $keys[$i]) { $this->queryString .= ","; if (is_array($this->setArr[$keys[$k]])) { $v = $this->setArr[$keys[$k]][$j]; $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'"; } else { $v = $this->setArr[$keys[$k]]; $this->queryString .= "'" . Constants::$mysqli->escape_string($v) . "'"; } } } //------------------------------------------------- //if ($i == sizeof($this->setArr)-1) { //$this->queryString = substr($this->queryString, 0, -1); $this->queryString .= ")"; //} //------------------------------------------------- if ($j < $high - 1) { $this->queryString .= ","; } } } //---------------------------------------------------------- if (!is_null($this->onDuplicate)) { $this->queryString .= " ON DUPLICATE KEY UPDATE "; $this->queryString = MySQL::condition($this->tableID, $this->onDuplicate, NULL, $this->queryString); } //---------------------------------------------------------- if (!$this->returnQuery) { $chk = $this->getResult(); $insert_id = $chk['insert_id']; if ($chk['duplicate']) { $chk['duplicate'] = GetTable::go($this->tableID, $this->setArr); } else { if (sizeof($this->updateArr) > 0) { foreach ($this->updateArr as $i => $value) { if (strrpos($value, "{hash}") === 0) { $value = strtr($value, array('{hash}' => "")); /*if (!is_numeric($value)) { $chk['bool'] = false; $chk['messgae'] = "In order to use the alphaID() utility ".$value.' must be numeric!!!'; return $chk; }*/ $this->updateArr[$i] = alphaID($insert_id . $value); } } $this->setArr['id'] = $insert_id; $chk = Update::go($this->tableID, $this->updateArr, $this->setArr); } } if (!$chk['bool']) { return $chk; } if ($this->returnRow) { $chk['row'] = GetTable::go($this->tableID, array("id" => $insert_id)); if ($chk['row']['bool']) { $chk['row'] = $chk['row']['result'][0]; } } $chk['insert_id'] = $insert_id; return $chk; } else { return $this->queryString; } }
function post($data, $syntax, $ttl, $password, $cipher) { $template = $this->template; // This may be required if a user is dealing with a file that is so large that it takes more than 30 seconds set_time_limit(0); require_once __DIR__ . '/paste.class.php'; $pastes = new Paste(); // new post submission $paste = $pastes->add($data, $syntax, $ttl, $password, $cipher); // return our new ID to the user $output = array('id' => alphaID($paste, false)); $template->render(200, null, $output); }
private function confirmLink_hash_CFG($id) { Trace::output($this->traceID, "confirmLink_hash_CFG"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, "traceID" => "confirmLink_hash_CFG"); //---------------------------------------------------------- $date = date("Y-m-d H:i:s"); $linkHash = alphaID($id . strtotime($date)); //---------------------------------------------------------- $chk = Update::go($this->confirmLinkTbl, array("hash" => $linkHash), array("id" => $id)); //---------------------------------------------------------- $chk['result']['hash'] = $linkHash; //---------------------------------------------------------- return $chk; }
public function insertInvites($obj) { $hash; $queryString = "INSERT INTO invites\n\t\t(from_accounts_id, to_accounts_id, teams_id, events_id, auto_approve, email, hash)\n\t\tVALUES "; for ($i = 0; $i < sizeof($obj["players"]); $i++) { $hash = alphaID($i . $obj['events_id'] . $obj['to_accounts_id'] . $obj['teams_id'] . strtotime(date("Y-m-d H:i:s"))); //-------------------------------------------------- $queryString .= "('116', '" . $obj['players'][$i]['id'] . "', '" . $obj['teams_id'] . "', '" . $obj['events_id'] . "',"; $queryString .= $obj['players'][$i]['info']['rosterOption'] == 1 ? "'1'," : "DEFAULT,"; $queryString .= "DEFAULT,"; $queryString .= "'" . $hash . "'"; $queryString .= ")"; if ($i < sizeof($obj["players"]) - 1) { $queryString .= ","; } $obj['players'][$i]['hash'] = $hash; } //---------------------------------------------------------- if (sizeof($obj["emails"]) != 0) { $queryString .= ","; //------------------------------------------------------ for ($i = 0; $i < sizeof($obj["emails"]); $i++) { $hash = alphaID(GenFun::encrypt($obj['emails'][$i]['id']) . $i . $obj['events_id'] . $obj['teams_id'] . strtotime(date("Y-m-d H:i:s"))); //-------------------------------------------------- $queryString .= "('116', DEFAULT, '" . $obj['teams_id'] . "', '" . $obj['events_id'] . "',"; $queryString .= $obj['emails'][$i]['info']['rosterOption'] == 1 ? "1" : "DEFAULT, "; $queryString .= "'" . $obj['emails'][$i]['id'] . "',"; $queryString .= "'" . $hash . "'"; $queryString .= ")"; if ($i < sizeof($obj["emails"]) - 1) { $queryString .= ","; } $obj['emails'][$i]['hash'] = $hash; } } //---------------------------------------------------------- $chk = Result::go($queryString); //---------------------------------------------------------- $chk['obj'] = $obj; //---------------------------------------------------------- return $chk; }
public function _newPlaylist($title = NULL, $idArr = NULL, $getList = false) { Trace::output($this->traceID, "newPlaylist"); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, "traceID" => "newPlaylist"); //---------------------------------------------------------- $setArr = array(); $update = false; //---------------------------------------------------------- $date = date("Y-m-d H:i:s"); if (is_null($title)) { $title = "DEFAULT"; } //---------------------------------------------------------- $chk = GetTable::go('playlist', array('title' => "{$title}", 'disabled' => "{ignore} IS NULL", 'accounts_id' => GlobalMas::$loggedIN['id'])); //---------------------------------------------------------- if (sizeof($chk['result']) > 0) { $chk['bool'] = false; $chk['message'] = "Playlist titled '{$title}' already exist."; } //---------------------------------------------------------- if ($chk['bool']) { $chk = InsertINTO::go('playlist', array("title" => $title, "accounts_id" => GlobalMas::$loggedIN['id']), array("returnRow" => true, "onDuplicate" => array('disabled' => '{DEFAULT}'))); } else { return $chk; } //---------------------------------------------------------- //print_r($chk); if ($chk['bool']) { $table = $chk['result'][0]; } else { return $chk; } //---------------------------------------------------------- $insert_id = GlobalMas::$mysqli->insert_id; //---------------------------------------------------------- $hash = alphaID(strtotime($table['date']) . $insert_id); //---------------------------------------------------------- if ($chk['bool']) { $chk = Update::go('playlist', array("hash" => $hash), array("id" => $insert_id), array("returnTable" => true)); } else { return $chk; } //---------------------------------------------------------- if ($chk['bool']) { $table = $chk['result'][0]; } //---------------------------------------------------------- $setArr['playlist_id'] = $insert_id; $setArr['videos_id'] = $idArr; //---------------------------------------------------------- if ($chk['bool'] && !is_null($idArr)) { $chk = InsertINTO::go('playlist_videos', $setArr); } //---------------------------------------------------------- if (!$chk['bool']) { return $chk; } //---------------------------------------------------------- if ($getList) { $table = $this->getPlaylist(); $table = $table['result']; $chk['title'] = $title; } //---------------------------------------------------------- $chk['result'] = $table; //---------------------------------------------------------- $chk['message'] = "Playlist '{$title}' has successfully been created!!!"; //---------------------------------------------------------- if ($chk['bool']) { $this->resetQueries(); } //---------------------------------------------------------- return $chk; }
private function newSwf() { //---------------------------------------------------------- $result = $this->uploadClass->post(false); //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'traceID' => "newSwf"); //---------------------------------------------------------- if ($chk[bool]) { $swfData = new SwfData(); $chk = $swfData->getData(dirname(__FILE__) . "/jquery_fileupload/swfmngr_v0/files/" . $result['files'][0]->name); } //---------------------------------------------------------- if ($chk[bool] && is_null($result["files"][0]->error)) { $date = new DateTime(); $id_result = $this->getLastID(Projects_const::TBL); $encrypt = alphaID($id_result['result'] . $date->getTimestamp()); $setArr = array(Swfs_const::CLM_UPLOADRESULT => json_encode($result["files"]), Swfs_const::CLM_URL => $result["files"][0]->url, Swfs_const::CLM_INFO => json_encode($chk['result']), Swfs_const::CLM_SWFKEY => $encrypt, Swfs_const::CLM_LINK => $this->swfReader_url . "id=" . $encrypt); //------------------------------------------------------ $chk = InsertINTO::go(array("tableID" => Swfs_const::TBL, "setArr" => $setArr)); } //---------------------------------------------------------- $chk['result'] = $result["files"][0]->name; //---------------------------------------------------------- return $chk; }
/** * Uploads a single video to YouTube * * @param int $id Movie id * @param array $options Movie options * @param Zend_Gdata_YouTube_VideoEntry $videoEntry A video entry object * describing the video to be uploaded * * Note: Content-length and Connection: close headers are sent so that * process can be run in the background without the user having to wait, * and the database entry will be updated even if the user closes the * browser window. * * See: * http://zulius.com/how-to/close-browser-connection-continue-execution/ * * @return Zend_Gdata_YouTube_VideoEntry */ private function _uploadVideoToYouTube($video, $filepath, $id, $title, $description, $tags, $share, $html) { include_once HV_ROOT_DIR . '/../src/Database/MovieDatabase.php'; include_once HV_ROOT_DIR . '/../lib/alphaID/alphaID.php'; $movies = new Database_MovieDatabase(); // Add movie entry to YouTube table if entry does not already exist $movieId = alphaID($id, true, 5, HV_MOVIE_ID_PASS); if (!$movies->insertYouTubeMovie($movieId, $title, $description, $tags, $share)) { throw new Exception('Movie has already been uploaded. Please allow several minutes for your video to appear on YouTube.', 46); } // buffer all upcoming output ob_start(); // let user know that upload is in progress if ($html) { ?> <!DOCTYPE html> <html lang="en"> <head> <title>Helioviewer.org - YouTube Upload In Progress</title> <link rel="shortcut icon" href="../favicon.ico"> <meta charset="utf-8" /> </head> <body style='text-align: center;'> <div style='margin-top: 200px;'> <span style='font-size: 32px;'>Upload processing</span><br /> Your video should appear on YouTube in 1-2 minutes. </div> </body> <?php } else { header('Content-type: application/json'); echo json_encode(array('status' => 'upload in progress.')); } // get the size of the output $size = ob_get_length(); // send headers to tell the browser to close the connection header('Content-Length: ' . $size); header('Connection: close'); // flush all output ob_flush(); ob_end_flush(); flush(); // close current session if (session_id()) { session_write_close(); } // Begin upload try { // Specify the size of each chunk of data, in bytes. Set a higher value for // reliable connection as fewer chunks lead to faster uploads. Set a lower // value for better recovery on less reliable connections. $chunkSizeBytes = 1 * 1024 * 1024; // Setting the defer flag to true tells the client to return a request which can be called // with ->execute(); instead of making the API call immediately. $this->_httpClient->setDefer(true); // Create a request for the API's videos.insert method to create and upload the video. $insertRequest = $this->_youTube->videos->insert("status,snippet", $video); // Create a MediaFileUpload object for resumable uploads. $media = new Google_Http_MediaFileUpload($this->_httpClient, $insertRequest, 'video/*', null, true, $chunkSizeBytes); $media->setFileSize(filesize($filepath)); // Read the media file and upload it chunk by chunk. $status = false; $handle = fopen($filepath, "rb"); while (!$status && !feof($handle)) { $chunk = fread($handle, $chunkSizeBytes); $status = $media->nextChunk($chunk); } fclose($handle); // If you want to make other calls after the file upload, set setDefer back to false $this->_httpClient->setDefer(false); } catch (Zend_Gdata_App_HttpException $httpException) { throw $httpException; } catch (Zend_Gdata_App_Exception $e) { throw $e; } // Update database entry and return result $movies->updateYouTubeMovie($movieId, $status['id']); return $media; }
public function init($obj) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => true, 'result' => array(), "func" => "init"); //---------------------------------------------------------- if (!is_null($obj)) { if (isset($obj['zip'])) { $getFile = GetTable::go("files", array("id" => $obj['zip'])); //------------------------------------------------------ if (!$getFile['bool']) { return $getFile; } if (sizeof($getFile['result']) > 0) { //-------------------------------------------------- $projectName = $obj['project_name']; $hash = $getFile['result'][0]['hash']; $dir_relative = GlobalMas::$filesPath_relative . $hash . "/"; $dir = GlobalMas::$filesPath_absolute . $hash . "/"; $zip_path = $dir . $getFile['result'][0]['name']; $savePath = dirname($zip_path) . "/compile/" . $projectName . "/"; //----------------------------------------------------- Archive::extract($zip_path, $this->extractTo = dirname($zip_path) . "/" . FileFolder::getFileName($zip_path)); //----------------------------------------------------- //if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true") $projectName = FileFolder::getFileName($zip_path); //----------------------------------------------------- $url = GenFun::get_full_url(dirname($zip_path) . "/" . rawurlencode(FileFolder::getFileName($zip_path)) . "/"); //----------------------------------------------------- $bool = $this->htmlExist_CHK($this->extractTo); } } else { if (isset($obj['url']) || is_string($obj)) { $url = isset($obj['url']) ? $obj['url'] : $obj; $bool = $this->htmlExist_CHK($url_local = GenFun::get_local_url($url)); //------------------------------------------------------ $output = CurlUtil::go(array("url" => $url)); $projectName = $this->getTitle($output); //------------------------------------------------------ if (is_null($projectName)) { $projectName = date("YmdHis"); $hash = alphaID(strtotime($projectName)); $projectName = "untitled_" . $projectName; } //------------------------------------------------------ $savePath_relative = $hash . "/" . "compile/" . $projectName . "/"; $savePath = GlobalMas::$filesPath_absolute . $savePath_relative; /*if (isset($obj['take_file_name']) && $obj['take_file_name'] == "true")*/ $useTitle = true; } else { $chk = array(); $chk['bool'] = false; $chk['error'] = true; $chk['message'] = $this->notifications_CFG(["message" => "Url could not be obtained!!!"]); die(json_encode($chk)); } } //--------------------------------------------------------- $compiler = $this->compile_CFG($url, $projectName, $savePath); //--------------------------------------------------------- if (!is_null($compiler->error)) { return $compiler->error; } //--------------------------------------------------------- //$chk['bool'] = true; // $chk['compiler'] = $compiler; $notifications = $compiler->compilerGlobal->notifications; //--------------------------------------------------------- /*if (sizeof($notifications) > 0) { $chk = $this->deleteFile($getFile['result'][0]['id'], true); $chk['message'] = $this->notifications_CFG($notifications); $chk['bool'] = false; $chk['error'] = true; return $chk; }*/ //--------------------------------------------------------- $new_zip_path = Archive::zipDir($compiler->compilePath); //--------------------------------------------------------- $prop = array(); $prop['hash'] = "{hash}"; $prop['url'] = $url; $prop['name'] = $projectName; $prop['dir'] = $savePath_relative; $prop["filesize"] = FileFolder::getFileSize($new_zip_path); if (isset($obj['zip'])) { $prop['files_id'] = $obj['zip']; } //--------------------------------------------------------- $chk = InsertINTO::go("compiles", $prop); //--------------------------------------------------------- $chk['download_link'] = GenFun::get_full_url(Import::$uber_src_path . "server/werm/services/Download.php") . "?url=" . GenFun::get_full_url($new_zip_path); $chk["filesize"] = $prop["filesize"]; $chk["url"] = $url; //--------------------------------------------------------- //$chk['project_location'] = GenFun::get_full_url($compiler->compilePath); } return $chk; }
<?php define('DW_ROOT', dirname(dirname(__FILE__))); require_once DW_ROOT . '/lib/utils/alphaID.php'; $ids = split("\n", trim(file_get_contents(DW_ROOT . "/scripts/legacy-ids.txt"))); print $ids; foreach ($ids as $id) { $num_id = alphaID($id, true); print $id; // load html $html = file_get_contents('http://datawrapper.de/?c=' . $id); file_put_contents(DW_ROOT . '/www/legacy/' . $id . '.html', $html); // load data $csv = file_get_contents('http://datawrapper.de/actions/export.php?c=' . $num_id); file_put_contents(DW_ROOT . '/www/legacy/data/' . $num_id . '.csv', $csv); }
// inform the user they are unable to use it. if (isset($_GET['raw'])) { $template->assign('paste', 'You can not obtain a raw of this paste as it is password protected.'); } break; case EZCRYPT_MISSING_DATA: $template->assign('meta_title', 'EZCrypt - Paste does not exist'); $template->assign('paste_id', $display_id); die($template->render('nonexistant.tpl')); break; case EZCRYPT_NO_PASSWORD: // no password, show paste $template->assign('paste', $paste['data']); $template->assign('syntax', $paste['syntax']); break; } if (isset($_GET['raw'])) { die($template->render('raw.tpl')); } $template->assign('meta_title', 'EZCrypt - Paste'); die($template->render('paste.tpl')); } elseif (!empty($_POST)) { // new post submission $paste = $pastes->add($_POST['data'], $_POST['syn'], $_POST['ttl'], $_POST['p']); // return our new ID to the user $output = array('id' => alphaID($paste, false)); die(json_encode($output)); } // new paste $template->assign('norobots', false); $template->render('new.tpl');
public function updateBlock($slug, $blockid, $value) { if ($this->lock) { return false; } $blocks = Block::find($blockid); $blocks = $this->blocks()->where('id', $blockid); if ($blocks->count() == 0) { return false; } $block = $blocks->first(); if (alphaID($block->swatch_id) != $slug) { return false; } return $block->iterate($value); }