"delete", "id" => "gl_".strval($aws_gallery['image_id']) ) ); if(Renderosity\Facades\CS::domain("gallery")->saveDocument('delete_gallery.json', $json_data)){ if(Renderosity\Facades\CS::domain("gallery")->uploadDocument('delete_gallery.json')){ return true; } else{ return false; } }else{ return false;} } } function cleanup( $id, $permenently = false ){ DB::execute("select image_id, user_id from gallery_image where image_id=".intval($id)); $item = DB::getAtIndex(0); if( !empty($item) ){ /* Aws Cloudsearch Cleanup */ awsDocumentDelete(intval($item["image_id"])); /* Redis tmp clean up */ Renderosity\Facades\RedTrack::track('art')->untrackUpload( array("trackable_id" => $item['image_id'], "owner_id" => $item["user_id"] ) ); } } /////////////////////////////////////////////////// // S3 File Upload /////////////////////////////////////////////////// function validImage($ext){ if( strtolower($ext) == '.jpeg' || strtolower($ext) == '.jpg' || strtolower($ext) == '.gif' || strtolower($ext) == '.png'){ return true; } else{ return false; } } /////////////////////////////////////////////////// //AJAX IMAGE UPLOAD /////////////////////////////////////////////////// if( !empty($_FILES['file']['name']) ){ if(!validImage(bw_ExtractFileExt($_FILES['file']['name']))){ exit(json_encode(array( "error" => "File could not be saved." ))); }else{ /* Security Check */ if( !logged_in() ){ exit(json_encode(array( "error" => "File could not be saved." ))); }else{ //upload S3 thumbnail if($_FILES['file']['name'] != ''){ $filename = 'file_'.md5(rand(100, 200)).bw_ExtractFileExt($_FILES['file']['name']); //tmp saves images to server if(!is_dir(MEDIA_DIR)){ mkdir(MEDIA_DIR, 0775); } $file = Renderosity\Facades\Image::open($_FILES['file']['tmp_name'])->save(MEDIA_DIR.$filename, array('quality' => 100)); //uploads to s3 from server if(Renderosity\Facades\S3::bucket("gallery")->putObject(MEDIA_DIR.$filename, 'gallery_tmp/'.$filename)){ @unlink(MEDIA_DIR.$filename); exit(json_encode(array( "link" => array( "url" => Renderosity\Facades\S3::bucket("gallery")->getObjectUrl('gallery_tmp/'.$filename), "alt" => $_FILES['file']['name'], "basename" => $filename, "is_image" => true )))); } } } } } /////////////////////////////////////////////////// // Report Gallery Item /////////////////////////////////////////////////// if ( is_numeric($_POST['report']) ) { if( logged_in() ){ /* Get message info */ DB::execute("select * from gallery_image where image_id=".intval($_POST['report'])); $image = DB::getAtIndex(0); /* if valid */ if( !empty($image) ){ DB::execute("INSERT INTO gallery_report SET image_id = ".$image['image_id'].", user_id = ".intval($_SESSION['UserId']).", artist_id=".intval($image['user_id']).", reason='".$_POST['reason']."', message='".$_POST['message']."', status='new', report_date=now();"); Renderosity\Facades\Flash::add( array( "type" => "s", "message" => "Success! Your report was submitted successfully.", "redirect" => bw_href_prefix().'/mod/gallery/?image_id='.$image['image_id'] ) ); }else{ Renderosity\Facades\Flash::add( array( "type" => "e", "message" => "Sorry! We cannot find this image in our records.", "redirect" => bw_href_prefix().'/mod/gallery/' ) ); } } } if( is_numeric($_GET['delete']) ){ require_once root_dir().'secure.php'; /* Retrieve DB info */ DB::execute("SELECT * FROM gallery_image WHERE image_id = ".intval($_GET['delete']), false); $item = DB::getAtIndex(0); if( empty($item) ){ Renderosity\Facades\Flash::add( array("type" => "e", "message" => "Sorry! We could not find this image in our records.", "redirect" => bw_href_prefix().'/mod/gallery/') ); } DB::execute("SELECT * FROM bwcore_member WHERE userid = ".intval($item['user_id']), false); $item['username'] = DB::getAtIndex(0,'username'); if( !is_admin() && !$gapp->is_coordinator() && !$gapp->is_moderator() && $item['user_id'] != intval($_SESSION['UserId']) ){ Renderosity\Facades\Flash::add( array("type" => "e", "message" => "Sorry! You do not have the permission to delete this gallery item.", "redirect" => bw_href_prefix().'/mod/gallery/') ); } /* Deprecate in future versions */ @unlink(FILE_DIR.$item['image_file']); @unlink(FILE_DIR.$item['display_file']); @unlink(FILE_DIR.$item['thumb_file']); /* Delete S3 Data */ cleanup($item['image_id']); /* Delete Database Data - place in queue for cleanup.php */ DB::execute("update gallery_image set status = 'deleted', status_change_date = now(), status_user_id=".intval($_SESSION["UserId"])." WHERE image_id = ".$item['image_id']); /* Data handler */ if( isset($_GET['json']) ){ echo json_encode($data); exit(); }else{ if( !empty($_GET['gotoPage']) ){ Renderosity\Facades\Flash::add( array("type" => "w", "message" => "Success! The gallery image was successfully deleted.", "redirect" => $_GET['gotoPage'] ) ); } else{ Renderosity\Facades\Flash::add( array("type" => "w", "message" => "Success! The gallery image was successfully deleted.", "redirect" => bw_href_prefix().'/mod/gallery/' ) ); } } } /* Legacy fix */ if( is_numeric($_GET["user_id"]) ){ $_GET["uid"] = $_GET["user_id"]; } /* VOM & VOY & ASY & ROY & MVP */ DB::execute("select a.* from bwcore_award_winner_map a join bwcore_award b on a.award_id=b.award_id where b.award_key = 'AOM' and YEAR(awarded_at) = YEAR(CURDATE()) and MONTH(awarded_at) = MONTH(CURDATE()) limit 1"); $aom = DB::getAtIndex(0,"awardable_id"); DB::execute("select a.* from bwcore_award_winner_map a join bwcore_award b on a.award_id=b.award_id where b.award_key = 'AOY' and YEAR(awarded_at) = YEAR(CURDATE()) limit 1"); $aoy = DB::getAtIndex(0,"awardable_id"); /////////////////////////////////////////////////// // Page Controllers /////////////////////////////////////////////////// if( isset($_GET['search']) || is_numeric($_GET['section_id']) || is_numeric($_GET['genre_id'])){ require_once root_dir().'mod/gallery/results/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js", "assets/javascripts/imageLoader.js", "assets/javascripts/date.js"), "css" => array("assets/css/gallery.css"), "title" => "Browse Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Featured Section */ elseif( isset($_GET['featured']) ){ require_once root_dir().'mod/gallery/featured/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "Featured | Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Trending Section */ elseif( isset($_GET['trending']) ){ require_once root_dir().'mod/gallery/trending/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "Trending | Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Trending Section */ elseif( isset($_GET['recommended']) ){ require_once root_dir().'secure.php'; require_once root_dir().'mod/gallery/recommended/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "For You | Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Artists Section */ elseif( isset($_GET['artists']) ){ require_once root_dir().'mod/gallery/artists/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js", "assets/javascripts/endlessScroller.js" ), "css" => array("assets/css/gallery.css"), "title" => "Artists | Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Image description page */ elseif(is_numeric($_GET['image_id']) ){ require_once root_dir().'mod/gallery/info/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "meta" => $meta_data, "title" => $meta_title )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Gallery Portfolio */ elseif(isset($_GET['uid'])){ require_once root_dir().'mod/gallery/portfolio/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js", "assets/javascripts/imageLoader.js"), "css" => array("assets/css/gallery.css"), "meta" => $meta_data, "title" => $meta_title )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* ArtCharts */ elseif(isset($_GET['leaderboard']) ){ require_once root_dir().'mod/gallery/leaderboard/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "Art Charts" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Admin area for managing galleries and genres */ elseif( isset($_GET['manage']) ){ require_once root_dir().'secure.php'; require_once root_dir().'mod/gallery/manage/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "Manage Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Admin area for managing galleries and genres */ elseif( isset($_GET['albums']) ){ require_once root_dir().'secure.php'; require_once root_dir().'mod/gallery/albums/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "Manage Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Settings */ elseif (isset($_GET['sga'])) { require_once root_dir().'secure.php'; require_once root_dir().'mod/gallery/settings/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => 'Gallery Settings | Renderosity')); require_once root_dir().'settings/_index.html.php'; } /* Upload & edit gallery image */ elseif(isset($_GET['upload']) ){ require_once root_dir().'secure.php'; require_once root_dir().'mod/gallery/upload/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js"), "css" => array("assets/css/gallery.css"), "title" => "Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } /* Landing pages */ else{ require_once root_dir().'mod/gallery/homepage/index.php'; Renderosity\Facades\TMPL::renderHeader('layouts/application/header.html.php', array( "js" => array("assets/javascripts/gallery.js", "assets/javascripts/imageLoader.js"), "css" => array("assets/css/gallery.css"), "title" => "Gallery | Renderosity" )); require_once root_dir().'mod/gallery/_index.html.php'; Renderosity\Facades\TMPL::renderFooter('layouts/application/footer.html.php'); } ?>