-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
145 lines (141 loc) · 5.21 KB
/
example.php
File metadata and controls
145 lines (141 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
/**
* Flickr Photoblog Example
*
* Visit https://github.com/dbough/Flickr-Photoblog for the latest code.
*
* @author Dan Bough <daniel.bough at gmail.com> / http://www.danielbough.com
* @copyright Copyright (C) 2010-2013
*
*/
// Change path if needed.
include "Flickr_Photoblog.php";
$apiKey = ($_POST['apiKey']) ? $_POST['apiKey'] : NULL;
$userName = ($_POST['userName']) ? $_POST['userName'] : NULL;
$tags = ($_POST['tags']) ? $_POST['tags'] : NULL;
$title = ($_POST['title']) ? $_POST['title'] : NULL;
$outputPath = ($_POST['outputPath']) ? $_POST['outputPath'] : "/";
if ($apiKey && $userName && $tags & $title) {
$outputFile = $outputPath . "/photoblog.html";
$fb = new Flickr_Photoblog($apiKey, $userName, $tags);
$fb->postTitle = array($title, $_POST['hSize']);
if ($_POST['attrib']) {
$fb->attribution = true;
}
if ($_POST['fullHtml']) {
$fb->fullHtml = true;
}
if ($_POST['size']) {
$fb->maxSize = $_POST['size'];
}
$html = $fb->getHtml();
if ($html) {
$fh = fopen($outputFile, "w");
if ($fh) {
fwrite($fh, $html);
fclose($fh);
}
else {
$errorMsg = "Error opening " . $outputFile;
}
}
else {
$errorMsg .= $fb->error;
}
}
else {
$errorMsg = "<pre>";
$errorMsg .= "API Key, Username, Tags and Title Required!";
$errorMsg .= "</pre>";
}
if (file_exists($outputFile) && !$_POST) {
unlink($outputFile);
}
?>
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8' />
<title>Flickr Photoblog Example</title>
</head>
<body style="margin:0;padding:0;background:#f5f2f2;">
<div style="max-width:960px;margin:auto;padding:auto;">
<div style="text-align:center;">
<h1>Flickr Photoblog Example</h1>
<p>Flickr Photoblog allows you to easily create a blog post or webpage from photos on Flickr. <a href="https://github.com/dbough/Flickr-Photoblog">Get more info here.</a></p>
</div>
<div style="text-align:center;">
<?php
if ($errorMsg && $_POST) {
echo "<div style='background-color:yellow;'>";
echo "<pre>";
echo $errorMsg;
echo "</pre>";
echo "</div>";
}
if (file_exists($outputFile) && (filesize($outputFile) > 0)) {
echo "<a style='font-size:200%' href='" . $outputFile . "'>View your Photoblog!</a>";
}
?>
</div>
<div style="width:70%;margin:auto;padding:auto;">
<div style="float:left;">
<form method="post" action="example.php" >
<p title="Get your Flickr API key at http://www.flickr.com/services/api/misc.api_keys.html" style="cursor:help;">
API Key
<input type="password" placeholder="Flickr API Key" name="apiKey" size="40">
</p>
<p>
Username
<input type="text" placeholder="Flickr Username" name="userName" size="40">
</p>
<p style="cursor:help;" title="Comma separated list of search terms.">
Tags
<input type="text" placeholder="Flickr Tags" name="tags" size="40">
</p>
<p>
Post Title
<input type="text" placeholder="Post Title" name="title" size="40">
</p>
<p style="cursor:help;" title="Must be writable by the web server. Do not include outside slashes.">
Output Relative Path
<input type="text" placeholder="HTML Output Path" name="outputPath" size="40">
</p>
</div>
<div style="float:right;">
<p>
Attribution
<input type="checkbox" name="attrib"/>
</p>
<p>
Max Photo Size
<select name="size">
<option value="Original">Original</option>
<option value="Large">Large</option>
<option selected value="Medium">Medium</option>
<option value="Small">Small</option>
</select>
</p>
<p>
Title Size
<select name="hSize">
<option value="H1">H1</option>
<option value="H2">H2</option>
<option value="H3">H3</option>
</select>
</p>
<p>
Full HTML?
<input type="checkbox" name="fullHtml"/>
</p>
</div>
<div style="clear:both;"></div>
<p style='margin-top:30px;'>
<input type="submit" name="submit"/>
</p>
</form>
</div>
<br/>
</div>
</body>
</html>