Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* HTML code */
- Filename with extension :
- <input type="text" placeholder="ex: test.css" id="titlecopypaste" /><br/>
- <textarea cols="60" rows="10" placeholder="Insert code here" id="content"></textarea><br/>
- <select id="choose">
- <option value="public" selected="selected">Public</option>
- <option value="private">private</option>
- <option value="both">Public si private</option>
- </select>
- <center><button id="submitcopypaste">Done</button><br/>
- <p id="status_create"></p>
- </center>
- /* Javascript code */
- $("#submitcopypaste").click(function()
- {
- var fisier=$("#titlecopypaste").val();
- var content=$("#content").text();
- var select=$("#choose").val();
- $.ajax({
- type:"POST",
- url:"include/uploadtxt.php",
- data:"fis="+fisier+"&cont="+content+"&sel="+select,
- success:function(ev)
- {
- $(this).hide();
- $("#status_create").html(ev);
- }
- });
- /* PHP code */
- session_start();
- include('Files.php'); //the class created by
- include('connect.php');
- $status="";
- if(isset($_POST['fis'],$_POST['cont'],$_POST['sel']))
- {
- $obj=new Files();
- $file=$_POST['fis'];
- $content=$_POST['cont'];
- $selected=$_POST['sel'];
- switch($selected)
- {
- case "public":{
- $status=$obj->createfile("../diskuser/_public/".$file, $content);break;
- }
- case "private":{
- if(isset($_SESSION['utilizator'],$_SESSION['parola']))
- {
- $cer=mysql_query("select * from user where nickname='".$_SESSION['user']."' and password='".$_SESSION['parola']."'");
- if($cer)
- {
- while($info=mysql_fetch_array($cer))
- {
- $status=$obj->createfile("../diskuser/".$info['nickname']."/".$file, $content);break;
- }
- }
- else
- {
- $status="Connection error!";
- }
- }
- else
- {
- $status="The session has been expired !";
- }
- break;
- }
- case "both":{
- $status=$obj->createfile("../diskuser/_public/".$file, $content);
- $cer=mysql_query("select * from user where nickname='".$_SESSION['user']."' and password='".$_SESSION['parola']."'");
- if($cer)
- {
- while($info=mysql_fetch_array($cer))
- {
- $status=$obj->createfile("../diskuser/".$info['nickname']."/".$file, $content);break;
- }
- }
- else
- {
- $status="Database connection error !";
- }
- break;
- }
- }
- }
- else
- {
- $status="Invalid data !";
- }
- echo $status;
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement