Exemplo n.º 1
0
function M($table_name)
{
    $db = new Database("localhost", 3306, "messengershop", "root", "");
    $prefix = "";
    //定义表前缀
    return $db->table($prefix . $table_name);
}
Exemplo n.º 2
0
 private function database($name)
 {
     if ($this->db) {
         return $this->db;
     }
     $this->db = Database::table($name);
     return $this->db;
 }
Exemplo n.º 3
0
 public static function init_connection($host, $db, $table, $username, $password)
 {
     self::$host = $host;
     self::$db = $db;
     self::$table = $table;
     self::$user = $username;
     self::$password = $password;
     self::$mysqli = new mysqli(self::$host, self::$user, self::$password, self::$db);
     return self::$mysqli->ping();
 }
Exemplo n.º 4
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$institutions_records = $gui->select('institutions');
$places_records = $gui->joinThree('institutions', 'places_for_institutions', 'places', 'city', 'institution_id', 'place_id');
if (!empty($_POST)) {
    $post_institution = $_POST['institution'];
    $db->table('institutions');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['institution' => ['required' => true]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        $insert_institution = ['institution' => $post_institution];
        if ($db->insert($insert_institution)) {
            $last_id = $db->lastID();
            if ($_POST['place']) {
                $post_place = $_POST['place'];
                for ($m = 0; $m < count($post_place); $m++) {
                    $insert_place = ['place_id' => $post_place[$m], 'institution_id' => $last_id];
                    $db->table('places_for_institutions')->insert($insert_place);
                }
            }
            header('Location: create_institutions.php');
Exemplo n.º 5
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$exhibition_types_records = $gui->select('exhibition_types');
if (!empty($_POST)) {
    $db->table('exhibition_types');
    if ($db->delete($_POST['id'])) {
        header('Location: delete_exhibition_types.php');
        die;
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Delete exhibition types</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
	</head>
	<body style="font-family:Helvetica;font-size:12px">
		<h3>Exhibition types</h3>
		<h4>Delete exhibition type</h4>

		<?php 
Exemplo n.º 6
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$media_types_records = $gui->select('media_types');
if (!empty($_POST)) {
    $db->table('media_types');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['media_type' => ['required' => true]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_media_types.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create media types</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
Exemplo n.º 7
0
<?php

/**
 * Connect to database
 */
$db = new Database();
/**
 * Select all rows from table users
 */
$rows = $db->table('users')->select();
/**
 * Select all rows from table users, where user_id = 1, or user id = 5
 */
$rows = $db->table('users')->where(null, 'user_id', '=', 1)->where('or', 'user_id', '=', 5) - select();
/**
 * Insert new row to table quz, foo = hello, and bar = world
 */
$db->table('quz')->fields('foo', 'bar')->values('hello', 'world')->insert();
/**
 * Delete a row from table quz where foo = hello and bar = world
 */
$db->table('quz')->where('', 'foo', '=', 'hello')->where('and', 'bar', '=', 'world')->delete();
Exemplo n.º 8
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$institutions_records = $gui->select('institutions');
$places_records = $gui->joinThree('institutions', 'places_for_institutions', 'places', 'city', 'institution_id', 'place_id');
if (!empty($_POST)) {
    $db->table('institutions');
    if ($db->delete($_POST['id'])) {
        $db->table('places_for_institutions');
        $db->deleteWhich($_POST['id'], 'institution_id');
        $db->table('institutions_for_collections');
        $db->deleteWhich($_POST['id'], 'institution_id');
        $db->table('institutions_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'institution_id');
        $db->table('institutions_for_prizes');
        $db->deleteWhich($_POST['id'], 'institution_id');
        header('Location: delete_institutions.php');
        die;
    }
}
?>

<!doctype html>
	<html>
Exemplo n.º 9
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$spaces_records = $gui->select('spaces');
$places_records = $gui->joinThree('spaces', 'places_for_spaces', 'places', 'city', 'space_id', 'place_id');
if (!empty($_POST)) {
    $post_space = $_POST['space'];
    $db->table('spaces');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['space' => ['required' => true]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        $insert_space = ['space' => $post_space];
        if ($db->insert($insert_space)) {
            $last_id = $db->lastID();
            if ($_POST['place']) {
                $post_place = $_POST['place'];
                for ($m = 0; $m < count($post_place); $m++) {
                    $insert_place = ['place_id' => $post_place[$m], 'space_id' => $last_id];
                    $db->table('places_for_spaces')->insert($insert_place);
                }
            }
            header('Location: create_spaces.php');
Exemplo n.º 10
0
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$exhibitions_records = $gui->select('exhibitions');
$exhibition_types_records = $gui->rightJoin('type', 'exhibition_types', 'exhibition_type');
$exhibition_kinds_records = $gui->rightJoin('kind', 'exhibition_kinds', 'exhibition_kind');
$events_records = $gui->joinThree('exhibitions', 'events_for_exhibitions', 'events', 'event', 'exhibition_id', 'event_id');
$spaces_records = $gui->joinThree('exhibitions', 'spaces_for_exhibitions', 'spaces', 'space', 'exhibition_id', 'space_id');
$places_records = $gui->joinThree('exhibitions', 'places_for_exhibitions', 'places', 'city', 'exhibition_id', 'place_id');
$projects_records = $gui->joinThree('exhibitions', 'exhibitions_for_projects', 'projects', 'project', 'exhibition_id', 'project_id');
$institutions_records = $gui->joinThree('exhibitions', 'institutions_for_exhibitions', 'institutions', 'institution', 'exhibition_id', 'institution_id');
$people_org_records = $gui->joinThree('exhibitions', 'people_for_exhibitions_org', 'people', 'name', 'exhibition_id', 'person_id');
$people_curatorship_records = $gui->joinThree('exhibitions', 'people_for_exhibitions_curatorship', 'people', 'name', 'exhibition_id', 'person_id');
$people_participants_records = $gui->joinThree('exhibitions', 'people_for_exhibitions_participants', 'people', 'name', 'exhibition_id', 'person_id');
if (!empty($_POST)) {
    $db->table('exhibitions');
    if ($db->delete($_POST['id'])) {
        $db->table('events_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
        $db->table('spaces_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
        $db->table('places_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
        $db->table('projects_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
        $db->table('institutions_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
        $db->table('people_for_exhibitions_org');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
        $db->table('people_for_exhibitions_curatorship');
        $db->deleteWhich($_POST['id'], 'exhibition_id');
Exemplo n.º 11
0
require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$works_records = $gui->select('works');
$media_records = $gui->joinThree('works', 'media_for_works', 'media', 'media_title', 'work_id', 'media_id');
$categories_records = $gui->joinThree('works', 'categories_for_works', 'categories', 'category', 'work_id', 'category_id');
$techniques_records = $gui->joinThree('works', 'techniques_for_works', 'techniques', 'technique', 'work_id', 'technique_id');
$technologies_records = $gui->joinThree('works', 'technologies_for_works', 'technologies', 'technology', 'work_id', 'technology_id');
if (!empty($_POST)) {
    $db->table('works');
    if ($db->delete($_POST['id'])) {
        $db->table('media_for_works');
        $db->deleteWhich($_POST['id'], 'work_id');
        $db->table('categories_for_works');
        $db->deleteWhich($_POST['id'], 'work_id');
        $db->table('techniques_for_works');
        $db->deleteWhich($_POST['id'], 'work_id');
        $db->table('technologies_for_works');
        $db->deleteWhich($_POST['id'], 'work_id');
        $db->table('works_for_projects');
        $db->deleteWhich($_POST['id'], 'work_id');
        header('Location: delete_works.php');
        die;
    }
}
Exemplo n.º 12
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$companies_records = $gui->select('companies');
if (!empty($_POST)) {
    $db->table('companies');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['company' => ['required' => true], 'website' => ['required' => false], 'description' => ['required' => false], 'year_start' => ['required' => true], 'year_end' => ['required' => false]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        echo '<pre>', print_r($_POST), '</pre>';
        if ($db->insert($_POST)) {
            header('Location: create_companies.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create companies</title>
Exemplo n.º 13
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$categories_records = $gui->select('categories');
if (!empty($_POST)) {
    $db->table('categories');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['category' => ['required' => true, 'unique' => 'categories']]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_categories.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create categories</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
Exemplo n.º 14
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$people_records = $gui->select('people');
if (!empty($_POST)) {
    $db->table('people');
    if ($db->delete($_POST['id'])) {
        $db->table('people_for_exhibitions_curatorship');
        $db->deleteWhich($_POST['id'], 'person_id');
        $db->table('people_for_exhibitions_org');
        $db->deleteWhich($_POST['id'], 'person_id');
        $db->table('people_for_exhibitions_participants');
        $db->deleteWhich($_POST['id'], 'person_id');
        $db->table('people_for_projects_author');
        $db->deleteWhich($_POST['id'], 'person_id');
        $db->table('people_for_projects_collaboration');
        $db->deleteWhich($_POST['id'], 'person_id');
        header('Location: delete_people.php');
        die;
    }
}
?>

<!doctype html>
Exemplo n.º 15
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$spaces_records = $gui->select('spaces');
$places_records = $gui->joinThree('spaces', 'places_for_spaces', 'places', 'city', 'space_id', 'place_id');
if (!empty($_POST)) {
    $db->table('spaces');
    if ($db->delete($_POST['id'])) {
        $db->table('places_for_spaces');
        $db->deleteWhich($_POST['id'], 'space_id');
        $db->table('spaces_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'space_id');
        header('Location: delete_spaces.php');
        die;
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Delete spaces</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
	</head>
Exemplo n.º 16
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$categories_records = $gui->select('categories');
if (!empty($_POST)) {
    // echo '<pre>',print_r($_POST['id']),'</pre>';
    $db->table('categories');
    if ($db->delete($_POST['id'])) {
        $db->table('categories_for_projects');
        $db->deleteWhich($_POST['id'], 'category_id');
        $db->table('categories_for_works');
        $db->deleteWhich($_POST['id'], 'category_id');
        header('Location: delete_categories.php');
        die;
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Delete categories</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
	</head>
Exemplo n.º 17
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$exhibition_kinds_records = $gui->select('exhibition_kinds');
if (!empty($_POST)) {
    $db->table('exhibition_kinds');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['exhibition_kind' => ['required' => true]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_exhibition_kinds.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create exhibition kinds</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
Exemplo n.º 18
0
$project_types_records = $gui->rightJoin('type', 'project_types', 'given_name');
$categories_records = $gui->joinThree('projects', 'categories_for_projects', 'categories', 'category', 'project_id', 'category_id');
$companies_records = $gui->joinThree('projects', 'companies_for_projects', 'companies', 'company', 'project_id', 'company_id');
$techniques_records = $gui->joinThree('projects', 'techniques_for_projects', 'techniques', 'technique', 'project_id', 'technique_id');
$technologies_records = $gui->joinThree('projects', 'technologies_for_projects', 'technologies', 'technology', 'project_id', 'technology_id');
$places_records = $gui->joinThree('projects', 'places_for_projects', 'places', 'city', 'project_id', 'place_id');
$media_records = $gui->joinThree('projects', 'media_for_projects', 'media', 'media_title', 'project_id', 'media_id');
$works_records = $gui->joinThree('projects', 'works_for_projects', 'works', 'work_title', 'project_id', 'work_id');
$functions_records = $gui->joinThree('projects', 'functions_for_projects', 'functions', 'function', 'project_id', 'function_id');
$people_authors_records = $gui->joinThree('projects', 'people_for_projects_author', 'people', 'name', 'project_id', 'person_id');
$people_collaborators_records = $gui->joinThree('projects', 'people_for_projects_collaboration', 'people', 'name', 'project_id', 'person_id');
$exhibitions_records = $gui->joinThree('projects', 'exhibitions_for_projects', 'exhibitions', 'exhibition', 'project_id', 'exhibition_id');
$prizes_records = $gui->joinThree('projects', 'prizes_for_projects', 'prizes', 'name', 'project_id', 'prize_id');
$collections_records = $gui->joinThree('projects', 'collections_for_projects', 'collections', 'collection', 'project_id', 'collection_id');
if (!empty($_POST)) {
    $db->table('projects');
    if ($db->delete($_POST['id'])) {
        $db->table('categories_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
        $db->table('companies_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
        $db->table('techniques_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
        $db->table('technologies_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
        $db->table('places_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
        $db->table('media_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
        $db->table('works_for_projects');
        $db->deleteWhich($_POST['id'], 'project_id');
Exemplo n.º 19
0
 /**
  * @covers Lazer\Classes\Database::__isset
  */
 public function testIsset()
 {
     $table = $this->object->table('users')->find(1);
     $this->assertTrue(isset($table->name));
     $this->assertFalse(isset($table->someField));
 }
Exemplo n.º 20
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$collection_types_records = $gui->select('collection_types');
if (!empty($_POST)) {
    $db->table('collection_types');
    if ($db->delete($_POST['id'])) {
        header('Location: delete_collection_types.php');
        die;
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Delete collection types</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
	</head>
	<body style="font-family:Helvetica;font-size:12px">
		<h3>Collection types</h3>
		<h4>Delete collection type</h4>

		<?php 
Exemplo n.º 21
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$functions_records = $gui->select('functions');
if (!empty($_POST)) {
    $db->table('functions');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['function' => ['required' => true, 'unique' => 'functions']]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_functions.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create functions</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
Exemplo n.º 22
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$technologies_records = $gui->select('technologies');
if (!empty($_POST)) {
    $db->table('technologies');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['technology' => ['required' => true]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_technologies.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create technologies</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
Exemplo n.º 23
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$techniques_records = $gui->select('techniques');
if (!empty($_POST)) {
    $db->table('techniques');
    if ($db->delete($_POST['id'])) {
        $db->table('techniques_for_projects');
        $db->deleteWhich($_POST['id'], 'technique_id');
        $db->table('techniques_for_works');
        $db->deleteWhich($_POST['id'], 'technique_id');
        header('Location: delete_techniques.php');
        die;
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Delete techniques</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
	</head>
	<body style="font-family:Helvetica;font-size:12px">
Exemplo n.º 24
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$categories_records = array();
if (!empty($_POST)) {
    $db->table('categories');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['category' => ['required' => true, 'unique' => 'categories']]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_categories.php');
            die;
        }
    }
}
if ($results = $db->table('categories')->select()) {
    foreach ($results as $row) {
        $categories_records[] = $row;
    }
}
?>
Exemplo n.º 25
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$places_records = $gui->select('places');
if (!empty($_POST)) {
    $db->table('places');
    if ($db->delete($_POST['id'])) {
        $db->table('places_for_collections');
        $db->deleteWhich($_POST['id'], 'place_id');
        $db->table('places_for_events');
        $db->deleteWhich($_POST['id'], 'place_id');
        $db->table('places_for_exhibitions');
        $db->deleteWhich($_POST['id'], 'place_id');
        $db->table('places_for_institutions');
        $db->deleteWhich($_POST['id'], 'place_id');
        $db->table('places_for_prizes');
        $db->deleteWhich($_POST['id'], 'place_id');
        $db->table('places_for_projects');
        $db->deleteWhich($_POST['id'], 'place_id');
        $db->table('places_for_spaces');
        $db->deleteWhich($_POST['id'], 'place_id');
        header('Location: delete_places.php');
        die;
    }
Exemplo n.º 26
0
require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$works_records = $gui->select('works');
$media_records = $gui->joinThree('works', 'media_for_works', 'media', 'media_title', 'work_id', 'media_id');
$categories_records = $gui->joinThree('works', 'categories_for_works', 'categories', 'category', 'work_id', 'category_id');
$techniques_records = $gui->joinThree('works', 'techniques_for_works', 'techniques', 'technique', 'work_id', 'technique_id');
$technologies_records = $gui->joinThree('works', 'technologies_for_works', 'technologies', 'technology', 'work_id', 'technology_id');
if (!empty($_POST)) {
    $post_works = array_slice($_POST, 0, 2);
    $db->table('works');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($post_works, ['work_title' => ['required' => true], 'work_description' => ['required' => false]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($post_works)) {
            $last_id = $db->lastID();
            if ($_POST['media']) {
                $post_media = $_POST['media'];
                for ($m = 0; $m < count($post_media); $m++) {
                    $insert_media = ['media_id' => $post_media[$m], 'work_id' => $last_id];
                    $db->table('media_for_works')->insert($insert_media);
                }
            }
            if ($_POST['category']) {
Exemplo n.º 27
0
 /**
  ---------------------------------------------------------------------------------------------------------------------------
 *  Build html FORM based on defined active control
 *  @param $ob_controls     array   sets of array value in format : $class_field_name => array([label value] ['html string'], [custom field message])
 *                                  this array value can be generated from add[Object] method in this class
 *                                  or by user define. 
 *  @param  $template       string  [columnar | tabular] style that is going to be used as list object style
 *                                  this parameter also can be valued with user defined template (use full dir path in this case) 
 *  @access public
 *  @return string  Returns a string with form and control formated
 *  ex : $this->render(
 *          array(
 *              'hidden'    => array('hidden id',  '<input type="hidden" value="123" name="hidden_id" id="hidden_id" />'),
 *              'user_name' => array('Nama User',  '<input type="text" name="user" id="user" />'),
 *              'password'  => array('Kata Sandi', '<input type="password" name="pwd" id="pwd" />'),
 *          ),
 *          'columnar',
 *          false
 *       )
  ---------------------------------------------------------------------------------------------------------------------------
 */
 function render($ob_controls, $template = '', $return = false)
 {
     $frm = '';
     //build controls based on default style [columnar | tabular]
     if ($template == 'columnar' || $template == 'tabular') {
         //set break for columnar style
         $break = $template == 'columnar' ? '<br class="clear" />' : '';
         //wrap all defined object in div container with
         foreach ($ob_controls as $field => $ob) {
             //set label value for each object
             $lbl_name = isset($ob[0]) ? $ob[0] : 'Field Not defined';
             //set object string
             $ob_string = isset($ob[1]) ? $ob[1] : 'Object Not defined';
             //set custom message
             $field_msg = isset($ob[2]) ? '<br /><span class="mdkfield_msg"><b>&raquo;</b> ' . $ob[2] . '</span>' : false;
             //cek if object is hidden value
             $hidden = $field == "hidden" ? ' hidden' : '';
             //wrap every single controller on a control container
             $frm .= '<div class="mdkrow' . $hidden . '">
                         <div class="mdklabel ' . $field . '">' . $lbl_name . $field_msg . '</div>
                         ' . $break . $ob_string . '
                      </div>';
         }
     } else {
         // build controls based on user defined template and style
         //check form template, if not found then trigger error
         if (file_exists($template)) {
             //set template into variabel as a string
             $frm = file_get_contents($template);
             $guide = array();
             //var_dump(isset($this->form_properties['guide']) && $this->form_properties['guide'] === TRUE);
             if (isset($this->form_properties['guide']) && $this->form_properties['guide'] === TRUE) {
                 $db = new Database();
                 $data = $db->table('mdk_guide')->where('form', strtolower($this->form_properties['name']))->get();
                 $guides = array();
                 foreach ($data as $d) {
                     $guides[$d['field']] = $d['content'];
                 }
                 /*
                  echo '<pre>';
                  var_dump($guides);
                  echo '</pre>';
                 */
             }
             //insert all object control into template
             foreach ($ob_controls as $field => $ob) {
                 //set label value for each object
                 $lbl_name = isset($ob[0]) ? $ob[0] : 'Field Not defined';
                 //set object string
                 $ob_string = isset($ob[1]) ? $ob[1] : 'Object Not defined';
                 //set custom message
                 $field_msg = isset($ob[2]) ? '<br /><span class="mdkfield_msg"><b>&raquo;</b> ' . $ob[2] . '</span>' : false;
                 //set guide
                 //$guide_msg  = (isset($guides[$field])) ? '<br /><span class="mdkguide_msg"><b>&raquo;</b> '.$guides[$field].'</span>' : false;
                 //replace every keyword on template with object
                 $frm = str_replace('{LABEL:' . strtoupper($field) . '}', $lbl_name, $frm);
                 $frm = str_replace('{OB:' . strtoupper($field) . '}', $ob_string, $frm);
                 $frm = str_replace('{NOTIF:' . strtoupper($field) . '}', $field_msg, $frm);
                 //$frm   = str_replace('{guide:'.$field.'}', $guide_msg, $frm);
             }
         } else {
             echo $template . ' not found !';
             //trigger_error("Custom form template cannot be found in : ".$template);
             exit;
         }
     }
     //include necessary css
     $css = '';
     if (is_array($this->form_properties['css']) && count($this->form_properties['css']) > 0) {
         foreach ($this->form_properties['css'] as $c) {
             $css .= '<link rel="stylesheet" type="text/css href="' . $c . '" />';
         }
     }
     //include necessary js
     $js = '';
     if (is_array($this->form_properties['js']) && count($this->form_properties['js']) > 0) {
         foreach ($this->form_properties['js'] as $j) {
             $js .= '<script type="text/javascript" src="' . $j . '"></script>';
         }
     }
     /* added to support adding css class for form */
     $frm_cls = isset($this->form_properties['class']) ? 'class="' . $this->form_properties['class'] . '"' : '';
     // start generating the output
     $output = $css . $js . $this->gen_css() . '<form ' . 'name="' . $this->form_properties['name'] . '" ' . 'id="' . $this->form_properties['name'] . '" ' . 'action="' . htmlspecialchars($this->form_properties['action']) . '" ' . 'method="' . strtolower($this->form_properties['method']) . '" 
         enctype = "multipart/form-data"' . $frm_cls . '>' . $frm . '</form>';
     if ($return) {
         return $output;
     } else {
         echo $output;
     }
 }
Exemplo n.º 28
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$technologies_records = $gui->select('technologies');
if (!empty($_POST)) {
    $db->table('technologies');
    if ($db->delete($_POST['id'])) {
        $db->table('technologies_for_projects');
        $db->deleteWhich($_POST['id'], 'technology_id');
        $db->table('technologies_for_works');
        $db->deleteWhich($_POST['id'], 'technology_id');
        header('Location: delete_technologies.php');
        die;
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Delete technologies</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">
	</head>
	<body style="font-family:Helvetica;font-size:12px">
Exemplo n.º 29
0
 /**
  * Process query with joined data
  * @param object $row One row of data
  * @return Database
  */
 protected function join($row)
 {
     $keys['local'] = $this->keys['local'];
     $keys['foreign'] = $this->keys['foreign'];
     if ($this->relationType == 'hasAndBelongsToMany') {
         $join = Database::table($this->getJunction())->groupBy($this->tables['local'] . '_id')->where($this->tables['local'] . '_id', '=', $row->{$keys['local']})->findAll()->asArray(null, $this->tables['foreign'] . '_id');
         if (empty($join)) {
             return array();
         }
         return Database::table($this->tables['foreign'])->where($keys['foreign'], 'IN', $join[$row->{$keys['local']}]);
     }
     return Database::table($this->tables['foreign'])->where($keys['foreign'], '=', $row->{$keys['local']});
 }
Exemplo n.º 30
0
<?php

require '../../classes/Database.php';
require '../../classes/Validator.php';
require '../../classes/ErrorHandler.php';
require '../../classes/AdminGui.php';
require '../../functions/security.php';
$errorHandler = new ErrorHandler();
$db = new Database();
$gui = new AdminGui($db);
$people_records = $gui->select('people');
if (!empty($_POST)) {
    $db->table('people');
    $validator = new Validator($db, $errorHandler);
    $validation = $validator->check($_POST, ['name' => ['required' => true], 'website' => ['required' => false], 'description' => ['required' => false]]);
    if ($validation->fails()) {
        echo '<pre>', print_r($validation->errors()->all()), '</pre>';
    } else {
        if ($db->insert($_POST)) {
            header('Location: create_people.php');
            die;
        }
    }
}
?>

<!doctype html>
	<html>
	<head>
		<title>Create people</title>
		<link rel="stylesheet" type="text/css" href="../../public/front/css/admin.css">