summaryrefslogtreecommitdiffstats
path: root/urldecode
diff options
context:
space:
mode:
Diffstat (limited to 'urldecode')
-rwxr-xr-xurldecode24
1 files changed, 9 insertions, 15 deletions
diff --git a/urldecode b/urldecode
index 19df702..dcea3e2 100755
--- a/urldecode
+++ b/urldecode
@@ -1,16 +1,10 @@
-#!/bin/bash
-arg="$1"
-i="0"
-while [ "$i" -lt ${#arg} ]; do
- c0=${arg:$i:1}
- if [ "x$c0" = "x%" ]; then
- c1=${arg:$((i+1)):1}
- c2=${arg:$((i+2)):1}
- printf "\x$c1$c2"
- i=$((i+3))
- else
- echo -n "$c0"
- i=$((i+1))
- fi
-done
+#!/usr/bin/php
+<?php
+if (count($argv) == 0) {
+ echo urldecode(file_get_contents("php://stdin"));
+} else {
+ foreach ($argv as $arg) {
+ echo urldecode(file_get_contents($arg));
+ }
+}