function createChessBoard() { $color_array = array(); $color = 1; for ($row = 0; $row < 8; $row++) { $color_array[$row] = array(); for ($col = 0; $col < 8; $col++) { // push each color onto each column of the row array_push($color_array[$row], $color); $color = switchColor($color); } // switch after every row, since you want each row to alternate colors $color = switchColor($color); } $html = twig('/twig', 'board.html', array('color_array' => $color_array)); return $html; }
/** * Sends compiled view * @param string $tpl_name Name of the template (in "dot" notation) * @param array $data Array containing your data; empty by default * @param integer $status_code HTTP status code for the response; 200 by default */ function view($tpl_name, $data = [], $status_code = 200) { $response = new HTTP\Response(); $response->setStatus($status_code); $response->setBody(twig()->render($tpl_name, $data)); HTTP\Sapi::sendResponse($response); }
public function index() { return twig('contact.html'); }
<?php /** * @Product: NanoCore * @Author: Maxim P. */ $twig = twig(); // Connection information $database = json_decode(base64_decode(urldecode(get('s'))), true); // SQL File $sql = ROOT . S . 'install' . S . 'install.sql'; // Save form if (isset($_POST['import'])) { if (!@mysql_connect($database['host'], $database['user'], $database['password']) || !@mysql_select_db($database['name'])) { $twig->addGlobal('error', 'Connection to database failed. ' . mysql_error()); } else { mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"); $status = $errors = []; $install = explode(';', file_get_contents($sql)); $status['total'] = count($install); $status['success'] = 0; foreach ($install as $query) { if (!@mysql_query(trim($query))) { $errors[] = ['query' => nl2br($query), 'errno' => mysql_errno(), 'error' => mysql_error()]; } else { $status['success'] += 1; } } $status['result'] = round($status['success'] / $status['total'] * 100, 2); $twig->addGlobal('errors', $errors); $twig->addGlobal('status', $status);