diff --git a/diylc-server-api/.project b/diylc-server-api/.project
new file mode 100644
index 00000000..6f7ed32c
--- /dev/null
+++ b/diylc-server-api/.project
@@ -0,0 +1,11 @@
+
+
+ diylc-server-api
+
+
+
+
+
+
+
+
diff --git a/diylc-server-api/v1/createUser.php b/diylc-server-api/v1/createUser.php
new file mode 100644
index 00000000..e5b01fa9
--- /dev/null
+++ b/diylc-server-api/v1/createUser.php
@@ -0,0 +1,64 @@
+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);
+
+// Run the query
+$sql= "SELECT name FROM diylc_user WHERE LOWER(name) = LOWER('".$name."')";
+
+if (!$result = $mysqli->query($sql)) {
+ echo "{\"string\":Error}";
+ exit;
+}
+
+$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)."')";
+
+ if ($mysqli->query($sql) === TRUE) {
+ echo "{\"string\":Success}";
+ } else {
+ echo "{\"string\":Error}";
+ }
+
+} else {
+ echo "{\"string\":User already exists.}";
+}
+
+$mysqli->close();
+?>
\ No newline at end of file
diff --git a/diylc-server-api/v1/download-icon-32.png b/diylc-server-api/v1/download-icon-32.png
new file mode 100644
index 00000000..090ed556
Binary files /dev/null and b/diylc-server-api/v1/download-icon-32.png differ
diff --git a/diylc-server-api/v1/download-icon.png b/diylc-server-api/v1/download-icon.png
new file mode 100644
index 00000000..2a53d12e
Binary files /dev/null and b/diylc-server-api/v1/download-icon.png differ
diff --git a/diylc-server-api/v1/error_log b/diylc-server-api/v1/error_log
new file mode 100644
index 00000000..68a7c73b
--- /dev/null
+++ b/diylc-server-api/v1/error_log
@@ -0,0 +1,55 @@
+[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 '"' (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
diff --git a/diylc-server-api/v1/getCategories.php b/diylc-server-api/v1/getCategories.php
new file mode 100644
index 00000000..56d373f9
--- /dev/null
+++ b/diylc-server-api/v1/getCategories.php
@@ -0,0 +1,39 @@
+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);
+
+// Run the query
+$sql= "SELECT name FROM diylc_category ORDER BY sort_order";
+
+if (!$result = $mysqli->query($sql)) {
+ echo "{\"string\":Error}";
+ exit;
+}
+
+echo "{\"list\":{\"java.lang.String\":[";
+
+$i=0;
+
+while ($row = $result->fetch_assoc()) {
+ if ($i>0)
+ echo ",";
+ echo "\"".$row["name"]."\"";
+ $i++;
+}
+
+echo "]}}";
+
+$mysqli->close();
+?>
\ No newline at end of file
diff --git a/diylc-server-api/v1/left-arrow.png b/diylc-server-api/v1/left-arrow.png
new file mode 100644
index 00000000..42f1a9eb
Binary files /dev/null and b/diylc-server-api/v1/left-arrow.png differ
diff --git a/diylc-server-api/v1/login.php b/diylc-server-api/v1/login.php
new file mode 100644
index 00000000..5ad084f0
--- /dev/null
+++ b/diylc-server-api/v1/login.php
@@ -0,0 +1,52 @@
+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);
+
+// Run the query
+$sql= "SELECT name FROM diylc_user WHERE name = \"".addslashes($name)."\" AND password = \"".addslashes($pwd)."\"";
+if (!$result = $mysqli->query($sql)) {
+ echo "{\"string\":Error}";
+ exit;
+}
+
+if ($result->num_rows === 0) {
+ echo "{\"string\":Error}";
+} else {
+ $token = uniqid(addslashes($name), false);
+ $sql = "UPDATE diylc_user SET last_login = NOW(), machine_id = '".$machineId."', token='".$token."' WHERE name = \"".$name."\"";
+ $result2 = $mysqli->query($sql);
+ echo "{\"string\":".$token."}";
+}
+$result->free();
+$mysqli->close();
+?>
\ No newline at end of file
diff --git a/diylc-server-api/v1/loginWithToken.php b/diylc-server-api/v1/loginWithToken.php
new file mode 100644
index 00000000..abe540df
--- /dev/null
+++ b/diylc-server-api/v1/loginWithToken.php
@@ -0,0 +1,53 @@
+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);
+
+// Run the query
+$sql= "SELECT name FROM diylc_user WHERE name = \"".addslashes($name)."\" AND token= \"".addslashes($pwd)."\" AND machine_id = \"".addslashes($machineId)."\"";
+
+if (!$result = $mysqli->query($sql)) {
+ echo "{\"string\":Error}";
+ exit;
+}
+
+if ($result->num_rows === 0) {
+ echo "{\"string\":Error}";
+} else {
+ $sql = "UPDATE diylc_user SET last_login = NOW() WHERE name = \"".$name."\"";
+ $result2 = $mysqli->query($sql);
+ echo "{\"string\":Success}";
+}
+
+
+$result->free();
+$mysqli->close();
+?>
\ No newline at end of file
diff --git a/diylc-server-api/v1/properties.php b/diylc-server-api/v1/properties.php
new file mode 100644
index 00000000..9467326b
--- /dev/null
+++ b/diylc-server-api/v1/properties.php
@@ -0,0 +1,250 @@
+defaults = $defaults;
+ }
+
+ $this->properties = array();
+ }
+
+ /**
+ * Retrieves a property value. If a value is not found for this key, the
+ * defaults object is searched for a default. If not default value is
+ * found there, the default value passed into this function is used. If
+ * a value still cannot be determined, null is returned.
+ */
+ public function getProperty($key, $defaultValue = null) {
+ $value = null;
+
+ if(array_key_exists($key, $this->properties)) {
+ $value = $this->properties[$key];
+ }
+
+ if($value == null && $this->defaults != null) {
+ $value = $this->defaults->getProperty($key);
+ }
+
+ if($value == null) {
+ $value = $defaultValue;
+ }
+
+ return $value;
+ }
+
+ /**
+ * Sets a property value. Returns the old value, if available. No defaults
+ * are used when searching for the old value; a value is returned only if it
+ * was explicitly set.
+ */
+ public function setProperty($key, $value) {
+ $oldValue = null;
+ if(array_key_exists($key, $this->properties)) {
+ $oldValue = $this->properties[$key];
+ }
+ $this->properties[$key] = $value;
+ return $oldValue;
+ }
+
+ /**
+ * Returns the names of all keys in this property set, including keys in the
+ * default property set if no value is defined in this property set.
+ */
+ public function propertyNames() {
+ $keys = array();
+ if($this->defaults != null) {
+ $keys = $this->defaults->propertyNames();
+ }
+
+ $myKeys = array_keys($this->properties);
+ sort($myKeys);
+ for($i = 0; $i < count($myKeys); $i++) {
+ if(!array_key_exists($myKeys[$i], $keys)) {
+ array_push($keys, $myKeys[$i]);
+ }
+ }
+
+ return $keys;
+ }
+
+ /**
+ * Writes the properties to the given stream, in the format defined by
+ * java.util.Properties.
+ */
+ public function store($handle, $comment = null) {
+ if($comment != null) {
+ fwrite($handle, "#" . $this->escapeComment($comment) . PHP_EOL);
+ }
+ fwrite($handle, "#" . date("D M d H:i:s T Y") . PHP_EOL);
+
+ $propertyNames = array_keys($this->properties);
+ for($i = 0; $i < count($propertyNames); $i++) {
+ fwrite($handle, $this->escapeKey($propertyNames[$i]) . "=" . $this->escapeValue($this->properties[$propertyNames[$i]]) . PHP_EOL);
+ }
+ }
+
+ /**
+ * Loads a file from the given stream, in the format defined by
+ * java.util.Properties
+ */
+ public function load($handle) {
+ $this->properties = array();
+
+ $logicalLine = "";
+ $appendNext = false;
+ while(!feof($handle)) {
+ $line = fgets($handle);
+ $line = rtrim($line, "\r\n"); // Chomp!
+ $line = ltrim($line);
+
+ // If the previous line was a continuation line, append this one
+ if($appendNext) {
+ $logicalLine .= $line;
+ $appendNext = false;
+ } else {
+ $logicalLine = $line;
+ }
+
+ // Is it a comment line?
+ // Check this before checking for continuations, as comments cannot be continued
+ if(preg_match("/^[ ]*[#!]/", $logicalLine)) {
+ continue;
+ }
+
+ // Is this line continued?
+ // A continuation line is one ending in an odd number of backslashes
+ $numTrailingBackslashes = 0;
+ while((strlen($logicalLine) - $numTrailingBackslashes - 1) > -1 &&
+ $logicalLine[strlen($logicalLine) - $numTrailingBackslashes - 1] == "\\") {
+ $numTrailingBackslashes++;
+ }
+ if($numTrailingBackslashes % 2 == 1) {
+ // If it is a continuation line, append a newline.. this will
+ // removed when the line is unescaped, but appending it in
+ // advance prevents backslashes other than the final one from
+ // escaping the next line, e.g. in the case
+ // a=b\\\
+ // n
+ // If you are not careful, this will be transformed into
+ // a=b\\n
+ // And bad things could happen.
+ $logicalLine .= "\n";
+ $appendNext = true;
+ continue;
+ }
+
+ // Now that we've combined the physical lines to form one large
+ // logical line, see if it's empty.
+ if(strcmp($logicalLine, "") == 0) {
+ continue;
+ }
+
+ // Split into key-value pairs
+ $matches = array();
+ $key = "";
+ $value = "";
+
+ // This regex splits the string into 3 sections:
+ // - Leading whitespace plus all non-whitespace characters up to
+ // the first unescaped :, =, space, or tab character
+ // - The :, =, space, or tab character itself, which separates
+ // the key from the value
+ // - The rest of the string
+ // If this match succeeds, the first and third pieces form the key
+ // and value. Otherwise, the entire string is considered to be a
+ // key with no value.
+ if(preg_match("/^([ ]*.*?[^\\\\])([:= ]+?)([^:= ].*)$/s", $logicalLine, $matches)) {
+ $key = $matches[1];
+ $value = $matches[3];
+ } else {
+ $key = $logicalLine;
+ }
+
+ $key = $this->unescapeGeneric($key);
+ $value = $this->unescapeGeneric($value);
+
+ $this->properties[$key] = $value;
+ }
+
+ }
+
+ /**
+ * List the contents to an output stream. This is useful for debugging.
+ */
+ public function debugList($handle) {
+ fwrite($handle, "-- listing properties --" . PHP_EOL);
+ $propertyNames = $this->propertyNames();
+ for($i = 0; $i < count($propertyNames); $i++) {
+ fwrite($handle, $propertyNames[$i] . "=" . $this->getProperty($propertyNames[$i]) . PHP_EOL);
+ }
+ }
+
+ private function escapeKey($key) {
+ return str_replace(" ", "\\ ", $this->escapeGeneric($key));
+ }
+
+ private function escapeValue($value) {
+ $value = $this->escapeGeneric($value);
+
+ // Values have leading space replaced, but none other
+ if(strlen($value) > 0 && strcmp($value[0], ' ') == 0) {
+ $value = "\\" . $value;
+ }
+
+ return $value;
+ }
+
+ private function escapeGeneric($value) {
+ $value = str_replace("#", "\\#", $value);
+ $value = str_replace("!", "\\!", $value);
+ $value = str_replace("=", "\\=", $value);
+ $value = str_replace(":", "\\:", $value);
+ $value = str_replace("\t", "\\t", $value);
+ $value = str_replace("\n", "\\n", $value);
+ $value = str_replace("\r", "\\r", $value);
+ return $value;
+ }
+
+ private function escapeComment($comment) {
+ return preg_replace("/\n([^#])/", "\n#\\1", $comment);
+ }
+
+ private function unescapeGeneric($value) {
+ $value = preg_replace("/\\\\([^\\\\trn\\n])/s", "\\1", $value);
+ $value = str_replace("\\\n", "", $value);
+ $value = str_replace("\\t", "\t", $value);
+ $value = str_replace("\\r", "\r", $value);
+ $value = str_replace("\\n", "\n", $value);
+ return $value;
+ }
+
+ private $properties /* Array */;
+ private $defaults /* Properties */;
+}
+
+?>
diff --git a/diylc-server-api/v1/right-arrow.png b/diylc-server-api/v1/right-arrow.png
new file mode 100644
index 00000000..baceadb3
Binary files /dev/null and b/diylc-server-api/v1/right-arrow.png differ
diff --git a/diylc-server-api/v1/search.php b/diylc-server-api/v1/search.php
new file mode 100644
index 00000000..6cca990c
--- /dev/null
+++ b/diylc-server-api/v1/search.php
@@ -0,0 +1,150 @@
+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 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
+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}";
+ exit;
+}
+
+$num = $num = $result->num_rows;
+if ($num === 0) {
+ if ($isJson)
+ echo "{\"list\":\"\"}";
+ else {
+ echo "
| No matching projects found. |
";
+ echo "";
+
+ if ($page > 1)
+ echo " ";
+ echo " | |
";
+ }
+} else {
+ // JSON header
+ if ($isJson)
+ echo "{\"list\":{\"".$className."\":[";
+ else
+ echo "";
+
+ $i=0;
+ while ($row = $result->fetch_assoc()) {
+ if ($i>0) {
+ if ($isJson)
+ echo ",";
+ else
+ 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 "
+
+  |
+ |
+ ".$row["name"]." |
+ by ".$row["owner"]." |
+ |
+
+
+ |
+ ".$row["description"]." |
+ |
+
+
+ |
+ Category: ".$row["category"]." Uploaded on ".$updated." |
+  |
+
";
+ }
+ $i++;
+ }
+
+ // JSON footer
+ if ($isJson)
+ echo "]}}";
+ else {
+ echo "
";
+ echo "
";
+
+ echo "";
+ if ($page > 1)
+ echo " ";
+ echo " | ";
+ if ($num == $itemsPerPage)
+ echo " ";
+ echo " |
";
+ }
+}
+
+$result->free();
+$mysqli->close();
+?>
\ No newline at end of file
diff --git a/diylc-server-api/v1/testUpload.html b/diylc-server-api/v1/testUpload.html
new file mode 100644
index 00000000..29fe3daa
--- /dev/null
+++ b/diylc-server-api/v1/testUpload.html
@@ -0,0 +1,27 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/diylc-server-api/v1/upload.php b/diylc-server-api/v1/upload.php
new file mode 100644
index 00000000..84093818
--- /dev/null
+++ b/diylc-server-api/v1/upload.php
@@ -0,0 +1,134 @@
+ 100000) {
+ echo "{\"string\":Thumbnail file is too big.}";
+ exit;
+}
+if ($projectFile['size'] > 10000000) {
+ echo "{\"string\":Project file is too big.}";
+ exit;
+}
+if (getimagesize($thumbnailFile['tmp_name']) == false) {
+ echo "{\"string\":Thumbnail image is not valid.}";
+ 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"];
+
+ // Find the right category
+ $sql = "
+ SELECT category_id
+ FROM diylc_category
+ WHERE LOWER(name) = LOWER(\"".addslashes($category)."\")";
+
+ if (!$result = $mysqli->query($sql)) {
+ echo "{\"string\":Error while determining the category.}";
+ exit;
+ }
+
+ if ($row = $result->fetch_assoc()) {
+ $categoryId = $row["category_id"];
+
+ // Insert into the database
+ $sql= "
+ INSERT INTO diylc_project (name, description, category_id, owner_user_id, diylc_version, keywords, uploaded_on, last_update)
+ VALUES (\"".$projectName."\",\"".$description."\",".$categoryId.",".$userId.",\"".$diylcVersion."\",\"".$keywords."\",now(),now())";
+
+ if (!$result = $mysqli->query($sql)) {
+ echo "{\"string\":Error while uploading the project into the database.}";
+ exit;
+ } else {
+ $projectId = $mysqli->insert_id;
+ // Move the uploaded files
+ if (move_uploaded_file($thumbnailFile['tmp_name'], '/home/diyfever/public_html/diylc/thumbnails/'.$projectId.".png") and
+ move_uploaded_file($projectFile['tmp_name'], '/home/diyfever/public_html/diylc/uploads/'.$projectId.".diy"))
+ echo "{\"string\":Success}";
+ else {
+ // delete the entry if we couldn't move the files
+ $sql="DELETE diylc_project WHERE project_id=".$projectId;
+ $mysqli->query($sql);
+ echo "{\"string\":Error processing uploaded files.}";
+ }
+ }
+ } else {
+ echo "{\"string\":Invalid category.}";
+ }
+} else {
+ echo "{\"string\":User is not logged in.}";
+}
+
+$mysqli->close();
+
+?>
\ No newline at end of file