>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
include_once('db.php');
include_once('files.php');
// If you experience problem with slashes in searches you may need 'AllowEncodedSlashes NoDecode' in your Apache config (outside of . More info at https://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes )
$words=explode(' ', urldecode($path[3]));
$order=$path[4]; // TODO: Test (at time of writing there was only one 'thing')
$count=(int)$path[5];
$skip=(int)$path[6];
if(!$count){$count=10;}
switch($order)
{
case 'alpha': $order='name asc'; break;
case 'old': $order='posted asc'; break;
case 'new':
default: $order='posted desc'; break;
}
// Find quotes and combine into one "word"
$qstart=false;
for($i=0; $i$row['thingid'],
'name'=>$row['name'],
'description'=>$row['description'],
'date'=>$row['posted']);
$user=$row['user'];
// Grab preview from the chosen file, or the first file if none is chosen for preview
$res2=mysqli_query($db, 'select name, hash from files where thing='.(int)$row['id'].' order by preview desc limit 1');
$row=mysqli_fetch_assoc($res2);
$thing['preview']=getpreview($row['name'], $row['hash']);
// Designer
$res2=mysqli_query($db, 'select displayname, name from users where id='.$user);
$row=mysqli_fetch_assoc($res2);
$thing['by']=$row;
$obj[]=$thing;
}
print(json_encode($obj));
?>