Пример #1
0
            //already set
        } elseif (isset($uploadmanager->exifdate)) {
            $smarty->assign('imagetaken', $uploadmanager->exifdate);
            //$smarty->assign('imagetakenmessage', ' ('.$uploadmanager->exifdate.' stated in exif header)');
        } else {
            $smarty->assign('imagetaken', '--');
        }
        if (isset($_SESSION['last_imagetaken'])) {
            $smarty->assign('last_imagetaken', $_SESSION['last_imagetaken']);
        }
        $smarty->assign('today_imagetaken', date("Y-m-d"));
    }
    //which step to display?
    $smarty->assign('step', $step);
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
        customExpiresHeader(3600, false, true);
    }
} elseif (!empty($_POST['rss'])) {
    $xh = new xmlHandler();
    $nodeNames = array("PHOTO:THUMBNAIL", "PHOTO:IMGSRC", "TITLE");
    $xh->setElementNames($nodeNames);
    $xh->setStartTag("ITEM");
    $xh->setVarsDefault();
    $xh->setXmlParser();
    $xh->setXmlData(stripslashes($_POST['rss']));
    $pData = $xh->xmlParse();
    $smarty->assign_by_ref('pData', array_slice($pData, 0, 10));
} else {
    $template = "puploader_login.tpl";
}
$smarty->display($template, $cacheid);
 function picasa_pre_upload()
 {
     global $serendipity;
     if (!serendipity_userLoggedIn()) {
         if (!serendipity_login()) {
             // save off the rss data because it won't be posted again
             if ($_POST['rss']) {
                 $_SESSION['picasa_rss'] = $_POST['rss'];
             }
             echo "<html>\n";
             echo "<head>\n";
             echo "<script language=javascript> function sf() { document.getElementById('serendipity[user]').focus(); }</script>\n";
             echo "</head>\n";
             echo "<body onload='javscript:sf()'>\n";
             echo "<form name='f' method='post' action='index.php?/plugin/picasa_pre_upload'>\n";
             echo "<h2>" . PLUGIN_EVENT_PICASA_UPLOAD_HEADER . $serendipity['baseURL'] . "</h2>\n";
             echo PLUGIN_EVENT_PICASA_UPLOAD_USERNAME . "<br />\n";
             echo "<input type='text' name='serendipity[user]' /><br />\n";
             echo PLUGIN_EVENT_PICASA_UPLOAD_PASSWORD . "<br />\n";
             echo "<input type='password' name='serendipity[pass]' /><br />\n";
             echo "<input id='autologin' type='checkbox' name='serendipity[auto]' /><label for='autologin'>" . PLUGIN_EVENT_PICASA_UPLOAD_REMEMBER_LOGIN . "</label><br />\n";
             echo "<input type='submit' name='submit' value='" . PLUGIN_EVENT_PICASA_UPLOAD_LOGIN . "' />";
             echo "<input type='button' value='" . PLUGIN_EVENT_PICASA_UPLOAD_DISCARD . "' onclick=\"location.href='minibrowser:close'\">\n";
             echo "</form>\n";
             echo "</body>\n";
             echo "</html>\n";
             return;
         }
     }
     if (!$_POST['rss']) {
         if (!$_SESSION['picasa_rss']) {
             echo PLUGIN_EVENT_PICASA_ERR_MISSING_RSS;
             return;
         } else {
             $rss = $_SESSION['picasa_rss'];
         }
     } else {
         $rss = $_POST['rss'];
     }
     $imgSize = $this->get_config('upload_image_size');
     $thumbSize = $serendipity['thumbSize'];
     $xh = new xmlHandler();
     $nodeNames = array("PHOTO:THUMBNAIL", "PHOTO:IMGSRC", "TITLE", "DESCRIPTION");
     $xh->setElementNames($nodeNames);
     $xh->setStartTag("ITEM");
     $xh->setXmlData($rss);
     $pData = $xh->xmlParse();
     // save this since we need to access the descriptions during upload
     $_SESSION['picasa_rss_parsed'] = $pData;
     echo "<html>\n";
     echo "<head>\n";
     echo "<script language=javascript> function sf() { document.getElementById('albumName').focus(); }</script>\n";
     echo "</head>\n";
     echo "<body onload='javscript:sf()'>\n";
     echo "<form name='f' method='post' action='index.php?/plugin/picasa_upload'>\n";
     echo "<h2>" . PLUGIN_EVENT_PICASA_UPLOAD_HEADER . $serendipity['baseURL'] . "</h2>\n";
     echo "<div>" . PLUGIN_EVENT_PICASA_UPLOAD_ALBUMNAME . "</div>\n";
     echo "<div><input type='text' name='albumName' tabindex='1'></div>\n";
     echo "<div>" . PLUGIN_EVENT_PICASA_UPLOAD_DESCRIPTION . "</div>\n";
     echo "<div><textarea name='albumDescription' rows='5' cols='50'></textarea></div>\n";
     echo "<div>" . PLUGIN_EVENT_PICASA_UPLOAD_PARENTDIR . "</div>\n";
     echo "<select name='parentDir' id='parentDir'>\n";
     echo "<option value=''>" . PLUGIN_EVENT_PICASA_UPLOAD_PARENTDIR_BASEDIR . "</option>\n";
     $picasapath = $this->get_config('picasapath');
     $paths = serendipity_traversePath($picasapath);
     $prunedPaths = array();
     foreach ($paths as $path) {
         $name = $path['name'];
         $relpath = $path['relpath'];
         // check if this is a subdirectory of an already pruned directory
         $subdirOfPruned = false;
         foreach ($prunedPaths as $prunedPath) {
             if (0 == strncmp($prunedPath, $relpath, strlen($prunedPath))) {
                 $subdirOfPruned = true;
                 break;
             }
         }
         // don't allow nesting of albums; if the album has any subdirectories, collisions could happen
         if (!file_exists($picasapath . '/' . $relpath . '/index.xml')) {
             if (!$subdirOfPruned) {
                 $splitPath = explode('/', $relpath);
                 $encodedRelpath = htmlentities($relpath, ENT_QUOTES, LANG_CHARSET);
                 $prefix = str_repeat('&nbsp;&nbsp;', count($splitPath));
                 echo "<option value='{$encodedRelpath}'>{$prefix} {$name}</option>\n";
             }
         } else {
             $prunedPaths[] = $relpath;
         }
     }
     echo "</select>\n";
     // Image request queue: add image requests for base image & clickthrough
     foreach ($pData as $e) {
         // use a thumbnail if you don't want exif (saves space)
         // thumbnail requests are clamped at 144 pixels
         // (negative values give square-cropped images)
         $small = $e['photo:thumbnail'] . "?size={$thumbSize}";
         $large = $e['photo:imgsrc'] . "?size={$imgSize}";
         echo "<input type='hidden' name='{$large}'>\n";
         echo "<input type='hidden' name='{$small}'>\n";
     }
     echo "<br />\n";
     echo "<input type=submit value='" . PLUGIN_EVENT_PICASA_UPLOAD_UPLOAD . "'>\n";
     echo "<input type=button value='" . PLUGIN_EVENT_PICASA_UPLOAD_DISCARD . "' onclick=\"location.href='minibrowser:close'\">\n";
     echo "</form><br />\n";
     // Preview "tray": draw thumbnails of each image that will be uploaded
     foreach ($pData as $e) {
         $thumb = $e['photo:thumbnail'];
         echo "<img src='{$thumb}?size={$thumbSize}'>\n";
     }
     echo "</body>\n";
     echo "</html>\n";
 }