Let's start to collect a few answers. More might follow if you can give meaningful answers
to the questions in the comments above:
Question 1: Most likely this is what you want to do:
substr($url, 0, -strlen(strrchr($url,'/')))
Alternatively:
dirname(sprintf('http://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']))
Question 2: There is little sense in obfuscating the path used inside a url to reference an image published somewhere: the url has to reference the image to enable anyone to see the image. For this to work the location of the image must be exposed by the url, so what is the point in that obfuscation? The obfuscated url references the image, however it looks. And everyone can use that url to retrieve the image.
Question 3: You configure a crontab entry on system level that is run daily at 11pm. That job calls something like wget http://localhost/myapp/sendmail.php
. That script sendmail.php
collects the required data and sends an email.