public static function delete_by_id($user_id) { MemberExtendedFieldsService::delete_user_fields($user_id); $condition = 'WHERE user_id=:user_id'; $parameters = array('user_id' => $user_id); self::$querier->delete(DB_TABLE_MEMBER, $condition, $parameters); self::$querier->delete(DB_TABLE_MEMBER_EXTENDED_FIELDS, $condition, $parameters); self::$querier->delete(DB_TABLE_SESSIONS, $condition, $parameters); self::$querier->delete(DB_TABLE_INTERNAL_AUTHENTICATION, $condition, $parameters); self::$querier->delete(DB_TABLE_AUTHENTICATION_METHOD, $condition, $parameters); $upload = new Uploads(); $upload->Empty_folder_member($user_id); self::regenerate_cache(); }
public static function ProcessSource($source) { $file = File::Temporary(TEMP_DIR, 'txt'); switch ($source['source']) { case self::SOURCE_CLIPBOARD: if (String::IsEmpty($_REQUEST[self::FIELD_CLIPBOARD])) { throw new BaseException('The Clipboard field was empty'); } file_put_contents($file, String::FormatNewlines($_REQUEST[self::FIELD_CLIPBOARD])); break; case self::SOURCE_UPLOAD: $upload = $_FILES[self::FIELD_UPLOAD]; // Check for errors if ($upload['error'] != UPLOAD_ERR_OK) { throw new BaseException(Uploads::CodeToMessage($upload['error'])); } if (move_uploaded_file($upload['tmp_name'], $file) === false) { throw new BaseException('Could not process uploaded file'); } break; case self::SOURCE_URL: $http = new HTTP(); if ($http->Get($_REQUEST[self::FIELD_URL], $_REQUEST[self::FIELD_URL])) { file_put_contents($file, String::FormatNewlines($http->body)); } else { throw new BaseException('Could not access URL: ' . $http->error); } break; } return basename($file); }
public function configure() { $this->useFields(array("title", "description", "cat", "author", "minlevel", "size")); // SIZE $this->widgetSchema['size'] = new sfWidgetFormInput(array("type" => "range"), array("max" => Uploads::getMaxSize() + 250, "val" => Uploads::getMaxSize() + 250, "step" => 250, "rel" => "tooltip", "title" => "Maximum size")); $this->validatorSchema['size'] = new sfValidatorInteger(array("required" => false)); // UPLOADER $uploaders = Uploads::getUploaders(); $uploaders[""] = ""; $this->widgetSchema['author'] = new sfWidgetFormChoice(array("choices" => $uploaders, "label" => "Uploader")); $this->validatorSchema['author'] = new sfValidatorChoice(array('choices' => array_keys($uploaders), 'required' => false)); $this->widgetSchema->setDefault("author", ""); // CATEGORIES $qcats = Doctrine_Query::create()->from("Categories"); $this->widgetSchema['cat'] = new sfWidgetFormDoctrineChoice(array('model' => 'categories', "expanded" => false, "multiple" => false, "query" => $qcats, 'method' => 'getIndentedName', "add_empty" => true, 'order_by' => array('root_id, lft', ''))); $this->validatorSchema['cat'] = new sfValidatorDoctrineChoice(array("model" => "Categories", "multiple" => false, "required" => false)); $this->widgetSchema['cat']->setLabel("Category"); // MIN LEVEL $levels = array(); foreach (Users::getLevels() as $lvl => $score) { if ($lvl > 0) { $levels[$lvl] = "Level " . $lvl; } } // If freeleech is allowed, adding this choice if (sfConfig::get('app_bt_allowfreeleech', true)) { $levels[0] = "Freeleech"; } ksort($levels); $this->widgetSchema['minlevel'] = new sfWidgetFormChoice(array("choices" => array_merge(array("" => ""), $levels))); $this->validatorSchema['minlevel'] = new sfValidatorChoice(array("choices" => array_keys(array_merge(array("" => ""), $levels)), 'required' => false)); }
/** * [文件上传方法] * @param [Array] $file [要上传的文件,数组中包含五要素] * @param [String] $path [文件移动路径] * @param [String] $mime [允许上传的类型] * @param [Int] $mixsize [文件大小] * @return [String] [新的文件名称] */ public static function uploadsfile($file, $path, $mime, $mixsize = 1000000) { // 验证类型 与元素长度 if (!is_array($file) || count($file) != 5) { self::$error = '上传失败.. 文件不合理.. '; return false; } // 判断系统错误 switch ($file['error']) { case '1': //超出服务器限定大小 self::$error = '上传失败,文件超出服务器限定大小'; return false; case '2': //超出自限定大小 self::$error = '上传失败,文件超出浏览器限定大小'; return false; case '3': //文件只上传了一部分 self::$error = '上传失败,文件只上传了一部分...'; return false; case '4': //用户没有选中文件 self::$error = '上传失败,请选择文件...'; return false; case '6': //找不到临时文件夹 //找不到临时文件夹 case '7': //服务器错误 文件无法写入 self::$error = '服务器错误,请联系管理员..'; return false; } // 文件类型鉴定 if (strpos($mime, $file['type']) === false) { self::$error = '上传类型不合法,请满足:' . $mime; return false; } // 验证文件大小是否符合当前设定 if ($file['size'] > $mixsize) { self::$error = '文件超出上传大小限定... 当前允许最大值:' . ceil($mixsize / 1000) . 'Kb'; return false; } //获取名字 $filename = self::getRandomName($file['name']); // 移动到指定目录 if (move_uploaded_file($file['tmp_name'], $path . '/' . $filename)) { // 上传成功 return $filename; } else { self::$error = '上传失败.. 文件无法保存.. '; return false; } }
public function PreProcess() { $v = Validator::Create(); $v->Register($this->source[Video_Source::FIELD_EMBED], Validator_Type::NOT_EMPTY, 'The Embed Code field is required'); $v->Register($this->source[Video_Source::FIELD_DURATION], Validator_Type::VALID_TIME, 'The Video Duration field must be in HH:MM:SS format'); $this->duration = Format::DurationToSeconds($this->source[Video_Source::FIELD_DURATION]); $this->video_dir = new Video_Dir(null, 0700); Request::FixFiles(); // No thumbnails uploaded if (!isset($_FILES[Video_Source::FIELD_THUMBNAILS])) { return; } // Process each uploaded file foreach ($_FILES[Video_Source::FIELD_THUMBNAILS] as $upload) { // No file uploaded in this field if ($upload['error'] == UPLOAD_ERR_NO_FILE) { continue; } // Check for other errors if ($upload['error'] != UPLOAD_ERR_OK) { throw new BaseException(Uploads::CodeToMessage($upload['error'])); } switch (File::Type($upload['name'])) { case File::TYPE_ZIP: foreach (Zip::ExtractEntries($upload['tmp_name'], File::TYPE_JPEG) as $name => $data) { $thumbs[] = $this->video_dir->AddTempFromVar($data, JPG_EXTENSION); } break; case File::TYPE_JPEG: $thumbs[] = $this->video_dir->AddTempFromFile($upload['tmp_name'], JPG_EXTENSION); break; } } // Resize (if possible) and move images to the correct directory if (Video_Thumbnail::CanResize()) { $this->thumbs = Video_Thumbnail::ResizeDirectory($this->video_dir->GetTempDir(), $this->video_dir->GetThumbsDir(), Config::Get('thumb_size'), Config::Get('thumb_quality')); } else { $this->thumbs = $this->video_dir->MoveFiles(Video_Dir::TEMP, Video_Dir::THUMBS, JPG_EXTENSION); } // Cleanup temp and processing dirs $this->video_dir->ClearTemp(); $this->video_dir->ClearProcessing(); }
/** * 编辑文章 * By:0x584A * Date:2015年9月21日 12:54:46 */ public function editartice() { $aid = intval($_REQUEST['aid']); // 标题 $data['a_title'] = trim($_REQUEST['title']); // 发布时间 $data['a_time'] = $_SERVER['REQUEST_TIME']; // 内容 $data['a_content'] = htmlspecialchars(addslashes($_REQUEST['content'])); // 分类 $data['s_id'] = intval($_REQUEST['typeid']); // 发布人昵称 $data['a_username'] = $_SESSION['adminuser']['u_name']; // 是否选择热门 $data['a_hot'] = isset($_REQUEST['is_hot']) ? 1 : 0; // 额外关键字 $data['a_keywords'] = trim($_REQUEST['keywords']); // 缩略图片 $data['a_thumb_img'] = trim($_REQUEST['img']); // 验证 if (empty($data['a_title']) || empty($data['a_content']) || empty($data['a_content']) || $data['s_id'] < 1) { $this->error('index.php?c=index&a=editartice&editid=' . $aid, '修改文章中存在为空的数据,请认真填写...'); } if (!empty($_FILES['articleimage'])) { // 载入文件上传白名单 $mime = $GLOBALS['config']['admin_goods_upload_mime']; // 上传图片并判断 if ($imgfile = Uploads::uploadsfile($_FILES['articleimage'], UPLOADS_DIR, $mime)) { // 制作缩略图 if ($thumbname = Images::makeThumb(UPLOADS_DIR . "/" . $imgfile, UPLOADS_DIR)) { // 成功 $data['a_thumb_img'] = $thumbname; $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "上传头像成功:{$thumbname}"); } else { // 失败写入到系统日志中 $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "上传头像失败:<font style='color:red'>{$imgfile}</b></font>"); } } } // 实例化 $article = new ArticeModel(); if ($article->updateArtice($data, $aid)) { $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "修改文章【" . $data['a_title'] . "】成功"); $this->success('index.php?c=index&a=listartice', '修改成功...'); } else { $logs = new LogsModel(); $logs->insertOne($_SESSION['adminuser']['u_name'] . "修改文章" . $data['a_title'] . "<font style='color:red'>失败</font>"); $this->error('index.php?c=index&a=editartice&editid=' . $aid, '修改失败,请联系管理员...'); } }
function set($type, $setArray) { switch ($type) { case 'upload': $comPareArray = array('filepath', 'allowsize', 'allowtype', 'allowsuffix', 'randfix', 'prefix'); if (Debug::compareArray($type, $setArray, $comPareArray)) { foreach ($setArray as $key => $value) { if ($key == 'allowtype') { if (!is_array($value)) { exit('请设置allowtype为数组!'); } } elseif ($key == 'allowsuffix') { if (!is_array($value)) { exit('请设置allowsuffix为数组!'); } } self::${$key} = $value; //设置成员属性 } } break; case 'water': $comPareArray = array('logopath', 'position', 'alpha', 'prefix'); if (Debug::compareArray($type, $setArray, $comPareArray)) { if (!file_exists($setArray['logopath'])) { self::error(-8); } $setArray['prefix'] = !isset($setArray['prefix']) ? 'wa_' : $setArray['prefix']; $setArray['position'] = !isset($setArray['position']) ? '9' : $setArray['position']; $setArray['alpha'] = !isset($setArray['alpha']) ? 100 : $setArray['alpha']; } self::$water = $setArray; break; case 'zoom': $comPareArray = array('width', 'height', 'prefix'); if (Debug::compareArray($type, $setArray, $comPareArray)) { if (!isset($setArray['prefix'])) { $setArray['prefix'] = 'zo_'; } } self::$zoom = $setArray; break; } return $this; }
<?php require_once '../admin/admin_begin.php'; define('TITLE', $LANG['administration']); require_once '../admin/admin_header.php'; import('members/uploads'); $Uploads = new Uploads(); $folder = retrieve(GET, 'f', 0); $folder_member = retrieve(GET, 'fm', 0); $parent_folder = retrieve(GET, 'fup', 0); $home_folder = !empty($_GET['root']) ? true : false; $del_folder = retrieve(GET, 'delf', 0); $empty_folder = retrieve(GET, 'eptf', 0); $del_file = retrieve(GET, 'del', 0); $get_error = retrieve(GET, 'error', ''); $get_l_error = retrieve(GET, 'erroru', ''); $show_member = !empty($_GET['showm']) ? true : false; $move_folder = retrieve(GET, 'movefd', 0); $move_file = retrieve(GET, 'movefi', 0); $to = retrieve(POST, 'new_cat', -1); if (isset($_GET['fup'])) { $parent_folder = $Sql->query_array(PREFIX . "upload_cat", "id_parent", "user_id", "WHERE id = '" . $parent_folder . "'", __LINE__, __FILE__); if (!empty($folder_member)) { redirect(HOST . DIR . '/admin/admin_files.php?showm=1'); } elseif ($parent_folder['user_id'] != -1 && empty($parent_folder['id_parent'])) { redirect(HOST . DIR . '/admin/admin_files.php?fm=' . $parent_folder['user_id']); } else { redirect(HOST . DIR . '/admin/admin_files.php?f=' . $parent_folder['id_parent']); } } elseif ($home_folder) { redirect(HOST . DIR . '/admin/admin_files.php');
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param integer $id the ID of the model to be loaded * @return Uploads the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Uploads::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
$this->RedirectToTab($id); } else { if (isset($params['submit'])) { // submit pressed. // get the parameters if (isset($params['category_name'])) { $dest_catname = trim($params['category_name']); } if (isset($params['category_desc'])) { $dest_catdesc = trim($params['category_desc']); } if (isset($params['category_path'])) { $dest_catpath = trim($params['category_path']); } $copyfiles = $params['copyfiles']; Uploads::load_admin(); $error = _uploads_CopyCategory($this, $category_id, $dest_catname, $dest_catpath, $dest_catdesc, true, true); if (empty($error)) { $this->SetMessage($this->Lang('category_copied')); $this->RedirectToTab($id); } echo $this->ShowErrors($error); } } // on submit // // give everything to smarty // $smarty->assign('category', $category); $smarty->assign('formstart', $this->CGCreateFormStart($id, 'admin_copycategory', $returnid, $params)); $smarty->assign('formend', $this->CreateFormEnd());
public static function bootstrap() { self::$absPath = TH_ROOT . TH_UPLOADS; self::testWritable(self::$absPath); }
// determine how many we're going to display $limitstr = ""; $pagelimit = 100000; $pagenum = 1; $numpages = 1; if (isset($params['count'])) { $pagelimit = (int) $params['count']; } if (isset($params['pagenum'])) { $pagenum = (int) $params['pagenum']; } $limitstr = " LIMIT 0,{$pagelimit}"; // get the category id $category = array(); if (trim($params['category']) != 'all') { $category = Uploads::getCategoryFromName(trim($params['category'])); if (!$category) { $this->_DisplayErrorPage($id, $params, $returnid, $this->Lang('error_categorynotfound')); return; } $this->smarty->assign('category_name', $params['category']); } // get the filter string $filter = ''; if (isset($params['input_filter']) && $params['input_filter'] != '') { $filter = trim($params['input_filter']); } if ($filter == '') { unset($params['hidden_params']); } if (isset($params['filter'])) {
</script> '; } else { echo 'an error has occured'; } break; case 'medialib_showfiles': $dir = $_GET['dir']; $page = $_GET['page']; if (empty($page)) { $page = 1; } $files = $db->fetch('uploads', 'dir', $dir, 'id', 'DESC', $page, 45); $pages_array = $db->pages_array('uploads', 'dir', $dir, $page, 45); include '../classes/uploads.php'; $uploads = new Uploads(); if (empty($files)) { echo $lang->get_phrase('directory_contains_no_files'); } else { foreach ($files as $file) { $this_thumb = $uploads->get_thumb($file['id'], 'control'); echo ' <span> <div id="file_' . $file['id'] . '" class="file" title="' . $file['file_name'] . '" style="background:url(' . $this_thumb . ') no-repeat;background-size:110px 90px;" onmouseover="file_mouseover(' . $file['id'] . ');" onmouseout="file_mouseout(' . $file['id'] . ');"> <input type="checkbox" onclick="checkbox_clicked(' . $file['id'] . ')" value="' . $file['id'] . '" id="tobeselected" /> <br /><br /> <button id="select" style="display:none" onclick="choose_photo(' . $file['id'] . ',\'' . $this_thumb . '\');">' . $lang->get_phrase('select') . '</button> <div id="title">' . mb_substr($file['file_name'], 0, 13) . '...</div> </div> </span>
/** * process new uploads, if any * * This function checks the input queue, and process new files on their arrival. * * This function is aiming to run silently, therefore errors are logged in a file. * * @return a string to be displayed in resulting page, if any * */ public static function tick_hook() { global $context; // useless if we don't have a valid database connection if (!$context['connection']) { return; } // remember start time $stamp = get_micro_time(); // process handx weblog entries, if any $count = 0; if (($files = Uploads::list_files('inbox/entries')) && @count($files) > 0) { foreach ($files as $file) { // help the webmaster Logger::remember('agents/upload.php: processing ' . $file); // create articles Uploads::process_handx_weblog($file); // no more than 10 entries per tick $count += 1; if ($count >= 10) { break; } } // remember tick date include_once $context['path_to_root'] . 'shared/values.php'; Values::set('uploads.tick.entries', $count); } // rebuild index pages if ($count) { Cache::clear(); } // compute execution time $time = round(get_micro_time() - $stamp, 2); // report on work achieved if ($count > 1) { return 'agents/uploads.php: ' . $count . ' files have been processed (' . $time . " seconds)" . BR; } elseif ($count == 1) { return 'agents/uploads.php: 1 file has been processed (' . $time . " seconds)" . BR; } else { return 'agents/uploads.php: nothing to do (' . $time . " seconds)" . BR; } }
if (!empty($password_old_hash) && !empty($password_hash) && !empty($password_bis_hash)) { if ($password_old_hash === $password_old_bdd && $password_hash === $password_bis_hash) { if (strlen($password) >= 6 && strlen($password_bis) >= 6) { $Sql->query_inject("UPDATE " . DB_TABLE_MEMBER . " SET password = '******' WHERE user_id = '" . $id_get . "'", __LINE__, __FILE__); } else { redirect(HOST . DIR . '/member/member' . url('.php?id=' . $id_get . '&edit=1&error=pass_mini') . '#errorh'); } } else { redirect(HOST . DIR . '/member/member' . url('.php?id=' . $id_get . '&edit=1&error=pass_same') . '#errorh'); } } } if (!empty($_POST['del_member'])) { $Sql->query_inject("DELETE FROM " . DB_TABLE_MEMBER . " WHERE user_id = '" . $User->get_attribute('user_id') . "'", __LINE__, __FILE__); import('members/uploads'); $Uploads = new Uploads(); $Uploads->Empty_folder_member($User->get_attribute('user_id')); $Cache->Generate_file('stats'); } $user_mail = strtolower($_POST['mail']); if (check_mail($user_mail)) { $user_lang = retrieve(POST, 'user_lang', ''); $user_theme = retrieve(POST, 'user_theme', ''); $user_editor = retrieve(POST, 'user_editor', ''); $user_timezone = retrieve(POST, 'user_timezone', ''); $user_show_mail = !empty($_POST['user_show_mail']) ? '0' : '1'; $user_local = retrieve(POST, 'user_local', ''); $user_occupation = retrieve(POST, 'user_occupation', ''); $user_hobbies = retrieve(POST, 'user_hobbies', ''); $user_desc = retrieve(POST, 'user_desc', '', TSTRING_PARSE); $user_sex = retrieve(POST, 'user_sex', 0);
require_once '../kernel/header.php'; $field = ''; $header = ''; $footer = ''; $popup = ''; $popup_noamp = ''; } if (!$User->check_level(MEMBER_LEVEL)) { $Errorh->handler('e_auth', E_USER_REDIRECT); } $Cache->load('uploads'); if (!$User->check_auth($CONFIG_UPLOADS['auth_files'], AUTH_FILES)) { $Errorh->handler('e_auth', E_USER_REDIRECT); } import('members/uploads'); $Uploads = new Uploads(); $folder = retrieve(GET, 'f', 0); $parent_folder = retrieve(GET, 'fup', 0); $home_folder = retrieve(GET, 'root', false); $del_folder = retrieve(GET, 'delf', 0); $del_file = retrieve(GET, 'del', 0); $get_error = retrieve(GET, 'error', ''); $get_l_error = retrieve(GET, 'erroru', ''); $move_folder = retrieve(GET, 'movefd', 0); $move_file = retrieve(GET, 'movefi', 0); $to = retrieve(POST, 'new_cat', -1); if (!empty($parent_folder)) { if (empty($parent_folder)) { redirect(HOST . DIR . url('/member/upload.php?f=0&' . $popup_noamp, '', '&')); } $info_folder = $Sql->query_array(PREFIX . "upload_cat", "id_parent", "user_id", "WHERE id = '" . $parent_folder . "'", __LINE__, __FILE__);
public function uploadImage($page, $id) { $fields = ['hotel_id', 'photo_name']; $oldImage = []; $res = $this->content->selectField('panel_hotel_photo', ['photo_name'], '', 0, 'hotel_id', '' . $id . '', 'id', ''); foreach ($res->result_array() as $row) { $oldImage[] = $row['photo_name']; } if (isset($_POST['submit'])) { print_r($_POST); die; $fields = ['hotel_id', 'photo_name']; $code = uniqid(); $upload = new Uploads(); $return = $upload->upfile($code); foreach ($return['image'] as $key => $ret) { $values[] = [$id, "'{$ret}'"]; } $this->content->addRecord2('panel_hotel_photo', $fields, $values); // foreach ($return as $ret){ // $this->content->addRecord(); // } } $content = $this->content->uploadImage($page, $id, $oldImage); $data['content'] = $content; $subTitle = $this->tools->subTitleGenerator('upload_image', $page, $this->fWhere, $this->where); $pageDetail = $this->tools->page_detail($page); $data['title2'] = ' '; $data['pagination'] = ''; $data['action'] = 'edit'; //$data['menu'] = $this->menu; $this->loadHeader($pageDetail, $subTitle); $this->loadMenu(); $this->load->view('admin/view', $data); $this->loadFooter(); }
<?php /** * Created by Kent M. Patrick * Project: BPU * Company: Fingerprints Ltd * Date: 21/09/2016 * Time: 9:58 AM */ require_once 'header.php'; $upload = new Uploads(); if (isset($_FILES['upload'])) { $upload->set_file_info($_FILES['upload']); $errors = $upload->file_checker(); if (count($errors) == 0) { if (!is_dir($upload->dir)) { mkdir($upload->dir, 0777, true); } if (!move_uploaded_file($upload->file_tmp, $upload->dir . $upload->file_name)) { $alerts->display("danger", "error", "file failed to upload"); } else { $_SESSION['upload_file'] = $upload->dir . $upload->file_name; } } else { unset($_SESSION['upload_file']); $alerts->display("danger", "error", $errors['0']); } } if (isset($_GET['step'])) { $form = new Forms(); switch ($_GET['step']) {
function tbxAvatarEdit() { global $t; $DB = GetDB(); $v = Validator::Create(); Uploads::ProcessNew(Config::Get('avatar_extensions')); $upload = Uploads::Get('avatar_file'); $v->Register(empty($upload), Validator_Type::IS_FALSE, _T('Validation:No image uploaded')); if (!empty($upload)) { $v->Register(empty($upload['error']), Validator_Type::IS_TRUE, $upload['error']); $imagesize = @getimagesize($upload['path']); $v->Register($imagesize, Validator_Type::NOT_FALSE, _T('Validation:Invalid image upload')); // Check dimensions and filesize if ($imagesize !== false) { list($width, $height) = explode('x', Config::Get('avatar_dimensions')); $v->Register($imagesize[0] > $width || $imagesize[1] > $height, Validator_Type::IS_FALSE, _T('Validation:Invalid image dimensions', Config::Get('avatar_dimensions'))); $v->Register(filesize($upload['path']), Validator_Type::LESS_EQ, _T('Validation:Invalid image size', Config::Get('avatar_filesize')), Format::StringToBytes(Config::Get('avatar_filesize'))); } } if ($v->Validate()) { $user = $DB->Row('SELECT * FROM `tbx_user` WHERE `username`=?', array(AuthenticateUser::GetUsername())); if (!empty($user['avatar_id'])) { Uploads::RemoveExisting($user['avatar_id']); } DatabaseUpdate('tbx_user', array('username' => $user['username'], 'avatar_id' => $upload['upload_id'])); $t->Assign('g_success', true); } else { Uploads::RemoveCurrent(); $t->Assign('g_errors', $v->GetErrors()); } $t->Display('user-avatar.tpl'); }
// cargamos modelos $Actividades = new Actividades(); //variables $datauser = array(); $id_actividad = $_POST['idActividad']; $nombre_actividad = $_POST['nombreActividad']; $costo_actividad = $_POST['costoActividad']; $contenido_actividad = $_POST['contenidoActividad']; $tipo_actividad = $_POST['tipoActividad']; $fecha_actividad = $_POST['fechaActividad']; $fecha_inicio_actividad = $_POST['fechaInicio']; $fecha_fin_actividad = $_POST['fechaFin']; $estado_actividad = $_POST['estadoActividad']; // cargamos classe para subir archivos y definimos que nos agregue el tiempo al final //(para evitar que existan archivos duplicadas y no nos rompa el proceso) $Uploads = new Uploads(); $Uploads->addtime = 1; ///////////////////////////////////// // cargamos la imagen $archivoResultado = $Uploads->doUpload('fileToUpload', '../images/'); // el primero corresponde a que $_FILES['fileToUpload'] y el segundo a la ruta de subida if ($archivoResultado['status'] == 1) { // la subida es correcta $imgActividad = $archivoResultado['filename']; } else { $errors[] = 'Error en subida de archivo/ talvez no se subio'; } ////////////////////////////////////// // cargamos la imagen Thumbnail $archivoResultadoThumbnail = $Uploads->doUpload('fileToUploadThumbnail', '../images/'); // el primero corresponde a que $_FILES['fileToUpload'] y el segundo a la ruta de subida
redirect(HOST . SCRIPT); } else { redirect(HOST . DIR . '/member/member' . url('.php?error=incomplete&add=1') . '#errorh'); } } else { redirect(HOST . DIR . '/admin/admin_members' . url('.php?id=' . $id . '&error=pass_mini&add=1') . '#errorh'); } } } else { redirect(HOST . DIR . '/admin/admin_members' . url('.php?error=invalid_mail&add=1') . '#errorh'); } } elseif (!empty($id) && $delete) { $Session->csrf_get_protect(); $Sql->query_inject("DELETE FROM " . DB_TABLE_MEMBER . " WHERE user_id = '" . $id . "'", __LINE__, __FILE__); import('members/uploads'); $Uploads = new Uploads(); $Uploads->Empty_folder_member($id); $Cache->Generate_file('stats'); redirect(HOST . SCRIPT); } elseif ($add) { $Template->set_filenames(array('admin_members_management2' => 'admin/admin_members_management2.tpl')); switch ($get_error) { case 'pass_mini': $errstr = $LANG['e_pass_mini']; break; case 'incomplete': $errstr = $LANG['e_incomplete']; break; case 'invalid_mail': $errstr = $LANG['e_mail_invalid']; break;
function tbxBannerDelete($item) { $DB = GetDB(); $DB->Update('DELETE FROM `tbx_banner` WHERE `banner_id`=?', array($item['banner_id'])); if (isset($item['upload_id'])) { Uploads::RemoveExisting($item['upload_id']); } return true; }
} elseif (!empty($rename_folder)) { $id_folder = $request->get_postint('id_folder', 0); if (!empty($id_folder) && !empty($name)) { if ($user->get_id() != $user_id) { if ($user->check_level(User::ADMIN_LEVEL)) { echo Uploads::Rename_folder($id_folder, $name, $previous_name, $user_id, Uploads::ADMIN_NO_CHECK); } else { echo Uploads::Rename_folder($id_folder, $name, $previous_name, $user->get_id(), Uploads::ADMIN_NO_CHECK); } } else { echo Uploads::Rename_folder($id_folder, $name, $previous_name, $user->get_id()); } } else { echo 0; } } elseif (!empty($rename_file)) { $id_file = $request->get_postint('id_file', 0); if (!empty($id_file) && !empty($name)) { if ($user->get_id() != $user_id) { if ($user->check_level(User::ADMIN_LEVEL)) { echo Uploads::Rename_file($id_file, $name, $previous_name, $user_id, Uploads::ADMIN_NO_CHECK); } else { echo Uploads::Rename_file($id_file, $name, $previous_name, $user->get_id(), Uploads::ADMIN_NO_CHECK); } } else { echo Uploads::Rename_file($id_file, $name, $previous_name, $user->get_id()); } } else { echo 0; } }
<?php define('PATH_TO_ROOT', '../../..'); define('NO_SESSION_LOCATION', true); include_once PATH_TO_ROOT . '/kernel/begin.php'; include_once PATH_TO_ROOT . '/kernel/header_no_display.php'; import('members/uploads'); $Uploads = new Uploads(); if (!empty($_GET['new_folder'])) { $id_parent = !empty($_POST['id_parent']) ? numeric($_POST['id_parent']) : '0'; $user_id = !empty($_POST['user_id']) ? numeric($_POST['user_id']) : $User->get_attribute('user_id'); $name = !empty($_POST['name']) ? strprotect(utf8_decode($_POST['name'])) : ''; if (!empty($user_id) && $User->get_attribute('user_id') != $user_id) { if ($User->check_level(ADMIN_LEVEL)) { echo $Uploads->Add_folder($id_parent, $user_id, $name); } else { echo $Uploads->Add_folder($id_parent, $User->get_attribute('user_id'), $name); } } else { echo $Uploads->Add_folder($id_parent, $User->get_attribute('user_id'), $name); } } elseif (!empty($_GET['rename_folder'])) { $id_folder = !empty($_POST['id_folder']) ? numeric($_POST['id_folder']) : '0'; $name = !empty($_POST['name']) ? strprotect(utf8_decode($_POST['name'])) : ''; $user_id = !empty($_POST['user_id']) ? numeric($_POST['user_id']) : $User->get_attribute('user_id'); $previous_name = !empty($_POST['previous_name']) ? strprotect(utf8_decode($_POST['previous_name'])) : ''; if (!empty($id_folder) && !empty($name)) { if ($User->get_attribute('user_id') != $user_id) { if ($User->check_level(ADMIN_LEVEL)) { echo $Uploads->Rename_folder($id_folder, $name, $previous_name, $user_id, ADMIN_NO_CHECK); } else {
} ////////////////////////////////////////////////////////////// if (isset($_POST['videoTestimonio']) and strlen(trim($_POST['videoTestimonio'])) >= 3) { $videoTestimonio = $_POST['videoTestimonio']; } else { $errors[] = 'Error'; } ////////////////////////////////////////////////////////////// if (isset($_POST['clienteTestimonio']) and strlen(trim($_POST['clienteTestimonio'])) >= 3) { $clienteTestimonio = $_POST['clienteTestimonio']; } else { $errors[] = 'Error'; } // cargamos classe para subir archivos y definimos que nos agregue el tiempo al final //(para evitar que existan archivos duplicadas y no nos rompa el proceso) $Uploads = new Uploads(); $Uploads->addtime = 1; // cargamos la imagen $archivoResultado = $Uploads->doUpload('fileToUpload', '../images/'); // el primero corresponde a que $_FILES['fileToUpload'] y el segundo a la ruta de subida if ($archivoResultado['status'] == 1) { // la subida es correcta $imgTestimonio = $archivoResultado['filename']; } else { $errors[] = 'Error en subida de archivo/ talvez no se subio'; } if (sizeof($errors) == 0) { $objTestimonio = new Testimonios(); $res = $objTestimonio->AddTestimonio($contenidoTestimonio, $imgTestimonio, $videoTestimonio, $clienteTestimonio); header('Location: ' . $baseurl); } else {
public function PreProcess() { $this->video_dir = new Video_Dir(null, 0700); Request::FixFiles(); if (!isset($_FILES[Video_Source::FIELD_UPLOADS])) { throw new BaseException('No files were uploaded'); } foreach ($_FILES[Video_Source::FIELD_UPLOADS] as $upload) { // No file uploaded in this field if ($upload['error'] == UPLOAD_ERR_NO_FILE) { continue; } // Check for other errors if ($upload['error'] != UPLOAD_ERR_OK) { throw new BaseException(Uploads::CodeToMessage($upload['error'])); } $thumbs = array(); $will_grab = Video_Info::CanExtract() && Video_FrameGrabber::CanGrab(); switch (File::Type($upload['name'])) { case File::TYPE_ZIP: foreach (Zip::ExtractEntries($upload['tmp_name'], File::TYPE_JPEG) as $name => $data) { $thumbs[] = $this->video_dir->AddTempFromVar($data, JPG_EXTENSION); } foreach (Zip::ExtractEntries($upload['tmp_name'], File::TYPE_VIDEO) as $name => $data) { $this->clips[] = $this->video_dir->AddClipFromVar($data, File::Extension($name)); } break; case File::TYPE_JPEG: $thumbs[] = $this->video_dir->AddTempFromFile($upload['tmp_name'], JPG_EXTENSION); break; case File::TYPE_VIDEO: $this->clips[] = $this->video_dir->AddClipFromFile($upload['tmp_name'], File::Extension($upload['name'])); break; } } // Make sure at least one video clip was uploaded if (empty($this->clips)) { throw new BaseException('No video files were uploaded'); } // Try to grab frames from video files if ($will_grab) { $amount = round(Config::Get('thumb_amount') / count($this->clips)); foreach ($this->clips as $clip) { $vi = new Video_Info($clip); $vi->Extract(); $this->duration += $vi->length; $temp_thumbs = Video_FrameGrabber::Grab($clip, $this->video_dir->GetProcessingDir(), $amount, Config::Get('thumb_quality'), Config::Get('thumb_size')); // Move generated thumbs from the processing directory foreach ($temp_thumbs as $temp_thumb) { $this->thumbs[] = $this->video_dir->AddThumbFromFile($temp_thumb); } $this->video_dir->ClearProcessing(); } } else { $this->duration = $this->source[Video_Source::FIELD_DURATION]; } // Use uploaded images if none could be generated if (empty($this->thumbs) && !empty($thumbs)) { if (Video_Thumbnail::CanResize()) { $this->thumbs = Video_Thumbnail::ResizeDirectory($this->video_dir->GetTempDir(), $this->video_dir->GetThumbsDir(), Config::Get('thumb_size'), Config::Get('thumb_quality')); } else { $this->thumbs = $this->video_dir->MoveFiles(Video_Dir::TEMP, Video_Dir::THUMBS, JPG_EXTENSION); } } // Cleanup temp and processing dirs $this->video_dir->ClearTemp(); $this->video_dir->ClearProcessing(); }
function _uploads_CopyCategory(&$module, $orig_category_id, $dest_name, $dest_path, $dest_desc, $copyfiles, $edit_desc = true) { global $gCms; $config = $gCms->GetConfig(); // get the original category $orig_category = Uploads::load_category_by_id($orig_category_id); if (!$orig_category) { return $module->Lang('error_categorynotfound'); } $dest_category = $orig_category; if (empty($dest_name)) { return $module->Lang('error_missing_invalid', 'name'); } if (empty($dest_path)) { return $module->Lang('error_missing_invalid', 'path'); } $tmp = Uploads::getCategoryFromName($dest_name); if (is_array($tmp)) { return $module->Lang('error_categoryexists2', $dest_name); } $tmp2 = Uploads::category_path_in_use($dest_path); if ($tmp2) { return $module->Lang('error_pathinuse2', $dest_path); } $srcdir = cms_join_path($config['uploads_path'], $orig_category['upload_category_path']); $destdir = cms_join_path($config['uploads_path'], $dest_path); if (file_exists($destdir)) { return $module->Lang('error_fileexists', $destdir); } if (!file_exists($srcdir)) { return $module->Lang('error_filenotfound', $srcdir); } $dest_category['upload_category_name'] = $dest_name; $dest_category['upload_category_path'] = $dest_path; if ($edit_desc) { $dest_category['upload_category_description'] = $dest_desc; } global $gCms; $db =& $gCms->GetDb(); $catid = $db->GenID(cms_db_prefix() . "module_uploads_categories_seq"); $query = 'INSERT INTO ' . cms_db_prefix() . 'module_uploads_categories (upload_category_id,upload_category_name, upload_category_description,upload_category_path, upload_category_listable,upload_category_groups, upload_category_deletable) VALUES (?,?,?,?,?,?,?)'; $dbr = $db->Execute($query, array($catid, $dest_category['upload_category_name'], $dest_category['upload_category_description'], $dest_category['upload_category_path'], $dest_category['upload_category_listable'], $dest_category['upload_category_groups'], $dest_category['upload_category_deletable'])); if (!$dbr) { return $module->Lang('error_dberror'); } @mkdir($destdir, 0777, true); if (!file_exists($destdir)) { $query = 'DELETE FROM ' . cms_db_prefix() . 'module_uploads_categories WHERE upload_category_id = ?'; $db->Execute($query, array($catid)); return $module->Lang('error_cantcreatedirectory' . ': ' . $destdir); } if ($module->GetPreference('create_dummy_index_html')) { @touch($destdir . DIRECTORY_SEPARATOR . "index.html"); } // send an event $parms = array(); $parms['name'] = $dest_category['upload_category_name']; $parms['description'] = $dest_category['upload_category_description']; $parms['path'] = $dest_category['upload_category_path']; $parms['listable'] = $dest_category['upload_category_listable']; $parms['deletable'] = $dest_category['upload_category_deletable']; $module->SendEvent('OnCreateCategory', $parms); $error = array(); if ($copyfiles) { // now copy the files. $author = $_SESSION['cms_admin_username']; $now = $db->DbTimeSTamp(time()); $file_records = Uploads::get_category_file_list($orig_category_id); $iquery = 'INSERT INTO ' . cms_db_prefix() . "module_uploads\n (upload_id,upload_category_id,upload_name,\n upload_author,upload_summary,upload_description,\n upload_ip,upload_size,upload_date,\n upload_key,upload_thumbnail)\n VALUES(?,?,?,?,?,?,?,?,{$now},?,?)"; if (!is_array($file_records)) { break; } for ($i = 0; $i < count($file_records); $i++) { if (!empty($error)) { break; } $did_copy_thumb = false; $destthumb = ''; $onerec =& $file_records[$i]; // get the file path $srcfile = cms_join_path($srcdir, $onerec['upload_name']); $destfile = cms_join_path($destdir, $onerec['upload_name']); // copy the file copy($srcfile, $destfile); // check for a thumbnail $srcthumb = cms_join_path($srcdir, 'thumb_' . $onerec['upload_name']); $destthumb = cms_join_path($destdir, 'thumb_' . $onerec['upload_name']); if (file_exists($srcdir)) { // copy it $destthumb = cms_join_path($destdir, 'thumb_' . $onerec['upload_name']); copy($srcthumb, $destthumb); $did_copy_thumb = true; } // generate a new file id $file_id = $db->GenID(cms_db_prefix() . "module_uploads_seq"); // alter the record $onerec['upload_id'] = $file_id; $onerec['upload_category_id'] = $catid; $onerec['upload_author'] = $author; $onerec['upload_ip'] = null; // insert it. $dbr = $db->Execute($iquery, array($file_id, $onerec['upload_category_id'], $onerec['upload_name'], $onerec['upload_author'], $onerec['upload_summary'], $onerec['upload_description'], $onerec['upload_ip'], $onerec['upload_size'], $onerec['upload_key'], $onerec['upload_thumbnail'])); // on error delete files. if (!$dbr) { @unlink($destfile); @unlink($destthumb); if (!is_array($error)) { $error = array(); } $error[] = $module->Lang('error_dberror'); } } } // copy files if (!$error) { return $error; } return FALSE; }
$tinymce = '<a href="' . PATH_TO_ROOT . '/upload/' . $row['path'] . '">' . $row['name'] . '</a>'; $link = '/upload/' . $row['path']; break; default: $bbcode = '[url=/upload/' . $row['path'] . ']' . $row['name'] . '[/url]'; $tinymce = '<a href="' . PATH_TO_ROOT . '/upload/' . $row['path'] . '">' . $row['name'] . '</a>'; $link = '/upload/' . $row['path']; } $is_bbcode_editor = $editor == 'BBCode'; $displayed_code = $is_bbcode_editor ? $bbcode : '/upload/' . $row['path']; $inserted_code = !empty($parse) ? !empty($no_path) ? $link : PATH_TO_ROOT . $link : ($is_bbcode_editor ? addslashes($bbcode) : TextHelper::htmlentities($tinymce)); $tpl->assign_block_vars('files', array('C_RECENT_FILE' => $row['timestamp'] > $now->get_timestamp() - 15 * 60, 'ID' => $row['id'], 'IMG' => $get_img_mimetype['img'], 'URL' => PATH_TO_ROOT . $link, 'TITLE' => str_replace('"', '\\"', $row['name']), 'NAME' => $name_cut, 'RENAME_FILE' => '<span id="fihref' . $row['id'] . '"><a href="javascript:display_rename_file(\'' . $row['id'] . '\', \'' . addslashes($row['name']) . '\', \'' . addslashes($name_cut) . '\');" title="' . LangLoader::get_message('edit', 'common') . '" class="fa fa-edit"></a></span>', 'FILETYPE' => $get_img_mimetype['filetype'] . $size_img, 'BBCODE' => '<input type="text" readonly="readonly" onclick="select_div(\'text_' . $row['id'] . '\');" id="text_' . $row['id'] . '" class="upload-input-bbcode" value="' . $displayed_code . '">', 'SIZE' => $row['size'] > 1024 ? NumberHelper::round($row['size'] / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($row['size'], 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'INSERT' => !empty($popup) ? '<a href="javascript:insert_popup(\'' . $inserted_code . '\')" title="' . $LANG['popup_insert'] . '" class="fa fa-clipboard"></a>' : '', 'LIGHTBOX' => !empty($size_img) ? ' data-lightbox="1"' : '', 'U_MOVE' => url('.php?movefi=' . $row['id'] . '&f=' . $folder . $popup))); $total_folder_size += $row['size']; $total_files++; } $result->dispose(); //Autorisation d'uploader sans limite aux groupes. $group_limit = AppContext::get_current_user()->check_max_value(DATA_GROUP_LIMIT, $files_upload_config->get_maximum_size_upload()); $unlimited_data = $group_limit === -1 || AppContext::get_current_user()->check_level(User::ADMIN_LEVEL); $total_size = !empty($folder) ? Uploads::Member_memory_used(AppContext::get_current_user()->get_id()) : PersistenceContext::get_querier()->get_column_value(DB_TABLE_UPLOAD, 'SUM(size)', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id())); $tpl->put_all(array('PERCENT' => !$unlimited_data ? '(' . NumberHelper::round($total_size / $group_limit, 3) * 100 . '%)' : '', 'SIZE_LIMIT' => !$unlimited_data ? $group_limit > 1024 ? NumberHelper::round($group_limit / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($group_limit, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common') : $LANG['illimited'], 'TOTAL_SIZE' => $total_size > 1024 ? NumberHelper::round($total_size / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($total_size, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'TOTAL_FOLDER_SIZE' => $total_folder_size > 1024 ? NumberHelper::round($total_folder_size / 1024, 2) . ' ' . LangLoader::get_message('unit.megabytes', 'common') : NumberHelper::round($total_folder_size, 0) . ' ' . LangLoader::get_message('unit.kilobytes', 'common'), 'TOTAL_FOLDERS' => $total_directories, 'TOTAL_FILES' => $total_files)); if ($total_directories == 0 && $total_files == 0) { $tpl->put_all(array('C_EMPTY_FOLDER' => true, 'L_EMPTY_FOLDER' => LangLoader::get_message('no_item_now', 'common'))); } $tpl->display(); } if (empty($popup)) { require_once '../kernel/footer.php'; } else { require_once '../kernel/footer_no_display.php'; }
chmod(public_path() . '\\' . 'uploads', 0777); $sections = Sections::all(); $section_values = Sections::where('id', '=', Input::get('id'))->first(); $path = public_path() . '\\' . 'sections\\' . $section_values->shortname; $zipFileName = $section_values->shortname . '.zip'; touch(public_path() . '\\' . 'uploads\\' . $zipFileName); $zip = new ZipArchive(); if ($zip->open(public_path() . '\\' . 'uploads\\' . $zipFileName, ZipArchive::CREATE) === TRUE) { // Copy all the files from the folder and place them in the archive. foreach (glob($path . '/*') as $fileName) { $file = basename($fileName); $zip->addFile(realpath($fileName), $file); } $zip->close(); $headers = array('Content-Type' => 'application/zip'); $upload = new Uploads(); $upload->section_name = $section_values->name_of_section; $upload->section_shortname = $section_values->shortname; $upload->section_url = $section_values->section_url; $upload->sub_section = $section_values->sub_section; $upload->file_url = public_path() . '\\' . 'uploads\\' . $zipFileName; $upload->save(); $page = DB::table('sections')->where('id', Input::get('id'))->update(array('upload_status' => "Uploaded")); } else { return View::make('upload')->withMessage('Creating zip file Failed'); } return View::make('upload')->with(['sections' => $sections]); }); Route::get('/add', function () { $sections = Sections::lists('name_of_section', 'name_of_section'); $pages = Pages::lists('page_description', 'page_link_value');
function tbxUploadStepTwo() { global $t; $upload = $_FILES['video_file']; $v = Validator::Create(); $DB = GetDB(); $v->Register(sha1($_REQUEST['step_one_data'] . Config::Get('random_value')) == $_REQUEST['step_one_sig'], Validator_Type::IS_TRUE, _T('Validation:Video Data Altered')); $v->Register($upload['error'] == UPLOAD_ERR_OK, Validator_Type::IS_TRUE, Uploads::CodeToMessage($upload['error'])); if (is_uploaded_file($upload['tmp_name'])) { $max_filesize = Format::StringToBytes(Config::Get('max_upload_size')); $max_duration = Format::DurationToSeconds(Config::Get('max_upload_duration')); $extensions = str_replace(',', '|', Config::Get('upload_extensions')); $v->Register($upload['size'], Validator_Type::IS_BETWEEN, _T('Validation:Video size too large'), '1,' . $max_filesize); $v->Register(File::Extension($upload['name']), Validator_Type::REGEX_MATCH, _T('Validation:Video file extension not allowed'), '~^(' . $extensions . ')$~'); try { $vi = new Video_Info($upload['tmp_name']); $vi->Extract(); $v->Register($vi->length, Validator_Type::LESS_EQ, _T('Validation:Video duration too long'), $max_duration); } catch (Exception $e) { $v->Register(false, Validator_Type::IS_TRUE, $e->getMessage()); } $md5 = md5_file($upload['tmp_name']); if (Config::Get('flag_upload_reject_duplicates')) { $v->Register($DB->QueryCount('SELECT COUNT(*) FROM `tbx_video_md5sum` WHERE `md5`=?', array($md5)), Validator_Type::IS_ZERO, _T('Validation:Duplicate video')); } } // Validate input if (!$v->Validate()) { $t->Assign('g_errors', $v->GetErrors()); $t->AssignByRef('g_form', $_REQUEST); if (isset($_REQUEST['flash'])) { $t->Display('upload-flash-errors.tpl'); } else { $t->Assign('g_file_types', '*.' . str_replace(',', ';*.', Config::Get('upload_extensions'))); $t->Assign('g_cookie', $_COOKIE[LOGIN_COOKIE]); $t->Display('upload-step-two.tpl'); } return; } $_REQUEST = array_merge($_REQUEST, unserialize(base64_decode($_REQUEST['step_one_data']))); Form_Prepare::Standard('tbx_video'); Form_Prepare::Standard('tbx_video_stat'); Form_Prepare::Custom('tbx_video_custom_schema', 'on_submit'); $_REQUEST['duration'] = $vi->length; $_REQUEST['date_added'] = Database_MySQL::Now(); $_REQUEST['username'] = AuthenticateUser::GetUsername(); $_REQUEST['is_private'] = Config::Get('flag_upload_allow_private') ? intval($_REQUEST['is_private']) : 0; $_REQUEST['allow_ratings'] = intval($_REQUEST['allow_ratings']); $_REQUEST['allow_embedding'] = intval($_REQUEST['allow_embedding']); $_REQUEST['allow_comments'] = intval($_REQUEST['allow_comments']) ? 'Yes - Add Immediately' : 'No'; $_REQUEST['is_user_submitted'] = 1; if ($_REQUEST['recorded_day'] && $_REQUEST['recorded_month'] && $_REQUEST['recorded_year']) { $_REQUEST['date_recorded'] = $_REQUEST['recorded_year'] . '-' . $_REQUEST['recorded_month'] . '-' . $_REQUEST['recorded_day']; } // Strip HTML tags if (Config::Get('flag_video_strip_tags')) { $_REQUEST = String::StripTags($_REQUEST); } // Configure status $_REQUEST['status'] = STATUS_ACTIVE; if (Config::Get('flag_upload_convert')) { $_REQUEST['status'] = STATUS_QUEUED; $_REQUEST['next_status'] = Config::Get('flag_upload_review') ? STATUS_PENDING : STATUS_ACTIVE; } else { if (Config::Get('flag_upload_review')) { $_REQUEST['status'] = STATUS_PENDING; } } // Add to database $_REQUEST['video_id'] = DatabaseAdd('tbx_video', $_REQUEST); DatabaseAdd('tbx_video_custom', $_REQUEST); DatabaseAdd('tbx_video_stat', $_REQUEST); if ($_REQUEST['status'] == STATUS_ACTIVE && !$_REQUEST['is_private']) { Tags::AddToFrequency($_REQUEST['tags']); } else { if ($_REQUEST['status'] == STATUS_QUEUED) { DatabaseAdd('tbx_conversion_queue', array('video_id' => $_REQUEST['video_id'], 'queued' => time())); } } // Mark as private if ($_REQUEST['is_private']) { $_REQUEST['private_id'] = sha1(uniqid(rand(), true)); DatabaseAdd('tbx_video_private', $_REQUEST); } // Setup video files and generate thumbnails $directory = Video_Dir::DirNameFromId($_REQUEST['video_id']); $vd = new Video_Dir($directory); $clip = $vd->AddClipFromFile($upload['tmp_name'], File::Extension($upload['name'])); if (Video_FrameGrabber::CanGrab()) { Video_FrameGrabber::Grab($clip, $vd->GetThumbsDir(), Config::Get('thumb_amount'), Config::Get('thumb_quality'), Config::Get('thumb_size'), $vi); } foreach ($vd->GetClipURIs() as $clip) { $_REQUEST['clip'] = $clip; $_REQUEST['filesize'] = filesize(Config::Get('document_root') . $clip); DatabaseAdd('tbx_video_clip', $_REQUEST); } $thumb_ids = array(); foreach ($vd->GetThumbURIs() as $thumb) { $_REQUEST['thumbnail'] = $thumb; $thumb_ids[] = DatabaseAdd('tbx_video_thumbnail', $_REQUEST); } // Select the display thumbnail $num_thumbnails = count($thumb_ids); $display_thumbnail = null; if ($num_thumbnails > 0) { $display_thumbnail = $thumb_ids[rand(0, floor(0.4 * $num_thumbnails))]; } DatabaseUpdate('tbx_video', array('video_id' => $_REQUEST['video_id'], 'num_thumbnails' => $num_thumbnails, 'display_thumbnail' => $display_thumbnail)); // Add MD5 sum for prevention of duplicates $DB->Update('REPLACE INTO `tbx_video_md5sum` VALUES (?)', array($md5)); // Update user stats StatsRollover(); $DB->Update('UPDATE `tbx_user_stat` SET ' . '`today_videos_uploaded`=`today_videos_uploaded`+1,' . '`week_videos_uploaded`=`week_videos_uploaded`+1,' . '`month_videos_uploaded`=`month_videos_uploaded`+1,' . '`total_videos_uploaded`=`total_videos_uploaded`+1 ' . 'WHERE `username`=?', array($_REQUEST['username'])); $t->AssignByRef('g_form', $_REQUEST); $t->AssignByRef('g_video', $_REQUEST); $t->Display(isset($_REQUEST['flash']) ? 'upload-flash-complete.tpl' : 'upload-complete.tpl'); UpdateCategoryStats($_REQUEST['category_id']); if (!Config::Get('flag_using_cron') && $_REQUEST['status'] == STATUS_QUEUED) { ConversionQueue::Start(); } }