"e", "message" => "Sorry! You must be signed in to perform this action." , "redirect" => !empty($_GET['gotoPage']) ? urldecode($_GET['gotoPage']) : bw_href_prefix().'/news/' ) ); } DB::execute("UPDATE bwcore_member SET receive_email='Y' where userid=".intval($_SESSION['UserId'])); Flash::add( array("type" => "s", "message" => "Success! You will now recieve newsletters, announcements, and special offers from Renderosity." , "redirect" => !empty($_GET['gotoPage']) ? urldecode($_GET['gotoPage']) : bw_href_prefix().'/news/' ) ); } /////////////////////////////////////////////////// //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, 0777); } $file = Image::open($_FILES['file']['tmp_name'])->save(MEDIA_DIR.$filename, array('quality' => 100)); //uploads to s3 from server if(S3::bucket("bwcore")->putObject(MEDIA_DIR.$filename, 'bwcore_tmp/'.$filename)){ @unlink(MEDIA_DIR.$filename); exit(json_encode(array( "link" => array( "url" => S3::bucket("bwcore")->getObjectUrl('bwcore_tmp/'.$filename), "alt" => $_FILES['file']['name'], "basename" => $filename, "is_image" => true )))); } } } } } if( $_POST['addResponse'] == 'Y' ){ if( !logged_in() ){ Flash::add( array("type" => "e", "message" => "Sorry! You must be signed in to perform this action." , "redirect" => bw_href_prefix().'/news/' ) ); } DB::execute("SELECT article_id,headline,headline_url,date_activated FROM bwcore_article WHERE article_id = ".intval($_POST['article_id']).";"); $orig_art = DB::getAtIndex(0); $headline_url = bw_get_article_url($orig_art); if( empty($orig_art ) ){ Flash::add( array("type" => "e", "message" => "Sorry! This article cannot be found in any of our records." , "redirect" => bw_href_prefix().'/news/' ) ); } $new_body = strip_tags($_POST['body']); DB::execute("INSERT INTO bwcore_article_response set article_id = ".$orig_art["article_id"].", userid=".intval($_SESSION['UserId']).", date_created = now(), time_created = now(), time_activated = now(), article_response_status='P', body= '".prep_markdown($new_body)."'"); $id = DB::lastInsertId(); /* S3 Files */ if( !empty($_POST['file']) ){ foreach ($_POST['file'] as $file) { if( S3::bucket("bwcore")->doesObjectExist('bwcore_tmp/'.$file) ){ try{ /* Copy tmp file to permanent location */ S3::client()->copyObject( array( 'Bucket' => S3::bucket('bwcore')->getBucketName(), 'Key' => 'comments/comment_'.$id.'/'.$file, 'CopySource' => S3::bucket('bwcore')->getBucketName().'/bwcore_tmp/'.$file, 'ACL' => 'public-read-write' ) ); /* Delete tmp file */ S3::bucket("bwcore")->deleteObject('bwcore_tmp/'.$file); /* Update Links */ DB::execute("select body from bwcore_article_response where article_response_id=".$id, false); $new_body = preg_replace('/bwcore_tmp\//', 'comments/comment_'.$id.'/', stripslashes(DB::getAtIndex(0,'body'))); DB::execute("update bwcore_article_response set body='".addslashes($new_body)."' where article_response_id=".$id); }catch(Exception $e){ $error = 'an error saving the uploaded body files.
Please try again contacting the site administrator.'; } } } } $mail = new AppMailer(); $mail->From = APP::get('adminAddress'); $mail->Subject = APP::get('communityname') . ": " . $orig_art['headline']; $mail->Body = bw_render('mailers/core/_article_comment_notification.html.php', array("comments_url" => APP::get('secure_server')."admin_content.php?comments", "headline_url" => $headline_url, "username" => username(intval($_SESSION['UserId'])), "name" => APP::get('communityname'), "body" => purify($new_body, array("prepare" => false)) ), 'mailers/templates/_basic_notification_template.html.php'); $mail->AltBody($mail->Body); $mail->AddBCC(APP::get('adminAddress')); $mail->Send(); Flash::add( array("type" => "s", "message" => "Success! Your opinion has successfully been submitted. Your opinion will be posted once our staff reviews it. Thank you for your interest." , "redirect" => bw_get_article_url($orig_art) ) ); } if( is_numeric($_GET['delResponse']) ){ if( !logged_in() ){ Flash::add( array("type" => "e", "message" => "Sorry! You must be signed in to perform this action." , "redirect" => bw_href_prefix().'/news/' ) ); } DB::execute("SELECT * FROM bwcore_article_response WHERE article_response_id = '".intval($_GET['delResponse']) . "'"); $response = DB::getAtIndex(0); if( !empty($response) ){ if ( $_SESSION['Admin'] == "Y" || intval($_SESSION['UserId']) == $response['userid']){ /* Delete From S3 */ S3::bucket("bwcore")->deleteDirectory('comments/comment_'.intval($_GET['delResponse'])); DB::execute("delete FROM bwcore_article_response WHERE article_response_id = ".intval($_GET['delResponse'])); DB::execute("select article_id, headline, headline_url, date_activated from bwcore_article where article_id = ".intval($response["article_id"])); Flash::add( array("type" => "s", "message" => "Success! The comment has successfully been removed." , "redirect" => bw_get_article_url(DB::getAtIndex(0)) ) ); }else{ DB::execute("select article_id,headline,headline_url,date_activated from bwcore_article where article_id = ".intval($response["article_id"])); Flash::add( array("type" => "w", "message" => "Sorry! You do not have permission to do this." , "redirect" => bw_get_article_url(DB::getAtIndex(0)) ) ); } }else{ Flash::add( array("type" => "e", "message" => "Sorry! This comment cannot be found in any of our records." , "redirect" => bw_href_prefix().'/news/' ) ); } } if( isset($_GET['article_id']) || isset($_GET['viewStory']) ){ require root_dir().'news/info/index.php'; TMPL::renderHeader('layouts/news/header.html.php', array( "js" => array("assets/javascripts/news.js"), "css" => array("assets/css/news.css"), "meta" => $meta_data, "title" => $meta_title )); require_once root_dir().'news/_index.html.php'; TMPL::renderFooter('layouts/application/footer.html.php'); } elseif ( isset($_GET['archives']) ) { require root_dir().'news/archives/index.php'; TMPL::renderHeader('layouts/news/header.html.php', array( "js" => array("assets/javascripts/news.js"), "css" => array("assets/css/news.css"), "title" => "Archives | Blog | Renderosity")); require_once root_dir().'news/_index.html.php'; TMPL::renderFooter('layouts/application/footer.html.php'); } elseif ( isset($_GET['keyword']) ) { require root_dir().'news/keywords/index.php'; TMPL::renderHeader('layouts/news/header.html.php', array( "js" => array("assets/javascripts/news.js"), "css" => array("assets/css/news.css"), "meta" => $meta_data, "title" => $meta_title )); require_once root_dir().'news/_index.html.php'; TMPL::renderFooter('layouts/application/footer.html.php'); } else{ require root_dir().'news/results/index.php'; TMPL::renderHeader('layouts/news/header.html.php', array( "js" => array("assets/javascripts/news.js", "assets/javascripts/endlessScroller.js"), "css" => array("assets/css/news.css", "assets/css/endless-scroller.css"), "title" => "Blog | Renderosity" )); require_once root_dir().'news/_index.html.php'; TMPL::renderFooter('layouts/application/footer.html.php'); } ?>