code
stringlengths
1
2.01M
language
stringclasses
1 value
<?php class DBConfig { protected static $db_host = "localhost"; protected static $db_username = "root"; protected static $db_password = ""; protected static $db_dbname = "0admin"; //protected static $db_host = "localhost"; //protected static $db_username = "diegolaprida_ujs"; //protected static $db_password = "Jesa2013"; //protected static $db_dbname = "diegolaprida_dbjs"; } ?>
PHP
<?php // Tipo accidente $categoriasList = array(); $categoriasList[] = array("key" => "DEPORTE", "value" => "Deporte", "color" => "#1C7682"); $categoriasList[] = array("key" => "POLITICA", "value" => "Politica", "color" => "#6A88A3"); $categoriasList[] = array("key" => "SOCIEDAD", "value" => "Sociedad", "color" => "#86C2AB"); $categoriasList[] = array("key" => "CULTURA", "value" => "Cultura", "color" => "#A37955"); $categoriasList[] = array("key" => "POLICIAL", "value" => "Policial", "color" => "#373F99"); ?>
PHP
<?php require_once('conf/DBConfig.php'); class DBConnection extends DBConfig{ private static $instance; private function __construct(){ self::$instance = mysql_connect(parent::$db_host, parent::$db_username, parent::$db_password) or DIE('Error en la conexion'); $db = mysql_select_db(parent::$db_dbname, self::$instance) or DIE("unable to select DB"); } public static function getInstance(){ if(empty(self::$instance)){ self::$instance = new DBConnection(); } return self::$instance; } } ?>
PHP
<?php require_once('include/header.php'); require_once('vo/AvisosVO.php'); require_once('search/AvisosSearchCriteria.php'); require_once('logic/AvisosLogic.php'); require('conf/configuration.php'); $logic = new AvisosLogic($_POST); // Ordenamiento if($_GET[order] == "asc") $order= "desc"; else if($_GET[order] == "desc") $order= "asc"; else $order= "desc"; if (!isset($_GET["orderby"])) $orderby = "Fecha"; else $orderby = $_GET["orderby"]; $smarty->assign("orderby", $orderby); $smarty->assign("order", $order); // Seteo el searchcriteria para mostrar la tabla con todos los resultados segun el filtro. (sin paginacion) $avisosSearchCriteria = new AvisosSearchCriteria(); $avisosSearchCriteria->setOrderby($orderby); $avisosSearchCriteria->setOrder($order); $avisosSearchCriteria->setSearch($_GET["search"]); $avisosSearchCriteria->setInicio(1); $avisosSearchCriteria->setFin(null); // Controller $action = $_GET["action"]; if ($action == null){ $action = $_POST["action"]; } switch ($action){ case "save": $result = $logic->save($_POST); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al guardar los cambios del Registro de Avisos"); else $smarty->assign("message", "El Registro de Avisosha sido actualizado"); break; case "add": $smarty->assign("detailPage","avisosForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "update": $id = $_GET["id"]; if ($id != null){ $avisos = $logic->get($id); $smarty->assign("avisos", $avisos); } $smarty->assign("detailPage","avisosForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "delete": $result = $logic->delete($_POST["id"]); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al eliminar el Registro de "); else $smarty->assign("message", "Se ha eliminado el Registro de "); break; } // Paginador $cantidad = $logic->count($avisosSearchCriteria); $totalItemsPerPage=10; if (isset($_GET["entradas"])) $totalItemsPerPage=$_GET["entradas"]; $totalPages = ceil($cantidad / $totalItemsPerPage); $smarty->assign("totalPages", $totalPages); $smarty->assign("totalItemsPerPage", $totalItemsPerPage); $page = $_GET[page]; if (!$page) { $start = 0; $page = 1; $smarty->assign("page", $page); } else $start = ($page - 1) * $totalItemsPerPage; $smarty->assign("page", $page); // Obtengo solo los registros de la pagina actual. $avisosSearchCriteria->setInicio($start); $avisosSearchCriteria->setOrderby($orderby); $avisosSearchCriteria->setOrder($order); $avisosSearchCriteria->setFin($totalItemsPerPage); $avisos = $logic->find($avisosSearchCriteria); $smarty->assign("allParams", CommonPlugin::getParamsAsString($_GET)); $smarty->assign("cantidad", $cantidad); $smarty->assign("search", $_GET["search"]); $smarty->assign("avisos", $avisos); $smarty->assign("detailPage", "avisos.tpl"); $smarty->display("admin_generic.tpl"); ?>
PHP
<?php /** * When a page is called, the page controller is run before any output is made. * The controller's job is to transform the HTTP request into business objects, * then call the approriate logic and prepare the objects used to display the response. * * The page logic performs the following steps: * 1. The cmd request parameter is evaluated. * 2. Based on the action other request parameters are evaluated. * 3. Value Objects (or a form object for more complex tasks) are created from the parameters. * 4. The objects are validated and the result is stored in an error array. * 5. The business logic is called with the Value Objects. * 6. Return status (error codes) from the business logic is evaluated. * 7. A redirect to another page is executed if necessary. * 8. All data needed to display the page is collected and made available to the page as variables of the controller. Do not use global variables. * * * @author dintech * */ require_once('include/header.php'); require_once('vo/UsuarioVO.php'); require_once('search/UsuarioSearchCriteria.php'); require_once('logic/UsuariosLogic.php'); require('conf/configuration.php'); $logic = new UsuariosLogic($_POST); $id = $_GET['id']; if ($id != null){ $usuario = $logic->get($id); $smarty->assign('usuario', $usuario); } $action = $_GET['action']; if ($action == null){ $action = $_POST['action']; } switch ($action){ case "add": if ($_POST['sendform']!="1"){ $smarty->display('usuariosAdd.tpl'); exit; } else{ $result = $logic->save($_POST); if ($result == 'error') { $smarty->assign('error', "Ha ocurrido un error al crear el usuario"); } else $smarty->assign('message', "El usuario <b>" . $_POST['username'] . "</b> ha sido creado"); } break; case "update": if ($_POST['sendform']!="1"){ $smarty->display('usuariosUpdate.tpl'); exit; } else{ $result = $logic->save($_POST); if ($result == 'error') { $smarty->assign('error', "Ha ocurrido un error al guardar los cambios del usuario"); } else $smarty->assign('message', "El usuario <b>" . $_POST['username'] . "</b> ha sido actualizado"); } break; case "delete": $result = $logic->delete($_POST['id']); if ($result == 'error') $smarty->assign('error', "Ha ocurrido un error al eliminar el usuario"); else $smarty->assign('message', "Se ha eliminado el usuario"); break; } $usuariosearchCriteria = new UsuarioSearchCriteria(); $usuariosearchCriteria->setOrder("DESC"); $usuariosearchCriteria->setInicio(1); $usuariosearchCriteria->setFin(null); $cantidad = $logic->count($usuariosearchCriteria); // Paginador $totalPages = ceil($cantidad / $totalItemsPerPage); $smarty->assign('totalPages', $totalPages); $smarty->assign('totalItemsPerPage', $totalItemsPerPage); $page = $_GET[page]; if (!$page) { $start = 0; $page = 1; $smarty->assign('page', $page); } else $start = ($page - 1) * $totalItemsPerPage; $smarty->assign('page', $page); $usuariosearchCriteria->setInicio($start); $usuariosearchCriteria->setFin($totalItemsPerPage); $usuarios = $logic->find($usuariosearchCriteria); $smarty->assign('cantidad', $cantidad); $smarty->assign('usuarios', $usuarios); $smarty->display('usuarios.tpl'); ?>
PHP
<?php require_once('include/header.php'); require_once('vo/ClientesVO.php'); require_once('search/ClientesSearchCriteria.php'); require_once('logic/ClientesLogic.php'); require('conf/configuration.php'); $logic = new ClientesLogic($_POST); // Ordenamiento if($_GET[order] == "asc") $order= "desc"; else if($_GET[order] == "desc") $order= "asc"; else $order= "desc"; if (!isset($_GET["orderby"])) $orderby = "Fecha"; else $orderby = $_GET["orderby"]; $smarty->assign("orderby", $orderby); $smarty->assign("order", $order); // Seteo el searchcriteria para mostrar la tabla con todos los resultados segun el filtro. (sin paginacion) $clientesSearchCriteria = new ClientesSearchCriteria(); $clientesSearchCriteria->setOrderby($orderby); $clientesSearchCriteria->setOrder($order); $clientesSearchCriteria->setSearch($_GET["search"]); $clientesSearchCriteria->setInicio(1); $clientesSearchCriteria->setFin(null); // Controller $action = $_GET["action"]; if ($action == null){ $action = $_POST["action"]; } switch ($action){ case "save": $result = $logic->save($_POST); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al guardar los cambios del Registro de Clientes"); else $smarty->assign("message", "El Registro de Clientesha sido actualizado"); break; case "add": $smarty->assign("detailPage","clientesForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "update": $id = $_GET["id"]; if ($id != null){ $clientes = $logic->get($id); $smarty->assign("clientes", $clientes); } $smarty->assign("detailPage","clientesForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "delete": $result = $logic->delete($_POST["id"]); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al eliminar el Registro de "); else $smarty->assign("message", "Se ha eliminado el Registro de "); break; } // Paginador $cantidad = $logic->count($clientesSearchCriteria); $totalItemsPerPage=10; if (isset($_GET["entradas"])) $totalItemsPerPage=$_GET["entradas"]; $totalPages = ceil($cantidad / $totalItemsPerPage); $smarty->assign("totalPages", $totalPages); $smarty->assign("totalItemsPerPage", $totalItemsPerPage); $page = $_GET[page]; if (!$page) { $start = 0; $page = 1; $smarty->assign("page", $page); } else $start = ($page - 1) * $totalItemsPerPage; $smarty->assign("page", $page); // Obtengo solo los registros de la pagina actual. $clientesSearchCriteria->setInicio($start); $clientesSearchCriteria->setOrderby($orderby); $clientesSearchCriteria->setOrder($order); $clientesSearchCriteria->setFin($totalItemsPerPage); $clientes = $logic->find($clientesSearchCriteria); $smarty->assign("allParams", CommonPlugin::getParamsAsString($_GET)); $smarty->assign("cantidad", $cantidad); $smarty->assign("clientes", $clientes); $smarty->assign(search, $_GET["search"]); $smarty->assign("detailPage", "clientes.tpl"); $smarty->display("admin_generic.tpl"); ?>
PHP
<?php /** * When a page is called, the page controller is run before any output is made. * The controller's job is to transform the HTTP request into business objects, * then call the approriate logic and prepare the objects used to display the response. * * The page logic performs the following steps: * 1. The cmd request parameter is evaluated. * 2. Based on the action other request parameters are evaluated. * 3. Value Objects (or a form object for more complex tasks) are created from the parameters. * 4. The objects are validated and the result is stored in an error array. * 5. The business logic is called with the Value Objects. * 6. Return status (error codes) from the business logic is evaluated. * 7. A redirect to another page is executed if necessary. * 8. All data needed to display the page is collected and made available to the page as variables of the controller. Do not use global variables. * * * @author dintech * */ require_once('include/header.php'); require_once('vo/NoticiasVO.php'); require_once('search/NoticiasSearchCriteria.php'); require_once('logic/NoticiasLogic.php'); //require_once('logic/TagsLogic.php'); require_once('plugin/CommonPlugin.php'); require('conf/configuration.php'); require_once('logic/ImagenesLogic.php'); require_once('search/ImagenesSearchCriteria.php'); $noticiasLogic = new NoticiasLogic($_POST); $imagenesLogic = new ImagenesLogic($_POST); // Ordenamiento if($_GET[order] == "asc") $order= "desc"; else if($_GET[order] == "desc") $order= "asc"; else $order= "desc"; if (!isset($_GET["orderby"])) $orderby = "Fecha"; else $orderby = $_GET["orderby"]; $smarty->assign("orderby", $orderby); $smarty->assign("order", $order); // obtener Noticia por id (si aplica) if (isset($_GET['id']) && ($_GET['id'] != '')) { $id = $_GET['id']; $noticia = $noticiasLogic->get($id); if ($noticia != null) $smarty->assign('noticia', $noticia); } // obtener action $action = $_GET['action']; if ($action == null){ $action = $_POST['action']; } // Seteo el searchcriteria para mostrar la tabla $noticiasSearchCriteria = new NoticiasSearchCriteria(); $noticiasSearchCriteria->setTitulo($_GET['titulo']); $noticiasSearchCriteria->setFechaFrom($_GET['desde']); $noticiasSearchCriteria->setFechaTo($_GET['hasta']); $noticiasSearchCriteria->setOrderby($orderby); $noticiasSearchCriteria->setOrder($order); $noticiasSearchCriteria->setInicio(1); $noticiasSearchCriteria->setFin(null); switch ($action){ case "save": $result = $noticiasLogic->save($_POST); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al guardar los cambios en la Noticia"); else $smarty->assign("message", "La noticia ha sido actualizada"); break; case "add": require('conf/enum.php'); $smarty->assign('categoriasList', $categoriasList); $smarty->assign("detailPage","noticiasForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "update": require('conf/enum.php'); $smarty->assign('categoriasList', $categoriasList); $smarty->assign("detailPage","noticiasForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "detail": // obtengo todas las imagenes $imageSearchCriteria = new ImagenesSearchCriteria(); $imageSearchCriteria->setIditem($id); $imageSearchCriteria->setTable('noticias'); $images = $imagenesLogic->find($imageSearchCriteria); $smarty->assign('images',$images); $smarty->assign("detailPage","noticiasDetails.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "delete": $result = $noticiasLogic->delete($_POST['id']); if ($result == 'error'){$smarty->assign('error', "Error al eliminar la noticia");} break; case "activar": $result = $noticiasLogic->activar($_GET['id']); if ($result == 'error'){$smarty->assign('error', "Error al activar la noticia");} break; case "desactivar": $result = $noticiasLogic->desactivar($_GET['id']); if ($result == 'error'){$smarty->assign('error', "Error al activar la noticia");} break; } $cantidad = $noticiasLogic->count($noticiasSearchCriteria); // Paginador if (isset($_GET["entradas"])) $totalItemsPerPage=$_GET["entradas"]; $totalPages = ceil($cantidad / $totalItemsPerPage); $smarty->assign('totalPages', $totalPages); $smarty->assign('totalItemsPerPage', $totalItemsPerPage); $page = $_GET[page]; if (!$page) { $start = 0; $page = 1; } else $start = ($page - 1) * $totalItemsPerPage; $smarty->assign('page', $page); $noticiasSearchCriteria->setInicio($start); $noticiasSearchCriteria->setFin($totalItemsPerPage); $noticias = $noticiasLogic->find($noticiasSearchCriteria); $smarty->assign('noticias', $noticias); $smarty->assign('allParams', CommonPlugin::getParamsAsString($_GET)); $smarty->assign('cantidad', $cantidad); $smarty->assign('titulo', $_GET['titulo']); $smarty->assign('fechaFrom', $_GET['desde']); $smarty->assign('fechaTo', $_GET['hasta']); $smarty->assign("detailPage", "noticias.tpl"); $smarty->display("admin_generic.tpl"); ?>
PHP
<?php class ContactoVO{ private $id = null; private $empresa = null; private $nombre = null; private $direccion = null; private $telefono = null; private $celular = null; private $mail = null; private $web = null; private $borrado = null; public function getId(){ return $this->id; } public function setId($id){ $this->id = $id; } public function getEmpresa(){ return $this->empresa; } public function setEmpresa($empresa){ $this->empresa = $empresa; } public function getNombre(){ return $this->nombre; } public function setNombre($nombre){ $this->nombre = $nombre; } public function getDireccion(){ return $this->direccion; } public function setDireccion($direccion){ $this->direccion = $direccion; } public function getTelefono(){ return $this->telefono; } public function setTelefono($telefono){ $this->telefono = $telefono; } public function getCelular(){ return $this->celular; } public function setCelular($celular){ $this->celular = $celular; } public function getMail(){ return $this->mail; } public function setMail($mail){ $this->mail = $mail; } public function getWeb(){ return $this->web; } public function setWeb($web){ $this->web = $web; } public function getBorrado(){ return $this->borrado; } public function setBorrado($borrado){ $this->borrado = $borrado; } }
PHP
<?php class NoticiasVO{ private $id = null; private $titulo = null; private $tags = null; private $resumen = null; private $contenido = null; private $fecha = null; private $categoria = null; private $seccion = null; private $orden = null; private $visitas = null; private $activo = null; private $borrado = null; public function getId(){ return $this->id; } public function setId($id){ $this->id = $id; } public function getTitulo(){ return $this->titulo; } public function setTitulo($titulo){ $this->titulo = $titulo; } public function getTags(){ return $this->tags; } public function setTags($tags){ $this->tags = $tags; } public function getResumen(){ return $this->resumen; } public function setResumen($resumen){ $this->resumen = $resumen; } public function getContenido(){ return $this->contenido; } public function setContenido($contenido){ $this->contenido = $contenido; } public function getFecha(){ return $this->fecha; } public function setFecha($fecha){ $this->fecha = $fecha; } public function getCategoria(){ return $this->categoria; } public function setCategoria($categoria){ $this->categoria = $categoria; } public function getSeccion(){ return $this->seccion; } public function setSeccion($seccion){ $this->seccion = $seccion; } public function getOrden(){ return $this->orden; } public function setOrden($orden){ $this->orden = $orden; } public function getVisitas(){ return $this->visitas; } public function setVisitas($visitas){ $this->visitas = $visitas; } public function getActivo(){ return $this->activo; } public function setActivo($activo){ $this->activo = $activo; } public function getBorrado(){ return $this->borrado; } public function setBorrado($borrado){ $this->borrado = $borrado; } } ?>
PHP
<?php /** * VOs are actually a J2EE pattern. It can easily be implemented in PHP. * A value object corresponds directly to a C struct. * It's a class that contains only member variables and no methods other than convenience * methods (usually none). A VO corresponds to a business object. * A VO typically corresponds directly to a database table. * Naming the VO member variables equal to the database fields is a good idea. * Do not forget the ID column. * * @author dintech * */ class ImagenesVO { var $id; var $filename; var $table; var $iditem; var $date; var $order; var $width; var $height; var $size; var $alt; var $description; function getId() { return $this->id; } function getFilename() { return $this->filename; } function getTable() { return $this->table; } function getIditem() { return $this->iditem; } function getDate() { return $this->date; } function getOrder() { return $this->order; } function getWidth() { return $this->width; } function getHeight() { return $this->height; } function getSize() { return $this->size; } function getAlt() { return $this->alt; } function getDescription() { return $this->description; } function setId($x) { $this->id = $x; } function setFilename($x) { $this->filename = $x; } function setTable($x) { $this->table = $x; } function setIditem($x) { $this->iditem = $x; } function setDate($x) { $this->date = $x; } function setOrder($x) { $this->order = $x; } function setWidth($x) { $this->width = $x; } function setHeight($x) { $this->height = $x; } function setSize($x) { $this->size = $x; } function setAlt($x) { $this->alt = $x; } function setDescription($x) { $this->description = $x; } } ?>
PHP
<?php /** * VOs are actually a J2EE pattern. It can easily be implemented in PHP. * A value object corresponds directly to a C struct. * It's a class that contains only member variables and no methods other than convenience * methods (usually none). A VO corresponds to a business object. * A VO typically corresponds directly to a database table. * Naming the VO member variables equal to the database fields is a good idea. * Do not forget the ID column. * * @author dintech * */ class UsuarioVO{ private $id = null; private $username = null; private $passw = null; private $rol = null; public function getId(){ return $this->id; } public function setId($id){ $this->id = $id; } public function getUsername(){ return $this->username; } public function setUsername($username){ $this->username = $username; } public function getPassw(){ return $this->passw; } public function setPassw($passw){ $this->passw = $passw; } public function getRol(){ return $this->rol; } public function setRol($rol){ $this->rol = $rol; } } ?>
PHP
<?php class ClientesVO{ private $id = null; private $nombre = null; private $mail = null; private $telefono = null; private $ciudad = null; private $active = null; private $fecha = null; private $borrado = null; public function getId(){ return $this->id; } public function setId($id){ $this->id = $id; } public function getNombre(){ return $this->nombre; } public function setNombre($nombre){ $this->nombre = $nombre; } public function getMail(){ return $this->mail; } public function setMail($mail){ $this->mail = $mail; } public function getTelefono(){ return $this->telefono; } public function setTelefono($telefono){ $this->telefono = $telefono; } public function getCiudad(){ return $this->ciudad; } public function setCiudad($ciudad){ $this->ciudad = $ciudad; } public function getActive(){ return $this->active; } public function setActive($active){ $this->active = $active; } public function getFecha(){ return $this->fecha; } public function setFecha($fecha){ $this->fecha = $fecha; } public function getBorrado(){ return $this->borrado; } public function setBorrado($borrado){ $this->borrado = $borrado; } }
PHP
<?php /** * VOs are actually a J2EE pattern. It can easily be implemented in PHP. * A value object corresponds directly to a C struct. * It's a class that contains only member variables and no methods other than convenience * methods (usually none). A VO corresponds to a business object. * A VO typically corresponds directly to a database table. * Naming the VO member variables equal to the database fields is a good idea. * Do not forget the ID column. * * @author dintech * */ class ImageVO{ var $id; var $path; var $fileName; var $table; var $idItem; var $date; var $order; var $width; var $height; var $size; var $alt; var $description; function getId() { return $this->id; } function getPath() { return $this->path; } function getFileName() { return $this->fileName; } function getTable() { return $this->table; } function getIdItem() { return $this->idItem; } function getDate() { return $this->date; } function getOrder() { return $this->order; } function getWidth() { return $this->width; } function getHeight() { return $this->height; } function getSize() { return $this->size; } function getAlt() { return $this->alt; } function getDescription() { return $this->description; } function setId($x) { $this->id = $x; } function setPath($x) { $this->path = $x; } function setFileName($x) { $this->fileName = $x; } function setTable($x) { $this->table = $x; } function setIdItem($x) { $this->idItem = $x; } function setDate($x) { $this->date = $x; } function setOrder($x) { $this->order = $x; } function setWidth($x) { $this->width = $x; } function setHeight($x) { $this->height = $x; } function setSize($x) { $this->size = $x; } function setAlt($x) { $this->alt = $x; } function setDescription($x) { $this->description = $x; } } ?>
PHP
<?php class AvisosVO{ private $id = null; private $fechatexto = null; private $fecha = null; private $descripcion = null; public function getId(){ return $this->id; } public function setId($id){ $this->id = $id; } public function getFechatexto(){ return $this->fechatexto; } public function setFechatexto($fechatexto){ $this->fechatexto = $fechatexto; } public function getFecha(){ return $this->fecha; } public function setFecha($fecha){ $this->fecha = $fecha; } public function getDescripcion(){ return $this->descripcion; } public function setDescripcion($descripcion){ $this->descripcion = $descripcion; } }
PHP
<?php class ContenidoVO{ private $id = null; private $titulo = null; private $texto = null; private $descripcion = null; private $imagen = null; private $borrado = null; public function getId(){ return $this->id; } public function setId($id){ $this->id = $id; } public function getTitulo(){ return $this->titulo; } public function setTitulo($titulo){ $this->titulo = $titulo; } public function getTexto(){ return $this->texto; } public function setTexto($texto){ $this->texto = $texto; } public function getDescripcion(){ return $this->descripcion; } public function setDescripcion($descripcion){ $this->descripcion = $descripcion; } public function getImagen(){ return $this->imagen; } public function setImagen($imagen){ $this->imagen = $imagen; } public function getBorrado(){ return $this->borrado; } public function setBorrado($borrado){ $this->borrado = $borrado; } }
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); /** * DAO is actually a J2EE pattern. * It can easily be implemented in PHP and helps greatly in separating database access from the rest of your code. * The DAOs form a thin layer. The DAO layer can be 'stacked' which helps for instance if you want to add DB * caching later when tuning your application. You should have one DAO class for every VO class. * Naming conventions are a good practice. * * @author dintech * */ class UsuarioDAO extends DAO { function ProductoDAO() {} function get($id) { DBConnection::getInstance(); $query = "SELECT * FROM `users` u where $id = id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function getByUsername($username) { DBConnection::getInstance(); $query = "SELECT * FROM `users` u where '$username' = username"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM `users` u where rol<>'0' $conditions"; $result = mysql_query($query); return $this->getFromResult($result); } function delete($id) { DBConnection::getInstance(); $query = "DELETE from `users` u where id = $id"; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $passw = $vo->getPassw(); if (($passw != null) && ($passw != "")) { // actualiza el rol $query = "UPDATE users SET ". " passw = '".$vo->getPassw()."'". " WHERE id =".$vo->getId(); } else { // actualiza solo el passw $query = "UPDATE users SET ". " rol = '".$vo->getRol()."'". " WHERE id =".$vo->getId(); } $result = mysql_query($query); return parent::checkError($result); } function insert(&$vo) { DBConnection::getInstance(); $query = "INSERT INTO `users` (`id`, `username`, `passw`, `rol`) values (NULL,'".$vo->getUsername()."', '".$vo->getPassw()."', '".$vo->getRol()."' )"; $result = mysql_query($query); return parent::checkError($result); } function getConditions($criteria){ $conditions = parent::getConditions($criteria, "u"); if ($criteria->getUsername() != null){ $conditions.= " AND username = '".$criteria->getUsername()."'"; } if ($criteria->getRol() != null){ $conditions.= " AND rol = ".$criteria->getRol(); } return $conditions; } function changePassword($username, $oldpassword, $newpassword) { $user = UsuarioDAO::getByUsername($username); } } ?>
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); class NoticiasDAO extends DAO { function NoticiasDAO() {} function get($id) { DBConnection::getInstance(); $query = "SELECT * FROM `noticias` where id = $id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM `noticias` WHERE 1=1 $conditions"; //echo $query; $result = mysql_query($query); return $this->getFromResult($result); } function deleteFisico($id){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "DELETE FROM noticias WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function delete($id){ DBConnection::getInstance(); $query = "UPDATE noticias SET borrado = 1 WHERE id = %ID%"; $query = str_replace('%ID%', $id, $query); $result = mysql_query($query); return parent::checkError($result); } function insert($vo) { DBConnection::getInstance(); $query = "INSERT INTO noticias(`id`, `titulo`, `tags`, `resumen`, `contenido`, `fecha`, `categoria`, `seccion`, `orden`, `visitas`, `activo`, `borrado`) VALUES (%ID%, '%TITULO%', '%TAGS%', '%RESUMEN%', '%CONTENIDO%', '%FECHA%', '%CATEGORIA%', '%SECCION%', '%ORDEN%', '%VISITAS%', '%ACTIVO%', '%BORRADO%')"; $query = str_replace('%ID%', 'null', $query); $query = str_replace('%TITULO%', $vo->getTitulo(), $query); $query = str_replace('%TAGS%', $vo->getTags(), $query); $query = str_replace('%RESUMEN%', $vo->getResumen(), $query); $query = str_replace('%CONTENIDO%', $vo->getContenido(), $query); $query = str_replace('%FECHA%', $vo->getFecha(), $query); $query = str_replace('%CATEGORIA%', $vo->getCategoria(), $query); $query = str_replace('%SECCION%', $vo->getSeccion(), $query); $query = str_replace('%ORDEN%', $vo->getOrden(), $query); $query = str_replace('%VISITAS%', $vo->getVisitas(), $query); $query = str_replace('%ACTIVO%', 1, $query); $query = str_replace('%BORRADO%', 0, $query); //echo $query; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $query = "UPDATE noticias SET ". "titulo ='%TITULO%', ". "tags ='%TAGS%', ". "resumen ='%RESUMEN%', ". "contenido ='%CONTENIDO%', ". "fecha ='%FECHA%', ". "categoria ='%CATEGORIA%', ". "seccion ='%SECCION%', ". "orden ='%ORDEN%', ". "visitas ='%VISITAS%', ". "activo ='%ACTIVO%', ". "borrado ='%BORRADO%'". " WHERE id =".$vo->getId(); $query = str_replace('%TITULO%', $vo->getTitulo(), $query); $query = str_replace('%TAGS%', $vo->getTags(), $query); $query = str_replace('%RESUMEN%', $vo->getResumen(), $query); $query = str_replace('%CONTENIDO%', $vo->getContenido(), $query); $query = str_replace('%FECHA%', $vo->getFecha(), $query); $query = str_replace('%CATEGORIA%', $vo->getCategoria(), $query); $query = str_replace('%SECCION%', $vo->getSeccion(), $query); $query = str_replace('%ORDEN%', $vo->getOrden(), $query); $query = str_replace('%VISITAS%', $vo->getVisitas(), $query); $query = str_replace('%ACTIVO%', 1, $query); $query = str_replace('%BORRADO%', 0, $query); //echo $query; $result = mysql_query($query); return parent::checkError($result); } function getConditions($criteria){ if ($criteria->getTitulo() != null) { $conditions.= " AND titulo like '%".$criteria->getTitulo()."%'"; } if ($criteria->getTags() != null) { $conditions.= " AND tags like '%".$criteria->getTags()."%'"; } if ($criteria->getFechaFrom() != null && $criteria->getFechaTo() != null ) { $conditions.= " AND noticias.fecha >= '".$criteria->getFechaFrom()."' AND noticias.fecha < '".$criteria->getFechaTo()."'"; } $conditions .= parent::getConditions($criteria, "noticias"); return $conditions; } function getMaxId() { DBConnection::getInstance(); $query = "SELECT id FROM noticias ORDER BY id DESC LIMIT 1"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0][id]; // no se por que, pero siempre retorna un valor menos } function getLastInsertId() { DBConnection::getInstance(); $query = "SELECT LAST_INSERT_ID() as last_id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0][last_id]; } function activar($id){ DBConnection::getInstance(); $query = "update noticias set activo = 1 WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function desactivar($id){ DBConnection::getInstance(); $query = "update noticias set activo = 0 WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } } ?>
PHP
<?php require_once('dao/UsuarioDAO.php'); require_once('dao/NoticiasDAO.php'); require_once('dao/ContenidoDAO.php'); require_once('dao/ContactoDAO.php'); require_once('dao/ClientesDAO.php'); require_once('dao/AvisosDAO.php'); require_once('dao/ImagenesDAO.php'); class FactoryDAO{ public static function getDao($dao) { if($dao == "NoticiasDAO") { return new NoticiasDAO(); } if($dao == "ContenidoDAO") { return new ContenidoDAO(); } if($dao == "ContactoDAO") { return new ContactoDAO(); } if($dao == "ClientesDAO") { return new ClientesDAO(); } if($dao == "ImagenesDAO") { return new ImagenesDAO(); } if($dao == "UsuarioDAO") { return new UsuarioDAO(); } if($dao == "AvisosDAO") { return new AvisosDAO(); } } } ?>
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); require_once('search/ImagenesSearchCriteria.php'); /** * DAO is actually a J2EE pattern. * It can easily be implemented in PHP and helps greatly in separating database access from the rest of your code. * The DAOs form a thin layer. The DAO layer can be 'stacked' which helps for instance if you want to add DB * caching later when tuning your application. You should have one DAO class for every VO class. * Naming conventions are a good practice. * * @author dintech * */ class ImagenesDAO extends DAO { function ImagenesDAO() {} function get($id) { DBConnection::getInstance(); $query = "SELECT * FROM `imagenes` I where $id = id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function delete($id) { DBConnection::getInstance(); $query = "DELETE from `imagenes` where id = $id"; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $query = "UPDATE imagenes SET ". " description ='".$vo->getDescription()."'". " WHERE id =".$vo->getId(); //echo $query; $result = mysql_query($query); return parent::checkError($result); } function insert(&$vo) { DBConnection::getInstance(); $query = "INSERT INTO `imagenes` (`id`, `filename`, `tablename`, `iditem`, `date`, `order`, `width`, `height`, `size`, `alt`, `description`) values (NULL, '".$vo->getFilename()."', '".$vo->getTable()."', '".$vo->getIditem()."', '".$vo->getDate()."', '".$vo->getOrder()."', '".$vo->getWidth()."', '".$vo->getHeight()."', '".$vo->getSize()."', '".$vo->getAlt()."', '".$vo->getDescription()."' )"; $result = mysql_query($query); return parent::checkError($result); } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM `imagenes` I where 1 $conditions"; $result = mysql_query($query); return $this->getFromResult($result); } function getLastInsertId() { DBConnection::getInstance(); $query = "SELECT LAST_INSERT_ID() as last_id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0][last_id]; } function getConditions($criteria){ if ($criteria->getIdItem() != null){ $conditions.= " AND iditem = '".$criteria->getIditem()."'"; } if ($criteria->getFecha() != null){ $conditions.= " AND fecha = '".$criteria->getFecha()."'"; } if ($criteria->getTable() != null){ $conditions.= " AND tablename = '".$criteria->getTable()."'"; } return $conditions; } /** * Actualiza el imagesid FK con el id de la imagen * y el imagecount de una propiedad por id * El valor de $valueIncrDec puede ser +1 o -1, dependiendo * de si se agregue o elimine una imagen * @param ID de la propiedad $id * @param Integer $imagesId (FK) * @param Integer $valueIncrDec */ function updateImageinfo($table, $id, $imagesId, $valueIncrDec = 1) { DBConnection::getInstance(); // si la propiedad no tiene ($imagecount=0), setear // como $imagesid la actual if ($imagesId != null ) { $query = "UPDATE $table SET " ." imagesid=".$imagesId ." WHERE id=".$id; echo $query; $result = mysql_query($query); } // modifica valor de imagecount $query = "UPDATE $table SET " ." imagecount=imagecount+(".$valueIncrDec.")" ." WHERE id=".$id; //echo "<br/>".$query;exit; $result = mysql_query($query); return parent::checkError($result); } function getEntidad($table, $iditem) { DBConnection::getInstance(); $query = "SELECT * FROM $table where id = $iditem"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } } ?>
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); class ClientesDAO extends DAO { function ClientesDAO() {} function get($id){ DBConnection::getInstance(); $query = "SELECT * FROM clientes WHERE id = $id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM clientes WHERE 1=1 $conditions"; $result = mysql_query($query); return $this->getFromResult($result); } function deleteFisico($id){ DBConnection::getInstance(); $query = "DELETE FROM clientes WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function delete($id){ DBConnection::getInstance(); $query = "UPDATE clientes SET borrado = '1' WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function insert($vo) { DBConnection::getInstance(); $query = "INSERT INTO clientes(id, nombre, mail, telefono, ciudad, active, fecha, borrado) VALUES (NULL, '".$vo->getNombre()."', '".$vo->getMail()."', '".$vo->getTelefono()."', '".$vo->getCiudad()."', '".$vo->getActive()."', '".$vo->getFecha()."', '".$vo->getBorrado()."')"; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $query = "UPDATE clientes SET ". "nombre ='".$vo->getNombre()."', ". "mail ='".$vo->getMail()."', ". "telefono ='".$vo->getTelefono()."', ". "ciudad ='".$vo->getCiudad()."', ". "active ='".$vo->getActive()."', ". "fecha ='".$vo->getFecha()."' ". " WHERE id =".$vo->getId(); $result = mysql_query($query); return parent::checkError($result); } function getConditions($criteria){ if ($criteria->getNombre() != null) { $conditions.= " AND nombre= '".$criteria->getNombre()."'"; } if ($criteria->getCiudad() != null) { $conditions.= " AND ciudad= '".$criteria->getCiudad()."'"; } if ($criteria->getActive() != null) { $conditions.= " AND active= '".$criteria->getActive()."'"; } if ($criteria->getFecha() != null) { $conditions.= " AND fecha= '".$criteria->getFecha()."'"; } if ($criteria->getSearch() != null) { $conditions.= " AND nombre like '%".$criteria->getSearch()."%'"; } $conditions .= parent::getConditions($criteria,'clientes'); return $conditions; } }
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); class AvisosDAO extends DAO { function AvisosDAO() { } function get($id){ DBConnection::getInstance(); $query = "SELECT * FROM avisos WHERE id = $id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM avisos WHERE 1=1 $conditions"; //echo $query; $result = mysql_query($query); return $this->getFromResult($result); } function delete($id){ DBConnection::getInstance(); $query = "DELETE FROM avisos WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function insert($vo) { DBConnection::getInstance(); $query = "INSERT INTO avisos(id, fechatexto, fecha, descripcion) VALUES ('".$vo->getId()."', '".$vo->getFechatexto()."', '".$vo->getFecha()."', '".$vo->getDescripcion()."')"; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $query = "UPDATE avisos SET ". "fechatexto ='".$vo->getFechatexto()."', ". "fecha ='".$vo->getFecha()."', ". "descripcion ='".$vo->getDescripcion()."'". " WHERE id =".$vo->getId(); //echo $query; $result = mysql_query($query); return parent::checkError($result); } function getConditions($criteria){ if ($criteria->getFecha() != null) { $conditions.= " AND fecha= '".$criteria->getFecha()."'"; } if ($criteria->getSearch() != null) { $conditions.= " AND descripcion like '%".$criteria->getSearch()."%' "; } $conditions .= parent::getConditions($criteria,'avisos'); return $conditions; } }
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); class ContactoDAO extends DAO { function ContactoDAO() {} function get($id){ DBConnection::getInstance(); $query = "SELECT * FROM contacto WHERE id = $id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM contacto WHERE 1=1 $conditions"; $result = mysql_query($query); return $this->getFromResult($result); } function deleteFisico($id){ DBConnection::getInstance(); $query = "DELETE FROM contacto WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function delete($id){ DBConnection::getInstance(); $query = "UPDATE contacto SET borrado = '1' WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function insert($vo) { DBConnection::getInstance(); $query = "INSERT INTO contacto(id, empresa, nombre, direccion, telefono, celular, mail, web, borrado) VALUES (NULL, '".$vo->getEmpresa()."', '".$vo->getNombre()."', '".$vo->getDireccion()."', '".$vo->getTelefono()."', '".$vo->getCelular()."', '".$vo->getMail()."', '".$vo->getWeb()."', '".$vo->getBorrado()."')"; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $query = "UPDATE contacto SET ". "empresa ='".$vo->getEmpresa()."', ". "nombre ='".$vo->getNombre()."', ". "direccion ='".$vo->getDireccion()."', ". "telefono ='".$vo->getTelefono()."', ". "celular ='".$vo->getCelular()."', ". "mail ='".$vo->getMail()."', ". "web ='".$vo->getWeb()."' ". " WHERE id =".$vo->getId(); echo $query; $result = mysql_query($query); return parent::checkError($result); } function getConditions($criteria){ if ($criteria->getEmpresa() != null) { $conditions.= " AND empresa= '".$criteria->getEmpresa()."'"; } if ($criteria->getNombre() != null) { $conditions.= " AND nombre= '".$criteria->getNombre()."'"; } $conditions .= parent::getConditions($criteria,'contacto'); return $conditions; } }
PHP
<?php require_once('conf/DBConnection.php'); require_once('dao/DAO.php'); class ContenidoDAO extends DAO { function ContenidoDAO() { } function get($id){ DBConnection::getInstance(); $query = "SELECT * FROM contenido WHERE id = $id"; $result = mysql_query($query); $results = $this->getFromResult($result); return $results[0]; } function find($criteria){ DBConnection::getInstance(); $conditions = $this->getConditions($criteria); $query = "SELECT * FROM contenido WHERE 1=1 $conditions"; $result = mysql_query($query); return $this->getFromResult($result); } function deleteFisico($id){ DBConnection::getInstance(); $query = "DELETE FROM contenido WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function delete($id){ DBConnection::getInstance(); $query = "UPDATE contenido SET borrado = '1' WHERE id = $id"; $result = mysql_query($query); return parent::checkError($result); } function insert($vo) { DBConnection::getInstance(); $query = "INSERT INTO contenido(id, titulo, texto, descripcion, imagen, borrado) VALUES (NULL, '".$vo->getTitulo()."', '".$vo->getTexto()."', '".$vo->getDescripcion()."', '".$vo->getImagen()."', '".$vo->getBorrado()."')"; $result = mysql_query($query); return parent::checkError($result); } function update($vo) { DBConnection::getInstance(); $query = "UPDATE contenido SET ". "titulo ='".$vo->getTitulo()."', ". "texto ='".$vo->getTexto()."', ". "descripcion ='".$vo->getDescripcion()."', ". "imagen ='".$vo->getImagen()."' ". " WHERE id =".$vo->getId(); $result = mysql_query($query); return parent::checkError($result); } function getConditions($criteria){ if ($criteria->getTitulo() != null) { $conditions.= " AND titulo like '%".$criteria->getTitulo()."%'"; } if ($criteria->getSearch() != null) { $conditions.= " AND titulo like '%".$criteria->getSearch()."%' OR descripcion like '%".$criteria->getSearch()."%' "; } $conditions .= parent::getConditions($criteria,'contenido'); return $conditions; } }
PHP
<?php class FileUtilityPlugin { /** * Obtener la extension de un archivo */ public static function getExtension($fileName) { $pathInfo = pathinfo($fileName); //echo $partes_ruta['dirname'] . "\n"; //echo $partes_ruta['basename'] . "\n"; return $pathInfo['extension']; } /* * Elimina un archivo */ public static function remove($fileName) { unlink($fileName); } /** * Function: sanitize * Returns a sanitized string, typically for URLs. * * Parameters: * $string - The string to sanitize. * $force_lowercase - Force the string to lowercase? * $anal - If set to *true*, will remove all non-alphanumeric characters. */ public static function sanitize($string, $force_lowercase = true, $anal = false) { $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", "}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;", "—", "–", ",", "<", ">", "/", "?"); $clean = trim(str_replace($strip, "", strip_tags($string))); $clean = preg_replace('/\s+/', "-", $clean); $clean = ($anal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean ; return ($force_lowercase) ? (function_exists('mb_strtolower')) ? mb_strtolower($clean, 'UTF-8') : strtolower($clean) : $clean; } }
PHP
<?php class SecurityAccessPlugin { /** * Retorna true si el rol tiene acceso a la pagina que se intenta ver ($scriptPhp) */ public static function hasAccess($menuItems, $scriptPhp, $allAccessPages, $rol) { if ($rol == "0") return true; // chequea que scriptPhp no se encuentre dentro de las paginas permitidas foreach ($allAccessPages as $page) { if ($page[script] == $scriptPhp) { return true; } } // obtener la pagina actual del menu item $menuItemPage = null; foreach ($menuItems as $page) { if ($page[script] == $scriptPhp) { $menuItemPage = $page; } else { $submenu = $page[submenu]; if (($submenu != null) && (count($submenu) > 0)) { foreach ($submenu as $subPage) { if ($subPage[script] == $scriptPhp) $menuItemPage = $subPage; } } } } if (strpos($rol, $menuItemPage[rol]) !== false) return true; return false; } }
PHP
<?php //set_include_path('.:/php/includes:/home/diegolaprida/domains/simesev.com.ar/public_html/admin/core:/usr/lib/php:/usr/local/lib/php'); //require_once 'coreapi/SmartyAPI.php'; require_once 'Zend/Session/Namespace.php'; require_once 'Smarty/Smarty.class.php'; class SmartyPlugin { /** * Retorna el objeto Manage con sus propiedades seteadas */ public static function getSmarty() { // Incluye archivo de configuracion require('conf/configuration.php'); // Crea objeto Smarty y setea propiedades $smarty = new Smarty(); $smarty->template_dir = $template_dir; $smarty->compile_dir = $compile_dir; $smarty->cache_dir = $cache_dir; $smarty->config_dir = $config_dir; // $session->setExpirationSeconds(1); return $smarty; // return SmartyAPI::getSmarty($template_dir, $compile_dir, $cache_dir, $config_dir); } }
PHP
<?php require_once 'plugin/SessionPlugin.php'; /** * Para funciones comunes * */ class CommonPlugin { /** * Retorna los parametros recibidos por GET formateados */ public static function getParamsAsString($get) { $params = ""; $keys = array_keys($get); $values = array_values($get); for ($i = 0; $i < count($get); $i++) { if (($keys[$i] != 'page') && ($keys[$i] != 'action') && ($keys[$i] != 'option')) $params .= $keys[$i].'='.$values[$i] . "&"; } return $params; } /** * Retorna la url actual * Ej. script.php?param1=aaa&param2=bbb */ public static function getActualUrl() { $url = basename($_SERVER['REQUEST_URI']); return $url; } /** * Setea un mensaje para mostrar */ public static function setMessage($message) { require('conf/configuration.php'); SessionPlugin::setSessionValue($message, 'message', $appname); } /** * Retorna un mensaje para mostrar */ public static function getMessage() { require('conf/configuration.php'); return SessionPlugin::getSessionValue('message', $appname); } }
PHP
<?php require_once 'plugin/SessionPlugin.php'; require_once 'plugin/UsersDBPlugin.php'; /** * Loguea un usuario en la DB * */ class LoginPlugin { /** * Chequea que exista el usuario */ public static function existUser($username, $password) { return UsersDBPlugin::existUser($username, $password); } /** * Loguea el usuario (lo busca en la DB) */ public static function login($username, $password) { require('conf/configuration.php'); $user = UsersDBPlugin::existUserMatchPassword($username, $password); if ($user != null) { SessionPlugin::setSessionValue($username, 'username'.$appname, 'login'.$appname); $rolArray = explode('_', $user[rol]); SessionPlugin::setSessionValue($rolArray[0], 'rol'.$appname, 'login'.$appname); // obtengo el club id desde rol (ej. Cr_5, el club id es 5) if ($rolArray != null && count($rolArray) >= 2) SessionPlugin::setSessionValue($rolArray[1], 'club'.$appname, 'login'.$appname); SessionPlugin::setExpirationSeconds('login'.$appname, $expirationSeconds); return true; } else { return false; } } /** * Chequea si el usuario ya esta logueado (session var seteada) */ public static function isLogged() { require('conf/configuration.php'); if ((SessionPlugin::getSessionValue('username'.$appname, 'login'.$appname) != null) && (SessionPlugin::getSessionValue('username'.$appname, 'login'.$appname) != '')) { SessionPlugin::setExpirationSeconds('login'.$appname, $expirationSeconds); return true; } else return false; } /** * Logout del usuario */ public static function logout() { require('conf/configuration.php'); if (SessionPlugin::getSessionValue('username'.$appname, 'login'.$appname) != null) { SessionPlugin::setSessionValue('', 'username'.$appname, 'login'.$appname); } SessionPlugin::setExpirationSeconds('login'.$appname, 1); } /** * Chequea si el usuario ya esta logueado (session var seteada) y retorna el username */ public static function getUsername() { require('conf/configuration.php'); return SessionPlugin::getSessionValue('username'.$appname, 'login'.$appname); } /** * Chequea si el usuario ya esta logueado (session var seteada) y retorna el rol */ public static function getRol() { require('conf/configuration.php'); return SessionPlugin::getSessionValue('rol'.$appname, 'login'.$appname); } /** * Chequea si el usuario ya esta logueado (session var seteada) y retorna el club */ public static function getClub() { require('conf/configuration.php'); return SessionPlugin::getSessionValue('club'.$appname, 'login'.$appname); } }
PHP
<?php require_once 'Zend/Config/Xml.php'; class XMLParserPlugin { /** * Parsea una seccion de un archivo xml * * @param Xml file $xmlfile * @param section $option * @return parsed section from xml file */ public static function parse($xmlfile, $section) { // Parseo XML $parsed = new Zend_Config_Xml($xmlfile, $section); return $parsed; } }
PHP
<?php //set_include_path('.:/php/includes:/home/diegolaprida/domains/simesev.com.ar/public_html/admin/core:/usr/lib/php:/usr/local/lib/php'); require_once 'Zend/Session/Namespace.php'; class SessionPlugin { /** * Retorna la sessionVar del namespace */ public static function getSessionValue($sessionVar, $namespace) { $session = new Zend_Session_Namespace($namespace); if (isset($session->$sessionVar)) { return $session->$sessionVar; } else { return null; } } /** * Setea una session var en un namespace */ public static function setSessionValue($value, $sessionVar, $namespace) { $session = new Zend_Session_Namespace($namespace); $session->$sessionVar = $value; } /** * Setea el expiration time para un namespace */ public static function setExpirationSeconds($namespace, $time) { $session = new Zend_Session_Namespace($namespace); if (isset($session)) { $session->setExpirationSeconds($time); } } }
PHP
<?php class AppConfigPlugin { /** * Retorna el objeto Menu con sus propiedades seteadas */ public static function getMenuItems($rol = null) { require('conf/configuration.php'); // si el rol es "administrador" retornar todos los menu items if ($rol == "0" || $rol == null) { return $menuItems; } // sino, filtrar solo los menu permitidos $accessMenuItems = array(); foreach ($menuItems as $menuItem) { //echo "<br/>rol usuario: " . $rol; //echo "<br/>rol pagina: " . $menuItem[rol]; if (strpos($rol, $menuItem[rol]) !== false) $accessMenuItems[] = $menuItem; } return $accessMenuItems; } /** * Retorna el objeto Manage con sus propiedades seteadas */ public static function getManageItems() { require('conf/configuration.php'); return $manageItems; } /** * Retorna app info */ public static function getAppInfo() { require('conf/configuration.php'); return $appInfo; } public static function search($array, $script, &$breadcrumb, &$found) { for($i = 0; $i <= count($array) && !$found; $i++) { $item = $array[$i]; if ($item[script] == $script) { $breadcrumb[] = array("name" => $item[name], "script" => $item[script], "image" => $item[image]); $found = true; } else { if (($item[sons] != null) && (count($item[sons]) > 0)) { $breadcrumb[] = array("name" => $item[name], "script" => $item[script]); $found = AppConfigPlugin::search($item[sons], $script, $breadcrumb, $found); if (!$found) array_pop($breadcrumb); } } } return $found; } /** * Retorna page tree */ public static function getBreadcrumb($script) { require('conf/configuration.php'); $found = false; $breadcrumb = array(); $exist = AppConfigPlugin::search($pageTree, $script, $breadcrumb, $found); return $breadcrumb; } public static function sons($array, $script, &$sons, &$found) { for($i = 0; $i <= count($array) && !$found; $i++) { $item = $array[$i]; if ($item[script] == $script) { $sons = $item[sons]; $found = true; } else { if (($item[sons] != null) && (count($item[sons]) > 0)) { //$breadcrumb[] = array("name" => $item[name], "script" => $item[script]); $found = AppConfigPlugin::sons($item[sons], $script, $sons, $found); /*if (!$found) array_pop($breadcrumb);*/ } } } return $found; } /** * Retorna page tree */ public static function getSons($script) { require('conf/configuration.php'); $found = false; $sons = array(); $exist = AppConfigPlugin::sons($pageTree, $script, $sons, $found); return $sons; } /** * Retorna los iconos img */ public static function getIconsImg() { require('conf/configuration.php'); return $iconsImg; } /** * Retorna la cantidad de items para mostrar en cada pagina */ public static function getTotalItemsPerPage() { require('conf/configuration.php'); return $totalItemsPerPage; } /** * Retorna el nombre del script php actual (licencias.php) */ public static function getCurrentScript() { $file = $_SERVER["SCRIPT_NAME"]; $break = explode('/', $file); return $break[count($break) - 1]; } /** * Retorna la url con los parametros de GET incluido (ej. licencias.php?action=add) */ function curPageURL() { $url = $_SERVER["REQUEST_URI"]; $break = explode('/', $url); $break = $break[count($break) - 1]; $break = explode('&', $break); return $break[0]; } }
PHP
<?php /** * thumbnail.inc.php * * @author Ian Selby (ian@gen-x-design.com) * @copyright Copyright 2006 * @version 1.1 (PHP5) * */ /** * PHP class for dynamically resizing, cropping, and rotating images for thumbnail purposes and either displaying them on-the-fly or saving them. * */ class Thumbnail { /** * Error message to display, if any * * @var string */ private $errmsg; /** * Whether or not there is an error * * @var boolean */ private $error; /** * Format of the image file * * @var string */ private $format; /** * File name and path of the image file * * @var string */ private $fileName; /** * Image meta data if any is available (jpeg/tiff) via the exif library * * @var array */ public $imageMeta; /** * Current dimensions of working image * * @var array */ private $currentDimensions; /** * New dimensions of working image * * @var array */ private $newDimensions; /** * Image resource for newly manipulated image * * @var resource */ private $newImage; /** * Image resource for image before previous manipulation * * @var resource */ private $oldImage; /** * Image resource for image being currently manipulated * * @var resource */ private $workingImage; /** * Percentage to resize image by * * @var int */ private $percent; /** * Maximum width of image during resize * * @var int */ private $maxWidth; /** * Maximum height of image during resize * * @var int */ private $maxHeight; /** * Class constructor * * @param string $fileName * @return Thumbnail */ public function __construct($fileName) { //make sure the GD library is installed if(!function_exists("gd_info")) { echo 'You do not have the GD Library installed. This class requires the GD library to function properly.' . "\n"; echo 'visit http://us2.php.net/manual/en/ref.image.php for more information'; exit; } //initialize variables $this->errmsg = ''; $this->error = false; $this->currentDimensions = array(); $this->newDimensions = array(); $this->fileName = $fileName; $this->imageMeta = array(); $this->percent = 100; $this->maxWidth = 0; $this->maxHeight = 0; //check to see if file exists if(!file_exists($this->fileName)) { $this->errmsg = 'File not found'; $this->error = true; } //check to see if file is readable elseif(!is_readable($this->fileName)) { $this->errmsg = 'File is not readable'; $this->error = true; } //if there are no errors, determine the file format if($this->error == false) { //check if gif if(stristr(strtolower($this->fileName),'.gif')) $this->format = 'GIF'; //check if jpg elseif(stristr(strtolower($this->fileName),'.jpg') || stristr(strtolower($this->fileName),'.jpeg')) $this->format = 'JPG'; //check if png elseif(stristr(strtolower($this->fileName),'.png')) $this->format = 'PNG'; //unknown file format else { $this->errmsg = 'Unknown file format'; $this->error = true; } } //initialize resources if no errors if($this->error == false) { switch($this->format) { case 'GIF': $this->oldImage = ImageCreateFromGif($this->fileName); break; case 'JPG': $this->oldImage = ImageCreateFromJpeg($this->fileName); break; case 'PNG': $this->oldImage = ImageCreateFromPng($this->fileName); break; } $size = GetImageSize($this->fileName); $this->currentDimensions = array('width'=>$size[0],'height'=>$size[1]); $this->newImage = $this->oldImage; $this->gatherImageMeta(); } if($this->error == true) { $this->showErrorImage(); break; } } /** * Class destructor * */ public function __destruct() { if(is_resource($this->newImage)) @ImageDestroy($this->newImage); if(is_resource($this->oldImage)) @ImageDestroy($this->oldImage); if(is_resource($this->workingImage)) @ImageDestroy($this->workingImage); } /** * Returns the current width of the image * * @return int */ private function getCurrentWidth() { return $this->currentDimensions['width']; } /** * Returns the current height of the image * * @return int */ private function getCurrentHeight() { return $this->currentDimensions['height']; } /** * Calculates new image width * * @param int $width * @param int $height * @return array */ private function calcWidth($width,$height) { $newWp = (100 * $this->maxWidth) / $width; $newHeight = ($height * $newWp) / 100; return array('newWidth'=>intval($this->maxWidth),'newHeight'=>intval($newHeight)); } /** * Calculates new image height * * @param int $width * @param int $height * @return array */ private function calcHeight($width,$height) { $newHp = (100 * $this->maxHeight) / $height; $newWidth = ($width * $newHp) / 100; return array('newWidth'=>intval($newWidth),'newHeight'=>intval($this->maxHeight)); } /** * Calculates new image size based on percentage * * @param int $width * @param int $height * @return array */ private function calcPercent($width,$height) { $newWidth = ($width * $this->percent) / 100; $newHeight = ($height * $this->percent) / 100; return array('newWidth'=>intval($newWidth),'newHeight'=>intval($newHeight)); } /** * Calculates new image size based on width and height, while constraining to maxWidth and maxHeight * * @param int $width * @param int $height */ private function calcImageSize($width,$height) { $newSize = array('newWidth'=>$width,'newHeight'=>$height); if($this->maxWidth > 0) { $newSize = $this->calcWidth($width,$height); if($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight) { $newSize = $this->calcHeight($newSize['newWidth'],$newSize['newHeight']); } //$this->newDimensions = $newSize; } if($this->maxHeight > 0) { $newSize = $this->calcHeight($width,$height); if($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth) { $newSize = $this->calcWidth($newSize['newWidth'],$newSize['newHeight']); } //$this->newDimensions = $newSize; } $this->newDimensions = $newSize; } /** * Calculates new image size based percentage * * @param int $width * @param int $height */ private function calcImageSizePercent($width,$height) { if($this->percent > 0) { $this->newDimensions = $this->calcPercent($width,$height); } } /** * Displays error image * */ private function showErrorImage() { header('Content-type: image/png'); $errImg = ImageCreate(220,25); $bgColor = imagecolorallocate($errImg,0,0,0); $fgColor1 = imagecolorallocate($errImg,255,255,255); $fgColor2 = imagecolorallocate($errImg,255,0,0); imagestring($errImg,3,6,6,'Error:',$fgColor2); imagestring($errImg,3,55,6,$this->errmsg,$fgColor1); imagepng($errImg); imagedestroy($errImg); } /** * Resizes image to maxWidth x maxHeight * * @param int $maxWidth * @param int $maxHeight */ public function resize($maxWidth = 0, $maxHeight = 0) { $this->maxWidth = $maxWidth; $this->maxHeight = $maxHeight; $this->calcImageSize($this->currentDimensions['width'],$this->currentDimensions['height']); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } else { $this->workingImage = ImageCreate($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } ImageCopyResampled( $this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height'] ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $this->newDimensions['newWidth']; $this->currentDimensions['height'] = $this->newDimensions['newHeight']; } /** * Resizes the image by $percent percent * * @param int $percent */ public function resizePercent($percent = 0) { $this->percent = $percent; $this->calcImageSizePercent($this->currentDimensions['width'],$this->currentDimensions['height']); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } else { $this->workingImage = ImageCreate($this->newDimensions['newWidth'],$this->newDimensions['newHeight']); } ImageCopyResampled( $this->workingImage, $this->oldImage, 0, 0, 0, 0, $this->newDimensions['newWidth'], $this->newDimensions['newHeight'], $this->currentDimensions['width'], $this->currentDimensions['height'] ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $this->newDimensions['newWidth']; $this->currentDimensions['height'] = $this->newDimensions['newHeight']; } /** * Crops the image from calculated center in a square of $cropSize pixels * * @param int $cropSize */ public function cropFromCenter($cropSize) { if($cropSize > $this->currentDimensions['width']) $cropSize = $this->currentDimensions['width']; if($cropSize > $this->currentDimensions['height']) $cropSize = $this->currentDimensions['height']; $cropX = intval(($this->currentDimensions['width'] - $cropSize) / 2); $cropY = intval(($this->currentDimensions['height'] - $cropSize) / 2); if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($cropSize,$cropSize); } else { $this->workingImage = ImageCreate($cropSize,$cropSize); } imagecopyresampled( $this->workingImage, $this->oldImage, 0, 0, $cropX, $cropY, $cropSize, $cropSize, $cropSize, $cropSize ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $cropSize; $this->currentDimensions['height'] = $cropSize; } /** * Advanced cropping function that crops an image using $startX and $startY as the upper-left hand corner. * * @param int $startX * @param int $startY * @param int $width * @param int $height */ public function crop($startX,$startY,$width,$height) { //make sure the cropped area is not greater than the size of the image if($width > $this->currentDimensions['width']) $width = $this->currentDimensions['width']; if($height > $this->currentDimensions['height']) $height = $this->currentDimensions['height']; //make sure not starting outside the image if(($startX + $width) > $this->currentDimensions['width']) $startX = ($this->currentDimensions['width'] - $width); if(($startY + $height) > $this->currentDimensions['height']) $startY = ($this->currentDimensions['height'] - $height); if($startX < 0) $startX = 0; if($startY < 0) $startY = 0; if(function_exists("ImageCreateTrueColor")) { $this->workingImage = ImageCreateTrueColor($width,$height); } else { $this->workingImage = ImageCreate($width,$height); } imagecopyresampled( $this->workingImage, $this->oldImage, 0, 0, $startX, $startY, $width, $height, $width, $height ); $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $width; $this->currentDimensions['height'] = $height; } /** * Outputs the image to the screen, or saves to $name if supplied. Quality of JPEG images can be controlled with the $quality variable * * @param int $quality * @param string $name */ public function show($quality=100,$name = '') { switch($this->format) { case 'GIF': if($name != '') { ImageGif($this->newImage,$name); } else { header('Content-type: image/gif'); ImageGif($this->newImage); } break; case 'JPG': if($name != '') { ImageJpeg($this->newImage,$name,$quality); } else { header('Content-type: image/jpeg'); ImageJpeg($this->newImage,'',$quality); } break; case 'PNG': if($name != '') { ImagePng($this->newImage,$name); } else { header('Content-type: image/png'); ImagePng($this->newImage); } break; } } /** * Saves image as $name (can include file path), with quality of # percent if file is a jpeg * * @param string $name * @param int $quality */ public function save($name,$quality=100) { $this->show($quality,$name); } /** * Creates Apple-style reflection under image, optionally adding a border to main image * * @param int $percent * @param int $reflection * @param int $white * @param bool $border * @param string $borderColor */ public function createReflection($percent,$reflection,$white,$border = true,$borderColor = '#a4a4a4') { $width = $this->currentDimensions['width']; $height = $this->currentDimensions['height']; $reflectionHeight = intval($height * ($reflection / 100)); $newHeight = $height + $reflectionHeight; $reflectedPart = $height * ($percent / 100); $this->workingImage = ImageCreateTrueColor($width,$newHeight); ImageAlphaBlending($this->workingImage,true); $colorToPaint = ImageColorAllocateAlpha($this->workingImage,255,255,255,0); ImageFilledRectangle($this->workingImage,0,0,$width,$newHeight,$colorToPaint); imagecopyresampled( $this->workingImage, $this->newImage, 0, 0, 0, $reflectedPart, $width, $reflectionHeight, $width, ($height - $reflectedPart)); $this->imageFlipVertical(); imagecopy($this->workingImage,$this->newImage,0,0,0,0,$width,$height); imagealphablending($this->workingImage,true); for($i=0;$i<$reflectionHeight;$i++) { $colorToPaint = imagecolorallocatealpha($this->workingImage,255,255,255,($i/$reflectionHeight*-1+1)*$white); imagefilledrectangle($this->workingImage,0,$height+$i,$width,$height+$i,$colorToPaint); } if($border == true) { $rgb = $this->hex2rgb($borderColor,false); $colorToPaint = imagecolorallocate($this->workingImage,$rgb[0],$rgb[1],$rgb[2]); imageline($this->workingImage,0,0,$width,0,$colorToPaint); //top line imageline($this->workingImage,0,$height,$width,$height,$colorToPaint); //bottom line imageline($this->workingImage,0,0,0,$height,$colorToPaint); //left line imageline($this->workingImage,$width-1,0,$width-1,$height,$colorToPaint); //right line } $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $width; $this->currentDimensions['height'] = $newHeight; } /** * Inverts working image, used by reflection function * */ private function imageFlipVertical() { $x_i = imagesx($this->workingImage); $y_i = imagesy($this->workingImage); for($x = 0; $x < $x_i; $x++) { for($y = 0; $y < $y_i; $y++) { imagecopy($this->workingImage,$this->workingImage,$x,$y_i - $y - 1, $x, $y, 1, 1); } } } /** * Converts hexidecimal color value to rgb values and returns as array/string * * @param string $hex * @param bool $asString * @return array|string */ private function hex2rgb($hex, $asString = false) { // strip off any leading # if (0 === strpos($hex, '#')) { $hex = substr($hex, 1); } else if (0 === strpos($hex, '&H')) { $hex = substr($hex, 2); } // break into hex 3-tuple $cutpoint = ceil(strlen($hex) / 2)-1; $rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3); // convert each tuple to decimal $rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0); $rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0); $rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0); return ($asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb); } /** * Reads selected exif meta data from jpg images and populates $this->imageMeta with appropriate values if found * */ private function gatherImageMeta() { //only attempt to retrieve info if exif exists if(function_exists("exif_read_data") && $this->format == 'JPG') { $imageData = exif_read_data($this->fileName); if(isset($imageData['Make'])) $this->imageMeta['make'] = ucwords(strtolower($imageData['Make'])); if(isset($imageData['Model'])) $this->imageMeta['model'] = $imageData['Model']; if(isset($imageData['COMPUTED']['ApertureFNumber'])) { $this->imageMeta['aperture'] = $imageData['COMPUTED']['ApertureFNumber']; $this->imageMeta['aperture'] = str_replace('/','',$this->imageMeta['aperture']); } if(isset($imageData['ExposureTime'])) { $exposure = explode('/',$imageData['ExposureTime']); $exposure = round($exposure[1]/$exposure[0],-1); $this->imageMeta['exposure'] = '1/' . $exposure . ' second'; } if(isset($imageData['Flash'])) { if($imageData['Flash'] > 0) { $this->imageMeta['flash'] = 'Yes'; } else { $this->imageMeta['flash'] = 'No'; } } if(isset($imageData['FocalLength'])) { $focus = explode('/',$imageData['FocalLength']); $this->imageMeta['focalLength'] = round($focus[0]/$focus[1],2) . ' mm'; } if(isset($imageData['DateTime'])) { $date = $imageData['DateTime']; $date = explode(' ',$date); $date = str_replace(':','-',$date[0]) . ' ' . $date[1]; $this->imageMeta['dateTaken'] = date('m/d/Y g:i A',strtotime($date)); } } } /** * Rotates image either 90 degrees clockwise or counter-clockwise * * @param string $direction */ public function rotateImage($direction = 'CW') { if($direction == 'CW') { $this->workingImage = imagerotate($this->workingImage,-90,0); } else { $this->workingImage = imagerotate($this->workingImage,90,0); } $newWidth = $this->currentDimensions['height']; $newHeight = $this->currentDimensions['width']; $this->oldImage = $this->workingImage; $this->newImage = $this->workingImage; $this->currentDimensions['width'] = $newWidth; $this->currentDimensions['height'] = $newHeight; } } ?>
PHP
<?php class Utils { // Dada una fecha en php la retorna con formato mysql public static function getDateForDB($fecha) { if ($fecha == "") return ""; $numeros = explode("-",$fecha); return trim($numeros[2])."-".trim($numeros[1])."-".trim($numeros[0]); } public static function getDateForView($fecha) { if ($fecha == "") return ""; $numeros = explode("-",$fecha); return trim($numeros[2])."-".trim($numeros[1])."-".trim($numeros[0]); } public static function removeBlanks($texto) { return str_replace(' ','',$texto); } } ?>
PHP
<?php include_once('plugin/LoginPlugin.php'); // Valida que exista el usuario if (!LoginPlugin::isLogged()) { include_once('coreapi/SmartyManager.php'); $smarty = SmartyManager::getSmarty(); $smarty->display('login.tpl'); }
PHP
<?php // Include include_once('plugin/SmartyPlugin.php'); include_once('plugin/LoginPlugin.php'); include_once('plugin/AppConfigPlugin.php'); include_once('plugin/SecurityAccessPlugin.php'); include_once('plugin/CommonPlugin.php'); // Para establecer locale en espanol (evita problemas como el formateo de la fecha de Smarty) setlocale (LC_TIME,"spanish"); // Chequea si el usuario ya esta logueado if (!LoginPlugin::isLogged()) { header( 'Location: index.php' ); exit; } // Current script $currentScript = AppConfigPlugin::getCurrentScript(); //error_reporting(0); $currentUrl = AppConfigPlugin::curPageURL(); // Ejecucion $username = LoginPlugin::getUsername(); $rol = LoginPlugin::getRol(); $clubRol = LoginPlugin::getClub(); $menuItems = AppConfigPlugin::getMenuItems($rol); $manageItems = AppConfigPlugin::getManageItems(); $appInfo = AppConfigPlugin::getAppInfo(); $iconsImg = AppConfigPlugin::getIconsImg(); // Mensaje $message = CommonPlugin::getMessage(); CommonPlugin::setMessage(""); // Creacion de Smarty $smarty = SmartyPlugin::getSmarty(); $smarty->assign('menuItems', $menuItems); $smarty->assign('manageItems', $manageItems); $smarty->assign('appInfo', $appInfo); $smarty->assign('iconsImg', $iconsImg); $smarty->assign('username', $username); $smarty->assign('rol', $rol); $smarty->assign('message', $message); // Sons $sons = AppConfigPlugin::getSons(basename($_SERVER['PHP_SELF'])); $smarty->assign('sons', $sons); $smarty->assign('currentScript', $currentScript); $menuItems = AppConfigPlugin::getMenuItems(null); if (!SecurityAccessPlugin::hasAccess($menuItems, $currentUrl, $manageItems, $rol)) { $smarty->display('noaccess.tpl'); exit(); }
PHP
<?php require_once('include/header.php'); require_once('dao/FactoryDAO.php'); require_once('plugin/UtilsPlugin.php'); require_once('vo/ContenidoVO.php'); require_once('search/ContenidoSearchCriteria.php'); class ContenidoLogic { var $_POST; var $contenidoDAO; function ContenidoLogic($post){ $this->$_POST = $post; $this->contenidoDAO = FactoryDAO::getDao('ContenidoDAO'); } function save($post) { $vo = new ContenidoVO(); $vo->setId($post['id']); $vo->setTitulo($post['titulo']); $vo->setTexto($post['texto']); $vo->setDescripcion($post['descripcion']); $vo->setImagen($post['imagen']); $vo->setBorrado($post['borrado']); if ( isset($post['id']) && $post['id'] != "" ) { return $this->contenidoDAO->update($vo); } else{ return $this->contenidoDAO->insert($vo); } } function delete($id) { return $this->contenidoDAO->delete($id); } function get($id) { return $this->contenidoDAO->get($id); } function find($contenidoSearchCriteria) { return $this->contenidoDAO->find($contenidoSearchCriteria); } function count($contenidoSearchCriteria) { return $this->contenidoDAO->count($contenidoSearchCriteria); } }//end class
PHP
<?php require_once('include/header.php'); require_once('plugin/UtilsPlugin.php'); require_once('dao/FactoryDAO.php'); require_once('vo/ImagenesVO.php'); require_once('search/ImagenesSearchCriteria.php'); /** * Business logic directly reflects the use cases. The business logic deals with VOs, * modifies them according to the business requirements and uses DAOs to access the persistence layer. * The business logic classes should provide means to retrieve information about errors that occurred. * * @author dintech * */ Class ImagenesLogic { var $_POST; var $ImagenesDAO; var $noticiaDAO; /** * Constructor * @param POST array $_POST */ function ImagenesLogic($post){ $this->$_POST = $post; $this->ImagenesDAO = FactoryDAO::getDao('ImagenesDAO'); // *** Reemplazar por el DAO de la tabla que se quiera instanciar *** $this->noticiasDAO = FactoryDAO::getDao('NoticiasDAO'); } /** * Guarda una imagen en la DB y * copia la imagen (y su thumbnail) al directorio /images/$_POST[t] * @param POST array $_POST * @param FILES array $files */ function save($post, $files){ // Genero el nombre del archivo = <idauto>_<nroimagen>.<extension> require_once 'plugin/FileUtilityPlugin.php'; $extension = FileUtilityPlugin::getExtension($files['imgfile']['name']); // Genero nuevo nombre unico para la imagen srand(time()); $randomCode = rand(1,10000); $newFileName = $post['iditem'] . '_' . $randomCode . "." . $extension; $imagesVO = new ImagenesVO(); $imagesVO->setAlt($post['alt']); $imagesVO->setDate(Utils::getDateForDB(date("d-m-Y"))); $imagesVO->setDescription($post['descripcion']); $imagesVO->setFilename($newFileName); $imagesVO->setHeight($post['height']); $imagesVO->setId(null); $imagesVO->setIditem($post['iditem']); $imagesVO->setOrder($post['order']); $imagesVO->setSize($files['imgfile']['size']); $imagesVO->setTable($post['t']); $imagesVO->setWidth($post['width']); $result = $this->ImagenesDAO->save($imagesVO); // obtengo ID de la imagen recien agregada $newImageId = $this->ImagenesDAO->getLastInsertId(); // *** Reemplazar por el DAO de la tabla que se quiera instanciar *** // incremento el imagecount de la noticia $imageSearchCriteria = new ImagenesSearchCriteria(); $imageSearchCriteria->setIditem($post['iditem']); $imageSearchCriteria->setTable($post['t']); $images = $this->find($imageSearchCriteria); $this->ImagenesDAO->updateImageinfo($post['t'], $post['iditem'], (count($images) == 1) ? $newImageId : null, 1); if ($result != "error"){ $error = false; // genero nombre de path y thumbnailPath $path = "images/".$post['t']."/". $newFileName; $thumbnailPath = "images/".$post['t']."/small/". $newFileName; // copia archivo al server if(move_uploaded_file($files['imgfile']['tmp_name'], $path)) { ; } else{ $error = true; } copy($files['uploadedfile']['tmp_name'], $path); // genera thumbnail y lo copia en el path /small require_once 'plugin/ThumbnailPlugin.php'; $thumb = new Thumbnail($path); $thumb->resize(960); $thumb->save($path, 100); $thumb = new Thumbnail($path); $thumb->resize(250); $thumb->save($thumbnailPath, 100); if ($error) return "error"; else return "ok"; } else return $result; return; } /** * Actualiza la informacion de una imagen (descripcion y default - en un futuro) * @param POST array $post */ function update($post){ $imagesVO = new ImagenesVO(); $imagesVO->setDescription($post['descripcion']); $imagesVO->setId($post['id']); $result = $this->ImagenesDAO->save($imagesVO); if ($post['defaultimage'] == 1) $this->ImagenesDAO->updateImageinfo($post['t'], $post['iditem'], $post['id'], 0); return $result; } /** * Elimina una imagen de la DB y tambien fisicamente el archivo * de la imagen y su thumbnail * @param POST array $post */ function delete($post){ // chequear si imagesid (FK) es igual a la que se quiere eliminar $noticia = $this->noticiasDAO->get($post['iditem']); $newImageId = null; $replaceImageId = false; if ($noticia[imagesid] == $post[id] && $noticia[imagecount] > 1) { $replaceImageId = true; // obtener otra imagen para seleccionar como la nueva imagesid (FK) $imageSearchCriteria = new ImagenesSearchCriteria(); $imageSearchCriteria->setIditem($post['iditem']); $images = $this->find($imageSearchCriteria); foreach ($images as $image) { if ($image[id] != $post[id]) { $newImageId = $image[id]; break; } } } // elimino fisicamente la imagen y su thumbnail $imagen = $this->ImagenesDAO->get($post[id]); $path = "images/".$imagen[tablename]."/". $imagen[filename]; $thumbnailPath = "images/".$imagen[tablename]."/small/". $imagen[filename]; unlink($path); unlink($thumbnailPath); // *** Reemplazar por el DAO de la tabla que se quiera instanciar *** // decremento en uno el imagecount de iditem $this->ImagenesDAO->updateImageinfo($post['t'], $post['iditem'], ($replaceImageId) ? $newImageId : null, -1); // elimino la imagen de la DB return $this->ImagenesDAO->delete($post[id]); } /** * Devuelve una imagen a partir de su ID * @param ID $id */ function get($id){ return $this->ImagenesDAO->get($id); } /** * Retorna todas las imagen que hagan matching * con el criterio definido en $imageSearchCriterio * @param ImageSearchCriteria $imageSearchCriteria */ function find($imageSearchCriteria){ return $this->ImagenesDAO->find($imageSearchCriteria); } /** * Retorna la cantidad de imagenes que hacen matching * con el criterio definido en $imageSearchCriteria * @param ImageSearchCriteria $imageSearchCriteria */ function count($imageSearchCriteria){ return $this->ImagenesDAO->count($imageSearchCriteria); } /** * Retorna la entidad (cualquier tabla que use el modulo de imagenes) * @return Entidad */ function getEntidad($table, $iditem) { return $this->ImagenesDAO->getEntidad($table, $iditem); } } ?>
PHP
<?php require_once('include/header.php'); require_once('dao/FactoryDAO.php'); require_once('plugin/UtilsPlugin.php'); require_once('vo/ClientesVO.php'); require_once('search/ClientesSearchCriteria.php'); class ClientesLogic { var $_POST; var $clientesDAO; function ClientesLogic($post){ $this->$_POST = $post; $this->clientesDAO = FactoryDAO::getDao('ClientesDAO'); } function save($post) { $vo = new ClientesVO(); $vo->setId($post['id']); $vo->setNombre($post['nombre']); $vo->setMail($post['mail']); $vo->setTelefono($post['telefono']); $vo->setCiudad($post['ciudad']); $vo->setActive($post['active']); $vo->setFecha($post['fecha']); $vo->setBorrado($post['borrado']); if ( isset($post['id']) && $post['id'] != "" ) { return $this->clientesDAO->update($vo); } else{ return $this->clientesDAO->insert($vo); } } function delete($id) { return $this->clientesDAO->delete($id); } function get($id) { return $this->clientesDAO->get($id); } function find($clientesSearchCriteria) { return $this->clientesDAO->find($clientesSearchCriteria); } function count($clientesSearchCriteria) { return $this->clientesDAO->count($clientesSearchCriteria); } }//end class
PHP
<?php require_once('include/header.php'); require_once('dao/FactoryDAO.php'); require_once('plugin/UtilsPlugin.php'); require_once('vo/NoticiasVO.php'); require_once('search/NoticiasSearchCriteria.php'); class NoticiasLogic { var $_POST; var $noticiasDAO; function NoticiasLogic($post){ $this->$_POST = $post; $this->noticiasDAO = FactoryDAO::getDao('NoticiasDAO'); } function save($post) { $vo = new NoticiasVO(); $vo->setId($post['id']); $vo->setTitulo($post['titulo']); $vo->setTags($post['tags']); $vo->setResumen($post['resumen']); $vo->setContenido($post['contenido']); $vo->setFecha(Utils::getDateForDB($post['fecha'])); $vo->setCategoria($post['categoria']); $vo->setSeccion($post['seccion']); $vo->setOrden($post['orden']); $vo->setVisitas($post['visitas']); $vo->setActivo($post['activo']); $vo->setBorrado($post['borrado']); if ( isset($post['id']) && $post['id'] != "" ) { return $this->noticiasDAO->update($vo); } else{ return $this->noticiasDAO->insert($vo); } } function delete($id) { return $this->noticiasDAO->delete($id); } function get($id) { return $this->noticiasDAO->get($id); } function find($noticiasSearchCriteria) { return $this->noticiasDAO->find($noticiasSearchCriteria); } function count($noticiasSearchCriteria) { return $this->noticiasDAO->count($noticiasSearchCriteria); } function activar($id) { return $this->noticiasDAO->activar($id); } function desactivar($id) { return $this->noticiasDAO->desactivar($id); } }//end class ?>
PHP
<?php require_once('include/header.php'); require_once('dao/FactoryDAO.php'); require_once('plugin/UtilsPlugin.php'); require_once('vo/ContactoVO.php'); require_once('search/ContactoSearchCriteria.php'); class ContactoLogic { var $_POST; var $contactoDAO; function ContactoLogic($post){ $this->$_POST = $post; $this->contactoDAO = FactoryDAO::getDao('ContactoDAO'); } function save($post) { $vo = new ContactoVO(); $vo->setId($post['id']); $vo->setEmpresa($post['empresa']); $vo->setNombre($post['nombre']); $vo->setDireccion($post['direccion']); $vo->setTelefono($post['telefono']); $vo->setCelular($post['celular']); $vo->setMail($post['mail']); $vo->setWeb($post['web']); $vo->setBorrado($post['borrado']); if ( isset($post['id']) && $post['id'] != "" ) { return $this->contactoDAO->update($vo); } else{ return $this->contactoDAO->insert($vo); } } function delete($id) { return $this->contactoDAO->delete($id); } function get($id) { return $this->contactoDAO->get($id); } function find($contactoSearchCriteria) { return $this->contactoDAO->find($contactoSearchCriteria); } function count($contactoSearchCriteria) { return $this->contactoDAO->count($contactoSearchCriteria); } }//end class
PHP
<?php require_once('include/header.php'); require_once('dao/FactoryDAO.php'); require_once('vo/UsuarioVO.php'); require_once('search/UsuarioSearchCriteria.php'); /** * Business logic directly reflects the use cases. The business logic deals with VOs, * modifies them according to the business requirements and uses DAOs to access the persistence layer. * The business logic classes should provide means to retrieve information about errors that occurred. * * @author dintech * */ Class UsuariosLogic { var $_POST; var $usuarioDAO; function UsuariosLogic($post){ $this->$_POST = $post; $this->usuarioDAO = FactoryDAO::getDao('UsuarioDAO'); } function save($post){ $usuarioVO = new UsuarioVO(); $usuarioVO->setId($post['id']); $usuarioVO->setUsername($post['username']); $passw = $post['passw']; // solo setear passw si existe (ej. agregar nuevo usuario) if (($passw != null) && ($passw != "")) $usuarioVO->setPassw(md5($post['passw'])); $usuarioVO->setRol($post['rol'].'_'.$post['club']); if ( isset($$post['id']) && $post['id'] != "" ) return $this->usuarioDAO->update($usuarioVO); else return $this->usuarioDAO->save($usuarioVO); } function delete($id){ return $this->usuarioDAO->delete($id); } function get($id){ return $this->usuarioDAO->get($id); } function getByUsername($username){ return $this->usuarioDAO->getByUsername($username); } function find($usuarioSearchCriteria){ return $this->usuarioDAO->find($usuarioSearchCriteria); } function count($usuarioSearchCriteria){ return $this->usuarioDAO->count($usuarioSearchCriteria); } function changePassword($username, $_POST) { $usuarioDAO = $this->usuarioDAO->getByUsername($username); if ($usuarioDAO[passw] == md5($_POST['password'])) { $usuarioVO = new UsuarioVO(); $usuarioVO->setId($usuarioDAO[id]); $usuarioVO->setUsername($usuarioDAO[username]); $usuarioVO->setPassw(md5($_POST['newpassword'])); $usuarioVO->setRol($usuarioDAO[rol]); return $this->usuarioDAO->save($usuarioVO); } else return "passw_not_match"; } } ?>
PHP
<?php require_once('include/header.php'); require_once('dao/FactoryDAO.php'); require_once('plugin/UtilsPlugin.php'); require_once('vo/AvisosVO.php'); require_once('search/AvisosSearchCriteria.php'); class AvisosLogic { var $_POST; var $avisosDAO; function AvisosLogic($post){ $this->$_POST = $post; $this->avisosDAO = FactoryDAO::getDao('AvisosDAO'); } function save($post) { $vo = new AvisosVO(); $vo->setId($post['id']); $vo->setFechatexto($post['fechatexto']); $vo->setFecha(Utils::getDateForDB($post['fecha'])); $vo->setDescripcion($post['descripcion']); if ( isset($post['id']) && $post['id'] != "" ) { return $this->avisosDAO->update($vo); } else{ return $this->avisosDAO->insert($vo); } } function delete($id) { return $this->avisosDAO->delete($id); } function get($id) { return $this->avisosDAO->get($id); } function find($avisosSearchCriteria) { return $this->avisosDAO->find($avisosSearchCriteria); } function count($avisosSearchCriteria) { return $this->avisosDAO->count($avisosSearchCriteria); } }//end class
PHP
<?php require_once('include/header.php'); require_once('vo/ContactoVO.php'); require_once('search/ContactoSearchCriteria.php'); require_once('logic/ContactoLogic.php'); require('conf/configuration.php'); $logic = new ContactoLogic($_POST); // Ordenamiento if($_GET[order] == "asc") $order= "desc"; else if($_GET[order] == "desc") $order= "asc"; else $order= "desc"; if (!isset($_GET["orderby"])) $orderby = "Id"; else $orderby = $_GET["orderby"]; $smarty->assign("orderby", $orderby); $smarty->assign("order", $order); // Seteo el searchcriteria para mostrar la tabla con todos los resultados segun el filtro. (sin paginacion) $contactoSearchCriteria = new ContactoSearchCriteria(); $contactoSearchCriteria->setOrderby($orderby); $contactoSearchCriteria->setOrder($order); //$contactoSearchCriteria->setSearch($_GET["search"]); $contactoSearchCriteria->setInicio(1); $contactoSearchCriteria->setFin(null); // Controller $action = $_GET["action"]; if ($action == null){ $action = $_POST["action"]; } switch ($action){ case "save": $result = $logic->save($_POST); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al guardar los cambios del Registro de Contacto"); else $smarty->assign("message", "El Registro de Contactoha sido actualizado"); break; case "add": $smarty->assign("detailPage","contactoForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "update": $id = $_GET["id"]; if ($id != null){ $contacto = $logic->get($id); $smarty->assign("contacto", $contacto); } $smarty->assign("detailPage","contactoForm.tpl"); $smarty->display("admin_generic.tpl"); exit;break; case "detail": $id = $_GET["id"]; if ($id != null){ $contacto = $logic->get($id); $smarty->assign("contacto", $contacto); } $smarty->assign("detailPage","contactoDetail.tpl"); $smarty->display("admin_generic.tpl"); exit; break; case "delete": $result = $logic->delete($_POST["id"]); if ($result == "error") $smarty->assign("error", "Ha ocurrido un error al eliminar el Registro de "); else $smarty->assign("message", "Se ha eliminado el Registro de "); break; } // Paginador $cantidad = $logic->count($contactoSearchCriteria); $totalItemsPerPage=10; if (isset($_GET["entradas"])) $totalItemsPerPage=$_GET["entradas"]; $totalPages = ceil($cantidad / $totalItemsPerPage); $smarty->assign("totalPages", $totalPages); $smarty->assign("totalItemsPerPage", $totalItemsPerPage); $page = $_GET[page]; if (!$page) { $start = 0; $page = 1; $smarty->assign("page", $page); } else $start = ($page - 1) * $totalItemsPerPage; $smarty->assign("page", $page); // Obtengo solo los registros de la pagina actual. $contactoSearchCriteria->setInicio($start); $contactoSearchCriteria->setOrderby($orderby); $contactoSearchCriteria->setOrder($order); $contactoSearchCriteria->setFin($totalItemsPerPage); $contacto = $logic->find($contactoSearchCriteria); $smarty->assign("allParams", CommonPlugin::getParamsAsString($_GET)); $smarty->assign("cantidad", $cantidad); $contacto = $logic->get(1); $smarty->assign("contacto", $contacto); $smarty->assign("detailPage", "contactoForm.tpl"); $smarty->display("admin_generic.tpl"); ?>
PHP
<?php /** * When a page is called, the page controller is run before any output is made. * The controller's job is to transform the HTTP request into business objects, * then call the approriate logic and prepare the objects used to display the response. * * The page logic performs the following steps: * 1. The cmd request parameter is evaluated. * 2. Based on the action other request parameters are evaluated. * 3. Value Objects (or a form object for more complex tasks) are created from the parameters. * 4. The objects are validated and the result is stored in an error array. * 5. The business logic is called with the Value Objects. * 6. Return status (error codes) from the business logic is evaluated. * 7. A redirect to another page is executed if necessary. * 8. All data needed to display the page is collected and made available to the page as variables of the controller. Do not use global variables. * * * @author dintech * */ require_once('include/header.php'); require_once('plugin/CommonPlugin.php'); require_once('logic/UsuariosLogic.php'); require('conf/configuration.php'); $logic = new UsuariosLogic($_POST); $action = $_GET['action']; if ($action == null){ $action = $_POST['action']; } switch ($action){ case "changepassword": if ($_POST['sendform']=="1"){ // TODO Diego, esta logica esta bien aca? o debe ir en el Logic? // Chequea passwords if ($_POST['newpassword'] != $_POST['repeatnewpassword']) { $smarty->assign('error', "Error: La nueva contrase&ntilde;a debe coincidir"); break; } if (trim($_POST['newpassword']) == "") { $smarty->assign('error', "Error: La nueva contrase&ntilde;a no puede estar vacia"); break; } $username = LoginPlugin::getUsername(); $result = $logic->changePassword($username, $_POST); if ($result == "passw_not_match") { $smarty->assign('error', "Error: La contrase&ntilde;a no coincide con la actual"); break; } else { $smarty->assign('message', "Su nueva contrase&ntilde;a ha sido guardada correctamente"); break; } //$result = $logic->save($_POST); //$success = UsersDBPlugin::changePassword($username, $_POST[actualpassword], $_POST[newpassword]); //echo $username; } break; } $smarty->display('myaccount.tpl'); ?>
PHP
<?php // Include include_once('plugin/LoginPlugin.php'); include_once('plugin/SmartyPlugin.php'); include_once('plugin/AppConfigPlugin.php'); include_once('plugin/CommonPlugin.php'); // Ejecutar la accion if (isset($_GET[action])) { require_once($_GET[action].".php"); } // Chequea si el usuario ya esta logueado if (LoginPlugin::isLogged()) { header( 'Location: contenido.php' ); exit; } // Ejecucion $smarty = SmartyPlugin::getSmarty(); $appInfo = AppConfigPlugin::getAppInfo(); $message = CommonPlugin::getMessage(); CommonPlugin::setMessage(""); // Smarty call $smarty->assign('message', $message); $smarty->assign('appInfo', $appInfo); $smarty->display('admin_login.tpl');
PHP
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Category Management</title> <link href="css/style.css" rel="stylesheet"> </head> <body> <?php require_once dirname(__FILE__) . '/dao_category.php'; $dao_category = new dao_category(); //Load table list $list_category = $dao_category->get_all(); //Load select list $list_parent_category = $dao_category->get_all(); //Load edit item if (!empty($_GET['e_id'])) { $edit_item = $dao_category->get_by_id($_GET['e_id']); } //If insert action if (!empty($_POST['btn_insert']) && empty($_GET['e_id'])) : $cat_name = $_POST['txt_cat_name']; $parent_id = $_POST['ddl_parent']; if ($dao_category->insert($cat_name, $parent_id)) : ?> <script type="text/javascript"> alert('Inserted new category successfully!'); window.location = "index.php"; </script> <?php else : ?> <script type="text/javascript"> alert('Failed, the category name existed!'); window.location = "index.php"; </script> <?php endif; endif; //If edit action if (!empty($_POST['btn_edit']) && !empty($_GET['e_id'])) : $cat_id = $_GET['e_id']; $cat_name = $_POST['txt_cat_name']; $parent_id = $_POST['ddl_parent']; $result = $dao_category->edit($cat_id, $cat_name, $parent_id); if ($result == 1) : ?> <script type="text/javascript"> alert('Edited category successfully!'); window.location = "index.php"; </script> <?php elseif ($result == 0) : ?> <script type="text/javascript"> alert('Failed, the category name existed!'); window.location = "index.php"; </script> <?php elseif ($result == -1) : ?> <script type="text/javascript"> alert('Failed, category is the same as parent!'); window.location = "index.php"; </script> <?php endif; endif; //If delete action if (!empty($_GET['d_id'])) { $d_id = $_GET['d_id']; if ($dao_category->delete($d_id)) : ?> <script type="text/javascript"> alert('Deleted category successfully!'); window.location = "index.php"; </script> <?php else: ?> <script type="text/javascript"> alert('Deleted category failed!'); window.location = "index.php"; </script> <?php endif; } ?> <form name="cat_form" method="POST"> <div class="container"> <div class="top"> <label for="txt_cat_name">Category Name:<span style="color: red;">*</span></label> <input name="txt_cat_name" type="text" value="<?php if (!empty($edit_item)) echo $edit_item['cat_name']; ?>" placeholder="Category Name" required=""> <br/> <br/> <label for="ddl_parent">Select Parent Category:</label> <select name="ddl_parent"> <?php if (empty($list_parent_category)): ?> <option value="-1">Default</option> <?php else: ?> <option value="-1">Default</option> <?php foreach ($list_parent_category as $item) : ?> <option value="<?php echo $item['cat_id']; ?>" <?php if (!empty($edit_item) && $edit_item['parent_id'] > -1 && $edit_item['parent_id'] == $item['cat_id']) echo 'selected="selected"'; ?> ><?php echo $item['cat_name']; ?></option> <?php endforeach; endif; ?> </select> <br/> <br/> <input type="submit" name="btn_insert" value="Insert"> <input type="submit" name="btn_edit" value="Edit"> </div> <div class="bottom"> <table> <tr> <th>Category ID</th> <th>Category Name</th> <th>Parent Category ID</th> <th>Parent Category Name</th> <th colspan="2">Action</th> </tr> <?php foreach ($list_category as $item): ?> <tr> <td><?php echo $item['cat_id'] ?></td> <td><?php echo $item['cat_name'] ?></td> <td><?php echo $item['parent_id'] ?></td> <td><?php echo $dao_category->get_name($item['parent_id']) ?></td> <td> <a href="index.php?e_id=<?php echo $item['cat_id'] ?>">edit</a> </td> <td> <a href="index.php?d_id=<?php echo $item['cat_id'] ?>" onclick="return confirm('Are you sure? All children of this category will aslo be deleted!');">delete</a> </td> </tr> <?php endforeach; ?> </table> </div> </div> </form> </body> </html>
PHP
<?php require_once dirname(__FILE__) . '/config.php'; class db_connection { public function open_connect() { $config = new config(); $db_host = $config->get_db_host(); $db_user = $config->get_db_user(); $db_pass = $config->get_db_pass(); $db_name = $config->get_db_name(); $con = new mysqli($db_host, $db_user, $db_pass, $db_name) or die("Can't connect to database"); return $con; } public function close_connect($con) { mysqli_close($con); } }
PHP
<?php require_once dirname(__FILE__) . '/db_connection.php'; class dao_category { /** * * @return array of all category */ public function get_all() { $db = new db_connection(); $con = $db->open_connect(); $query = "SELECT * FROM tbl_category"; $result = mysqli_query($con, $query) or die('Failed ' . mysqli_error()); $list = array(); while ($row = mysqli_fetch_array($result)) { array_push($list, $row); } $db->close_connect($con); return $list; } /** * * @param type $cat_id * @param type $cat_name * @return boolean */ public function check($cat_name) { $db = new db_connection(); $con = $db->open_connect(); $query = "SELECT * FROM tbl_category WHERE cat_name = '" . $cat_name . "' "; $result = mysqli_query($con, $query) or die('Failed ' . mysqli_error()); if (mysqli_fetch_array($result) == TRUE) { $db->close_connect($con); return TRUE; } else { $db->close_connect($con); return FALSE; } } public function get_by_id($cat_id) { $db = new db_connection(); $con = $db->open_connect(); $query = "SELECT * FROM tbl_category WHERE cat_id = " . $cat_id; $result = mysqli_query($con, $query) or die('Failed ' . mysqli_error()); $row = mysqli_fetch_array($result); $db->close_connect($con); return $row; } /** * * @param type $cat_name * @param type $parent_id * @return TRUE: insert success * @return FALSE: insert failed */ public function insert($cat_name, $parent_id) { $db = new db_connection(); $con = $db->open_connect(); if ($this->check($cat_name)) { $db->close_connect($con); return FALSE; } $query = "INSERT INTO tbl_category(cat_name, parent_id) VALUES ('" . $cat_name . "', " . $parent_id . ")"; mysqli_query($con, $query) or die('Insert Failed! : ' . mysqli_error()); $db->close_connect($con); return TRUE; } /** * * @param type $cat_id * @param type $cat_name * @param type $parent_id * @return boolean */ public function edit($cat_id, $cat_name, $parent_id) { $db = new db_connection(); $con = $db->open_connect(); $check_query = "SELECT * FROM tbl_category WHERE cat_id != " . $cat_id . " AND cat_name = '" . $cat_name . "'"; $result = mysqli_query($con, $check_query) or die('Failed query!'); $row = mysqli_fetch_array($result); if (!empty($row)) { return -1; } if($cat_id == $parent_id){ return 0; } $query = "UPDATE tbl_category SET cat_name = '" . $cat_name . "', parent_id = " . $parent_id . " WHERE cat_id = " . $cat_id; mysqli_query($con, $query) or die('Update Failed! : ' . mysqli_error()); $db->close_connect($con); return 1; } /** * * @param type $cat_id * @return array parent of Cat ID input */ public function get_children($cat_id){ $db = new db_connection(); $con = $db->open_connect(); $query = "SELECT * FROM tbl_category WHERE parent_id = " . $cat_id; $result = mysqli_query($con, $query) or die('Select Failed! : ' . mysqli_error()); $list_children = array(); while ($row = mysqli_fetch_array($result)) { array_push($list_children, $row); } $db->close_connect($con); return $list_children; } public function delete_basic($cat_id) { $db = new db_connection(); $con = $db->open_connect(); $query = "DELETE FROM tbl_category WHERE cat_id = " . $cat_id; mysqli_query($con, $query) or die('Update Failed! : ' . mysqli_error()); $db->close_connect($con); } public function delete($cat_id) { $db = new db_connection(); $con = $db->open_connect(); $children = $this->get_children($cat_id); foreach ($children as $child): $list_child = $this->get_children($child['cat_id']); if (empty($list_child)) : $this->delete_basic($child['cat_id']); else : $this->delete($child['cat_id']); endif; endforeach; $this->delete_basic($cat_id); $db->close_connect($con); return TRUE; } public function get_name($cat_id) { $db = new db_connection(); $con = $db->open_connect(); if ($cat_id == -1) { return "NULL"; } $query = "SELECT * FROM tbl_category WHERE cat_id = " . $cat_id; $result = mysqli_query($con, $query) or die('Failed ' . mysqli_error()); $row = mysqli_fetch_array($result); $db->close_connect($con); return $row['cat_name']; } }
PHP
<?php class config { private $db_name = '1191_category_management'; private $db_host = 'localhost'; private $db_user = 'root'; private $db_pass = ''; public function get_db_name() { return $this->db_name; } public function get_db_host() { return $this->db_host; } public function get_db_user() { return $this->db_user; } public function get_db_pass() { return $this->db_pass; } }
PHP
<?php get_header(); ?> <a name="pagetop" id="pagetop"></a> <div id="wrapper"> <!-- コンテンツ START --> <div id="main" class="top_main clearfix"> <!-- コンテンツ START --> <div class="top_img"> <h1><img src="<?php bloginfo('template_url'); ?>/images/front/img_h1.png" alt="梨衣名" width="152" height="80" title="梨衣名" /></h1> </div> <div class="top_msg"> <?php if(have_posts()): the_post(); the_content(); endif; ?> </div> </div> <!-- //コンテンツ END// --> <!-- グローバルナビ START --> <?php echo get_navi(); ?> <!-- //グローバルナビ END// --> <!-- Pagetop START --> <div class="pagetop"> <p><a href="#pagetop">▲Page Topに戻る</a></p> </div> <!-- //Pagetop END// --> <?php get_footer(); ?>
PHP
<?php define("PACKAGE_ROOT", dirname(__FILE__)); include_once PACKAGE_ROOT.'/conf/facebook_const.php'; include_once PACKAGE_ROOT.'/lib/mastercontrol.php'; //+++++++++++++++++++++++++++++++++++++++++ //カスタムヘッダー include_once 'lib/func_header.php'; include_once 'lib/func_footer.php'; include_once 'lib/layout/func.php'; include_once 'lib/design/func.php'; include_once 'lib/social.php'; add_shortcode('ogp_single_blog', 'ogp_single_base_content'); add_shortcode('blog_like', 'get_base_like'); /* add_custom_image_header('','admin_header_style'); function admin_header_style() {} //標準のヘッダー画像を指定 define('HEADER_IMAGE','%s/images/header.jpg'); //ヘッダー画像の横幅と高さを指定 define('HEADER_IMAGE_WIDTH','256'); define('HEADER_IMAGE_HEIGHT','88'); //ヘッダーの文字を隠す define('NO_HEADER_TEXT',true); //背景画像を指定 add_custom_background(); //記事のpタグを削除 remove_filter('the_content', 'wpautop'); */ //+++++++++++++++++++++++++++++++++++++++++ //カスタムメニュー include_once 'lib/func_gnavi.php'; /* register_nav_menus(array( 'navbar' => 'ナビゲーションバー', 'sidebar' => 'サイドバー' )); */ //+++++++++++++++++++++++++++++++++++++++++ //エディタ・スタイルシート add_editor_style(); //+++++++++++++++++++++++++++++++++++++++++ //ウィジェット登録 register_sidebar(array( 'description' => '', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '' ) ); register_sidebar(array( 'description' => '', 'before_widget' => '', 'after_widget' => '', 'before_title' => '', 'after_title' => '' ) ); //ウィジェットタイトル非表示 function my_widget_title( $title ) { return ''; } add_filter( 'widget_title', 'my_widget_title' ); //+++++++++++++++++++++++++++++++++++++++++ // アイキャチ画像 add_theme_support('post-thumbnails'); set_post_thumbnail_size(120, 90, true); //set_post_thumbnail_size(120, 90); //+++++++++++++++++++++++++++++++++++++++++ // アイキャチ画像のURLを取得 function get_featured_image_url() { $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id, 'thumbnail', true); echo $image_url[0]; } //+++++++++++++++++++++++++++++++++++++++++ // 管理バーを消す add_filter( 'show_admin_bar', '__return_false' ); //+++++++++++++++++++++++++++++++++++++++++ // ログイン画面ロゴ function custom_login_logo() { echo '<style type="text/css">h1 a { background: url('.get_bloginfo('template_directory').'/images/tool/master_control_image.png) 50% 50% no-repeat !important; }</style>'; } add_action('login_head', 'custom_login_logo'); //+++++++++++++++++++++++++++++++++++++++++ // 管理画面左上のロゴ add_action('admin_head', 'my_custom_logo'); function my_custom_logo() { echo '<style type="text/css">#header-logo { background-image:url('.get_bloginfo('template_directory').'/images/tool/master_control_logo.png) !important; }</style>'; } //+++++++++++++++++++++++++++++++++++++++++ // 管理画面フッターのテキスト function custom_admin_footer() { echo '© CYBIRD Co., Ltd All Rights Reserved.'; } add_filter('admin_footer_text', 'custom_admin_footer'); //+++++++++++++++++++++++++++++++++++++++++ // HTML エディタのフォントを変更 function change_editor_font(){ echo "<style type='text/css'> #editorcontainer textarea#content { font-family: \"ヒラギノ角ゴ Pro W3\", \"Hiragino Kaku Gothic Pro\", Osaka, \"MS Pゴシック\", sans-serif; font-size:14px; color:#333; } </style>"; } add_action("admin_print_styles", "change_editor_font"); //+++++++++++++++++++++++++++++++++++++++++ // アドミンバーを消す add_filter('show_admin_bar','__return_false'); //+++++++++++++++++++++++++++++++++++++++++ // 管理者以外にアップデートのお知らせ非表示 if (!current_user_can('edit_users')) { function wphidenag() { remove_action( 'admin_notices', 'update_nag'); } add_action('admin_menu','wphidenag'); } //+++++++++++++++++++++++++++++++++++++++++ // 管理者以外にダッシュボードの内容非表示 if (!current_user_can('edit_users')) { remove_all_actions('wp_dashboard_setup'); function example_remove_dashboard_widgets() { global $wp_meta_boxes; //Main column unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']); unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); //Side Column unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); } add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' ); } //+++++++++++++++++++++++++++++++++++++++++ // 管理者以外は[表示オプション][ヘルプ]のタブを非表示にする if (!current_user_can('edit_users')) { function my_admin_print_styles(){ echo ' <style type="text/css"> #screen-options-link-wrap, #contextual-help-link-wrap{display:none;} </style>'; } add_action('admin_print_styles', 'my_admin_print_styles', 21); } //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト Event情報 include_once 'lib/module/info/func.php'; /* register_post_type( 'event', array( 'label' => 'イベント情報', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/event.png', 'supports' => array( 'title', 'editor' ) ) ); */ //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト photogallery register_post_type( 'photogallery', array( 'label' => 'フォトギャラリー', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/media.png', 'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト DISCOGRAPHY register_post_type( 'discography', array( 'label' => 'ディスコグラフィー', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/discography.png', 'supports' => array( 'title', ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト MEDIA register_post_type( 'media', array( 'label' => 'メディア/出演情報', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/media.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト BLOG include_once 'lib/module/blog/func.php'; /* register_post_type( 'blog', array( 'label' => 'ブログ', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/blog.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); */ //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト MULTI-BLOG register_post_type( 'multiblog', array( 'label' => 'マルチブログ', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/blog.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト ITUNES register_post_type( 'itunes', array( 'label' => 'iTunes', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/itune.png', 'supports' => array( 'title', 'editor' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト GOODS register_post_type( 'goods', array( 'label' => 'グッズ', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/goods.png', 'supports' => array( 'title', 'thumbnail' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト Twitter include_once 'lib/module/twitter/func.php'; /* register_post_type( 'twitter', array( 'label' => 'Twitter', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/twitter.png', 'supports' => array( 'title' ) ) ); */ //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト YouTube register_post_type( 'youtube', array( 'label' => 'YouTube', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/youtube.png', 'supports' => array( 'title' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト Profile register_post_type( 'profile', array( 'label' => 'プロフィール', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/profile.png', 'supports' => array( 'title', 'editor' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト MasterControl Setting register_post_type( 'mastercontrol', array( 'label' => 'MasterControl', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/master_control_logo.png', 'supports' => array( 'title' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト おすすめコーデ register_post_type( 'osusume', array( 'label' => 'おすすめコーデ', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/stockstyle.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ //パンくずリスト用(未使用) function get_breadcrumbs(){ global $wp_query; if ( !is_home() ){ // Add the Home link echo '<a href="'. get_settings('home') .'">TOP</a>'; if ( is_category() ) { $catTitle = single_cat_title( "", false ); $cat = get_cat_ID( $catTitle ); echo '&gt;<span class="now">'. get_category_parents( $cat, TRUE, "" ) .'</span>'; } elseif ( is_archive() && !is_category() ) { echo '&gt;&nbsp;<span class="now">Archives</span>'; } elseif ( is_search() ) { echo '&gt;&nbsp;<span class="now">Search Results</span>'; } elseif ( is_404() ) { echo '&gt;&nbsp;<span class="now">404 Not Found</span>'; } elseif ( is_single() ) { $category = get_the_category(); $category_id = get_cat_ID( $category[0]->cat_name ); echo '&gt;<span class="now">'. get_category_parents( $category_id, TRUE, "&gt;" ); echo '&nbsp;&nbsp;' . the_title('','', FALSE) ."</span>"; } elseif ( is_page() ) { $post = $wp_query->get_queried_object(); if ( $post->post_parent == 0 ){ echo '&nbsp;&gt;&nbsp;<span class="now">'.the_title('','', FALSE).'</span>'; } else { $title = the_title('','', FALSE); $ancestors = array_reverse( get_post_ancestors( $post->ID ) ); array_push($ancestors, $post->ID); foreach ( $ancestors as $ancestor ){ if( $ancestor != end($ancestors) ){ echo '&nbsp;&gt;&nbsp; <a href="'. get_permalink($ancestor) .'">'. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'</a>'; } else { echo '&nbsp;&gt;&nbsp; <span class="now">'. strip_tags( apply_filters( 'single_post_title', get_the_title( $ancestor ) ) ) .'</span>'; } } } } } } function get_breadcrumb(){ if(function_exists('bcn_display')){ return bcn_display(true); } return; } add_shortcode('bcn_display', 'get_breadcrumb'); //+++++++++++++++++++++++++++++++++++++++++ // ギャラリー用facebookいいねボタン追加 /* デフォルトのショートコードを削除 */ remove_shortcode('gallery', 'gallery_shortcode'); /* 新しい関数を定義 */ add_shortcode('gallery', 'my_gallery_shortcode'); function my_gallery_shortcode($attr) { global $post, $wp_locale; static $instpe = 0; $instpe++; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) unset( $attr['orderby'] ); } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ( 'RAND' == $order ) $orderby = 'none'; if ( !empty($include) ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } else { $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "¥n"; foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link($att_id, $size, true) . "¥n"; return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instpe}"; $output = apply_filters('gallery_style', " <style type='text/css'> #{$selector} { margin: auto; } #{$selector} .gallery-item { float: {$float}; margin-top: 10px; text-align: center; width: {$itemwidth}%; } #{$selector} img { border: 2px solid #cfcfcf; } #{$selector} .gallery-caption { margin-left: 0; } </style> <!-- see gallery_shortcode() in wp-includes/media.php --> <div id='$selector' class='gallery galleryid-{$id}'>"); $i = 0; foreach ( $attachments as $id => $attachment ) { $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); $output .= "<{$itemtag} class='gallery-item'>"; $output .= " <{$icontag} class='gallery-icon'> $link </{$icontag}>"; if ( $captiontag && trim($attachment->post_excerpt) ) { $output .= " <{$captiontag} class='gallery-caption'> " . wptexturize($attachment->post_excerpt) . " </{$captiontag}>"; } $url_thumbnail = wp_get_attachment_image_src($id, $size='thumbnail'); $url = urlencode(get_bloginfo('home') . '/?attachment_id=' . $id); $url .= urlencode('&app_data=' . get_bloginfo('home') . '/?attachment_id=' . $id); $output .= '<p><div class="btn_like"><iframe src="http://www.facebook.com/plugins/like.php?href='; $output .= $url; $output .= '&amp;id=fb&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;width=120&amp;action=like&amp;colorscheme=light$amp;locale=ja_JA&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:21px;" allowTransparency="true"></iframe></div></p>'; $output .= "</{$itemtag}>"; if ( $columns > 0 && ++$i % $columns == 0 ) $output .= '<br style="clear: both" />'; } $output .= "</div>"; return $output; } function remove_gallery_css() { return "<div id='gallery_box'>"; } add_filter('gallery_style', 'remove_gallery_css'); function fix_gallery_output( $output ){ $output = preg_replace("%<br style=.*clear: both.* />%", "", $output); $output = preg_replace("%<dl class='gallery-item'>%", "<div class='photobox'>", $output); $output = preg_replace("%<dt class='gallery-icon'>%", "", $output); $output = preg_replace("%</dl>%", "</div>", $output); $output = preg_replace("%</dt>%", "", $output); return $output; } add_filter('the_content', 'fix_gallery_output',11, 1); //+++++++++++++++++++++++++++++++++++++++++ ?>
PHP
<?php $template_type = get_post_type(get_the_ID()); include 'custom_' . $template_type . '.php'; ?>
PHP
<?php /* Template Name: Event */ ?> <?php get_header(); ?> <a name="pagetop" id="pagetop"></a> <div id="wrapper"> <div id="google_translate_element" style="float:right"></div> <!-- ヘッダー START --> <div id="header"> <h1><a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/front/img_h1.png" alt="<?php bloginfo('name'); ?>" title="<?php bloginfo('name'); ?>" /></a></h1> </div> <!-- //ヘッダー END// --> <!-- コンテンツ START --> <div id="main_top">&nbsp;</div> <div id="main" class="clearfix"> <h2 class="menu_image info">Information</h2> <!-- 検索条件START --> <?php if(!is_single()): ?> <div id="search_box"> <hr class="search"> <div class="category"> <p><img src="<?php bloginfo('template_url'); ?>/images/front/stitle_cat.png"></p> <?php echo get_selectbox_category(); ?> </div> <div class="monthly"> <p><img src="<?php bloginfo('template_url'); ?>/images/front/stitle_month.png"></p> <?php echo get_selectbox_monthly(); ?> </div> <hr class="search"> </div> <?php endif; ?> <!-- //検索条件END// --> <!-- ブログSTART --> <!-- ##シングルページへのアクセスだった場合(single.phpからのincludeの場合)は表示させるPostIDを取得 --> <?php if(is_single()){ $displayablePostID = get_the_ID();}else{$displayablePostID = "";} ?> <!-- ##Eventポスト取得のループ開始 --> <?php wp_reset_query();query_posts('post_type=event&meta_key=eventstart&orderby=meta_value&order=DSC'); ?> <?php if(have_posts()): ?> <?php while(have_posts()): the_post(); ?> <?php $event = get_event_meta(); ?> <!-- ##イベントの非表示条件を判定 --> <?php if(is_event_disable($event)){continue;} ?> <!-- ##シングルページの場合は、指定されたPostID以外は表示させない --> <?php if($displayablePostID !== "" && $displayablePostID !== get_the_ID()){ continue; } ?> <div id="info_box"> <div class="info_top"> <p class="date"><?php echo $event["startdate"]; ?></p> </div> <div class="info_body"> <h3> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> <img src="<?php bloginfo('template_url'); ?>/images/front/ico_<?php echo $event["category"]; ?>.png"> </h3> <p class="detail"><?php the_content(); ?></p> </div> <div class="info_bottom"> <?php echo getLikeBottun(); ?> </div> </div> <!-- //インフォ詳細END// --> <?php endwhile; ?> <?php endif; ?> <!-- //ブログEND// --> </div> <!-- //コンテンツ END// --> <!-- グローバルナビ START --> <?php echo get_navi(); ?> <!-- //グローバルナビ END// --> <!-- Pagetop START --> <div class="pagetop"> <p><a href="#">▲Page Topに戻る</a></p> </div> <!-- //Pagetop END// --> <?php function get_event_meta(){ $c = get_post_custom_values('eventstart', get_the_ID()); $event["startdate"] = $c[0]; $c = get_post_custom_values('eventend' , get_the_ID()); $event["enddate"] = $c[0]; $c = get_post_custom_values('opendate' , get_the_ID()); $event["opendate"] = $c[0]; $c = get_post_custom_values('closedate' , get_the_ID()); $event["closedate"] = $c[0]; $c = get_post_custom_values('category' , get_the_ID()); $event["category"] = $c[0]; if($event["enddate"] == "" || $event["enddate"] === $event["startdate"]){$event["datelabel"] = $event["startdate"];} if($event["enddate"] != "" && $event["enddate"] != $event["startdate"]){$event["datelabel"] = $event["startdate"] . " - " . $event["enddate"];} return $event; } function is_event_disable($event){ $filtered = false; // ##opendate <- -> closedate 以外であれば非表示 if( $event["opendate"] != ""){ if(strtotime( $event["opendate"] ) > time() ){ $filtered = true; }} if( $event["closedate"] != ""){ if(strtotime( $event["closedate"] ) < time() ){ $filtered = true; }} //##月指定があれば絞り込み if(isset($_REQUEST["mon"])){ $filter = date("Y", $_REQUEST["mon"]) . date("m", $_REQUEST["mon"]); $current = date("Y", strtotime($event["startdate"])) . date("m", strtotime($event["startdate"])); if($filter != $current){$filtered = true;} } //##カテゴリ指定があれば絞り込み if(isset($_REQUEST["cat"])){ if($_REQUEST["cat"] != $event["category"]){$filtered = true;} } return $filtered; } function get_selectbox_category(){ wp_reset_query(); query_posts('post_type=event'); if(have_posts()){ while(have_posts()){ the_post(); $e = get_event_meta(); if( $e["opendate"] != ""){ if(strtotime( $e["opendate"] ) > time() ){ continue; }} if( $e["closedate"] != ""){ if(strtotime( $e["closedate"] ) < time() ){ continue; }} $cat = get_post_custom_values('category', get_the_ID()); $catList[$e["category"]] = ""; } } $catListKeys = array_keys($catList); $selectbox_html = "<select name='cat' id='cat' class='postform' >"; $selectbox_html .= "<option value=''>カテゴリーを選択</option>"; foreach($catListKeys as $k=>$v){ if($_REQUEST["cat"] === $v){$selected = "selected";}else{$selected = "";} $selectbox_html .= '<option class="level-0" value="' . $v . '" ' . $selected . '>' . $v . '</option>'; } $selectbox_html .= "</select>"; $selectbox_html .= "<script type='text/javascript'>"; $selectbox_html .= "/* <![CDATA[ */"; $selectbox_html .= "var catdropdown = document.getElementById('cat');"; $selectbox_html .= " function onCatChange() {"; $selectbox_html .= " location.href = './?cat='+catdropdown.options[catdropdown.selectedIndex].value;"; $selectbox_html .= "}"; $selectbox_html .= "catdropdown.onchange = onCatChange;"; $selectbox_html .= "/* ]]> */"; $selectbox_html .= "</script>"; return $selectbox_html; } function get_selectbox_monthly(){ wp_reset_query(); query_posts('post_type=event'); if(have_posts()){ while(have_posts()){ the_post(); $e = get_event_meta(); if( $e["opendate"] != ""){ if(strtotime( $e["opendate"] ) > time() ){ continue; }} if( $e["closedate"] != ""){ if(strtotime( $e["closedate"] ) < time() ){ continue; }} $monthList[date("Y", strtotime($e["startdate"])) . "/" . date("n", strtotime($e["startdate"]))] = ""; } } $monthListKeys = array_keys($monthList); $selectbox_html = "<select name='mon' id='mon' class='postform' >"; $selectbox_html .= "<option value=''>月を選択</option>"; foreach($monthListKeys as $k=>$v){ if($_REQUEST["mon"] === strtotime($v."/1")){$selected = "selected";}else{$selected = "";} $selectbox_html .= '<option class="level-0" value="' . strtotime($v."/1") . '" ' . $selected . '>' . $v . '</option>'; } $selectbox_html .= "</select>"; $selectbox_html .= "<script type='text/javascript'>"; $selectbox_html .= "/* <![CDATA[ */"; $selectbox_html .= "var mondropdown = document.getElementById('mon');"; $selectbox_html .= "function onMonChange() {"; $selectbox_html .= " location.href = './?mon='+mondropdown.options[mondropdown.selectedIndex].value;"; $selectbox_html .= "}"; $selectbox_html .= "mondropdown.onchange = onMonChange;"; $selectbox_html .= "/* ]]> */"; $selectbox_html .= "</script>"; return $selectbox_html; } ?> <?php get_footer(); ?>
PHP
<?php /* Template Name: Blog */ get_header(); ?> <div id="wrapper"> <a name="pagetop" id="pagetop"></a> <?php run_layout(); ?> <?php get_footer(); ?>
PHP
<?php /* Template Name: osusume */ get_header(); $template_url = get_bloginfo('template_url'); $site_name = get_bloginfo('name'); $is_single = false; print <<<META_HEADER <script type="text/javascript" src="$template_url/js/prototype.js"></script> <script type="text/javascript" src="$template_url/js/scriptaculous.js?load=effects,builder"></script> <script type="text/javascript" src="$template_url/js/lightbox.js"></script> <link rel="stylesheet" href="$template_url/css/lightbox.css" type="text/css" media="screen" /> <script type="text/javascript">//<![CDATA[ // セレクトボックスに項目を割り当てる。 function lnSetSelect(form, name1, name2, val, lists, vals) { //sele11 = document[form][name1]; sele11 = document.getElementById(name1); sele12 = document.getElementById(name2); if(sele11 && sele12) { index = sele11.selectedIndex; // セレクトボックスのクリア count = sele12.options.length; for(i = count; i >= 0; i--) { sele12.options[i] = null; } // セレクトボックスに値を割り当てる len = lists[index].length; for(i = 0; i < len; i++) { sele12.options[i] = new Option(lists[index][i], vals[index][i]); if(val != "" && vals[index][i] == val) { sele12.options[i].selected = true; } } } } //]]> </script> <script type="text/javascript">//<![CDATA[ jQuery(document).ready( function(){ jQuery(".fav_button").live('click', function() { var reqcnt = 0; var reqparams = ""; jQuery("input:checked").each( function(){ if ( jQuery(this)[0] ) { var formid = '#' + jQuery(this).attr('formid'); var prodid = formid + " input[name=product_id]"; var catid1 = formid + " select[name=classcategory_id1] option:selected"; var catid2 = formid + " select[name=classcategory_id2] option:selected"; var sizid = formid + ' #size'; var colid = formid + ' #color'; var req_url = "/products/facebook.php"; var req_mode = 'cart'; var req_product_id = jQuery(prodid).val(); var mesag = formid + ' #messege' + req_product_id; var req_cry_id1 = jQuery(catid1).val(); var req_cry_id2 = jQuery(catid2).val(); reqparams += "ary_product_id[" + reqcnt + "]=" + req_product_id + '&ary_classcategory_id1[' + reqcnt + ']=' + req_cry_id1 + '&ary_classcategory_id2[' + reqcnt + ']=' + req_cry_id2 + '&'; reqcnt++; } }); var reqobj; reqparams += "multimode=cart&quantity=1"; reqobj = jQuery.ajax({type: 'POST', url: '/products/facebook.php', data: reqparams, success: function(html) { var w = window.open('about:blank', '_blank'); w.location.href = '/cart/index.php'; }}); }); }); //]]> </script> </head> META_HEADER; // Google翻訳 $google_trans = '<div id="google_translate_element" style="float:right"></div>'; // グローバルナビ $global_navi = get_navi(); $bloginfo_url = get_bloginfo('url'); print <<<CUSTOM_HEADER <body> <a name="pagetop" id="pagetop"></a> <div id="wrapper"> $google_trans <!-- ヘッダーSTART --> <div id="header"> <h1><a href="$bloginfo_url"><img src="$template_url/images/front/img_h1.png" alt="$site_name" title="$site_name" /></a></h1> </div> <!-- //ヘッダーEND// --> <!-- コンテンツ START --> <div class="info_main clearfix"> <div id="main" class="clearfix"> <h2 class="menu_image favorites">Favorites</h2> CUSTOM_HEADER; echo '<!-- おすすめコーデSTART -->'; // ##シングルページへのアクセスだった場合(single.phpからのincludeの場合)は表示させるPostIDを取得 if(is_single()){ $is_single = true; $displayablePostID = get_the_ID(); }else{ $is_single = false; $displayablePostID = ""; } // <!-- ##blogポスト取得のループ開始 --> query_posts('post_type=osusume'); if(have_posts()): $listcount = 0; while(have_posts()): the_post(); $title = $content = $post_meta = $permalink = $likebutton = 0; $listcount++; $title = get_the_title(); $content = get_the_content(); $post_meta = get_post_meta($post->ID, sprintf("products", $c), true); $permalink = get_permalink(); $url = parse_url($permalink); $stockstyle = "stockstyle.net"; if ( $url['host'] === "dev.mastercontrol.jp" ){ $stockstyle = "stage.stockstyle.net"; } $url_path = $url['path']; $likebutton = getLikeBottun(); // <!-- ##シングルページの場合は、指定されたPostID以外は表示させない --> if($is_single && $displayablePostID !== get_the_ID()){ continue; } if( $is_single || $listcount == 1): // モデル着用ボタン $model_photo_url = get_post_meta($post->ID, sprintf("モデルPhoto", $c), true); $model_photo_style = $model_photo_url !== "" ? ' style="display:none;"' : ''; // -------------- シングル コンテンツ 開始 --------------- print <<<SINGLE_CONTENT <!-- コメントSTART --> $content <!-- コメントEND --> <!-- inline:osusume_code --> $post_meta <!-- inline:osusume_code --> <p class="fav_model clearfix" $model_photo_style> <a href="$model_photo_url" rel="lightbox">モデル着用PHOTO</a> </p> <!-- //購入ボタンSTART --> <div class="fav_button"> <input type="submit" value="" id="fav_buy" /> </div> <!-- //購入ボタンEND// --> SINGLE_CONTENT; // -------------- シングル コンテンツ 終了 --------------- else: // -------------- 一覧 コンテンツ 開始 --------------- print <<<LIST_CONTENT <div id="info_box"> <div class="info_body"> <h3><a href="http://$stockstyle/products/facebook.php?osusume_url=$url_path">$title</a></h3> </div> </div> LIST_CONTENT; // -------------- 一覧 コンテンツ 終了 --------------- endif; endwhile; endif; echo '<!-- //おすすめコーデEND// -->'; print <<<CUSTOM_FOOTER </div> </div> <!-- コンテンツ END --> <!-- グローバルナビ START --> $global_navi <!-- //グローバルナビ END// --> <!-- Pagetop START --> <div class="pagetop"> <p><a href="#pagetop">▲Page Topに戻る</a></p> </div> <!-- //Pagetop END// --> CUSTOM_FOOTER; get_footer(); ?>
PHP
<?php get_header(); ?> <?php get_footer(); ?>
PHP
<?php get_header(); ?> <?php get_footer(); ?>
PHP
<?php /* Template Name: Info */ get_header(); ?> <div id="wrapper"> <a name="pagetop" id="pagetop"></a> <?php run_layout(); ?> <?php get_footer(); ?>
PHP
<!-- Pagetop START --> <div class="pagetop"> <p><a href="#pagetop">▲Page Topに戻る</a></p> </div> <!-- //Pagetop END// --> <!-- フッター START --> <div id="footer"> <p>Copyright&copy; LesPros Entertainment Co., Ltd. All rights reserved.</p> </div> <!-- //フッター END// --> <div> <?php wp_footer(); ?> </body> </html>
PHP
<?php $q = get_posts('post_type=mastercontrol&posts_per_page=1'); $qq = get_post_custom_values('appid', $q[0]->ID); if($qq[0] == ""){$APP_ID = "";}else{$APP_ID = $qq[0];} define("APP_ID", $APP_ID); $qq = get_post_custom_values('appsecret', $q[0]->ID); if($qq[0] == ""){$SECRET_KEY = "";}else{$SECRET_KEY = $qq[0];} define("SECRET_KEY", $SECRET_KEY); $qq = get_post_custom_values('facebookurl', $q[0]->ID); if($qq[0] == ""){$FB_URL = "";}else{$FB_URL = $qq[0];} define("FB_URL", $FB_URL); $qq = get_post_custom_values('page_id', $q[0]->ID); if($qq[0] == ""){$PAGE_ID = "";}else{$PAGE_ID = $qq[0];} define("PAGE_ID", $PAGE_ID); $qq = get_post_custom_values('access_token', $q[0]->ID); if($qq[0] == ""){$ACCESS_TOKEN = "";}else{$ACCESS_TOKEN = $qq[0];} define("ACCESS_TOKEN", $ACCESS_TOKEN); $qq = get_post_custom_values('enable_site', $q[0]->ID); if($qq[0] == ""){$ENABLE_SITE = "";}else{$ENABLE_SITE = $qq[0];} define("ENABLE_SITE", $ENABLE_SITE); $qq = get_post_custom_values('fbpage_only', $q[0]->ID); if($qq[0] == ""){$FBPAGE_ONLY = false;}else{$FBPAGE_ONLY = true;} define("FBPAGE_ONLY", $FBPAGE_ONLY); ?>
PHP
<?php loadIframeFB(); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xml:lang="ja" lang="ja"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-style-type" content="text/css"> <meta http-equiv="content-script-type" content="text/javascript"> <title><?php bloginfo('name'); ?> facebook page</title> <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" /> <link rel="stylesheet" href="<?php echo get_custom_templateurl(); ?>/base.css" type="text/css" /> <link rel="stylesheet" href="<?php echo get_custom_templateurl(); ?>/rayout.css" type="text/css" /> <?php echo do_shortcode('[ogp_meta]'); redirectFB(); wp_head(); ?> </head> <body>
PHP
<?php /* Template Name: Profile */ ?> <?php get_header(); ?> <a name="pagetop" id="pagetop"></a> <div id="wrapper"> <div id="google_translate_element" style="float:right"></div> <!-- ヘッダー START --> <div id="header"> <h1><a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_url'); ?>/images/front/img_h1.png" alt="<?php bloginfo('name'); ?>" title="<?php bloginfo('name'); ?>" /></a></h1> </div> <!-- //ヘッダー END// --> <!-- コンテンツ START --> <div id="main" class="prof_main clearfix"> <h2 class="menu_image prof">Profile</h2> <?php query_posts('post_type=profile'); if(have_posts()): the_post(); the_content(); endif; ?> </div> <!-- //コンテンツ END// --> <!-- グローバルナビ START --> <?php echo get_navi(); ?> <!-- //グローバルナビ END// --> <?php get_footer(); ?>
PHP
<?php get_header(); ?> <a name="pagetop" id="pagetop"></a> <div id="wrapper"> <!-- コンテンツ START --> <div id="main" class="top_main clearfix"> <!-- コンテンツ START --> <div class="top_img"> <h1><img src="<?php bloginfo('template_url'); ?>/images/front/img_h1.png" alt="梨衣名" width="152" height="80" title="梨衣名" /></h1> </div> <div class="top_msg"> <?php if(have_posts()): the_post(); the_content(); endif; ?> </div> </div> <!-- //コンテンツ END// --> <!-- グローバルナビ START --> <?php echo do_shortcode("[gnavi]"); ?> <!-- //グローバルナビ END// --> <?php get_footer(); ?>
PHP
<?php function footer_html(){ $likeCount = facebook_likeCount("http://www.facebook.com/stockstyle"); print <<<FOOTER_STYLE <div id="powerd"> Powerd by&nbsp;<a href="https://www.facebook.com/stockstyle">STOCK STYLE</a> <span class="likeCountArrow"><span>$likeCount</span></span> </div> FOOTER_STYLE; } add_action( 'wp_footer', 'footer_html' ); ?>
PHP
<?php // プラグイン //remove_action( 'wp_head', 'wordbooker_header' ); remove_action( 'wp_head', 'wpogp_auto_include' ); remove_action( 'wp_head', 'wp_page_numbers_stylesheet' ); remove_action( 'wp_head', 'widget_akismet_style' ); remove_action( 'wp_head', 'feed_links' ); // システム remove_action( 'wp_head', 'feed_links'); remove_action( 'wp_head', 'feed_links_extra'); remove_action( 'wp_head', 'rsd_link'); remove_action( 'wp_head', 'wlwmanifest_link'); remove_action( 'wp_head', 'index_rel_link'); remove_action( 'wp_head', 'parent_post_rel_link'); remove_action( 'wp_head', 'start_post_rel_link'); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head'); remove_action( 'wp_head', 'wp_generator' ); remove_action( 'wp_head', 'rel_canonical' ); remove_action( 'wp_head', 'wp_enqueue_scripts' ); remove_action( 'wp_head', 'locale_stylesheet' ); remove_action( 'wp_head', 'noindex' ); remove_action( 'wp_head', 'wp_print_styles' ); remove_action( 'wp_head', 'wp_print_head_scripts' ); remove_action( 'wp_head', '_custom_background_cb' ); // ヘッダースタイル add_action( 'wp_head', 'header_style' ); //+++++++++++++++++++++++++++++++++++++++++ //カスタムヘッダー add_custom_image_header('','admin_header_style'); function admin_header_style() {} //標準のヘッダー画像を指定 define('HEADER_IMAGE','%s/images/front/bg_header.jpg'); register_default_headers( array( 'default' => array( 'url' => '%s/images/front/bg_header.jpg', 'thumbnail_url' => '%s/images/front/bg_header.jpg', 'description' => __( 'default', 'default_header' ) ) ) ); //ヘッダー画像の横幅と高さを指定 define('HEADER_IMAGE_WIDTH','520'); define('HEADER_IMAGE_HEIGHT','115'); //ヘッダーの文字を隠す define('NO_HEADER_TEXT',true); function get_custom_css($design_type){ list($conf_designs) = get_posts( array('post_type'=>'design', 'meta_query' => array( array( 'key'=>'design_type', 'value'=>"$design_type", ), ), 'order'=>'ASC' ) ); $style_sheet = ""; if( isset($conf_designs) ): list($get_style) = get_post_meta($conf_designs->ID, 'stylesheet'); $style_sheet = $get_style; endif; return $style_sheet; } function get_ogp_meta(){ $template_type = get_template_type(); $app_ogp = "ogp_" . PAGE_TYPE . "_" . $template_type; if(function_exists($app_ogp)) { return do_shortcode("[" . $app_ogp ."]"); } else { return ""; } } add_shortcode('ogp_meta', 'get_ogp_meta'); function get_template_type(){ global $posts; $app_type = "home"; if ( $posts[0]->{"post_type"} === 'page' ){ $app_type = $posts[0]->{"post_name"}; define( 'PAGE_TYPE', 'page' ); } else { $app_type = $posts[0]->{"post_type"}; $single_id = $posts[0]->{"ID"}; define( 'PAGE_TYPE', 'single' ); define( 'POST_ID', $single_id ); } return $app_type; } function header_style(){ $header_image = get_header_image(); $background_style = get_custom_background(); $custom_style = get_custom_css(get_template_type()); print <<<HEADER_STYLE <style> #header { background: url($header_image); } #wrapper { $background_style } body { overflow-x : hidden ;} $custom_style </style> <script> function googleTranslateElementInit() { new google.translate.TranslateElement({ pageLanguage: 'ja', includedLanguages: 'en,ko,ja', layout: google.translate.TranslateElement.InlineLayout.SIMPLE }, 'google_translate_element'); } </script> <script src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> jQuery.event.add(window, "load", function(){ var footer_height = jQuery("#footer").position().top + 200; FB.Canvas.setSize({ height: footer_height }); }); </script> HEADER_STYLE; } if ( is_admin() ){ require_once( ABSPATH . 'wp-admin/custom-background.php' ); $GLOBALS['custom_background'] =& new Custom_Background( $admin_header_callback, $admin_image_div_callback ); add_action( 'admin_menu', array( &$GLOBALS['custom_background'], 'init' ) ); } /** * Default custom background callback. * * @since 3.0.0 * @see add_custom_background() * @access protected */ function get_custom_background() { $background = get_background_image(); $color = get_background_color(); if ( ! $background && ! $color ) return; $style = $color ? "background-color: #$color;" : ''; if ( $background ) { $image = " background-image: url('$background');"; $repeat = get_theme_mod( 'background_repeat', 'repeat' ); if ( ! in_array( $repeat, array( 'no-repeat', 'repeat-x', 'repeat-y', 'repeat' ) ) ) $repeat = 'repeat'; $repeat = " background-repeat: $repeat;"; $position = get_theme_mod( 'background_position_x', 'left' ); if ( ! in_array( $position, array( 'center', 'right', 'left' ) ) ) $position = 'left'; $position = " background-position: top $position;"; $attachment = get_theme_mod( 'background_attachment', 'scroll' ); if ( ! in_array( $attachment, array( 'fixed', 'scroll' ) ) ) $attachment = 'scroll'; $attachment = " background-attachment: $attachment;"; $style .= $image . $repeat . $position . $attachment; } return trim( $style ); } ?>
PHP
<?php // FacebookPageにリダイレクト function redirectFB() { if($_GET["app_data"] != "" && !ereg("facebook",$_SERVER['HTTP_USER_AGENT'])){ echo '<meta http-equiv="refresh" CONTENT="0;URL=' . FB_URL . "&app_data=" . $_GET["app_data"] . '" />'; exit; } } function loadIframeFB(){ if ( isset($_REQUEST["signed_request"]) ){ $signed_request = $_REQUEST["signed_request"]; list($encoded_sig, $payload) = explode('.', $signed_request, 2); $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true); } // Fan Gate if ( isset($data["page"]["liked"]) ){ if ( $data["page"]["liked"] === true ){ } else { echo '<html><head><style>body{overflow-x : hidden ;overflow-y : hidden ;}</style></head><body><img src="'. get_bloginfo('template_url'). '/images/front/fangate.jpg" alt="' . get_bloginfo('name') . '" title="' . get_bloginfo('name') . '" /></body></html>'; exit; } } // like page if ( isset($data["app_data"]) ){ echo '<meta http-equiv="refresh" CONTENT="0;URL=' . get_bloginfo("siteurl") . base64_decode($data["app_data"]) . '" />'; exit; } } // FacebookLikeボタンを取得 function getLikeBottun() { $permalink = get_permalink(); $appdata = str_replace(get_bloginfo("siteurl"), "", $permalink); $like_link = $permalink . '?app_data=' . base64_encode( $appdata ); $like_bottun = '<iframe src="https://www.facebook.com/plugins/like.php?app_id=' . APP_ID . '&href='; $like_bottun .= urlencode($like_link); $like_bottun .= '&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:20px" allowTransparency="true"></iframe>'; return '<!--' . $like_link . '-->' . $like_bottun; //return $like_bottun; } add_shortcode('facebook_like', 'getLikeBottun'); // OGPタグを取得 function getOGPMeta() { global $post, $id; setup_postdata($post); if (is_page_template('custom_photogallary.php')) { $OGP_meta = '<meta property="og:type" content="article" />'; $OGP_meta .= '<meta property="og:title" content="Photo Gallary' . get_the_title() . '" />'; $OGP_meta .= '<meta property="og:url" content="' . get_permalink() . '?app_data=' . base64_encode(get_permalink()) . '" />'; $OGP_meta .= '<meta property="og:description" content="' . get_the_title() . '" />'; $OGP_meta .= '<meta property="og:site_name" content="' . get_bloginfo('name') . '" />'; $OGP_meta .= '<meta property="og:image" content="' . get_the_post_thumbnail($id) . '" />'; $OGP_meta .= '<meta property="fb:app_id" content="' . APP_ID . '" />'; }else if (is_single()) { $OGP_meta = '<meta property="og:type" content="article" />'; $OGP_meta .= '<meta property="og:title" content="「' . get_the_title() . '」" />'; $OGP_meta .= '<meta property="og:url" content="' . get_permalink() . '?app_data=' . base64_encode(get_permalink()) . '" />'; $OGP_meta .= '<meta property="og:description" content="' . get_the_title() . '" />'; $OGP_meta .= '<meta property="og:site_name" content="' . get_bloginfo('name') . '" />'; $OGP_meta .= '<meta property="og:image" content="' . get_bloginfo('template_url') . '/images/front/img_head.jpg" />'; $OGP_meta .= '<meta property="fb:app_id" content="' . APP_ID . '" />'; }else if (is_attachment()) { $url_large = wp_get_attachment_image_src($id, $size='large'); $OGP_meta = '<meta property="og:type" content="article" />'; $OGP_meta .= '<meta property="og:title" content="「' . get_the_title() . '」" />'; $OGP_meta .= '<meta property="og:url" content="' . get_bloginfo('home') . '/?attachment_id=' . $id . '&app_data=' . base64_encode(get_bloginfo('home')) . '/?attachment_id=' . $id . '" />'; $OGP_meta .= '<meta property="og:description" content="' . get_the_title() . '" />'; $OGP_meta .= '<meta property="og:site_name" content="' . get_bloginfo('name') . '" />'; $OGP_meta .= '<meta property="og:image" content="' . $url_large[0] . '" />'; $OGP_meta .= '<meta property="fb:app_id" content="' . APP_ID . '" />'; }else{ $OGP_meta = '<meta property="og:type" content="article" />'; $OGP_meta .= '<meta property="og:title" content="「' . get_the_title() . '」" />'; $OGP_meta .= '<meta property="og:url" content="' . get_permalink() . '?app_data=' . base64_encode(get_permalink()) . '" />'; $OGP_meta .= '<meta property="og:description" content="' . get_the_title() . '" />'; $OGP_meta .= '<meta property="og:site_name" content="' . get_bloginfo('name') . '" />'; $OGP_meta .= '<meta property="og:image" content="' . get_bloginfo('template_url') . '/images/front/img_head.jpg" />'; $OGP_meta .= '<meta property="fb:app_id" content="' . APP_ID . '" />'; } return $OGP_meta; } ?>
PHP
<?php function header_googleplus(){ print <<<GOOGLE_PLUS <script type="text/javascript"> window.___gcfg = {lang: 'ja'}; (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> GOOGLE_PLUS; } add_action( 'wp_head', 'header_googleplus' ); function header_facebook(){ $appId = APP_ID; print <<<HEADER_FACEBOOK <script type="text/javascript" src="https://connect.facebook.net/ja_JP/all.js"></script> <div id="fb-root"></div> <script type="text/javascript"> FB.init({ appId : '$appId', status : true, // check login status cookie : true, // enable cookies xfbml : true, // parse XFBML logging : true }); </script> HEADER_FACEBOOK; } add_action( 'wp_head', 'header_facebook' ); /* * いいね用 デフォルト */ function get_base_like(){ global $custom_post; if ( isset($custom_post) ){ $ID = $custom_post->ID; $like_title = $custom_post->post_title; } else { $ID = get_the_ID(); $like_title = get_the_title(); } $single_page = '/single/' . get_template_type() . '/' . $ID . '/'; $permalink = get_bloginfo('siteurl') . $single_page; $like_link = $permalink . '?app_data=' . base64_encode( $single_page ); $like_bottun = '<iframe src="https://www.facebook.com/plugins/like.php?app_id=' . APP_ID . '&href='; $like_bottun .= urlencode($like_link); $like_bottun .= '&amp;send=false&amp;layout=button_count&amp;width=68&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:68px; height:20px" allowTransparency="true"></iframe>'; $google_plus = '<div class="g-plusone" data-size="medium" data-annotation="none"></div>'; //$google_plus = ''; $twitter = <<<TWITTER_BUTTON <a href="https://twitter.com/share" class="twitter-share-button" data-url="$like_link" data-text="$like_title" data-lang="ja" data-count="none">ツイート</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> TWITTER_BUTTON; //$twitter = ''; return "\n" . $google_plus . "\n" . $twitter . "\n" . $like_bottun . "\n" . '<!-- facebook_like: ' . $like_link . ' // -->'; } add_shortcode('base_like', 'get_base_like'); add_shortcode('facebook_like', 'get_base_like'); /* * OpenGraphProtocol デフォルト * * Usage: * */ function ogp_single_base_content(){ $ogp_meta = ""; global $wp_query; $og_site = get_bloginfo('name'); $permalink = get_permalink(); $appdata = str_replace(get_bloginfo("siteurl"), "", $permalink); $og_url = $permalink . '?app_data=' . urlencode(base64_encode( $appdata )); $og_appId = APP_ID; $text_excerpt = strip_tags(htmlspecialchars_decode(get_the_excerpt())); $text_content = $wp_query->{"queried_object"}->{"post_content"}; $default_img = get_bloginfo("template_url") . "/screenshot.png"; $all_images = (preg_match_all('~img.+?src="([^"]+?)"~', $text_content, $matches)) ? array_unique($matches[1]) : array($default_img); $og_title = get_the_title(); $og_content = $text_excerpt; $refresh = FB_URL . "&app_data=" . urlencode(base64_encode( get_permalink() )); $maxwidth = 0; foreach ( $all_images as $image ) : $buf_image = @getimagesize($image); if ( $buf_image[0] > $maxwidth ){ $maxwidth = $buf_image[0]; $og_image = $image; } endforeach; if ( empty($og_image) ) { $og_image = $default_img; } if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ('https' === $_SERVER['HTTP_X_FORWARDED_PROTO']) ){ $og_url = str_replace( "http:", "https:", $og_url ); } $ogp_meta = <<<META_OGP <meta property="og:title" content="$og_title" /> <meta property="og:type" content="article" /> <meta property="og:url" content="$og_url" /> <meta property="og:image" content="$og_image" /> <meta property="og:site_name" content="$og_site" /> <meta property="fb:app_id" content="$og_appId" /> <meta property="og:description" content="$og_content"> <meta property="og:locale" content="ja_JP" /> <meta itemprop="name" content="$og_title"> <meta itemprop="description" content="$og_content"> <meta itemprop="image" content="$og_image"> META_OGP; return $ogp_meta; } add_shortcode('ogp_single_content', 'ogp_single_base_content'); /* * WallPost用 * * @prams og_image 画像 (無くてもよい) * @prams og_url いいね用 URL * @prams title タイトル * @prams message メッセージ * */ function wall_post( $og_image, $og_url, $og_title, $message ){ $fanpage = PAGE_ID; $page_token = ACCESS_TOKEN; if ( $page_token !== "" ): $ch = curl_init(); $params = 'access_token=' . urlencode($page_token); if ( !empty($og_image) ) $params .= '&picture=' . urlencode($og_image); $params .= '&link=' . urlencode($og_url); $params .= '&name=' . urlencode($og_title); $params .= '&message=' . $message; curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/'.$fanpage.'/feed'); curl_setopt($ch, CURLOPT_POSTFIELDS, $params); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $resp = curl_exec($ch); curl_close($ch); endif; } $wppostfix = new WpPostFix(); // 記事が保存されたときに起動する add_action('save_post', array($wppostfix, 'postfix'), 99); //add_action('edit_post', array($wppostfix, 'postfix'), 99); //add_action('publish_post', array($wppostfix, 'postfix'), 99); class WpPostFix { function postfix($postID) { // ウォール投稿多重チェック $wall_posted = get_option( 'wall_posted' ); if ( empty($wall_posted) ){ // 未投稿 add_option( 'wall_posted', $postID, '', 'yes' ); } else { if ( $wall_posted < $postID ){ // 投稿許可 } else { // 投稿済みの為 ここで終了 return $postID; } } global $wpdb; list($result) = $wpdb->get_results("SELECT post_status,post_title,post_type,post_content FROM {$wpdb->posts} WHERE ID = '{$postID}' LIMIT 1"); $post_status = $result->post_status; $content = $result->post_content; $post_type = $result->post_type; $og_title = $result->post_title; $message = br2nl( strip_tags(htmlspecialchars_decode( $content ), '<br>') ); // 誤動作防止 if ( get_bloginfo("siteurl") !== ENABLE_SITE ) { return $postID; } $single_page_url = '/single/' . $post_type . '/' . $postID; $og_url = get_bloginfo("siteurl") . $single_page_url . '?app_data=' . urlencode(base64_encode($single_page_url)); //$og_url = htmlspecialchars_decode(get_post_meta($postID ,'syndication_permalink',true)); // 画像 content 内 // デフォルト画像が必要な時 $default_img = get_bloginfo("template_url") . "/screenshot.png"; // $default_img = null; $all_images = (preg_match_all('~img.+?src="([^"]+?)"~', $content, $matches)) ? array_unique($matches[1]) : array($default_img); $maxwidth = 0; foreach ( $all_images as $image ) : $buf_image = @getimagesize($image); if ( $buf_image[0] > $maxwidth ){ $maxwidth = $buf_image[0]; $og_image = $image; } endforeach; if ( empty($og_image) ) { $og_image = $default_img; } // 画像 ここまで // ウォール投稿を許可するカスタムポストタイプ $enable_type = array( 'blog' ); if ( in_array( $post_type , $enable_type ) ): /* * 動作チェック用 * // コンテンツ書き換え */ // $content = $this->blogcontent($post_status, $content); // * // DB をなおした内容でアップデートする // $wpdb->query("UPDATE {$wpdb->posts} SET post_content = '{$content}' WHERE ID = '{$postID}'"); // */ // 公開の投稿をウォールへポスト if ( $post_status === 'publish' ){ // ウォールへポスト wall_post( $og_image, $og_url, $og_title, $message ); update_option( 'wall_posted', $postID ); } endif; // 次の人のために post_id 戻しておく return $postID; } function blogcontent($post_type, $content) { // 書き換えたい内容を記載 $before = 'hogehoge'; $after = 'mogemoge'; $after = $post_type; $content = preg_replace("/$before/i", $after, $content); // 戻す return $content; } } function br2nl($string){ //改行コードのリスト $aBreakTags = array( '/&lt;br&gt;/', '/&lt;br \/&gt;/', '/&lt;BR&gt;/', '/<br>/', '/<BR>/', '/<br \/>/', '/<BR \/>/' ); return preg_replace($aBreakTags ,"\n" , $string ); } function facebook_likeCount($str = null) { if($str) $url = $str; else $url = ((!empty($_SERVER['HTTPS']))? "https://" : "http://").$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; $json = file_get_contents('http://graph.facebook.com/' . $url ,true); $data = json_decode($json, true); return ($data['shares'])? $data['shares'] : 0; } ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ //カスタムメニュー register_nav_menus(array( 'navbar' => 'ナビゲーションバー', 'sidebar' => 'サイドバー' )); function facebook_js(){ print <<<FACEBOOK_HEADER <script type="text/javascript" src="https://connect.facebook.net/en_US/all.js"></script> <script type="text/javascript"> FB.Canvas.setSize({ width: 520, height: 800 }); </script> FACEBOOK_HEADER; } //add_action( 'wp_head', 'facebook_js' ); function header_gnav_script(){ $template_url = get_custom_templateurl(); $local_time = time(); define( CUSTOM_TYPE , get_template_type() ); print <<<HEADER_GNAV <link rel="stylesheet" href="$template_url/css/gnavi.css?$local_time" type="text/css" /> HEADER_GNAV; } add_action( 'wp_head', 'header_gnav_script' ); function get_navi(){ $nav_opt = array( 'menu' => 'gnav', // menu '' カスタムメニューのIDを指定 'container' => 'div', // container 'div' ナビゲーションメニューを囲むタグ名を指定 'container_class' => 'floatClear', // container_class '' ナビゲーションメニューを囲むタグのクラス名を指定 'container_id' => 'gnav', // container_id '' ナビゲーションメニューを囲むタグのIDを指定 'menu_class' => 'navi', // menu_class 'menu' ナビゲーションメニューを囲むタグのクラス名を指定 'echo' => false, // echo true ナビゲーションメニューを表示する場合はtrue、文字列として取得する場合はfalseを指定 'depth' => 0, // depth 0 階層数を指定(0はすべてを表示、1ならばメニューバーのみ)。 'walker' => new MasterControl_Global_Navi(), // walker '' コールバック関数名を指定 'theme_location' => 'navbar', // theme_location '' テーマ内のロケーションIDを指定。 ); return wp_nav_menu($nav_opt); } function print_navi(){ $nav_opt = array( 'menu' => 'gnav', // menu '' カスタムメニューのIDを指定 'container' => 'div', // container 'div' ナビゲーションメニューを囲むタグ名を指定 'container_class' => 'floatClear', // container_class '' ナビゲーションメニューを囲むタグのクラス名を指定 'container_id' => 'gnav', // container_id '' ナビゲーションメニューを囲むタグのIDを指定 'menu_class' => 'navi', // menu_class 'menu' ナビゲーションメニューを囲むタグのクラス名を指定 'echo' => false, // echo true ナビゲーションメニューを表示する場合はtrue、文字列として取得する場合はfalseを指定 'depth' => 0, // depth 0 階層数を指定(0はすべてを表示、1ならばメニューバーのみ)。 'walker' => new MasterControl_Global_Navi(), // walker '' コールバック関数名を指定 'theme_location' => 'navbar', // theme_location '' テーマ内のロケーションIDを指定。 ); print wp_nav_menu($nav_opt); } add_shortcode('gnavi', 'get_navi'); /** * Navigation Menu template functions * * @package WordPress * @subpackage Nav_Menus * @since 3.0.0 */ /** * Create HTML list of nav menu items. * * @package WordPress * @since 3.0.0 * @uses Walker */ class MasterControl_Global_Navi extends Walker_Nav_Menu { /** * @see Walker::start_el() * @since 3.0.0 * * @param string $output Passed by reference. Used to append additional content. * @param object $item Menu item data object. * @param int $depth Depth of menu item. Used for padding. * @param int $current_page Menu item ID. * @param object $args */ function start_el(&$output, $item, $depth, $args) { global $gnavi_Class; global $wp_query; $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; $LF = "\n"; $class_names = $value = ''; $gnavi_Class = 'menu_' . $item->title; $class_names = ' class="' . esc_attr( 'menu_' . $item->title ) . '" '; $id = ' id="' . esc_attr( 'gnav_' . $item->title ) . '"'; $output .= $indent . '<li' . $id . $value . $class_names .'>' . $LF; $attributes = ' title="' . esc_attr( $item->title ) . '"'; $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : ''; $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : ''; $attributes .= strtolower(CUSTOM_TYPE) === strtolower($item->title) ? ' class="current"' : ''; if ( preg_match("/favorites/", $item->url)) { $url = parse_url($item->url); $stockstyle = $url['host'] === "dev.mastercontrol.jp" ? "stage.stockstyle.net" : "stockstyle.net"; $attributes .= 'href="//' . $stockstyle . '/products/facebook.php?osusume_url=' . $url['path'] . '"'; } else { $lang_url = ( isset($_GET["lang"]) ) ? '?lang=' . $_GET["lang"] : ''; $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) . $lang_url . '"' : ''; } $item_output = $args->before; $item_output .= '<a'. str_replace( "http:", "", $attributes ) .'>'; $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; $item_output .= '</a>'; $item_output .= $args->after; $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); } } ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト Info 情報 register_post_type( 'Info', array( 'label' => 'Infomation', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/event.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); function get_info_meta(){ $c = get_post_custom_values('infostart', get_the_ID()); $info["startdate"] = $c[0]; $c = get_post_custom_values('infoend' , get_the_ID()); $info["enddate"] = $c[0]; $c = get_post_custom_values('opendate' , get_the_ID()); $info["opendate"] = $c[0]; $c = get_post_custom_values('closedate' , get_the_ID()); $info["closedate"] = $c[0]; $c = get_post_custom_values('category' , get_the_ID()); $info["category"] = $c[0]; if($info["enddate"] == "" || $info["enddate"] === $info["startdate"]){$info["datelabel"] = $info["startdate"];} if($info["enddate"] != "" && $info["enddate"] != $info["startdate"]){$info["datelabel"] = $info["startdate"] . " - " . $info["enddate"];} return $info; } /* function is_info_disable($info){ $filtered = false; // ##opendate <- -> closedate 以外であれば非表示 if( $info["opendate"] != ""){ if(strtotime( $info["opendate"] ) > time() ){ $filtered = true; }} if( $info["closedate"] != ""){ if(strtotime( $info["closedate"] ) < time() ){ $filtered = true; }} //##月指定があれば絞り込み if(isset($_REQUEST["mon"])){ $filter = date("Y", $_REQUEST["mon"]) . date("m", $_REQUEST["mon"]); $current = date("Y", strtotime($info["startdate"])) . date("m", strtotime($info["startdate"])); if($filter != $current){$filtered = true;} } //##カテゴリ指定があれば絞り込み if(isset($_REQUEST["cat"])){ if($_REQUEST["cat"] != $info["category"]){$filtered = true;} } return $filtered; } */ function get_selectbox_category(){ wp_reset_query(); query_posts('post_type=info'); $catList = array(); if(have_posts()){ while(have_posts()){ the_post(); $e = get_info_meta(); if( $e["opendate"] != ""){ if(strtotime( $e["opendate"] ) > time() ){ continue; }} if( $e["closedate"] != ""){ if(strtotime( $e["closedate"] ) < time() ){ continue; }} $cat = get_post_custom_values('category', get_the_ID()); $catList[$e["category"]] = ""; } } $catListKeys = array_keys($catList); $selectbox_html = "<select name='cat' id='cat' class='postform' >"; $selectbox_html .= "<option value=''>カテゴリーを選択</option>"; foreach($catListKeys as $k=>$v){ if($_REQUEST["cat"] === $v){$selected = "selected";}else{$selected = "";} $selectbox_html .= '<option class="level-0" value="' . $v . '" ' . $selected . '>' . $v . '</option>'; } $selectbox_html .= "</select>"; $selectbox_html .= "<script type='text/javascript'>"; $selectbox_html .= "/* <![CDATA[ */"; $selectbox_html .= "var catdropdown = document.getElementById('cat');"; $selectbox_html .= " function onCatChange() {"; $selectbox_html .= " location.href = './?cat='+catdropdown.options[catdropdown.selectedIndex].value;"; $selectbox_html .= "}"; $selectbox_html .= "catdropdown.onchange = onCatChange;"; $selectbox_html .= "/* ]]> */"; $selectbox_html .= "</script>"; return $selectbox_html; } add_shortcode('select_category', 'get_selectbox_category'); function get_selectbox_monthly(){ wp_reset_query(); query_posts('post_type=info'); $monthList = array(); if(have_posts()){ while(have_posts()){ the_post(); $e = get_info_meta(); if( $e["opendate"] != ""){ if(strtotime( $e["opendate"] ) > time() ){ continue; }} if( $e["closedate"] != ""){ if(strtotime( $e["closedate"] ) < time() ){ continue; }} $monthList[date("Y", strtotime($e["startdate"])) . "/" . date("n", strtotime($e["startdate"]))] = ""; } } $monthListKeys = array_keys($monthList); $selectbox_html = "<select name='mon' id='mon' class='postform' >"; $selectbox_html .= "<option value=''>月を選択</option>"; foreach($monthListKeys as $k=>$v){ if(intval( $_REQUEST["mon"] ) === strtotime($v."/1")){ $selected = "selected"; }else{ $selected = ""; } $selectbox_html .= '<option class="level-0" value="' . strtotime($v."/1") . '" ' . $selected . '>' . $v . '</option>'; } $selectbox_html .= "</select>"; $selectbox_html .= "<script type='text/javascript'>"; $selectbox_html .= "/* <![CDATA[ */"; $selectbox_html .= "var mondropdown = document.getElementById('mon');"; $selectbox_html .= "function onMonChange() {"; $selectbox_html .= " location.href = './?mon='+mondropdown.options[mondropdown.selectedIndex].value;"; $selectbox_html .= "}"; $selectbox_html .= "mondropdown.onchange = onMonChange;"; $selectbox_html .= "/* ]]> */"; $selectbox_html .= "</script>"; return $selectbox_html; } add_shortcode('select_monthly', 'get_selectbox_monthly'); function get_info_the_title(){ return get_custom_the_title(); } add_shortcode('info_title', 'get_info_the_title'); function get_info_the_content(){ return get_custom_the_content(); } add_shortcode('info_content', 'get_info_the_content'); function get_info_category(){ return get_custom_category(); } add_shortcode('info_category', 'get_info_category'); function get_page_info(){ if ( PAGE_TYPE === 'page' ) { global $custom_post; global $custom_query_posts; $item_content = ""; $items = get_posts($custom_query_posts); if( isset($items) ): for( $i = 0; $i < count( $items ) && $custom_post = $items[$i]; $i++ ) : $item_content .= apply_filters('the_content', constant('INFO_HTML_PAGE')); endfor; endif; return $item_content; } return; } add_shortcode('info_page' , 'get_page_info'); function get_single_info(){ $item_content = ""; if ( PAGE_TYPE === 'single' ) { global $custom_post; $custom_post = wp_get_single_post( POST_ID, 'OBJECT' ); $item_content = apply_filters('the_content', constant('INFO_HTML_PAGE')); } return $item_content; } add_shortcode('info_single' , 'get_single_info'); function exec_info(){ //echo $_GET["cat"] . "<BR>\n"; global $custom_query_posts; $custom_query_posts = ""; if ( isset($_GET["cat"]) ){ $category = $_GET["cat"]; $custom_query_posts = array( 'post_type'=>'info', 'meta_query' => array( array( 'key'=>'category', 'value'=>"$category", ), array( 'key' => 'opendate', 'value' => date("Y-m-d"), 'compare'=> '<=', 'type' => 'DATE' ), array( 'key' => 'closedate', 'value' => date("Y-m-d"), 'compare'=> '>=', 'type' => 'DATE' ), 'relation'=>'AND' ), 'posts_per_page'=>10, 'meta_key'=>'infostart', 'orderby'=>'meta_value', 'order'=>'ASC' ); } elseif ( isset($_GET["mon"]) ){ $select_mon = $_GET["mon"]; $startDay = date("Y-m-d", $select_mon); $lastDay = date("Y-m-d", mktime(0, 0, 0, date("m",$select_mon)+1, 0, date("Y",$select_mon))); $custom_query_posts = array( 'meta_query' => array( array( 'key' => 'infostart', 'value' => $startDay, 'compare'=> '>=', 'type' => 'DATE' ), array( 'key' => 'infostart', 'value' => $lastDay, 'compare'=> '<=', 'type' => 'DATE' ), array( 'key' => 'opendate', 'value' => date("Y-m-d"), 'compare'=> '<=', 'type' => 'DATE' ), array( 'key' => 'closedate', 'value' => date("Y-m-d"), 'compare'=> '>=', 'type' => 'DATE' ), 'relation'=>'AND' ), 'meta_key' => 'infostart', 'orderby' => 'meta_value', 'post_type' => 'info', 'posts_per_page' => 20, 'order' => 'DSC' ); } else { $custom_query_posts = array( 'meta_query' => array( array( 'key' => 'opendate', 'value' => date("Y-m-d"), 'compare'=> '<=', 'type' => 'DATE' ), array( 'key' => 'closedate', 'value' => date("Y-m-d"), 'compare'=> '>=', 'type' => 'DATE' ), 'relation'=>'AND' ), 'meta_key' => 'infostart', 'orderby' => 'meta_value', 'post_type' => 'info', 'posts_per_page' => 20, 'order' => 'DSC' ); } get_import_design("info"); return apply_filters('the_content', INFO_HTML_FRAME); } add_shortcode('run_info', 'exec_info'); ?>
PHP
<?php /* //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト photogallery register_post_type( 'photogallery', array( 'label' => 'フォトギャラリー', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/media.png', 'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト DISCOGRAPHY register_post_type( 'discography', array( 'label' => 'ディスコグラフィー', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/discography.png', 'supports' => array( 'title', ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト MEDIA register_post_type( 'media', array( 'label' => 'メディア/出演情報', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/media.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト MULTI-BLOG register_post_type( 'multiblog', array( 'label' => 'マルチブログ', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/blog.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); */ ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト Profile register_post_type( 'profile', array( 'label' => 'Profile', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/profile.png', 'supports' => array( 'title', 'custom-fields' ) ) ); function get_prof_detail(){ return get_custom_textarea(PROF_ID, 'prof_detail'); } add_shortcode('prof_detail', 'get_prof_detail'); function get_prof_comment(){ return get_custom_textarea(PROF_ID, 'prof_comment'); } add_shortcode('prof_comment', 'get_prof_comment'); function get_prof_image(){ return get_custom_image(PROF_ID, ('prof_image')); } add_shortcode('prof_image', 'get_prof_image'); function exec_profile(){ get_import_design("profile"); list($conf_profile) = get_posts('post_type=profile&order=DSC'); if ( isset( $conf_profile ) ): define('PROF_ID' , $conf_profile->ID); endif; return apply_filters('the_content', PROFILE_HTML_FRAME); } add_shortcode('run_profile', 'exec_profile'); ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト ITUNES register_post_type( 'itunes', array( 'label' => 'iTunes', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/itune.png', 'supports' => array( 'title', 'editor' ) ) ); function exec_itunes(){ print <<<START_ITUNES <div id="main" class="clearfix"> <h2 class="itunes">itunes</h2> START_ITUNES; $itunes_url = "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=%E7%A7%8B%E8%B5%A4%E9%9F%B3&country=JP&limit=10&entity=album&offset=0"; $itunes_res = json_decode(file_get_contents($itunes_url)); foreach ( $itunes_res->{"results"} as $album ) : $collectionId = $album->{"collectionId"}; echo <<<VIEW_ITUNE_IFRAME <iframe src="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewAlbumSocialPreview?id=$collectionId&s=143462&uo=4&wdId=32800" frameborder="0" scrolling="no" width="500px" height="280px"></iframe> VIEW_ITUNE_IFRAME; endforeach; print <<<END_ITUNES </div> END_ITUNES; } add_shortcode('run_itunes', 'exec_itunes'); ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト BLOG register_post_type( 'blog', array( 'label' => 'ブログ', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/blog.png', 'supports' => array( 'title', 'editor', 'custom-fields' ) ) ); function ogp_single_blog(){ $ogp_meta = ""; global $wp_query; $og_site = get_bloginfo('name'); $permalink = get_permalink(); $appdata = str_replace(get_bloginfo("siteurl"), "", $permalink); $og_url = $permalink . '?app_data=' . urlencode(base64_encode( $appdata )); $og_appId = APP_ID; $text_excerpt = strip_tags(htmlspecialchars_decode(get_the_excerpt())); $text_content = $wp_query->{"queried_object"}->{"post_content"}; $default_img = get_bloginfo("template_url") . "/screenshot.png"; $all_images = (preg_match_all('~img.+?src="([^"]+?)"~', $text_content, $matches)) ? array_unique($matches[1]) : array($default_img); $og_title = get_the_title(); $og_content = $text_excerpt; $refresh = FB_URL . "&app_data=" . urlencode(base64_encode( get_permalink() )); $maxwidth = 0; foreach ( $all_images as $image ) : $buf_image = @getimagesize($image); if ( $buf_image[0] > $maxwidth ){ $maxwidth = $buf_image[0]; $og_image = $image; } endforeach; if ( empty($og_image) ) { $og_image = $default_img; } if ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && ('https' === $_SERVER['HTTP_X_FORWARDED_PROTO']) ){ $og_url = str_replace( "http:", "https:", $og_url ); } $ogp_meta = <<<META_OGP <meta property="og:title" content="$og_title" /> <meta property="og:type" content="article" /> <meta property="og:url" content="$og_url" /> <meta property="og:image" content="$og_image" /> <meta property="og:site_name" content="$og_site" /> <meta property="fb:app_id" content="$og_appId" /> <meta property="og:description" content="$og_content"> <meta property="og:locale" content="ja_JP" /> META_OGP; return $ogp_meta; } // add_shortcode('ogp_single_blog', 'ogp_single_blog'); function get_blog_the_title(){ return get_custom_the_title(); } add_shortcode('blog_title', 'get_blog_the_title'); function get_blog_the_content(){ $content = str_replace('img src="', 'img src="/img.php?imgurl=', get_custom_the_content()); $content = str_replace('a href="', 'a target="_blank" href="', $content); $content = strip_tags( $content , '<img><br>'); return $content; } add_shortcode('blog_content', 'get_blog_the_content'); function get_blog_date(){ return date('Y年m月d日', SimplePie_Parse_Date::get()->parse(get_custom_date())); } add_shortcode('blog_date', 'get_blog_date'); function get_blog_url(){ global $custom_post; return get_post_meta($custom_post->ID ,'syndication_permalink',true); } add_shortcode('blog_url', 'get_blog_url'); function get_blog_like(){ global $custom_post; $single_page = '/single/blog/' . $custom_post->ID . '/'; $permalink = get_bloginfo('siteurl') . $single_page; $like_link = $permalink . '?app_data=' . base64_encode( $single_page ); $like_bottun = '<iframe src="https://www.facebook.com/plugins/like.php?app_id=' . APP_ID . '&href='; $like_bottun .= urlencode($like_link); $like_bottun .= '&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=20" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:20px" allowTransparency="true"></iframe>'; return "\n" . $like_bottun . "\n" . '<!-- facebook_like: ' . $like_link . ' // -->'; } //add_shortcode('blog_like', 'get_blog_like'); function get_pagenavi(){ $navi_html = ""; $navi_html = '<div class="tablenav">'; $paged = get_query_var('paged'); $paginate_base = get_pagenum_link(1); global $wp_rewrite; global $max_pages; if (strpos($paginate_base, '?') || ! $wp_rewrite->using_permalinks()) { $paginate_format = ''; $paginate_base = add_query_arg('paged', '%#%'); } else { $paginate_format = (substr($paginate_base, -1 ,1) == '/' ? '' : '/') . user_trailingslashit('page/%#%/', 'paged');; $paginate_base .= '%_%'; } $navi_html .= paginate_links( array( 'base' => $paginate_base, 'format' => $paginate_format, 'total' => $max_pages, 'mid_size' => 3, 'current' => ($paged ? $paged : 1), 'prev_text' => '&laquo;', 'next_text' => '&raquo;', )); $navi_html .= '</div>'; return str_replace('http:', '', $navi_html); } add_shortcode('pagenavi', 'get_pagenavi'); function get_page_blog(){ if ( PAGE_TYPE === 'page' ) { global $custom_post; global $custom_query_posts; $item_content = ""; wp_reset_query(); query_posts($custom_query_posts); global $wp_query; global $max_pages; $max_pages = $wp_query->{"max_num_pages"}; $item_content .= do_shortcode('[pagenavi]'); if( isset($wp_query) ): $items = $wp_query->{"posts"}; for( $i = 0; $i < count( $items ) && $custom_post = $items[$i]; $i++ ) : $item_content .= do_shortcode( constant('BLOG_HTML_PAGE') ); endfor; endif; return $item_content; } return; } add_shortcode('blog_page' , 'get_page_blog'); function get_single_blog(){ $item_content = ""; if ( PAGE_TYPE === 'single' ) { global $custom_post; $custom_post = wp_get_single_post( POST_ID, 'OBJECT' ); if(have_posts()): while(have_posts()): the_post(); $item_content = do_shortcode( constant('BLOG_HTML_SINGLE') ); endwhile; endif; } return $item_content; } add_shortcode('blog_single' , 'get_single_blog'); function exec_blog(){ global $custom_query_posts; $blog_content = ""; $paged = get_query_var('paged'); $custom_query_posts = "post_type=blog&posts_per_page=2&paged=$paged&order=DSC"; get_import_design("blog"); //return apply_filters('the_content', BLOG_HTML_FRAME); return do_shortcode( constant('BLOG_HTML_FRAME') ); } add_shortcode('run_blog', 'exec_blog');
PHP
<?php register_post_type( 'gallery', array( 'label' => 'Gallery', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/media.png', 'supports' => array( 'title', 'editor', 'custom-fields', 'thumbnail' ) ) ); function exec_gallery(){ $gallery_content = ""; wp_reset_query();query_posts('post_type=gallery&order=ASC'); if(have_posts()): while(have_posts()): the_post(); echo the_title() . "<br>\n"; echo the_content(); echo the_permalink() . "<br>\n"; endwhile; endif; //get_import_design("gallery"); //return apply_filters('the_content', GALLERY_HTML_FRAME); } add_shortcode('run_gallery', 'exec_gallery'); //+++++++++++++++++++++++++++++++++++++++++ // ギャラリー用facebookいいねボタン追加 /* デフォルトのショートコードを削除 */ remove_shortcode('gallery', 'gallery_shortcode'); /* 新しい関数を定義 */ add_shortcode('gallery', 'my_gallery_shortcode'); function my_gallery_shortcode($attr) { global $post, $wp_locale; static $instpe = 0; $instpe++; // Allow plugins/themes to override the default gallery template. $output = apply_filters('post_gallery', '', $attr); if ( $output != '' ) return $output; // We're trusting author input, so let's at least make sure it looks like a valid orderby statement if ( isset( $attr['orderby'] ) ) { $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] ); if ( !$attr['orderby'] ) unset( $attr['orderby'] ); } extract(shortcode_atts(array( 'order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post->ID, 'itemtag' => 'dl', 'icontag' => 'dt', 'captiontag' => 'dd', 'columns' => 3, 'size' => 'thumbnail', 'include' => '', 'exclude' => '' ), $attr)); $id = intval($id); if ( 'RAND' == $order ) $orderby = 'none'; if ( !empty($include) ) { $include = preg_replace( '/[^0-9,]+/', '', $include ); $_attachments = get_posts( array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); $attachments = array(); foreach ( $_attachments as $key => $val ) { $attachments[$val->ID] = $_attachments[$key]; } } elseif ( !empty($exclude) ) { $exclude = preg_replace( '/[^0-9,]+/', '', $exclude ); $attachments = get_children( array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } else { $attachments = get_children( array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby) ); } if ( empty($attachments) ) return ''; if ( is_feed() ) { $output = "¥n"; foreach ( $attachments as $att_id => $attachment ) $output .= wp_get_attachment_link($att_id, $size, true) . "¥n"; return $output; } $itemtag = tag_escape($itemtag); $captiontag = tag_escape($captiontag); $columns = intval($columns); $itemwidth = $columns > 0 ? floor(100/$columns) : 100; $float = is_rtl() ? 'right' : 'left'; $selector = "gallery-{$instpe}"; $output = apply_filters('gallery_style', " <style type='text/css'> #{$selector} { margin: auto; } #{$selector} .gallery-item { float: {$float}; margin-top: 10px; text-align: center; width: {$itemwidth}%; } #{$selector} img { border: 2px solid #cfcfcf; } #{$selector} .gallery-caption { margin-left: 0; } </style> <!-- see gallery_shortcode() in wp-includes/media.php --> <div id='$selector' class='gallery galleryid-{$id}'>"); $i = 0; foreach ( $attachments as $id => $attachment ) { echo "<!--" . var_dump($attachment) . "-->\n"; $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false); echo "\n<!-- link: " . $link . " /link -->"; $output .= "<{$itemtag} class='gallery-item'>"; $output .= " <{$icontag} class='gallery-icon'> $link </{$icontag}>"; if ( $captiontag && trim($attachment->post_excerpt) ) { $output .= " <{$captiontag} class='gallery-caption'> " . wptexturize($attachment->post_excerpt) . " </{$captiontag}>"; } $url_thumbnail = wp_get_attachment_image_src($id, $size='thumbnail'); $url = urlencode(get_bloginfo('home') . '/?attachment_id=' . $id); $url .= urlencode('&app_data=' . get_bloginfo('home') . '/?attachment_id=' . $id); $output .= '<p><div class="btn_like"><iframe src="http://www.facebook.com/plugins/like.php?href='; $output .= $url; $output .= '&amp;id=fb&amp;send=false&amp;layout=button_count&amp;show_faces=false&amp;width=120&amp;action=like&amp;colorscheme=light$amp;locale=ja_JA&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:21px;" allowTransparency="true"></iframe></div></p>'; $output .= "</{$itemtag}>"; if ( $columns > 0 && ++$i % $columns == 0 ) $output .= '<br style="clear: both" />'; } $output .= "</div>"; return $output; } function remove_gallery_css() { return "<div id='gallery_box'>"; } add_filter('gallery_style', 'remove_gallery_css'); function fix_gallery_output( $output ){ /* $output = preg_replace("%<br style=.*clear: both.* />%", "", $output); $output = preg_replace("%<dl class='gallery-item'>%", "<div class='photobox'>", $output); $output = preg_replace("%<dt class='gallery-icon'>%", "", $output); $output = preg_replace("%</dl>%", "</div>", $output); $output = preg_replace("%</dt>%", "", $output); */ return $output; } add_filter('the_content', 'fix_gallery_output',11, 1); //+++++++++++++++++++++++++++++++++++++++++ ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト PV (YouTube) register_post_type( 'pv', array( 'label' => 'PV', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/youtube.png', 'supports' => array( 'title', 'custom-fields' ) ) ); function ogp_page_pv(){ $ogp_meta = ""; list($ogp_post) = get_posts("post_type=pv&order=DSC"); if(have_posts()): the_post(); //$ogp_meta = ogp_single_pv(); setup_postdata($ogp_post); $og_site = get_bloginfo('name'); $permalink = get_permalink(); $youtube_url = get_post_meta($ogp_post->ID, 'URL', true); $contents = file_get_contents("https://youtu.be/" . $youtube_url); $appdata = str_replace(get_bloginfo("siteurl"), "", $permalink); $og_url = $permalink . '?app_data=' . urlencode(base64_encode( $appdata )); $og_appId = APP_ID; $htmls = split ( "\n" , $contents ); foreach ( $htmls as $linehtml ){ if ( preg_match('/"og:([^"]+)"/', $linehtml, $matchline) ){ if ( $matchline[1] === "url" ) { $ogp_meta .= '<meta property="og:url" content="'.$og_url.'" />' . "\n"; } elseif ( $matchline[1] === "site_name" ){ $ogp_meta .= '<meta property="og:site_name" content="'.$og_site.'" />' . "\n"; } else { $ogp_meta .= $linehtml . "\n"; } } } endif; $ogp_meta .= '<meta property="og:locale" content="ja_JP" />' . "\n"; return $ogp_meta; } add_shortcode('ogp_page_pv', 'ogp_page_pv'); function ogp_single_pv(){ $ogp_meta = ""; $og_site = get_bloginfo('name'); $permalink = get_permalink(); $youtube_url = get_post_meta(get_the_ID(), 'URL', true); $contents = file_get_contents("https://youtu.be/" . $youtube_url); $appdata = str_replace(get_bloginfo("siteurl"), "", $permalink); $og_url = $permalink . '?app_data=' . urlencode(base64_encode( $appdata )); $og_appId = APP_ID; $htmls = split ( "\n" , $contents ); foreach ( $htmls as $linehtml ){ if ( preg_match('/"og:([^"]+)"/', $linehtml, $matchline) ){ if ( $matchline[1] === "url" ) { $ogp_meta .= '<meta property="og:url" content="'.$og_url.'" />' . "\n"; } elseif ( $matchline[1] === "site_name" ){ $ogp_meta .= '<meta property="og:site_name" content="'.$og_site.'" />' . "\n"; } else { $ogp_meta .= $linehtml . "\n"; } } } $ogp_meta .= '<meta property="og:locale" content="ja_JP" />'; return $ogp_meta; } add_shortcode('ogp_single_pv', 'ogp_single_pv'); function get_custom_title(){ return get_custom_text(get_the_ID(), 'タイトル'); } add_shortcode('pv_title', 'get_custom_title'); function get_custom_url(){ return get_custom_text(get_the_ID(), 'URL'); } add_shortcode('youtubeID', 'get_custom_url'); function get_custom_detail(){ return get_custom_text(get_the_ID(), '説明文'); } add_shortcode('pv_detail', 'get_custom_detail'); function get_page_pv(){ if ( PAGE_TYPE === 'page' ) { global $custom_query_posts; $item_content = ""; query_posts($custom_query_posts); if(have_posts()): while(have_posts()): the_post(); $item_content .= apply_filters('the_content', constant('PV_HTML_PAGE')); endwhile; endif; return $item_content; } return; } add_shortcode('pv_page' , 'get_page_pv'); function get_single_pv(){ $item_content = ""; if ( PAGE_TYPE === 'single' ) { global $custom_post; $custom_post = wp_get_single_post( POST_ID, 'OBJECT' ); if(have_posts()): while(have_posts()): the_post(); $item_content = apply_filters('the_content', constant('PV_HTML_SINGLE')); endwhile; endif; } return $item_content; } add_shortcode('pv_single' , 'get_single_pv'); function exec_pv(){ global $custom_query_posts; $custom_query_posts = "post_type=pv&order=DSC"; get_import_design("pv"); return apply_filters('the_content', PV_HTML_FRAME); } add_shortcode('run_pv', 'exec_pv'); ?>
PHP
<?php register_post_type( 'goods_book', array( 'label' => 'Goods_BOOK', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/goods.png', 'supports' => array( 'title', 'custom-fields' ) ) ); register_post_type( 'goods_cd', array( 'label' => 'Goods_CD', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/goods.png', 'supports' => array( 'title', 'custom-fields' ) ) ); function get_item_detail(){ global $goods_id; return get_custom_textarea($goods_id, 'item_detail'); } add_shortcode('item_detail', 'get_item_detail'); function get_item_title(){ global $goods_id; return get_custom_textarea($goods_id, 'item_title'); } add_shortcode('item_title', 'get_item_title'); function get_item_image(){ global $goods_id; return get_custom_image($goods_id, 'item_image'); } add_shortcode('item_image', 'get_item_image'); function get_page_book(){ if ( PAGE_TYPE === 'page' ) { global $goods_id; get_import_design("goods_book"); $item_content = ""; $items = get_posts("post_type=goods_book&order=DSC"); if( isset($items) ): for( $i = 0; $i < count( $items ) && $item = $items[$i]; $i++ ) : $goods_id = $item->ID; $item_content .= apply_filters('the_content', constant('GOODS_BOOK_HTML_PAGE')); endfor; endif; return $item_content; } return; } add_shortcode('book_page' , 'get_page_book'); function get_page_cd(){ if ( PAGE_TYPE === 'page' ) { global $goods_id; get_import_design("goods_cd"); $item_content = ""; $items = get_posts('post_type=goods_cd&order=DSC'); if( isset($items) ): for( $i = 0; $i < count( $items ) && $item = $items[$i]; $i++ ) : $goods_id = $item->ID; $item_content .= apply_filters('the_content', constant('GOODS_CD_HTML_PAGE')); endfor; endif; return $item_content; } return; } add_shortcode('cd_page' , 'get_page_cd'); function get_single_cd(){ if ( PAGE_TYPE === 'single' ) { global $goods_id; get_import_design("goods_cd"); $goods_id = POST_ID; $item_content .= apply_filters('the_content', constant('GOODS_CD_HTML_SINGLE')); return $item_content; } return; } add_shortcode('cd_single' , 'get_single_cd'); function get_single_book(){ if ( PAGE_TYPE === 'single' ) { global $goods_id; get_import_design("goods_book"); //$items = wp_get_single_post(POST_ID, 'ARRAY_A'); $goods_id = POST_ID; $item_content .= apply_filters('the_content', constant('GOODS_BOOK_HTML_SINGLE')); return $item_content; } return; } add_shortcode('book_single' , 'get_single_book'); function exec_goods_book(){ get_import_design('goods_book'); return apply_filters('the_content', constant('GOODS_BOOK_HTML_FRAME')); } add_shortcode('run_goods_book', 'exec_goods_book'); function exec_goods_cd(){ get_import_design('goods_cd'); return apply_filters('the_content', constant('GOODS_CD_HTML_FRAME')); } add_shortcode('run_goods_cd', 'exec_goods_cd'); function exec_goods(){ get_import_design("goods"); return apply_filters('the_content', GOODS_HTML_FRAME); } add_shortcode('run_goods', 'exec_goods'); ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト Twitter register_post_type( 'twitter', array( 'label' => 'Twitter', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/twitter.png', 'supports' => array( 'title' ) ) ); function get_twitter_account(){ return get_custom_text(TWITTER_ID, ('Twitter')); } add_shortcode('twitter_account', 'get_twitter_account'); function exec_twitter(){ get_import_design("twitter"); list($conf_twitter) = get_posts('post_type=twitter&order=DSC'); if ( isset( $conf_twitter ) ): define('TWITTER_ID' , $conf_twitter->ID); endif; return apply_filters('the_content', TWITTER_HTML_FRAME); } add_shortcode('run_twitter', 'exec_twitter'); ?>
PHP
<?php //+++++++++++++++++++++++++++++++++++++++++ // カスタムポスト デザイン register_post_type( 'design', array( 'label' => 'デザイン', 'hierarchical' => false, 'public' => true, 'query_var' => false, 'menu_icon' => get_bloginfo('template_url').'/images/tool/master_control_logo.png', 'supports' => array( 'title', 'custom-fields' ) ) ); function get_css_design($design_type){ list($conf_designs) = get_posts( array('post_type'=>'design', 'meta_query' => array( array( 'key'=>'design_type', 'value'=>"$design_type", ), ), 'order'=>'ASC' ) ); $style_sheet = ""; if( isset($conf_designs) ): list($get_style) = get_post_meta($conf_designs->ID, 'stylesheet'); $style_sheet = $get_style; endif; return $style_sheet; } function get_import_design($design_type){ // Design Template OUTPUT  $design = array(); list($conf_designs) = get_posts(array('post_type'=>'design','meta_key'=>'design_type','meta_value'=>"$design_type",'order'=>'ASC')); if( isset($conf_designs) ): // $title = $conf_designs->post_title; list($conf_design_type) = get_post_meta($conf_designs->ID, 'design_type'); list($design["html_frame"]) = get_post_meta($conf_designs->ID, 'html_frame'); list($design["html_page"]) = get_post_meta($conf_designs->ID, 'html_page'); list($design["html_single"]) = get_post_meta($conf_designs->ID, 'html_single'); $frame_name = strtoupper($design_type) . '_HTML_FRAME'; define($frame_name, $design["html_frame"] ); $frame_name = strtoupper($design_type) . '_HTML_SINGLE'; define($frame_name, $design["html_single"] ); $frame_name = strtoupper($design_type) . '_HTML_PAGE'; define($frame_name, $design["html_page"] ); endif; return $design; } ?>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Sign up &middot; Online Shopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet"> <style type="text/css"> body { padding-top: 40px; padding-bottom: 40px; background-color:#CCCCCC; } .form-signin { max-width: 300px; padding: 19px 29px 29px; margin: 0 auto 20px; background-color: #FFFFFF; border: 1px solid #666666; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05); box-shadow: 0 1px 2px rgba(0,0,0,.05); } .form-signin .form-signin-heading, .form-signin .checkbox { margin-bottom: 10px; color: black; } .form-signin input[type="text"], .form-signin input[type="password"] { font-size: 16px; height: auto; margin-bottom: 15px; padding: 7px 9px; } </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Fav and touch icons --> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="../assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="../assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="../assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="../assets/ico/apple-touch-icon-57-precomposed.png"> <link rel="shortcut icon" href="../assets/ico/favicon.png"> </head> <body> <h1 align="center">Online Shopping</h1> <br> <div class="container"> <form class="form-signin"> <h2 class="form-signin-heading" align="center">Registeration</h2> <input type="text" class="input-block-level" name="firstname" <?php $i_agree="fn" ?> placeholder="First Name"> <input type="text" class="input-block-level" name="lastname" <?php $i_agree="ln" ?> placeholder="Last Name"> <input type="text" class="input-block-level" name="username" <?php $i_agree="un" ?> placeholder="User Name"> <input type="text" class="input-block-level" name="email" <?php $i_agree="em" ?> placeholder="E-Mail"> <input type="password" class="input-block-level" name="password" <?php $i_agree="pw" ?> placeholder="Password"> <input type="password" class="input-block-level" name="confirm_password" <?php $i_agree="cpw" ?> placeholder="Confirm Password"> <label class="checkbox"> <input type="checkbox" value="iagree" <?php $i_agree="ig" ?> > I agree all the terms and conditions </label> <a href="reg.php"><button class="btn btn-large btn-primary" type="submit" >Sign in</button></a> </form> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<?php $id= $_POST['id']; $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $username = $_POST['username']; $password = $_POST['password']; $con = mysql_connect("localhost", "root", ""); mysql_select_db("onlineshopping"); $sql = "INSERT INTO `onlineshopping`.`users` (`id`, `firstname`, `lastname`, `email`, `username`, `password`) VALUES (NULL, '$firstname', '$lastname', '$email', '$username', '$password');"; $result = mysql_query($sql); mysql_close($con); header ("location: index.php"); ?>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<?php $page ='home'; ?> <div class="navbar"> <div class="navbar-inner"> <ul class="nav"> <li class="<?php if ($page='home') "active";?>" > <a href="index.php">Home</a></li> <li><a href="womens.php">Womens</a></li> <li><a href="mens.php">Mens</a></li> <li><a href="kids.php">Kids</a></li> <li><a href="footwear.php">Footwear</a></li> <li><a href="jewellery.php">Jewellery</a></li> <li><a href="fashion.php">Fashion</a></li> <li><a href="bags.php">Bags</a></li> <li><a href="books.php">Books</a></li> <li><a href="gifts.php">Gifts</a></li> <li><a href="computer.php">Computer</a></li> <li><a href="electronics.php">Electronics</a></li> <li><a href="essentials.php">Essentials</a></li> </ul> </div> </div>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <!--<h1>Online Shopping</h1>--> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php // include "nav_top.php" include "nav.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- <div id="social_network"> <div rel="tooltip" title="Facebook" class="facebook_network"> <img src="D:\PHP Practise\base\assets\img\fa.png" class="img-polaroid"> </div> <div rel="tooltip" title="Twitter" class="twitter_network"> <img src="D:\PHP Practise\base\assets\img\tw.png" class="img-polaroid"> </div> <div rel="tooltip" title="Google Plus" class="gplus_network"> <img src="D:\PHP Practise\base\assets\img\gt.png" class="img-polaroid"> </div> </div> --> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> </div> </div> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>OnlineShopping</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="../assets/css/bootstrap.css" rel="stylesheet" type="text/css"> <style> </style> <link href="../assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- .style1 {color: #FFFFFF} --> </style> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <?php include "login_signup_nav.php"; ?> </div> </div> </div> <div class="container"> <?php include "form_search.php"; ?> <?php include "logo_online.php"; ?> <p>Shop here anything.</p> <?php include "nav_top.php" ?> <!-- Social Networking Icons --> <?php include "social_network.php"; ?> <!-- Social Networking Icons End --> <?php include "left_nav.php"; ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="../assets/js/jquery.js"></script> <script src="../assets/js/bootstrap-transition.js"></script> <script src="../assets/js/bootstrap-alert.js"></script> <script src="../assets/js/bootstrap-modal.js"></script> <script src="../assets/js/bootstrap-dropdown.js"></script> <script src="../assets/js/bootstrap-scrollspy.js"></script> <script src="../assets/js/bootstrap-tab.js"></script> <script src="../assets/js/bootstrap-tooltip.js"></script> <script src="../assets/js/bootstrap-popover.js"></script> <script src="../assets/js/bootstrap-button.js"></script> <script src="../assets/js/bootstrap-collapse.js"></script> <script src="../assets/js/bootstrap-carousel.js"></script> <script src="../assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<?php include "includes/common.php"; //Step - 3 (SQL / Get result) $sql = "SELECT * from `settings`"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><?php echo $row['site_name'];?></title> <meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" /> <meta name="author" content="Erwin Aligam - styleshout.com" /> <meta name="description" content="Site Description Here" /> <meta name="keywords" content="keywords, here" /> <meta name="robots" content="index, follow, noarchive" /> <meta name="googlebot" content="noarchive" /> <link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> <link media="screen" rel="stylesheet" href="<?php echo $site_url;?>third_party/colorbox/colorbox.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <script src="<?php echo $site_url;?>third_party/colorbox/jquery.colorbox.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".cbox").colorbox({transition:"none", width:"85%", height:"85%"}); }); </script> </head> <body> <!-- wrap starts here --> <div id="wrap"> <!--header --> <div id="header"> <h1 id="logo-text"><a href="<?php echo $site_url;?>" title=""><?php echo $row['site_name'];?></a></h1> <p id="slogan"><?php echo $row['site_slogan'];?></p> <div id="nav"> <ul> <li class="first" id="current"><a href="index.html">Home</a></li> <li><a href="style.html">Style</a></li> <li><a href="blog.html">Blog</a></li> <li><a href="archives.html">Archives</a></li> </ul> </div> <div id="header-image"></div> <!--header ends--> </div> <!-- featured starts --> <div id="featured" class="clear"> <a name="TemplateInfo"></a> <?php $featured_sql = "SELECT post.*, post_categories.name, users.username from `post` JOIN `post_categories` ON post.category = post_categories.id JOIN `users` ON post.user_id = users.id WHERE post_categories.slug ='featured' order by post.created_at DESC LIMIT 1"; $featured_result = mysql_query($featured_sql); $featured_post = mysql_fetch_assoc($featured_result); ?> <div class="image-block"> <img width="330" src="<?php echo UPLOAD_PATH.$featured_post['image'];?>" alt="featured"/> </div> <div class="text-block"> <h2><a href="index.html"><?php echo $featured_post['title'];?></a></h2> <p class="post-info">Posted by <a href="index.html"><?php echo $featured_post['username'];?></a></p> <p> <?php echo substr($featured_post['content'],0,300); ?> </p> <p><a href="index.html" class="more-link">Read More</a></p> </div> <!-- featured ends --> </div> <!-- content --> <div id="content-outer" class="clear"><div id="content-wrap"> <div id="content"> <div id="left"> <?php $general_sql = "SELECT post.*, post_categories.name, users.username from `post` JOIN `post_categories` ON post.category = post_categories.id JOIN `users` ON post.user_id = users.id WHERE post_categories.slug ='general' order by post.created_at DESC LIMIT 5"; $general_result = mysql_query($general_sql); while ($post = mysql_fetch_assoc($general_result)) { ?> <div class="entry"> <h3><a href="index.html"><?php echo $post['title'];?></a></h3> <p> <?php echo substr($post['content'],0,300);?> </p> <p><a class="more-link" href="index.html">continue reading</a></p> </div> <?php } ?> </div> <div id="right"> <h3>Search</h3> <form id="quick-search" action="index.html" method="get" > <p> <label for="qsearch">Search:</label> <input class="tbox" id="qsearch" type="text" name="qsearch" value="type and hit enter..." title="Start typing and hit ENTER" /> <input class="btn" alt="Search" type="image" name="searchsubmit" title="Search" src="images/search.gif" /> </p> </form> <div class="sidemenu"> <h3>Sidebar Menu</h3> <ul> <li><a href="index.html">Home</a></li> <li><a href="index.html#TemplateInfo">TemplateInfo</a></li> <li><a href="style.html">Style Demo</a></li> <li><a href="blog.html">Blog</a></li> <li><a href="archives.html">Archives</a></li> <li><a href="http://www.dreamtemplate.com" title="Web Templates">Web Templates</a></li> </ul> </div> <div class="sidemenu"> <h3>Sponsors</h3> <ul> <li><a href="http://www.dreamtemplate.com" title="Website Templates">DreamTemplate <br /> <span>Over 6,000+ Premium Web Templates</span></a> </li> <li><a href="http://www.themelayouts.com" title="WordPress Themes">ThemeLayouts <br /> <span>Premium WordPress &amp; Joomla Themes</span></a> </li> <li><a href="http://www.imhosted.com" title="Website Hosting">ImHosted.com <br /> <span>Affordable Web Hosting Provider</span></a> </li> <li><a href="http://www.dreamstock.com" title="Stock Photos">DreamStock <br /> <span>Download Amazing Stock Photos</span></a> </li> <li><a href="http://www.evrsoft.com" title="Website Builder">Evrsoft <br /> <span>Website Builder Software &amp; Tools</span></a> </li> <li><a href="http://www.webhostingwp.com" title="Web Hosting">Web Hosting <br /> <span>Top 10 Hosting Reviews</span></a> </li> </ul> </div> </div> </div> <!-- content end --> </div></div> <!-- footer starts here --> <div id="footer-outer" class="clear"><div id="footer-wrap"> <div class="col-a"> <h3>Image Gallery </h3> <p class="thumbs"> <?php $sql = "SELECT * FROM `gallery` LIMIT 8"; $gallery = mysql_query($sql); if ($gallery && mysql_num_rows($gallery)) { while ($row = mysql_fetch_assoc($gallery)) { ?> <a class="cbox" href="<?php echo $upload_url.$row['path'];?>"><img height="40" width="40" src="<?php echo $upload_url.$row['path']; ?>"/> </a> <?php } } ?> </p> </div> <div class="col-a"> <h3>Lorem Ipsum</h3> <p> <strong>Lorem ipsum dolor</strong> <br /> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec libero. Suspendisse bibendum. Cras id urna. Morbi tincidunt, orci ac convallis aliquam, lectus turpis varius lorem, eu posuere nunc justo tempus leo. Donec mattis, purus nec placerat bibendum, dui pede condimentum odio, ac blandit ante orci ut diam.</p> </div> <div class="col-b"> <h3>About</h3> <p> <a href="index.html"><img src="images/gravatar.jpg" width="40" height="40" alt="firefox" class="float-left" /></a> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec libero. Suspendisse bibendum. Cras id urna. Morbi tincidunt, orci ac convallis aliquam, lectus turpis varius lorem, eu posuere nunc justo tempus leo. Donec mattis, purus nec placerat bibendum, dui pede condimentum odio, ac blandit ante orci ut diam.</p> </div> <!-- footer ends --> </div></div> <!-- footer-bottom starts --> <div id="footer-bottom"> <div class="bottom-left"> <p> &copy; 2010 <strong>Your Copyright Info Here</strong>&nbsp; &nbsp; &nbsp; <a href="http://www.bluewebtemplates.com/" title="Website Templates">website templates</a> by <a href="http://www.styleshout.com/">styleshout</a> </p> </div> <div class="bottom-right"> <p> <a href="http://jigsaw.w3.org/css-validator/check/referer">CSS</a> | <a href="http://validator.w3.org/check/referer">XHTML</a> | <a href="index.html">Home</a> | <a href="index.html">Sitemap</a> | <a href="index.html">RSS Feed</a> </p> </div> <!-- footer-bottom ends --> </div> <!-- wrap ends here --> </div> </body> </html>
PHP
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>PHP Course</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content=""> <meta name="author" content=""> <!-- Le styles --> <link href="assets/css/bootstrap.css" rel="stylesheet"> <style> body { padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ } </style> <link href="assets/css/bootstrap-responsive.css" rel="stylesheet"> <!-- HTML5 shim, for IE6-8 support of HTML5 elements --> <!--[if lt IE 9]> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <!-- Fav and touch icons --> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/apple-touch-icon-144-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/apple-touch-icon-114-precomposed.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/apple-touch-icon-72-precomposed.png"> <link rel="apple-touch-icon-precomposed" href="assets/ico/apple-touch-icon-57-precomposed.png"> <link rel="shortcut icon" href="assets/ico/favicon.png"> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="#">PHP Course</a> <div class="nav-collapse collapse"> <ul class="nav"> <li class="active"><a href="#">Home</a></li> <li><a href="#about">Users</a></li> <li><a href="#contact">Photos</a></li> <li><a href="#contact">Videos</a></li> <li><a href="#contact">Feedback</a></li> </ul> </div><!--/.nav-collapse --> </div> </div> </div> <div class="container"> <h1>Welcome to Database</h1> <?php ?> </div> <!-- /container --> <!-- Le javascript ================================================== --> <!-- Placed at the end of the document so the pages load faster --> <script src="assets/js/jquery.js"></script> <script src="assets/js/bootstrap-transition.js"></script> <script src="assets/js/bootstrap-alert.js"></script> <script src="assets/js/bootstrap-modal.js"></script> <script src="assets/js/bootstrap-dropdown.js"></script> <script src="assets/js/bootstrap-scrollspy.js"></script> <script src="assets/js/bootstrap-tab.js"></script> <script src="assets/js/bootstrap-tooltip.js"></script> <script src="assets/js/bootstrap-popover.js"></script> <script src="assets/js/bootstrap-button.js"></script> <script src="assets/js/bootstrap-collapse.js"></script> <script src="assets/js/bootstrap-carousel.js"></script> <script src="assets/js/bootstrap-typeahead.js"></script> </body> </html>
PHP
<?php if (!$_SESSION['login']) exit; ?> <div class="navbar navbar-inverse navbar-fixed-top"> <div class="navbar-inner"> <div class="container"> <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </a> <a class="brand" href="admin.php">PHP Course</a> <div class="nav-collapse collapse"> <ul class="nav"> <li><a href="admin.php">Home</a></li> <li><a href="navigations.php">Navigations</a></li> <li><a href="posts.php">Posts</a></li> <li><a href="settings.php">Settings</a></li> <li><a href="gallery.php">Gallery</a></li> <li><a href="#contact">Feedback</a></li> <li><a href="logout.php">Logout - <?php echo $_SESSION['username']; ?></a></li> </ul> </div><!--/.nav-collapse --> </div> </div> </div>
PHP
<?php include "../includes/common.php"; $id = $_GET['id']; if ($id) { $sql = "select * from `gallery` where `id`=$id;"; $r = mysql_query($sql); $pic = mysql_fetch_assoc($r); $picture_from_db = $pic['path']; if ($picture_from_db!= "") { $filename = "../../uploads/" . $picture_from_db ; unlink($filename); } $delsql = "delete from `gallery` where `id` = $id"; mysql_query ($delsql); } header ("location: ../gallery.php"); ?>
PHP
<?php //Step - 1 (Connection) $con = mysql_connect("localhost", "root", ""); //Step - 2 (Database) mysql_select_db("test"); //Step - 3 (SQL / Get result) $id = $_GET['id']; $sql = "delete from `users` where `id` = $id"; mysql_query($sql); //echo "user id ". $_GET['id'] . " deleted"; header ("location: ../database.php"); ?>
PHP
<?php //Step - 1 (Connection) $con = mysql_connect("localhost", "root", ""); //Step - 2 (Database) mysql_select_db("test"); //Step - 3 (SQL / Get result) $sql = ""; //Step - 4 (Grab / Process / Execute query) $sql = "delete from `users` where `id` = $id"; mysql_query($sql); //Step - 5 (Close connection) mysql_close($con); //redirect to main page header ("location: ../database.php"); ?>
PHP