lol
This commit is contained in:
commit
20496a4be0
6 changed files with 310 additions and 0 deletions
110
JsPHP.php
Normal file
110
JsPHP.php
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
<?php
|
||||||
|
//created by Ziver koc. Nice hu
|
||||||
|
// Too make this work you must have echoed out html and the body tags
|
||||||
|
//********* GLOBAL **********************
|
||||||
|
$progressInit = false;
|
||||||
|
$progressNextId = 0;
|
||||||
|
//**************************************
|
||||||
|
// Example of use
|
||||||
|
echo"<html><body><center>";
|
||||||
|
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-life.gif");
|
||||||
|
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-mana.gif");
|
||||||
|
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-life.gif");
|
||||||
|
progressBarInit(550, 16, "img/bar-grey.gif", "img/bar-mana.gif");
|
||||||
|
for($i=0;$i<=100;$i+=2){
|
||||||
|
sleep(1);
|
||||||
|
progressSetValue($i);
|
||||||
|
progressSetText($i."%");
|
||||||
|
progressSetValue($i/2,1);
|
||||||
|
progressSetText(($i/2)."%",1);
|
||||||
|
progressSetValue($i/4,2);
|
||||||
|
progressSetText(($i/4)."%",2);
|
||||||
|
progressSetValue($i/3,3);
|
||||||
|
progressSetText(($i/3)."%",3);
|
||||||
|
//echo $i."% > ";
|
||||||
|
}
|
||||||
|
echo"</center></body></html>";
|
||||||
|
redirect("http://google.com");
|
||||||
|
|
||||||
|
function progressBarInit($width, $height, $imgBar, $imgProggress){
|
||||||
|
GLOBAL $progressInit, $progressNextId;
|
||||||
|
if(!$progressInit){
|
||||||
|
echo"
|
||||||
|
<script type='text/javascript'>
|
||||||
|
<!--
|
||||||
|
function setValue(id,value){
|
||||||
|
document.getElementById('progressValue'+id).style.width = value+'%';
|
||||||
|
}
|
||||||
|
function setText(id,text){
|
||||||
|
document.getElementById('progressText'+id).innerHTML = text;
|
||||||
|
}
|
||||||
|
//-->
|
||||||
|
</script>";
|
||||||
|
$progressInit = true;
|
||||||
|
}
|
||||||
|
$id = $progressNextId;
|
||||||
|
$progressNextId++;
|
||||||
|
echo"
|
||||||
|
<style type='text/css'>
|
||||||
|
.progress".$id."{
|
||||||
|
background: transparent url(".$imgBar.") repeat-x scroll 0%;
|
||||||
|
border: 1px solid black;
|
||||||
|
color: white;
|
||||||
|
height: ".$height."px;
|
||||||
|
margin: 5pt;
|
||||||
|
padding: 0pt;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
width: ".$width."px;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
#progressValue".$id."{
|
||||||
|
background: transparent url(".$imgProggress.") repeat-x scroll 0%;
|
||||||
|
float: left;
|
||||||
|
height: ".$height."px;
|
||||||
|
margin: 0pt;
|
||||||
|
padding: 0pt;
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div class='progress".$id."'>
|
||||||
|
<div id='progressValue".$id."' style='width: 0%' >
|
||||||
|
<span id='progressText".$id."'></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
flush();
|
||||||
|
return $id;
|
||||||
|
}
|
||||||
|
function progressSetValue($value,$id=0){
|
||||||
|
echo"
|
||||||
|
<script type='text/javascript'>
|
||||||
|
<!--
|
||||||
|
setValue(".$id.",".$value.");
|
||||||
|
//-->
|
||||||
|
</script>
|
||||||
|
";
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
function progressSetText($text,$id=0){
|
||||||
|
echo"
|
||||||
|
<script type='text/javascript'>
|
||||||
|
<!--
|
||||||
|
setText(".$id.",'".$text."');
|
||||||
|
//-->
|
||||||
|
</script>
|
||||||
|
";
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
function redirect($url){
|
||||||
|
echo"
|
||||||
|
<script type='text/javascript'>
|
||||||
|
<!--
|
||||||
|
window.location = '".$url."';
|
||||||
|
//-->
|
||||||
|
</script>
|
||||||
|
";
|
||||||
|
flush();
|
||||||
|
}
|
||||||
|
?>
|
||||||
45
db.php
Normal file
45
db.php
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
$db_host = "koc.se";
|
||||||
|
$db_database = "";
|
||||||
|
$db_user = "";
|
||||||
|
$db_password = "";
|
||||||
|
|
||||||
|
|
||||||
|
function dbconnect(){
|
||||||
|
@mysql_pconnect($GLOBALS['db_host'],$GLOBALS['db_user'],$GLOBALS['db_password'])
|
||||||
|
or die("ERROR CONNECTING TO DATABASE ".$GLOBALS['db_host']."!!!");
|
||||||
|
@mysql_select_db($GLOBALS['db_database'])
|
||||||
|
or die("THE DATABASE <b>".$GLOBALS['db_database']."</b> DO NOT EXIST!!!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function dbdisconnect(){
|
||||||
|
@mysql_close();
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableRow($table, $id){
|
||||||
|
$sqlSats = "SELECT * FROM ".$table." WHERE id=".$id;
|
||||||
|
return @mysql_fetch_assoc(runSimpleQuery($sqlSats));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getTableCount($table){
|
||||||
|
$sqlSats = "SELECT * FROM ".$table;
|
||||||
|
return @mysql_num_rows(runSimpleQuery($sqlSats));
|
||||||
|
}
|
||||||
|
|
||||||
|
function runQueryArray($sqlSats){
|
||||||
|
$resultat = array();
|
||||||
|
$sql = @mysql_query($sqlSats)
|
||||||
|
or die("QUERY FAILD!!!.");
|
||||||
|
|
||||||
|
while ($row = mysql_fetch_array($sql,MYSQL_ASSOC) ) array_push($resultat, $row);
|
||||||
|
return $resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
function runSimpleQuery($sqlSats){
|
||||||
|
$resultat = @mysql_query($sqlSats)
|
||||||
|
or die("QUERY FAILD!!!.");
|
||||||
|
|
||||||
|
return $resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
BIN
img/bar-grey.gif
Normal file
BIN
img/bar-grey.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 95 B |
BIN
img/bar-life.gif
Normal file
BIN
img/bar-life.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 B |
BIN
img/bar-mana.gif
Normal file
BIN
img/bar-mana.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 163 B |
155
sync.php
Normal file
155
sync.php
Normal file
|
|
@ -0,0 +1,155 @@
|
||||||
|
<?php
|
||||||
|
$sync = true;
|
||||||
|
$localDir = "projects";
|
||||||
|
$remoteFileSyncURL = "http://www.nada.kth.se/~ziver/sync.php";
|
||||||
|
$skip_filetype = array ("..",".");
|
||||||
|
$sessionPassword = "lol";
|
||||||
|
|
||||||
|
|
||||||
|
if(isset($_GET["fileList"])){
|
||||||
|
if($_GET["fileList"] == "array") print_r(getFileArray($localDir));
|
||||||
|
else echo serialize(getFileArray($localDir));
|
||||||
|
}
|
||||||
|
else if(isset($_GET["copyid"]) && $sync){
|
||||||
|
session_start();
|
||||||
|
if($_SESSION['auth'] == $sessionPassword){
|
||||||
|
echo "
|
||||||
|
<html>
|
||||||
|
<body onload='stop = true;'>
|
||||||
|
<div id='load'>|</div>
|
||||||
|
<script language='javascript'>
|
||||||
|
var stop = false;
|
||||||
|
function load() {
|
||||||
|
var loading = document.getElementById('load');
|
||||||
|
if (loading.innerHTML == '-') {
|
||||||
|
loading.innerHTML = '\\\\';
|
||||||
|
}
|
||||||
|
else if(loading.innerHTML == '\\\\'){
|
||||||
|
loading.innerHTML = '|';
|
||||||
|
}
|
||||||
|
else if(loading.innerHTML == '|'){
|
||||||
|
loading.innerHTML = '/';
|
||||||
|
}
|
||||||
|
else if(loading.innerHTML == '/'){
|
||||||
|
loading.innerHTML = '-';
|
||||||
|
}
|
||||||
|
if(stop){
|
||||||
|
loading.innerHTML = 'OK';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setTimeout('load()',200);
|
||||||
|
}
|
||||||
|
load();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
";
|
||||||
|
flush();
|
||||||
|
copyFile($_SESSION["id".$_GET["copyid"]]["copy"],$_SESSION["id".$_GET["copyid"]]["to"],$_SESSION["id".$_GET["copyid"]]["date"]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "<font color=red>ERROR</font>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if($sync){
|
||||||
|
session_start();
|
||||||
|
$_SESSION['auth'] = $sessionPassword;
|
||||||
|
$sessionId = 0;
|
||||||
|
|
||||||
|
$remoteFileList = unserialize(file_get_contents($remoteFileSyncURL."?fileList"));
|
||||||
|
$localFileList = getFileArray($localDir);
|
||||||
|
|
||||||
|
echo "<center><b>KOC SYNC: </b>".$remoteFileSyncURL."<br /><table width='200' border='1' style='border:1px solid #CCCCCC; border-collapse:collapse; width:95%;'>";
|
||||||
|
foreach($remoteFileList as $remoteFile){
|
||||||
|
$temp = searchFile($remoteFile, $localFileList);
|
||||||
|
if($temp >= 0){
|
||||||
|
if($remoteFile[0] > $localFileList[$temp][0]){
|
||||||
|
$_SESSION["id".$sessionId]["copy"] = $remoteFile[2];
|
||||||
|
$_SESSION["id".$sessionId]["to"] = $localDir.$localFileList[$temp][1];
|
||||||
|
$_SESSION["id".$sessionId]["date"] = $remoteFile[0];
|
||||||
|
echo "<tr bgcolor='#FF6F5C'><td>Local File Old!</td><td><iframe src='sync.php?copyid=".$sessionId."' width='25' height='20' frameborder='0' marginwidth='0' marginheight='0'></iframe></td>";
|
||||||
|
$sessionId++;
|
||||||
|
//copyFile($remoteFile[2],$localDir.$localFileList[$temp][1], $remoteFile[0]);
|
||||||
|
}
|
||||||
|
else if($remoteFile[0] < $localFileList[$temp][0]){
|
||||||
|
echo "<tr bgcolor='#A9B4FF'><td>Local File Newer!</td><td></td>";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
echo "<tr><td>Synced!</td><td></td>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$_SESSION["id".$sessionId]["copy"] = $remoteFile[2];
|
||||||
|
$_SESSION["id".$sessionId]["to"] = $localDir.$remoteFile[1];
|
||||||
|
$_SESSION["id".$sessionId]["date"] = $remoteFile[0];
|
||||||
|
echo "<tr bgcolor='#89FF8B'><td>New File!</td><td><iframe src='sync.php?copyid=".$sessionId."' width='25' height='20' frameborder='0' marginwidth='0' marginheight='0'></iframe></td>";
|
||||||
|
$sessionId++;
|
||||||
|
//copyFile($remoteFile[2],$localDir.$remoteFile[1],$remoteFile[0]);
|
||||||
|
}
|
||||||
|
echo "<td>".$remoteFile[2]."</td><td> => </td><td>".$remoteFile[1]."</td></tr>";
|
||||||
|
}
|
||||||
|
echo "</table></center>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo"<center><font color=red>Sync disabled for this server!</font></center>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyFile($source,$dest, $lastModDate = null){
|
||||||
|
@$file = fopen ($source, "rb");
|
||||||
|
if (!$file) {
|
||||||
|
echo"<font color=red>Failed to copy $source -> $dest!</font><br>";
|
||||||
|
return false;
|
||||||
|
}else {
|
||||||
|
if(!file_exists(dirname($dest)))
|
||||||
|
mkdir(dirname($dest),0777,true);
|
||||||
|
$filename = basename($source);
|
||||||
|
$fc = fopen($dest, "wb");
|
||||||
|
echo "<font color=green>$source => $dest</font><br><font color=black>";
|
||||||
|
while (!feof ($file)) {
|
||||||
|
$line = fread ($file, 1028);
|
||||||
|
fwrite($fc,$line);
|
||||||
|
echo "#";
|
||||||
|
}
|
||||||
|
fclose($fc);
|
||||||
|
if($lastModDate != null) touch($dest,$lastModDate);
|
||||||
|
echo "</font><br>";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tempFilesArray = array();
|
||||||
|
|
||||||
|
function getFileArray($foldername) {
|
||||||
|
GLOBAL $localDir, $skip_filetype, $tempFilesArray;
|
||||||
|
|
||||||
|
$dirhandle = @opendir($foldername); //öppnar mappen
|
||||||
|
$temp = 0;
|
||||||
|
if($dirhandle !== false){ //gick det att öppna mappen?
|
||||||
|
while($filename = readdir($dirhandle)){ //loopar igenom alla filer i mappen
|
||||||
|
$filepath = $foldername ."/". $filename;
|
||||||
|
if($temp>1 && is_dir($filepath)){ //är det en mapp?
|
||||||
|
getFileArray($filepath);
|
||||||
|
}
|
||||||
|
else{ // its a file
|
||||||
|
$filetype = ereg_replace("^.+\\.([^.]+)$", "\\1", $filename);
|
||||||
|
if (!in_array($filetype, $skip_filetype)) {
|
||||||
|
$tempFilesArray[] = array(filemtime($filepath),str_replace($localDir, "", $filepath),("http://".$_SERVER['SERVER_NAME'].str_replace("sync.php","",$_SERVER['SCRIPT_NAME']).$filepath),$filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$temp++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $tempFilesArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
function searchFile($remoteFile, $localFileList){
|
||||||
|
if(isset($localFileList)){
|
||||||
|
foreach($localFileList as $key => $localFile){
|
||||||
|
if($localFile[1] == $remoteFile[1]){
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
?>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue