session_start();
include_once dirname(__FILE__)."/../scripts/php/db_connection.php";
?>
$my_metadata = array(
"author" => "https://www.the3rdSequence.com/"
);
function setMetadata($id,$data){
$cwd = getcwd();
chdir(dirname(__FILE__)."/../../");
$imagick = new Imagick();
$imagick->readImage("data/textures/".$id."/thumb.jpg");
foreach($data as $key => $value){
$imagick->setImageProperty($key, $value);
print($imagick->getImageProperty($key));
}
chdir($cwd);
}
function GetTexturesByQuery($query){
global $mysqli;
$ids = array();
$queries = explode(" ",$query);
foreach($queries as $query){
$q = "%".$query."%";
$stmt = $mysqli->prepare("SELECT id FROM texdb_textures WHERE name LIKE ? AND id <= 260");
$stmt->bind_param("s",$q);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$ids[] = $id;
}
$stmt->close();
$stmt = $mysqli->prepare("SELECT ST.id_texture FROM texdb_tags T, texdb_textures_tags ST WHERE T.id = ST.id_tag AND T.tag LIKE ?");
$stmt->bind_param("s",$q);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$ids[] = $id;
}
$stmt->close();
}
$ids = array_unique($ids);
return CleanResults($ids);
}
function GetTexturesByTag($id_tag){
global $mysqli;
$ids = array();
$stmt = $mysqli->prepare("SELECT id FROM texdb_textures S, texdb_textures_tags ST WHERE S.id = ST.id_texture AND ST.id_tag = ?");
$stmt->bind_param("i",$id_tag);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$ids[] = $id;
}
$stmt->close();
return CleanResults($ids);
}
function GetTexturesById($id_texture){
global $mysqli;
$ids = array();
$stmt = $mysqli->prepare("SELECT id FROM texdb_textures WHERE id = ?");
$stmt->bind_param("i",$id_texture);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$ids[] = $id;
}
$stmt->close();
return CleanResults($ids);
}
function GetTexturesByName($name){
global $mysqli;
$ids = array();
$stmt = $mysqli->prepare("SELECT id FROM texdb_textures WHERE name = ? AND id <= 260");
$stmt->bind_param("s",$name);
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$ids[] = $id;
}
$stmt->close();
return CleanResults($ids);
}
function GetTextures(){
global $mysqli;
$ids = array();
$stmt = $mysqli->prepare("SELECT id FROM texdb_textures WHERE id <= 260 ORDER BY id DESC");
$stmt->execute();
$stmt->bind_result($id);
while($stmt->fetch()){
$ids[] = $id;
}
$stmt->close();
return CleanResults($ids);
}
function CleanResults($array){
$tmp = array();
foreach($array as $element){
$tmp[] = $element;
}
return $tmp;
}
function GetTextureInfo($id){
global $mysqli;
$texture = array();
$stmt = $mysqli->prepare("SELECT id, name FROM texdb_textures WHERE id = ?");
$stmt->bind_param("i",$id);
$stmt->execute();
$stmt->bind_result($texture_id, $texture_name);
while($stmt->fetch()){
$texture['id'] = $texture_id;
$texture['name'] = $texture_name;
}
$stmt->close();
$tags = array();
$stmt = $mysqli->prepare("SELECT id, tag FROM texdb_tags T, texdb_textures_tags ST WHERE T.id = ST.id_tag AND ST.id_texture = ?");
$stmt->bind_param("i",$texture['id']);
$stmt->execute();
$stmt->bind_result($id, $tag);
while($stmt->fetch()){
$tags[] = array(
'id' => $id,
'tag' => $tag
);
}
$stmt->close();
$texture['tags'] = $tags;
$cwd = getcwd();
chdir(dirname(__FILE__)."/../../");
$texture['files'] = array();
$glob = glob("data/textures/".$texture['id']."/".$texture['id'].".*");
if(count($glob)>0){
foreach($glob as $g){
if(strpos($g,"thumb") === false){
$filePath = $g;
$fileExt = strrchr($g, '.');
$texture['files'][] = array(
'file' => $filePath,
'ext' => $fileExt
);
}
}
}
$glob = glob("data/textures/".$texture['id']."/thumb.jpg");
if(count($glob)>0){
foreach($glob as $g){
$texture['thumbnail'] = $g;
}
}
chdir($cwd);
return $texture;
}
?>
Warning: Undefined variable $mysqli in /web/htdocs/www.the3rdsequence.com/home/texturedb/texture/index.php on line 6
Fatal error: Uncaught Error: Call to a member function prepare() on null in /web/htdocs/www.the3rdsequence.com/home/texturedb/texture/index.php:6
Stack trace:
#0 {main}
thrown in /web/htdocs/www.the3rdsequence.com/home/texturedb/texture/index.php on line 6