From the developer of TagIt! Tagboard, DeadlySin3 dot Net brings to you ScrotIt! Screencapture! Written for Linux and similiar systems, ScrotIt! Screencapture requires SCROT to be installed on your system.
By : DeadlySin3
ScrotIt! Screencapture v0.1.A
Tested with:
PHP 4.3.10-16 (cli) (built: Aug 24 2005 20:25:01)
on Debian.Sarge v3.1
and
PHP 4.4.2-1+b1 (cli) (built: Mar 20 2006 03:48:19)
on Debian.Sid
Notes:
This is my first attempt at creating a php command line
interface to a program called "scrot".
Official Website: http://linuxbrit.co.uk/scrot/
Install using apt-get: # apt-get install scrot
scrot is required in order to run this script!
Description: command line screen capture utility
scrot (SCReen shOT) is a simple commandline screen capture
utility that uses imlib2 to grab and save images. Multiple
image formats are supported through imlib2's dynamic saver
modules.
Purpose:
I wrote this user interface for scrot to make taking a screen capture
and uploading it to your website as easy as possible. With a single
command on a shell, scrot captures an image and the php script I
wrote uploads the image via FTP to a remote host.
Command:
user@localhost:~$ php -f .take
Script Configuration:
Open inc.shot.php in an editor and set up the basics.
Drop all scripts in this download into your home
directory. ex. /home/paul/
Or whichever directory you choose. I reccomend not
keeping this program in a www accessible directory.
Rename ALL scripts:
inc.shot.php => .inc.shot
snapShot.php => .snapShot
upload.php => .upload
take.php => .take
The reason for this is simple. Hiding the script keeps
it out of view, for the most part, keeping your directory
"clean".
If you installed:
in your own home directory, you simply open a terminal
emulator (x-term, e-term, p-term, k-term, rxvt, etc)
and type the following:
php -f .take
anywhere else, type:
php -f /path/to/script/.take
(the "-f" option is optional - it may be omitted)
And you're done. In a moment, your desktop image will
be taken and uploaded!
UploadIt! is not meant as a web application. If you
manage to use it as one, do let me know!
e-mail: deadlysin3 at gmail dot com
Using "alias" to make this even easier!
user@localhost:~$ alias take='php -f .take'
Then simply type "take" on a shell.
TO DO:
------
I'm thinking about developing a way to allow users of your website to click a link, and have an online php script call home to your machine and execute the command to take and upload a screenshot. I'm not sure how I can do it but that's why I'm thinking about it! Feel free to send ideas and suggestions to : deadlysin3 at gmail dot com
-------
CODE
-------
<?php
#
#.inc.shot
#
### Directory on remote server to store image
$ftproot = "/public_html";
### Directory on localhost to store image
$srcroot = "/home/paul/public_html/shots";
### Name to save image as (*.jpg, *.jpeg, *.png) etc
$pic_name = "currentDesktop.jpeg";
$destination_file = "$ftproot/$pic_name";
$source_file = "$srcroot/$pic_name";
### Set up connection
$ftp_server = "ftp.site.net";
$ftp_user_name = "anonymous@localhost";
$ftp_user_pass = "";
$conn_id = ftp_connect($ftp_server);
?>
<?php
#
# .snapShot
#
### File information
require_once(".inc.shot");
$output = passthru("scrot '$pic_name' -e 'mv -u $pic_name $srcroot/'");
?>
<?php
#
# .take
#
### File information
require_once(".inc.shot");
system("php -f .snapShot");
require_once(".upload");
?>
<?php
#
# .upload
#
### File information
require_once(".inc.shot");
// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
// check connection
if ((!$conn_id) || (!$login_result)) {
echo "\r\n FTP connection has failed! \r\n";
echo "\r\n Attempted to connect to $ftp_server for user $ftp_user_name \r\n";
exit;
} else {
echo "\r\n Connected to $ftp_server. \r\n";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
// check upload status
if (!$upload) {
// close the FTP stream
ftp_close($conn_id);
$err=1;
echo "\r\n $conn_id status: closed \r\n";
echo "\r\n !! FTP upload has failed !! \r\n";
} else {
echo "\r\n Uploaded $source_file to $ftp_server \r\n";
}
// close the FTP stream
if(!$err) {
ftp_close($conn_id);
echo "\r\n $conn_id status: closed \r\n";
echo "\r\n $destination_file has completed! \r\n";
}
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More Miscellaneous Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
<a href="http://zeus.developershed.com/shonuff.php?blackbird=3853&zoneid=442&source=&dest=http%3A%2F%2Fwww.ibm.com%2Fdeveloperworks%2Fspaces%2Fjazz%3FS_TACT%3D105AGY31%26S_CMP%3DDEVSHED&ismap="><img src="http://images.devshed.com/corp/img/news/jazz01.gif" alt="developerWorks Jazz space" align="left"></a>You've heard the buzz about Jazz... want to know more about it from a developer's perspective? Check out the Jazz space on developerWorks. This space is an up-to-date resource for developers, including technical information about Jazz and products built on Jazz, like Rational Team Concert Express. The Jazz space includes content from a wide variety of sources, including links, feeds, and comments from experts. FREE! Go There Now!
|
|
|
|
Hear how IBM Rational Project and Portfolio Management integrated solutions help teams put the right tools and processes in place to maximize the effectiveness and efficiency of project teams and ensure that the business vision is being executed correctly. Learn how to automate and integrate requirements prioritization, top-down project planning, communications and controls, and methodology deployment to keep your scope, costs, and schedules under control. Tackle with an end-to-end approach the management of scope and scope changes, usage of methodology to control and empower project teams, and optimization of resources to align activity costs with the overall project plan. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development FREE! Go There Now!
|
|
|
|
CakePHP is a stable production-ready, rapid-development aid for building Web sites in PHP. This "Cook up Web sites fast with CakePHP" series shows you how to build an online product catalog using CakePHP. FREE! Go There Now!
|
|
|
|
Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
|
|
|
|
This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”. FREE! Go There Now!
|
|
|
|
Rational Build Forge Express Edition is an automation framework that packages the latest enterprise-grade technologies into a reliable, flexible and robust configuration designed and priced specifically for small to midsize businesses. The new Rational Build Forge Express eKit provides you with valuable resources – including a case study, podcast, demo, and articles – to help you increase staff productivity, compress development cycles and deliver better software, fast. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on November 29 at 1:00 pm ET to participate in an interactive discusssion with Grady Booch around architecture and reuse. Get your questions answered! FREE! Go There Now!
|
|
|
|
IBM Lotus Notes 8 provides a wide range of developers the ability to provide customized, integrated user interfaces via composite applications and via custom sidebar and toolbar plug-ins. This webcast provides you with tips and techniques to use with out-of-the-box capabilities of Lotus Notes 8, and survey how you can share useful components within your own company and within a larger community. FREE! Go There Now!
|
|
|
|
Join this webcast to learn how IBM Rational's Functional Testing solution enables you to implement automation your way, at your pace, with your existing staff. In this webcast, you’ll learn how you can eliminate redundancy of manual test scripts, reduce errors, and increase test coverage through test automation. After this presentation you will understand how IBM Rational Functional Testing solution can streamline your manual testing and make test automation easily attainable. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |