Просмотр исходного кода

actual initial commit

just looking to back this little project up
development
mauirixxx 8 лет назад
Сommit
024d6465c5
21 измененных файлов: 698 добавлений и 0 удалений
  1. +13
    -0
      LICENSE
  2. +11
    -0
      README.md
  3. +34
    -0
      collection.php
  4. +6
    -0
      connect.php
  5. +89
    -0
      edit.php
  6. +8
    -0
      footer.php
  7. +23
    -0
      header.php
  8. Двоичные данные
      images/no-image-available.jpg
  9. +75
    -0
      imageupload.php
  10. +11
    -0
      index.php
  11. +27
    -0
      list.php
  12. +37
    -0
      login.php
  13. +19
    -0
      logout.php
  14. +51
    -0
      newfunko.php
  15. +2
    -0
      register.php
  16. +63
    -0
      search.php
  17. +130
    -0
      smart_resize_image.function.php
  18. +3
    -0
      sql/db_popcollections_examples.sql
  19. +3
    -0
      sql/db_popimages_data.sql
  20. +41
    -0
      sql/db_structure_only.sql
  21. +52
    -0
      style.css

+ 13
- 0
LICENSE Просмотреть файл

@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 mauirixxx <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.

+ 11
- 0
README.md Просмотреть файл

@@ -0,0 +1,11 @@
# funkopopscollector
Yet another PHP based Funko Pop collection tracker, about as bare bones as you can get, but it's functional.

Basically you can add a new Funko Pop you own - it collects the Pop number, Pop name, Pop collection,
you can add/edit the date you bought the Pop, and add an image to it afterwards. You can edit/delete stored
pops, AND it's multi user friendly, so you and your family/friends can all use it to track their collection.

I know it's ugly, but it's highly functional, and searching works well, but the mobile version (ha!) needs
to be done/started/helped.

Just need PHP & MySQL/MariaDB and some know how to get this thing going. I forget how to add users :(

+ 34
- 0
collection.php Просмотреть файл

@@ -0,0 +1,34 @@
<?php
$pagetitle = "Add Collection";
include_once ('header.php');
if (isset($userid)){
echo '<BODY onLoad="document.fpcform.collection.focus()">';
$fpcname = (isset($_POST['collection']) ? $_POST['collection'] : null);
$fpcname = mysqli_real_escape_string($con, $fpcname);
$sqlfpcname = "INSERT INTO funkopops.popcollection (popcollection) VALUES ('$fpcname')";
if (!empty($fpcname)) {
if (!$result = $con->query($sqlfpcname)){
die ('There was an error running the query [' . $con->error . ']');
}
echo 'You have successfully entered ' . $fpcname . ' into the database!<BR />';
echo 'Refreshing page in 2 seconds to add another pop collection group.<BR />';
header("refresh:2;url=collection.php");
} else {
echo '<TABLE BORDER="0">';
echo '<FORM METHOD="POST" ACTION="collection.php" NAME="fpcform"><TR><TD>Collection Name: <INPUT TYPE="TEXT" NAME="collection" SIZE="25"></TD></TR>';
echo '<TR><TD><CENTER><INPUT TYPE="SUBMIT" VALUE="Add Group to Database"></CENTER></FORM></TD></TR></TABLE>';
echo '<BR />';
echo 'Here\'s the existing groups: <SELECT>';
$sqlgrouplist = "SELECT * FROM funkopops.popcollection ORDER BY popcollection ASC";
if (!$result = $con->query($sqlgrouplist)){
die ('There was an error running the query [' . $con->error . ']');
}
while ($row = $result->fetch_array()){
$groupname = $row['popcollection'];
echo '<OPTION VALUE="' . $groupname . '">' . $groupname . '</OPTION>';
}
echo '</SELECT><BR /><BR /> ';
}
}
include_once ('footer.php');
?>

+ 6
- 0
connect.php Просмотреть файл

@@ -0,0 +1,6 @@
<?php
define ("DATABASE_HOST", "localhost");
define ("DATABASE_USER", "change_me_user");
define ("DATABASE_PASS", "change_me_password");
define ("DATABASE_NAME", "change_me_FPC");
?>

+ 89
- 0
edit.php Просмотреть файл

@@ -0,0 +1,89 @@
<?php
$pagetitle = "Edit Funko Pop";
include_once ('header.php');
$editid = mysqli_real_escape_string($con, $_GET['id']);
$updatepop = (isset($_POST['update']) ? $_POST['update'] : null);
$updatepop = mysqli_real_escape_string($con, $updatepop);
if (isset($_SESSION['userid']) && ($_SESSION['username'])) {
if ($updatepop == "yes") {
$fid = mysqli_real_escape_string($con, $_POST['funkoid']);
$fuid = mysqli_real_escape_string($con, $_POST['userid']);
$fno = mysqli_real_escape_string($con, $_POST['popno']);
$fname = mysqli_real_escape_string($con, $_POST['popname']);
$fpcid = mysqli_real_escape_string($con, $_POST['popcollectionid']);
$fdate = mysqli_real_escape_string($con, $_POST['inserteddate']);
list ($y, $m, $d) = explode('-', $fdate);
if (!checkdate($m, $d, $y)) {
echo 'Date is invalid ' . $fdate . '<BR />';
echo 'Date format is YYYY-MM-DD / 1977-06-07<BR />';
echo 'Please click <A HREF="edit.php?id=' . $fid . '" CLASS="navlink">HERE</A> to try again';
include_once ('footer.php');
exit();
}
$sqlupdate = "UPDATE `pops` SET `popno` = $fno, `popname` = '$fname', `popcollectionid` = $fpcid, `inserteddate` = '$fdate' WHERE `funkoid` = $fid AND `userid` = $userid";
if (!$result = $con->query($sqlupdate)){
die ('There was an error running the query [' . $con->error . ']');
}
echo $fname . ' info successfully updated, returning to editor.';
header("refresh:2;url=edit.php?id=$fid");
include_once ('footer.php');
exit();
} else {
echo 'Editing data <BR />';
if (!$editid == "") {
$sqlfind = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `funkoid` = $editid AND `userid` = $userid";
if (!$result = $con->query($sqlfind)){
die ('There was an error running the query [' . $con->error . ']');
}
echo '<FORM METHOD="POST" ACTION="edit.php"><TABLE BORDER="1"><TR><TD>Pop No</TD><TD>Pop Name</TD><TD>Purchase Date</TD><TD>Pop Collection</TD></TR>';
while ($row = $result->fetch_array()){
$fid = $row['funkoid'];
$fuid = $row['userid'];
$fno = $row['popno'];
$fname = $row['popname'];
$fpcid = $row['popcollectionid'];
$fdate = $row['inserteddate'];
$fcollection = $row['popcollection'];
$_SESSION['popno'] = $fno;
$_SESSION['popname'] = $fname;
echo '<TR><TD><INPUT TYPE="HIDDEN" NAME="funkoid" VALUE="' . $fid . '"><INPUT TYPE="HIDDEN" NAME="userid" VALUE="' . $fuid . '">';
echo '<INPUT TYPE="NUMBER" NAME="popno" SIZE="4" MIN="1" MAX="9999" VALUE="' . $fno . '"></TD><TD><INPUT SIZE="75" TYPE="TEXT" NAME="popname" VALUE="' . $fname . '"></TD>';
echo '<TD><INPUT TYPE="DATE" NAME="inserteddate" VALUE="' . $fdate . '"></TD><TD><SELECT NAME="popcollectionid"><OPTION VALUE="' . $fpcid . '">' . $fcollection . '</OPTION>';
$sqlfpc = "SELECT * FROM popcollection ORDER BY popcollection ASC";
if (!$result2 = $con->query($sqlfpc)){
die ('There was an error running the query [' . $con->error . ']');
}
while ($row2 = $result2->fetch_array()){
$fpcid2 = $row2['popcollectionid'];
$fcollection2 = $row2['popcollection'];
echo '<OPTION VALUE="' . $fpcid2 . '">' . $fcollection2 . '</OPTION>';
}
echo '</SELECT></TD></TR>';
}
echo '</TABLE>';
echo '<INPUT TYPE="HIDDEN" NAME="update" VALUE="yes">';
echo '<INPUT TYPE="SUBMIT" VALUE="Update Funko Pop"></FORM><BR />';
$sqlimage = "SELECT popimages.imageid, popimages.imagepath FROM popimages WHERE popimages.funkoid = $fid AND popimages.userid = $fuid";
if (!$result3 = $con->query($sqlimage)){
die ('There was an error running the query [' . $con->error . ']');
}
if (mysqli_num_rows($result3) == 1) {
$row3 = mysqli_fetch_array($result3);
echo '<IMG SRC="images/' . $row3['imagepath'] . '" ALT="' . $fname . '"><BR />';
$_SESSION['imageid'] = $row3['imageid'];
$_SESSION['imagepath'] = $row3['imagepath'];
$_SESSION['image'] = "existing";
} else {
echo '<IMG SRC="images/no-image-available.jpg">';
$_SESSION['image'] = "default";
}
echo '<FORM METHOD="POST" ACTION="imageupload.php"><input type="hidden" name="uploadyn" value="change"><INPUT TYPE="HIDDEN" NAME="funkoid" VALUE="' . $fid . '">';
echo '<INPUT TYPE="SUBMIT" VALUE="Change Image"></FORM><BR /><BR />';
} else {
echo 'Please select a Funko Pop to edit!';
}
}
echo 'Retun to <A HREF="list.php" CLASS="navlink">Funko Pop list</A><BR />';
}
include_once 'footer.php';
?>

+ 8
- 0
footer.php Просмотреть файл

@@ -0,0 +1,8 @@
</CENTER>
<?php
if (isset($_SESSION['userid']) && ($_SESSION['username'])) {
echo '<BR /><BR /><CENTER><FORM METHOD="POST" ACTION="logout.php"><INPUT TYPE="HIDDEN" NAME="logout"><INPUT TYPE="SUBMIT" VALUE="Logout"></FORM></CENTER>';
}
?>
</BODY>
</HTML>

+ 23
- 0
header.php Просмотреть файл

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="style.css">
<?php
session_start();
$uname = (isset($_SESSION['username']) ? $_SESSION['username'] : null);
$userid = (isset($_SESSION['userid']) ? $_SESSION['userid'] : null);
include_once ('connect.php');
$con = @new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);
if ($con->connect_errno){
die ('Unable to connect to database [' . $db->connect_errno . ']');
}
if (!$userid){
echo '<TITLE>Please login first</TITLE></HEAD><BODY>';
echo '<CENTER><FORM ACTION="login.php" METHOD="POST">Username:<INPUT TYPE="TEXT" NAME="username" SIZE="20"><BR />';
echo 'Password:<INPUT TYPE="PASSWORD" NAME="password" SIZE="20"><BR />';
echo '<INPUT TYPE="SUBMIT" VALUE="Login ..."></FORM></CENTER>';
} else {
echo '<TITLE>' . $pagetitle . '</TITLE></HEAD><BODY><CENTER>';
echo '(<A HREF="index.php" CLASS="navlink">Home</A>) (<A HREF="search.php" CLASS="navlink">SEARCH</A>) (<A HREF="logout.php?action=logout" CLASS="navlink">Logout ' . $uname . '</A>)<HR><BR / >';
}
?>

Двоичные данные
images/no-image-available.jpg Просмотреть файл

До После
Ширина: 300  |  Высота: 300  |  Размер: 11 KiB

+ 75
- 0
imageupload.php Просмотреть файл

@@ -0,0 +1,75 @@
<?php
$pagetitle = "Image Uploader";
include_once ('header.php');
include_once ('smart_resize_image.function.php');
$uploadedimage = mysqli_real_escape_string($con, $_POST['uploadyn']);
$funkoid = mysqli_real_escape_string($con, $_POST['funkoid']);
$imageid = $_SESSION['imageid'];
$uploadyn = $_SESSION['image'];
$remimage = $_SESSION['imagepath'];
#
# File name should be a combo of the time (so no 2 images are named the same),
# pop number, pop name, and username of uploader.
# For example: 1497650696_147_C2-B5_funkybeast808.jpg
#
if (isset($_SESSION['userid'])){
if ($uploadedimage == "default") {
extract($_POST);
$UploadedFileName = $_FILES['uploadedfile']['name'];
$extension = end(explode(".", $UploadedFileName));
if($UploadedFileName != '') {
$upload_directory = "images/"; //This is the folder which you created just now
$TargetPath=time()."_".$_SESSION['popno']."_".$_SESSION['popname']."_".$uname.".".$extension;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload_directory.$TargetPath)) {
$resized = $upload_directory.$TargetPath;
smart_resize_image ($upload_directory.$TargetPath, null, 230, 300, true, $resized, false, false, 100);
$insertfile = "INSERT INTO funkopops.popimages (funkoid, userid, imagepath) VALUES ($funkoid, $userid, '$TargetPath')";
if (!$addpath = $con->query($insertfile)) {
die ('There was an error running the query: [' . $con->error . ']');
}
}
}
echo 'You have successfully uploaded a new image.<BR />';
echo 'Redirecting back to editor.<BR />';
header("refresh:2;url=edit.php?id=$funkoid");
include_once ('footer.php');
exit();
} else if ($uploadedimage == "existing") {
extract($_POST);
$UploadedFileName = $_FILES['uploadedfile']['name'];
$extension = end(explode(".", $UploadedFileName));
if($UploadedFileName != '') {
$upload_directory = "images/"; //This is the folder which you created just now
$TargetPath=time()."_".$_SESSION['popno']."_".$_SESSION['popname']."_".$uname.".".$extension;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $upload_directory.$TargetPath)) {
$resized = $upload_directory.$TargetPath;
smart_resize_image ($upload_directory.$TargetPath, null, 250, 0, true, $resized, false, false, 100);
$insertfile = "UPDATE funkopops.popimages SET imagepath = ('$TargetPath') WHERE imageid = $imageid AND funkoid = $funkoid AND userid = $userid";
if (!$addpath = $con->query($insertfile)) {
die ('There was an error running the query: [' . $con->error . ']');
}
}
}
if (file_exists("images/$remimage")) {
unlink("images/$remimage");
} else {
echo 'Image ' . $remimage . ' was NOT deleted.<BR />';
}
echo 'You have successfully updated the image.<BR />';
echo 'Redirecting back to editor.<BR />';
header("refresh:2;url=edit.php?id=$funkoid");
include_once ('footer.php');
exit();
} else {
$fid = $funkoid;
echo '<form action="imageupload.php" method="post" enctype="multipart/form-data">';
echo 'Filename: <input type="hidden" name="funkoid" value="' . $fid . '">';
echo '<input type="hidden" name="uploadyn" value="' . $uploadyn . '">';
echo '<input type="file" name="uploadedfile"><br>';
echo '<input type="submit" value="Upload image"></form>';
}
} else {
echo 'Please login <A HREF="index.php" CLASS="navlink">HERE</A> before continuing.<BR />';
}
include_once ('footer.php');
?>

+ 11
- 0
index.php Просмотреть файл

@@ -0,0 +1,11 @@
<?php
$pagetitle = "Funko Pop Collection Database";
include_once ('header.php');
if (isset($_SESSION['userid'])){
echo 'Enter new Funko Pop <A HREF="newfunko.php" CLASS="navlink">here</A><BR /><BR />';
echo 'Search for existing Funko Pop <A HREF="search.php" CLASS="navlink">here</A><BR /><BR />';
echo 'List ALL Funko Pops <A HREF="list.php" CLASS="navlink">here</A><BR /><BR />';
echo 'Add a new Funko Pop group <A HREF="collection.php" CLASS="navlink">here</A><BR />';
}
include_once ('footer.php');
?>

+ 27
- 0
list.php Просмотреть файл

@@ -0,0 +1,27 @@
<?php
$pagetitle = "Funko Pop Complete List";
include_once ('header.php');
if (isset($_SESSION['userid'])){
$sql = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `userid` = $userid ORDER BY `popcollection`, `popno`, `inserteddate` ASC";
$sqlcount = "SELECT COUNT(*) FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `userid` = $userid";
if (!$result = $con->query($sql)){
die ('There was an error running the query [' . $con->error . ']');
}
$count = mysqli_query($con, $sqlcount);
$row3 = mysqli_fetch_array($count);
if ($row3[0] <> 1) {
echo 'You have <B>' . $row3[0] . '</B> Funko Pops!<BR />Click the Pop # to edit the data<BR />';
} else {
echo 'You have ' . $row3[0] . ' Funko Pop - go buy some more, it\s lonely!<BR />Click the Pop # to edit the data<BR />';
}
echo '<TABLE BORDER="0">';
echo '<TR><TD>Pop #</TD><TD>Pop Name</TD><TD>Date Added</TD><TD>Pop Collection</TD></TR>';
if (mysqli_num_rows($result) > 0) {
while ($row = $result->fetch_array()){
echo '<TR><TD><A HREF="edit.php?id=' . $row['funkoid'] . '">' . $row['popno'] . '</A></TD><TD>' . $row['popname'] . '</TD><TD>' . $row['inserteddate'] . '</TD><TD>' . $row['popcollection'] . '</TD></TR>';
}
}
echo '</TABLE>';
}
include_once ('footer.php');
?>

+ 37
- 0
login.php Просмотреть файл

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<HTML>
<HEAD>
<link rel="stylesheet" type="text/css" href="style.css">
<TITLE>Logging in</TITLE>
</HEAD>
<BODY>
<CENTER>
<?php
include_once ('connect.php');
$con = new mysqli(DATABASE_HOST, DATABASE_USER, DATABASE_PASS, DATABASE_NAME);
session_start();
$username = mysqli_real_escape_string($con, $_POST['username']);
$password = mysqli_real_escape_string($con, $_POST['password']);
$password = sha1($password);
if ($con->connect_errno > 0){
die ('Unable to connect to database [' . $db->connect_errno . ']');
}
$sqllogin = "SELECT * FROM users WHERE users.username = '$username' and passwd = '$password'";
if ($result = $con->query($sqllogin)){
$row_cnt = mysqli_num_rows($result);
if ($row_cnt > 0){
while ($row = $result->fetch_array()){
$uname = $row['username'];
$uid = $row['userid'];
$_SESSION['username'] = $uname;
$_SESSION['userid'] = $uid;
}
header("refresh:1;url=index.php");
echo 'You have successfully logged in ...<BR />Returning to index in a few seconds</CENTER>';
} else {
echo 'That was not a valid username or password!<BR /><BR />';
echo 'Please try again <A HREF="index.php" CLASS="navlink">here</A></CENTER>';
}
}
include_once ('footer.php');
?>

+ 19
- 0
logout.php Просмотреть файл

@@ -0,0 +1,19 @@
<?php
$pagetitle = "Logging Out";
include_once ('header.php');
$logout = $_GET['action'];
if ($logout == "logout"){
session_unset();
session_destroy();
header("refresh:2;url=index.php");
echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>';
} else if (isset($_POST['logout'])){
session_unset();
session_destroy();
header("refresh:2;url=index.php");
echo '<CENTER>You have been logged out ...<BR />Returning to login screen in a few seconds</CENTER>';
} else {
echo '<CENTER>Something went wrong, you haven\'t been logged out!<BR /><BR />Please click <A HREF="logout.php" CLASS="navlink">HERE</A> to try again</CENTER>';
}
include_once ('footer.php');
?>

+ 51
- 0
newfunko.php Просмотреть файл

@@ -0,0 +1,51 @@
<?php
$pagetitle = "Enter New Funko Pop";
include_once ('header.php');
//$insfunko = (isset($_POST['insertfunko']) ? $_POST['insertfunko'] : null);
$insfunko = mysqli_real_escape_string($con, $_POST['insertfunko']);
if (isset($_SESSION['userid'])){
echo '<BODY onLoad="document.funkodata.popno.focus()">';
if ($insfunko == 1){
$popno = mysqli_real_escape_string($con, $_POST['popno']);
$popname = mysqli_real_escape_string($con, $_POST['popname']);
$popdate = mysqli_real_escape_string($con, $_POST['todaysdate']);
$popcollectionid = mysqli_real_escape_string($con, $_POST['popcollectionid']);
list ($y, $m, $d) = explode('-', $popdate);
if (!checkdate($m, $d, $y)) {
echo 'Date is invalid ' . $popdate . '<BR />';
echo 'Date format is YYYY-MM-DD / 1977-06-07<BR />';
echo 'Please click <A HREF="newfunko.php" CLASS="navlink">HERE</A> to try again';
echo '<BR /><BR />Return to <A HREF="index.php" CLASS="navlink">home</A>.</CENTER></BODY></HTML>';
include_once ('footer.php');
exit();
}
$sqlfunkins = "INSERT INTO funkopops.pops (userid, popno, popname, popcollectionid, inserteddate) VALUES ($userid, $popno, '$popname', $popcollectionid, '$popdate')";
if (!$funkoinsert = $con->query($sqlfunkins)){
die ('There was an error running the query [' . $con->error . ']');
}
echo 'You have successfully entered ' . $popname . ' into the database!<BR />';
echo 'Refreshing page in 2 seconds to add another pop to your collection!<BR />';
header("refresh:2;url=newfunko.php");
} else {
echo '<TABLE BORDER="0">';
echo '<FORM METHOD="POST" ACTION="newfunko.php" NAME="funkodata"><TR><TD>Pop Number: <INPUT TYPE="NUMBER" NAME="popno" MIN="1" MAX="9999" SIZE="5"></TD></TR>';
echo '<TR><TD>Pop Name: <INPUT TYPE="TEXT" NAME="popname" SIZE="40"></TD></TR>';
$sqlpopcollection = "SELECT * FROM popcollection ORDER BY popcollection ASC";
if (!$results = $con->query($sqlpopcollection)){
die ('There was an error running the query [' . $con->error . ']');
}
echo '<TR><TD>Pop Collection: <SELECT NAME="popcollectionid">';
while ($row = $results->fetch_array()){
$pcid = $row['popcollectionid'];
$pcname = $row['popcollection'];
echo '<OPTION VALUE="' . $pcid . '">' . $pcname . '</OPTION>';
}
echo '</TD></TR>';
echo '<TR><TD>Date Purchased: <INPUT NAME="todaysdate" TYPE="DATE" PLACEHOLDER="1977-06-07" VALUE="' . date('Y-m-d') . '"></TD></TR>';
echo '<TR><TD><INPUT TYPE="HIDDEN" NAME="insertfunko" VALUE="1"><INPUT TYPE="SUBMIT" VALUE="Add Pop to Database"></FORM></TD></TR></TABLE>';
}
} else {
echo 'Please login <A HREF="index.php" CLASS="navlink">HERE</A> before continuing.';
}
include_once ('footer.php');
?>

+ 2
- 0
register.php Просмотреть файл

@@ -0,0 +1,2 @@
<?php
include_once 'connect.php';

+ 63
- 0
search.php Просмотреть файл

@@ -0,0 +1,63 @@
<?php
$pagetitle = "Funko Pop Search";
include_once ('header.php');
if (isset($_SESSION['userid']) && ($_SESSION['username'])) {
echo '<BODY onLoad="document.funkosearch.searchname.focus()">';
$searchtype = (isset($_POST['stype']) ? $_POST['stype'] : null);
$searchtype = mysqli_real_escape_string($con, $searchtype);
$searchname = (isset($_POST['searchname']) ? $_POST['searchname'] : null);
$searchname = mysqli_real_escape_string($con, $searchname);
$searchcollection = (isset($_POST['collectionid']) ? $_POST['collectionid'] : null);
$searchcollection = mysqli_real_escape_string($con, $searchcollection);
if (!empty($searchname) || !empty($searchcollection)) {
if ($searchtype == "name") {
$sqlsearch = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `popname` LIKE '%$searchname%' AND `userid` = $userid ORDER BY popcollection.popcollection, pops.popno ASC";
$sqlcount = "SELECT COUNT(*) as count FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `popname` LIKE '%$searchname%' AND `userid` = $userid";
} else if ($searchtype == "group") {
$sqlsearch = "SELECT * FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `pops`.`popcollectionid` = $searchcollection AND `userid` = $userid ORDER BY popno ASC";
$sqlcount = "SELECT COUNT(*) as count FROM (pops INNER JOIN popcollection ON pops.popcollectionid = popcollection.popcollectionid) WHERE `pops`.`popcollectionid` = $searchcollection AND `userid` = $userid";
} else {
echo 'No search type defined, please try again!';
include_once ('footer.php');
exit();
}
if (!$result = $con->query($sqlsearch)){
die ('There was an error running the query [' . $con->error . ']');
}
$count = mysqli_query($con, $sqlcount);
$row3 = mysqli_fetch_array($count);
if ($row3['count'] > 1) {
echo 'There are ' . $row3['count'] . ' Funko Pops in the search results<BR />Click the Pop # to edit the data<BR />';
} else {
echo 'There is ' . $row3['count'] . ' Funko Pop in the search results<BR />Click the Pop # to edit the data<BR />';
}
echo '<TABLE BORDER="0">';
echo '<TR><TD>Pop #</TD><TD>Pop Name</TD><TD>Date Added</TD><TD>Pop Collection</TD></TR>';
if (mysqli_num_rows($result) > 0) {
while ($row = $result->fetch_array()){
echo '<TR><TD><A HREF="edit.php?id=' . $row['funkoid'] . '">' . $row['popno'] . '</A></TD><TD>' . $row['popname'] . '</TD><TD>' . $row['inserteddate'] . '</TD><TD>' . $row['popcollection'] . '</TD></TR>';
}
} else {
echo 'No results found!<BR />';
}
echo '</TABLE><BR />Click <A HREF="search.php" CLASS="navlink">here</A> to search again.<BR />';
} else {
echo 'Please search for a Funko Pop name! <BR />';
echo '<FORM ACTION="search.php" METHOD="POST" NAME="funkosearch">Funko Pop name to search for: <INPUT TYPE="TEXT" NAME="searchname" SIZE="30"><BR /><BR />';
//echo 'Funko Pop number to search for: <INPUT TYPE="NUMBER" NAME="searchno" MIN="1" MAX="9999"><BR />';
echo '<INPUT TYPE="HIDDEN" NAME="stype" VALUE="name"><INPUT TYPE="SUBMIT" VALUE="Search for a Pop"></FORM><BR /><BR />';
$sqlfpc = "SELECT DISTINCT `popcollection`.`popcollectionid`, `popcollection`.`popcollection` FROM (popcollection INNER JOIN pops ON popcollection.popcollectionid = pops.popcollectionid) WHERE `pops`.`userid` = $userid ORDER BY popcollection.popcollection ASC";
if (!$result2 = $con->query($sqlfpc)){
die ('There was an error running the query [' . $con->error . ']');
}
echo 'Or find all Funko Pops by collection: <FORM ACTION="search.php" METHOD="POST"><SELECT NAME="collectionid">';
while ($row2 = $result2->fetch_array()){
$pcid = $row2['popcollectionid'];
$pcname = $row2['popcollection'];
echo '<OPTION VALUE="' . $pcid . '">' . $pcname . '</OPTION>';
}
echo '</SELECT><INPUT TYPE="HIDDEN" NAME="stype" VALUE="group"><INPUT TYPE="SUBMIT" VALUE="List group"></FORM>';
}
}
include_once ('footer.php');
?>

+ 130
- 0
smart_resize_image.function.php Просмотреть файл

@@ -0,0 +1,130 @@
<?php
/**
* easy image resize function
* @param $file - file name to resize
* @param $string - The image data, as a string
* @param $width - new image width
* @param $height - new image height
* @param $proportional - keep image proportional, default is no
* @param $output - name of the new file (include path if needed)
* @param $delete_original - if true the original image will be deleted
* @param $use_linux_commands - if set to true will use "rm" to delete the image, if false will use PHP unlink
* @param $quality - enter 1-100 (100 is best quality) default is 100
* @param $grayscale - if true, image will be grayscale (default is false)
* @return boolean|resource
*/
function smart_resize_image($file,
$string = null,
$width = 0,
$height = 0,
$proportional = false,
$output = 'file',
$delete_original = true,
$use_linux_commands = false,
$quality = 100,
$grayscale = false
) {
if ( $height <= 0 && $width <= 0 ) return false;
if ( $file === null && $string === null ) return false;

# Setting defaults and meta
$info = $file !== null ? getimagesize($file) : getimagesizefromstring($string);
$image = '';
$final_width = 0;
$final_height = 0;
list($width_old, $height_old) = $info;
$cropHeight = $cropWidth = 0;

# Calculating proportionality
if ($proportional) {
if ($width == 0) $factor = $height/$height_old;
elseif ($height == 0) $factor = $width/$width_old;
else $factor = min( $width / $width_old, $height / $height_old );

$final_width = round( $width_old * $factor );
$final_height = round( $height_old * $factor );
}
else {
$final_width = ( $width <= 0 ) ? $width_old : $width;
$final_height = ( $height <= 0 ) ? $height_old : $height;
$widthX = $width_old / $width;
$heightX = $height_old / $height;
$x = min($widthX, $heightX);
$cropWidth = ($width_old - $width * $x) / 2;
$cropHeight = ($height_old - $height * $x) / 2;
}

# Loading image to memory according to type
switch ( $info[2] ) {
case IMAGETYPE_JPEG: $file !== null ? $image = imagecreatefromjpeg($file) : $image = imagecreatefromstring($string); break;
case IMAGETYPE_GIF: $file !== null ? $image = imagecreatefromgif($file) : $image = imagecreatefromstring($string); break;
case IMAGETYPE_PNG: $file !== null ? $image = imagecreatefrompng($file) : $image = imagecreatefromstring($string); break;
default: return false;
}
# Making the image grayscale, if needed
if ($grayscale) {
imagefilter($image, IMG_FILTER_GRAYSCALE);
}
# This is the resizing/resampling/transparency-preserving magic
$image_resized = imagecreatetruecolor( $final_width, $final_height );
if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) {
$transparency = imagecolortransparent($image);
$palletsize = imagecolorstotal($image);

if ($transparency >= 0 && $transparency < $palletsize) {
$transparent_color = imagecolorsforindex($image, $transparency);
$transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
imagefill($image_resized, 0, 0, $transparency);
imagecolortransparent($image_resized, $transparency);
}
elseif ($info[2] == IMAGETYPE_PNG) {
imagealphablending($image_resized, false);
$color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127);
imagefill($image_resized, 0, 0, $color);
imagesavealpha($image_resized, true);
}
}
imagecopyresampled($image_resized, $image, 0, 0, $cropWidth, $cropHeight, $final_width, $final_height, $width_old - 2 * $cropWidth, $height_old - 2 * $cropHeight);
# Taking care of original, if needed
if ( $delete_original ) {
if ( $use_linux_commands ) exec('rm '.$file);
else @unlink($file);
}

# Preparing a method of providing result
switch ( strtolower($output) ) {
case 'browser':
$mime = image_type_to_mime_type($info[2]);
header("Content-type: $mime");
$output = NULL;
break;
case 'file':
$output = $file;
break;
case 'return':
return $image_resized;
break;
default:
break;
}
# Writing image according to type to the output destination and image quality
switch ( $info[2] ) {
case IMAGETYPE_GIF: imagegif($image_resized, $output); break;
case IMAGETYPE_JPEG: imagejpeg($image_resized, $output, $quality); break;
case IMAGETYPE_PNG:
$quality = 9 - (int)((0.9*$quality)/10.0);
imagepng($image_resized, $output, $quality);
break;
default: return false;
}
return true;
}
?>

+ 3
- 0
sql/db_popcollections_examples.sql Просмотреть файл

@@ -0,0 +1,3 @@
/*Data for the table `popcollection` */

insert into `popcollection`(`popcollectionid`,`popcollection`) values (63,'2017 ECCC Exclusive'),(76,'Alien Covenant'),(22,'Aliens'),(17,'Animation'),(3,'Asia'),(72,'Avengers 2'),(64,'Baby Metal'),(13,'Back to the Future'),(60,'Batgirl'),(51,'Batman Arkham Asylum'),(50,'Batman Arkham Knight'),(52,'Batman Classic Series'),(43,'Batman the Animated Series'),(49,'Batman The Dark Knight Returns'),(34,'Batman v Superman'),(38,'Beauty and the Beast'),(44,'Big Hero 6'),(78,'Build-A-Bear'),(71,'Captain America Civil War'),(65,'Captain Underpants'),(24,'Clueless'),(26,'Custom'),(75,'DC Comics'),(40,'DC Comics Bombshells'),(35,'DC Super Heroes'),(61,'DC\'s Legends of Tomorrow'),(31,'Deadpool'),(37,'Disney'),(70,'Doctor Strange'),(21,'DOOM'),(81,'Elf'),(28,'Elvira Mistress of the Dark'),(6,'Ferris Bueller\'s Day Off'),(66,'Five Nights at Freddy\'s'),(25,'Football'),(4,'Game of Thrones'),(20,'Games'),(59,'Godzilla'),(53,'Gotham Before The Legend'),(15,'Guardians of the Galaxy'),(47,'Guardians of the Galaxy Vol. 2'),(30,'Guns n Roses'),(32,'Heroes'),(56,'Inside Out'),(48,'Jay and Silent Bob Strike Back'),(79,'Justice League'),(46,'Kill Bill'),(58,'Kong Skull Island'),(16,'Labyrinth'),(41,'Lord of the Rings'),(14,'Marvel'),(77,'Marvel Spider-Man Homecoming'),(11,'Mean Girls'),(36,'Mighty Morphin Power Rangers'),(57,'Moana'),(62,'Momotaro'),(55,'Monster High'),(1,'Movies'),(10,'Once Upon a Time'),(5,'Orange is the New Black'),(67,'Power Rangers'),(74,'Purple Haze Properties'),(29,'Rocks'),(19,'Sesame Street'),(7,'Sixteen Candles'),(9,'Star Wars'),(68,'Star Wars Rogue One'),(54,'Strawberry Shortcake'),(45,'Street Fighter'),(33,'Suicide Squad'),(42,'Tekken'),(2,'Television'),(23,'The Big Bang Theory'),(8,'The Breakfast Club'),(69,'The Flash'),(80,'The Joy of Painting'),(12,'The Karate Kid'),(18,'Voltron'),(27,'Winnie the Pooh'),(39,'Wonder Woman (Movie)');

+ 3
- 0
sql/db_popimages_data.sql Просмотреть файл

@@ -0,0 +1,3 @@
/*Data for the table `popimages` */

insert into `popimages`(`imageid`,`funkoid`,`userid`,`imagepath`) values (1,0,0,'images/no-image-available.jpg');

+ 41
- 0
sql/db_structure_only.sql Просмотреть файл

@@ -0,0 +1,41 @@
/*Table structure for table `popcollection` */

CREATE TABLE `popcollection` (
`popcollectionid` int(11) NOT NULL AUTO_INCREMENT,
`popcollection` varchar(40) DEFAULT NULL,
PRIMARY KEY (`popcollectionid`),
KEY `popcollection` (`popcollection`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=latin1;

/*Table structure for table `popimages` */

CREATE TABLE `popimages` (
`imageid` int(11) NOT NULL AUTO_INCREMENT,
`funkoid` int(11) DEFAULT NULL COMMENT 'the funko pop itself',
`userid` int(11) DEFAULT NULL COMMENT 'the user that uploaded the picture',
`imagepath` text COMMENT 'where the image is physically located',
PRIMARY KEY (`imageid`)
) ENGINE=InnoDB AUTO_INCREMENT=54 DEFAULT CHARSET=latin1;

/*Table structure for table `pops` */

CREATE TABLE `pops` (
`funkoid` int(11) NOT NULL AUTO_INCREMENT,
`userid` int(11) DEFAULT NULL,
`popno` int(11) DEFAULT NULL,
`popname` varchar(200) DEFAULT NULL,
`popcollectionid` int(11) DEFAULT NULL COMMENT 'Game of Thrones, Voltron, TV, Movies, Asia, etc etc',
`inserteddate` date DEFAULT NULL,
PRIMARY KEY (`funkoid`),
KEY `popname` (`popname`)
) ENGINE=InnoDB AUTO_INCREMENT=297 DEFAULT CHARSET=latin1;

/*Table structure for table `users` */

CREATE TABLE `users` (
`userid` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(200) DEFAULT NULL,
`passwd` varchar(200) DEFAULT NULL,
`email` varchar(200) DEFAULT NULL,
PRIMARY KEY (`userid`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1;

+ 52
- 0
style.css Просмотреть файл

@@ -0,0 +1,52 @@
body { background-color: #DDD; }

.content {
background-color: #f5f5f5;
padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;
margin-top: 10px; margin-right: 10px; margin-bottom: 10px; margin-left: 10px;
}

a.navlink:link { color: #003366; font-weight: bold; text-decoration: none; }
a.navlink:visited { color: #003366; font-weight: bold; text-decoration: none; }
a.navlink:hover { color: #CCCCCC; font-weight: bold; text-decoration: none; }

td {
font-family: Tahoma; font-size: 13px;
vertical-align: center;
}

.title {
font-size: 24px; font-weight: normal; color: #FFFFFF;
margin-top: 5px; margin-bottom: 5px; margin-left: 20px;
padding-top: 5px; padding-bottom: 5px; padding-left: 20px;
}

ul, li{
margin:0;
padding:0 0 0 15px;
}

.column{
float: left;
margin: 0 20px 0 0;
}

fieldset {
padding: 1em;
font:80%/1 sans-serif;
}
label {
float:left;
width:25%;
margin-right:0.5em;
padding-top:0.2em;
text-align:right;
font-weight:bold;
}
img.resize {
width:220px;
height:300px;
}

Загрузка…
Отмена
Сохранить