首页 > PHP教程

php mysql显示数据表字段 SHOW FIELDS

php mysql显示数据表字段 SHOW FIELDS

$mydbname=RepPostVar($_GET['mydbname']);
$mytbname=RepPostVar($_GET['mytbname']);
if(empty($mydbname)||empty($mytbname))
{
 printerror("ErrorUrl","history.go(-1)");
}
$form=$_GET['form'];
if(empty($form))
{
 $form='ebakchangetb';
}
$usql=$empire->query("use `$mydbname`");
$sql=$empire->query("SHOW FIELDS FROM `".$mytbname."`");

阅读全文

fckeditor具有查看/重命名/删除功能

第一步 找到这个文件 /fckeditoreditorfilemanagerbrowserdefaultfrmresourceslist.html

将已经存在的代码修改为:

oListManager.GetFolderRowHtml = function( folderName, folderPath )
{
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFolder('' + ProtectPath( folderPath ) + '');return false;"><img alt="" src="images/Folder.gif" width="16" height="16" border="0"> ' ;

var rLink = '<a href="#" title="Rename Folder" onclick="RenameFolder('' + folderName + '');return false;"><img src="images/rename.gif" width="16" height="16" border="0" alt="Rename Folder" title="Rename Folder"></a>' ;

var dLink = '<a href="#" title="Delete Folder" onclick="DeleteFolder('' + folderName + '');return false;"><img src="images/delete.gif" width="16" height="16" border="0" alt="Delete Folder" title="Delete Folder">' ;

    var ssLink =  rLink + dLink;
return '<tr>' +
   '<td width="16"></td><td nowrap>&nbsp;' +
    sLink +
    folderName +
    '</a></td><td align="right" nowrap>' + ssLink +
  '</td></tr>' ;
}

oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
{
var sIcon = oIcons.GetIcon( fileName ) ;

// Build the link to view the file.
var sLink = '<a href="#" onclick="OpenFile('' + ProtectPath( fileUrl ) + '');return false;"><img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"> ' ;

var vLink = '<a href="' + ProtectPath( fileUrl ) + '" target="_blank"" title="View file"><img src="images/view.gif" width="16" height="16" border="0" alt="View File" title="View File"></a>' ;

var rLink = '<a href="#" title="Rename file" onclick="RenameFile('' + fileName + '');return false;"><img src="images/rename.gif" width="16" height="16" border="0" alt="Rename File" title="Rename File"></a>' ;

var dLink = '<a href="#" title="Delete file" onclick="DeleteFile('' + fileName + '');return false;"><img src="images/delete.gif" width="16" height="16" border="0" alt="Delete File" title="Delete File"></a>' ;


// Get the file icon.
    var ssLink =  vLink + rLink + dLink;
return '<tr>' +
   '<td width="16"></td><td>&nbsp;' +
    sLink +
    fileName +
    '</a>' +
   '</td><td align="right" nowrap>&nbsp;' +
    fileSize +
    ' KB' + ssLink +
  '</td></tr>' ;
}

function OpenFolder( folderPath )
{
// Load the resources list for this folder.
window.parent.frames['frmFolders'].LoadFolders( (folderPath) ) ;
}

function OpenFile( fileUrl )
{
window.top.opener.SetUrl( fileUrl.replace( '#', '%23' ) ) ;
window.top.close() ;
window.top.opener.focus() ;
}

function DeleteFolder( folderUrl )
{
if ( !confirm( 'Do you really delete the folder "' + folderUrl + '" ?' ) ) return false;

oConnector.SendCommand( 'DeleteFolder', 'FolderName=' + ( encodeURI(folderUrl) ) , DeleteFolderCallBack ) ;
}

function DeleteFolderCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;

switch ( iErrorNumber )
{
  case 0 :
   Refresh() ;
   break ;
  case 201 :
   alert( 'You have no permissions to delete the folder' ) ;
   break ;
  case 202 :
   alert( 'Invalid folder name' + sErrorDescription ) ;
   break ;
  case 203 :
   alert( 'Folder not exists' + sErrorDescription ) ;
   break ;
  default :
   alert( 'Error deleting folder. nError number: ' + iErrorNumber  + ' nError description: ' + sErrorDescription ) ;
   break ;
}
}

function DeleteFile(fileUrl)
{
if ( !confirm( 'Do you really delete the file "' + fileUrl + '" ?' ) ) return false;

oConnector.SendCommand( 'DeleteFile', 'FileName=' + encodeURI( fileUrl ) , DeleteFileCallBack ) ;
}

function DeleteFileCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;

switch ( iErrorNumber )
{
  case 0 :
   Refresh() ;
   break ;
  case 301 :
   alert( 'You have no permissions to delete the file' ) ;
   break ;
  case 302 :
   alert( 'Invalid file name' + sErrorDescription ) ;
   break ;
  case 303 :
   alert( 'File not exists' + sErrorDescription  ) ;
   break ;
  default :
   alert( 'Error deleting file. nError number: ' + iErrorNumber  + ' nError description: ' + sErrorDescription ) ;
   break ;
}
}

function RenameFolder( folderName )
{
var newName = prompt('Please enter the new folder name for "' + folderName + '":', folderName);

if ((newName != null) && (newName != '') && (newName != folderName)) {
  oConnector.SendCommand( 'RenameFolder', "FolderName=" + encodeURI(folderName) + "&NewName=" + encodeURI ( newName ), RenameFolderCallBack ) ;
}
}

function RenameFolderCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;

switch ( iErrorNumber )
{
  case 0 :
   Refresh() ;
   break ;
  case 401 :
   alert( 'You have no permissions to rename the folder' ) ;
   break ;
  case 402 :
   alert( 'Invalid folder name' + sErrorDescription ) ;
   break ;
  case 403 :
   alert( 'is not Folder' + sErrorDescription ) ;
   break ;
  case 404 :
   alert( 'Folder not exists' + sErrorDescription ) ;
   break ;
  default :
   alert( 'Error renaming folder. nError number: ' + iErrorNumber  + ' nError description: ' + sErrorDescription ) ;
   break ;
}
}

function RenameFile( fileName )
{
var newName = prompt('Please enter the new file name for "' + fileName + '":', fileName);

if ((newName != null) && (newName != '') && (newName != fileName)) {
  oConnector.SendCommand( 'RenameFile', "FileName=" + encodeURI( fileName ) + "&NewName=" + encodeURI( newName ), RenameFileCallBack ) ;
}
}

function RenameFileCallBack( fckXml )
{
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
var sErrorDescription = String( oNode.attributes.getNamedItem('originalDescription').value ) ;

switch ( iErrorNumber )
{
  case 0 :
   Refresh() ;
   break ;
  case 501 :
   alert( 'You have no permissions to rename the file' ) ;
   break ;
  case 502 :
   alert( 'Invalid file name' + sErrorDescription ) ;
   break ;
  case 503 :
   alert( sErrorDescription +  'is not a file' ) ;
   break ;
  case 504 :
   alert( 'File not exists' + sErrorDescription  ) ;
   break ;
  default :
   alert( 'Error renaming file. nError number: ' +  ' nError description: ' + sErrorDescription ) ;
   break ;
}
}

2。 第二步 找到这个文件 /fckeditoreditorfilemanagerbrowserdefaultfrmfolders.html
  将函数OpenFolder(folderPath)最后一句修改为:

阅读全文

php 正则html网址代码

php 正则html网址代码

$pattern = "/[w-]+.(com|net|org|gov|cc|biz|info|cn)(.(cn|hk))*/";
    preg_match($pattern, http://pic4.phprm.com/2015/07/04/$url.jpg, $matches);
    if(count($matches) > 0) {
        return $matches[0];
    }else{
        $rs = parse_url($url);
        $main_url = $rs["host"];
        if(!strcmp(long2ip(sprintf("%u",ip2long($main_url))),$main_url)) {
            return $main_url;
        }else{
            $arr = explode(".",$main_url);
            $count=count($arr);
            $endArr = array("com","net","org","3322");//com.cn  net.cn 等情况
            if (in_array($arr[$count-2],$endArr)){
                $domain = $arr[$count-3].".".$arr[$count-2].".".$arr[$count-1];
            }else{
                $domain =  $arr[$count-2].".".$arr[$count-1];
            }
            return $domain;
        }// end if(!strcmp...)
    }// end if(count...)
}// end function

阅读全文

php 显示今天是星期几与一年的每几天代码

php 显示今天是星期几与一年的每几天代码

public function getPart ($part) {
  $source = $this->timestamp;
  switch($part)
  {
   case 'yy' : $result = intval(date("Y", $source)); break; //年
   case 'mm' : $result = intval(date("m", $source)); break; //月
   case 'dd' : $result = intval(date("d", $source)); break; //日
   case 'w'  : $result = intval(date("N", $source)); break; //星期 [1-7] "1"表示星期一
   case 'cw' : $index = date("N", $source); //中文星期
      $week_array = array('1'=>'一', '2'=>'二', '3'=>'三', '4'=>'四', '5'=>'五', '6'=>'六', '7'=>'日');
      $result = '星期' . $week_array[$index];

阅读全文

php 批量保存数据与批量更新数据

if ($insert && $insertsql) {php 批量保存数据与批量更新数据
  $keystr = $valstr = $tmp = '';
  foreach($insertsql as $key => $val) {
   if ($val) {
    $keystr .= $tmp.$key;
    $valstr .= $tmp."'".addslashes($val)."'";
    $tmp = ',';
   }
  }
  if ($keystr && $valstr) {
   dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
   m(q("INSERT INTO $tablename ($keystr) VALUES ($valstr)") ? 'Insert new record of success' : mysql_error());
  }
 }
 if ($update && $insertsql && $base64) {
  $valstr = $tmp = '';
  foreach($insertsql as $key => $val) {
   $valstr .= $tmp.$key."='".addslashes($val)."'";
   $tmp = ',';
  }
  if ($valstr) {
   $where = base64_decode($base64);
   dbconn($dbhost,$dbuser,$dbpass,$dbname,$charset,$dbport);
   m(q("UPDATE $tablename SET $valstr WHERE $where LIMIT 1") ? 'Record updating' : mysql_error());
  }
 }

阅读全文

php 类的静态变量的初始化

共有的成员还有办法解决,例如:
class A {
static public $child;
}
A::$child = new B();

对于私有的成员似乎就没有什么干净的方法了,只能这样做:
class A {
static private $child;
static public initialize() {
self::$child = new B();
}
}
A::initialize();

阅读全文

php 获取系统当前路径与检查php配置参数

php 获取系统当前路径与检查php配置参数
function getPath($mainpath, $relativepath) {
  global $dir;
  $mainpath_info           = explode('/', $mainpath);
  $relativepath_info       = explode('/', $relativepath);
  $relativepath_info_count = count($relativepath_info);
  for ($i=0; $i<$relativepath_info_count; $i++) {
   if ($relativepath_info[$i] == '.' || $relativepath_info[$i] == '') continue;
   if ($relativepath_info[$i] == '..') {
    $mainpath_info_count = count($mainpath_info);
    unset($mainpath_info[$mainpath_info_count-1]);
    continue;
   }
   $mainpath_info[count($mainpath_info)] = $relativepath_info[$i];
  } //end for
  return implode('/', $mainpath_info);
 }

阅读全文

php 复制目录及目录下所有文件

function copy($from, $to) {
  if ($this->abspath($to)=="/") $to=$this->basedir;
  if ($this->dirname($from) == $this->dirname($to)) $to = $this->dirname($to).'/复件'.basename($from);
  if (!is_dir($from)) {
   return @copy($from, $to);
  } else {
   if (!is_dir($to)) @mkdir($to);
   $path = opendir($from);
   while( $file = readdir( $path ) ) {
    if (($file=='.')||($file=='..')) continue;
    if (is_dir($from.'/'.$file)) $this->copy($from.'/'.$file, $to.'/'.$file);
    else echo basename($file), copy($from.'/'.$file, $to.'/'.$file) ? ' Success!' : ' False.', '<br />';
   }
   return true;
  }
 }

阅读全文