svn: /web/php/trunk/ mailing-lists.php ws.php
| From: | Philip Olson | Date: | Tue, 22 Jun 2010 19:30:40 +0000 |
| Subject: | svn: /web/php/trunk/ mailing-lists.php ws.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-8412@lists.php.net to get a copy of this message | ||
philip Tue, 22 Jun 2010 19:30:40 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=300673
Log:
help clarify that php-general@ is for support questions, whereas php-webmaster@ is not
Changed paths:
U web/php/trunk/mailing-lists.php
U web/php/trunk/ws.php
Modified: web/php/trunk/mailing-lists.php
===================================================================
--- web/php/trunk/mailing-lists.php 2010-06-22 18:34:39 UTC (rev 300672)
+++ web/php/trunk/mailing-lists.php 2010-06-22 19:30:40 UTC (rev 300673)
@@ -182,7 +182,7 @@
),
array (
'php-general', 'General user list',
- 'This is a really high volume general list for PHP users',
+ 'This is a high volume list for general PHP support; ask PHP questions here',
FALSE, TRUE, TRUE, "php.general"
),
array (
@@ -275,7 +275,7 @@
'PHP website mailing lists',
array (
'php-webmaster', 'Webmaster discussion',
- 'List for discussing the PHP websites',
+ 'List for discussing and maintaining the php.net web infrastructure; this is not for PHP
<a href="/support.php">support</a> questions',
FALSE, FALSE, FALSE, "php.webmaster"
),
Modified: web/php/trunk/ws.php
===================================================================
--- web/php/trunk/ws.php 2010-06-22 18:34:39 UTC (rev 300672)
+++ web/php/trunk/ws.php 2010-06-22 19:30:40 UTC (rev 300673)
@@ -1,8 +1,13 @@
<?php
+$conf['appid'] =
'x9z8FnjV34GpvBj3HNN94r4JcEWjlfMAHaf7XUeltFDQVczSJWth9QethWv_6Qf6JRZZ';
+$conf['svc'] = 'http://search.yahooapis.com/WebSearchService/V1/webSearch';
+/*
if(!$conf=apc_fetch('ws_config')) {
include '/local/Web/ws.conf';
apc_store('ws_config',$conf);
}
+*/
+
$raw = filter_input(INPUT_GET, 'q', FILTER_UNSAFE_RAW);
$q = urlencode($raw);
$r = isset($_REQUEST['results']) ? (int)$_REQUEST['results'] : 10;
@@ -20,17 +25,36 @@
);
if(isset($sites[$_REQUEST['profile']])) {
- $scope = $_REQUEST['profile'];
+ $scope = $_REQUEST['profile'];
} else {
- $scope = 'all';
+ $scope = 'all';
}
-$request =
"{$conf['svc']}?appid={$conf['appid']}&query=$q&start=$s&results=$r&site={$sites[$scope]}&language=$l&output=php&similar_ok=1";
-$data = @file_get_contents($request);
-list($version,$status_code,$msg) = explode(' ',$http_response_header[0], 3);
-if($status_code==200) echo $data;
-else echo serialize($http_response_header[0]);
+$r_hack = $r;
+if ($scope === 'manual') {
+ $r_hack = $r * 3;
+}
+$request =
"{$conf['svc']}?appid={$conf['appid']}&query=$q&start=$s&results=$r_hack&site=www.php.net&language=$l&output=php&similar_ok=1&vs=www.php.net&sm=EjK&smid=EjK";
+$data = file_get_contents($request);
+
+list($version, $status_code, $msg) = explode(' ', $http_response_header[0], 3);
+
+if ($status_code == 200) {
+
+ $data = unserialize($data);
+
+ if ($scope === 'manual') {
+ #$data = process_manual_data($data, $r, $l);
+ }
+
+ print "<pre>";
+ print_r($data);
+} else {
+ echo serialize($http_response_header[0]);
+}
+
+/*
$dbh = new PDO('mysql:host=localhost;dbname=ws', $conf['db_user'],
$conf['db_pw'], array(PDO::ATTR_PERSISTENT => true,
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -40,4 +64,73 @@
} catch (PDOException $e) {
}
+*/
+
+/*
+ Hack to clean up 'manual' searches, to only show results from the PHP Manual.
+
+ - This messes up various statistics, like totalResultsAvailable will no longer be true.
+ - For this reason, and my lack of desire to recalculate or waste Y! resources,
+ the intelligence (e.g., "you are viewing results 1-10 of 80") was removed.
+ and replaced with a simple "more results ->"
+ - Note: Many of the results are bogus anyways, so the count isn't all that useful
+ - Feel free to update.
+*/
+function process_manual_data($data, $numresults, $langcode = 'en') {
+
+ // Don't touch anything in this case
+ if ($data['ResultSet']['totalResultsAvailable'] == 0) {
+ return $data;
+ }
+
+ $good = array();
+ $en = array();
+ $count = 0;
+
+ $data_tmp = $data;
+
+ foreach ($data['ResultSet']['Result'] as $num => $result) {
+
+ // Sometimes the url refers to a specific user comment, so let's remove that part
+ // Note: We use Url, but DisplayUrl and ClickUrl also exist
+ // Note: Consider fixing this at the API level
+ $result['Url'] = preg_replace('/(#\d+)/', '',
$result['Url']);
+
+ // Require manual/ in the result urls
+ // Note: Consider allowing 404 urls, like php.net/function.strlen
+ if (false === strpos($result['Url'], 'php.net/manual')) {
+ continue;
+ }
+
+ // Lang code.
+ // Note: Language specific manuals already include English pages for missing text
+ if (false === strpos($result['Url'], "php.net/manual/{$langcode}")) {
+
+ /*
+ Other languages don't seem possible at the moment, oh well, this is for FC I guess
+ Not sure how useful this is, so not using it for now.
+ Return code might look like: $good = array_merge($good, array_slice($en, 0, ($numresults -
count($good))));
+
+ if ($langcode !== 'en' && false !== strpos($result['Url'],
"php.net/manual/en")) {
+ $en[] = $result;
+ }
+ */
+ continue;
+ }
+
+ $good[$count++] = $result;
+
+ // Stop if we have enough results
+ if ($count === $numresults) {
+ break;
+ }
+ }
+
+ // Lie, and return our Result as their Result
+ // Got and Desired information is new.
+ $data['totalResultsDesired'] = $numresults;
+ $data['totalResultsGot'] = count($good);
+ $data['ResultSet']['Result'] = $good;
+ return $data;
+}
?>