Miscellaneous Code
  Home arrow Miscellaneous Code arrow ScrotIt! Screencapture
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Download TestComplete 
Forums Sitemap 
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS CODE

ScrotIt! Screencapture
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2006-04-02

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    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

     

    IBM® developerWorks developerWorks - FREE Tools!


    IBM – Taking Web 2.0 to Work

    You'll get answers to many questions and more from David Barnes, Lead Evangelist for IBM Emerging Internet Technologies. David will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve.
    FREE! Go There Now!


    NEW! Best practices for software analysis: An introduction to the IBM Rational Software Analyzer application

    This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer.
    FREE! Go There Now!


    NEW! Don't wait! Try the Rational Application Developer (RAD) v7.5 open beta code today

    Download the Rational Application Developer (RAD) v7.5 open beta code and start developing applications for the JEE5 standard which features EJB3.0, JPA, JSF 1.2, JSP 2.1 and Servlet 2.5 standards. When you use this beta you will see how you can increase developer productivity for already existing applications with improved support for refactoring, as well as adding new features to existing applications. In addition, the beta provides tooling for JD Edwards, Oracle, SAP, Siebel and PeopleSoft to improve the developer productivity with these enterprise systems.
    FREE! Go There Now!


    NEW! IBM Enterprise Modernization Sandbox for System z: Architecture

    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!


    NEW! Innovate don't duplicate! Asset reuse strategies for success

    Asset Reuse is a key strategy for companies looking to create innovative solutions to solve complex software development problems. Searching for, identifying, updating, using and deploying software assets can be a difficult challenge. Listen to this webcast, to learn about strategies and tools that you can leverage for a successful project, including Rational Asset Manager, Rational Software Architect and WebSphere Service Registry and Repository.
    FREE! Go There Now!


    NEW! Trial download: IBM Rational Performance Tester V7.0.1

    Get a free trial download of the latest version of IBM Rational Performance Tester V7.0.1, a load and performance testing solution for teams concerned about the scalability of their Web-based applications. Combining multiple ease-of-use features with granular detail, Rational Performance Tester simplifies the test-creation, load-generation and data-collection processes that help teams ensure the ability of their applications to accommodate required user loads.
    FREE! Go There Now!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes.
    FREE! Go There Now!


    NEW! Webcast: Eclipse: Empowering the universal platform

    The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now.
    FREE! Go There Now!


    NEW! Webcast: Extreme transaction processing with WebSphere Extended Deployment

    In this webcast, you'll get an introduction to the eXtreme Transaction Processing (XTP) features of WebSphere Extended Deployment and the common architectural traits required by XTP applications. See how WebSphere Extended Deployment's ObjectGrid feature provides a state-of-the-art infrastructure for hosting XTP applications.
    FREE! Go There Now!


    NEW! Webcast: What is new in Viper 2 for developers?

    Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    MISCELLANEOUS CODE ARTICLES

    - A Web App Based on a Model for the CodeIgnit...
    - Completing a Model for the CodeIgniter PHP F...
    - Validating Input Data with the CodeIgniter P...
    - Deleting Database Records with the CodeIgnit...
    - Inserting Database Records with a CodeIgnite...
    - Fetching Database Rows with a Model for the ...
    - Model Data and Validation Rules for a Generi...
    - Building a Generic Model for the CodeIgniter...
    - upload image to database sql
    - Random Password Generator
    - BCroot, get the root of a number with BC fun...
    - Find pi in a high precision
    - [PHP5] FORMCHECKER : data validation
    - SPL and ITERATOR : examples
    - Xml with Rss Feeds





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT