phpldapadmin之config.php过滤

完全过滤掉/*--------*/"和空行,以及”//“开头、”#“开头的行,

sed  -e '/\/\*/,/\*\//d' config.php|grep -Ev "(^$)|(^(\/\/))|(^#)"

sed  -e '/\/\*/,/\*\//d' -e '/^\/\//d' -e '/^$/d' -e '/^#/d' config.php

<?php

$config->custom->session['blowfish'] = '500c2e72fe8a4621d6e576fe6e40e39d';     # Autogenerated for studylinux

$config->custom->appearance['friendly_attrs'] = array(

         'facsimileTelephoneNumber' => 'Fax',

         'gid'                      => 'Group',

         'mail'                     => 'Email',

         'telephoneNumber'          => 'Telephone',

         'uid'                      => 'User Name',

         'userPassword'             => 'Password'

 );

$servers = new Datastore();

$servers->newServer('ldap_pla');

$servers->setValue('server','name','Local LDAP Server');

$servers->setValue('appearance','password_hash','');

 $servers->setValue('login','attr','uid');

?>

 

过滤完“/*--------*/"和空行后,应该是这个样子。

<?php

$config->custom->session['blowfish'] = '500c2e72fe8a4621d6e576fe6e40e39d';     # Autogenerated for studylinux

// $config->custom->session['http_realm'] = sprintf('%s %s',app_name(),'login');

// $config->custom->appearance['language'] = 'auto';

// $config->custom->jpeg['tmpdir'] = '/tmp';     // Example for Unix systems

#  $config->custom->jpeg['tmpdir'] = 'c:\\temp'; // Example for Windows systems

#  $config->custom->password['no_random_crypt_salt'] = true;

// $config->custom->session['timelimit'] = 30;

// $config->custom->appearance['show_clear_password'] = false;

// $config->custom->search['size_limit'] = 50;

#  $config->custom->search['size_limit'] = 1000;

// $config->custom->appearance['timezone'] = null;

#  $config->custom->appearance['timezone'] = 'Australia/Melbourne';

// $config->custom->appearance['tree'] = 'AJAXTree';

#  $config->custom->appearance['tree'] = 'HTMLTree';

// $config->custom->appearance['custom_templates_only'] = false;

// $config->custom->appearance['disable_default_template'] = false;

// $config->custom->appearance['hide_template_warning'] = false;

// $config->custom->appearance['minimalMode'] = false;

// $config->custom->appearance['tree_filter'] = '(objectclass=*)';

// $config->custom->appearance['tree_height'] = null;

#  $config->custom->appearance['tree_height'] = 600;

// $config->custom->appearance['tree_width'] = null;

#  $config->custom->appearance['tree_width'] = 250;

// $config->custom->confirm['create'] = true;

// $config->custom->confirm['update'] = true;

// $config->custom->confirm['copy'] = true;

$config->custom->appearance['friendly_attrs'] = array(

         'facsimileTelephoneNumber' => 'Fax',

         'gid'                      => 'Group',

         'mail'                     => 'Email',

         'telephoneNumber'          => 'Telephone',

         'uid'                      => 'User Name',

         'userPassword'             => 'Password'

 );

// $config->custom->appearance['hide_attrs'] = array();

#  $config->custom->appearance['hide_attrs'] = array('objectClass');

// $config->custom->appearance['hide_attrs_exempt'] = null;

#  $config->custom->appearance['hide_attrs_exempt'] = 'cn=PLA UnHide,ou=Groups,c=AU';

// $config->custom->appearance['readonly_attrs'] = array();

// $config->custom->appearance['readonly_attrs_exempt'] = null;

#  $config->custom->appearance['readonly_attrs_exempt'] = 'cn=PLA ReadWrite,ou=Groups,c=AU';

// $config->custom->modify_member['groupattr'] = array('member','uniqueMember','memberUid');

// $config->custom->modify_member['filter'] = '(objectclass=Person)';

// $config->custom->modify_member['attr'] = 'dn';

// $config->custom->modify_member['posixattr'] = 'uid';

// $config->custom->modify_member['posixfilter'] = '(uid=*)';

// $config->custom->modify_member['posixgroupattr'] = 'memberUid';

// $config->custom->appearance['attr_display_order'] = array();

#  $config->custom->appearance['attr_display_order'] = array(

#   'givenName',

#   'sn',

#   'cn',

#   'displayName',

#   'uid',

#   'uidNumber',

#   'gidNumber',

#   'homeDirectory',

#   'mail',

#   'userPassword'

#  );

$servers = new Datastore();

$servers->newServer('ldap_pla');

$servers->setValue('server','name','Local LDAP Server');

// $servers->setValue('server','host','127.0.0.1');

// $servers->setValue('server','port',389);

// $servers->setValue('server','base',array(''));

// $servers->setValue('login','auth_type','session');

// $servers->setValue('login','bind_id','');

#  $servers->setValue('login','bind_id','cn=Manager,dc=example,dc=com');

// $servers->setValue('login','bind_pass','');

#  $servers->setValue('login','bind_pass','secret');

// $servers->setValue('server','tls',false);

// $servers->setValue('login','auth_type','sasl');

// $servers->setValue('sasl','mech','GSSAPI');

// $servers->setValue('sasl','realm','');

#  $servers->setValue('sasl','realm','EXAMPLE.COM');

// $servers->setValue('sasl','authz_id', null);

// $servers->setValue('sasl','authz_id_regex',null);

// $servers->setValue('sasl','authz_id_replacement',null);

#  $servers->setValue('sasl','authz_id_regex','/^uid=([^,]+)(.+)/i');

#  $servers->setValue('sasl','authz_id_replacement','$1');

// $servers->setValue('sasl','props',null);

// $servers->setValue('appearance','password_hash','md5');

$servers->setValue('appearance','password_hash','');

// $servers->setValue('login','attr','dn');

 $servers->setValue('login','attr','uid');

// $servers->setValue('login','base',array());

// $servers->setValue('login','class',array());

// $servers->setValue('login','fallback_dn',false);

// $servers->setValue('server','read_only',false);

// $servers->setValue('appearance','show_create',true);

// $servers->setValue('appearance','open_tree',false);

// $servers->setValue('auto_number','enable',true);

// $servers->setValue('auto_number','mechanism','search');

// $servers->setValue('auto_number','min',array('uidNumber'=>1000,'gidNumber'=>500));

// $servers->setValue('auto_number','dn',null);

// $servers->setValue('auto_number','pass',null);

// $servers->setValue('login','anon_bind',true);

#  $servers->setValue('custom','pages_prefix','custom_');

 #  $servers->setValue('login','allowed_dns',array(

#   'uid=stran,ou=People,dc=example,dc=com',

#   '(&(gidNumber=811)(objectClass=groupOfNames))',

#   '(|(uidNumber=200)(uidNumber=201))',

#   'cn=callcenter,ou=Group,dc=example,dc=com'));

// $servers->setValue('server','visible',true);

......

// $servers->setValue('unique','pass',null);

?>

 

 

// 查看全文
2020 8月 13

Centos7学习笔记(六)——shell编程初步

1、shell编程的一些基础

a)shell编程有两类变量,

                             全局变量(环境变量)——  一般指系统内置的变量,或者手动用export、declare等方式宣称,写入/etc/profile(~./bash_profile、~/bashrc、/etc/bashrc)的全局变量

                             局部变量(普通变量)——   用于shell脚本。常规定义的变量。

b)局部变量的定义方式:

          变量名=值  (注意:两边不能有空格

      其中,变量名只能用字母、数字、下划线组成,且不能是数字开头。

      =称之为赋值符。

      “值”的内容,可以用单引号''、双引号""、反引号``或者不加引号,具体效果和shell命令行模式下相同。

[root@ecs-ryCz8 /home/study]# x=1
[root@ecs-ryCz8 /home/study]# y=$x+1
[root@ecs-ryCz8 /home/study]# echo $y
1+1
[root@ecs-ryCz8 /home/study]# let y=$x+1            #《=======这里,let使变量参与实际运算
[root@ecs-ryCz8 /home/study]# echo $y
2

 

[root@ecs-ryCz8 /home/study]# a=1
[root@ecs-ryCz8 /home/study]# echo $a23

[root@ecs-ryCz8 /home/study]# echo ${a}23           #《========这里,若想输出123,那么用$a23是不行的,$a23会被认为是名为a23的变量,要用${a}23
123

 

2、shell内置的,用于接收参数的变量

$0——对应当前shell脚本的名称

$1、$2、$3....——对应每一个接收的参数的值,当大于10时,要写成${10}的样式

$#——对应接收参数的数量

$*——对应所有接收的参数的值

$@——也对应所有的参数,不过每个参数区别对待。

$?——上一命令执行的结果,结果为0表示执行正常,结果为1表示执行失败

$$——脚本执行的进程id

$!——后台运行的进程的最后一个进程进程号

示例脚本及输出结果如下:

[study@c7study ~]$ cat shell_variables_lianxi.sh 
#/bin/bash
##本脚本的目的是为了学习shell内置参数变量,脚本用法:xxx.sh 字串 【多个空格分隔字串】##
echo "当前脚本名称为$0"
echo "总共有$#个参数,分别是$*"                            #《========= 这里$*是把传递的参数变量值作为整体 
echo "第1个参数是$1,第3个参数是$3,第5个参数是$5"
for i in $@                                              #《========= 这里用for循环显示$@中每一个变量值
do
echo "每一个参数分别是:$i"
done

[study@c7study ~]$ bash shell_variables_lianxi.sh 11 1st ?,rbs xx12 x--y $abc _$der
当前脚本名称为shell_variables_lianxi.sh
总共有6个参数,分别是11 1st ?,rbs xx12 x--y _
第1个参数是11,第3个参数是?,rbs,第5个参数是x--y
每一个参数分别是:11
每一个参数分别是:1st
每一个参数分别是:?,rbs
每一个参数分别是:xx12
每一个参数分别是:x--y
每一个参数分别是:_

 

3、shell相关运算符

a)文件测试运算符

                            -d             测试文件是否为目录类型

                            -e             测试文件是否存在,存在为真

                            -f             判断是否为一般文件

                            -L             测试文件是否为链接符号文件,是为真

                            -r             测试当前用户是否有权限读取

                            -w            测试当前用户是否有权限写入

                            -x             测试当前用户是否有权限执行

其他不常用的

                            -s             测试文件是空,非空为真

                            -b             测试文件是否块设备文件

                            -c             测试文件是否为字符设备文件

                            -p            测试文件是否为管道文件

                            -S             测试文件是否为套接字文件

                            -u             测试文件是否有SUID权限

                            -g             测试文件是否有SGID权限

                            -k             测试文件是否有SBIT权限

b)逻辑测试运算符

                            &&          逻辑与——前者执行正确(结果返回值为0,即$?为0),后者才执行

                            ||              逻辑或——前者执行结果不正确($?为1),后者才执行

                            !            逻辑非——对所有执行结果取反

c)整数值比较运算符

                            eq           等于

                            ne           不等于

                            lt             小于

                            gt            大于

                            le             小于等于

                            ge            大于等于

d)字符串比较运算符

                           =      比较字符串内容是否相同

                          !=      比较字符串内容是否不同

                         -z        判断字符串内容是否为空

                         -n        判断字符串内容是否为非空

4、echo命令

echo命令作为shell脚本中使用频次非常高的一个命令,要掌握2个基本参数。

-n——用于echo后不换行输出

-e——用于转义控制符,比如"\n、\t、\v、\r”等,\0nnn表示八进制,\xhh表示十六进制。

对于-e,有一组成对的特殊的“\e[1;”、"\e[0m",用于控制shell环境下的颜色输出,其中控制字符本身的颜色有:30m黑色,31m红色,32m绿色,33m黄色,34m蓝色,35m洋红,36m青色,37m白色。

控制字符背景颜色的有:40m黑色,41m红色,42m绿色,43m黄色,44m蓝色,45m洋红,46m青色,47m白色。

image.png

那么

image.png

[ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\[\e[34;1m\]\u\[\e[0m\]\[\e[33;1m\]@\[\e[0m\]\[\e[32;1m\]\H\[\e[0m\]\[\e[31;1m\] \w\[\e[0m\]]\\$ "

也就不难理解了,这里的“PS1”,由于是变量,在使用时,需要转义“[”符号本身,所以有大量的转义符“\”,而且,写成“\e[34;1m”是等价于“\e[1;34m”的。本质上,除了颜色控制,写的还是“[\u@\H \w]\$”。

 

5、history命令

-c——清除“~/.bash_history”文件中记录的和内存中缓存的历史命令痕迹

-w——将内存缓存的历史命令痕迹写入“~/.bash_history”文件中

关于“HISTSIZE”的问题,究竟是改大好还是改小好,有不同的说法。改小是为了增强安全性,但其实也有点悖论,因为如果账户被暴力破解,没人会傻到靠查历史命令的方式去探取进一步的权限。

 

6、read命令

常用参数:

-s(secret)——用于将输入内容隐藏

-p(prompt)——用于输出提示内容

-a(array)——用于把输入内容作为数组对象

-n(nchars)——用于指定字符个数,后面接个数n,超过n个字符的内容,不被变量取得

-t(timeout)——用于read等待输入超时时间

#!/bin/bash
read -t 30 -p "please input your num1:"  num1
read -t 30 -p "Please input your num2:"  num2
sum=$(( $num1 + $num2 ))                            #《===========这里的$num1和$num2前后的空格,可加可不加,但最好统一
echo "$sum"

 

7、declare命令

参数:

-:给变量设定类型属性

+:取消变量的类型属性

-i:设定变量为integer整数型

-a:设定变量为array数组型

-r:设定变量为readonly只读型,注意,一旦变量设定为只读型,那么它变量内容既不能被修改,也不能删除变量的值,甚至不能通过+r取消只读属性。在当前shell环境中,也不能用unset取消变量,唯有重启或其他方式,清空。-r多用于系统自身声明只读变量,一般不自行设置永久只读变量。

-x:将变量声明为环境变量

-p:显示指定变量的被申明类型

在shell中,单独执行declare -p,就会发现,它显示的是当前环境中的所有环境变量,这些环境变量,都是declare结合参数来申明的。本质上说,用export命令来申明环境变量,就是调用declare来设置环境变量。

要注意的是:array数组型变量,在shell中用的很少,究其原因,是因为shell中的内置函数很少,不能通过调用函数来实现一些复杂的功能。这点上,是跟其他编程语言是有本质的区别的。比如,对一组数字进行从大到小(或从小到大)的排序,因为没有内置函数去实现排序,那么在shell中,就需要自己写算法进行比较。要想实现,最好的方式是用python等语言去实现。

 

8、expr和let命令

expr用expr --help即可明明白白显示其具体用法:(注意:ARG1和ARG2两边都是有空格的。ARG1、ARG2当然可以是事先定义的变量)

 

ARG1 | ARG2      ARG1 if it is neither null nor 0, otherwise ARG2   
  ARG1 & ARG2      ARG1 if neither argument is null or 0, otherwise 0
  ARG1 < ARG2      ARG1 is less than ARG2           小于
  ARG1 <= ARG2       ARG1 is less than or equal to ARG2   小于等于
  ARG1 = ARG2      ARG1 is equal to ARG2          等于
  ARG1 != ARG2       ARG1 is unequal to ARG2      不等于
  ARG1 >= ARG2       ARG1 is greater than or equal to ARG2  大于等于
  ARG1 > ARG2      ARG1 is greater than ARG2    大于
  ARG1 + ARG2      arithmetic sum of ARG1 and ARG2  加法
  ARG1 - ARG2      arithmetic difference of ARG1 and ARG2  减法
  ARG1 * ARG2      arithmetic product of ARG1 and ARG2     乘法
  ARG1 / ARG2      arithmetic quotient of ARG1 divided by ARG2  除法
  ARG1 % ARG2      arithmetic remainder of ARG1 divided by ARG2  取余

let命令中,对运算,变量前后可以不加空格。

 

 

// 查看全文
2020 8月 12