Advertisement
Guest User

Untitled

a guest
Feb 21st, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <?php
  2. //config
  3.  
  4. $url = '/new-editor.php';
  5. $file = '/home/pi/.config/lxsession/LXDE-pi/autostart';
  6.  
  7.  
  8.  
  9.  
  10.  
  11. if (preg_match("(http:\/\/.*\..*)", $_POST['text']))
  12. {
  13. $content = file_get_contents($file);
  14. $newContent = preg_replace("(http:\/\/.*\..*)", $_POST['text'], $content);
  15. file_put_contents($file, $newContent);
  16.  
  17. header(sprintf('Location: %s', $url));
  18. printf('<a href="%s">Moved</a>.', htmlspecialchars($url));
  19. exit();
  20. } else {
  21. echo "Feil: Det du skrev inn er ikke en gyldig URL, den må starte med http://<br>";
  22.  
  23. }
  24.  
  25. }
  26. $content = file_get_contents($file);
  27. $contArray = str_split($content);
  28. $tmpContent = preg_grep("(http:\/\/.*\..*)", $contArray);
  29. $oldContent = implode($tmpContent);
  30. ?>
  31. <form action="" method=post>
  32. URL til siden som skal vises: <input type="text" name="text" value="<?php echo htmlspecialchars($oldContent) ?>"><br>
  33. <input type="submit" />
  34. <input type="reset" />
  35. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement