Public
snipts » php
showing 1-20 of 338 snipts for php
-
∞ random md5
md5(uniqid(rand(), true)); -
∞ Get the nth sentence from the post (beta)
<?php function the_nth_sentence($sentence_num = 1) { if ($sentence_num == 0) { return false; } if ($sentence_num >= 1) { $sentence_num = $sentence_num-1; } $content = get_the_content('',FALSE,''); $content = apply_filters('the_content', $content); $content = strip_tags($content); $pos = strpos($content, '.'); for($i=1; $i<=$sentence_num; $i++) { $pos = strpos($content, '.', $pos+1); } echo '<p>' . substr($content,0,$pos+1) . '</p>'; } ?>
-
∞ show php errors
ini_set('display_errors', "1"); ini_set('error_reporting', E_ALL ^ E_NOTICE);
-
∞ Django Mediawiki Auth Intergation Class
<?php /* Auth_django.php */ error_reporting(E_ALL); /** * This plugin allows you to use the django auth system with mediawiki. * * Copyright 2009 Thomas Lilley <mail@tomlilley.co.uk> (tomlilley.co.uk) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * http://www.gnu.org/copyleft/gpl.html */ require_once './includes/AuthPlugin.php'; /** * Handles the Authentication with the PHPBB database. * */ class Auth_django extends AuthPlugin { /** * Django User Table Name * * @var int */ private $UserTable = 'auth_user'; /** * Database connection * * @var object */ private $db; /** * Constructor * * @param array $aConfig */ function __construct($aConfig) { // Set some MediaWiki Values // This requires a user be logged into the wiki to make changes. $GLOBALS['wgGroupPermissions']['*']['edit'] = false; // Specify who may create new accounts: $GLOBALS['wgGroupPermissions']['*']['createaccount'] = false; // Load Hooks //$GLOBALS['wgHooks']['UserLoginForm'][] = array($this, 'onUserLoginForm', false); //$GLOBALS['wgHooks']['UserLoginComplete'][] = $this; //$GLOBALS['wgHooks']['UserLogout'][] = $this; // We could use mediawiki's database class but this way is more simple for the time $this->db = new mysqli($aConfig['Django_Host'], $aConfig['Django_User'], $aConfig['Django_Pass'], $aConfig['Django_DBName']); if ($this->db->connect_error) { die('Connect Error (' . mysqli_connect_errno() . ') ' . $this->db->connect_error); } } /** * Check whether there exists a user account with the given name. * The name will be normalized to MediaWiki's requirements, so * you might need to munge it (for instance, for lowercase initial * letters). * * @param $username String: username. * @return bool */ public function userExists($username) { $query = sprintf('SELECT username FROM %s WHERE username = "%s" LIMIT 0,1', $this->UserTable, $this->db->real_escape_string($username)); if ($result = $this->db->query($query)) { // single row so no looping $row = $result->fetch_assoc(); // this may be cheating but it's alot simpler just to make both usernames lowercase, then compare if (strtolower($row['username']) == strtolower($username)) { return true; } $result->close(); } return false; } /** * Check if a username+password pair is a valid login. * The name will be normalized to MediaWiki's requirements, so * you might need to munge it (for instance, for lowercase initial * letters). * * @param $username String: username. * @param $password String: user password. * @return bool */ public function authenticate($username, $password) { // Check Database for username and password. $query = sprintf('SELECT id, username, password FROM %s WHERE username = "%s" LIMIT 0,1', $this->UserTable, $this->db->real_escape_string($username)); if ($result = $this->db->query($query)) { // single row so no looping $row = $result->fetch_assoc(); $password_array = explode('$', $row['password'] ); // Only works with sha1 for the current time. Other possible types: md5, crypt if ($password_array[0] == 'sha1') { if (sha1($password_array[1] . $password) == $password_array[2]) { return true; } } $result->close(); } return false; } /** * Modify options in the login template. * * @param $template UserLoginTemplate object. */ public function modifyUITemplate( &$template ) { # Override this! $template->set('usedomain', false); $template->set('create', false); $template->set('useemail', false); } /** * Set the domain this plugin is supposed to use when authenticating. * * @param $domain String: authentication domain. */ public function setDomain( $domain ) { $this->domain = $domain; } /** * Check to see if the specific domain is a valid domain. * * @param $domain String: authentication domain. * @return bool */ public function validDomain( $domain ) { # Override this! return true; } /** * When a user logs in, optionally fill in preferences and such. * For instance, you might pull the email address or real name from the * external user database. * * The User object is passed by reference so it can be modified; don't * forget the & on your function declaration. * * @param User $user */ public function updateUser( &$user ) { # Override this and do something return true; } /** * Return true if the wiki should create a new local account automatically * when asked to login a user who doesn't exist locally but does in the * external auth database. * * If you don't automatically create accounts, you must still create * accounts in some way. It's not possible to authenticate without * a local account. * * This is just a question, and shouldn't perform any actions. * * @return bool */ public function autoCreate() { return true; } /** * Can users change their passwords? * * @return bool */ public function allowPasswordChange() { return true; } /** * Set the given password in the authentication database. * As a special case, the password may be set to null to request * locking the password to an unusable value, with the expectation * that it will be set later through a mail reset or other method. * * Return true if successful. * * @param $user User object. * @param $password String: password. * @return bool */ public function setPassword( $user, $password ) { return true; } /** * Update user information in the external authentication database. * Return true if successful. * * @param $user User object. * @return bool */ public function updateExternalDB( $user ) { return true; } /** * Check to see if external accounts can be created. * Return true if external accounts can be created. * @return bool */ public function canCreateAccounts() { return false; } /** * Add a user to the external authentication database. * Return true if successful. * * @param User $user - only the name should be assumed valid at this point * @param string $password * @param string $email * @param string $realname * @return bool */ public function addUser( $user, $password, $email='', $realname='' ) { return false; } /** * Return true to prevent logins that don't authenticate here from being * checked against the local database's password fields. * * This is just a question, and shouldn't perform any actions. * * @return bool */ public function strict() { return false; } /** * Check if a user should authenticate locally if the global authentication fails. * If either this or strict() returns true, local authentication is not used. * * @param $username String: username. * @return bool */ public function strictUserAuth( $username ) { return false; } /** * When creating a user account, optionally fill in preferences and such. * For instance, you might pull the email address or real name from the * external user database. * * The User object is passed by reference so it can be modified; don't * forget the & on your function declaration. * * @param $user User object. * @param $autocreate bool True if user is being autocreated on login */ public function initUser( &$user, $autocreate=false ) { $query = sprintf('SELECT email FROM %s WHERE username = "%s" LIMIT 0,1', $this->UserTable, $this->db->real_escape_string($user->mName)); if ($result = $this->db->query($query)) { $row = $result->fetch_assoc(); $user->mEmail = $row['email']; } } /** * If you want to munge the case of an account name before the final * check, now is your chance. */ public function getCanonicalName( $username ) { // probable ToDo: Find out what format django and wiki usernames are and put in correct format for wiki here. return $username; } /** * Get an instance of a User object * * @param $user User * @public */ public function getUserInstance( User &$user ) { return new AuthPluginUser( $user ); } } ?>
-
∞ Backup index.php Super45.net
<?php get_header(); ?> <div id="row1"> <div id="discodestacado"> <h2><img src="/images/disco-destacado.png" alt="Disco Destacado" /></h2> <div id="contenedor-disco"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=1488'); ?> <?php while (have_posts()) : the_post(); ?> <div id="foto-tit-dd"> <div id="fotodd"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div id="titdd"><h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3></div> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> </div><!-- end of discodestacado div --> <div id="otrosdiscos"> <h2><img src="/images/en-breve.png" alt="En Breve" /></h2> <div id="slider"> <ul> <li> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&cat=1489'); ?> <?php while (have_posts()) : the_post(); ?> <div class="d-breve"><div class="foto-breve"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div><div class="tit-breve"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </li> <li> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&offset=6&cat=1489'); ?> <?php while (have_posts()) : the_post(); ?> <div class="d-breve"><div class="foto-breve"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div><div class="tit-breve"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </li> <li> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=6&offset=12&cat=1489'); ?> <?php while (have_posts()) : the_post(); ?> <div class="d-breve"><div class="foto-breve"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div><div class="tit-breve"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </li> </ul> </div> </div><!-- end of otrosdiscos div --> <div id="publi1"> <script type='text/javascript'><!--//<![CDATA[ var m3_u = (location.protocol=='https:'?'https://open.estupendos.net/www/delivery/ajs.php':'http://open.estupendos.net/www/delivery/ajs.php'); var m3_r = Math.floor(Math.random()*99999999999); if (!document.MAX_used) document.MAX_used = ','; document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); document.write ("?zoneid=2"); document.write ('&cb=' + m3_r); if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used); document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : '')); document.write ("&loc=" + escape(window.location)); if (document.referrer) document.write ("&referer=" + escape(document.referrer)); if (document.context) document.write ("&context=" + escape(document.context)); if (document.mmm_fo) document.write ("&mmm_fo=1"); document.write ("'><\/scr"+"ipt>"); //]]>--></script><noscript><a href='http://open.estupendos.net/www/delivery/ck.php?n=a75a6856&cb=23544353' target='_blank'><img src='http://open.estupendos.net/www/delivery/avw.php?zoneid=2&cb=23544353&n=a75a6856' border='0' alt='' /></a></noscript> </div><!-- end of publi1 div --> </div><!-- end of row1 div --> <div id="row2"> <div id="destacado"> <h2><img src="/images/destacamos.png" alt="Destacamos en S45" /></h2> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=1509'); ?> <?php while (have_posts()) : the_post(); ?> <div id="contenedor-destacado"> <div class="foto-destacado"><?php get_the_image('custom_key=foto-home&default_size=full&default_image=/images/medium.png'); ?></div> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php foreach((get_the_category()) as $cat) { if ($cat->cat_ID != "1509" ) { echo '<a href="/?cat=' . $cat->cat_ID . '"> ' . $cat->cat_name . '</a> '; } } ?> | Por <?php the_author_posts_link(); ?> | <?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=5&offset=1&cat=1509'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php foreach((get_the_category()) as $cat) { if ($cat->cat_ID != "1509" ) { echo '<a href="/?cat=' . $cat->cat_ID . '"> ' . $cat->cat_name . '</a> '; } } ?> | <?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div><!-- end of destacado div --> <div id="articulos"> <ul> <li><a href="#tabs-1"><img src="/images/blog.png" alt="Blog" /></a></li> <li><a href="#tabs-2"><img src="/images/noticias.png" alt="Noticias" /></a></li> <li><a href="#tabs-3"><img src="/images/articulos.png" alt="Articulos" /></a></li> </ul> <div id="tabs-1"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=8&cat=41'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="vertodos"><a href="/seccion/blog/" title="Ver todo el blog">[+] Ver todos</a></div> </div> <div id="tabs-2"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=8&cat=3'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="vertodos"><a href="/seccion/noticias/" title="Ver todas las noticias">[+] Ver todos</a></div> </div> <div id="tabs-3"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=42'); ?> <?php while (have_posts()) : the_post(); ?> <div id="contenedor-articulo"> <div class="contenedor-foto-articulo"><?php get_the_image('custom_key=foto-home&default_size=full&default_image=/images/medium.png'); ?></div> <div class="cat-arti"><?php the_category(); ?></div> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata">Por <?php the_author_posts_link(); ?> | <?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=5&offset=1&cat=42,44,45'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="cat-arti"><?php the_category(); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="vertodos"><a href="/seccion/articulos/" title="Ver todos los artículos">[+] Ver todos</a></div> </div> </div><!-- end of articulos div --> <div id="radio"> <div id="s45radio"> <h2><img src="/images/2009/06/super-45-radio.png" alt="S45 en Radio Duna" /></h2> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=49'); ?> <?php while (have_posts()) : the_post(); ?> <div id="foto-radio"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div id="txt-radio"> <span class="prox-radio">Próximo programa:<br /></span> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <?php the_excerpt() ?> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <div class="podcast"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=21'); ?> <?php while (have_posts()) : the_post(); ?> <div id="txt-podcast"> <p class="podcast-anterior">Descarga el programa anterior:</p> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <div class="excerpt-podcast"><?php the_excerpt() ?></div> </div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> </div> <div id="ad-radio1"></div> <div id="agenda"> <ul> <li><a href="#tabs-4"><img src="/images/nuestra_agenda.png" alt="Nuestra Agenda" /></a></li> <li><a href="#tabs-5"><img src="/images/cartelera.png" alt="Cartelera" /></a></li> <li><a href="#tabs-6"><img src="/images/concursos.png" alt="Concursos" /></a></li> </ul> <div id="tabs-4"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=2&cat=1511'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> <div id="tabs-5"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=35'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado25"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> <div id="tabs-6"> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=1&cat=66'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-destacado"> <div class="foto-sub-destacado"><?php get_the_image('custom_key=foto-home&default_size=thumbnail&default_image=/images/thumb.png'); ?></div> <div class="txt-sub-destacado"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado2"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> <?php if (have_posts()) : ?> <?php //query_posts('paged='.$paged); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(); $wp_query->query('showposts=2&offset=1&cat=66'); ?> <?php while (have_posts()) : the_post(); ?> <div class="sub-concurso"> <div class="txt-sub-concurso"> <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h3> <p class="metadata"><?php the_time('d.m.y') ?> | <?php comments_popup_link('<img src="/images/icon-comm.png" alt="Comentarios" /> 0', '<img src="/images/icon-comm.png" alt="Comentarios" /> 1', '<img src="/images/icon-comm.png" alt="Comentarios" /> %'); ?></p> </div> </div> <div class="clear-destacado"></div> <?php endwhile; ?> <?php else : ?> <?php endif; ?> </div> </div><!-- end of agenda div --> <div id="ad-radio2"><a href="http://sonik.cl"><img src="/images/300x100-Sonik-S45.gif" alt="Sonik" /></a></div> <div id="ad-radio3"> <script type='text/javascript'><!--//<![CDATA[ var m3_u = (location.protocol=='https:'?'https://open.estupendos.net/www/delivery/ajs.php':'http://open.estupendos.net/www/delivery/ajs.php'); var m3_r = Math.floor(Math.random()*99999999999); if (!document.MAX_used) document.MAX_used = ','; document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u); document.write ("?zoneid=5"); document.write ('&cb=' + m3_r); if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used); document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : '')); document.write ("&loc=" + escape(window.location)); if (document.referrer) document.write ("&referer=" + escape(document.referrer)); if (document.context) document.write ("&context=" + escape(document.context)); if (document.mmm_fo) document.write ("&mmm_fo=1"); document.write ("'><\/scr"+"ipt>"); //]]>--></script><noscript><a href='http://open.estupendos.net/www/delivery/ck.php?n=a5a9a894&cb=5467546' target='_blank'><img src='http://open.estupendos.net/www/delivery/avw.php?zoneid=5&cb=5467546&n=a5a9a894' border='0' alt='' /></a></noscript> </div> <div id="tla"><?php tla_ads(); ?><br/><?php if (is_callable(array("LinkLiftPlugin", "execute"))) LinkLiftPlugin::execute(); ?></div> </div><!-- end of radio div --> </div><!-- end of row2 div --> <div id="row3"> <h2>Comunidad Super 45</h2> <div id="eventos"> <h3><a href="http://vimeo.com/super45">Noa Noa</a></h3> <div class="videos-oficiales"> <!-- START Vimeo Badge ... info at http://vimeo.com/widget --> <div class="vimeoBadge"> <script type="text/javascript" src="http://vimeo.com/super45/badgeo/?stream=uploaded&stream_id=&count=4&thumbnail_width=100&show_titles=no"></script> </div> <!--END Vimeo Badge--> </div> </div><!-- end of eventos div --> <div id="vimeo"> <h3><a href="http://vimeo.com/channels/super45">Canal Vimeo</a></h3> <!-- START Vimeo Badge ... info at http://vimeo.com/widget --> <div class="vimeoBadge"> <script type="text/javascript" src="http://vimeo.com/super45/badgeo/?stream=channel&stream_id=34616&count=6&thumbnail_width=100&show_titles=no"></script> </div> <!--END Vimeo Badge--> </div><!-- end of vimeo div --> <div id="flickr"> <h3><a href="http://www.flickr.com/super45/">Super 45 en Flickr</a></h3> <div id="contenedor-flickr"> <!-- Start of Flickr Badge --> <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?count=5&display=latest&size=s&layout=x&source=user&user=39096086%40N04"></script> <!-- End of Flickr Badge --> </div> </div><!-- end of flickr div --> <div id="sociales"> <ul> <li><a class="facebook" href="http://facebook.com/group.php?gid=13967200331">Grupo Facebook</a></li> <li><a class="facebook" href="http://facebook.com/pages/Santiago-Chile/Super-45/14050945943">Página Facebook</a></li> <li><a class="twitter" href="http://twitter.com/super45">Twitter</a></li> <li><a class="lastfm" href="http://last.fm/group/Super+45">Grupo Last.fm</a></li> </ul> </div><!-- end of sociales div --> </div><!-- end of row3 div --> <?php get_footer(); ?>
-
∞ PHP reads from text file and write into YML file
<? $arr=file("province.txt");// the txt file to be read // read the data from province.txt and write into 02_district.yml $myFile = "02_district.yml"; //open a new file with name $myFile, if permission is dennied, throws message $fh = fopen($myFile, 'w') or die("can't open file"); // write the head in YML file without backspace $head= "District:\n"; fwrite($fh, $head); $i = 0; $k = 0; $tmp = "province"; foreach($arr as $str) { $k++; // split $str, if digits were found list($province,$district)=preg_split("/[\d]+/", $str);; /*echo "<ul>"; echo "<li>".$province; echo "<li>".$district; echo "</ul>"; echo "<hr>";*/ $district_id = " District_".$k.":\n";// \n change line $district_name = " name: ".$district.""; if($tmp != $province){//if province is changed, increase the id of province $i++; $tmp = $province; } $province_id = " province_id: Province_".$i."\n"; fwrite($fh, $district_id);//write the value in file fwrite($fh, $district_name); fwrite($fh, $province_id); } fclose($fh); ?> // this is text file to be read by PHP script Nuristan 3001 Nuristan Nuristan 3002 Kamdesh Nuristan 3003 Waygal Nuristan 3004 Mandol Nuristan 3005 Bargi Matal Nuristan 3006 Wama Nuristan 3007 Du Ab Nuristan 3008 Nurgaram Sari Pul 3101 Sari Pul Sari Pul 3102 Sangcharak Sari Pul 3103 Kohistanat Sari Pul 3104 Balkhab Sari Pul 3105 Sozma Qala Sari Pul 3106 Sayyad Sari Pul 3107 Gosfandi
-
∞ PHP class template
<?php /** * @author 1:Carlos Pires} * @copyright Copyright (c) 2010, 2:2km interativa!} */ class ${3:nome da classe} { $end } ?>
-
∞ Dates Samples
<?php $currDate = date('Y-m-d h:i:s'); // convert timestamp from mysql $nextReviewDt = date('F d, Y',strtotime($nextReviewDt)); // Add 30 days $CommentStartDt = date('m/d/Y'); $CommentEndDt = date('m/d/Y', mktime(0,0,0,date("m"),date("d")+30,date("Y"))); // add 30 days // convert year to 4 digits if ($y > 60) $y = '19'.$y; else $y = '20'.$y; // split if there are slash or dash list($m, $d, $y) = split('[/|-]', $iDate); if (preg_match("/-/", $iDate)) list($m, $d, $y) = split('-', $iDate); else if (preg_match("/\//", $iDate)) list($m, $d, $y) = split('/', $iDate); $specDate = mktime(0, 0, 0, $m, $d, $y); $numOfDays = (time() - $specDate) / (24 * 60 * 60); // convert date from mysql db if (preg_match("/(.*)Dt$/", $dbDate)) $dbDate = date("M d, Y h:ia", strtotime($dbDate)); // output dates - walk the days $startDt = '2009-01-04'; $endDt = date('Y-m-d'); while ($startDt != $endDt) { echo "$startDt <br/>"; // increment the day $startDt = strtotime(date("Y-m-d", strtotime($startDt)) . " +1 day"); // convert back to readable format $startDt = date("Y-m-d",$startDt); } function count_days( $a, $b ) { // First we need to break these dates into their constituent parts: $gd_a = getdate( $a ); $gd_b = getdate( $b ); // Now recreate these timestamps, based upon noon on each day // The specific time doesn't matter but it must be the same each day $a_new = mktime( 12, 0, 0, $gd_a['mon'], $gd_a['mday'], $gd_a['year'] ); $b_new = mktime( 12, 0, 0, $gd_b['mon'], $gd_b['mday'], $gd_b['year'] ); // Subtract these two numbers and divide by the number of seconds in a // day. Round the result since crossing over a daylight savings time // barrier will cause this time to be off by an hour or two. return round( abs( $a_new - $b_new ) / 86400 ); }
-
∞ Log errors in diffent folders/files reflecting the application folder structure.
<?php /** * Log PHP's error into separate files. Recommended for use in production site. * Should be used in set_error_handler() to handle certain PHP errors (i.e. E_STRICT). * @link http://www.php.net/manual/en/function.set-error-handler.php Reference */ function errorHandler($errno, $errstr, $errfile=NULL, $errline=NULL, $errcontext=NULL) { // Log uncategorized errors if (is_null($errfile)) { $errfile = 'errors.log'; } // Reconstruct the path // define('APP_DIR', '/my/application/') // define('LOG_DIR', '/log_dir/') // E.g. /my/application/controller/index.php -> /log_dir/controller/index.php $pos = strpos($errfile, APP_DIR); if ($pos !== FALSE) { // Strip off the application directory and attach log directory $errfile = LOG_DIR.substr($errfile, $pos + strlen(CMS_ROOT)); } else { $errfile = LOG_DIR.$errfile; // E.g. /log_dir/errors.log } $dir = dirname($errfile); // Create dir if necessary if (! file_exists($dir)) { mkdir($dir, 0775, TRUE); } $logFile = fopen($errfile, 'a'); fwrite($logFile, date('Y-m-d H:i:s ').$errstr); if ($errline) fwrite($logFile, " on line $errline"); fwrite($logFile, "\n"); fclose($logFile); if (PRODUCTION_SITE) // Prevent err msg from being printed out (log errors silently) return TRUE; return FALSE; } ?>
-
∞ AJAX in Joomla 1.5
<?php /* /com_mycomponent |-/views | |-/response | |-/tmpl | | |-default.php | | |-index.html | |-view.raw.php */ ?> <?php //default.php defined('_JEXEC') or die('Restricted access'); echo $this->response; ?> <?php //view.raw.php defined('_JEXEC') or die('Restricted access'); jimport( 'joomla.application.component.view'); class MycomponentViewResponse extends JView{ public function plain($tpl=null){ $this->setLayout('default'); parent::display($tpl); } public function json($tpl=null){ $this->response = json_encode($this->response); $this->setLayout('default'); parent::display($tpl); } } ?> <?php //somewhere in a controller public function check(){ $view = &$this->getView('response','raw'); $view->response = 'OK'; $view->plain(); } ?> In your ajax call use the following base URL: index.php?option=com_mycomponent&format=raw& Then append the right controller & task parameters to the url, like: index.php?option=com_mycomponent&format=raw&controller=mycontroller&task=check
-
∞ Respaldo de template de area comercial de Horizonte.cl
<?php /* Template Name: Area Comercial */ ?> <?php get_header(); ?> <?php get_sidebar(); ?> <div id="columna_izquierda" class="ancho_contacto"> <div id="contacto"> <div class="titulo"> <h1>Perfil de la radio</h1> </div> <div class="contenedor"> <p>Horizonte es una radio donde se le da énfasis a las tendencias musicales nacionales e internacionales. Donde comparten espacio los clásicos y la vanguardia. Un medio pluralista y abierto a respetar las distintas opciones de la actualidad, difundir la cultura y generar comunidades activas.</p> <p>Nuestro público objetivo está definido como hombres y mujeres entre los 20 y 34 años pertenecientes a los grupos socio económico ABC1 y C2.</p> <p>Además de la música, tenemos programas descritos a continuación:</p> </div> <br /> <div class="titulo"> <h1>Guia de Avisadores</h1> </div> <div class="contenedor"> <p><b>TARIFAS AUSPICIOS RADIO HORIZONTE </b></p> <p><b>RADIO HORIZONTE RED SATELITAL</b> transmite en Santiago 103.3 y Viña del Mar 101.1.</p> <p><b>En Radio Horizonte tenemos para nuestros clientes espacios publicitarios en forma de frases (repartidas y/o determinadas), auspicios y espacios noticiosos.</b></p> <table> <tr> <th>Tipo de Frases en Horizonte Stgo. + Regiones</th> <th>Valor Mensual</th> </tr> <tr> <td>Frase mes horario Repartido de hasta 30".</td> <td>$1.100.000 + iva.</td> </tr> <tr> <td>Frase mes horario Determinado de hasta 30". </td> <td>$1.320.000 + iva.</td> </tr> <tr> <td>Frase mes Política de hasta 30". </td> <td>$1.380.000 + iva.</td> </tr> </table> <p><b>CONDICIONES GENERALES:</b></p> <ol> <li>Segundaje: Las tarifas consideradas comprenden frases de hasta 30 segundos. Si el segundaje contratado fuera inferior a dicho tiempo, la radio no retribuirá con una mayor frecuencia la diferencia existente. Si por el contrario el segundaje supera los 30", la Radio disminuirá proporcionalmente la frecuencia contratada.</li> <li>Los valores incluyen Comisión de Agencia.</li> <li>Los valores no incluyen IVA.</li> <li>Los valores son considerados con pago a 30 días del inicio de la Publicidad.</li> <li>Se considera un descuento por pago contado.</li> <li>Los avisos solicitados en cabeza o cierre de tanda tienen un recargo del 25%.</li> </ol> </div> <br /> <div class="titulo"> <h1> Nuestros Programas </h1> </div> <div class="contenedor"> <p> <h4>CONDICIONES GENERALES</h4> <ol> <li>Segundaje: Las tarifas consideradas comprenden frases de hasta 30 seg. Si el segundaje contratado fuera inferior a dicho tiempo, la radio no retribuirá con una mayor frecuencia la diferencia existente. Si por el contrario el segundaje supera los 30", la Radio disminuirá proporcionalmente la frecuencia contratada.</li> <li>Los valores incluyen Comisión de Agencia.</li> <li>Los valores no incluyen IVA.</li> <li>Los valores son considerados con pago a 30 días del inicio de la Publicidad.</li> <li>Se considera un descuento por pago contado.</li> <li>Los avisos solicitados en cabeza o cierre de tanda tienen un recargo del 25%.</li> </ol> <hr size="1"/> <table id="fina"> <tr> <th>Programa</th> <th>Fina Seleccion</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 2 Frases diarias de hasta 30".<br/> 1 Mención Conductor</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Viernes y Domingos de 22:00 a 23:00 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 3.000.000 + iva mensual.</td> </tr> </table> <br /> <table id="destacados"> <tr> <th>Programa</th> <th>5 Destacados</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 5 Frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>Lunes a Domingos a las:<br /> 8.30, 11.30, 13.30, 16.30 y 19.30 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 4.620.000 + iva mensual.</td> </tr> </table> <br /> <table id="retro"> <tr> <th>Programa</th> <th>Retro</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención de marca en 4 emisiones diarias<br /> 1 Frase diaria despues de cada micro (4 diarias)<br /> 1 Mención Conductor</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>Lunes a Domingo a las:<br/> 10.00, 13.00, 15.00, 19.00 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 4.000.000 + iva mensual.</td> </tr> </table> <br /> <table id="loop"> <tr> <th>Programa</th> <th>Loop</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con menció<br /> 3 Frases diaria de hasta 30"<br /> 2 Menciónes</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>Sabado a las:<br/> 00.00 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 2.500.000 + iva mensual.</td> </tr> </table> <br /> <table id="agenda"> <tr> <th>Programa</th> <th>Agenda Horizonte</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 5 Frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo:<br /> 8.15, 10.15, 13.15, 16.15 y 19.15 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="tele"> <tr> <th>Programa</th> <th>Tele</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 1 frase después de cada micro (5 diarias)<br /> 3 frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo a las:<br /> 9.15, 12.15, 15.15, 18.15 y 21.15 hrs.</td> </tr> <tr> <td width="150"><b>VALOR MENSUAL </th> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="ticket"> <tr> <th>Programa</th> <th>Ticket</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 1 frase después de cada micro (5 diarias)<br /> 3 frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo a las:<br /> 9.15, 12.15, 15.15, 18.15 y 21.15 hrs.</td> </tr> <tr> <td width="150"><b>VALOR MENSUAL </th> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="version"> <tr> <th>Programa</th> <th>Versión Oficial</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con menció<br /> 1 Frase diaria de hasta 30"<br /> 1 Mención Conductor</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>Lunes a Domingo a las:<br/> 8.00, 11.00, 14.00, 17.00 y 20.00 hrs. Resumen especial domingo a las 17.00 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 4.620.000 + iva mensual.</td> </tr> </table> <br /> <table id="agenda"> <tr> <th>Programa</th> <th>Agenda Horizonte</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 5 Frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo:<br /> 8.15, 10.15, 13.15, 16.15 y 19.15 hrs.</td> </tr> <tr> <td width="150"><strong>VALOR MENSUAL</strong></td> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="tele"> <tr> <th>Programa</th> <th>Tele</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 1 frase después de cada micro (5 diarias)<br /> 3 frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo a las:<br /> 9.15, 12.15, 15.15, 18.15 y 21.15 hrs.</td> </tr> <tr> <td width="150"><b>VALOR MENSUAL </th> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="ticket"> <tr> <th>Programa</th> <th>Ticket</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación y cierre con mención.<br/> 1 frase después de cada micro (5 diarias)<br /> 3 frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo a las:<br /> 9.15, 12.15, 15.15, 18.15 y 21.15 hrs.</td> </tr> <tr> <td width="150"><b>VALOR MENSUAL </th> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="horarias"> <tr> <th>Programa</th> <th>Señales Horarias</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación (9 diarias)<br/> 9 frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo.</td> </tr> <tr> <td width="150"><b>VALOR MENSUAL </th> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> <br /> <table id="temperatura"> <tr> <th>Programa</th> <th>Señales de Temperatura</th> </tr> <tr> <td width="150"><strong>DERECHOS</strong></td> <td>Presentación (9 diarias)<br/> 9 frases diarias de hasta 30".</td> </tr> <tr> <td width="150"><strong>FRECUENCIA</strong></td> <td>De Lunes a Domingo.</td> </tr> <tr> <td width="150"><b>VALOR MENSUAL </th> <td> $ 5.335.000 + iva mensual.</td> </tr> </table> </div> <br /> <div class="titulo"> <h1>Contacto Comercial</h1> </div> <div class="contenedor"> <p>El Departamento Comercial de Radio Horizonte, opera en: <br/> Av. Pocuro 2151 comuna de Providencia - Santiago.</p> <p> <strong>EJECUTIVO COMERCIAL<br />SERGIO HERNANDEZ</strong><br /> Teléfono: 4105431<br/> E-Mail: <a href="mailto:shernandez@horizonte.cl">shernandez@horizonte.cl</a> </p> <p>Para cualquier consulta, duda o información respecto de la disponibilidad de espacios y/o programación en la Radio, nuestro Departamento Comercial atenderá oportunamente tales inquietudes.</p> </div> </div> </div> <?php get_footer(); ?>
-
∞ Respaldo de templates de programas de Horizonte.cl
<?php get_header(); ?> <?php get_sidebar(); ?> <div id="columna_izquierda"> <div id="programas"> <div class="programa"> <img src="/images/finaseleccion.jpg" alt="Fina Seleccion" /> <h3>Fina <span>Selección</span></h3> <h4>De lunes a viernes a las 22.00 hrs. Repetición el día domingo.</h4> <p>Los archivos favoritos de nuestro catálogo musical. Un programa donde podrás escuchar discos nuevos, clásicos y compilados de colección.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/fina-seleccion/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/5destacados.jpg" alt="5 Destacados" /> <h3>5 <span>Destacados</span></h3> <h4>De lunes a domingo a las 8.30, 11.30, 13.30, 16.30 y 19.30 hrs.</h4> <p>Entre millones de descargas anuales, miles de discos mensuales y cientos de canciones Radio Horizonte elige sólo 5 destacados.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/los-5-destacados/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/versionoficial.jpg" alt="Version Oficial" /> <h3><span>Versión</span> Oficial</h3> <h4>De lunes a domingo a las 8.00, 11.00, 14.00, 17.00 y 20.00 hrs. Especial de una hora domingo a las 17.00 hrs.</h4> <p>El especialista en covers de Radio Horizonte.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/version-oficial/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/agendahorizonte.jpg" alt="Agenda Horizonte" /> <h3><span>Agenda</span> Horizonte</h3> <h4>De lunes a domingo a las 8.15, 10.15, 13.15, 16.15 y 19.15 hrs.</h4> <p>La ciudad abre sus secretos en el 103.3 todo lo que necesitas saber para que tu vida sea más entretenida: música, conciertos, datos, actualidad, tecnología, cine, fiestas y lo mejor de la cartelera cultural.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/agenda-horizonte/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/tele.jpg" alt="Tele" /> <h3><span>Tele</span></h3> <h4>De lunes a domingo a las 9.15, 12.15, 15.15, 18.15 y 21.15 hrs.</h4> <p>Si vas a ver televisión, déjate guiar por la radio. El mapa audiovisual de Radio Horizonte: programas, series, películas, documentales y más.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/tele/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/retro.jpg" alt="Retro" /> <h3><span>Retro</span></h3> <h4>De lunes a domingo a las 10.00, 13.00, 15.00 y 19.00 hrs.</h4> <p>Un flashback a los tiempos del cassette y el vinilo que revisa los hitos más importantes del mundo del cine, la ciencia, la televisión, el arte y la música; una mirada retroactiva a la cultura pop de los 50 en adelante, con sus respectivas bandas sonoras. Conducido por Carolina Pulido.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/retro/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/catedralencoma.jpg" alt="Catedral en Coma" /> <h3>Catedral en <span>coma</span></h3> <h4>Miércoles, en vivo y en directo desde el Bar Catedral desde las 23.00 hrs.</h4> <p>Bandas chilenas y extranjeras agitan las noches santiaguinas en un solo escenario. Con Vicente García-Huidobro.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/catedral-en-coma/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/ticket.jpg" alt="Ticket" /> <h3><span>Ticket</span></h3> <h4>De lunes a domingo a las 9.30, 12.30, 15.30, 18.30 y 21.30 hrs. Especial de una hora domingo a las 19.00 hrs.</h4> <p>Una invitación a (re)conocer y (re)descubrir el mundo a través del 103.3. Un viaje sin escalas al lugar donde vive la música. Conduce: Carolina Pulido</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/ticket/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> <div class="programa"> <img src="/images/loop.jpg" alt="Loop" /> <h3><span>Loop</span></h3> <p>Cuando el sol se esconde, la música fluorece en Radio Horizonte. No te pierdas la selección musical más bailable de la radiofonía nacional todos los sábados en la noche.</p> <a class="btn_plomo" href="http://www.horizonte.cl/categoria/programas/loop/"><span>Ir al Programa</span></a> <div class="clear_fix"></div> </div> </div> </div> <?php include (TEMPLATEPATH . '/sidebar2.php'); ?> <?php get_footer(); ?>
-
∞ PHP Contextual Dates
<?php function contextualTime($small_ts, $large_ts=false) { if(!$large_ts) $large_ts = time(); $n = $large_ts - $small_ts; if($n <= 1) return 'less than 1 second ago'; if($n < (60)) return $n . ' seconds ago'; if($n < (60*60)) { $minutes = round($n/60); return 'about ' . $minutes . ' minute' . ($minutes > 1 ? 's' : '') . ' ago'; } if($n < (60*60*16)) { $hours = round($n/(60*60)); return 'about ' . $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ago'; } if($n < (time() - strtotime('yesterday'))) return 'yesterday'; if($n < (60*60*24)) { $hours = round($n/(60*60)); return 'about ' . $hours . ' hour' . ($hours > 1 ? 's' : '') . ' ago'; } if($n < (60*60*24*6.5)) return 'about ' . round($n/(60*60*24)) . ' days ago'; if($n < (time() - strtotime('last week'))) return 'last week'; if(round($n/(60*60*24*7)) == 1) return 'about a week ago'; if($n < (60*60*24*7*3.5)) return 'about ' . round($n/(60*60*24*7)) . ' weeks ago'; if($n < (time() - strtotime('last month'))) return 'last month'; if(round($n/(60*60*24*7*4)) == 1) return 'about a month ago'; if($n < (60*60*24*7*4*11.5)) return 'about ' . round($n/(60*60*24*7*4)) . ' months ago'; if($n < (time() - strtotime('last year'))) return 'last year'; if(round($n/(60*60*24*7*52)) == 1) return 'about a year ago'; if($n >= (60*60*24*7*4*12)) return 'about ' . round($n/(60*60*24*7*52)) . ' years ago'; return false; } ?>
-
∞ GeoIP
<?php include("geoip.inc"); $gi = geoip_open("GeoIP.dat",GEOIP_STANDARD); //dosyalarimizi include ettik $country_code = geoip_country_code_by_addr($gi, $_SERVER['REMOTE_ADDR']); echo "Your country code is: $country_code \n"; // Ulke kodunu alip yazdirdik $country_name = geoip_country_name_by_addr($gi, $_SERVER['REMOTE_ADDR']); echo "Your country name is: $country_name \n"; // Ulke adini alip yazdirdik geoip_close($gi); // veritabanini kapattik ?>
-
∞ Register autoload of classes in a folder with customizable file naming rule
<?php /** * @author dukeofgaming * @param string $path The path where the files with the classes are located (1 class per file always) * @param function $rule Callback that receives the file name as parameter and returns the class name */ function autoloadPath($path,$rule=null){ $absolute_path = dirname(__FILE__).DS.$path; $files = array_filter( scandir($absolute_path), create_function('$filename','return preg_match(\'/\.php$/\', $filename);') ); $classes = array(); if($rule === null){ function class_name($filename){ if(preg_match('/(.*)\.php$/', $filename, $matches)){ return $matches[1]; } } foreach($files as $file){ $classes[class_name($file)] = $absolute_path.DS.$file; } }else{ foreach($files as $file){ $classes[$rule($file)] = $absolute_path.DS.$file; } } spl_autoload_register( create_function('$class',' $classes = '.var_export($classes,true).'; if(array_key_exists($class, $classes)){ require_once($classes[$class]); } ') ); }
-
∞ Inserción de una fila en una BD MySQL
<?php /* Establecemos la conexión (utilizamos "@" para que PHP no muestre automáticamente, en caso de que surja, el error por pantalla). Nota: inicializar las variables. */ @mysql_connect($db_url_server, $db_username, $db_password); if (mysql_error()) // Tratar el error de conexión con el servidor. // Seleccionamos la BD. @mysql_select_db($db_name); if (mysql_error()) // Tratar el error de conexión a la base de datos. // Realizamos la inserción. @mysql_query("INSERT INTO tabla (columna1, columna2) VALUES ('valor1', 'valor2')"); // Comprabmos si hubo algún tipo de error. if (mysql_error()) // Tratar el error. if (mysql_affected_rows == 0) // Tratar el error (posiblemente debido a una restricción de integridad de la BD). // Cerramos la conexión con la BD. @mysql_close(); ?>
-
∞ how to install php extension
cd /tmp/xdebug-2.0.5/xdebug-2.0.5 phpize ./configure make cd modules cp xdebug.so /usr/local/lib/php/extensions/no-debug-non-zts-20090626/
-
∞ extract user friendly EXIF data
<? session_start(); header("Content-type: text/html; charset=UTF-8"); require_once("mysql_imge.php"); $sql_connection_for_imge = new sql_works_for_imge(); $imge_id = $_GET["imge_id"]; $filename = $sql_connection_for_imge->Fotograf_Filename_Getir($imge_id,2); $sizeStr=array("byte", "KB", "MB"); if (is_file($filename)) { $size=filesize($filename); $degree=floor(log($size, 1024)); $size=round($size/pow(1024, $degree), 2); echo "<b>Özgün Dosya Boyutu</b>: $size ".$sizeStr[$degree]."<br />\n"; $data=exif_read_data($filename); //print_r($data); $focalLength=0; $aperture=0; @eval('$focalLength=round('.$data["FocalLength"].', 2);'); @eval('$aperture=round('.$data["FNumber"].', 2);'); if (isset($data["FlashStrength"])) @eval('$flash=round('.$data["FlashStrength"].'*100);'); else if (is_numeric($data["Flash"])) $flash=floatval($data["Flash"]); else $flash=-1; if ($flash==1) $flash=100; echo "<b>Özgün Dosya Ölçüleri</b>: ".$data["COMPUTED"]["Width"]." x ".$data["COMPUTED"]["Height"]."<br />\n"; if (isset($data["DateTimeOriginal"])) echo "<b>Çekim Zaman?</b>: ".$data["DateTimeOriginal"]."<br />\n"; if (isset($data["Make"]) || isset($data["Model"])) echo "<b>Foto?raf Makinesi</b>: ".$data["Make"]." - ".$data["Model"]."<br />\n"; if (isset($data["Software"])) { echo "<b>Kullan?lan Düzenleme Yaz?l?m?</b>: ".$data["Software"]." <br />\n"; echo "<b>Düzenleme Tarihi</b>: ".$data["DateTime"]." <br />\n"; } echo "<br />\n"; if ($flash>-1) echo "<b>Çekimde fla? ".(($flash>0)?"%$flash güçte kullan?lm??":"kullan?lmam??").".</b><br />\n"; if ($focalLength) echo "<b>Özgün Odak Uzakl???</b>: $focalLength mm<br />\n"; if (isset($data["ISOSpeedRatings"])) echo "<b>I??k Hassasiyeti</b>: ISO ".$data["ISOSpeedRatings"]."<br />\n"; if (isset($data["ExposureTime"])) echo "<b>Pozlama Süresi</b>: ".$data["ExposureTime"]." saniye<br />\n"; if ($aperture) echo "<b>Diyafram Aç?kl???</b>: f$aperture<br />\n"; } //echo $outText; ?>
-
∞ PHP Debug Print
// inside PHP echo "<pre>"; var_dump($variable); echo "</pre>"; // DEBUGPRINT // inside HTML <?php echo "<pre>"; var_dump($variable); echo "</pre>"; // DEBUGPRINT ?>
-
∞ Doctrine pre-save event
<?php class Default_Model_Reservation extends Doctrine_Record { // ... /** * Empty template method to provide concrete Record classes with the possibility * to hook into the saving procedure. */ public function preSave($event) { // validate method here ... $valid = true; // If validation fails, don't allow the transaction to continue if(!$valid) $event->skipOperation = true; } // ... }



Web Database Applications with PHP & MySQL