online-editor

Gesponsorde koppelingen

PHP script bestanden

  1. online-editor

« Lees de omschrijving en reacties

index.php:

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
// Online php/script Editor
//
// Author: Jeroen Boersma
// Email: Pianoplayer[ @ ]planet.nl
// 05-2005
//
// Don't delete this header!
////////////////////////////////////

// connection

$db=mysql_connect("xxx","xxx","");
mysql_select_db("xxx",$db);

// functions
Function CreateTable(){
   $sql="CREATE TABLE phpscript (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,name VARCHAR(50),script TEXT)";
   $res=mysql_query($sql);
      if($res){
         $name="php script name here :)";
         $script="php script here :)";
         $sql="INSERT INTO phpscript (name,script) VALUES ('$name','$script')";
         $res2=mysql_query($sql);
            if($res2) echo "Table Created.";
            if(!$res2) echo "Table Created, but couldn't get any data in it.";
      }

      if(!$res) echo "Couldn't Create table. Please check your databaseconnection and the script.";

}
Function
SaveScript($id,$name,$script){
   $sql="UPDATE phpscript SET name='$name',script='$script' WHERE id='$id'";
   $res=mysql_query($sql);
      if($res) echo "Script Saved.";
      if(!$res){
         echo "Couldn't save the script. Maybe there is no table with the name phpscript.<br />";
         echo "<form action=" . $_SERVER['PHP_SELF'] . " method=POST><input type=submit value=\"Create Table\" name=CreateTable /></form>";
      }
}
Function
SaveAsNew($name,$script){
   $sql="INSERT INTO phpscript (name,script) VALUES ('$name','$script')";
   $res=mysql_query($sql);
   if($res) "Script saved.";
   if(!$res) "Couldn't save the script. Check your database and the script.";
}
Function
DeleteScript($id){
   $sql="DELETE FROM phpscript WHERE id='$id'";
   $res=mysql_query($sql);
   if($res) echo "Script deleted.";
   if(!$res) echo "Script not deleted. Check your database and the script.";
}


// something to do
if(isset($_POST['CreateTable'])){
   CreateTable();
}

if(isset($_POST['SaveScript'])){
   SaveScript($_POST['id'],$_POST['name'],addslashes($_POST['script']));
}

if(isset($_POST['SaveAsNew'])){
   SaveAsNew($_POST['name'],$_POST['script']);
}

if(isset($_POST['delete'])){
   DeleteScript($_POST['id']);
}


// show text.
if(isset($_POST['Show'])){
   $id=$_POST['id'];
   $name=$_POST['name'];
   $script=$_POST['script'];
}

else{
   if(isset($_GET['show_script'])){
      $SSid=$_GET['show_script'];
      $sql="SELECT * FROM phpscript WHERE id='$SSid'";
      $res=mysql_query($sql);
         if($res){
            $sarray=mysql_fetch_array($res);
            $id=$sarray['id'];
            $name=$sarray['name'];
            $script=stripslashes($sarray['script']);
         }

         else{
            echo "This script isn't in the database.";
         }
   }

   else{
      $sql="SELECT * FROM phpscript ORDER BY id DESC LIMIT 0,1";
      $res=mysql_query($sql);
         if($res){
            $sarray=mysql_fetch_array($res);
            $id=$sarray['id'];
            $name=$sarray['name'];
            $script=stripslashes($sarray['script']);
         }

         else{
           echo "Couldn't get data from table. Maybe the table isn't in the database.<br />If you don't have a mysql connection, just make your script, copy into some text program on your computer, and save it there.";
        echo "<form action=" . $_SERVER['PHP_SELF'] . " method=POST><input type=submit value=\"Create Table\" name=CreateTable /></form>";
           if(isset($_POST['script'])){$name=$_POST['name']; $script=$_POST['script'];}
           else{$id="0"; $name="Name"; $script="";}
      }
   }
}

echo "<table border=1 width=900>
       <tr>
        <td width=500 valign=top>"
;
    highlight_string($script);
echo   "</td>
    <td valign=top>
     <form action="
. $_SERVER['PHP_SELF'] . " method=POST><textarea rows=20 cols=45 name=script>" . htmlspecialchars($script) . "</textarea><input type=hidden name=id value=" . $id . " /><br /><input type=submit value=Show name=Show /><br /><br />Save name: <input type=text name=name value=\"$name\" /><br /><input type=submit value=Save name=SaveScript /> <input type=submit value=\"Save As New\" name=SaveAsNew /> <input type=submit value=Delete name=delete /></form><hr size=1 />";

$sql="SELECT id,name FROM phpscript ORDER BY name";
$res=mysql_query($sql);
if($res){
   while($phpscript=mysql_fetch_array($res)){
      echo "<a href=" . $_SERVER['PHP_SELF'] . "?show_script=" . $phpscript['id'] . ">" . $phpscript['name'] . "</a><br />";
   }
}


echo "<a href=show_all.php>Show all scripts</a> [<a href=show_all.php target=\"_blank\">new screen</a>]";
echo   "</td>
       </tr>
      </table>"
;
mysql_close();
?>



show_all.php

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
<?php
$db
=mysql_connect("localhost","root","");
mysql_select_db("tools",$db);
$sql="SELECT * FROM phpscript ORDER BY name";
$res=mysql_query($sql);
while($phpscript=mysql_fetch_array($res)){
   echo "<b>".$phpscript['name']."</b><br /><br />";
   highlight_string($phpscript['script']);
   echo "<hr />";
}

echo "<a href=index.php>Terug naar Editor.</a>";
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.