Ignore:
Timestamp:
Jan 7, 2011, 12:03:31 AM (13 years ago)
Author:
rub
Message:

Server upload

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/FacebookPlug/Server/upload_photo.php

    r8425 r8483  
    2323require_once 'include/common.php';
    2424
    25 // Check argument
    26 !empty($_GET['filename']) or trigger_error('Missing argument!', E_USER_ERROR);
     25?>
     26<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
     27<html>
     28<head>
     29  <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
     30</head>
     31<body>
     32  <center>
     33    <div id="loading"><img src="./image/image_85486.gif" alt="Loading"></div>
     34    <div id="infos">
     35      <img src="./image/infos.png" alt="Infos">
     36      <a id ="info_a" href="" onclick="window.open(this.href); return false;">
     37        <img src="<?php echo addslashes($_GET['u']) ?>" alt="Image" style="height:50px">
     38      </a>
     39    </div>
     40    <div id="errors">
     41        <img src="./image/errors.png" alt="Error">
     42        <textearea id="error_result"></textearea>
     43    </div>
     44  </center>
     45 
     46  <script type="text/javascript">
     47    $(document).ready(function () {
     48      $("#errors").hide();
     49      $("#infos").hide();
     50      $.get(
     51      './do_upload_photo.php',
     52      {u:"<?php echo addslashes($_GET['u']) ?>", pu: "<?php echo addslashes($_GET['pu']) ?>", pt: "<?php echo addslashes($_GET['pt']) ?>", gt: "<?php echo addslashes($_GET['gt']) ?>"},
     53      function(data) {
     54        $("#loading").hide();
     55        is_ok = ! isNaN(data);
     56        if (is_ok)
     57        {
     58          div_id = "#infos";
     59          fb_photo_page = 'http://www.facebook.com/photo.php?fbid='+data;
     60          $('#info_a').attr('href', fb_photo_page);
     61        }
     62        else
     63        {
     64          div_id = "#errors";
     65          $('#error_result').html(data);
     66        }
     67        $(div_id).show();
     68        $(div_id).fadeOut(3000, function ()
     69          {
     70            if (is_ok) { window.open(fb_photo_page); }
     71            window.close();
     72          });
     73      });
     74  });
     75  </script>
     76<!-- google-analytics -->
     77<script type="text/javascript">
     78  var _gaq = _gaq || [];
     79  _gaq.push(['_setAccount', 'UA-2272624-7']);
     80  _gaq.push(['_trackPageview']);
    2781
    28 /*try
    29 {
    30   //~ $fbme = null;
    31   $uid = $facebook->getUser();
    32   $fbme = $facebook->api('/me');
     82  (function() {
     83    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     84    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
     85    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     86  })();
    3387
    34   $param  =   array(
    35      'method'  => 'users.getinfo',
    36      //~ 'uids'       => $fbme['id'],
    37      'uids'       => $uid,
    38      'fields'     => 'name,current_location,profile_url',
    39      'callback'  => ''
    40   );
    41   $userInfo   =   $facebook->api($param);
    42   d($userInfo);
    43 }
    44 catch (FacebookApiException $e)
    45 {
    46   d($e);
    47 }*/
    48 
    49 fbp_mkdir($conf['local_upload_dir']);
    50 
    51   //~ try {
    52         //~ $statusUpdate = $facebook->api('/me/feed', 'post', array('message'=> $fbme['name'].' a mis à jour son status par Piwigo en test sur FB', 'cb' => ''));
    53         //~ echo "Status mis à jour";
    54   //~ } catch (FacebookApiException $e) {
    55         //~ d($e);
    56   //~ }
    57 
    58   //~ try {
    59         //~ $result = $facebook->api('/me/albums', 'post', array('name' => 'Piwigo', 'message'=> 'Test'));
    60         //~ d($result);
    61         //~ echo "Album créé";
    62   //~ } catch (FacebookApiException $e) {
    63         //~ d($e);
    64   //~ }
    65 
    66   $filename = $_GET['filename'];
    67   $local_filename = $conf['local_upload_dir'].'/'.basename($filename);
    68 
    69   @unlink($local_filename);
    70 
    71   @set_time_limit(0);
    72 
    73   //~ copy($filename, $local_filename);
    74   if ($handle = @fopen($local_filename, 'wb') and fbp_fetchRemote($filename, $handle))
    75   {
    76     fclose($handle);
    77   }
    78 
    79   if (is_file($local_filename))
    80   {
    81     try
    82     {
    83       $facebook->setFileUploadSupport(true);
    84       //~ $result = $facebook->api('/me/photos', 'post', array('source' => '@./tmp/_upload/'.basename($local_filename)));
    85       $result = $facebook->api('/me/photos', 'post', array('source' => '@'.$local_filename));
    86       //~ d($result);
    87       unlink($local_filename);
    88      }
    89      catch (FacebookApiException $e)
    90      {
    91       d($e);
    92      }
    93 
    94   }
    95   else
    96   {
    97     trigger_error('$filename not uploaded', E_USER_ERROR);
    98   }
    99 
    100   // check extension
    101   // changer le nom de l'image
    102 
    103 ?>
     88</script>
     89<!-- google-analytics -->
     90</body>
     91</html>
Note: See TracChangeset for help on using the changeset viewer.