コード例 #1
0
ファイル: Parser.php プロジェクト: c4pone/pagespeed-parser
 /**
  * Returns a screenshot object
  *
  * @return Screenshot
  */
 public function getScreenshot()
 {
     $screenshot = new Screenshot();
     if ($this->get('screenshot', false) != false) {
         $screenshot->setData($this->get('screenshot.data', ''));
     }
     return $screenshot;
 }
コード例 #2
0
ファイル: Upload.php プロジェクト: trevorpao/f3cms
 static function takeScreenshot($uri)
 {
     $root = f3()->get('ROOT') . f3()->get('BASE');
     $path = "/upload/screenshot/" . date("Y/m") . "/";
     if (!file_exists($root . $path)) {
         mkdir($root . $path, 0777, true);
     }
     $filename = $path . substr(md5(uniqid(microtime(), 1)), 0, 15);
     $fp = fopen($root . $filename . ".png", 'w+b');
     $params = ['key' => f3()->get('screenshot_key'), 'size' => Screenshot::SIZE_F, 'url' => $uri, 'format' => Screenshot::PNG, 'timeout' => 1000];
     $ss = new Screenshot($params);
     $raw = $ss->saveScreen($fp);
     fclose($fp);
     return $filename . ".png";
 }
コード例 #3
0
 /**
  * Test running migration.
  *
  * @test
  */
 public function testTakeScreenshot()
 {
     // get events
     $screenshot = \Screenshot::take('http://www.twosuperior.co.uk');
     // has results
     $this->assertTrue((bool) $screenshot);
 }
コード例 #4
0
ファイル: update_app.php プロジェクト: WebApps4u/lwappstore
        $shots = $_FILES['shot'];
        $scr_target_dir = "../screenshots";
        $i = 1;
        foreach ($shots['error'] as $key => $error) {
            if ($error == UPLOAD_ERR_OK) {
                $tmp_name = $_FILES["shot"]["tmp_name"][$key];
                $name = basename($_FILES["shot"]["name"][$key]);
                $scr_id = $_POST['scr_id'][$i - 1];
                $ext = strrchr($name, ".");
                $dest_name = str_replace(" ", "", $apptitle) . "_" . $i . $ext;
                $i++;
                $destination = $scr_target_dir . "/" . $dest_name;
                chmod($tmp_name, 0777);
                //chmod($destination, 0777);
                if (move_uploaded_file($tmp_name, $destination)) {
                    $screenshot = new Screenshot();
                    $screenshot->id = $scr_id;
                    $screenshot->name = $dest_name;
                    $screenshot->app_id = $dis_app[0]->id;
                    $screenshot->update();
                    //
                } else {
                    echo "an error occured";
                    //header('Location: error.php');
                }
            }
        }
    }
    $session->setMessage("Your app has been updated.");
    header('Location: ../all_apps_listing.php');
} else {
コード例 #5
0
ファイル: main.php プロジェクト: 0xd34df00d/Qross
<?php

require_once 'screenshot.php';
$app = new QApplication($argc, $argv);
$screenshot = new Screenshot();
$screenshot->show();
$app->exec();
コード例 #6
0
ファイル: console.php プロジェクト: WebApps4u/lwappstore
 function uploadScreenshots($shots = "")
 {
     if (!empty($_POST['ajax'])) {
         $shots = $_FILES['shot'];
     }
     $app_id = $this->input->post('app_id');
     $title = str_replace(" ", "", $this->input->post('title')) != "" ? str_replace(" ", "", $this->input->post('title')) : NULL;
     if (!empty($shots)) {
         $i = 1;
         if (!empty($_POST['nushot'])) {
             $count = $this->screenshot->count_all("WHERE `app_id`={$app_id}");
             $i = $count['COUNT(*)'] + 1;
         }
         foreach ($shots['error'] as $key => $value) {
             if ($value == UPLOAD_ERR_OK) {
                 //continue
                 $tmp_name = $shots['tmp_name'][$key];
                 $name = basename($shots["name"][$key]);
                 $name = str_replace(" ", "", $name);
                 $ext = strtolower(strrchr($name, "."));
                 if ($ext != ".jpg" && $ext != ".jpeg" && $ext != ".png" && $ext != ".gif") {
                     $uploaded[] = "Invalid image format.";
                 } else {
                     //continue
                     if ($title != NULL) {
                         $dest_name = "scr_" . $title . "_" . $i . $ext;
                     } else {
                         $dest_name = "scr_" . $i . $ext;
                     }
                     $i++;
                     $destination = "screenshots/" . $dest_name;
                     if (move_uploaded_file($tmp_name, $destination)) {
                         $uploaded[] = $dest_name;
                         $screenshot = new Screenshot();
                         $screenshot->name = base_url() . $destination;
                         $screenshot->app_id = $app_id;
                         $screenshot->create();
                     }
                 }
             } else {
                 $uploaded[] = $this->useful->upload_errors[$value];
             }
         }
         if (!empty($_POST['ajax'])) {
             echo json_encode($uploaded);
         }
     }
 }