<html>
<head>
<title>SMS Web Sender Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<h2>SMS Web Sender DEMO!</h2>
<?php
if ($action != "submit") {
?>
<i>Any username or password you enter here will not be stored
in any way (although we're not using SSL either)</i>
<p><i>Also, as you can see most of these are UK sites, not all
of them will support international numbers!</i></p>
<form method="post" action="demo.php">
<table width="600" border="0" cellspacing="0" cellpadding="4">
<tr>
<td align="right"><b>Site</b></td>
<td>
<select name="site">
<option value="txtuk.net">txtuk.net (no login)</option>
<option value="mtnsms_com">mtnsms.com</option>
<option value="lycos_co_uk">lycos.co.uk</option>
<option value="excite_co_uk">excite.co.uk</option>
<option value="uboot_com">uboot.com</option>
<option value="genie_co_uk">genie.co.uk</option>
</select>
</td>
</tr>
<tr>
<td align="right"><b>User</b></td>
<td>
<input type="text" name="user">
</td>
</tr>
<tr>
<td align="right"><b>Password</b></td>
<td>
<input type="password" name="pass">
</td>
</tr>
<tr>
<td valign="top" align="right"><b>Number</b></td>
<td>
<input type="text" name="number">
(eg. +447123123123)</td>
</tr>
<tr>
<td valign="top" align="right"><b>Message</b></td>
<td>
<textarea name="message" cols="40" rows="8"></textarea>
</td>
</tr>
<tr>
<td align="right"><b>Debug</b></td>
<td>
<input type="checkbox" name="debug" value="yes">
</td>
</tr>
<tr>
<td align="right"> </td>
<td> </td>
</tr>
<tr>
<td align="right"> </td>
<td>
<input type="hidden" name="action" value="submit">
<input type="submit" name="Submit" value="Send!">
</td>
</tr>
</table>
</form>
<?php
} else {
// contains the site details
include("sites.php");
// contains main class
include("class.sms_web_sender.php");
if (empty($number) || empty($site) || empty($message)) {
die("Make sure number, site and message are not empty");
}
if (!empty($debug) && $debug == "yes") {
$debug = true;
} else {
$debug = false;
}
// signature bit of text that's required by some
// sites like MTNSMS.com, you can leave as is
$signature = "*";
// create instance of sms web sender the one
// optional argument will determine if
// debug is turned on or not
$sms = new sms_web_sender($debug);
// add accounts
// 1st argument: username
// 2nd argument: password
// 3rd argument: server
// 4th argument: weight (this is only useful when
// shuffling the logins, the higher
// the weight, the more likely it'll
// be placed near the top of the list)
// default if left blank: 1
$sms->add_login("$user", "$pass", "$site");
// add Proxy Server details if required
// I haven't tested this myself, feature of jm_sms
//$sms->setProxyServer("proxyserver");
//$sms->setProxyPort(81);
//$sms->setProxyUser("proxyusername");
//$sms->setProxyPass("proxypassword");
//$sms->setProxy(true);
// passes the number, signature and message in an array
$result = $sms->send_sms(array("number"=>$number, "signature"=>$signature, "message"=>$message));
if ($result) {
echo "<h2>Sent!</h2>";
} else {
echo "<h2>Could not send :(</h2>";
echo "<p><a href="javascript:history.back()">Go Back</a></p>";
}
}
?>
</body>
</html>
class Import{
var $csv_fields=array(); //fields in csv to care about...
var $csv_file; //file to open
var $csv_data; //data in file
var $csv_array = array(); //array of data in file
var $csv_all_fields = array(); //all the field names in the csv file
var $csv_data_all = array(); //all the data
var $csv_data_keyed = array(); //all the data
var $tmp_array=array();
var $mysql_array=array();
var $table; //table to insert into
var $mysql_link; //database
var $instructions=array(); //sql and default settings
var $instruct_functions = array(); //function calls
var $debug=0; // show debug information - step by step messages
var $return_debug=0; // return debug information instead of echoing it
var $vals_per_insert=100; //number of values to add per insert statement of SQL
var $format="linux";
var $linebreak_char="n";
var $delimit_char = ",";
var $use_external_csv_header_file = 0;
var $external_headers="";
function Import(){
echo "n";
return(TRUE);
}
var $resetProgress=0;
function reset_class_state(){
$this->dmsg("Resetting class state", 2);
$this->csv_data_all = array();
$this->csv_fields = array();
$this->csv_data_keyed = array();
$this->tmp_array = array();
$this->mysql_array = array();
$this->instructions = array();
$this->instruct_functions = array();
$this->error_messages = "";
$this->output_sql = "";
$this->resetProgress=1;
$this->dmsg("Ready for new table and data definitions", 2);
}
function set_delimit_char($ch){
$this->delimit_char = $ch;
$this->dmsg("Set delimiter character to $ch", 2);
}
function debug($d=0,$r=0){
$this->debug=$d;
$this->return_debug=$r;
}
var $y=1;
var $error_messages="";
var $debug_level = 1;
function set_debug_level($dl=1){
$this->debug_level = $dl;
}
function dmsg($string, $dlvl=1){
global $PHP_SELF;
//debug level - 1-4 //1 is status messages only - 4 is full debugging
if($dlvl <= $this->debug_level){
if($this->debug){
if(!$this->return_debug){
if($PHP_SELF){
echo "• ".$string."<BR>n";
}else{
echo "n# $string ";
}
}else{
$this->error_messages .="# $string <BR>n";
}
$this->y++;
}
}
}
var $terminal_width=100;
var $queries_per_dot = 20;
function progress_guess(){
$calculations_to_perform = `wc -l $this->csv_file`;
$funcs_per_row = count($this->instruct_functions);
$total_function_calls = $calculations_to_perform * $funcs_per_row;
$this->queries_per_dot = round($total_function_calls / 100);
$this->dmsg("functions: $total_function_calls function calls to be made - dots at $this->queries_per_dot calls per dot", 3);
}
function set_terminal_width($w){
$this->terminal_width=$w;
}
function set_resetProgress($on=1){
$this->resetProgress=1;
}
function show_progress_meter(){
static $count=0;
static $first=1;
static $ticker=0;
//reset class state triggers this action
if($this->resetProgress){
$count=0;
$first=1;
$ticker=0;
$this->resetProgress=0;
}
if($this->debug){
if($count == 0 && $first){
echo "n#";
$first=0;
}
if($count > $this->terminal_width ){
echo "n#";
$count=0;
}
//queries per dot
if($ticker == $this->queries_per_dot){
echo ".";
$ticker=0;
$count++;
}else{
$ticker++;
}
}
}
function blank_error_messages(){
$this->error_messages = "";
}
function get_error_messages(){
return($this->error_messages);
}
function add_field_alias($csv_field, $mysql_field){
//add element to array
$this->csv_fields[$csv_field] = $mysql_field;
if(ereg("^TMP__", $mysql_field)){
$this->dmsg("added temporary field alias $csv_field --> $mysql_field", 2);
}else{
$this->dmsg("added field alias $csv_field --> $mysql_field", 2);
}
}
//only call this after calling read_csv_file - otherwise array will be missing.
//ALSO - ONLY CALL AFTER create_csv_data_array() has been called for any initial add_field_alias values.
//otherwise these fields are missing from the end array but no warnings are dipsplayed!! :(
function duplicate_field($csv_field, $mysql_field){
if(!is_array($this->mysql_array)){
echo "Run read_csv_file($file) first to create necessary arrays"; die();
}
reset($this->mysql_array);
while(list($key, $this->field) = each($this->mysql_array)){
$this->mysql_array[$key][$mysql_field] = $this->csv_data_all[$key][$csv_field];
}
reset($this->mysql_array);
$this->dmsg("duplicated field $csv_field --> $mysql_field", 1);
}
function use_external_headers($headerfile){
$this->dmsg("Reading in external csv headers from $headerfile.", 2);
if(file_exists($headerfile)){
$fd = fopen($headerfile, "r");
$this->external_headers = fread($fd, filesize($headerfile));
$this->external_headers = trim($this->external_headers);
fclose($fd);
$this->use_external_csv_header_file = 1;
}else{
$this->dmsg("Error - csv header file $headerfile does not exist!" );
die();
}
$this->dmsg("Got headers:n $this->external_headers", 2);
}
//clean file will replace commas quotes and apostrophies with safe alternatives -
//create_sql knows about the aliases and flips them back in the final sql output
function clean_file($text){
$rows = explode($this->linebreak_char,$text);
$return = "";
while(list($key,$val)=each($rows)){
//replace commas apostrophies and quotes.... these are flipped back to propper values in the create_sql function
$val = preg_replace("/,"(.*)([,])(.*)",/", ',"\1,\3",', $val, -1);
$val = str_replace("""", ""e;", $val);
$val = str_replace("'", "&appos;", $val);
$return .= $val."n";
}
return($return);
}
var $pages = array();
function find_xls_pages($file){
$command = " xlhtml -dp -asc $file";
$xls_detail = `$command`;
$this->dmsg($xls_detail);
}
//function can read xls files and create the necessary arrays from that (by using xlhtml application to craete a csv in /tmp)
function read_xls_file($file){
//use xlhtml to convert...
$this->dmsg("checking if xlhtml is installed...", 3);
$xlhtml_check = `which xlhtml 2>/dev/null`;
if(strlen($xlhtml_check)==0){
$this->dmsg("You must install xlhtml to be able to import xls files directly into csv2mysql", 1);
die("n# Script Endedn");
}
$this->dmsg("$xlhtml_check");
$tmpfilename="/tmp/TMPCSV2MYSQL.CSV";
$this->find_xls_pages($file);
$command = "$xlhtml_check -csv -xp:0 $file > $tmpfilename";
$this->dmsg("Running command $command");
exec($command);
$this->read_big_csv_file($tmpfilename);
}
var $fd;
function read_csv_file($file){
//call better function - reads in file line by line
$this->read_big_csv_file($file);
}
var $buffer;
var $csvfields;
var $csv_all_possible_fields = array();
var $csvFields = array();
function read_big_csv_file($file){
$this->dmsg("Reading data from csv file: $file", 1);
$this->csv_file = $file;
if(!$this->fd=fopen($this->csv_file, "r")){
echo "Unable to open csv filenn"; die();
}
/*
$x=0;
while(!feof($this->fd)){
$this->buffer = fgets($this->fd, 4096);
$this->csv_data .= $this->buffer;
$x++;
}
*/
//creates an array called data....
while($data = fgetcsv($this->fd, 1000, $this->delimit_char)){
$num = count($data);
$count=1;
foreach($data as $cell){
$cell = str_replace(""", ""e;", $cell);
$cell = str_replace("'", "&appos;", $cell);
$cell = str_replace(",", ",", $cell);
$this->csv_data .= $cell;
if($count < $num){
$this->csv_data .= $this->delimit_char;
$count++;
}
}
$this->csv_data .= $this->linebreak_char;
}
//die($this->csv_data);
//clean file will replace commas quotes and apostrophies with safe alternatives -
//create_sql knows about the aliases and flips them back in the final sql output
//$this->csv_data = $this->clean_file($this->csv_data);
//if we are using an external header file then add the headers to the top of the read in data for simplicities sake...
if($this->use_external_csv_header_file){
$this->csv_data = $this->external_headers."n".$this->csv_data;
}
/* create array of the field names */
$this->csvfields = explode($this->linebreak_char, $this->csv_data);
$this->csv_all_possible_fields = $this->csvfields[0];
//explode these on commas
$this->csvfields = explode($this->delimit_char, $this->csv_all_possible_fields);
foreach($this->csvfields as $field){
$this->csvFields[] = addslashes($field);
}
$this->dmsg("Finished reading data from csv file", 2);
}
var $tmp;
function set_format($format){
$this->format = $format;
if($format == "win"){
$this->linebreak_char = "rn";
$this->tmp = "\r\n";
}else{
$this->linebreak_char = "n";
$this->tmp = "\n";
}
//$this->dmsg("Line break format set to ".addslashes($this->linebreak_char));
$this->dmsg("Line break format set to $this->tmp", 2);
}
var $lines;
var $stripQuotes = 1;
function setStripQuotes($on=1){
$this->stripQuotes = $on;
}
//function will create csv_data_all array - keyed on csv field names holding values.
function create_csv_data_array(){
if(empty($this->csv_data)){
echo "No data in csv file $this->csv_filen"; die();
}
$this->lines = array();
$this->csv_data_all = array();
$this->dmsg("Started to create data array", 1);
$this->lines = explode($this->linebreak_char, $this->csv_data);
foreach($this->lines as $line){
if(!empty($line)){
$values = explode($this->delimit_char, $line);
//strip the " tags wrapping the strings...
foreach($values as $k=>$v){
if($this->stripQuotes){
$len = strlen($v)-1;
//are the first and last characters quotes?
$v = stripslashes($v);
if(ereg("^".+"$", $v)){
//if so replace them with spaces and then trim them off
//$v[0] = " ";
//$v[$len] = " ";
//$v = trim($v);
//$v = str_replace(""", "", $v);
}
}
$v = str_replace(""", "", $v);
//$values[$k] = addslashes($v);
$values[$k] = $v;
}
$this->csv_array[] = $values;
}
}
$this->csv_all_fields = $this->csv_array[0];
//skip line 1 as this is the csv definition then run through the array -
//create a new array keyed on the field names of the csv and holding the values
$count=0;
reset($this->csv_array);
while(list($foo,$el)=each($this->csv_array)){
if($count>0){
foreach($el as $key=>$val){
$this->csv_data_keyed[$this->csv_all_fields[$key]]=$val;
}
$this->csv_data_all[] = $this->csv_data_keyed;
}
$count++;
}
reset($this->csv_array);
$this->dmsg("finished creating initial data array", 2);
$this->convert_array_to_mysql_keys();
}
function convert_array_to_mysql_keys(){
reset($this->csv_data_all);
$this->dmsg("creating keyed data array", 2);
//loop through all specified fields - create new array keyed on the specified aliases.
reset($this->csv_data_all);
while(list($foo,$data)=each($this->csv_data_all)){
foreach($this->csv_fields as $key=>$field){
$this->tmp_array[$field] = $data[$key];
}
$this->mysql_array[] = $this->tmp_array;
}
reset($this->csv_data_all);
}
var $sql;
var $result;
var $tbl_structure;
var $mysqlFields = array();
//specify database table to insert into.....
function specify_table($table){
$this->table = $table;
$this->dmsg("looking at database table $table", 2);
$this->sql = "desc $this->table";
$this->result = mysql_query($this->sql, $this->mysql_link) or die(mysql_error());
while($rows = mysql_fetch_array($this->result, MYSQL_ASSOC)){
$this->tbl_structure[] = $rows;
$this->mysqlFields[] = $rows['Field'];
}
$this->dmsg("finished looking at table $table", 2);
}
//adds a static alias - if you always want field "foobar" to say "hello" then add_static_alias("foobar", "hello"); will do this for every row
function add_static_alias($field, $value){
$this->add_db_instruction($field, $value);
}
//add an sql instruction for a particular field
function add_db_instruction($field, $sql, $key=""){
$instruct['field'] = $field;
$instruct['sql'] = $sql;
$instruct['select_key'] = $key;
$this->instructions[]=$instruct;
$this->dmsg("added db instruction or static alias for $field", 2);
$this->set_resetProgress();
}
function add_function_instruction($field, $functionname, $args){
$instruct['field'] = $field;
$instruct['function_name'] = $functionname;
$instruct['args'] = $args;
$this->instruct_functions[] = $instruct;
$this->dmsg("added function instruction for $field", 2);
$this->set_resetProgress();
}
//execute function instructions
var $call;
function get_function_instruction_values(){
$this->progress_guess();
$this->dmsg("calculating values for function instructions", 2);
reset($this->mysql_array);
while(list($key,$element)=each($this->mysql_array)){
foreach($this->instruct_functions as $function){
$this->call = "$function_result = ".$function['function_name'];
//split the arguments up to calculate values...
$args = explode(",", $function['args']);
$arg_call = "";
$num_args = count($args)-1;
$count=0;
//get the arg values
foreach($args as $arg){
$arg = trim($arg);
$arg_call.=""".$element[$arg].""";
if($count<$num_args){
$arg_call .= ",";
}
$count++;
}
//add arg values to end of function
$this->call.="(".$arg_call.");";
//eval the created function call - variable function_result populated with return value
//die($this->call);
$this->dmsg("Run function instruction : $this->call", 4);
$this->show_progress_meter();
eval($this->call);
//add the value to the mysql_array
$this->mysql_array[$key][$function['field']] = $function_result;
}
}
reset($this->mysql_array);
}
//execute db instructions
var $product_id;
function get_instruction_values(){
$this->dmsg("calculating values for db instructions", 2);
reset($this->mysql_array);
while(list($key,$element)=each($this->mysql_array)){
foreach($this->instructions as $ins){
if(eregi("SELECT", $ins['sql'])){
$ins['sql'] = stripslashes($ins['sql']);
$this->select_key = $ins['select_key'] ;
//if we havent yet got a value for this...
if(!isset($this->mysql_array[$key][$ins['field']])){
$this->mysql_array[$key][$ins['field']] = $this->run_sql_query($ins['sql'], $element[$this->select_key]);
}
}else{
$this->mysql_array[$key][$ins['field']] = $ins['sql'];
}
}
$this->show_progress_meter();
}
reset($this->mysql_array);
}
var $runsql;
var $dbrows;
var $dbkey;
//not what you'd think function -- this is for evaling code - for the instructions.
//TODO rename function to a more logical name reflecting what it does better.
function run_sql_query($sql, $dbkey){
$this->runsql = stripslashes($sql);
$this->dbkey = $dbkey;
//eval the code into this->runsql -
//this makes the dbkey get populated with a value instead of being a string
eval("$this->runsql = "$this->runsql";");
$this->dmsg("running sql query..$this->runsql", 4);
//run query and return result
$this->result = mysql_query($this->runsql, $this->mysql_link) or die(mysql_error());
while($rows = mysql_fetch_array($this->result, MYSQL_ASSOC)){
$this->dbrows = $rows['result'];
$this->dmsg("$this->runsql returns: $this->dbrows", 4);
}
$this->dmsg("$this->runsql returns: $this->dbrows", 4);
return($this->dbrows);
}
//connect to the database
function db_connect($host, $user, $pass, $db){
$this->dmsg("connecting to database", 2);
$this->mysql_link = mysql_pconnect("$host", "$user", "$pass") or die(mysql_error());
if($this->mysql_link){
mysql_select_db($db);
}
}
var $specified_fields=array();
var $sql_error=0;
var $error_fields = array();
//check that all the fields required for the table are present and correct....
function validate_sql(){
$this->dmsg("validating array elements to generate sql from", 1);
reset($this->mysql_array);
//step through elements in array, foo is an unused variable.
while(list($foo,$this->element)=each($this->mysql_array)){
//dont mind a foreach here- tiny array to play with...
foreach($this->element as $this->field=>$val){
//make an array of the field names that have been specified...
if(!in_array($this->field, $this->specified_fields)){
$this->specified_fields[] = $this->field;
}
}
}
reset($this->mysql_array);
//upon errors this will be true - causing die below to spring to life...
$this->sql_error=0;
//loop through the tables fields - create array
foreach ($this->tbl_structure as $this->field){
//if the field is not in the array of specified fields and it has no default value
// and the field in question is not a primary key- moan
if(!in_array($this->field['Field'], $this->specified_fields)
&& ($this->field['Default']=="")
&& ($this->field['Key'] != 'PRI')
&& ($this->field['Extra'] != 'auto_increment')
&& ($this->field['NULL'] != "YES" ) ){
$this->dmsg( "{$this->field['Field']} has no default and you have not specified a value for this field.", 1);
$this->sql_error=1;
$this->error_fields[] = $this->field['Field'];
}else{
$this->dmsg( "{$this->field['Field']} has been verified.", 4);
}
}
#IF THIS VAR IS SET THEN SOMETHING ERRORED - REPORT THIS WITH A MESSAGE.
if($this->sql_error){
echo $this->error_messages;
$this->csv_data_all = array();
if(function_exists("render_page_head")){
echo render_page_head();
}
$erst="";
foreach($this->error_fields as $f){
$erst.="Field ".$f." has no default <BR>";
}
die("n$erst Please specify values for the missing fields please add definitions for these fields.");
}
}
var $element;
var $output_sql;
var $insert_into;
var $values;
var $all_values = array();
var $insert_line;
function create_sql($show=0){
//check all array elements are present and correct...
$this->validate_sql();
$this->dmsg("creating sql", 1);
#TODO: THIS IS NOT VERY CLEVER MEMORY MANAGEMENT - IT WOULD BE BETTER NOT TO CREATE
# EACH VALUE LINE AND SAVE IN AN ARRAY - IF THERE ARE 10,000 RECORDS THIS WILL KILL
# PHP AND THE LINUXBOX - LOCKUP COMPLETELY ALT+SYSREQ+S+U+B TO RECOVER MACHINE!!!!
# OUTPUTTING EACH LINE AS IT WAS CREATED WOULD BE MUCH LESS PROCESSOR INTENSIVE.
$this->values = "";
//loop through each row to be entered
reset($this->mysql_array);
$this->all_values = array();
while(list($foobar,$this->element)=each($this->mysql_array)){
//loop through each field name and value
$num=count($this->element)-1;
$x=0;
//blank data
$this->insert_into = "";
$this->values = "(";
foreach($this->element as $field=>$val){
//do not include temporary fields - these can be used for the function fields
if(!ereg("^TMP__", $field )){
$val = str_replace(""e;", """, $val);
$val = str_replace(",", ",", $val);
$val = str_replace("&appos;", "'", $val);
$this->insert_into .= $field." ";
$this->values .= "'$val' ";
if($x<$num){
//capture field names
$this->insert_into.=",";
$this->values .= ", ";
}
}
$x++;
}
$this->values .= ")";
$this->all_values[] = $this->values;
}
//create insert line of the sql
$this->insert_line = "REPLACE INTO $this->table ( $this->insert_into ) VALUESn ";
$this->output_sql = $this->insert_line;
$num=count($this->all_values)-1;
$x=0;
$i=1;
//loop through the list of VALUES "(bla,bla,bla)" in array adding each to sql
//when vals_per_insert is reached close sql statement and add another insert line
reset($this->all_values);
while(list($foo,$v)=each($this->all_values)){
//only add specified number of values per insert statement (vals_per_insert)
if($i== $this->vals_per_insert){
$this->output_sql .= $v.";nn".$this->insert_line;
$i=1;
}
else{
$this->output_sql .= " $v ";
if($x<$num){
$this->output_sql .= ",n";
}
}
$x++;
$i++;
}
reset($this->all_values);
reset($this->mysql_array);
//finish the sql statement
$this->output_sql .= ";";
if($show){
echo "n##########################################################n";
echo "# SQL Created by Csv2MySQL.1.1.inc n";
echo "# CyBeRtIlL LeGaCy ImPoRtAtIoN ToOl n";
echo "# ".date("D d-m-Y H:i:s", time())."n";
echo "# CSV File: $this->csv_file n";
echo "##########################################################n";
echo "nn".$this->output_sql."n";
}
else{
return($this->output_sql);
}
}
var $keys;
//just a little debugging function
function show_definitions($tbl=1, $return=0){
if(!$tbl){
ds($this->mysql_array);
#BELOW ARE JUST SOME MORE OPTIONAL DUMPS FOR DEBUGGING
//ds($this->csv_fields);
//ds($this->csv_data_all);
//ds($this->tbl_structure);
//ds($this->instructions);
//echo nl2br($this->output_sql);
}else{
if(!$return){
#DEBUG JARGON - "FOR THOSE THAT KNOW" ;)
echo "<pre>";
$d=new display($this->csv_data_all);
$d->make_layout(1);
$d=new display($this->mysql_array);
$d->make_layout(1);
#OPTIONAL DEBUG DUMPS
//$d=new display($this->instructions);
//$d->make_layout(1);
//$d=new display($this->instruct_functions);
//$d->make_layout(1);
//$d=new display($this->tbl_structure);
//$d->make_layout(1);
//echo nl2br($this->output_sql);
echo "</pre>";
}else{
#RETURN DATA TO FUNCTION CALLER...
//get the array keys
$keys = array_keys($this->mysql_array[0]);
$this->keys = $keys;
//go through keys - grab 5 rows from big array - this is to display
//to the user what they are doing while adding functions etc. - without
//taking up potentially 1000's of lines...
foreach($keys as $key){
$x=0;
while($x<5){
$sample[$x][$key] = $this->mysql_array[$x][$key];
$x++;
}
}
$d=new display($sample);
$string = $d->make_layout(0);
return("<pre>".$string."</pre>");
}
}
}
function return_csv_fields(){
return($this->csvFields);
}
function return_mysql_fields(){
return($this->mysqlFields);
}
function return_mysql_key_fields(){
//return(array_keys($this->mysql_array[0]));
return($this->keys);
}
}
?>
htmltablecreation.inc 0100400 0177776 0177776 00000013216 07561045034 015071 0 ustar nobody nogroup <?php
//////// sample array to pass to class //////////
/*
$stuff = array("0" => array(
"product_id" => "00001",
"actual_unit_cost" => "99.99",
"retail_unit_cost" => "124.99",
"quantity" => "5"
),
"1" => array(
"product_id" => "00002",
"actual_unit_cost" => "699.99",
"retail_unit_cost" => "750.00",
"quantity" => "3"
)
);
*/
class display {
var $widths = array();
var $biggest = array();
var $data = array();
var $dis;
var $divider;
var $rows;
var $emptyset=FALSE;
var $write; //echo the output
var $ascii_output;
var $finalhtmltable;
var $stylesheet;
var $borderwidth = 0;
var $bordercolor = "#000000";
var $cellpadding = 2;
var $cellspacing = 1;
function calculate_widths($array){
if(empty($array)){
//check that there is some data to display
$this->emptyset=TRUE;
return(false);
}
//loop through each row
$this->data = $array;
$x=0;
if(is_array($array)){
foreach($array as $a){
while(list($key, $val) = each($a)){
$this->widths[$x][$key] = strlen($val);
}
++$x;
}
}
$this->biggest = $this->get_longest_only();
return($this->widths);
}
function get_longest_only(){
$x=0;
$array = $this->widths;
foreach($array as $a){
while(list($key, $val) = each($a)){
if($val > $this->biggest[$key] || empty($this->biggest[$key])){
$this->biggest[$key] = $val;
}
if(strlen($key) > $this->biggest[$key]){
$this->biggest[$key] = strlen($key);
}
}
++$x;
}
return($this->biggest);
}
function make_layout($write=1){
$this->write = $write;
if($this->emptyset){
return("Empty set (0.00 hehehe)n");
}
$first="+";
while(list($key, $val) = each($this->biggest)){
$dis.="+";
for($x=0;$x<$this->biggest[$key];$x++){
$first .= "-";
}
$first.="+";
$s="|".ucwords(str_replace("_", " ",$key));
if(strlen($s)<= $this->biggest[$key]){
for($x=strlen($s);$x<=$this->biggest[$key];$x++){
$s.=" ";
}
}
$second.=$s;
}
$this->divider = $first;
$re = $first."n".$second."|n".$first."n";
$re.=$rows;
$this->rows = $this->make_body();
$re.=$this->rows;
if($this->write){
//write the output to the webpage
//echo "<pre>".$re."</pre>";
echo "".$re."";
}
$this->ascii_out = $re;
return($re);
}
function create_stylesheet($bg="ededed", $fontcol="000000", $fontsize="x-small", $bg2="444444", $fontcol2="ffffff", $fontsize2="x-small"){
$this->stylesheet = "
<STYLE type='text/css'>
<!--
.column-data { background:$bg; color:$fontcol; font-size:$fontsize; }
.table-header { background:$bg2; color:$fontcol2; font-weight:bold; text-align:center; font-size:$fontsize2 }
//-->
</style>";
}
function make_body(){
if(is_array($this->data)){
foreach($this->data as $row){
while(list($key, $val)=each($row)){
if(is_array($val)){
$out[0]=$val;
$tr = new display($out);
$tr->make_layout(0);
$tr->set_borderwidth($this->borderwidth);
$tr->set_cellpadding($this->cellpadding);
$tr->set_cellspacing($this->cellspacing);
$tr->set_bordercolor($this->bordercolor);
$val = "<Table><TR><TD> ".$tr->make_html_table()."</TD></tR></tAble>";
}
$r .= "|".$val;
if(strlen($val)<= $this->biggest[$key]){
for($x=strlen($val);$x < $this->biggest[$key]; $x++){
$r.=" ";
}
}
}
$r.="|n";
}
}
$r.=$this->divider."n";
return($r);
}
function get_divider(){
return($this->divider);
}
function display($stuff){
//constructor function
$this->widths = $this->calculate_widths($stuff);
}
function set_borderwidth($wid){
$this->borderwidth = $wid;
}
function set_cellpadding($pad){
$this->cellpadding=$pad;
}
function set_cellspacing($spac){
$this->cellspacing=$spac;
}
function set_bordercolor($col){
$this->bordercolor=$col;
}
function make_html_table(){
//converts ascii display into a proper html table
$text = $this->ascii_out;
$rows = explode("n", $text);
$x=0;
foreach($rows as $row){
$last = strlen($row);
$class = "column-data";
if($x==1){
$class = "table-header";
}
if(!ereg("^+-*", $row) && strlen($row)>0){
$row = "<TR>n <td class='$class' align='center' valign='middle'>".$row;
$row .= "</td>n</TR>n";
$row = str_replace("+", "</td><td class='$class' align='center'>", $row);
$row = str_replace("|", "</td><td class='$class' align='center'>", $row);
$row = str_replace("<td class='$class' align='center'></td>", "", $row); //remove any blanks
$row = str_replace("<td class='$class' align='center' valign='middle'></td>", "", $row); //remove any blanks
$htmloutput.=$row;
}
$x++;
}
$style = $this->stylesheet;
$htmloutput = $style."n<TABLE border='".$this->borderwidth."' bordercolor='".$this->bordercolor."' cellpadding='".$this->cellpadding."' cellspacing='".$this->cellspacing."'>n ".$htmloutput."n</TABLE>";
$this->finalhtmltable = $htmloutput;
return($htmloutput);
}
function returnhtml(){
return($this->finalhtmltable);
}
function parsehtml(){
echo $this->finalhtmltable;
}
}
//$t = new display($stuff);
//$t->make_layout(0);
//echo $t->make_html_table();
/*
$d = new display($stuff);
$d->make_layout(0);
$d->set_borderwidth(0);
$d->set_cellspacing(1);
$d->set_cellpadding(2);
$d->make_html_table();
$d->parsehtml();
*/
?>
$mymode = FTP_ASCII;
$delete = 0;
$local_dir = "/my_local_download_directory";
$host = "ftp.yahoo.de";
$remote_dir = ".";
$anonymous = 0;
$user = "myusername";
核心代码
class myftp {
var $connector;
var $getback;
function connect($ftp_server, $uname, $passwd){
// Baut grundlegende FTP Connection auf
$this->connector = @ftp_connect($ftp_server);
$this->login_result = @ftp_login($this->connector, "$uname", "$passwd");
if ((!$this->connector) || (!$this->login_result))
{
echo "FTP connection has failed! n";
echo "Attempted to connect to $ftp_server for user $uname n";
die;
} else {
echo "Connected to $ftp_server, for user $uname n";
}
}
function lastmodtime($value){
$getback = ftp_mdtm ($this->connector,$value);
return $getback;
}
function changedir($targetdir){
$getback = ftp_chdir($this->connector, $targetdir);
return $getback;
}
function getdir(){
// Liefert Directory Namen zur
class CsvFieldDump {
var $headers;
var $fieldnum;
function CsvFieldDump($infile){
if(empty($infile)){
die("You must specify a csv file to readn");
}
if(!file_exists($infile)){
die("$infile doesn't exist!n");
}
$this->infile = $infile;
$this->fieldnum = $field;
$this->createFile=0;
return(true);
}
var $headers=array();
function dump_headers($dumptoscreen=1){
$this->fd=fopen($this->infile, "r") or die("Couldn't open csv file $file");
$count=0;
while($data = fgetcsv($this->fd, 1000, ",") ){
if(!$count){
if($dumptoscreen){
print_r($data);
}
$this->headers=$data;
}
$count=1;
}
return($this->headers);
}
function dump_column($num){
$this->fieldnum = $num;
$this->fd=fopen($this->infile, "r") or die("Couldn't open csv file $file");
$count=0;
while($data = fgetcsv($this->fd, 1000, ",")){
$array=array();
if(is_array($this->fieldnum)){
foreach($this->fieldnum as $num){
$array[]=$data[$num];
}
}else{
$array = array($data[$this->fieldnum]);
}
$this->write_line($array);
}
}
var $colname;
var $headers_flip;
function dump_column_by_name($name){
if(!isset($name)){
die("No field name specified");
}
$this->colname=$name;
$this->dump_headers(0);
$this->headers_flip = array_flip($this->headers);
if(is_array($this->colname)){
foreach($this->colname as $n){
$array[] = $this->headers_flip[$n];
}
}else{
$array[] = $this->headers_flip[$this->colname];
}
$this->dump_column($array);
}
function write_line($data){
$string="";
$num=count($data);
for($x=0;$x<$num;$x++){
$string.=$data[$x];
if($x<$num-1){
$string.=",";
}
}
echo $string."n";
}
}
/////////////////////// make it think its a c program :)
if(isset($argv[1])){
$filename = $argv[count($argv)-1];
if($argv[1] == "-h"){
render_help();
die();
}else{
$b=new CsvFieldDump($filename);
}
$x=0;
foreach($argv as $opt){
switch($opt) {
case "df":
case "-df" :
$number = $argv[$x+1];
if(strstr($number, ",")){
$numbers = explode(",",$number);
}else{
$numbers = $number;
}
$b->dump_column($numbers);
break;
case "-dn":
$number = $argv[$x+1];
if(strstr($number, ",")){
$names = explode(",",$number);
}else{
$names = $number;
}
$b->dump_column_by_name($names);
break;
case "--help":
case "-h" :
render_help();
break;
case "-dh" :
$b->dump_headers();
break;
}
$x++;
}
}
function render_help(){
echo "CsvFieldDump version 0.0.0.1 by mark fate_amendable_to_change@yahoo.com
-df <n> = dumps field(s) number n - also (accepts comma delimited list for multiple field numbers eg: -df 1,2,3)
-dn <N> = dumps field(s) named N (accepts comma delimited list for multiple names eg: -dn Code,Desc)
-dh = dumps csv headers
";
}
?>
CREATE TABLE `xqbar`.`suggest` (
`id` INT NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 100 ) NOT NULL ,
`hits` INT NOT NULL DEFAULT '0',
PRIMARY KEY ( `id` )
) ENGINE = InnoDB
insert into suggest(title,hits)values('xqbar.com',100);
insert into suggest(title,hits)values('www.111cn.net',410);
insert into suggest(title,hits)values('http://xqbar.com',700);
insert into suggest(title,hits)values('mail:xqbar.com',200);
insert into suggest(title,hits)values('ftp:xqbar.com',100);
insert into suggest(title,hits)values('http://www.111cn.net',70)[/code]search.php
(关于php我也是接触不久,下面的php如果罗嗦还望高手指点)
返回的信息字符串要为 xxx1|xxx2$200|100 前后对应[code]
<?php
if($_GET["action"]!=''){
#获取用户输入的关键字
$keyword=$_GET["keyword"];
#过滤关键字
$keyword=str_replace("[","[[]",$keyword);
$keyword=str_replace("&","[&]",$keyword);
$keyword=str_replace("%","[%]",$keyword);
$keyword=str_replace("^","[^]",$keyword);
#链接数据库
$conn=mysql_connect("localhost","xqbar","xqbaradmin");
#选择数据库
@mysql_select_db("xqbar") or die('sorry');
mysql_query('set names utf-8');
#查询语句
$sql="select title,hits from suggest where title like '%".$keyword."%' order by hits desc limit 10";
$result=mysql_query($sql);
#循环得到查询结果,返回字符串
#格式为 结果1|结果2$结果1点击次数|结果2点击次数
if($result){
$i=1;$title='';$hits='';
while($row=mysql_fetch_array($result,MYSQL_BOTH))
{
$title=$title.$row['title'];
$hits=$hits.$row['hits'];
if($i<mysql_num_rows($result))
{
$title=$title."|";
$hits=$hits."|";
}
$i++;
}
}
mysql_close();
}
?>
<?php echo $title.'js代码[code]
引入prototye.js有朋友说这个库太大,或者把,不习惯的朋友可以使用jquery.js框架或者直接创建ajax对象,这个我就不想说了,这里直接引用prototye.js框架
<script type="text/javascript"" width=100% src="prototype.js"></script>
创建层和显示查询结果的js代码
<script type="text/javascript">
//定义变量lastindex 表示为鼠标在查询结果上滑动所在位置,初始为-1
var lastindex=-1;
//定义变量flag 表示是否根据用户输入的关键字进行ajax查询,flase为允许查询 true为禁止查询
var flag=false;
//返回的查询结果生成的数组长度
var listlength=0;
//创建自定字符串,优化效率
function StringBuffer(){this.data=[];}
//赋值
StringBuffer.prototype.append=function(){this.data.push(arguments[0]);return this;}
//输出
StringBuffer.prototype.tostring=function(){return this.data.join("");}
//去掉字符串两边空格
String.prototype.Trim = function(){return this.replace(/(^s*)|(s*$)/g, "");}
//隐藏函数 主要是隐藏显示的提示下拉层和iframe,关于iframe下面在说其作用
function hiddensearch()
{
$('rlist').style.display="none";
$('rFrame').style.display="none";
}
//显示函数 主要是显示的提示下拉层和iframe 参数num,根据该参数控制要显示提示层和iframe的高度
function showsearch(num)
{
$('rlist').style.display='';
$('rFrame').style.display='';
//这里我定义每个返回查询结果的提示高度为20px,其中提示层总高度又加了num,是因为我在定义样式时使用了padding一个像素
$('rlist').style.height=num*20+num+'px';
//同样定位iframe的高度
$('rFrame').style.height=num*20+num+'px';
}
//返回文本输入框的坐标函数,参数element为要返回的对象,参数offset可选为offsetLeft|offsetTop 分别表示为该对象距离左窗口上角的绝对位置
//利用这个函数可以定位我们要显示的提示层位置,使提示层正确的显示在文本输入框下面
function getposition(element,offset)
{
var c=0;
while(element)
{
c+=element[offset];
element=element.offsetParent
}
return c;
}
//创建提示层函数 包括提示层和为了避免在文本输入框下面出现select下拉选框时我们的提示层不能再select之上的iframe
//可以理解为当文本输入框下有select下拉选框时从底向上依次为 select下拉选框-iframe-提示层
function createlist()
{
//创建提示层
var listDiv=document.createElement("div");
//提示层id
listDiv.id="rlist";
listDiv.style.zIndex="2";
listDiv.style.position="absolute";
listDiv.style.border="solid 1px #000000";
listDiv.style.backgroundColor="#FFFFFF";
listDiv.style.display="none";
listDiv.style.width=$('keyword').clientWidth+"px";
listDiv.style.left=getposition($('keyword'),'offsetLeft')+1.5+"px";
listDiv.style.top =(getposition($('keyword'),'offsetTop')+$('keyword').clientHeight +3)+"px";
var listFrame=document.createElement("iframe");
listFrame.id="rFrame";
listFrame.style.zIndex="1";
listFrame.style.position="absolute";
listFrame.style.border="0";
listFrame.style.display="none";
listFrame.style.width=$('keyword').clientWidth+"px";
listFrame.style.left=getposition($('keyword'),'offsetLeft')+1+"px";
listFrame.style.top =(getposition($('keyword'),'offsetTop')+$('keyword').clientHeight +3)+"px";
document.body.appendChild(listDiv);
document.body.appendChild(listFrame);
}
function setstyle(element,classname)
{
switch (classname)
{
case 'm':
element.style.fontSize="12px";
element.style.fontFamily="arial,sans-serif";
element.style.backgroundColor="#3366cc";
element.style.color="black";
element.style.width=$('keyword').clientWidth-2+"px";
element.style.height="20px";
element.style.padding="1px 0px 0px 2px";
if(element.displaySpan)element.displaySpan.style.color="white"
break;
case 'd':
element.style.fontSize="12px";
element.style.fontFamily="arial,sans-serif";
element.style.backgroundColor="white";
element.style.color="black";
element.style.width=$('keyword').clientWidth-2+"px";
element.style.height="20px";
element.style.padding="1px 0px 0px 2px";
if(element.displaySpan)element.displaySpan.style.color="green"
break;
case 't':
element.style.width="80%";
if(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)element.style.cssFloat="left";
else element.style.styleFloat="left";
element.style.whiteSpace="nowrap";
element.style.overflow="hidden";
element.style.textOverflow="ellipsis";
element.style.fontSize="12px";
element.style.textAlign="left";
break;
case 'h':
element.style.width="20%";
if(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)element.style.cssFloat="right";
else element.style.styleFloat="right";
element.style.textAlign="right";
element.style.color="green";
break;
}
}
function focusitem(index)
{
if($('item'+lastindex)!=null)setstyle($('item'+lastindex),'d');
if($('item'+index)!=null)
{
setstyle($('item'+index), 'm');
lastindex=index;
}
else $("keyword").focus();
}
function searchclick(index)
{
$("keyword").value=$('title'+index).innerHTML;
flag=true;
}
function searchkeydown(e)
{
if($('rlist').innerHTML=='')return;
var keycode=(window.navigator.appName=="Microsoft Internet Explorer")?event.keyCode:e.which;
//down
if(keycode==40)
{
if(lastindex==-1||lastindex==listlength-1)
{
focusitem(0);
searchclick(0);
}
else{
focusitem(lastindex+1);
searchclick(lastindex+1);
}
}
if(keycode==38)
{
if(lastindex==-1)
{
focusitem(0);
searchclick(0);
}
else{
focusitem(lastindex-1);
searchclick(lastindex-1);
}
}
if(keycode==13)
{
focusitem(lastindex);
$("keyword").value=$('title'+lastindex).innerText;
}
if(keycode==46||keycode==8){flag=false;ajaxsearch($F('keyword').substring(0,$F('keyword').length-1).Trim());}
}
function showresult(xmlhttp)
{
var result=unescape(xmlhttp.responseText);
if(result!=''){
var resultstring=new StringBuffer();
var title=result.split('搜索框[code]
<form id="form1" name="form1" method="post" action="">
<b>输入搜索关键字</b>
<input name="keyword" type="text" class="inputblue" id="keyword" maxlength="20" style="width:300px;" />
</form>[/code]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6.$hits;?>[/code]js代码[code]
引入prototye.js有朋友说这个库太大,或者把,不习惯的朋友可以使用jquery.js框架或者直接创建ajax对象,这个我就不想说了,这里直接引用prototye.js框架
<script type="text/javascript"" width=100% src="prototype.js"></script>
创建层和显示查询结果的js代码
<script type="text/javascript">
//定义变量lastindex 表示为鼠标在查询结果上滑动所在位置,初始为-1
var lastindex=-1;
//定义变量flag 表示是否根据用户输入的关键字进行ajax查询,flase为允许查询 true为禁止查询
var flag=false;
//返回的查询结果生成的数组长度
var listlength=0;
//创建自定字符串,优化效率
function StringBuffer(){this.data=[];}
//赋值
StringBuffer.prototype.append=function(){this.data.push(arguments[0]);return this;}
//输出
StringBuffer.prototype.tostring=function(){return this.data.join("");}
//去掉字符串两边空格
String.prototype.Trim = function(){return this.replace(/(^s*)|(s*$)/g, "");}
//隐藏函数 主要是隐藏显示的提示下拉层和iframe,关于iframe下面在说其作用
function hiddensearch()
{
$('rlist').style.display="none";
$('rFrame').style.display="none";
}
//显示函数 主要是显示的提示下拉层和iframe 参数num,根据该参数控制要显示提示层和iframe的高度
function showsearch(num)
{
$('rlist').style.display='';
$('rFrame').style.display='';
//这里我定义每个返回查询结果的提示高度为20px,其中提示层总高度又加了num,是因为我在定义样式时使用了padding一个像素
$('rlist').style.height=num*20+num+'px';
//同样定位iframe的高度
$('rFrame').style.height=num*20+num+'px';
}
//返回文本输入框的坐标函数,参数element为要返回的对象,参数offset可选为offsetLeft|offsetTop 分别表示为该对象距离左窗口上角的绝对位置
//利用这个函数可以定位我们要显示的提示层位置,使提示层正确的显示在文本输入框下面
function getposition(element,offset)
{
var c=0;
while(element)
{
c+=element[offset];
element=element.offsetParent
}
return c;
}
//创建提示层函数 包括提示层和为了避免在文本输入框下面出现select下拉选框时我们的提示层不能再select之上的iframe
//可以理解为当文本输入框下有select下拉选框时从底向上依次为 select下拉选框-iframe-提示层
function createlist()
{
//创建提示层
var listDiv=document.createElement("div");
//提示层id
listDiv.id="rlist";
listDiv.style.zIndex="2";
listDiv.style.position="absolute";
listDiv.style.border="solid 1px #000000";
listDiv.style.backgroundColor="#FFFFFF";
listDiv.style.display="none";
listDiv.style.width=$('keyword').clientWidth+"px";
listDiv.style.left=getposition($('keyword'),'offsetLeft')+1.5+"px";
listDiv.style.top =(getposition($('keyword'),'offsetTop')+$('keyword').clientHeight +3)+"px";
var listFrame=document.createElement("iframe");
listFrame.id="rFrame";
listFrame.style.zIndex="1";
listFrame.style.position="absolute";
listFrame.style.border="0";
listFrame.style.display="none";
listFrame.style.width=$('keyword').clientWidth+"px";
listFrame.style.left=getposition($('keyword'),'offsetLeft')+1+"px";
listFrame.style.top =(getposition($('keyword'),'offsetTop')+$('keyword').clientHeight +3)+"px";
document.body.appendChild(listDiv);
document.body.appendChild(listFrame);
}
function setstyle(element,classname)
{
switch (classname)
{
case 'm':
element.style.fontSize="12px";
element.style.fontFamily="arial,sans-serif";
element.style.backgroundColor="#3366cc";
element.style.color="black";
element.style.width=$('keyword').clientWidth-2+"px";
element.style.height="20px";
element.style.padding="1px 0px 0px 2px";
if(element.displaySpan)element.displaySpan.style.color="white"
break;
case 'd':
element.style.fontSize="12px";
element.style.fontFamily="arial,sans-serif";
element.style.backgroundColor="white";
element.style.color="black";
element.style.width=$('keyword').clientWidth-2+"px";
element.style.height="20px";
element.style.padding="1px 0px 0px 2px";
if(element.displaySpan)element.displaySpan.style.color="green"
break;
case 't':
element.style.width="80%";
if(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)element.style.cssFloat="left";
else element.style.styleFloat="left";
element.style.whiteSpace="nowrap";
element.style.overflow="hidden";
element.style.textOverflow="ellipsis";
element.style.fontSize="12px";
element.style.textAlign="left";
break;
case 'h':
element.style.width="20%";
if(window.navigator.userAgent.toLowerCase().indexOf("firefox")!=-1)element.style.cssFloat="right";
else element.style.styleFloat="right";
element.style.textAlign="right";
element.style.color="green";
break;
}
}
function focusitem(index)
{
if($('item'+lastindex)!=null)setstyle($('item'+lastindex),'d');
if($('item'+index)!=null)
{
setstyle($('item'+index), 'm');
lastindex=index;
}
else $("keyword").focus();
}
function searchclick(index)
{
$("keyword").value=$('title'+index).innerHTML;
flag=true;
}
function searchkeydown(e)
{
if($('rlist').innerHTML=='')return;
var keycode=(window.navigator.appName=="Microsoft Internet Explorer")?event.keyCode:e.which;
//down
if(keycode==40)
{
if(lastindex==-1||lastindex==listlength-1)
{
focusitem(0);
searchclick(0);
}
else{
focusitem(lastindex+1);
searchclick(lastindex+1);
}
}
if(keycode==38)
{
if(lastindex==-1)
{
focusitem(0);
searchclick(0);
}
else{
focusitem(lastindex-1);
searchclick(lastindex-1);
}
}
if(keycode==13)
{
focusitem(lastindex);
$("keyword").value=$('title'+lastindex).innerText;
}
if(keycode==46||keycode==8){flag=false;ajaxsearch($F('keyword').substring(0,$F('keyword').length-1).Trim());}
}
function showresult(xmlhttp)
{
var result=unescape(xmlhttp.responseText);
if(result!=''){
var resultstring=new StringBuffer();
var title=result.split('搜索框[code]
<form id="form1" name="form1" method="post" action="">
<b>输入搜索关键字</b>
<input name="keyword" type="text" class="inputblue" id="keyword" maxlength="20" style="width:300px;" />
</form>[/code]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[0];
var hits=result.split('搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6.$hits;?>[/code]js代码[ DISCUZ_CODE_2 ]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[1];
for(var i=0;i<title.split('|').length;i++)
{
resultstring.append('<div id="item'+i+'">');
resultstring.append('<span id=title'+i+'>');
resultstring.append(title.split('|'));
resultstring.append('</span>');
resultstring.append('<span id=hits'+i+'>');
resultstring.append(hits.split('|'));
resultstring.append('</span>');
resultstring.append('</div>');
}
$('rlist').innerHTML=resultstring.tostring();
for(var j=0;j<title.split('|').length;j++)
{
setstyle($('item'+j),'d');
$('item'+j).displaySpan=$('hits'+j);
setstyle($('title'+j),'t');
setstyle($('hits'+j),'h');
}
showsearch(title.split('|').length);
listlength=title.split('|').length;
lastindex=-1;
}
else hiddensearch();
}
function ajaxsearch(value)
{
new Ajax.Request('search.php',{method:"get",parameters:"action=do&keyword="+escape(value),onComplete:showresult});
}
function main()
{
$('keyword').className=$('keyword').className=='inputblue'?'inputfocus':'inputblue';
if($F('keyword').Trim()=='')hiddensearch();
else
{
if($F('keyword')!=''&&flag==false)ajaxsearch($F('keyword').Trim());
if(listlength!=0)$('keyword').onkeydown=searchkeydown;
else hiddensearch();
}
}
function oninit()
{
$('keyword').autocomplete="off";
$('keyword').onfocus=main;
$('keyword').onkeyup=main;
$('keyword').onblur=hiddensearch;
createlist();
}
Event.observe(window,'load',oninit);
</script>[/code]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6.$hits;?>[/code]js代码[ DISCUZ_CODE_2 ]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[0];
var hits=result.split('搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[0];
var hits=result.split('搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6.$hits;?>[/code]js代码[ DISCUZ_CODE_2 ]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[1];
for(var i=0;i<title.split('|').length;i++)
{
resultstring.append('<div id="item'+i+'">');
resultstring.append('<span id=title'+i+'>');
resultstring.append(title.split('|'));
resultstring.append('</span>');
resultstring.append('<span id=hits'+i+'>');
resultstring.append(hits.split('|'));
resultstring.append('</span>');
resultstring.append('</div>');
}
$('rlist').innerHTML=resultstring.tostring();
for(var j=0;j<title.split('|').length;j++)
{
setstyle($('item'+j),'d');
$('item'+j).displaySpan=$('hits'+j);
setstyle($('title'+j),'t');
setstyle($('hits'+j),'h');
}
showsearch(title.split('|').length);
listlength=title.split('|').length;
lastindex=-1;
}
else hiddensearch();
}
function ajaxsearch(value)
{
new Ajax.Request('search.php',{method:"get",parameters:"action=do&keyword="+escape(value),onComplete:showresult});
}
function main()
{
$('keyword').className=$('keyword').className=='inputblue'?'inputfocus':'inputblue';
if($F('keyword').Trim()=='')hiddensearch();
else
{
if($F('keyword')!=''&&flag==false)ajaxsearch($F('keyword').Trim());
if(listlength!=0)$('keyword').onkeydown=searchkeydown;
else hiddensearch();
}
}
function oninit()
{
$('keyword').autocomplete="off";
$('keyword').onfocus=main;
$('keyword').onkeyup=main;
$('keyword').onblur=hiddensearch;
createlist();
}
Event.observe(window,'load',oninit);
</script>[/code]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6.$hits;?>[/code]js代码[ DISCUZ_CODE_2 ]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[1];
for(var i=0;i<title.split('|').length;i++)
{
resultstring.append('<div id="item'+i+'">');
resultstring.append('<span id=title'+i+'>');
resultstring.append(title.split('|'));
resultstring.append('</span>');
resultstring.append('<span id=hits'+i+'>');
resultstring.append(hits.split('|'));
resultstring.append('</span>');
resultstring.append('</div>');
}
$('rlist').innerHTML=resultstring.tostring();
for(var j=0;j<title.split('|').length;j++)
{
setstyle($('item'+j),'d');
$('item'+j).displaySpan=$('hits'+j);
setstyle($('title'+j),'t');
setstyle($('hits'+j),'h');
}
showsearch(title.split('|').length);
listlength=title.split('|').length;
lastindex=-1;
}
else hiddensearch();
}
function ajaxsearch(value)
{
new Ajax.Request('search.php',{method:"get",parameters:"action=do&keyword="+escape(value),onComplete:showresult});
}
function main()
{
$('keyword').className=$('keyword').className=='inputblue'?'inputfocus':'inputblue';
if($F('keyword').Trim()=='')hiddensearch();
else
{
if($F('keyword')!=''&&flag==false)ajaxsearch($F('keyword').Trim());
if(listlength!=0)$('keyword').onkeydown=searchkeydown;
else hiddensearch();
}
}
function oninit()
{
$('keyword').autocomplete="off";
$('keyword').onfocus=main;
$('keyword').onkeyup=main;
$('keyword').onblur=hiddensearch;
createlist();
}
Event.observe(window,'load',oninit);
</script>[/code]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[0];
var hits=result.split('搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6.$hits;?>[/code]js代码[ DISCUZ_CODE_2 ]搜索框[ DISCUZ_CODE_3 ]就这些,没加说明,有时间再加吧,加的话 可以去我的博客看看http://www.111cn.net/read.php?6)[1];
for(var i=0;i<title.split('|').length;i++)
{
resultstring.append('<div id="item'+i+'">');
resultstring.append('<span id=title'+i+'>');
resultstring.append(title.split('|'));
resultstring.append('</span>');
resultstring.append('<span id=hits'+i+'>');
resultstring.append(hits.split('|'));
resultstring.append('</span>');
resultstring.append('</div>');
}
$('rlist').innerHTML=resultstring.tostring();
for(var j=0;j<title.split('|').length;j++)
{
setstyle($('item'+j),'d');
$('item'+j).displaySpan=$('hits'+j);
setstyle($('title'+j),'t');
setstyle($('hits'+j),'h');
}
showsearch(title.split('|').length);
listlength=title.split('|').length;
lastindex=-1;
}
else hiddensearch();
}
function ajaxsearch(value)
{
new Ajax.Request('search.php',{method:"get",parameters:"action=do&keyword="+escape(value),onComplete:showresult});
}
function main()
{
$('keyword').className=$('keyword').className=='inputblue'?'inputfocus':'inputblue';
if($F('keyword').Trim()=='')hiddensearch();
else
{
if($F('keyword')!=''&&flag==false)ajaxsearch($F('keyword').Trim());
if(listlength!=0)$('keyword').onkeydown=searchkeydown;
else hiddensearch();
}
}
function oninit()
{
$('keyword').autocomplete="off";
$('keyword').onfocus=main;
$('keyword').onkeyup=main;
$('keyword').onblur=hiddensearch;
createlist();
}
Event.observe(window,'load',oninit);
</script>[