update back-end code

This commit is contained in:
bancika
2016-10-28 10:47:55 +02:00
parent f571992692
commit 5d5aa05f08
21 changed files with 691 additions and 165 deletions
+13 -2
View File
@@ -19,7 +19,7 @@ if (strlen($pwd) < 6) {
exit;
}
if (!$email) {
echo "{\"string\":E-mail not provided.}";
echo "{\"string\":eMail not provided.}";
exit;
}
$pwd = hash("ripemd160", $pwd);
@@ -45,10 +45,21 @@ if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error}";
exit;
}
function ip_details($IPaddress)
{
$json = file_get_contents("http://ip-api.com/json/{$IPaddress}");
$details = json_decode($json);
return $details;
}
$ip = $_SERVER["REMOTE_ADDR"];
$location = ip_details($ip);
$num = $num = $result->num_rows;
if ($num === 0) {
$sql= "INSERT INTO diylc_user (name, password, email, website, bio) VALUES ('".addslashes($name)."', '".$pwd."', '".addslashes($email)."', '".addslashes($website)."', '".addslashes($bio)."')";
$sql= "INSERT INTO diylc_user (name, password, email, website, bio, ip, country) VALUES ('".addslashes($name)."', '".$pwd."', '".addslashes($email)."', '".addslashes($website)."', '".addslashes($bio)."', '".$ip."', '".$location->country."')";
if ($mysqli->query($sql) === TRUE) {
echo "{\"string\":Success}";
+62
View File
@@ -0,0 +1,62 @@
-- phpMyAdmin SQL Dump
-- version 4.0.10.14
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Oct 28, 2016 at 10:45 AM
-- Server version: 5.6.33
-- PHP Version: 5.6.20
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `diyfever_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `diylc_category`
--
CREATE TABLE IF NOT EXISTS `diylc_category` (
`category_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(30) NOT NULL,
`sort_order` int(11) NOT NULL DEFAULT '0',
`parent_id` int(11) NOT NULL,
PRIMARY KEY (`category_id`),
UNIQUE KEY `category_id` (`category_id`),
KEY `category_id_2` (`category_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=22 ;
--
-- Dumping data for table `diylc_category`
--
INSERT INTO `diylc_category` (`category_id`, `name`, `sort_order`, `parent_id`) VALUES
(1, 'Effects', 200, 0),
(2, 'Compressors', 210, 1),
(3, 'Delays', 215, 1),
(4, 'Distortions', 220, 1),
(5, 'Reverbs', 235, 1),
(6, 'Boosters', 205, 1),
(7, 'Wahs', 240, 1),
(8, 'Modulations', 225, 1),
(9, 'Amplifiers', 100, 0),
(13, 'Hi-Fi Amplifiers', 150, 9),
(14, 'Guitar Amplifiers', 110, 9),
(21, 'Hi-Fi Preamps', 160, 9),
(20, 'Guitar Preamps', 120, 9),
(18, 'Guitar Wiring Diagrams', 400, 0),
(19, 'Other', 1000, 0);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+42
View File
@@ -0,0 +1,42 @@
-- phpMyAdmin SQL Dump
-- version 4.0.10.14
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Oct 28, 2016 at 10:45 AM
-- Server version: 5.6.33
-- PHP Version: 5.6.20
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `diyfever_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `diylc_comment`
--
CREATE TABLE IF NOT EXISTS `diylc_comment` (
`comment_id` int(11) NOT NULL AUTO_INCREMENT,
`project_id` int(11) NOT NULL,
`parent_id` int(11) NOT NULL DEFAULT '0',
`user_id` int(11) NOT NULL,
`comment` varchar(1024) NOT NULL,
`posted_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`flagged` bit(1) NOT NULL,
PRIMARY KEY (`comment_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+46
View File
@@ -0,0 +1,46 @@
-- phpMyAdmin SQL Dump
-- version 4.0.10.14
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Oct 28, 2016 at 10:45 AM
-- Server version: 5.6.33
-- PHP Version: 5.6.20
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `diyfever_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `diylc_project`
--
CREATE TABLE IF NOT EXISTS `diylc_project` (
`project_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`category_id` int(11) NOT NULL,
`owner_user_id` int(11) NOT NULL,
`description` varchar(1024) DEFAULT NULL,
`diylc_version` varchar(50) NOT NULL,
`uploaded_on` datetime NOT NULL,
`last_update` datetime NOT NULL,
`keywords` varchar(1024) NOT NULL,
`view_count` int(11) NOT NULL DEFAULT '0',
`download_count` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`project_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
@@ -0,0 +1,41 @@
-- phpMyAdmin SQL Dump
-- version 4.0.10.14
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Oct 28, 2016 at 10:45 AM
-- Server version: 5.6.33
-- PHP Version: 5.6.20
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `diyfever_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `diylc_search_history`
--
CREATE TABLE IF NOT EXISTS `diylc_search_history` (
`ip` varchar(100) NOT NULL,
`country` varchar(100) NOT NULL,
`criteria` varchar(100) NOT NULL,
`category` varchar(100) NOT NULL,
`format` varchar(10) NOT NULL,
`sort` varchar(20) NOT NULL,
`search_time` datetime NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+46
View File
@@ -0,0 +1,46 @@
-- phpMyAdmin SQL Dump
-- version 4.0.10.14
-- http://www.phpmyadmin.net
--
-- Host: localhost:3306
-- Generation Time: Oct 28, 2016 at 10:45 AM
-- Server version: 5.6.33
-- PHP Version: 5.6.20
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `diyfever_db`
--
-- --------------------------------------------------------
--
-- Table structure for table `diylc_user`
--
CREATE TABLE IF NOT EXISTS `diylc_user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(50) NOT NULL,
`password` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
`website` varchar(100) NOT NULL,
`bio` varchar(1024) NOT NULL,
`token` varchar(50) NOT NULL,
`machine_id` varchar(50) NOT NULL,
`last_login` datetime NOT NULL,
`ip` varchar(50) NOT NULL,
`country` varchar(50) NOT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
Binary file not shown.

After

Width:  |  Height:  |  Size: 717 B

+36
View File
@@ -0,0 +1,36 @@
<?php
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename=project.diy');
$id=$_REQUEST["id"];
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
$sql = "
UPDATE diylc_project
SET download_count = download_count + 1
WHERE project_id=".$id;
//echo $sql;
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error}";
exit;
}
readfile("http://diy-fever.com/diylc/uploads/".$id.".diy");
$mysqli->close();
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
$id=$_REQUEST["id"];
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
$sql = "
UPDATE diylc_project
SET view_count = view_count + 1
WHERE project_id=".$id;
//echo $sql;
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error}";
exit;
}
$im = imagecreatefrompng("http://diy-fever.com/diylc/thumbnails/".$id.".png");
if ($im) {
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
}
$mysqli->close();
?>
-55
View File
@@ -1,55 +0,0 @@
[22-Dec-2009 22:17:29] PHP Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in /home/diyfever/public_html/diylc/db/project_search.php on line 40
[22-Dec-2009 22:19:40] PHP Fatal error: Call to a member function getProperty() on a non-object in /home/diyfever/public_html/diylc/db/project_search.php on line 15
[23-Dec-2009 11:39:11] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 25
[23-Dec-2009 11:39:11] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/diyfever/public_html/diylc/db/downloadProject.php:25) in /home/diyfever/public_html/diylc/db/downloadProject.php on line 28
[23-Dec-2009 11:39:11] PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 29
[23-Dec-2009 11:39:39] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 25
[23-Dec-2009 11:39:39] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/diyfever/public_html/diylc/db/downloadProject.php:25) in /home/diyfever/public_html/diylc/db/downloadProject.php on line 28
[23-Dec-2009 11:39:39] PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 29
[23-Dec-2009 11:40:46] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 25
[23-Dec-2009 11:40:46] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/diyfever/public_html/diylc/db/downloadProject.php:25) in /home/diyfever/public_html/diylc/db/downloadProject.php on line 28
[23-Dec-2009 11:40:46] PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 29
[10-Oct-2011 11:17:43] PHP Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 25
[10-Oct-2011 11:17:43] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/diyfever/public_html/diylc/db/downloadProject.php:25) in /home/diyfever/public_html/diylc/db/downloadProject.php on line 28
[10-Oct-2011 11:17:43] PHP Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/diyfever/public_html/diylc/db/downloadProject.php on line 29
[23-Jul-2014 13:13:53 Europe/Belgrade] PHP Warning: mysql_numrows() expects parameter 1 to be resource, boolean given in /home/diyfever/public_html/diylc/db/downloadProject.php on line 25
[23-Jul-2014 13:13:53 Europe/Belgrade] PHP Warning: Cannot modify header information - headers already sent by (output started at /home/diyfever/public_html/diylc/db/downloadProject.php:25) in /home/diyfever/public_html/diylc/db/downloadProject.php on line 28
[23-Jul-2014 13:13:53 Europe/Belgrade] PHP Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/diyfever/public_html/diylc/db/downloadProject.php on line 29
[14-Oct-2016 12:36:05 Europe/Belgrade] PHP Warning: require_once(properties.php): failed to open stream: No such file or directory in /home/diyfever/public_html/diylc/db/login.php on line 7
[14-Oct-2016 12:36:05 Europe/Belgrade] PHP Fatal error: require_once(): Failed opening required 'properties.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/diyfever/public_html/diylc/db/login.php on line 7
[14-Oct-2016 13:36:44 Europe/Belgrade] PHP Parse error: syntax error, unexpected '}' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 26
[14-Oct-2016 15:32:48 Europe/Belgrade] PHP Parse error: syntax error, unexpected '.' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 30
[14-Oct-2016 16:08:33 Europe/Belgrade] PHP Fatal error: Call to undefined function query() in /home/diyfever/public_html/diylc/db/createUser.php on line 46
[14-Oct-2016 16:09:24 Europe/Belgrade] PHP Fatal error: Call to undefined function query() in /home/diyfever/public_html/diylc/db/createUser.php on line 50
[14-Oct-2016 16:09:53 Europe/Belgrade] PHP Fatal error: Call to undefined function query() in /home/diyfever/public_html/diylc/db/createUser.php on line 52
[14-Oct-2016 16:27:45 Europe/Belgrade] PHP Parse error: syntax error, unexpected ':' in /home/diyfever/public_html/diylc/db/login.php on line 45
[14-Oct-2016 17:50:59 Europe/Belgrade] PHP Fatal error: Call to a member function free() on boolean in /home/diyfever/public_html/diylc/db/login.php on line 50
[14-Oct-2016 17:53:52 Europe/Belgrade] PHP Parse error: syntax error, unexpected 'echo' (T_ECHO) in /home/diyfever/public_html/diylc/db/loginWithToken.php on line 47
[19-Oct-2016 12:45:17 Europe/Belgrade] PHP Parse error: syntax error, unexpected '.' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 83
[19-Oct-2016 12:45:54 Europe/Belgrade] PHP Parse error: syntax error, unexpected '.' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 83
[19-Oct-2016 12:56:27 Europe/Belgrade] PHP Parse error: syntax error, unexpected '}', expecting ',' or ';' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 94
[19-Oct-2016 12:56:35 Europe/Belgrade] PHP Warning: Illegal string offset 'owner' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 84
[19-Oct-2016 12:57:13 Europe/Belgrade] PHP Warning: Illegal string offset 'owner' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 86
[19-Oct-2016 13:44:33 Europe/Belgrade] PHP Parse error: syntax error, unexpected '"</td>' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ';' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 105
[19-Oct-2016 14:15:35 Europe/Belgrade] PHP Parse error: syntax error, unexpected 'right' (T_STRING), expecting ',' or ';' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 106
[19-Oct-2016 14:25:05 Europe/Belgrade] PHP Parse error: syntax error, unexpected 'right' (T_STRING), expecting ',' or ';' in /home/diyfever/public_html/diylc/db/projectSearch.php on line 96
[19-Oct-2016 15:48:00 Europe/Belgrade] PHP Warning: mysql_query(): Access denied for user ''@'localhost' (using password: NO) in /home/diyfever/public_html/diylc/db/upload.php on line 96
[19-Oct-2016 15:48:00 Europe/Belgrade] PHP Warning: mysql_query(): A link to the server could not be established in /home/diyfever/public_html/diylc/db/upload.php on line 96
[19-Oct-2016 15:51:34 Europe/Belgrade] PHP Parse error: syntax error, unexpected ')' in /home/diyfever/public_html/diylc/db/upload.php on line 113
[19-Oct-2016 15:56:04 Europe/Belgrade] PHP Warning: move_uploaded_file(/path/to/your/destination/4.png): failed to open stream: No such file or directory in /home/diyfever/public_html/diylc/db/upload.php on line 120
[19-Oct-2016 15:56:04 Europe/Belgrade] PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpCQK5Bb' to '/path/to/your/destination/4.png' in /home/diyfever/public_html/diylc/db/upload.php on line 120
[19-Oct-2016 15:56:04 Europe/Belgrade] PHP Warning: move_uploaded_file(/path/to/your/destination/4.diy): failed to open stream: No such file or directory in /home/diyfever/public_html/diylc/db/upload.php on line 121
[19-Oct-2016 15:56:04 Europe/Belgrade] PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpCQK5Bb' to '/path/to/your/destination/4.diy' in /home/diyfever/public_html/diylc/db/upload.php on line 121
[19-Oct-2016 15:56:04 Europe/Belgrade] PHP Fatal error: Call to a member function free() on boolean in /home/diyfever/public_html/diylc/db/upload.php on line 131
[19-Oct-2016 15:58:21 Europe/Belgrade] PHP Fatal error: Call to a member function free() on boolean in /home/diyfever/public_html/diylc/db/upload.php on line 131
[19-Oct-2016 16:00:57 Europe/Belgrade] PHP Warning: move_uploaded_file(public_html/diylc/thumbnails7.png): failed to open stream: No such file or directory in /home/diyfever/public_html/diylc/db/upload.php on line 120
[19-Oct-2016 16:00:57 Europe/Belgrade] PHP Warning: move_uploaded_file(): Unable to move '/tmp/php5NzI1v' to 'public_html/diylc/thumbnails7.png' in /home/diyfever/public_html/diylc/db/upload.php on line 120
[19-Oct-2016 16:00:57 Europe/Belgrade] PHP Warning: move_uploaded_file(public_html/diylc/uploads/7.diy): failed to open stream: No such file or directory in /home/diyfever/public_html/diylc/db/upload.php on line 121
[19-Oct-2016 16:00:57 Europe/Belgrade] PHP Warning: move_uploaded_file(): Unable to move '/tmp/phpYopq2O' to 'public_html/diylc/uploads/7.diy' in /home/diyfever/public_html/diylc/db/upload.php on line 121
[19-Oct-2016 16:26:43 Europe/Belgrade] PHP Parse error: syntax error, unexpected '$isJson' (T_VARIABLE) in /home/diyfever/public_html/diylc/api/search.php on line 14
[19-Oct-2016 16:26:55 Europe/Belgrade] PHP Parse error: syntax error, unexpected 'require_once' (T_REQUIRE_ONCE) in /home/diyfever/public_html/diylc/api/search.php on line 43
[19-Oct-2016 16:33:12 Europe/Belgrade] PHP Parse error: syntax error, unexpected '<' in /home/diyfever/public_html/diylc/api/search.php on line 130
[19-Oct-2016 16:33:25 Europe/Belgrade] PHP Parse error: syntax error, unexpected end of file in /home/diyfever/public_html/diylc/api/search.php on line 137
[19-Oct-2016 16:40:41 Europe/Belgrade] PHP Parse error: syntax error, unexpected '&' in /home/diyfever/public_html/diylc/api/search.php on line 131
[22-Oct-2016 10:10:56 Europe/Belgrade] PHP Parse error: syntax error, unexpected end of file in /home/diyfever/public_html/diylc/api/v1/getAvailableCategories.php on line 39
[22-Oct-2016 10:26:50 Europe/Belgrade] PHP Parse error: syntax error, unexpected '"', expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/diyfever/public_html/diylc/api/v1/getCategories.php on line 32
+3
View File
@@ -0,0 +1,3 @@
{"list":{"org.diylc.announcements.Announcement":[
{"title":"Welcome note","date":"2016-10-25","text":"Thank you for trying out the latest and greatest DIYLC beta version.<br>Please note that all project submitted during beta testing stage will be deleted<br> once the we are ready for the release for a fresh start.<br>Enjoy surfing the cloud and please send your feedback to bancika@gmail.com"},
]}}
+2 -2
View File
@@ -15,7 +15,7 @@ $database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
// Run the query
$sql= "SELECT name FROM diylc_category ORDER BY sort_order";
$sql= "SELECT display_name FROM diylc_category_view";
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error}";
@@ -29,7 +29,7 @@ $i=0;
while ($row = $result->fetch_assoc()) {
if ($i>0)
echo ",";
echo "\"".$row["name"]."\"";
echo "\"".$row["display_name"]."\"";
$i++;
}
+67
View File
@@ -0,0 +1,67 @@
<?php
$className="org.diylc.plugins.cloud.model.CommentEntity";
$projectId=$_REQUEST["projectId"];
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
$sql = "
SELECT c.*, u.name username
FROM diylc_comment c
INNER JOIN diylc_user u ON u.user_id = c.user_id
WHERE project_id = ".$projectId;
//echo $sql;
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error:".$mysqli->error."}";
exit;
}
$num = $num = $result->num_rows;
if ($num === 0) {
echo "{\"list\":\"\"}";
} else {
// JSON header
echo "{\"list\":{\"".$className."\":[";
$i=0;
while ($row = $result->fetch_assoc()) {
if ($i>0) {
echo ",";
}
$time = strtotime($row["posted_at"]);
$postedAt= date("Y-m-d H:i:s", $time);
echo "{";
echo "\"id\":".$row["comment_id"].",";
echo "\"parentId\":".$row["parent_id"].",";
echo "\"username\":\"".$row["username"]."\",";
echo "\"comment\":\"".$row["comment"]."\",";
echo "\"postedAt\":\"".$postedAt."\"";
echo "}";
$i++;
}
echo "]}}";
}
$result->free();
$mysqli->close();
?>
+3
View File
@@ -0,0 +1,3 @@
<?php
echo "{\"list\":{\"java.lang.String\":[\"Name\",\"Category\",\"Age\",\"Author\"]}}";
?>
+54
View File
@@ -0,0 +1,54 @@
<?php
$name=$_REQUEST["username"];
$token=$_REQUEST["token"];
$machineId=$_REQUEST["machineId"];
if (!$name) {
echo "{\"string\":Username not provided.}";
exit;
}
if (!$token) {
echo "{\"string\":Token not provided.}";
exit;
}
if (!$machineId) {
echo "{\"string\":Machine ID not provided.}";
exit;
}
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
$className="org.diylc.plugins.cloud.model.UserEntity";
// Verify that the user is logged in
$sql = "
SELECT email, website, bio
FROM diylc_user
WHERE name = \"".addslashes($name)."\" AND token= \"".addslashes($token)."\" AND machine_id = \"".addslashes($machineId)."\"";
if (!$result = $mysqli->query($sql) or !($row = $result->fetch_assoc())) {
echo "{\"string\":Error while looking up the user.}";
} else {
echo "{\"".$className."\": {
\"username\":\"".$name."\",
\"email\":\"".addslashes($row["email"])."\",
\"website\":\"".addslashes($row["website"])."\",
\"bio\":\"".addslashes(str_replace(array("\n","\r\n","\r"),"<br>", $row["bio"]))."\"
}}";
}
$mysqli->close();
?>
+72
View File
@@ -0,0 +1,72 @@
<?php
$name=$_REQUEST["username"];
$token=$_REQUEST["token"];
$machineId=$_REQUEST["machineId"];
$projectId=$_REQUEST["projectId"];
$comment=$_REQUEST["comment"];
if (!$name) {
echo "{\"string\":Username not provided.}";
exit;
}
if (!$token) {
echo "{\"string\":Token not provided.}";
exit;
}
if (!$machineId) {
echo "{\"string\":Machine ID not provided.}";
exit;
}
if (!$projectId) {
echo "{\"string\":ProjectId not provided.}";
exit;
}
if (!$comment) {
echo "{\"string\":Comment not provided.}";
exit;
}
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
// Verify that the user is logged in
$sql = "
SELECT user_id
FROM diylc_user
WHERE name = \"".addslashes($name)."\" AND token= \"".addslashes($token)."\" AND machine_id = \"".addslashes($machineId)."\"";
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error while looking up the user.}";
exit;
}
if ($row = $result->fetch_assoc()) {
$userId = $row["user_id"];
$sql = "INSERT INTO diylc_comment (project_id, user_id, comment, posted_at) VALUES (".addslashes($projectId).",".$userId.",\"".addslashes($comment)."\",NOW())";
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error while uploading the project into the database.}";
exit;
} else {
echo "{\"string\":Success}";
}
} else {
echo "{\"string\":User is not logged in.}";
}
$mysqli->close();
?>
+50 -77
View File
@@ -1,12 +1,10 @@
<?php
$className="com.diyfever.diylc.plugins.cloud.model.ProjectEntity";
$className="org.diylc.plugins.cloud.model.ProjectEntity";
$criteria=$_REQUEST["criteria"];
$category=$_REQUEST["category"];
$format=$_REQUEST["format"];
$page=$_REQUEST["page"];
$itemsPerPage=$_REQUEST["itemsPerPage"];
$isJson=$format==="json";
$sort=$_REQUEST["sort"];
if(!$page)
$page=1;
@@ -18,7 +16,7 @@ if(!$sort)
$condition="";
if ($category)
$condition = $condition." AND LOWER(c.name) = LOWER('".$category."')";
$condition = $condition." AND LOWER(c.search_name) = LOWER('".$category."')";
if ($criteria)
$condition = $condition." AND (LOWER(p.description) LIKE LOWER('%".$criteria."%') OR LOWER(p.name) LIKE LOWER('%".$criteria."%') OR LOWER(p.keywords) LIKE LOWER('%".$criteria."%'))";
@@ -28,9 +26,9 @@ $orderBy = " ORDER BY ";
if ($sort==="Author")
$orderBy = $orderBy." u.name, p.name";
else if ($sort==="Category")
$orderBy = $orderBy." c.name, p.name";
$orderBy = $orderBy." c.search_name, p.name";
else if ($sort==="Age")
$orderBy = $orderBy." p.last_update";
$orderBy = $orderBy." p.last_update desc";
else
$orderBy = $orderBy." p.name";
@@ -50,99 +48,74 @@ $password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
function ip_details($IPaddress)
{
$json = file_get_contents("http://ip-api.com/json/{$IPaddress}");
$details = json_decode($json);
return $details;
}
$ip = $_SERVER["REMOTE_ADDR"];
$location = ip_details($ip);
$sql = "INSERT INTO diylc_search_history (ip, country, criteria, category, sort, search_time) VALUES (\"".$ip."\", \"".$location->country."\",\"".$criteria."\",\"".$category."\",\"".$sort."\",NOW())";
$mysqli->query($sql);
//echo $sql;
//if (!$result = $mysqli->query($sql)) {
// echo "{\"string\":Error:".$mysqli->error."}";
// exit;
//}
$sql = "
SELECT p.project_id, p.name, p.description, c.name AS 'category', u.name AS 'owner', p.last_update
FROM diylc_project p, diylc_category c, diylc_user u
SELECT p.project_id, p.name, p.description, c.search_name AS 'category', u.name AS 'owner', p.last_update, p.view_count, p.download_count, (SELECT COUNT(*) FROM diylc_comment co WHERE co.project_id = p.project_id) comment_count
FROM diylc_project p, diylc_category_view c, diylc_user u
WHERE p.category_id = c.category_id AND p.owner_user_id = u.user_id ".$condition.$orderBy.$limit;
//echo $sql;
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error}";
echo "{\"string\":Error:".$mysqli->error."}";
exit;
}
$num = $num = $result->num_rows;
if ($num === 0) {
if ($isJson)
echo "{\"list\":\"\"}";
else {
echo "<table width='600px' height='100px'><tr><td align='center' valign='top'><b>No matching projects found.</b></tr></td></table>";
echo "<table width='600px'><tr><td align='left'>";
if ($page > 1)
echo "<a href='".$params."&page=".($page-1)."'><img src='http://diy-fever.com/diylc/api/v1/left-arrow.png'></a>";
echo "</td><td align='right'></td></tr></table>";
}
echo "{\"list\":\"\"}";
} else {
// JSON header
if ($isJson)
echo "{\"list\":{\"".$className."\":[";
else
echo "<table width='600px' border='0' cellspacing='0' cellpadding='1'>";
echo "{\"list\":{\"".$className."\":[";
$i=0;
while ($row = $result->fetch_assoc()) {
if ($i>0) {
if ($isJson)
echo ",";
else
echo "<tr height='8px'></tr>";
echo ",";
}
$time = strtotime($row["last_update"]);
$updated = date("Y-m-d", $time);
if ($isJson)
{
echo "{";
echo "\"id\":".$row["project_id"].",";
echo "\"name\":\"".$row["name"]."\",";
echo "\"description\":\"".$row["description"]."\",";
echo "\"owner\":\"".$row["owner"]."\",";
echo "\"category\":\"".$row["category"]."\",";
echo "\"updated\":\"".$updated ."\",";
echo "\"thumbnailUrl\":\"http://diy-fever.com/diylc/thumbnails/".$row["project_id"].".png\",";
echo "\"downloadUrl\":\"http://diy-fever.com/diylc/uploads/".$row["project_id"].".diy\"";
echo "}";
} else {
echo "
<tr style='background-color:#999999;color:#FFFFFF;border-spacing:0;padding:0;'>
<td rowspan='3' width='1'><img src='http://diy-fever.com/diylc/thumbnails/".$row["project_id"].".png'/></td>
<td width='2px'></td>
<td height='1px' colspan='2'><b>".$row["name"]."</b></td>
<td height='1px' colspan='2' nowrap='1' align='right'>by ".$row["owner"]."</td>
<td width='2px'></td>
</tr>
<tr>
<td width='2px'></td>
<td valign='top' halign='left' colspan='4'><p align='justify'>".$row["description"]."</p></td>
<td style='border-right: 1px solid #999999;' width='2px'></td>
</tr>
<tr>
<td style='border-bottom: 1px solid #999999;' width='2px'></td>
<td style='border-bottom: 1px solid #999999;'colspan='3' valign='bottom'>Category: ".$row["category"]."<br>Uploaded on ".$updated."</td>
<td style='border-right: 1px solid #999999;border-bottom: 1px solid #999999;' width='1px' colspan='2' valign='bottom' align='right'><a href='http://diy-fever.com/diylc/uploads/".$row["project_id"].".diy'><img src='http://diy-fever.com/diylc/api/v1/download-icon-32.png'/></a></td>
</tr>";
}
$i++;
}
// JSON footer
if ($isJson)
echo "]}}";
else {
echo "</table>";
echo "<br>";
echo "<table width='600px'><tr><td align='left'>";
if ($page > 1)
echo "<a href='".$params."&page=".($page-1)."'><img src='http://diy-fever.com/diylc/api/v1/left-arrow.png'></a>";
echo "</td><td align='right'>";
if ($num == $itemsPerPage)
echo "<a href='".$params."&page=".($page+1)."'><img src='http://diy-fever.com/diylc/api/v1/right-arrow.png'></a>";
echo "</td></tr></table>";
}
echo "{";
echo "\"id\":".$row["project_id"].",";
echo "\"name\":\"".$row["name"]."\",";
echo "\"description\":\"".$row["description"]."\",";
echo "\"owner\":\"".$row["owner"]."\",";
echo "\"category\":\"".$row["category"]."\",";
echo "\"updated\":\"".$updated ."\",";
echo "\"thumbnailUrl\":\"http://diy-fever.com/diylc/api/v1/downloadThumbnail.php?id=".$row["project_id"]."\",";
echo "\"downloadUrl\":\"http://diy-fever.com/diylc/api/v1/downloadProject.php?id=".$row["project_id"]."\",";
echo "\"commentCount\":\"".$row["comment_count"]."\",";
echo "\"viewCount\":\"".$row["view_count"]."\",";
echo "\"downloadCount\":\"".$row["download_count"]."\"";
echo "}";
$i++;
}
echo "]}}";
}
$result->free();
-27
View File
@@ -1,27 +0,0 @@
<html>
<body>
<form method="POST" action="http://www.diy-fever.com/diylc/api/upload.php" enctype="multipart/form-data">
Username: <input type="text" name="username" value="testUser3">
<br>
MachineId: <input type="text" name="machineId" value="tttjg">
<br>
Token: <input type="text" name="token" value="testUser35800ffaabb0b92.58166942">
<br>
Name: <input type="text" name="projectName" value="">
<br>
Category: <input type="text" name="category" value="TestCat">
<br>
Description: <input type="text" name="description" value="The quick brown fox jumps over the lazy dog.">
<br>
Version: <input type="text" name="diylcVersion" value="3.0.0">
<br>
Keywords: <input type="text" name="keywords" value="">
<br>
Thumb: <input type="file" name="thumbnail" id="thumbnail">
<br>
Project: <input type="file" name="project" id="project">
<br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
+55
View File
@@ -0,0 +1,55 @@
<?php
$name=$_REQUEST["username"];
$oldPwd=$_REQUEST["oldPassword"];
$machineId=$_REQUEST["machineId"];
$newPwd=$_REQUEST["newPassword"];
if (!$name) {
echo "{\"string\":Username not provided.}";
exit;
}
if (!$oldPwd) {
echo "{\"string\":Old password not provided.}";
exit;
}
if (strlen($newPwd) < 6) {
echo "{\"string\":Password must be at least 6 characters long.}";
exit;
}
$oldPwd= hash("ripemd160", $oldPwd);
$newPwd= hash("ripemd160", $newPwd);
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
// Verify that the user is logged in
$sql = "
UPDATE diylc_user
SET password = \"".$newPwd."\"
WHERE name = \"".addslashes($name)."\" AND password= \"".$oldPwd."\"";
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Database error.}";
exit;
}
if ($mysqli->affected_rows === 0) {
echo "{\"string\":Could not update the password.}";
} else {
echo "{\"string\":Success}";
}
$mysqli->close();
?>
+59
View File
@@ -0,0 +1,59 @@
<?php
$name=$_REQUEST["username"];
$token=$_REQUEST["token"];
$machineId=$_REQUEST["machineId"];
$email=$_REQUEST["email"];
$website=$_REQUEST["website"];
$bio=$_REQUEST["bio"];
if (!$name) {
echo "{\"string\":Username not provided.}";
exit;
}
if (!$token) {
echo "{\"string\":Token not provided.}";
exit;
}
if (!$machineId) {
echo "{\"string\":Machine ID not provided.}";
exit;
}
if (!$email) {
echo "{\"string\":eMail not provided.}";
exit;
}
// Load help class
require_once("properties.php");
// Load properties
$dbProperties = new Properties();
$propertiesFile = fopen("db.properties", "rb");
$dbProperties->load($propertiesFile);
// Connect to the DB
$username=$dbProperties->getProperty("user");
$password=$dbProperties->getProperty("pass");
$database=$dbProperties->getProperty("db");
$mysqli = new mysqli(localhost,$username,$password,$database);
// Verify that the user is logged in
$sql = "
UPDATE diylc_user
SET email= \"".addslashes($email)."\", website= \"".addslashes($website)."\", bio= \"".addslashes($bio)."\"
WHERE name = \"".addslashes($name)."\" AND token= \"".addslashes($token)."\" AND machine_id = \"".addslashes($machineId)."\"";
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Database error.}";
exit;
}
if ($mysqli->affected_rows === 0) {
echo "{\"string\":Could not update the account.}";
} else {
echo "{\"string\":Success}";
}
$mysqli->close();
?>
+2 -2
View File
@@ -90,8 +90,8 @@ if ($row = $result->fetch_assoc()) {
// Find the right category
$sql = "
SELECT category_id
FROM diylc_category
WHERE LOWER(name) = LOWER(\"".addslashes($category)."\")";
FROM diylc_category_view
WHERE LOWER(display_name) = LOWER(\"".addslashes($category)."\")";
if (!$result = $mysqli->query($sql)) {
echo "{\"string\":Error while determining the category.}";