XMPPConnection xmpp = new XMPPConnection("gmail.com");
try {
xmpp.connect();
xmpp.login("user", "pass");
Vector<String> users = new Vector<String>();
Roster roster = xmpp.getRoster();
for(RosterEntry entry:roster.getEntries()){
Roster roster1 = xmpp.getRoster();
Collection entries = roster1.getEntries();
for(RosterEntry r:entries){
users.add( r.getUser() );
}
}
return (String[])users.toArray();
} catch (XMPPException e) {
e.printStackTrace();
}
return null; //
define( 'STATE_QUOTE_OPEN', 1 );
define( 'STATE_QUOTE_CLOSE', 2 );
define( 'STATE_LQUOTE_OPEN', 3 );
define( 'STATE_LQUOTE_CLOSE', 4 );
define( 'STATE_BRACE_OPEN', 5 );
define( 'STATE_BRACE_CLOSE', 6 );
function parse( $str, $repl ){
$state = 0; // default
$buf = '';
$brace_pos_start = 0;
for( $i = 0; $i < strlen( $str ); $i++ ){
switch( $str[$i] ){
case '"':
$state = $state == STATE_QUOTE_OPEN ? STATE_QUOTE_CLOSE : STATE_QUOTE_OPEN;
break;
case "'":
$state = $state == STATE_LQUOTE_OPEN ? STATE_LQUOTE_CLOSE : STATE_LQUOTE_OPEN;
break;
case '{':
if( $state != STATE_QUOTE_OPEN && $state != STATE_LQUOTE_OPEN ){
$state = STATE_BRACE_OPEN;
$buf = '';
$brace_pos_start = $i;
}
break;
case '}':
if( $state == STATE_BRACE_OPEN ){
$state = STATE_BRACE_CLOSE;
$str = substr_replace( $str, $repl[ $buf ], $brace_pos_start, $i - $brace_pos_start + 1 );
$i = $brace_pos_start + strlen( $repl[ $buf ] );
}
break;
default:
if( $state == STATE_BRACE_OPEN ) $buf .= $str[$i];
break;
}
}
return $str;
}
echo parse( 'SELECT * FROM {table} WHERE name="123 {qwerty} 789" AND id IN (SELECT id FROM {other_table})',
array( 'table' => 'tbl1', 'other_table' => 'tbl2' ) );
<?php
function translate($rus,$eng)
{
$lang = $_GET['lang'];
$cookie_fresh = mktime(23,59,59,12,31,date('Y')+1);
$c_lang = isset( $_COOKIE['lang'] ) ? $_COOKIE['lang'] : 'ru';
if ( $lang == 'eng' && $c_lang != $lang )
{
setcookie('lang', 'eng', $cookie_fresh);
header("Location: ./");
exit();
}
if ($c_lang != $lang && ($lang == 'rus' or !isset($_COOKIE['lang'])))
{
setcookie('lang', 'rus', $cookie_fresh);
header("Location: ./");
exit();
}
switch( $_COOKIE['lang'] ){
case 'eng':
echo $eng;
break;
case 'ru':
echo $rus;
break;
}
return true;
}
?>
UseCanonicalName Off
VirtualDocumentRoot /home/%0/web/html/
if( USER_AGENT == 'Firefox' ){
tpl.addPath(tplPath + 'firefox');
}else if( USER_AGENT == 'IE7' ){
tpl.addPath(tplPath + 'ie7');
}
templates
ie7
style.css
firefox
style.css
index.html
style.css
Random r = new Random();
Vector< Vector<Integer> > nums = new Vector<Vector<Integer>>();
long t = System.currentTimeMillis();
System.out.println( "Starting generate example" );
for( int column = 0; column < 20 ; column++ ){
Vector<Integer> rows = new Vector<Integer>();
for( int row = 0; row < 1000; row++ ){
rows.add( r.nextInt() );
}
nums.add(rows);
}
long t2 = System.currentTimeMillis();
System.out.println( "generate example finished at " + ( t2 - t ) );
System.out.println( "Starting getAnswer" );
System.out.println( p.getAnswer2(nums) );
long t3 = System.currentTimeMillis();
System.out.println( "getAnswer finished at " + ( t3 - t2) );
Starting generate example
generate example finished at 24
Starting getAnswer
13
getAnswer finished at 385