SHARE
TWEET

Untitled

a guest Apr 24th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include("zahlavi.php");
  3. ?>
  4. <script src='https://devpreview.tiny.cloud/demo/tinymce.min.js'></script>
  5.  
  6.  
  7. <script>tinymce.init({ selector:'textarea' });</script>
  8. <?php
  9. $obrazek = "";
  10. if(isset($_POST['submit_new'])) {
  11.     function makeimage($sourcepath, $filename, $newfilename, $path, $newwidth, $newheight) {
  12.   $sourc=$sourcepath.$filename;
  13.     //SEARCHES IMAGE NAME STRING TO SELECT EXTENSION (EVERYTHING AFTER . )
  14.     $image_type = strstr($filename,  '.');
  15.  
  16.     //SWITCHES THE IMAGE CREATE FUNCTION BASED ON FILE EXTENSION
  17.         switch($image_type) {
  18.             case '.jpg':
  19.                 $source = imagecreatefromjpeg($sourc);
  20.                 break;
  21.             case '.png':
  22.                 $source = imagecreatefrompng($sourc);
  23.                 break;
  24.             case '.gif':
  25.                 $source = imagecreatefromgif($sourc);
  26.                 break;
  27.             default:
  28.                 echo("Error Invalid Image Type");
  29.                 die;
  30.                 break;
  31.             }
  32.    
  33.     //CREATES THE NAME OF THE SAVED FILE
  34.     $file = $newfilename . $filename;
  35.    
  36.     //CREATES THE PATH TO THE SAVED FILE
  37.     $fullpath = $sourcepath . $file;
  38.  
  39.     //FINDS SIZE OF THE OLD FILE
  40.     list($width,  $height) = getimagesize($sourc);
  41.  
  42.     //CREATES IMAGE WITH NEW SIZES
  43.     $thumb = imagecreatetruecolor($newwidth,  $newheight);
  44.  
  45.     //RESIZES OLD IMAGE TO NEW SIZES
  46.     imagecopyresized($thumb,  $source,  0,  0,  0,  0,  $newwidth,  $newheight,  $width,  $height);
  47.  
  48.     //SAVES IMAGE AND SETS QUALITY || NUMERICAL VALUE = QUALITY ON SCALE OF 1-100
  49.     imagejpeg($thumb,  $fullpath,  60);
  50.  
  51.     //CREATING FILENAME TO WRITE TO DATABSE
  52.     $filepath = $fullpath;
  53.    
  54.     //RETURNS FULL FILEPATH OF IMAGE ENDS FUNCTION
  55.     return $filepath;
  56.  
  57. }
  58. //$miniatura="min_".$_FILES['soubor']['name'];
  59.        if(isset($_POST['submit_new'])){
  60.        if($_FILES['obrazek']['size']>0){
  61.        move_uploaded_file($_FILES['obrazek']['tmp_name'], "img/".$_FILES['obrazek'] ['name']);
  62.       makeimage("img/",$_FILES['obrazek'] ['name'],"min_","",180,135);
  63.        $obrazek=$_FILES['obrazek']['name'];
  64.        }else{
  65.        //echo "Soubor nebyl vybrán!<br/>";
  66.        }  
  67.        }  
  68.    
  69. $zprava="";
  70.  if(strlen(ltrim($_POST['nadpis']))>0){
  71.  $nadpis=htmlspecialchars($_POST['nadpis']);
  72.  }else{
  73.  $zprava .="Nevyplnili jste nadpis <br />";
  74.  }
  75.  if(strlen(ltrim($_POST['kratky']))>0){
  76.  $kratky=htmlspecialchars($_POST['kratky']);
  77.  }else{
  78.  $zprava .="Nevyplnili jste krátký text<br />";
  79.  }
  80.  if(strlen(ltrim($_POST['dlouhy']))>0){
  81.  $dlouhy=htmlspecialchars($_POST['dlouhy']);
  82.  }else{
  83.  $zprava .="Nevyplnili jste dlouhý text<br />";
  84.  }
  85.    
  86.  
  87.  if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
  88.     $ip = $_SERVER['HTTP_CLIENT_IP'];
  89. } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
  90.     $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
  91. } else {
  92.     $ip = $_SERVER['REMOTE_ADDR'];
  93. }
  94.       /*if(strlen(ltrim($_POST['rok']))>0){
  95.  
  96.  }else{
  97.  $zprava .="Nevyplnili jste pole rok <br />";
  98.  }
  99.       if($_POST['rok']==date('Y')){
  100.           $rok=$_POST['rok'];
  101.       }else{
  102.            $zprava .="Špatný rok <br />";
  103.       }*/
  104.      
  105.  
  106.   $date=$_POST['rok']."-".$_POST['mesic']."-".$_POST['den']." ".$_POST['hodina'].":".$_POST['minuta'].":00";
  107.  
  108.   if(strlen($zprava)==0){
  109.  
  110.     include ('../../mysqli_connect.php');
  111.       $sql="INSERT INTO novinky (nadpis,kratky_text,dlouhy_text,obrazek,vlozeno,datum) VALUES('$nadpis', '$kratky', '$dlouhy','$obrazek',now(),'$date')";
  112.     if($vysledek=mysqli_query($link,$sql)){
  113.     echo "Zpráva byla přidána.";
  114.    
  115.     exit;
  116.     }else {
  117.     echo mysqli_error($link);
  118.     }
  119.   }else{
  120.   echo $zprava;
  121.   }
  122.  
  123.   }
  124.  
  125.  ?>
  126.   <h1 align="center">Přidání novinky</h1>
  127.   <form action= "" method="post" enctype="multipart/form-data">
  128.   Nadpis: <br> <input type="text" name="nadpis" size="50"> <br>
  129.   Krátký text:<br> <textarea name="kratky" rows="5" cols="61"></textarea> <br>
  130.   Dlouhý text: <br><textarea name="dlouhy" rows="8" cols="61"></textarea> <br>
  131.   Obrázek: <input type="file" name="obrazek"><br>  
  132.   Datum:
  133. <select name="den">
  134.     <option value="-">-</option>
  135. <?php
  136.  
  137.  
  138.  
  139.  for($i=0; $i<=31;$i++){
  140.      //if($i == date("j")){
  141.         // echo "<option value=".$i." selected>".$i."</option>\n";
  142.     // }else{
  143.      echo "<option value=".$i.">".$i."</option> \n";       
  144.      //}
  145.   }  
  146.  
  147.   ?>  
  148.  
  149.   </select>
  150.  
  151.   <select name="mesic">
  152. <option value="-">-</option>
  153.       <?php
  154. /*$mesic = array(1=>"Leden","Únor","Březen","Duben","Květen","Červen","Červenec", "Srpen", "Září", "Říjen", "Listopad","Prosinec");
  155.   foreach($mesic as $key => $value){
  156.       $sel = ($key == date("n"))?" selected":"";
  157.  
  158.       echo "<option value=".$key." $sel>".$value."</option> \n";  
  159.   }  */
  160. //echo "<option value="-">-</option>";
  161. for($i=1; $i<=12;$i++){
  162.      //if($i == date("m")){
  163.          //echo "<option value=".$i." selected>".$i."</option>\n";
  164.      //}else{
  165.      echo "<option value=".$i.">".$i."</option> \n";       
  166.      //}
  167.   }  
  168.  
  169.      ?>  
  170.   </select>
  171.  
  172.   <select name="rok">
  173.       <option value="-">-</option>
  174. <?php
  175.  $i=date("Y");
  176.    while($i<=date("Y")+3){
  177.     //$sel = ($i == date("Y"))?" selected":"";  
  178.    echo "<option value=".$i." $sel>".$i."</option> \n";
  179.    $i++;
  180.    }    
  181.      ?>  
  182.   </select>
  183.      <br>Čas:
  184.       <select name="hodina">
  185.           <option value="-">-</option>
  186. <?php
  187.  
  188.  
  189.  
  190.  for($i=0; $i<=24;$i++){
  191.     // if($i == date("G")){
  192.     //   echo "<option value=".$i." selected>".$i."</option>\n";
  193.      //}else{
  194.      echo "<option value=".$i.">".$i."</option> \n";       
  195.      //}
  196.   }  
  197.  
  198.   ?>  
  199.  
  200.   </select>
  201.       :
  202.     <select name="minuta">
  203.         <option value="-">-</option>
  204. <?php
  205.  
  206.  
  207.  
  208.  for($i=0; $i<=59;$i++){
  209.     // if($i == date("i")){
  210.     //   echo "<option value=".$i." selected>".$i."</option>\n";
  211.      //}else{
  212.      echo "<option value=".$i.">".$i."</option> \n";       
  213.      //}
  214.   }  
  215.  
  216.   ?>  
  217.  
  218.   </select>  
  219.  
  220.  
  221.     <!-- <br> Napište aktualní rok:<br>
  222.       <input type="text" name="rok" size="4"> --><br>
  223.         <input type="submit" name="submit_new">
  224.   </form>
  225.  
  226.  
  227. <?php
  228. include("zapati.php");
  229. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top