summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--server.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/server.php b/server.php
new file mode 100644
index 0000000..0683f12
--- /dev/null
+++ b/server.php
@@ -0,0 +1,59 @@
+<?php
+
+if($_POST['number'])
+{
+$varNumber = $_POST['number'];
+
+$mySourceFile = fopen("source.txt", "r") or die("Unable to open file!");
+
+for ($i = 1; $i <= $varNumber; $i++) {
+ fgets($mySourceFile);
+}
+
+if (!feof($mySourceFile))
+ {
+ echo fgets($mySourceFile);
+
+ }
+ else
+ {
+ echo "The end of the input file.";
+ }
+fclose($mySourceFile);
+}
+
+
+if($_POST['number_trgt'])
+{
+$varNumber = $_POST['number_trgt'];
+
+$myTargetFile = fopen("target.txt", "r") or die("Unable to open file!");
+
+for ($i = 1; $i <= $varNumber; $i++) {
+ fgets($myTargetFile);
+}
+
+if (!feof($myTargetFile))
+ {
+ echo fgets($myTargetFile);
+ }
+ else
+ {
+ echo "The end of the input file.";
+ }
+fclose($myTargetFile);
+}
+
+
+if($_POST['postedit'])
+{
+$varData = $_POST['postedit'];
+echo $varData;
+
+$myFile = "testFile.txt";
+file_put_contents($myFile, $varData, FILE_APPEND);
+file_put_contents($myFile, PHP_EOL, FILE_APPEND);
+
+}
+
+?>