/** * Bootstrap any application services. * * @return void */ public function boot() { User::created(function (User $user) { Folder::create(['name' => '/', 'user_id' => $user->id]); Activity::create(['type' => 'user_created', 'user_id' => $user->id]); }); Folder::deleting(function (Folder $folder) { foreach ($folder->folders as $_folder) { $_folder->_delete(); } foreach ($folder->files as $file) { $file->delete(); } }); File::deleting(function (File $file) { $file = updateFile($file, fileInfo($file)); $filenames = []; if ($file->type == 'image') { $altImages = ['opt', 'xs']; foreach ($altImages as $suffix) { $name = explode('.', $file->filename)[0]; $extension = explode('.', $file->filename)[1]; array_push($filenames, "{$name}.{$suffix}.{$extension}"); } } Storage::delete($file->filename); if (!empty($filenames)) { foreach ($filenames as $filename) { Storage::delete($filename); } } }); }
function writeConnection($name, $url) { $new_connection = array('name' => $name, 'url' => $url); if (file_exists("../data/connections.json")) { updateFile($name, $new_connection); } else { $data = array('connections' => array($new_connection)); echo json_encode($data); writeFile(json_encode($data)); } echo generateResponse("success", json_encode($new_connection)); }
function show(Activity $activity) { $file = false; $_file = false; if ($activity->item_id) { $file = FileModel::findOrFail($activity->item_id); $_file = fileInfo($file); $file = updateFile($file, $_file); } if ($file) { switch ($file->type) { case 'audio': return "<audio preload='none' class=\"file-view\" controls>" . "<source src=\"{$file->src}\">" . "Your browser does not support the audio element." . "</audio>"; case 'video': return "<video preload='none' class=\"file-view\" controls>" . "<source src=\"{$file->src}\">" . "Your browser does not support the video tag." . "</video>"; case 'image': return "<img id=\"image-view\" class=\"file-view\" " . "src=\"{$file->src}/opt\"" . ">"; default: return '<div class="text-center text-danger">' . '<i class="fa fa-ban"></i> No Preview Available</div>'; } } }
<?php include_once 'include/common.php'; include_once 'include/db.php'; include_once 'include/html_db.php'; include_once 'include/Disk.php'; include_once 'include/File.php'; include_once 'include/Category.php'; db_open(); $dir = new DirectoryResolver(); if (isset($_REQUEST["ids"])) { $ids = $_REQUEST["ids"]; } else { $ids = array($_REQUEST["id"]); } if (isset($_REQUEST["bt_save_notes"])) { $data = array('better_name' => $_REQUEST['better_name'], 'description' => $_REQUEST['description'], 'notes' => $_REQUEST['notes']); updateFile($ids[0], $data); } header('Content-Type: text/html; charset=' . $config_charset); include 'file_notes.php_html';
function addPendingFile($folderId, $filePath, $fileSize, $dropFolderPlugin) { $file = addFile($folderId, $filePath, $fileSize, $dropFolderPlugin); updateFile($file->id, $fileSize, $filePath, $dropFolderPlugin); return $file; }
$file_id = $file->file_id; $post_id = $file->post_id; $file_name = $file->file_name; $file_url = $file->file; $file_des = $file->file_des; $file_size = formatBytes($file->file_size); $file_hits = $file->file_hits; $file_date = $file->file_date; $file_updated_date = $file->file_updated_date; $file_last_downloaded_date = $file->file_last_downloaded_date; $file_views = $file->file_views; $link_name = sanitize_title($file_name); $mylink = home_url('/') . 'download/' . $file_id . '/' . $link_name; if (!isset($_SESSION['file_views'][$file_id])) { $_SESSION['file_views'][$file_id] = $file_views + 1; updateFile(array('file_views' => $file_views + 1), array('file_id' => $file_id)); } ?> <div class="download-link"> <a href="<?php echo $mylink; ?> " title="<?php echo $file_des; ?> " rel="nofollow"> <span class="text-bold">Tải về <?php echo $file_name; ?> </span> [ <?php echo $file_size;
$content = $_GET['content']; switch ($a) { case "getStat": echo file_get_contents($idRe); break; case "setStat": updateFile($idRe, $content); break; case "read": $content = file_get_contents($id); if ($content === false) { echo "{\"code\":-1}"; } else { $serviceStat = json_decode(file_get_contents($idRe), true); $content = json_decode($content, true); //print_r($serviceStat); //print_r($content); //print_r(); echo json_encode(array_merge($content, $serviceStat)); } break; case "delete": unlink($id); break; case "create": case "update": updateFile($id, $content); break; default: echo ""; }
function save_custom_meta($post_id) { global $custom_meta_fields, $post; // verify nonce if (!wp_verify_nonce($_POST['custom_meta_box_nonce'], basename(__FILE__))) { return $post_id; } // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } // check permissions if ('page' == $_POST['post_type']) { if (!current_user_can('edit_page', $post_id)) { return $post_id; } } elseif (!current_user_can('edit_post', $post_id)) { return $post_id; } $files = getFileByPostID($post->ID); // loop through fields and save the data foreach ($custom_meta_fields as $field) { if ($field['type'] == 'tax_select') { continue; } $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ($new && $new != $old) { update_post_meta($post_id, $field['id'], $new); } elseif ('' == $new && $old) { delete_post_meta($post_id, $field['id'], $old); } if ($field['type'] == 'download') { $gID = $_POST['_infomation_download_file_id_']; $files = (array) $files; foreach ($files as $file) { $file = (array) $file; if (!in_array($file['file_id'], $gID)) { deleteFile(array('file_id' => $file['file_id'])); } } $gFileName = $_POST['_infomation_download_file_name_']; $gFileLink = $_POST['_infomation_download_file_']; $gFileDes = $_POST['_infomation_download_des_']; for ($i = 0; $i < count($gID); $i++) { if (!empty($gFileName[$i]) && !empty($gFileLink[$i])) { if (empty($gID[$i])) { $data = array('post_id' => $post_id, 'file' => $gFileLink[$i], 'jad_file' => " ", 'file_name' => $gFileName[$i], 'file_des' => $gFileDes[$i], 'file_size' => remote_filesize($gFileLink[$i]), 'file_date' => date("d-m-Y H:i:s"), 'file_updated_date' => date("d-m-Y H:i:s"), 'file_last_downloaded_date' => date("d-m-Y H:i:s")); insertFile($data); } else { $data = array('post_id' => $post_id, 'file' => $gFileLink[$i], 'jad_file' => " ", 'file_name' => $gFileName[$i], 'file_des' => $gFileDes[$i], 'file_size' => remote_filesize($gFileLink[$i]), 'file_updated_date' => date("d-m-Y H:i:s")); $where = array('file_id' => $gID[$i]); updateFile($data, $where); } } } } } // enf foreach }
echo $opts->getUsageMessage(); exit(0); } if (!isset($opts->d) && !isset($opts->p) || isset($opts->d) && isset($opts->p)) { echo "Please select one of EITHER --dev OR --production.\n"; echo $opts->getUsageMessage(); exit(1); } if (isset($opts->d)) { echo "Enabling development mode\n"; $from = 'dist'; $to = 'src'; } else { echo "Enabling production mode\n"; $from = 'src'; $to = 'dist'; } updateFile($configfile, $from, $to); updateFile($viewfile, $from, $to); echo "Done!\n"; function updateFile($file, $from, $to) { echo " Updating {$file}\n"; $content = file_get_contents($file); $pattern = '#/(' . $from . ')/#'; $replacement = '/' . $to . '/'; $content = preg_replace($pattern, $replacement, $content); if (!empty($content)) { file_put_contents($file, $content); } }
function upload_file_to_google_drive($title, $filename) { $fileId = searchFile($this->service, $title); if ($fileId != null) { echo __FUNCTION__ . ": updating file: " . $filename . " to google drive\n"; updateFile($this->service, $fileId, $title, $title, $this->mime_type, $filename, false); } else { echo __FUNCTION__ . ": uploading file: " . $filename . " to google drive\n"; insertFile($this->service, $title, $title, $this->folder_id, $this->mime_type, $filename); } }
public function fileView(FileModel $file) { if (!$file->shared) { $this->authorize('all', $file); } $_file = fileInfo($file); $file = updateFile($file, $_file); return view('files.file', ['file' => $file]); }
echo returnErrorCode(3); } } else { echo returnErrorCode(2); } } else { echo returnErrorCode(1); } } else { if (isset($_GET['type']) && $_GET['type'] == "file" && isset($_GET['action']) && $_GET['action'] == "update" && isset($_GET['project']) && isset($_GET['file']) && isset($_POST['data'])) { $project = htmlentities(mysql_real_escape_string($_GET['project'])); $file = htmlentities(mysql_real_escape_string($_GET['file'])); if (check($login) == 1) { //Modification from keke approved by keke : htmlentities cause weirdness :p if (authenticate($login, $password)) { if (updateFile($login, $project, $file, $_POST['data']) == 1) { echo buildJSONResponse(array("create" => "ok", "updated" => "ok")); } else { echo returnErrorCode(3); } } else { echo returnErrorCode(2); } } else { echo returnErrorCode(1); } } else { if (isset($_GET['type']) && $_GET['type'] == "file" && isset($_GET['action']) && $_GET['action'] == "delete" && isset($_GET['project']) && isset($_GET['file'])) { $project = htmlentities(mysql_real_escape_string($_GET['project'])); $file = htmlentities(mysql_real_escape_string($_GET['file'])); if (check($login) == 1) {
function googlefilerename() { if ($this->input->post('btnsubmit')) { $client = $this->google_client; $client->setAccessToken($this->session->userdata('accessToken')); $service = new Google_DriveService($client); $fileId = $this->input->post('fileid'); $newDescription = $this->input->post('description'); $newRevision = $this->input->post('headRevisionId'); $newMimeType = $this->input->post('mimeType'); $filename = $this->input->post('filename'); $urlfolderid = trim($this->input->post('urlfolderid')); $mimearray = explode('/', $newMimeType); $newTitle = $filename . '.' . $mimearray[1]; $filename = $filename . '.' . $mimearray[1]; $newFileName = $filename; updateFile($service, $fileId, $newTitle, $newDescription, $newMimeType, $newFileName, $newRevision); /* Recent document code here */ $array = array('title' => $newFileName, 'doc_id' => $fileId, 'doc_type' => $newMimeType, 'folder_id' => $urlfolderid, 'folder_name' => '', 'user_id' => $this->session->userdata('userid'), 'action_description' => 'File Rename by user'); $this->usermodel->saverecentfiles($array); $this->session->set_flashdata('message', '<div class="alert-success">' . $this->lang->line('rename_file_msg') . '</div>'); redirect("users/fileListing/{$urlfolderid}"); //pr($_SERVER['REQUEST_URI']); } }
<?php include_once 'include/common.php'; include_once 'include/File.php'; include_once 'include/Messages.php'; include_once 'include/html.php'; db_open(); $ids = $_REQUEST['ids']; $ids = array_diff($ids, array($_REQUEST['main_file'])); updateFile($ids, array('main_file' => $_REQUEST['main_file'])); add_request_message("Created multi-file entry"); echo render_messages(); echo returnToSearchResultsButton();
$doCommit = 1; break; case '--no-commit': $doCommit = 0; break; default: fatal("Must specify --commit or --no-commit\n"); } /* *********************************************************************** */ /* Main */ echo "Updating from {$oldVersion} to {$newVersion}...\n"; updateFile("xml/version.xml", function ($content) use($newVersion, $oldVersion) { return str_replace($oldVersion, $newVersion, $content); }); updateFile("sql/civicrm_generated.mysql", function ($content) use($newVersion, $oldVersion) { return str_replace($oldVersion, $newVersion, $content); }); $sqlFile = "CRM/Upgrade/Incremental/sql/{$newVersion}.mysql.tpl"; if (!file_exists($sqlFile)) { echo "Create \"{$sqlFile}\"\n"; file_put_contents($sqlFile, "{* file to handle db changes in {$newVersion} during upgrade *}\n"); } if ($doCommit) { $files = "xml/version.xml sql/civicrm_generated.mysql " . escapeshellarg($sqlFile); passthru("git add {$files}"); passthru("git commit {$files} -m " . escapeshellarg("Set version to {$newVersion}")); } /* *********************************************************************** */ /* Helper functions */ function updateFile($file, $callback) {
<? ob_start(); ?> <?php $file_id = get_query_var('file_id'); $fname = get_query_var("file_name"); if (!empty($file_id) && !empty($fname)) { $file = getFileByFileID($file_id); foreach ($file as $fi) { $post_id = $fi->post_id; $file_name = $fi->file_name; $file_url = $fi->file; $file_des = $fi->file_des; $file_size = formatBytes($fi->file_size); $file_hits = $fi->file_hits; $file_date = $fi->file_date; $file_updated_date = $fi->file_updated_date; $file_last_downloaded_date = $fi->file_last_downloaded_date; $file_views = $fi->file_views; } $_SESSION['hits'] = $file_hits; if (!isset($_SESSION['file_views'][$file_id])) { $_SESSION['file_views'][$file_id] = $file_views + 1; updateFile(array('file_views' => $file_views + 1), array('file_id' => $file_id)); } } $link = getLinkByFileID($file_id); $hit = $_SESSION['hits'] + 1; updateFile(array('file_hits' => $hit, 'file_last_downloaded_date' => date("d-m-Y H:i:s")), array('file_id' => $file_id)); header("Location:" . $link); exit($link); ?> <?ob_flush();?>
updateFile("online", $servers[$i]['id'], true); } } else { if (isOnline($status) && $count != -1 && $count > 1550) { updateFile("online (full)", $servers[$i]['id'], false); } elseif (isOnline($status) && $count != -1 && $count >= 0) { updateFile("online (timeout)", $servers[$i]['id'], false); } elseif (isOnline($status) && $count == -1) { updateFile("offline", $servers[$i]['id'], true); } elseif ($status == "offline" && $count != -1 && $count >= 0) { updateFile("online (timeout)", $servers[$i]['id'], true); } elseif ($status == "offline" && $count != -1 && $count > 1550) { updateFile("online (full)", $servers[$i]['id'], true); } elseif ($status == "offline" && $count == -1) { updateFile("offline", $servers[$i]['id'], false); } elseif (isOnline($status)) { updateFile("offline", $servers[$i]['id'], true); } elseif ($status == "offline") { updateFile("offline", $servers[$i]['id'], false); } else { updateFile("offline", $servers[$i]['id'], true); } } } //update the last check time $filename = $absolute_cache_path . "lastcheck.txt"; $myfile = fopen($filename, "w"); $newtime = new DateTime('now'); fwrite($myfile, $newtime->format('Y-m-d H:i:s')); fclose($myfile); echo "Done!";