Programovacie jazyky, rady, poradňa...
WebScript
Medium Expert
Príspevky: 118 Registrovaný: 04 okt 2009, 14:25
Príspevok
od používateľa WebScript » 17 dec 2009, 16:16
Chcel by som Vás poprosiť, našiel som tento php skript a chcel by som vás poprosiť že či by mi ho niekdo neprerobil aby ten subor nebol tam dany, ale aby sa ten subor tam zadaval v tej adrese ( takto nejak
http://notpead.webscript.biz/index.php? ... suboru.txt ) Tu je ten skript:
Kód: Vybrať všetko
<html>
<body>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Sorry, Notepad will not work with your browser.");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
}
}
var info = document.notepad.textarea.value;
ajaxRequest.open("GET", "process.php?info=" + info, true);
ajaxRequest.send(null);
}
//-->
</script>
<form name='notepad'>
Name: <textarea onKeyUp="ajaxFunction();" name='textarea'>
<?php
echo file_get_contents('test.txt');
?>
</textarea>
</form>
</body>
</html>
Už som to skúšal, ale píše mi to Parse error: syntax error, unexpected T_STRING in /home/www/webscript.biz/notepad/index.php on line 46
Tu je ten mnou upravený skript:
Kód: Vybrať všetko
<html>
<body>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxFunction(){
var ajaxRequest;
try{
ajaxRequest = new XMLHttpRequest();
} catch (e){
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
alert("Sorry, Notepad will not work with your browser.");
return false;
}
}
}
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
}
}
var info = document.notepad.textarea.value;
ajaxRequest.open("GET", "process.php?info=" + info, true);
ajaxRequest.send(null);
}
//-->
</script>
<form name='notepad'>
Name: <textarea onKeyUp="ajaxFunction();" name='textarea'>
<?php
echo file_get_contents('$_GET['subor']');
?>
</textarea>
</form>
</body>
</html>
Ďakujem
WebScript
Medium Expert
Príspevky: 118 Registrovaný: 04 okt 2009, 14:25
Príspevok
od používateľa WebScript » 17 dec 2009, 16:29
stale mi píše tú istú chybu,
nemohol by si mi radšej tak upraviť aby tento script nemal trvalo dané, aby tie subory sa dali upraviť na tejto adrese
http://notepad.webscript.biz/index.php? ... suboru.txt
Tu je subor index.php :
Kód: Vybrať všetko
<?php
if(!file_exists("notepad.txt")){
$f = fopen("notepad.txt", 'w');
fclose($f);
}
?>
<html>
<head>
<title>Ajax Notepad</title>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxfunc(){
document.getElementById('loading').style.display = "block";
document.getElementById('submit').disabled = "disabled";
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.getElementById('window').value = ajaxRequest.responseText;
document.getElementById('loading').style.display = "none";
document.getElementById('submit').value = " saved ";
}
}
ajaxRequest.open("GET", "write.php?n="+document.getElementById('window').value.replace(/\n/g,"<br>"), true);
ajaxRequest.send(null);
}
//-->
</script>
<style type="text/css">
#main {
width: 300px;
height: 234px;
border: 1px solid #aaa;
background: #ccc;
margin-left: 20px;
}
#status {
height: 6px;
text-align: center;
}
#loading {
display: none;
}
#window {
width: 290px;
height: 200px;
border: 1px solid #ccc;
margin-left: 5px;
margin-right: 5px;
padding: 1px;
}
#submit {
width: 100px;
border: 1px solid #aaa;
font-family: Arial;
}
</style>
</head>
<body>
<div id="main">
<div id="status"><center><img id="loading" src='loading.gif' alt='' /></center></div>
<textarea id="window" onkeyup="javascript:document.getElementById('submit').disabled='';document.getElementById('submit').value=' save ';"><?php echo file_get_contents("notepad.txt"); ?></textarea>
<div id="controls"><center><input id="submit" type="submit" onclick="javascript:ajaxfunc();return false" value=" saved " disabled="disabled" /></center></div>
</div>
<br />
Based on <a href="http://www.google.com/notebook/" target="_blanc">Google Notebook</a> and <a href="http://www.php.uni.cc/notes.html" target="_blanc">Tim's php-Notepad</a>.
</body>
</html>
A tu je subor write.php :
Kód: Vybrať všetko
<?php
$contents = strip_tags(str_replace('<br>',"\r\n",$_GET['n']));
$f2 = fopen("notepad.txt", 'w');
fwrite($f2, str_replace("\'", "'", str_replace('\"', '"', $contents)));
fclose($f2);
echo stripslashes($contents);
?>
Ďakujem
audiotrack
VIP
Príspevky: 25958 Registrovaný: 09 sep 2005, 18:39
Kontaktovať používateľa:
Príspevok
od používateľa audiotrack » 17 dec 2009, 16:39
write.php
Kód: Vybrať všetko
<?php
$contents = strip_tags(str_replace('<br>',"\r\n",$_GET['n']));
$f2 = fopen($_GET['file'], 'w');
fwrite($f2, str_replace("\'", "'", str_replace('\"', '"', $contents)));
fclose($f2);
echo stripslashes($contents);
?>
index.php
Kód: Vybrať všetko
<?php
if(!file_exists($_GET['file'])){
$f = fopen($_GET['file'], 'w');
fclose($f);
}
?>
<html>
<head>
<title>Ajax Notepad</title>
<script language="javascript" type="text/javascript">
<!--
//Browser Support Code
function ajaxfunc(){
document.getElementById('loading').style.display = "block";
document.getElementById('submit').disabled = "disabled";
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
document.getElementById('window').value = ajaxRequest.responseText;
document.getElementById('loading').style.display = "none";
document.getElementById('submit').value = " saved ";
}
}
ajaxRequest.open("GET", "write.php?file=<?php echo $_GET['file'];?>&n="+document.getElementById('window').value.replace(/\n/g,"<br>"), true);
ajaxRequest.send(null);
}
//-->
</script>
<style type="text/css">
#main {
width: 300px;
height: 234px;
border: 1px solid #aaa;
background: #ccc;
margin-left: 20px;
}
#status {
height: 6px;
text-align: center;
}
#loading {
display: none;
}
#window {
width: 290px;
height: 200px;
border: 1px solid #ccc;
margin-left: 5px;
margin-right: 5px;
padding: 1px;
}
#submit {
width: 100px;
border: 1px solid #aaa;
font-family: Arial;
}
</style>
</head>
<body>
<div id="main">
<div id="status"><center><img id="loading" src='loading.gif' alt='' /></center></div>
<textarea id="window" onkeyup="javascript:document.getElementById('submit').disabled='';document.getElementById('submit').value=' save ';"><?php echo file_get_contents($_GET['file']); ?></textarea>
<div id="controls"><center><input id="submit" type="submit" onclick="javascript:ajaxfunc();return false" value=" saved " disabled="disabled" /></center></div>
</div>
<br />
Based on <a href="http://www.google.com/notebook/" target="_blanc">Google Notebook</a> and <a href="http://www.php.uni.cc/notes.html" target="_blanc">Tim's php-Notepad</a>.
</body>
</html> skús takto, ak to nepôjde tak skúsim zapnúť apache, tieto úpravy som robil on the fly
WebScript
Medium Expert
Príspevky: 118 Registrovaný: 04 okt 2009, 14:25
Príspevok
od používateľa WebScript » 17 dec 2009, 17:09
diki, už to funguje, nemohol by si mi doplnit do toho skriptu že keď nevyberem žiadny súbor tak mi to otvorý defaultý súbor(subor.txt) s upozornením že nevybral žiadny súbor.
Ďakujem