略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: yp_cat

2024-05-03

yp_cat

(PHP 4 >= 4.0.6, PHP 5 < 5.1.0)

yp_catReturn an array containing the entire map

说明

yp_cat ( string $domain , string $map ) : array

Returns all map entries.

参数

domain

The NIS domain name.

map

The NIS map.

返回值

Returns an array of all map entries, the maps key values as array indices and the maps entries as array data.

add a note add a note

User Contributed Notes 2 notes

up
1
Anonymous
13 years ago
I hope this will userfull to somebody:

function auth_by_nis($login,$password,$nis_domain='-d xxx_nis',$nis_host='-h xxx.it')
{
    $output = shell_exec("ypcat $nis_domain $nis_host passwd");
    $lines=split("\n",$output);
    foreach ($lines as $k=>$v)
    {
        list($login_nis,$pw_nis)=split(":",$v);
        if ($login_nis != $login)continue;
        //login trovata: ora si verifica la password
        $salt=substr( $pw_nis , 0 ,2);
        $pass_cript=crypt($password, $salt);
        if($pass_cript == $pw_nis) return 1;
        else return 0;   
    }
    return 0;
}
up
0
Nicholas Humfrey
12 years ago
yp_cat is lacking in PHP5 - this is a suitable (slow, forking) replacement...

<?php
    $handle
= popen( 'ypcat passwd.byname', 'r' );
    while ((
$line = fgets($handle, 1024)) !== FALSE) {
        list(
$user,$pass,$uid,$gid,$gcos,$home,$shell) = explode (':', $line);
        list(
$name,$room,$work,$home,$position)  = explode (',', $gcos);

       
## Do Stuff ##

   
}  
   
pclose( $handle );
?>

官方地址:https://www.php.net/manual/en/function.yp-cat.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3