Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
Submit
~
home
cmediaonline-mnfgj
cmediaonline.in
public
admin
File Content:
addmainnews1.php
<?php ob_start(); ?> <?php session_start(); if (!isset($_SESSION['username'])) { $_SESSION['msg'] = "You must log in first"; header('location: login.php'); } if (isset($_GET['logout'])) { session_destroy(); unset($_SESSION['username']); header("location: login.php"); } ?> <?php include "assets/includes/functions.php";?> <?php include "assets/includes/header.php";?> <!-- Page content start --> <div class="page-contentbar"> <!--left navigation start--> <?php include "assets/includes/sidebar.php";?> <!--left navigation end--> <!-- START PAGE CONTENT --> <div id="page-right-content"> <div class="container"> <div class="row"> <br><br><br> <div class="panel panel-color panel-primary"> <div class="panel-heading"> <h3 class="panel-title">Add Main News [ <span class="required" style="text-align: right"> *</span>= Required ]</h3> </div> <div class="panel-body" > <div class="container" id="addmember"> <input type="hidden" id="imgw" value="" > <input type="hidden" id="imgh" value="" > <p class="statusMsg"></p> <form enctype="multipart/form-data" id="add_name" method="post"> <div class="form-group"> <div class="row"> <div class="col-md-12"> <label for="userName"> Sections in Home Page<span class="text-danger"></span></label> <select name="PostSection" class="form-control" id="PostSection" required=""> <option value="" disabled selected>Select</option> <option value="Entertainments">Entertainments,Sports,Auto & Travel</option> <option value="Science">Science & Tech</option> <option value="Chuttuvattam">Chuttuvattam</option> </select> </div> </div> </div> <div class="form-group" id="enter"> <div class="row"> <div class="col-md-12"> <label for="userName"> Main Category<span class="text-danger"></span></label> <select name="PostCategoryId" class="form-control" id="PostCategoryId" required=""> <option value="" disabled selected>Select</option> <option value="Main News">Main News</option> <option value="Sub News">Sub News</option> </select> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-md-12"> <label for="PostTitle<span Class=required>*</span>" class="col-md-3 control-label">Title<span Class=required style='color:#F00;'> * </span></label> <input name="PostTitle" class="form-control" maxlength="256" type="text" id="PostTitle" required=""/> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-md-12"> <label for="PostImage<spanClass=required></span>" id="l1" class="col-md-3 control-label">Image<span Class=required style='color:#F00;'> * </span>[ size: 368 x 300 ]</label> <label for="PostImage<spanClass=required></span>" id="l2" class="col-md-3 control-label" style="display: none;">Image<span Class=required style='color:#F00;'> * </span>[ size: 100 x 80 ]</label> <input type="file" name="file" class="form-control" id="PostImage" onchange="checkFileDetails()" required=""/> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-md-12"> <label for="PostContent<spanClass=required>*</span>" class="col-md-3 control-label">Content<span Class=required> * </span></label> <textarea name="PostContent" class="form-control" rows="12" cols="30" id="PostContent" required=""></textarea> </div> </div> </div> <div class="form-group"> <div class="row"> <div class="col-md-12"> <label for="userName">Status<span class="text-danger"></span></label> <select class="form-control select2" name="istatus" id="istatus" style="font-family:inherit;width:100%; height:50px; float:left; padding:5px; line-height:40px; text-align:left;" required=""> <option value="Active">Active</option> <option value="Inactive">Inactive</option> </select> </div> </div> </div> <div class="form-group text-right m-b-0"> <input type="submit" name="submit" class="btn btn-primary submitBtn" value="Submit"/> <button type="button" name="cancel" id="cancel" class="btn btn-default waves-effect m-l-5"> Cancel </button> </div> <?php if(isset($_POST['submit'])) { $section=$_POST["PostSection"]; $category=$_POST["PostCategoryId"]; $PostTitle=$_POST["PostTitle"]; $PostImage=$_FILES['file']['name']; $PostContent=$_POST["PostContent"]; $status=$_POST["istatus"]; date_default_timezone_set ("Asia/Calcutta"); $postdate= date("M d,Y h:i:s a"); // echo $postdate; // echo $PostImage; // echo $PostContent; if ($PostImage == "" || empty($PostImage)) { $image_text = ""; } { $target = "assets/images/mainnews/".basename($_FILES['file']['name']); // root dir move_uploaded_file($_FILES['file']['tmp_name'], $target); } $sql = "INSERT INTO mainnews (section,heading,newspic,newsdate,newscontent,status,maincategory) values ('".mysqli_real_escape_string($connection, $section)."','".mysqli_real_escape_string($connection, $PostTitle)."','".mysqli_real_escape_string($connection, $PostImage)."','".mysqli_real_escape_string($connection, $postdate)."','".mysqli_real_escape_string($connection, $PostContent)."','".mysqli_real_escape_string($connection, $status)."','".mysqli_real_escape_string($connection, $category)."')"; if ($connection->query($sql) === TRUE) { echo "New record created successfully"; header("Location: mainnews.php"); } else { echo "Error: " . $sql . "<br>" . $connection->error; } } ?> </form> </div> </div></div> </div> </div> <!-- end container --> <div class="footer"> <div class="pull-right hidden-xs"> Project Completed <strong class="text-custom">99%</strong>. </div> <div> <strong>C Media</strong> - Copyright © 2019 </div> </div> <!-- end footer --> </div> <!-- End #page-right-content --> </div> <!-- end .page-contentbar --> </div> <!-- End #page-wrapper --> <!-- js placed at the end of the document so the pages load faster --> <script src="assets/js/jquery-2.1.4.min.js"></script> <script src="assets/js/bootstrap.min.js"></script> <script src="assets/js/metisMenu.min.js"></script> <script src="assets/js/jquery.slimscroll.min.js"></script> <script src="assets/plugins/bootstrap-tagsinput/js/bootstrap-tagsinput.min.js"></script> <script src="assets/plugins/select2/js/select2.min.js" type="text/javascript"></script> <script src="assets/plugins/bootstrap-filestyle/js/bootstrap-filestyle.min.js" type="text/javascript"></script> <script src="assets/plugins/switchery/switchery.min.js"></script> <script type="text/javascript" src="assets/plugins/parsleyjs/parsley.min.js"></script> <script src="assets/plugins/moment/moment.js"></script> <script src="assets/plugins/timepicker/bootstrap-timepicker.js"></script> <script src="assets/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.min.js"></script> <script src="assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.min.js"></script> <script src="assets/plugins/clockpicker/js/bootstrap-clockpicker.min.js"></script> <script src="assets/plugins/bootstrap-daterangepicker/daterangepicker.js"></script> <script src="assets/plugins/summernote/summernote.min.js"></script> <!-- form advanced init js --> <script src="assets/pages/jquery.form-advanced.init.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!-- App Js --> <script src="assets/js/jquery.app.js"></script> <script type="text/javascript"> $(document).ready(function() { $('.form-validation').parsley(); $('.summernote').summernote({ height: 350, // set editor height minHeight: null, // set minimum height of editor maxHeight: null, // set maximum height of editor focus: false // set focus to editable area after initializing summernote }); }); </script> <script type="text/javascript"> $(document).ready(function(){ $("#l1").show(); $("#l2").hide(); $("#enter").show(); $('#PostSection').change(function(){ var section_id = $('#PostSection').val(); if(section_id =="Entertainments") { $("#enter").show(); $('#PostCategoryId').change(function(){ var location_id = $('#PostCategoryId').val(); if(location_id =="Main News") { $("#l1").show(); $("#l2").hide(); $("#imgw").val("368"); $("#imgh").val("300"); } else { $("#l1").hide(); $("#l2").show(); $("#imgw").val("100"); $("#imgh").val("80"); } }) } else if(section_id =="Science") { $("#enter").hide(); $("#l1").show(); $("#l2").hide(); $("#imgw").val("368"); $("#imgh").val("300"); } else if(section_id =="Chuttuvattam") { $("#enter").hide(); $("#l1").hide(); $("#l2").show(); $("#imgw").val("100"); $("#imgh").val("80"); } }) }); </script> <script> $(document).ready(function(e){ $('#cancel').delegate('','click change',function(){ window.location = "mainnews.php"; return false; }); }); </script> <!-- =================== --> <script> function checkFileDetails() { var fi = document.getElementById('PostImage'); if (fi.files.length > 0) { // FIRST CHECK IF ANY FILE IS SELECTED. for (var i = 0; i <= fi.files.length - 1; i++) { var fileName, fileExtension, fileSize, fileType, dateModified; // FILE NAME AND EXTENSION. fileName = fi.files.item(i).name; fileExtension = fileName.replace(/^.*\./, ''); // CHECK IF ITS AN IMAGE FILE. // TO GET THE IMAGE WIDTH AND HEIGHT, WE'LL USE fileReader(). if (fileExtension == 'png' || fileExtension == 'jpg' || fileExtension == 'jpeg') { readImageFile(fi.files.item(i)); // GET IMAGE INFO USING fileReader(). } else { // IF THE FILE IS NOT AN IMAGE. fileSize = fi.files.item(i).size; // FILE SIZE. fileType = fi.files.item(i).type; // FILE TYPE. dateModified = fi.files.item(i).lastModifiedDate; // FILE LAST MODIFIED. document.getElementById('fileInfo').innerHTML = document.getElementById('fileInfo').innerHTML + '<br /> ' + 'Name: <b>' + fileName + '</b> <br />' + 'File Extension: <b>' + fileExtension + '</b> <br />' + 'Size: <b>' + Math.round((fileSize / 1024)) + '</b> KB <br />' + 'Type: <b>' + fileType + '</b> <br />' + 'Last Modified: <b>' + dateModified + '</b> <br />'; } } // GET THE IMAGE WIDTH AND HEIGHT USING fileReader() API. function readImageFile(file) { var reader = new FileReader(); // CREATE AN NEW INSTANCE. var imgw = $('#imgw').val(); var imgh = $('#imgh').val(); reader.onload = function (e) { var img = new Image(); img.src = e.target.result; img.onload = function () { var w = this.width; var h = this.height; if (w == imgw && h== imgh){ document.getElementById('fileInfo').innerHTML = document.getElementById('fileInfo').innerHTML + '<br /> ' + 'Name: <b>' + file.name + '</b> <br />' + 'File Extension: <b>' + fileExtension + '</b> <br />' + 'Size: <b>' + Math.round((file.size / 1024)) + '</b> KB <br />' + 'Width: <b>' + w + '</b> <br />' + 'Height: <b>' + h + '</b> <br />' + 'Type: <b>' + file.type + '</b> <br />' + 'Last Modified: <b>' + file.lastModifiedDate + '</b> <br />'; }else { alert("Image Dimension Should be " + imgw + " x " + imgh) $("#PostImage").val(''); return false; } } }; reader.readAsDataURL(file); } } } </script> </body> </html> <?php ob_end_flush(); ?>
Edit
Rename
Chmod
Delete