📜 ⬆️ ⬇️

Your screenshot service for a restful sleep

Quite often in development, and not only, you need to share a screenshot with someone. Therefore, it is already difficult to surprise anyone with Clip2Net , Joxi or Gyazo .

But there are several nuances that may interfere with their use. For me, this is advertising or a lot of garbage information around the screenshot (for example, from which browser window and when I made it - I'm paranoid), a dozen clicks to the cherished link in the browser and the clipboard. And to keep your screenshot with the image of the most important and above the secret information is not clear where - it is generally incomprehensible how.

It should be like this: pressed the hot key for a rectangle or screen, or for a scrolling window and that's it. The picture opened in the browser, and the link to it was copied to the clipboard. All this on your hosting next to your sites. Optionally, in the screenshot you can still draw different arrows and circles.
')
These tasks are perfectly solved by the Fast Stone Capture program plus your FTP, where you can upload the created screenshots. But there are nuances about which, if you think about it, you can stop sleeping peacefully. Under the cut I tell about the nuances and how to solve them, if you also need only pictures, only on your server and to sleep well.



Here is the standard option to configure the generated file name and parameters for FTP download.
imageimage


It seems all is well. They made a screen shot, it was loaded on the FTP, the link was opened and it also got on the clipboard. All at home, nothing superfluous, just a fairy tale.

However, we see that the first screenshot was obtained with the name example.com/_ss/screenshot0001.png , the second example.com/_ss/screenshot0002.png , the third example.com/_ss/screenshot0003.png and all of them lie on your ftp. I wonder how quickly someone will guess from your friends, especially developers, that it is so easy to go through all your pictures?

After all, there is surely something that is not intended for everyone. After a couple of years of such use of this screenshot, I'm afraid to imagine what could be. But it’s better not to think about it. Even if you use templates with dates, understanding this nuance will not let you fall asleep.

Idea number 1
For a second it even seemed that you could use a cliptunet from a yohi or a gazo. There links are quite difficult to sort out. I tried. But no. This is the only advantage did not defeat all the flaws against their own FTP with pictures. Especially after a long-term habit of taking a screenshot with one click of a hot key and getting exactly what was intended - a screenshot without garbage, but also on your server.

Idea number 2
You can also write in support of the program, but this is still the answer, until it appears, if it does. In 30 minutes you can do everything yourself.

In general, we will tune what the soul lies.

Solution number 1
We make a pattern of the form H $ YE $ SL $ M01 $ D $ S $ H #### $ N $ SABC $ S - add a lot of garbage between dates, a screenshot sequence number, seconds with minutes duplicate several times in different places, etc. P. Definitely the name of the file H2014E41L080115411600085941ABC41.png already gives much less cause for concern.

One could dwell on this, but the thought of enumeration still does not give rest. Although, who does they need these my pictures? But the matter of the principle: development, security, everything. That is, I am not calm. Surely someone else will, too.

Decision number 2
We make the same non-simple name template and add our own password (salt) to it. For example,
2G35nl0OJb4FkZH $ YE $ SL $ M01 $ D $ S $ H #### $ N $ SABC $ S. And we write our little script writer, which, when opening the link, will still shamanize over this file. In fact, it would have been possible to get by just with the garbage in the file template; no one will know the template from the bottom line. But you never know.

As a result, the FTP options window began to look like this:
image

Add to the URL a link to your script, which will be able to rename the opened file as needed and open it in the browser at a new address. Top secret, as it should be. Then you will first open a new screenshot, and then for all the link will already be new. Add here the option to delete old screenshots.

Some PHP code
<? $key = 'JLWWJLjfsdlf99234ged2340'; //   md5   . $folder = 'files'; //    ,     ss.php $lifetime = 86400 * 7; //     7  //     $link = ''; $cd = dirname(__FILE__) . '/'; //        if (!empty($_GET['file'])) { $file = ltrim($_GET['file'], '/'); // FS    ?file= if (preg_match('#^[0-9a-z_-]+\.(png|jpg|jpeg|gif)$#si', $file, $f)) { $dest = $cd . $folder . '/' . md5($key . $file) . '.' . $f[1]; $url = 'http://' . getEnv('HTTP_HOST') . str_replace(basename(__FILE__), '', $_SERVER['SCRIPT_NAME']) . $folder . '/'; $src = $cd . $file; $link = $url . basename($dest); if (file_exists($src)) { rename($src, $dest); } } } //    $dest = $cd . $folder . '/'; $files = scandir($dest); foreach ($files as $file) { if ($file[0] == '.') continue; $file = $dest . $file; if (time() - filectime($file) > $lifetime) unlink($file); } ?> <? if ($link): //header('Location: ' . $link); //exit(); ?> <html> <body> <button id="copy-button" data-clipboard-text="<?= $link; ?>" style="padding: 20px; margin: 50px auto; display: block;"><?= $link; ?></button> <script src="zc/ZeroClipboard.js"></script> <script type="text/javascript"> // main.js var client = new ZeroClipboard( document.getElementById("copy-button") ); client.on( "ready", function( readyEvent ) { client.on( "aftercopy", function( event ) { document.location.href = event.data["text/plain"]; }); }); </script> </body> </html> <? endif; ?> 



There was one tremendous nuance.
After renaming the file, the link in the clipboard will be a curve to the name encoder. I had to add a large button, which by browser means copies the new link to the image and opens it in the browser. But with this really somehow have to put up. The zeroclipboard library helped .

As a result, press Ctrl + PrtSc, select the desired area, we get in the browser a button to copy the links to the clipboard
image

And the perfect link to the screenshot without anything extra: www.grinkevich.by/_ss/files/9bf30316a61ee1f8caf078ebac1f7dda.png which will be deleted in 7 days. I hope someone else would benefit from such a decision.

Perhaps it will be ridiculous to someone, and to someone, it’s also quite sad from such perversions. But who needs it, and the program is a bit paid, and here too, who cares :)

Take care of your screenshots and everyone on Friday!

Source: https://habr.com/ru/post/233491/


All Articles