cvs: pearweb /include pear-database.php pear-format-xml.php signatures.php xmlrpc-methods.php /public_html test.php

From: Date: Wed, 07 Nov 2001 10:42:39 +0000
Subject: cvs: pearweb /include pear-database.php pear-format-xml.php signatures.php xmlrpc-methods.php /public_html test.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1277@lists.php.net to get a copy of this message
ssb Wed Nov 7 05:42:39 2001 EDT Removed files: /pearweb/include pear-format-xml.php Modified files: /pearweb/include pear-database.php signatures.php xmlrpc-methods.php /pearweb/public_html test.php Log: * xmlrpc user authentication work

Index: pearweb/include/pear-database.php diff -u pearweb/include/pear-database.php:1.29 pearweb/include/pear-database.php:1.30 --- pearweb/include/pear-database.php:1.29 Sat Nov 3 19:41:00 2001 +++ pearweb/include/pear-database.php Wed Nov 7 05:42:39 2001 @@ -1,4 +1,22 @@ <?php +/* + +----------------------------------------------------------------------+ + | PEAR Web site version 1.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Stig Sæther Bakken <ssb@fast.no> | + | Tomas V.V.Cox <cox@php.net> | + +----------------------------------------------------------------------+ + */ require_once "DB/storage.php"; @@ -98,7 +116,7 @@ class category { - // {{{ proto int category::add(struct) + // {{{ *proto int category::add(struct) /* $data = array( @@ -136,7 +154,7 @@ } // }}} - // {{{ proto array category::listAll() + // {{{ -proto array category::listAll() function listAll() { @@ -150,7 +168,7 @@ class package { - // {{{ proto int package::add(struct) + // {{{ *proto int package::add(struct) // add a package, return new package id or PEAR error function add($data) @@ -194,7 +212,7 @@ } // }}} - // {{{ proto struct package::info(string|int) + // {{{ *proto struct package::info(string|int) function info($pkg) { @@ -225,7 +243,7 @@ } // }}} - // {{{ proto struct package::listAll() + // {{{ -proto struct package::listAll() function listAll() { @@ -249,7 +267,7 @@ class maintainer { - // {{{ proto int maintainer::add(int, string, string) + // {{{ +proto int maintainer::add(int, string, string) function add($package, $user, $role) { @@ -271,7 +289,7 @@ class release { - // {{{ proto array release::getRecent([int]) + // {{{ -proto array release::getRecent([int]) function getRecent($n = 5) { @@ -295,7 +313,7 @@ } // }}} - // {{{ proto bool release::upload(string, string, string, string, binary, string) + // {{{ +proto bool release::upload(string, string, string, string, binary, string) function upload($package, $version, $state, $relnotes, &$tarball, $md5sum) { @@ -359,7 +377,7 @@ class note { - // {{{ proto bool note::add(string, int, string) + // {{{ +proto bool note::add(string, int, string) function add($key, $value, $note) { @@ -377,7 +395,7 @@ } // }}} - // {{{ proto bool note::delete(int) + // {{{ +proto bool note::delete(int) function delete($id) { @@ -391,7 +409,7 @@ } // }}} - // {{{ proto bool note::deleteAll(string, int) + // {{{ +proto bool note::deleteAll(string, int) function deleteAll($key, $value) { @@ -408,7 +426,7 @@ class user { - // {{{ proto bool user::delete(string) + // {{{ *proto bool user::delete(string) function delete($uid) { @@ -419,7 +437,7 @@ } // }}} - // {{{ proto bool user::rejectRequest(string, string) + // {{{ *proto bool user::rejectRequest(string, string) function rejectRequest($uid, $reason) { @@ -435,7 +453,7 @@ } // }}} - // {{{ proto bool user::activate(string) + // {{{ *proto bool user::activate(string) function activate($uid) { @@ -466,7 +484,7 @@ // }}} } -// {{{ proto array testerror() +// {{{ +proto array testerror() function testerror() { Index: pearweb/include/signatures.php diff -u pearweb/include/signatures.php:1.5 pearweb/include/signatures.php:1.6 --- pearweb/include/signatures.php:1.5 Sat Nov 3 19:41:00 2001 +++ pearweb/include/signatures.php Wed Nov 7 05:42:39 2001 @@ -1,4 +1,24 @@ <?php +/* + +----------------------------------------------------------------------+ + | PEAR Web site version 1.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Stig Sæther Bakken <ssb@fast.no> | + | | + +----------------------------------------------------------------------+ + */ + +// {{{ parse_signatures_from_file() function parse_signatures_from_file($file, &$signatures, $out_format = "signatures") { @@ -13,13 +33,14 @@ // format: array( array(returntype, methodname, paramlist), ... ) settype($signatures, "array"); $matches = array(); - if (preg_match_all('/proto\s+([a-z|]+)\s+([a-zA-Z0-9_:]+)\s*\(([^\)]*)\)\s*?\n(\s*?\/\/\s+?(.*?)\s*?\n)?/s', + if (preg_match_all('/([ \*\+])?proto\s+([a-z|]+)\s+([a-zA-Z0-9_:]+)\s*\(([^\)]*)\)\s*?\n(\s*?\/\/\s+?(.*?)\s*?\n)?/s', $contents, $matches)) { for ($i = 0; $i < sizeof($matches[0]); $i++) { - $return_type = $matches[1][$i]; - $method_name = $matches[2][$i]; - $parameters = $matches[3][$i]; - //$purpose = @$matches[5][$i]; // XXX unfinished + $auth_type = $matches[1][$i]; + $return_type = $matches[2][$i]; + $method_name = $matches[3][$i]; + $parameters = $matches[4][$i]; + //$purpose = @$matches[6][$i]; // XXX unfinished $return_type_permutations = explode("|", $return_type); $xmlrpc_method = str_replace("::", ".", $method_name); $param_list = preg_split('/\s*,\s*/', $parameters); @@ -77,7 +98,14 @@ } } elseif ($out_format == "index") { foreach ($paramlist_permutations as $paramlist => $dummy) { - $signatures[$xmlrpc_method][$paramlist] = $method_name; + $signatures["index"][$xmlrpc_method][$paramlist] = $method_name; + if ($auth_type == "*") { + $signatures["auth"][$xmlrpc_method] = "admin"; + } elseif ($auth_type == "+") { + $signatures["auth"][$xmlrpc_method] = "user"; + } else { + $signatures["auth"][$xmlrpc_method] = "all"; + } } } else { foreach ($return_type_permutations as $ret_type) { @@ -93,6 +121,9 @@ return true; } +// }}} +// {{{ _signature_worker() + function _signature_worker(&$storage, $params, &$varyat, &$param_variations, $j = 0) { $n = $varyat[$j]; @@ -105,5 +136,7 @@ } } } + +// }}} ?> Index: pearweb/include/xmlrpc-methods.php diff -u pearweb/include/xmlrpc-methods.php:1.8 pearweb/include/xmlrpc-methods.php:1.9 --- pearweb/include/xmlrpc-methods.php:1.8 Sat Nov 3 19:41:00 2001 +++ pearweb/include/xmlrpc-methods.php Wed Nov 7 05:42:39 2001 @@ -1,24 +1,47 @@ -<?php // -*- C++ -*- +<?php // -*- PHP -*- +/* + +----------------------------------------------------------------------+ + | PEAR Web site version 1.0 | + +----------------------------------------------------------------------+ + | Copyright (c) 2001 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Authors: Stig Sæther Bakken <ssb@fast.no> | + | | + +----------------------------------------------------------------------+ + */ require_once "signatures.php"; parse_signatures_from_file("../include/pear-database.php", &$xmlrpc_method_index, "index"); +// {{{ pear_register_xmlrpc_methods() + function pear_register_xmlrpc_methods($xs) { global $xmlrpc_method_index; - foreach ($xmlrpc_method_index as $method => $foo) { + foreach ($xmlrpc_method_index["index"] as $method => $foo) { // error_log("registering $method"); xmlrpc_server_register_method($xs, $method, "pear_xmlrpc_dispatcher"); } xmlrpc_server_register_introspection_callback($xs, "pear_xmlrpc_introspection_callback"); } +// }}} +// {{{ pear_xmlrpc_dispatcher() + function pear_xmlrpc_dispatcher($method_name, $params, $appdata) { global $xmlrpc_method_index; - if (empty($xmlrpc_method_index[$method_name])) { + if (empty($xmlrpc_method_index["index"][$method_name])) { error_log("pear xmlrpc unknown method: $method_name"); return false; // XXX FAULT } @@ -29,11 +52,15 @@ } $type_key .= xmlrpc_get_type($params[$i]); } - if (!isset($xmlrpc_method_index[$method_name][$type_key])) { + if (!isset($xmlrpc_method_index["index"][$method_name][$type_key])) { error_log("pear xmlrpc no signature found for $method_name($type_key)"); return false; // XXX FAULT } - $function = $xmlrpc_method_index[$method_name][$type_key]; + $auth = $xmlrpc_method_index["auth"][$method_name]; + if ($auth != "all") { + auth_require($auth == "admin"); + } + $function = $xmlrpc_method_index["index"][$method_name][$type_key]; if (strstr($function, "::")) { list($class, $method) = explode("::", $function); // XXX deprecated syntax @@ -56,6 +83,8 @@ return $ret; } +// }}} +// {{{ pear_xmlrpc_introspection_callback() function pear_xmlrpc_introspection_callback($userdata) { @@ -69,17 +98,17 @@ $ret .= " <purpose/>\n"; $ret .= " <signatures>\n"; foreach ($sig["param_types"] as $params) { - $ret .= " <signature>\n"; - $ret .= " <params>\n"; - $paramlist = explode(",", $params); - foreach ($paramlist as $param) { - $ret .= " <value type='$param'/>\n"; - } - $ret .= " </params>\n"; - $ret .= " <returns>\n"; - $ret .= " <value type='$sig[return_type]'/>\n"; - $ret .= " </returns>\n"; - $ret .= " </signature>\n"; + $ret .= " <signature>\n"; + $ret .= " <params>\n"; + $paramlist = explode(",", $params); + foreach ($paramlist as $param) { + $ret .= " <value type='$param'/>\n"; + } + $ret .= " </params>\n"; + $ret .= " <returns>\n"; + $ret .= " <value type='$sig[return_type]'/>\n"; + $ret .= " </returns>\n"; + $ret .= " </signature>\n"; } $ret .= " </signatures>\n"; $ret .= " <see/>\n"; @@ -95,4 +124,5 @@ return $ret; } +// }}} ?> Index: pearweb/public_html/test.php diff -u pearweb/public_html/test.php:1.5 pearweb/public_html/test.php:1.6 --- pearweb/public_html/test.php:1.5 Sat Nov 3 19:41:00 2001 +++ pearweb/public_html/test.php Wed Nov 7 05:42:39 2001 @@ -3,8 +3,11 @@ require_once "signatures.php"; parse_signatures_from_file("../include/pear-database.php", &$signatures, - "signatures"); + "index"); +pre_dump($signatures); + +exit; print "<pre>"; $ret = "<introspection version='1.0'>\n"; $ret .= " <methodList>\n";
« previous php.pear.cvs (#1277) next »