command_status_1=$command_status_1"; if($command_status_1=='1' || $command_status_1=='2')//1--待执行状态 2--在执行状态 { echo "
$strCommandBeExecute!"; return(-1); } else//共享内存可写 { if($DEBUG) echo "
file_name=$file_name"; if($DEBUG) echo "
ip=$ip"; if($DEBUG) echo "
length=$length"; $set_result_1=tftp_set_shm(1,0); $set_result_2=tftp_set_shm($length,1); $set_result_3=tftp_set_shm($ip,5); $set_result_4=tftp_set_shm($file_name,20); if($DEBUG) echo "
set_result_1=$set_result_1"; if($DEBUG) echo "
set_result_2=$set_result_2"; if($DEBUG) echo "
set_result_3=$set_result_3"; if($DEBUG) echo "
set_result_4=$set_result_4"; $scan_1=0;//待执行状态标识 $scan_2=0;//已处理记录标识 $pre_records=0;//上次处理记录数 if($set_result_1>0 && $set_result_2>0 && $set_result_3>0 && $set_result_4>0)//设置共享内存成功 { do{ sleep(2); $command_status_2=tftp_get_shm(0,1); if($DEBUG) echo "
command_status_2=$command_status_2"; if($command_status_2=='1') { $scan_1++; if($DEBUG) echo "
scan_1=$scan_1"; if($scan_1>1)//如果连续4秒处于该状态,异常退出 { $prompt_name=$strMemoryWaitStatus; echo "
$prompt_name"; break; } } elseif($command_status_2=='2') { $the_records=tftp_get_shm(60,4); if($DEBUG) echo "
the_records=$the_records"; if($DEBUG) echo "
pre_records=$pre_records"; if($pre_records==$the_records) { $scan_2++; //echo "
scan_2=$scan_2"; } else { $pre_records=$the_records;//把本次已处理记录数赋给上次记录数 } if($scan_2>1) { $prompt_name=$strDaemonRecordNoChange; echo "
$prompt_name"; break;//如果连续4秒已处理记录数不变,异常退出 } } else { $describe=tftp_get_shm(64,36); echo "
$describe"; if($command_status_2=='4') { $prompt_name="$strDownloadFailureToSwitch"; echo "
$prompt_name"; } elseif($command_status_2=='3') { $prompt_name="$strDownloadSuccessToSwitch"; echo "
$prompt_name"; $suc_sign=1; } } }while($command_status_2=='1' || $command_status_2=='2'); $set_result=tftp_set_shm(0,0); if($suc_sign>0){ return(1); }else{ return(-1); } } else { echo "
$strSetMemoryFailure"; $set_result=tftp_set_shm(0,0); return(-1); } }//end else共享内存可写 } //**************************************************************** // 函数2 tftp_set_shm($str,$offset) // // 功能说明:该函数用于tftp通知后台程序的共享内存设定. // // 调用关系: // // 变量说明:$str 写入共享内存中的字串 // $offset 从开辟的共享内存块中的第几位开始写 // (0:发送一般命令,1:发送uninstall命令) // // 返回值:操作类型的值(正:成功,负:失败) // // // //修改注释: //NO.1 //姓名: //时间: //修改说明: // //---------------------------------------------------------- function tftp_set_shm($str,$offset) { //PHP_C_SHM_KEY 0x6AE00000 //PHP_C_SHM_PERM 0666 //PHP_C_SEM_KEY 440 //PHP_C_SEM_PERM 0666 //size 10*100 bytes define("Semaphore_Key",440,1); define("SharedMem_Key",0x6AE00000,1); define("SharedMem_Size",1000,1); //共享内存大小 $SharedMemID = @shmop_open(SharedMem_Key,"c",0666,SharedMem_Size); $sharemen_sign = 0; //将指定变量存入共享内存 if(shmop_write($SharedMemID,$str,$offset)) $sharemen_sign++; if($sharemen_sign == 1){ return(1); }else{ return(-1); } } //**************************************************************** // 函数3 tftp_get_shm($offset,$count) // // 功能说明:该函数用于tftp通知后台程序的共享内存设定. // // 调用关系: // // 变量说明: $offset 从开辟的共享内存块中的第几位开始读 // $count 读多少位 // // 返回值:操作类型的值(正:读出的值,负:失败) // // 作者: // //修改注释: //NO.1 //姓名: //时间: //修改说明: // //---------------------------------------------------------- function tftp_get_shm($offset,$count) { //PHP_C_SHM_KEY 0x6AE00000 //PHP_C_SHM_PERM 0666 //PHP_C_SEM_KEY 440 //PHP_C_SEM_PERM 0666 //size 10*100 bytes define("Semaphore_Key",440,1); define("SharedMem_Key",0x6AE00000,1); define("SharedMem_Size",1000,1); //共享内存大小 $SharedMemID = @shmop_open(SharedMem_Key,"c",0666,SharedMem_Size); //将指定共享内存存入变量 $Read_str= shmop_read($SharedMemID,$offset,$count); return($Read_str); } if($action1){ //if files have been uploaded, process them $DEBUG=0; ?> "; echo ""; echo ""; echo "Advanced > Software Upgrade >Tftp"; echo ""; echo " "; echo ""; echo ""; echo ""; adjust_title_tail(); adjust_content_head(); echo "
"; ?>



path1=$path1"; $source = $file1; if($DEBUG) echo "
source=$source"; $source_name = $file1_name; if($DEBUG) echo "
source_name=$source_name"; echo "
FileName:$source_name"; echo "
IPAddress:$ip"; echo "
MessageLength:$length BYTES
"; $log_name="TFTP ".$strFileUpload; if(($source <> "none")&&($source <> "")){ // see if the file exists; non-existing file has name of "none" if($error1 <> 1){ // no need to copy a file if directory not write-enabled $dest = $path1."/".$source_name; // append file name to our path if($DEBUG) echo "
dest=$dest"; if(copy($source,$dest)){ // copy the file from the temp directory to the upload directory, and test for success $newname = "../../../tftp/"; $newname .=$source_name; if(copy($dest,$newname)) { insertLog("$log_name"); echo "
$strFileUploadSuccessToServer
\n"; $set_result=send_shm_tftp($source_name,$ip,$length); } else { echo "
$strUploadFailure
\n"; insertLog("$log_name"); } unlink ($dest); }//end if(copy($source,$dest)) else { echo "$strUploadDirectoryNotWriteEnabled\n"; // you need to write-enable the upload directory $error1 = 1; // set flag insertLog("$log_name"); } }//if($error1 <> 1) unlink($source); // delete the file from the temp directory }else{//if(($source <> "none")&&($source <> "")) echo "
source=none!
"; } ?>

"; echo ""; echo ""; echo "Advanced > Software Upgrade >Tftp"; echo ""; echo ""; //showHelp($helpId); echo ""; echo ""; echo ""; adjust_title_tail(); adjust_content_head(); echo "
"; ?>

">
Bytes
"; ?>  

Remarks:

Browse to 8K E1 Card software in the File field.
Input IP address of LAN module of 8K E1 Card in the IP field.
Set 128 bytes for the Message length option.