Changeset 873


Ignore:
Timestamp:
Apr 1, 2015 4:55:43 PM (10 years ago)
Author:
dungnv
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pro-violet-viettel/www/deploy/api/platform/modules/space/actions/actions.class.php

    r861 r873  
    162162        return $item;
    163163    }
     164   
     165    private function createPreview($fileurl, $userId, $fileid) {
     166        $url = "https://docs.google.com/gview?url=" .urlencode($fileurl) . "";
     167        file_put_contents("1.html", $url);
     168        $content="";
     169        $ch = curl_init();
     170        curl_setopt($ch, CURLOPT_URL, $url);
     171        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
     172        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     173        $content = curl_exec($ch);
     174        file_put_contents("1.html", $content);
     175        preg_match("'img\?id\\\u003d(.*?)%3D'si", $content, $matches);
     176        $count=0;
     177        if (isset($matches[1]))
     178        {
     179                $id = $matches[1];
     180                $count=0;
     181                for ($i = 0; $i <= 20; $i++) {
     182                        $imgurl = "https://docs.google.com/viewerng/img?id=" . $id . "&w=600&page=" . $i;
     183                        $ch = curl_init();
     184                        curl_setopt($ch, CURLOPT_URL, $imgurl);
     185                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
     186                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     187                        $image = curl_exec($ch);
     188                        $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     189                        if ($code == 200)
     190                        {
     191   
     192                                $count++;
     193                                if (!file_exists('previews/'. $userId."/")) {
     194                                        mkdir('previews/'. $userId."/", 0777, true);
     195                                }
     196   
     197                                if (!file_exists('previews/'. $userId."/".$fileid."/")) {
     198   
     199                                        mkdir('previews/'. $userId."/".$fileid."/", 0777, true);
     200   
     201                                }
     202                                file_put_contents("previews/" . $userId . "/" . $fileid . "/" . $i . ".png", $image);
     203   
     204                        } else {
     205                                break;
     206                        }
     207                }
     208   
     209        }
     210        return $count;
     211    }   
     212   
    164213    public function executePreview(){
    165214        $fileId = $this->getRequestParameter('fileId');
     
    428477    }
    429478
    430     private function createPreview($fileurl, $userId, $fileid) {
    431 
    432        
    433         $url = "https://docs.google.com/gview?url=" .urlencode($fileurl) . "";
    434         file_put_contents("1.html", $url);
    435         $content="";
    436         $ch = curl_init();
    437         curl_setopt($ch, CURLOPT_URL, $url);
    438         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    439         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    440         $content = curl_exec($ch);
    441        file_put_contents("1.html", $content);
    442         preg_match("'img\?id\\\u003d(.*?)%3D'si", $content, $matches);
    443         $count=0;
    444         if (isset($matches[1]))
    445         {
    446         $id = $matches[1];
    447         $count=0;
    448         for ($i = 0; $i <= 20; $i++) {
    449             $imgurl = "https://docs.google.com/viewerng/img?id=" . $id . "&w=600&page=" . $i;
    450             $ch = curl_init();
    451             curl_setopt($ch, CURLOPT_URL, $imgurl);
    452             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
    453             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    454             $image = curl_exec($ch);
    455             $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    456             if ($code == 200)
    457             {
    458                
    459                 $count++;
    460                 if (!file_exists('previews/'. $userId."/")) {
    461                     mkdir('previews/'. $userId."/", 0777, true);
    462                 }
    463                
    464                 if (!file_exists('previews/'. $userId."/".$fileid."/")) {
    465                    
    466                     mkdir('previews/'. $userId."/".$fileid."/", 0777, true);
    467                    
    468                 }
    469                 file_put_contents("previews/" . $userId . "/" . $fileid . "/" . $i . ".png", $image);
    470 
    471             } else {
    472                 break;
    473             }
    474         }
    475        
    476         }
    477         return $count;
    478     }
    479 
    480479    public function executeSave() {
    481480        $content = file_get_contents('php://input');
     
    546545        return sfView::NONE;
    547546    }
     547   
    548548    public function executeGetFiles()
    549549    {
    550550       $tblfile = TblspacefilePeer::retrieveByPk(64);
    551551       print_r($tblfile);
    552       return sfView::NONE;
     552       return sfView::NONE;
    553553    }
    554554}
Note: See TracChangeset for help on using the changeset viewer.