added license and readme

This commit is contained in:
Christian Haschek
2015-10-27 16:26:57 +01:00
parent 2806fd54c6
commit 5d924b3a0c
30 changed files with 3849 additions and 3645 deletions

202
LICENSE Normal file
View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
# pictshare
PictShare is an open source image hosting service with a simple resizing API

0
adapt.sh Normal file → Executable file
View File

38
backend.php Normal file → Executable file
View File

@@ -1,19 +1,19 @@
<?php <?php
session_start(); session_start();
define('DS', DIRECTORY_SEPARATOR); define('DS', DIRECTORY_SEPARATOR);
define('ROOT', dirname(__FILE__)); define('ROOT', dirname(__FILE__));
define('DOMAINPATH',(isset($_SERVER['HTTPS'])?'https':'http').'://'.$_SERVER['HTTP_HOST'].'/'); define('DOMAINPATH',(isset($_SERVER['HTTPS'])?'https':'http').'://'.$_SERVER['HTTP_HOST'].'/');
require_once (ROOT . DS . 'inc' . DS . 'core.php'); require_once (ROOT . DS . 'inc' . DS . 'core.php');
$pm = new PictshareModel(); $pm = new PictshareModel();
if($_GET['getimage']) if($_GET['getimage'])
{ {
$url = $_GET['getimage']; $url = $_GET['getimage'];
echo json_encode($pm->uploadImageFromURL($url)); echo json_encode($pm->uploadImageFromURL($url));
} }
else else
echo json_encode(array('status'=>'ERR')); echo json_encode(array('status'=>'ERR'));

4720
classes/easyphpthumbnail.php Normal file → Executable file

File diff suppressed because it is too large Load Diff

986
classes/html.php Normal file → Executable file
View File

@@ -1,494 +1,494 @@
<?php <?php
class HTML { class HTML {
private $js = array(); private $js = array();
function shortenUrls($data) { function shortenUrls($data) {
$data = preg_replace_callback('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', array(get_class($this), '_fetchTinyUrl'), $data); $data = preg_replace_callback('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', array(get_class($this), '_fetchTinyUrl'), $data);
return $data; return $data;
} }
private function _fetchTinyUrl($url) { private function _fetchTinyUrl($url) {
$ch = curl_init(); $ch = curl_init();
$timeout = 5; $timeout = 5;
curl_setopt($ch, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url=' . $url[0]); curl_setopt($ch, CURLOPT_URL, 'http://tinyurl.com/api-create.php?url=' . $url[0]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch); $data = curl_exec($ch);
curl_close($ch); curl_close($ch);
return '<a href="' . $data . '" target = "_blank" >' . $data . '</a>'; return '<a href="' . $data . '" target = "_blank" >' . $data . '</a>';
} }
function code($data,$class='markdown') function code($data,$class='markdown')
{ {
return '<pre><code class="'.$class.'">'.$data.'</code></pre>'; return '<pre><code class="'.$class.'">'.$data.'</code></pre>';
} }
function form($data,$submitvalue="Speichern",$action="",$submitname="submit") function form($data,$submitvalue="Speichern",$action="",$submitname="submit")
{ {
return '<form enctype="multipart/form-data" method="POST" onsubmit="doCheck();" action="'.$action.'">'.$data.'<br/><input type="submit" name="'.$submitname.'" value="'.$submitvalue.'" /> </form>'; return '<form enctype="multipart/form-data" method="POST" onsubmit="doCheck();" action="'.$action.'">'.$data.'<br/><input type="submit" name="'.$submitname.'" value="'.$submitvalue.'" /> </form>';
} }
function number($z,$nachkommastellen=0) function number($z,$nachkommastellen=0)
{ {
return number_format($z, $nachkommastellen, ',', '.'); return number_format($z, $nachkommastellen, ',', '.');
} }
function span($data,$id="",$class="",$zusatz="") function span($data,$id="",$class="",$zusatz="")
{ {
return '<span id="'.$id.'" class="'.$class.'" '.$zusatz.'>'.$data.'</span>'; return '<span id="'.$id.'" class="'.$class.'" '.$zusatz.'>'.$data.'</span>';
} }
function textarea($name,$data='',$cols=50,$rows=10,$forcewysiwyg=false) function textarea($name,$data='',$cols=50,$rows=10,$forcewysiwyg=false)
{ {
$cs = new CubeshopModel; $cs = new CubeshopModel;
if($_SESSION['user'] && ($cs->hasUserItem('bbcode') || $forcewysiwyg)) if($_SESSION['user'] && ($cs->hasUserItem('bbcode') || $forcewysiwyg))
$textarea = $this->getWYSIWYGEditor($name,$data); $textarea = $this->getWYSIWYGEditor($name,$data);
else $textarea = '<textarea name="'.$name.'" cols="'.$cols.'" rows="'.$rows.'">'.$data.'</textarea>'; else $textarea = '<textarea name="'.$name.'" cols="'.$cols.'" rows="'.$rows.'">'.$data.'</textarea>';
return $textarea; return $textarea;
} }
function center($data) function center($data)
{ {
return '<center>'.$data.'</center>'; return '<center>'.$data.'</center>';
} }
function displayError($e) function displayError($e)
{ {
$text = addslashes($this->error($e)); $text = addslashes($this->error($e));
return '<script>$(document).ready(function(){error("'.$text.'");});</script>'; return '<script>$(document).ready(function(){error("'.$text.'");});</script>';
} }
function displaySuccess($e) function displaySuccess($e)
{ {
$text = addslashes($this->success($e)); $text = addslashes($this->success($e));
return '<script>$(document).ready(function(){error("'.$text.'");});</script>'; return '<script>$(document).ready(function(){error("'.$text.'");});</script>';
} }
function clear() function clear()
{ {
return '<div class="clear"></div>'; return '<div class="clear"></div>';
} }
function menu($arr, $id = "", $class = "") function menu($arr, $id = "", $class = "")
{ {
aasort($arr, 'priority'); aasort($arr, 'priority');
$o = '<ul id="' . $id . '" class="' . $class . '">'; $o = '<ul id="' . $id . '" class="' . $class . '">';
foreach ($arr as $key => $val) foreach ($arr as $key => $val)
{ {
if ($val['active']) if ($val['active'])
$c = 'active'; $c = 'active';
else else
$c = ''; $c = '';
$o.= '<li class="menu_item" page="'.strtolower($key).'" id="page_' . strtolower($key) . '"><a href="' . DS . strtolower($key) . '" class="' . $c . ' '.$val['class'].'">' . $val['text'] . '</a></li>'; $o.= '<li class="menu_item" page="'.strtolower($key).'" id="page_' . strtolower($key) . '"><a href="' . DS . strtolower($key) . '" class="' . $c . ' '.$val['class'].'">' . $val['text'] . '</a></li>';
} }
$o.= '</ul>'; $o.= '</ul>';
return $o; return $o;
} }
function strong($text,$id = "", $class = "") function strong($text,$id = "", $class = "")
{ {
return '<strong class="'.$class.'" id="'.$id.'">'.$text.'</strong>'; return '<strong class="'.$class.'" id="'.$id.'">'.$text.'</strong>';
} }
function dfn($text,$desc,$id = "", $class = "") function dfn($text,$desc,$id = "", $class = "")
{ {
return '<dfn class="'.$class.'" id="'.$id.'" title="'.$desc.'">'.$text.'</dfn>'; return '<dfn class="'.$class.'" id="'.$id.'" title="'.$desc.'">'.$text.'</dfn>';
} }
function tip($text,$id = "", $class = "") function tip($text,$id = "", $class = "")
{ {
return '<span class="tip '.$class.'" id="'.$id.'">'.$text.'</span>'; return '<span class="tip '.$class.'" id="'.$id.'">'.$text.'</span>';
} }
function submenu($arr, $id = "", $class = "") { function submenu($arr, $id = "", $class = "") {
if (!is_array($arr)) if (!is_array($arr))
return false; return false;
$o = '<ul id="' . $id . '" class="' . $class . '">'; $o = '<ul id="' . $id . '" class="' . $class . '">';
foreach ($arr as $key => $val) { foreach ($arr as $key => $val) {
if ($val['active']) if ($val['active'])
$c = 'active'; $c = 'active';
else else
$c = ''; $c = '';
$o.= '<li id="sub_' . strtolower($val['action']) . '"><a href="' . DS . $val['base'] . DS . strtolower($val['action']) . '" class="' . $c . '">' . $val['text'] . '</a></li>'; $o.= '<li id="sub_' . strtolower($val['action']) . '"><a href="' . DS . $val['base'] . DS . strtolower($val['action']) . '" class="' . $c . '">' . $val['text'] . '</a></li>';
} }
$o.= '</ul>'; $o.= '</ul>';
return $o; return $o;
} }
/** /**
* $timestamp = zeitpunt des ablaufens in unix timestamp * $timestamp = zeitpunt des ablaufens in unix timestamp
*/ */
function countdown($timestamp,$prestring="",$id=0,$allownegative=false) function countdown($timestamp,$prestring="",$id=0,$allownegative=false)
{ {
$a = new Algorithms(); $a = new Algorithms();
if(!$id) $id = $a->getRandomHash(8); if(!$id) $id = $a->getRandomHash(8);
$seconds = $timestamp-time(); $seconds = $timestamp-time();
//return '<span id="'.$id.'"><script>countdown("#'.$id.'",'.$timestamp.',"'.$prestring.'",'.(time()*1000).',0);</script></span>'; //return '<span id="'.$id.'"><script>countdown("#'.$id.'",'.$timestamp.',"'.$prestring.'",'.(time()*1000).',0);</script></span>';
return '<span id="'.$id.'"><script>countdown("#'.$id.'","","'.$prestring.'",'.($seconds*1000).',"'.$allownegative.'");</script></span>'; return '<span id="'.$id.'"><script>countdown("#'.$id.'","","'.$prestring.'",'.($seconds*1000).',"'.$allownegative.'");</script></span>';
} }
function sanitize($data) function sanitize($data)
{ {
return mysql_real_escape_string($data); return mysql_real_escape_string($data);
} }
function specialchars($text,$utf8=0) function specialchars($text,$utf8=0)
{ {
return htmlspecialchars($text); return htmlspecialchars($text);
} }
/* /*
* @param string $name * @param string $name
* @param string $value * @param string $value
* @param string $type * @param string $type
* @param string $id * @param string $id
* @param string $class * @param string $class
* @param int $size * @param int $size
*/ */
function input($name, $value = '', $type = 'text', $id = '', $class = '', $size = '20',$onClick='',$extra='') function input($name, $value = '', $type = 'text', $id = '', $class = '', $size = '20',$onClick='',$extra='')
{ {
return '<input type="' . $type . '" onClick="'.$onClick.'" value="' . $value . '" class="' . $class . '" id="' . $id . '" name="' . $name . '" size="' . $size . '" '.$extra.' />'; return '<input type="' . $type . '" onClick="'.$onClick.'" value="' . $value . '" class="' . $class . '" id="' . $id . '" name="' . $name . '" size="' . $size . '" '.$extra.' />';
} }
function button($name,$value,$onclick="return true;",$id='',$class="button") function button($name,$value,$onclick="return true;",$id='',$class="button")
{ {
return '<input type="button" name="'.$name.'" value="'.$value.'" id="'.$id.'" class="'.$class.'" onClick="'.$onclick.'"/>'; return '<input type="button" name="'.$name.'" value="'.$value.'" id="'.$id.'" class="'.$class.'" onClick="'.$onclick.'"/>';
} }
function buttonGoTo($value,$link,$id='',$class='') function buttonGoTo($value,$link,$id='',$class='')
{ {
return '<a href="'.$link.'" id="'.$id.'" class="button '.$class.'">'.$value.'</a>'; return '<a href="'.$link.'" id="'.$id.'" class="button '.$class.'">'.$value.'</a>';
} }
/* /*
* @param array $data the multidimensional array * @param array $data the multidimensional array
* @param bool $header should the first line be a <th> element instead of <td>? * @param bool $header should the first line be a <th> element instead of <td>?
* @param string $width * @param string $width
* @param string $id the ID of the table * @param string $id the ID of the table
* @param string $class the class of the table * @param string $class the class of the table
* @param string $tdclass the class of every td element * @param string $tdclass the class of every td element
*/ */
function table($data, $header = 1, $width = '100%', $id = '', $class = '', $tdclass = 'text_top', $evenwidth=1,$trclass='') function table($data, $header = 1, $width = '100%', $id = '', $class = '', $tdclass = 'text_top', $evenwidth=1,$trclass='')
{ {
if (!is_array($data)) if (!is_array($data))
return false; return false;
$t = '<table width="' . $width . '" id="' . $id . '" class="' . $class . '">'; $t = '<table width="' . $width . '" id="' . $id . '" class="' . $class . '">';
foreach ($data as $key => $val) foreach ($data as $key => $val)
{ {
if ($key == 0 && $header) if ($key == 0 && $header)
$td = 'th'; else $td = 'th'; else
$td = 'td class="' . $tdclass . '"'; $td = 'td class="' . $tdclass . '"';
$t.='<tr class="'.$trclass.'">'; $t.='<tr class="'.$trclass.'">';
if($evenwidth) $w = floor(100/count($val)).'%'; if($evenwidth) $w = floor(100/count($val)).'%';
foreach ($val as $j => $tdata) foreach ($val as $j => $tdata)
{ {
if($evenwidth) $w = floor(100/count($val)).'%'; if($evenwidth) $w = floor(100/count($val)).'%';
else $w = 'auto'; else $w = 'auto';
if(is_array($tdata)) if(is_array($tdata))
{ {
$text = $tdata['text']; $text = $tdata['text'];
if($tdata['header']) $td = 'th'; if($tdata['header']) $td = 'th';
if($tdata['width']) $w=$tdata['width']; if($tdata['width']) $w=$tdata['width'];
if($tdata['class']) $tdclass .= ' '.$tdata['class']; if($tdata['class']) $tdclass .= ' '.$tdata['class'];
if($tdata['id']) $tid = $tdata['id']; if($tdata['id']) $tid = $tdata['id'];
if($tdata['colspan']) $colspan = 'colspan="'.$tdata['colspan'].'"'; if($tdata['colspan']) $colspan = 'colspan="'.$tdata['colspan'].'"';
$tdata = $text; $tdata = $text;
} }
$t.='<' . $td . ' '.$colspan.' width="'.$w.'" class="'.$tclass.'" id="'.$tid.'">' . $tdata . '</' . $td . '>'; $t.='<' . $td . ' '.$colspan.' width="'.$w.'" class="'.$tclass.'" id="'.$tid.'">' . $tdata . '</' . $td . '>';
$class=''; $class='';
$tid=''; $tid='';
$colspan=''; $colspan='';
} }
$t.='</tr>'; $t.='</tr>';
} }
$t.='</table>'; $t.='</table>';
return $t; return $t;
} }
/* /*
* @param $err is the error code equivalent of /config/errors.php * @param $err is the error code equivalent of /config/errors.php
* if $err is not numeric or not found in errors.php, its printed as text * if $err is not numeric or not found in errors.php, its printed as text
* @param $class is the html tag class * @param $class is the html tag class
*/ */
function error($err, $class = 'error',$backbutton=false) function error($err, $class = 'error',$backbutton=false)
{ {
global $error; global $error;
if (is_numeric($err) && $error[$err]) if (is_numeric($err) && $error[$err])
$err = $error[$err]; $err = $error[$err];
if($backbutton) if($backbutton)
$bb = '<br/><a href="#" onClick="history.back();return false;">Zurück..</a>'; $bb = '<br/><a href="#" onClick="history.back();return false;">Zurück..</a>';
return '<span class="' . $class . '">' . $err . '</span>'.$bb; return '<span class="' . $class . '">' . $err . '</span>'.$bb;
} }
function arrayToString($arr) function arrayToString($arr)
{ {
if(!is_array($arr)) return false; if(!is_array($arr)) return false;
foreach($arr as $a) foreach($arr as $a)
{ {
$o.=$a.';'; $o.=$a.';';
} }
$o = substr($o,0,-1); $o = substr($o,0,-1);
return $o; return $o;
} }
function success($msg, $class = 'success') function success($msg, $class = 'success')
{ {
return '<span class="' . $class . '">' . $msg . '</span>'; return '<span class="' . $class . '">' . $msg . '</span>';
} }
function goToLocation($location = '/', $force = true) { function goToLocation($location = '/', $force = true) {
$script = '<script>window.location.href="' . $location . '"</script>'; $script = '<script>window.location.href="' . $location . '"</script>';
if ($force) if ($force)
exit($script); exit($script);
else else
return $script; return $script;
} }
function link($text, $path, $prompt = null, $confirmMessage = "Bist du sicher?",$class="") function link($text, $path, $prompt = null, $confirmMessage = "Bist du sicher?",$class="")
{ {
$path = str_replace(' ', '-', $path); $path = str_replace(' ', '-', $path);
if ($prompt) { if ($prompt) {
$data = '<a class="'.$class.'" href="' . BASE_PATH . '/' . $path . '" onclick="return confirm(\'' . $confirmMessage . '\')">' . $text . '</a>'; $data = '<a class="'.$class.'" href="' . BASE_PATH . '/' . $path . '" onclick="return confirm(\'' . $confirmMessage . '\')">' . $text . '</a>';
} else { } else {
$data = '<a class="'.$class.'" href="' . BASE_PATH . '/' . $path . '">' . $text . '</a>'; $data = '<a class="'.$class.'" href="' . BASE_PATH . '/' . $path . '">' . $text . '</a>';
} }
return $data; return $data;
} }
function liste($lines,$ulid='') function liste($lines,$ulid='')
{ {
if(!is_array($lines)) return false; if(!is_array($lines)) return false;
$o = '<ul id="'.$ulid.'">'; $o = '<ul id="'.$ulid.'">';
foreach($lines as $line) foreach($lines as $line)
$o.='<li>'.$line.'</li>'; $o.='<li>'.$line.'</li>';
$o.= '</ul>'; $o.= '</ul>';
return $o; return $o;
} }
function getArrowRight() function getArrowRight()
{ {
return '<img src="/css/imgs/arrow_right.png" height="20px" /> '; return '<img src="/css/imgs/arrow_right.png" height="20px" /> ';
} }
function includeJs($fileName) { function includeJs($fileName) {
$data = '<script src="' . BASE_PATH . '/js/' . $fileName . '.js"></script>'; $data = '<script src="' . BASE_PATH . '/js/' . $fileName . '.js"></script>';
return $data; return $data;
} }
function includeCss($fileName) { function includeCss($fileName) {
$data = '<style href="' . BASE_PATH . '/css/' . $fileName . '.css"></script>'; $data = '<style href="' . BASE_PATH . '/css/' . $fileName . '.css"></script>';
return $data; return $data;
} }
function getInfoMessage($message,$text=false) function getInfoMessage($message,$text=false)
{ {
$message = str_replace('"', "'", $message); $message = str_replace('"', "'", $message);
$message = str_replace("'", "\'", $message); $message = str_replace("'", "\'", $message);
return '<img class="tooltip" title="'.(($message)).'" src="/css/imgs/info.png" />'; return '<img class="tooltip" title="'.(($message)).'" src="/css/imgs/info.png" />';
//return '<span onmouseover="Tip(\''.$message.'\')" onmouseout="UnTip()">'.($text?$text:'<img src="/css/imgs/info.png" />').'</span>'; //return '<span onmouseover="Tip(\''.$message.'\')" onmouseout="UnTip()">'.($text?$text:'<img src="/css/imgs/info.png" />').'</span>';
} }
function BBCode($Text) function BBCode($Text)
{ {
//$Text = utf8_encode($Text); //$Text = utf8_encode($Text);
// Replace any html brackets with HTML Entities to prevent executing HTML or script // Replace any html brackets with HTML Entities to prevent executing HTML or script
// Don't use strip_tags here because it breaks [url] search by replacing & with amp // Don't use strip_tags here because it breaks [url] search by replacing & with amp
$Text = str_replace("<", "&lt;", $Text); $Text = str_replace("<", "&lt;", $Text);
$Text = str_replace(">", "&gt;", $Text); $Text = str_replace(">", "&gt;", $Text);
// Convert new line chars to html <br /> tags // Convert new line chars to html <br /> tags
$Text = nl2br($Text); $Text = nl2br($Text);
// Set up the parameters for a URL search string // Set up the parameters for a URL search string
$URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'"; $URLSearchString = " a-zA-Z0-9\:\/\-\?\&\.\=\_\~\#\'";
// Set up the parameters for a MAIL search string // Set up the parameters for a MAIL search string
$MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@"; $MAILSearchString = $URLSearchString . " a-zA-Z0-9\.@";
// Perform URL Search // Perform URL Search
$Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href=\'$1\' target=\'_blank\'>$1</a>', $Text); $Text = preg_replace("/\[url\]([$URLSearchString]*)\[\/url\]/", '<a href=\'$1\' target=\'_blank\'>$1</a>', $Text);
$Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href=\'$1\' target=\'_blank\'>$2</a>', $Text); $Text = preg_replace("(\[url\=([$URLSearchString]*)\](.+?)\[/url\])", '<a href=\'$1\' target=\'_blank\'>$2</a>', $Text);
//$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text); //$Text = preg_replace("(\[url\=([$URLSearchString]*)\]([$URLSearchString]*)\[/url\])", '<a href="$1" target="_blank">$2</a>', $Text);
// Perform MAIL Search // Perform MAIL Search
$Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href=\'mailto:$1\'>$1</a>', $Text); $Text = preg_replace("(\[mail\]([$MAILSearchString]*)\[/mail\])", '<a href=\'mailto:$1\'>$1</a>', $Text);
$Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href=\'mailto:$1\'>$2</a>', $Text); $Text = preg_replace("/\[mail\=([$MAILSearchString]*)\](.+?)\[\/mail\]/", '<a href=\'mailto:$1\'>$2</a>', $Text);
// Check for bold text // Check for bold text
$Text = preg_replace("(\[b\](.+?)\[\/b])is",'<strong>$1</strong>',$Text); $Text = preg_replace("(\[b\](.+?)\[\/b])is",'<strong>$1</strong>',$Text);
// Check for H1-H3 // Check for H1-H3
$Text = preg_replace("(\[h1\](.+?)\[\/h1])is",'<h1>$1</h1>',$Text); $Text = preg_replace("(\[h1\](.+?)\[\/h1])is",'<h1>$1</h1>',$Text);
$Text = preg_replace("(\[h2\](.+?)\[\/h2])is",'<h2>$1</h2>',$Text); $Text = preg_replace("(\[h2\](.+?)\[\/h2])is",'<h2>$1</h2>',$Text);
$Text = preg_replace("(\[h3\](.+?)\[\/h3])is",'<h3>$1</h3>',$Text); $Text = preg_replace("(\[h3\](.+?)\[\/h3])is",'<h3>$1</h3>',$Text);
// Check for Italics text // Check for Italics text
$Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<em>$1</em>',$Text); $Text = preg_replace("(\[i\](.+?)\[\/i\])is",'<em>$1</em>',$Text);
// Check for Underline text // Check for Underline text
$Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span style=\'text-decoration: underline;\'>$1</span>',$Text); $Text = preg_replace("(\[u\](.+?)\[\/u\])is",'<span style=\'text-decoration: underline;\'>$1</span>',$Text);
// Check for strike-through text // Check for strike-through text
$Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span style=\'text-decoration: line-through;\'>$1</span>',$Text); $Text = preg_replace("(\[s\](.+?)\[\/s\])is",'<span style=\'text-decoration: line-through;\'>$1</span>',$Text);
// Check for over-line text // Check for over-line text
$Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span style=\'text-decoration: overline;\'>$1</span>',$Text); $Text = preg_replace("(\[o\](.+?)\[\/o\])is",'<span style=\'text-decoration: overline;\'>$1</span>',$Text);
// Check for colored text // Check for colored text
$Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style='color: $1'>$2</span>",$Text); $Text = preg_replace("(\[color=(.+?)\](.+?)\[\/color\])is","<span style='color: $1'>$2</span>",$Text);
// Check for sized text // Check for sized text
$Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style='font-size: $1px'>$2</span>",$Text); $Text = preg_replace("(\[size=(.+?)\](.+?)\[\/size\])is","<span style='font-size: $1px'>$2</span>",$Text);
// Check for list text // Check for list text
$Text = preg_replace("/\[ul\](.+?)\[\/ul\]/is", '<ul class=\'listbullet\'>$1</ul>' ,$Text); $Text = preg_replace("/\[ul\](.+?)\[\/ul\]/is", '<ul class=\'listbullet\'>$1</ul>' ,$Text);
$Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class=\'listbullet\'>$1</ul>' ,$Text); $Text = preg_replace("/\[list\](.+?)\[\/list\]/is", '<ul class=\'listbullet\'>$1</ul>' ,$Text);
$Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class=\'listdecimal\'>$1</ul>' ,$Text); $Text = preg_replace("/\[list=1\](.+?)\[\/list\]/is", '<ul class=\'listdecimal\'>$1</ul>' ,$Text);
$Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class=\'listlowerroman\'>$1</ul>' ,$Text); $Text = preg_replace("/\[list=i\](.+?)\[\/list\]/s", '<ul class=\'listlowerroman\'>$1</ul>' ,$Text);
$Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class=\'listupperroman\'>$1</ul>' ,$Text); $Text = preg_replace("/\[list=I\](.+?)\[\/list\]/s", '<ul class=\'listupperroman\'>$1</ul>' ,$Text);
$Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class=\'listloweralpha\'>$1</ul>' ,$Text); $Text = preg_replace("/\[list=a\](.+?)\[\/list\]/s", '<ul class=\'listloweralpha\'>$1</ul>' ,$Text);
$Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class=\'listupperalpha\'>$1</ul>' ,$Text); $Text = preg_replace("/\[list=A\](.+?)\[\/list\]/s", '<ul class=\'listupperalpha\'>$1</ul>' ,$Text);
$Text = str_replace("[*]", "<li>", $Text); $Text = str_replace("[*]", "<li>", $Text);
$Text = preg_replace("/\[li\](.+?)\[\/li\]/s", '<li>$1</li>' ,$Text); $Text = preg_replace("/\[li\](.+?)\[\/li\]/s", '<li>$1</li>' ,$Text);
// Check for font change text // Check for font change text
$Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style='font-family: $1;'>$2</span>",$Text); $Text = preg_replace("(\[font=(.+?)\](.+?)\[\/font\])","<span style='font-family: $1;'>$2</span>",$Text);
$Text = preg_replace("(\[code=(.+?)\](.+?)\[\/code])is","<pre>$1 code:<code class=\"$1\">$2</code></pre>",$Text); $Text = preg_replace("(\[code=(.+?)\](.+?)\[\/code])is","<pre>$1 code:<code class=\"$1\">$2</code></pre>",$Text);
$Text = preg_replace("(\[code\](.+?)\[\/code])is","<pre>Code:<code class=\"markdown\">$1</code></pre>",$Text); $Text = preg_replace("(\[code\](.+?)\[\/code])is","<pre>Code:<code class=\"markdown\">$1</code></pre>",$Text);
$Text = preg_replace("(\[spoiler](.+?)\[\/spoiler])is","<div class='spoiler'><input type='button' value='Spoiler anzeigen' onClick=\"$(this).parent().children('.spoiltext').fadeIn();\"/><div class='spoiltext markdown invisible'>$1</div></div>",$Text); $Text = preg_replace("(\[spoiler](.+?)\[\/spoiler])is","<div class='spoiler'><input type='button' value='Spoiler anzeigen' onClick=\"$(this).parent().children('.spoiltext').fadeIn();\"/><div class='spoiltext markdown invisible'>$1</div></div>",$Text);
//$Text = preg_replace("(\[b\](.+?)\[\/b])is",'<strong>$1</strong>',$Text); //$Text = preg_replace("(\[b\](.+?)\[\/b])is",'<strong>$1</strong>',$Text);
// // Declare the format for [code] layout // // Declare the format for [code] layout
// $CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"> // $CodeLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
// <tr> // <tr>
// <td class="quotecodeheader"> Code:</td> // <td class="quotecodeheader"> Code:</td>
// </tr> // </tr>
// <tr> // <tr>
// <td class="codebody">$1</td> // <td class="codebody">$1</td>
// </tr> // </tr>
// </table>'; // </table>';
// // Check for [code] text // // Check for [code] text
// $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text); // $Text = preg_replace("/\[code\](.+?)\[\/code\]/is","$CodeLayout", $Text);
// // Declare the format for [php] layout // // Declare the format for [php] layout
// $phpLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"> // $phpLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
// <tr> // <tr>
// <td class="quotecodeheader"> Code:</td> // <td class="quotecodeheader"> Code:</td>
// </tr> // </tr>
// <tr> // <tr>
// <td class="codebody">$1</td> // <td class="codebody">$1</td>
// </tr> // </tr>
// </table>'; // </table>';
// // Check for [php] text // // Check for [php] text
// $Text = preg_replace("/\[php\](.+?)\[\/php\]/is",$phpLayout, $Text); // $Text = preg_replace("/\[php\](.+?)\[\/php\]/is",$phpLayout, $Text);
// Declare the format for [quote] layout // Declare the format for [quote] layout
$QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0"> $QuoteLayout = '<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr> <tr>
<td class="quotecodeheader"> Quote:</td> <td class="quotecodeheader"> Quote:</td>
</tr> </tr>
<tr> <tr>
<td class="quotebody">$1</td> <td class="quotebody">$1</td>
</tr> </tr>
</table>'; </table>';
// Check for [quote] text // Check for [quote] text
$Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is", $this->tip('Zitat:')."<code>$1</code>", $Text); $Text = preg_replace("/\[quote\](.+?)\[\/quote\]/is", $this->tip('Zitat:')."<code>$1</code>", $Text);
$Text = preg_replace("(\[quote\=([$URLSearchString]*)\](.+?)\[/quote\])", $this->tip('Zitat von $1:')."<code>$2</code>", $Text); $Text = preg_replace("(\[quote\=([$URLSearchString]*)\](.+?)\[/quote\])", $this->tip('Zitat von $1:')."<code>$2</code>", $Text);
// Images // Images
// [img]pathtoimage[/img] // [img]pathtoimage[/img]
$Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src=\'$1\'>', $Text); $Text = preg_replace("/\[img\](.+?)\[\/img\]/", '<img src=\'$1\'>', $Text);
// [img=widthxheight]image source[/img] // [img=widthxheight]image source[/img]
$Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src=\'$3\' height=\'$2\' width=\'$1\'>', $Text); $Text = preg_replace("/\[img\=([0-9]*)x([0-9]*)\](.+?)\[\/img\]/", '<img src=\'$3\' height=\'$2\' width=\'$1\'>', $Text);
return $Text; return $Text;
} }
function getProgressBar($percent,$alternatetext="",$width='100%',$id="") function getProgressBar($percent,$alternatetext="",$width='100%',$id="")
{ {
if($percent<0)$percent = 0; if($percent<0)$percent = 0;
if($percent>100)$percent = 100; if($percent>100)$percent = 100;
if(!$alternatetext) $alternatetext = $percent.'%'; if(!$alternatetext) $alternatetext = $percent.'%';
return '<div width="'.$width.'" class="progressbar_wrapper"><strong style="color:black;float:left;margin-left:50%;margin-top:4px;">'.$alternatetext.'</strong> return '<div width="'.$width.'" class="progressbar_wrapper"><strong style="color:black;float:left;margin-left:50%;margin-top:4px;">'.$alternatetext.'</strong>
<div style="width:'.$percent.'%" class="progressbar_progress"></div> <div style="width:'.$percent.'%" class="progressbar_progress"></div>
</div>'; </div>';
} }
function getContentBox($content,$title='',$id='',$class='',$bid='',$collapse=true,$start=0) function getContentBox($content,$title='',$id='',$class='',$bid='',$collapse=true,$start=0)
{ {
$flip = $start?'flip':''; $flip = $start?'flip':'';
if($collapse) if($collapse)
$control = '<a class="contentbox_toggle right '.$flip.'" href="#" onClick="return false;"><img title="Aus/Einfahren" src="/css/imgs/contentBoxenArrow.png" class="flip" /></a>'; $control = '<a class="contentbox_toggle right '.$flip.'" href="#" onClick="return false;"><img title="Aus/Einfahren" src="/css/imgs/contentBoxenArrow.png" class="flip" /></a>';
if($start) if($start)
$invis = 'invisible'; $invis = 'invisible';
$o = '<div id="'.$bid.'" class="content_box '.$class.'"> $o = '<div id="'.$bid.'" class="content_box '.$class.'">
<div class="content_box_header">'.$control.$title.'</div> <div class="content_box_header">'.$control.$title.'</div>
<div id="'.$id.'" class="'.$invis.' content_box_content">'.$content.'</div> <div id="'.$id.'" class="'.$invis.' content_box_content">'.$content.'</div>
</div>'; </div>';
return $o; return $o;
} }
function div($data,$id='',$class='') function div($data,$id='',$class='')
{ {
return '<div id="'.$id.'" class="'.$class.'">'.$data.'</div>'; return '<div id="'.$id.'" class="'.$class.'">'.$data.'</div>';
} }
function select($name,$data=null,$selected=null,$id='') function select($name,$data=null,$selected=null,$id='')
{ {
$o = '<select id="'.$id.'" name="'.$name.'">'; $o = '<select id="'.$id.'" name="'.$name.'">';
if(is_array($data)) if(is_array($data))
foreach($data as $key=>$val) foreach($data as $key=>$val)
{ {
if($selected==$key) $sel = ' selected'; if($selected==$key) $sel = ' selected';
else $sel = ''; else $sel = '';
$o.='<option value="'.$key.'" '.$sel.'>'.$val.'</option>'; $o.='<option value="'.$key.'" '.$sel.'>'.$val.'</option>';
} }
$o.= '</select>'; $o.= '</select>';
return $o; return $o;
} }
/** /**
* <form onsubmit="doCheck();"> * <form onsubmit="doCheck();">
* @param type $name * @param type $name
* @param type $value * @param type $value
* @param type $height * @param type $height
* @return string * @return string
*/ */
function getWYSIWYGEditor($name,$value='',$height='150px') function getWYSIWYGEditor($name,$value='',$height='150px')
{ {
$o = '<div class="richeditor"> $o = '<div class="richeditor">
<div class="editbar"> <div class="editbar">
<button title="bold" onclick="doClick(\'bold\');" type="button"><b>B</b></button> <button title="bold" onclick="doClick(\'bold\');" type="button"><b>B</b></button>
<button title="italic" onclick="doClick(\'italic\');" type="button"><i>I</i></button> <button title="italic" onclick="doClick(\'italic\');" type="button"><i>I</i></button>
<button title="underline" onclick="doClick(\'underline\');" type="button"><u>U</u></button> <button title="underline" onclick="doClick(\'underline\');" type="button"><u>U</u></button>
<button title="hyperlink" onclick="doLink();" type="button" style="background-image:url(\'/css/imgs/url.gif\');"></button> <button title="hyperlink" onclick="doLink();" type="button" style="background-image:url(\'/css/imgs/url.gif\');"></button>
<button title="image" onclick="doImage();" type="button" style="background-image:url(\'/css/imgs/img.gif\');"></button> <button title="image" onclick="doImage();" type="button" style="background-image:url(\'/css/imgs/img.gif\');"></button>
<button title="list" onclick="doClick(\'InsertUnorderedList\');" type="button" style="background-image:url(\'/css/imgs/icon_list.gif\');"></button> <button title="list" onclick="doClick(\'InsertUnorderedList\');" type="button" style="background-image:url(\'/css/imgs/icon_list.gif\');"></button>
<button title="color" onclick="showColorGrid2(\'none\')" type="button" style="background-image:url(\'/css/imgs/colors.gif\');"></button><span id="colorpicker201" class="colorpicker201"></span> <button title="color" onclick="showColorGrid2(\'none\')" type="button" style="background-image:url(\'/css/imgs/colors.gif\');"></button><span id="colorpicker201" class="colorpicker201"></span>
<button title="quote" onclick="doQuote();" type="button" style="background-image:url(\'/css/imgs/icon_quote.png\');"></button> <button title="quote" onclick="doQuote();" type="button" style="background-image:url(\'/css/imgs/icon_quote.png\');"></button>
<button title="switch to source" type="button" onclick="javascript:SwitchEditor()" style="background-image:url(\'/css/imgs/icon_html.gif\');"></button> <button title="switch to source" type="button" onclick="javascript:SwitchEditor()" style="background-image:url(\'/css/imgs/icon_html.gif\');"></button>
</div> </div>
<div class="container"> <div class="container">
<textarea id="'.$name.'" name="'.$name.'" style="height:'.$height.';width:100%;">'.$value.'</textarea> <textarea id="'.$name.'" name="'.$name.'" style="height:'.$height.';width:100%;">'.$value.'</textarea>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
initEditor("'.$name.'", true); initEditor("'.$name.'", true);
</script>'; </script>';
return $o; return $o;
} }
} }

124
classes/image.php Normal file → Executable file
View File

@@ -1,63 +1,63 @@
<?php <?php
class Image class Image
{ {
function getImage($hash,$size=false) function getImage($hash,$size=false)
{ {
$path = ROOT.DS.'upload'.DS.$hash.DS; $path = ROOT.DS.'upload'.DS.$hash.DS;
$fullpath = ROOT.DS.'upload'.DS.$hash.DS.$hash; $fullpath = ROOT.DS.'upload'.DS.$hash.DS.$hash;
$pm = new PictshareModel(); $pm = new PictshareModel();
$type = $pm->isTypeAllowed($pm->getTypeOfFile($fullpath)); $type = $pm->isTypeAllowed($pm->getTypeOfFile($fullpath));
if(!$type) return false; if(!$type) return false;
if(is_array($size)) if(is_array($size))
{ {
$width = $size[0]; $width = $size[0];
$height = $size[1]; $height = $size[1];
} }
else if($size) else if($size)
{ {
$width = $size; $width = $size;
$height = $size; $height = $size;
} }
if($width && $height && $type!='gif') if($width && $height && $type!='gif')
$filename = $width.'x'.$height.'_'.$hash; $filename = $width.'x'.$height.'_'.$hash;
else else
$filename = $hash; $filename = $hash;
if(file_exists($path.$filename)) if(file_exists($path.$filename))
return '/'.$filename; return '/'.$filename;
$thumb = new easyphpthumbnail; $thumb = new easyphpthumbnail;
if($width==$height) if($width==$height)
$thumb -> Thumbsize = $width; $thumb -> Thumbsize = $width;
else else
{ {
$size = getimagesize($fullpath); $size = getimagesize($fullpath);
if(($width/$height)==($size[0]/$size[1])) if(($width/$height)==($size[0]/$size[1]))
{ {
$thumb -> Thumbwidth = $width; $thumb -> Thumbwidth = $width;
$thumb -> Thumbheight = $height; $thumb -> Thumbheight = $height;
} }
else if($width>$height) else if($width>$height)
$thumb -> Thumbsize = $height; $thumb -> Thumbsize = $height;
else else
$thumb -> Thumbsize = $width; $thumb -> Thumbsize = $width;
//$thumb -> Thumbwidth = $width; //$thumb -> Thumbwidth = $width;
//$thumb -> Thumbheight = $height; //$thumb -> Thumbheight = $height;
} }
$thumb -> Inflate = false; $thumb -> Inflate = false;
$thumb -> Thumblocation = $path; $thumb -> Thumblocation = $path;
//$thumb -> Thumbsaveas = $type; //$thumb -> Thumbsaveas = $type;
$thumb -> Thumbfilename = $filename; $thumb -> Thumbfilename = $filename;
$thumb -> Createthumb($fullpath,'file'); $thumb -> Createthumb($fullpath,'file');
//var_dump($thumb -> Thumblocation.$thumb -> Thumbfilename); //var_dump($thumb -> Thumblocation.$thumb -> Thumbfilename);
return '/'.$filename; return '/'.$filename;
} }
} }

46
classes/model.php Normal file → Executable file
View File

@@ -1,23 +1,23 @@
<?php <?php
/** /**
* Model class for all models * Model class for all models
* *
* @author Christian * @author Christian
*/ */
class Model// extends SQLQuery class Model// extends SQLQuery
{ {
protected $_model; protected $_model;
function __construct($id=0) function __construct($id=0)
{ {
$this->_model = substr(get_class($this),0,-5); $this->_model = substr(get_class($this),0,-5);
$this->_table = strtolower($this->_model); $this->_table = strtolower($this->_model);
$this->_id = $id; $this->_id = $id;
} }
function __destruct() function __destruct()
{ {
} }
} }

0
classes/simpleimage.php Normal file → Executable file
View File

0
css/imgs/Thumbs.db Normal file → Executable file
View File

0
css/imgs/bg.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 9.2 KiB

0
css/imgs/content.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

0
css/imgs/footer.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

0
css/imgs/header.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

0
css/imgs/header_empty.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

0
css/imgs/header_logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

0
css/imgs/hs_logo.png Normal file → Executable file
View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

0
css/main.css Normal file → Executable file
View File

0
css/normalize.css vendored Normal file → Executable file
View File

0
css/pictshare.css Normal file → Executable file
View File

328
inc/core.php Normal file → Executable file
View File

@@ -1,165 +1,165 @@
<?php <?php
function __autoload($className) function __autoload($className)
{ {
if (file_exists(ROOT . DS . 'models' . DS . strtolower($className) . '.php')) if (file_exists(ROOT . DS . 'models' . DS . strtolower($className) . '.php'))
require_once(ROOT . DS . 'models' . DS . strtolower($className) . '.php'); require_once(ROOT . DS . 'models' . DS . strtolower($className) . '.php');
if (file_exists(ROOT . DS . 'classes' . DS . strtolower($className) . '.php')) if (file_exists(ROOT . DS . 'classes' . DS . strtolower($className) . '.php'))
require_once(ROOT . DS . 'classes' . DS . strtolower($className) . '.php'); require_once(ROOT . DS . 'classes' . DS . strtolower($className) . '.php');
} }
function stripSlashesDeep($value) function stripSlashesDeep($value)
{ {
$value = is_array($value) ? array_map('stripSlashesDeep', $value) : stripslashes($value); $value = is_array($value) ? array_map('stripSlashesDeep', $value) : stripslashes($value);
return $value; return $value;
} }
function removeMagicQuotes() function removeMagicQuotes()
{ {
if ( get_magic_quotes_gpc() ) if ( get_magic_quotes_gpc() )
{ {
$_GET = stripSlashesDeep($_GET ); $_GET = stripSlashesDeep($_GET );
$_POST = stripSlashesDeep($_POST ); $_POST = stripSlashesDeep($_POST );
$_COOKIE = stripSlashesDeep($_COOKIE); $_COOKIE = stripSlashesDeep($_COOKIE);
} }
} }
function aasort (&$array, $key) function aasort (&$array, $key)
{ {
$sorter=array(); $sorter=array();
$ret=array(); $ret=array();
reset($array); reset($array);
foreach ($array as $ii => $va) { foreach ($array as $ii => $va) {
$sorter[$ii]=$va[$key]; $sorter[$ii]=$va[$key];
} }
asort($sorter); asort($sorter);
foreach ($sorter as $ii => $va) { foreach ($sorter as $ii => $va) {
$ret[$ii]=$array[$ii]; $ret[$ii]=$array[$ii];
} }
$array=$ret; $array=$ret;
} }
function callHook() function callHook()
{ {
global $url; global $url;
global $default; global $default;
$urlArray = explode("/",$url); $urlArray = explode("/",$url);
$pm = new PictshareModel(); $pm = new PictshareModel();
$u1 = preg_replace("/[^a-zA-Z0-9._]+/", "", $urlArray[0]); $u1 = preg_replace("/[^a-zA-Z0-9._]+/", "", $urlArray[0]);
$u2 = preg_replace("/[^a-zA-Z0-9._]+/", "", $urlArray[1]); $u2 = preg_replace("/[^a-zA-Z0-9._]+/", "", $urlArray[1]);
if(isImage($u1)) // render the image if(isImage($u1)) // render the image
renderImage($u1); renderImage($u1);
else if($u1=='store' || $u1=='originals') //render also with legacy urls else if($u1=='store' || $u1=='originals') //render also with legacy urls
renderImage($u2); renderImage($u2);
else if(isResizedImage($u1,$u2)) // resize and render else if(isResizedImage($u1,$u2)) // resize and render
renderResizedImage($u1,$u2); renderResizedImage($u1,$u2);
else if($u1=='thumbs') else if($u1=='thumbs')
renderLegacyResized($u2); renderLegacyResized($u2);
else if(!$u1) else if(!$u1)
{ {
if($_POST['submit']==$pm->translate(3)) if($_POST['submit']==$pm->translate(3))
$o=$pm->ProcessUploads(); $o=$pm->ProcessUploads();
else else
$o.= $pm->renderUploadForm(); $o.= $pm->renderUploadForm();
} }
else else
header("HTTP/1.0 404 Not Found"); header("HTTP/1.0 404 Not Found");
$vars['content'] = $o; $vars['content'] = $o;
$vars['slogan'] = $pm->translate(2); $vars['slogan'] = $pm->translate(2);
render($vars); render($vars);
} }
function renderLegacyResized($path) function renderLegacyResized($path)
{ {
$a = explode('_',$path); $a = explode('_',$path);
if(count($a)!=2) return false; if(count($a)!=2) return false;
$pm = new PictshareModel(); $pm = new PictshareModel();
$hash = $a[1]; $hash = $a[1];
$size = $a[0]; $size = $a[0];
if(!$pm->hashExists($hash)) return false; if(!$pm->hashExists($hash)) return false;
renderResizedImage($size,$hash); renderResizedImage($size,$hash);
} }
function renderImage($hash,$file=false) function renderImage($hash,$file=false)
{ {
$pm = new PictshareModel(); $pm = new PictshareModel();
if(!$file) $file = DS.$hash; if(!$file) $file = DS.$hash;
$path = ROOT.DS.'upload'.DS.$hash.$file; $path = ROOT.DS.'upload'.DS.$hash.$file;
$type = $pm->isTypeAllowed($pm->getTypeOfFile($path)); $type = $pm->isTypeAllowed($pm->getTypeOfFile($path));
if($pm->countResizedImages($hash)>MAX_RESIZED_IMAGES) //if the number of max resized images is reached, just show the real one if($pm->countResizedImages($hash)>MAX_RESIZED_IMAGES) //if the number of max resized images is reached, just show the real one
$path = ROOT.DS.'upload'.DS.$hash.DS.$hash; $path = ROOT.DS.'upload'.DS.$hash.DS.$hash;
switch($type) switch($type)
{ {
case 'jpg': case 'jpg':
header ("Content-type: image/jpeg"); header ("Content-type: image/jpeg");
$im = imagecreatefromjpeg($path); $im = imagecreatefromjpeg($path);
imagejpeg($im); imagejpeg($im);
break; break;
case 'png': case 'png':
header ("Content-type: image/png"); header ("Content-type: image/png");
$im = imagecreatefrompng($path); $im = imagecreatefrompng($path);
imagepng($im); imagepng($im);
break; break;
case 'gif': case 'gif':
header ("Content-type: image/gif"); header ("Content-type: image/gif");
$im = imagecreatefromgif($path); $im = imagecreatefromgif($path);
imagegif($im); imagegif($im);
break; break;
} }
exit(); exit();
} }
function renderResizedImage($size,$hash) function renderResizedImage($size,$hash)
{ {
$pm = new PictshareModel(); $pm = new PictshareModel();
$im = new Image(); $im = new Image();
if(is_numeric($size)) if(is_numeric($size))
$path = $im->getImage($hash,$size); $path = $im->getImage($hash,$size);
else else
$path = $im->getImage($hash,explode('x',$size)); $path = $im->getImage($hash,explode('x',$size));
renderImage($hash,$path); renderImage($hash,$path);
} }
function isImage($hash) function isImage($hash)
{ {
$pm = new PictshareModel(); $pm = new PictshareModel();
if(!$hash) return false; if(!$hash) return false;
return $pm->hashExists($hash); return $pm->hashExists($hash);
} }
function isResizedImage($resize,$hash) function isResizedImage($resize,$hash)
{ {
if(!isImage($hash) || !$resize || !$hash) return false; if(!isImage($hash) || !$resize || !$hash) return false;
$a = explode('x',$resize); $a = explode('x',$resize);
if(!is_numeric($resize) && count($a)!=2) return false; if(!is_numeric($resize) && count($a)!=2) return false;
return true; return true;
} }
function render($variables=null) function render($variables=null)
{ {
if(is_array($variables)) if(is_array($variables))
extract($variables); extract($variables);
include (ROOT . DS . 'template.php'); include (ROOT . DS . 'template.php');
} }

0
index.php Normal file → Executable file
View File

0
js/helper.js Normal file → Executable file
View File

0
js/jquery-2.1.0.min.js vendored Normal file → Executable file
View File

0
js/main.js Normal file → Executable file
View File

0
js/plugins.js Normal file → Executable file
View File

0
js/vendor/modernizr-2.6.2.min.js vendored Normal file → Executable file
View File

0
js/vendor/zepto.min.js vendored Normal file → Executable file
View File

964
models/pictsharemodel.php Normal file → Executable file
View File

@@ -1,482 +1,482 @@
<?php <?php
class PictshareModel extends Model class PictshareModel extends Model
{ {
function backend($params) function backend($params)
{ {
return array('status'=>'ok'); return array('status'=>'ok');
} }
function renderUploadForm() function renderUploadForm()
{ {
$maxfilesize = (int)(ini_get('upload_max_filesize')); $maxfilesize = (int)(ini_get('upload_max_filesize'));
return ' return '
<div class="clear"></div> <div class="clear"></div>
<strong>'.$this->translate(0).': '.$maxfilesize.'MB / File</strong><br> <strong>'.$this->translate(0).': '.$maxfilesize.'MB / File</strong><br>
<strong>'.$this->translate(1).'</strong> <strong>'.$this->translate(1).'</strong>
<br><br> <br><br>
<FORM enctype="multipart/form-data" method="post"> <FORM enctype="multipart/form-data" method="post">
<div id="formular"> <div id="formular">
<strong>'.$this->translate(4).': </strong><input class="input" type="file" name="pic[]" multiple><div class="clear"></div> <strong>'.$this->translate(4).': </strong><input class="input" type="file" name="pic[]" multiple><div class="clear"></div>
<div class="clear"></div><br> <div class="clear"></div><br>
</div> </div>
<INPUT style="font-size:15px;font-weight:bold;background-color:#74BDDE;padding:3px;" type="submit" id="submit" name="submit" value="'.$this->translate(3).'"> <INPUT style="font-size:15px;font-weight:bold;background-color:#74BDDE;padding:3px;" type="submit" id="submit" name="submit" value="'.$this->translate(3).'">
</FORM>'; </FORM>';
} }
function getNewHash($type,$length=10) function getNewHash($type,$length=10)
{ {
while(1) while(1)
{ {
$hash = substr(md5(time().$type.rand(1,1000000).microtime()),0,$length).'.'.$type; $hash = substr(md5(time().$type.rand(1,1000000).microtime()),0,$length).'.'.$type;
if(!$this->hashExists($hash)) return $hash; if(!$this->hashExists($hash)) return $hash;
} }
} }
function hashExists($hash) function hashExists($hash)
{ {
return is_dir(ROOT.DS.'upload'.DS.$hash); return is_dir(ROOT.DS.'upload'.DS.$hash);
} }
function countResizedImages($hash) function countResizedImages($hash)
{ {
$fi = new FilesystemIterator(ROOT.DS.'upload'.DS.$hash.DS, FilesystemIterator::SKIP_DOTS); $fi = new FilesystemIterator(ROOT.DS.'upload'.DS.$hash.DS, FilesystemIterator::SKIP_DOTS);
return iterator_count($fi); return iterator_count($fi);
} }
function getTypeOfFile($url) function getTypeOfFile($url)
{ {
$fi = new finfo(FILEINFO_MIME); $fi = new finfo(FILEINFO_MIME);
$type = $fi->buffer(file_get_contents($url)); $type = $fi->buffer(file_get_contents($url));
$arr = explode(';', trim($type)); $arr = explode(';', trim($type));
if(count($arr)>1) if(count($arr)>1)
{ {
$a2 = explode('/', $arr[0]); $a2 = explode('/', $arr[0]);
return $a2[1]; return $a2[1];
} }
$a2 = explode('/', $type); $a2 = explode('/', $type);
return $a2[1]; return $a2[1];
} }
function isTypeAllowed($type) function isTypeAllowed($type)
{ {
switch($type) switch($type)
{ {
case 'x-png': return 'png'; case 'x-png': return 'png';
case 'png': return 'png'; case 'png': return 'png';
case 'jpeg': return 'jpg'; case 'jpeg': return 'jpg';
case 'pjpeg': return 'jpg'; case 'pjpeg': return 'jpg';
case 'gif': return 'gif'; case 'gif': return 'gif';
default: return false; default: return false;
} }
} }
function uploadImageFromURL($url) function uploadImageFromURL($url)
{ {
$type = $this->getTypeOfFile($url); $type = $this->getTypeOfFile($url);
$type = $this->isTypeAllowed($type); $type = $this->isTypeAllowed($type);
if(!$type) if(!$type)
return array('status'=>'ERR','reason'=>'wrong filetype'); return array('status'=>'ERR','reason'=>'wrong filetype');
$hash = $this->getNewHash($type); $hash = $this->getNewHash($type);
mkdir(ROOT.DS.'upload'.DS.$hash); mkdir(ROOT.DS.'upload'.DS.$hash);
$file = ROOT.DS.'upload'.DS.$hash.DS.$hash; $file = ROOT.DS.'upload'.DS.$hash.DS.$hash;
$status = file_put_contents($file, file_get_contents($url)); $status = file_put_contents($file, file_get_contents($url));
//remove all exif data from jpeg //remove all exif data from jpeg
if($type=='jpg') if($type=='jpg')
{ {
$res = imagecreatefromjpeg($file); $res = imagecreatefromjpeg($file);
imagejpeg($res, $file, 100); imagejpeg($res, $file, 100);
} }
if(LOG_UPLOADER) if(LOG_UPLOADER)
{ {
$fh = fopen(ROOT.DS.'upload'.DS.'uploads.txt', 'a'); $fh = fopen(ROOT.DS.'upload'.DS.'uploads.txt', 'a');
fwrite($fh, time().';'.$url.';'.$hash.';'.$_SERVER['REMOTE_ADDR']."\n"); fwrite($fh, time().';'.$url.';'.$hash.';'.$_SERVER['REMOTE_ADDR']."\n");
fclose($fh); fclose($fh);
} }
return array('status'=>'OK','type'=>$type,'hash'=>$hash,'url'=>DOMAINPATH.$hash); return array('status'=>'OK','type'=>$type,'hash'=>$hash,'url'=>DOMAINPATH.$hash);
} }
function ProcessUploads() function ProcessUploads()
{ {
$im = new Image(); $im = new Image();
$i = 0; $i = 0;
foreach ($_FILES["pic"]["error"] as $key => $error) foreach ($_FILES["pic"]["error"] as $key => $error)
{ {
if ($error == UPLOAD_ERR_OK) if ($error == UPLOAD_ERR_OK)
{ {
$dup_id = $this->isDuplicate($_FILES["pic"]["tmp_name"][$key]); $dup_id = $this->isDuplicate($_FILES["pic"]["tmp_name"][$key]);
if(!$dup_id) if(!$dup_id)
{ {
$data = $this->uploadImageFromURL($_FILES["pic"]["tmp_name"][$key],false); $data = $this->uploadImageFromURL($_FILES["pic"]["tmp_name"][$key],false);
if($data['hash']) if($data['hash'])
$this->saveSHAOfFile($_FILES["pic"]["tmp_name"][$key],$data['hash']); $this->saveSHAOfFile($_FILES["pic"]["tmp_name"][$key],$data['hash']);
} }
else else
$data = array('hash'=>$dup_id,'status'=>'OK'); $data = array('hash'=>$dup_id,'status'=>'OK');
if($data['status']=='OK') if($data['status']=='OK')
{ {
$o.= '<h2>'.$this->translate(4).' '.++$i.'</h2><a target="_blank" href="'.DOMAINPATH.$data['hash'].'"><img src="'.DOMAINPATH.'300/'.$data['hash'].'" /></a><br/>'; $o.= '<h2>'.$this->translate(4).' '.++$i.'</h2><a target="_blank" href="'.DOMAINPATH.$data['hash'].'"><img src="'.DOMAINPATH.'300/'.$data['hash'].'" /></a><br/>';
} }
} }
} }
$html = new HTML(); $html = new HTML();
//if($i==1)$html->goToLocation('/i/info/'.$data['hash']); //if($i==1)$html->goToLocation('/i/info/'.$data['hash']);
return $o; return $o;
} }
function saveSHAOfFile($filepath,$hash) function saveSHAOfFile($filepath,$hash)
{ {
$sha_file = ROOT.DS.'upload'.DS.'hashes.csv'; $sha_file = ROOT.DS.'upload'.DS.'hashes.csv';
$sha = sha1_file($filepath); $sha = sha1_file($filepath);
$fp = fopen($sha_file,'a'); $fp = fopen($sha_file,'a');
fwrite($fp,"$sha;$hash\n"); fwrite($fp,"$sha;$hash\n");
fclose($fp); fclose($fp);
} }
function isDuplicate($file) function isDuplicate($file)
{ {
$sha_file = ROOT.DS.'upload'.DS.'hashes.csv'; $sha_file = ROOT.DS.'upload'.DS.'hashes.csv';
$sha = sha1_file($file); $sha = sha1_file($file);
if(!file_exists($sha_file)) return false; if(!file_exists($sha_file)) return false;
$fp = fopen($sha_file,'r'); $fp = fopen($sha_file,'r');
while (($line = fgets($fp)) !== false) while (($line = fgets($fp)) !== false)
{ {
$line = trim($line); $line = trim($line);
if(!$line) contine; if(!$line) contine;
$sha_upload = substr($line,0,40); $sha_upload = substr($line,0,40);
if($sha_upload==$sha) //when it's a duplicate return the hash of the original file if($sha_upload==$sha) //when it's a duplicate return the hash of the original file
{ {
fclose($fp); fclose($fp);
return substr($line,41); return substr($line,41);
} }
} }
fclose($fp); fclose($fp);
return false; return false;
} }
function GetPictureDimensions($bildname) function GetPictureDimensions($bildname)
{ {
$size = getimagesize($bildname); $size = getimagesize($bildname);
return $size; return $size;
} }
function translate($index,$params="") function translate($index,$params="")
{ {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
//$lang = 'en'; //$lang = 'en';
switch ($lang){ switch ($lang){
case "de": case "de":
$words[0] = 'Maximale Dateigröße'; $words[0] = 'Maximale Dateigröße';
$words[1] = 'Es können auch mehrere Bilder auf einmal ausgewählt werden!'; $words[1] = 'Es können auch mehrere Bilder auf einmal ausgewählt werden!';
$words[2] = 'einfach, gratis, genial'; $words[2] = 'einfach, gratis, genial';
$words[3] = 'Foto hinaufladen'; $words[3] = 'Foto hinaufladen';
$words[4] = 'Bild'; $words[4] = 'Bild';
$words[5] = 'Die Datei '.$params[0].' kann nicht hinaufgeladen werden, da der Dateityp "'.$params[1].'" nicht unterstützt wird.'; $words[5] = 'Die Datei '.$params[0].' kann nicht hinaufgeladen werden, da der Dateityp "'.$params[1].'" nicht unterstützt wird.';
$words[6] = 'Fehler beim Upload von '.$params; $words[6] = 'Fehler beim Upload von '.$params;
$words[7] = 'Bild "'.$params.'"" wurde erfolgreich hochgeladen'; $words[7] = 'Bild "'.$params.'"" wurde erfolgreich hochgeladen';
$words[8] = 'Skaliert auf'; $words[8] = 'Skaliert auf';
$words[9] = 'Kleinansicht'; $words[9] = 'Kleinansicht';
$words[10] = 'für Verlinkungen und Miniaturvorschau in Foren'; $words[10] = 'für Verlinkungen und Miniaturvorschau in Foren';
$words[11] = 'Allgemeiner Fehler'; $words[11] = 'Allgemeiner Fehler';
$words[12] = 'Fehler 404 - nicht gefunden'; $words[12] = 'Fehler 404 - nicht gefunden';
$words[13] = 'Fehler 403 - nicht erlaubt'; $words[13] = 'Fehler 403 - nicht erlaubt';
$words[14] = 'Kein refferer'; $words[14] = 'Kein refferer';
$words[15] = 'Verlinkte Seiten'; $words[15] = 'Verlinkte Seiten';
$words[16] = 'Hinweis: Zugriffe über pictshare.net werden nicht gerechnet'; $words[16] = 'Hinweis: Zugriffe über pictshare.net werden nicht gerechnet';
$words[17] = 'Dieses Bild wurde '.$params[0].' mal von '.$params[1].' verschiedenen IPs gesehen und hat '.$params[2].' Traffic verursacht'; $words[17] = 'Dieses Bild wurde '.$params[0].' mal von '.$params[1].' verschiedenen IPs gesehen und hat '.$params[2].' Traffic verursacht';
$words[18] = 'Dieses Bild wurde von folgenden Ländern aufgerufen: '; $words[18] = 'Dieses Bild wurde von folgenden Ländern aufgerufen: ';
$words[19] = $params[0].' Aufrufe aus '.$params[1]; $words[19] = $params[0].' Aufrufe aus '.$params[1];
break; break;
default: default:
$words[0] = 'Max filesize'; $words[0] = 'Max filesize';
$words[1] = 'You can select multiple pictures at once!'; $words[1] = 'You can select multiple pictures at once!';
$words[2] = 'easy, free, engenious'; $words[2] = 'easy, free, engenious';
$words[3] = 'Upload'; $words[3] = 'Upload';
$words[4] = 'Picture'; $words[4] = 'Picture';
$words[5] = 'The file '.$params[0].' can\'t be uploaded since the filetype "'.$params[1].'" is not supported.'; $words[5] = 'The file '.$params[0].' can\'t be uploaded since the filetype "'.$params[1].'" is not supported.';
$words[6] = 'Error uploading '.$params; $words[6] = 'Error uploading '.$params;
$words[7] = 'Picture "'.$params.'"" was uploaded successfully'; $words[7] = 'Picture "'.$params.'"" was uploaded successfully';
$words[8] = 'Scaled to'; $words[8] = 'Scaled to';
$words[9] = 'Thumbnail'; $words[9] = 'Thumbnail';
$words[10] = 'for pasting in Forums, etc..'; $words[10] = 'for pasting in Forums, etc..';
$words[11] = 'Unspecified error'; $words[11] = 'Unspecified error';
$words[12] = 'Error 404 - not found'; $words[12] = 'Error 404 - not found';
$words[13] = 'Error 403 - not allowed'; $words[13] = 'Error 403 - not allowed';
$words[14] = 'No referrer'; $words[14] = 'No referrer';
$words[15] = 'Linked sites'; $words[15] = 'Linked sites';
$words[16] = 'Note: Views from pictshare.net will not be counted'; $words[16] = 'Note: Views from pictshare.net will not be counted';
$words[17] = 'Was seen '.$params[0].' times by '.$params[1].' unique IPs and produced '.$params[2].' traffic'; $words[17] = 'Was seen '.$params[0].' times by '.$params[1].' unique IPs and produced '.$params[2].' traffic';
$words[18] = 'This picture was seen from the following countries: '; $words[18] = 'This picture was seen from the following countries: ';
$words[19] = $params[0].' views from '.$params[1]; $words[19] = $params[0].' views from '.$params[1];
} }
return $words[$index]; return $words[$index];
} }
function AddWatermark($bildname,$type) function AddWatermark($bildname,$type)
{ {
$watermark = imagecreatefrompng('inc/wasserzeichen.png'); $watermark = imagecreatefrompng('inc/wasserzeichen.png');
$watermark_width = imagesx($watermark); $watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark); $watermark_height = imagesy($watermark);
if($type=='image/png' ||$type == 'png') if($type=='image/png' ||$type == 'png')
$image = imagecreatefrompng($bildname); $image = imagecreatefrompng($bildname);
else if($type=='image/jpeg' ||$type == 'jpg') else if($type=='image/jpeg' ||$type == 'jpg')
$image = imagecreatefromjpeg($bildname); $image = imagecreatefromjpeg($bildname);
else if($type=='image/gif' ||$type == 'gif') else if($type=='image/gif' ||$type == 'gif')
$image = imagecreatefromgif($bildname); $image = imagecreatefromgif($bildname);
else exit("Dateityp nicht erkannt"); else exit("Dateityp nicht erkannt");
$size = getimagesize($bildname); $size = getimagesize($bildname);
$dest_x = $size[0] - $watermark_width - 5; $dest_x = $size[0] - $watermark_width - 5;
$dest_y = $size[1] - $watermark_height - 5; $dest_y = $size[1] - $watermark_height - 5;
imagesavealpha($watermark,true); imagesavealpha($watermark,true);
//imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100); //imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 100);
imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height); imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height);
//$black = imagecolorallocate($image, 0, 0, 0); //$black = imagecolorallocate($image, 0, 0, 0);
//imagecolortransparent($image, $black); //imagecolortransparent($image, $black);
imagesavealpha($image,true); imagesavealpha($image,true);
if($type=='image/png'|| $type == 'png') if($type=='image/png'|| $type == 'png')
imagepng($image,$bildname,5); imagepng($image,$bildname,5);
else if($type=='image/jpeg'|| $type == 'jpg') else if($type=='image/jpeg'|| $type == 'jpg')
imagejpeg($image,$bildname,100); imagejpeg($image,$bildname,100);
else if($type=='image/gif'|| $type == 'gif') else if($type=='image/gif'|| $type == 'gif')
imagegif($image,$bildname); imagegif($image,$bildname);
} }
function BildResize($filename,$max_hoehe,$max_breite,$output) function BildResize($filename,$max_hoehe,$max_breite,$output)
{ {
$image = new Imagick($filename); $image = new Imagick($filename);
$image->adaptiveResizeImage($max_hoehe,$max_breite); $image->adaptiveResizeImage($max_hoehe,$max_breite);
$im->imageWriteFile (fopen ($output, "wb")); $im->imageWriteFile (fopen ($output, "wb"));
return $output; return $output;
/////////////////////////// ///////////////////////////
// Set a maximum height and width // Set a maximum height and width
$width = $max_breite; $width = $max_breite;
$height = $max_hoehe; $height = $max_hoehe;
// Get new dimensions // Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename); list($width_orig, $height_orig) = getimagesize($filename);
$size = getimagesize($filename); $size = getimagesize($filename);
$ratio_orig = $width_orig/$height_orig; $ratio_orig = $width_orig/$height_orig;
if($width_orig < $width && $height_orig < $height) if($width_orig < $width && $height_orig < $height)
{ {
$width = $width_orig; $width = $width_orig;
$height = $height_orig; $height = $height_orig;
} }
else else
{ {
if ($width/$height > $ratio_orig) if ($width/$height > $ratio_orig)
$width = $height*$ratio_orig; $width = $height*$ratio_orig;
else else
$height = $width/$ratio_orig; $height = $width/$ratio_orig;
} }
// Resample // Resample
$image_p = imagecreatetruecolor($width, $height); $image_p = imagecreatetruecolor($width, $height);
if($size['mime']=='image/jpeg') if($size['mime']=='image/jpeg')
$image = imagecreatefromjpeg($filename); $image = imagecreatefromjpeg($filename);
else if($size['mime']=='image/png') else if($size['mime']=='image/png')
$image = imagecreatefrompng($filename); $image = imagecreatefrompng($filename);
else if($size['mime']=='image/gif') else if($size['mime']=='image/gif')
$image = imagecreatefromgif($filename); $image = imagecreatefromgif($filename);
else if($size['mime']=='image/bmp') else if($size['mime']=='image/bmp')
$image = imagecreatefromwbmp($filename); $image = imagecreatefromwbmp($filename);
else exit('Bildart nicht unterstützt'); else exit('Bildart nicht unterstützt');
imagesavealpha($image,true); imagesavealpha($image,true);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
// Output // Output
$file = $output; $file = $output;
imagesavealpha($image_p,true); imagesavealpha($image_p,true);
if($size['mime']=='image/jpeg') if($size['mime']=='image/jpeg')
imagejpeg($image_p, $file, 100); imagejpeg($image_p, $file, 100);
else if($size['mime']=='image/png') else if($size['mime']=='image/png')
imagepng($image_p, $file, 5); imagepng($image_p, $file, 5);
else if($size['mime']=='image/gif') else if($size['mime']=='image/gif')
imagegif($image_p, $file); imagegif($image_p, $file);
//else if($size['mime']=='image/bmp') //else if($size['mime']=='image/bmp')
//$image = imagecreatefromwbmp($filename); //$image = imagecreatefromwbmp($filename);
else exit('Bildart nicht unterstützt'); else exit('Bildart nicht unterstützt');
return $file; return $file;
} }
function getUniqueIPs($hash,$type) function getUniqueIPs($hash,$type)
{ {
$db = new SQLite3("pictures.db"); $db = new SQLite3("pictures.db");
$results = $db->query("SELECT DISTINCT(ip) FROM views WHERE hash = '$hash' OR hash = '$hash.$type'"); $results = $db->query("SELECT DISTINCT(ip) FROM views WHERE hash = '$hash' OR hash = '$hash.$type'");
$i = 0; $i = 0;
while ($row = $results->fetchArray()) while ($row = $results->fetchArray())
{ {
$i++; $i++;
} }
return $i; return $i;
} }
function renderGraphOfImage($hash,$type) function renderGraphOfImage($hash,$type)
{ {
$db = new SQLite3("pictures.db"); $db = new SQLite3("pictures.db");
$results = $db->query("SELECT * FROM views WHERE hash = '$hash' OR hash = '$hash.$type' ORDER BY time ASC"); $results = $db->query("SELECT * FROM views WHERE hash = '$hash' OR hash = '$hash.$type' ORDER BY time ASC");
$first = false; $first = false;
$count = 0; $count = 0;
while ($row = $results->fetchArray()) while ($row = $results->fetchArray())
{ {
$count++; $count++;
$index = floor(($row['time']+7200)/3600); $index = floor(($row['time']+7200)/3600);
if(!$first) if(!$first)
$first = $index; $first = $index;
$data[$index]++; $data[$index]++;
$ref = $row['referrer']; $ref = $row['referrer'];
if($ref=='-') if($ref=='-')
$a[2] = $this->translate(14); $a[2] = $this->translate(14);
else else
$a = explode('/', $ref); $a = explode('/', $ref);
$domains[$a[2]]++; $domains[$a[2]]++;
} }
if(!$count) return; if(!$count) return;
$lasttime = $first*3600; $lasttime = $first*3600;
foreach ($domains as $dom => $count) foreach ($domains as $dom => $count)
{ {
$doms[] = "['$dom', $count]"; $doms[] = "['$dom', $count]";
} }
$doms = implode(',', $doms); $doms = implode(',', $doms);
foreach($data as $time=>$count) foreach($data as $time=>$count)
{ {
$time *=3600; $time *=3600;
$difh = (($time-$lasttime)/3600)-1; $difh = (($time-$lasttime)/3600)-1;
if($difh>0) if($difh>0)
for($i=0;$i<$difh;$i++) for($i=0;$i<$difh;$i++)
$d[] = '['.(($lasttime+(($i+1)*3600))*1000).', 0]'; $d[] = '['.(($lasttime+(($i+1)*3600))*1000).', 0]';
$d[] = '['.($time*1000).', '.$count.']'; $d[] = '['.($time*1000).', '.$count.']';
$lasttime = $time; $lasttime = $time;
} }
array_pop($d); array_pop($d);
$d = implode(',', $d); $d = implode(',', $d);
$o = "$(function () { $o = "$(function () {
$('#container').highcharts({ $('#container').highcharts({
chart: { chart: {
zoomType: 'x', zoomType: 'x',
type: 'spline' type: 'spline'
}, },
title: { title: {
text: 'Views of this image compared to time' text: 'Views of this image compared to time'
}, },
xAxis: { xAxis: {
type: 'datetime', type: 'datetime',
maxZoom: 3600000, maxZoom: 3600000,
title: { title: {
text: null text: null
} }
}, },
yAxis: { yAxis: {
title: { title: {
text: 'Views / Hour' text: 'Views / Hour'
}, },
min: 0 min: 0
}, },
tooltip: { tooltip: {
crosshairs: true, crosshairs: true,
pointFormat: '<span style=\"color:{series.color}\">{series.name}</span>: <b>{point.y}</b><br/>', pointFormat: '<span style=\"color:{series.color}\">{series.name}</span>: <b>{point.y}</b><br/>',
}, },
plotOptions: { plotOptions: {
spline: { spline: {
lineWidth: 4, lineWidth: 4,
states: { states: {
hover: { hover: {
lineWidth: 5 lineWidth: 5
} }
}, },
marker: { marker: {
enabled: false enabled: false
} }
} }
}, },
legend: { legend: {
enabled: true enabled: true
}, },
series: [{ series: [{
name: 'Views', name: 'Views',
data: [$d] data: [$d]
}] }]
}); });
}); });
$(function () { $(function () {
var chart; var chart;
$(document).ready(function () { $(document).ready(function () {
// Build the chart // Build the chart
$('#pie').highcharts({ $('#pie').highcharts({
chart: { chart: {
plotBackgroundColor: null, plotBackgroundColor: null,
plotBorderWidth: null, plotBorderWidth: null,
plotShadow: false plotShadow: false
}, },
title: { title: {
text: 'Referring sites' text: 'Referring sites'
}, },
tooltip: { tooltip: {
pointFormat: '{series.name}: <b>{point.y} = {point.percentage:.2f}%</b>' pointFormat: '{series.name}: <b>{point.y} = {point.percentage:.2f}%</b>'
}, },
plotOptions: { plotOptions: {
pie: { pie: {
allowPointSelect: true, allowPointSelect: true,
cursor: 'pointer', cursor: 'pointer',
dataLabels: { dataLabels: {
enabled: false enabled: false
}, },
showInLegend: true showInLegend: true
} }
}, },
series: [{ series: [{
type: 'pie', type: 'pie',
name: '".$this->translate(15)."', name: '".$this->translate(15)."',
data: [ data: [
$doms $doms
] ]
}] }]
}); });
}); });
});"; });";
return $o; return $o;
} }
} }

84
template.php Normal file → Executable file
View File

@@ -1,42 +1,42 @@
<!DOCTYPE html> <!DOCTYPE html>
<!--[if IEMobile 7 ]> <html class="no-js iem7"> <![endif]--> <!--[if IEMobile 7 ]> <html class="no-js iem7"> <![endif]-->
<!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js"> <!--<![endif]--> <!--[if (gt IEMobile 7)|!(IEMobile)]><!--> <html class="no-js"> <!--<![endif]-->
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $title; ?></title> <title><?php echo $title; ?></title>
<meta name="description" content=""> <meta name="description" content="">
<meta name="HandheldFriendly" content="True"> <meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320"> <meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="cleartype" content="on"> <meta http-equiv="cleartype" content="on">
<?php echo $meta; ?> <?php echo $meta; ?>
<link rel="stylesheet" href="/css/normalize.css"> <link rel="stylesheet" href="/css/normalize.css">
<link rel="stylesheet" href="/css/pictshare.css"> <link rel="stylesheet" href="/css/pictshare.css">
<script src="/js/vendor/modernizr-2.6.2.min.js"></script> <script src="/js/vendor/modernizr-2.6.2.min.js"></script>
<!--<script src="/js/highslide-full.js"></script>--> <!--<script src="/js/highslide-full.js"></script>-->
<script type="text/javascript" src="/js/jquery-2.1.0.min.js"></script> <script type="text/javascript" src="/js/jquery-2.1.0.min.js"></script>
<TITLE>PictShare - Free picture hosting</TITLE> <TITLE>PictShare - Free picture hosting</TITLE>
<meta name="description" content="Free picture sharing, linking and tracking"> <meta name="description" content="Free picture sharing, linking and tracking">
<meta name="keywords" content="picture, share, hosting, free"> <meta name="keywords" content="picture, share, hosting, free">
<meta name="robots" content="index, follow"> <meta name="robots" content="index, follow">
<meta name="copyright" content="Haschek Solutions"> <meta name="copyright" content="Haschek Solutions">
<meta name="language" content="EN,DE"> <meta name="language" content="EN,DE">
<meta name="author" content="Haschek Solutions"> <meta name="author" content="Haschek Solutions">
<meta name="distribution" content="global"> <meta name="distribution" content="global">
<meta name="rating" content="general"> <meta name="rating" content="general">
</HEAD> </HEAD>
<BODY> <BODY>
<div class="mitte" id="overall"> <div class="mitte" id="overall">
<a href="/"><div id="header"> <a href="/"><div id="header">
<div style="padding:15px;"><div class="rechts"><?php echo $slogan; ?></div></div> <div style="padding:15px;"><div class="rechts"><?php echo $slogan; ?></div></div>
</div></a> </div></a>
<div id="content"> <div id="content">
<?php echo $content?> <?php echo $content?>
</div> </div>
<div class="content"><center>(c)<?php echo date("y");?> by<br/><a href="http://haschek-solutions.com" target="_blank"><img height="30" src="/css/imgs/hs_logo.png" /></a></center></div> <div class="content"><center>(c)<?php echo date("y");?> by<br/><a href="http://haschek-solutions.com" target="_blank"><img height="30" src="/css/imgs/hs_logo.png" /></a></center></div>
<div id="footer"></div> <div id="footer"></div>
</div> </div>
</BODY> </BODY>
</HTML> </HTML>