removed mods directory from the ATutor codebase
[atutor.git] / mods / phpdoc2 / PhpDocumentor / phpDocumentor / Smarty-2.6.0 / libs / plugins / function.fetch.php
diff --git a/mods/phpdoc2/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/function.fetch.php b/mods/phpdoc2/PhpDocumentor/phpDocumentor/Smarty-2.6.0/libs/plugins/function.fetch.php
deleted file mode 100644 (file)
index 082c348..0000000
+++ /dev/null
@@ -1,217 +0,0 @@
-<?php\r
-/**\r
- * Smarty plugin\r
- * @package Smarty\r
- * @subpackage plugins\r
- */\r
-\r
-\r
-/**\r
- * Smarty {fetch} plugin\r
- *\r
- * Type:     function<br>\r
- * Name:     fetch<br>\r
- * Purpose:  fetch file, web or ftp data and display results\r
- * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}\r
- *       (Smarty online manual)\r
- * @param array\r
- * @param Smarty\r
- * @return string|null if the assign parameter is passed, Smarty assigns the\r
- *                     result to a template variable\r
- */\r
-function smarty_function_fetch($params, &$smarty)\r
-{\r
-    if (empty($params['file'])) {\r
-        $smarty->_trigger_fatal_error("[plugin] parameter 'file' cannot be empty");\r
-        return;\r
-    }\r
-\r
-    if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {\r
-               $_params = array('resource_type' => 'file', 'resource_name' => $params['file']);\r
-               require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_secure.php');\r
-               if(!smarty_core_is_secure($_params, $smarty)) {\r
-            $smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');\r
-            return;                    \r
-               }\r
-               \r
-               // fetch the file\r
-               if($fp = @fopen($params['file'],'r')) {\r
-                       while(!feof($fp)) {\r
-                               $content .= fgets ($fp,4096);\r
-                       }\r
-                       fclose($fp);\r
-               } else {\r
-            $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'');\r
-            return;                    \r
-               }\r
-    } else {\r
-               // not a local file\r
-               if(preg_match('!^http://!i',$params['file'])) {\r
-                       // http fetch\r
-                       if($uri_parts = parse_url($params['file'])) {\r
-                               // set defaults\r
-                               $host = $server_name = $uri_parts['host'];\r
-                               $timeout = 30;\r
-                               $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";\r
-                               $agent = "Smarty Template Engine ".$smarty->_version;\r
-                               $referer = "";\r
-                               $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';\r
-                               $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';\r
-                               $_is_proxy = false;\r
-                               if(empty($uri_parts['port'])) {\r
-                                       $port = 80;\r
-                               } else {\r
-                                       $port = $uri_parts['port'];\r
-                               }\r
-                               if(empty($uri_parts['user'])) {\r
-                                       $user = '';\r
-                               }                               \r
-                               // loop through parameters, setup headers\r
-                               foreach($params as $param_key => $param_value) {                        \r
-                                       switch($param_key) {\r
-                                               case "file":\r
-                                               case "assign":\r
-                                               case "assign_headers":\r
-                                                       break;\r
-                                               case "user":\r
-                                                       if(!empty($param_value)) {\r
-                                                               $user = $param_value;\r
-                                                       }\r
-                                                       break;\r
-                                               case "pass":\r
-                                                       if(!empty($param_value)) {\r
-                                                               $pass = $param_value;\r
-                                                       }\r
-                                                       break;\r
-                                               case "accept":\r
-                                                       if(!empty($param_value)) {\r
-                                                               $accept = $param_value;\r
-                                                       }\r
-                                                       break;\r
-                                               case "header":\r
-                                                       if(!empty($param_value)) {\r
-                                                               if(!preg_match('![\w\d-]+: .+!',$param_value)) {\r
-                                                       $smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");\r
-                                                       return;                                                                 \r
-                                                               } else {\r
-                                                                       $extra_headers[] = $param_value;\r
-                                                               }\r
-                                                       }\r
-                                                       break;\r
-                                               case "proxy_host":\r
-                                                       if(!empty($param_value)) {\r
-                                                               $proxy_host = $param_value;\r
-                                                       }\r
-                                                       break;\r
-                                               case "proxy_port":\r
-                                                       if(!preg_match('!\D!', $param_value)) {\r
-                                                               $proxy_port = (int) $param_value;\r
-                                                       } else {\r
-                                               $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");\r
-                                               return;                                                                 \r
-                                                       }\r
-                                                       break;\r
-                                               case "agent":\r
-                                                       if(!empty($param_value)) {\r
-                                                               $agent = $param_value;\r
-                                                       }\r
-                                                       break;\r
-                                               case "referer":\r
-                                                       if(!empty($param_value)) {\r
-                                                               $referer = $param_value;\r
-                                                       }\r
-                                                       break;\r
-                                               case "timeout":\r
-                                                       if(!preg_match('!\D!', $param_value)) {\r
-                                                               $timeout = (int) $param_value;\r
-                                                       } else {\r
-                                               $smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");\r
-                                               return;                                                                 \r
-                                                       }\r
-                                                       break;\r
-                                               default:\r
-                                       $smarty->_trigger_fatal_error("[plugin] unrecognized attribute '".$param_key."'");\r
-                                       return;\r
-                                       }                       \r
-                               }\r
-                               if(!empty($proxy_host) && !empty($proxy_port)) {\r
-                                       $_is_proxy = true;\r
-                                       $fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);\r
-                               } else {\r
-                                       $fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);\r
-                               }\r
-\r
-                               if(!$fp) {\r
-                       $smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");\r
-                       return;                         \r
-                               } else {\r
-                                       if($_is_proxy) {\r
-                                               fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");                                         \r
-                                       } else {\r
-                                               fputs($fp, "GET $uri HTTP/1.0\r\n");\r
-                                       }\r
-                                       if(!empty($host)) {\r
-                                               fputs($fp, "Host: $host\r\n");\r
-                                       }\r
-                                       if(!empty($accept)) {\r
-                                               fputs($fp, "Accept: $accept\r\n");\r
-                                       }\r
-                                       if(!empty($agent)) {\r
-                                               fputs($fp, "User-Agent: $agent\r\n");\r
-                                       }\r
-                                       if(!empty($referer)) {\r
-                                               fputs($fp, "Referer: $referer\r\n");\r
-                                       }\r
-                                       if(isset($extra_headers) && is_array($extra_headers)) {\r
-                                               foreach($extra_headers as $curr_header) {\r
-                                                       fputs($fp, $curr_header."\r\n");\r
-                                               }\r
-                                       }\r
-                                       if(!empty($user) && !empty($pass)) {\r
-                                               fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");                                                \r
-                                       }\r
-\r
-                                       $content = '';                                  \r
-                                       fputs($fp, "\r\n");\r
-                                       while(!feof($fp)) {\r
-                                               $content .= fgets($fp,4096);\r
-                                       }\r
-                                       fclose($fp);                                    \r
-                                       $csplit = split("\r\n\r\n",$content,2);\r
-\r
-                                       $content = $csplit[1];\r
-                                       \r
-                                       if(!empty($params['assign_headers'])) {\r
-                                               $smarty->assign($params['assign_headers'],split("\r\n",$csplit[0]));\r
-                                       }\r
-                               }\r
-                       } else {\r
-                       $smarty->_trigger_fatal_error("[plugin] unable to parse URL, check syntax");\r
-                       return;\r
-                       }\r
-               } else {\r
-                       // ftp fetch\r
-                       if($fp = @fopen($params['file'],'r')) {\r
-                               while(!feof($fp)) {\r
-                                       $content .= fgets ($fp,4096);\r
-                               }\r
-                               fclose($fp);\r
-                       } else {\r
-               $smarty->_trigger_fatal_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'');\r
-               return;                 \r
-                       }\r
-               }\r
-               \r
-       }\r
-\r
-\r
-    if (!empty($params['assign'])) {\r
-        $smarty->assign($params['assign'],$content);\r
-    } else {\r
-        return $content;\r
-    }\r
-}\r
-\r
-/* vim: set expandtab: */\r
-\r
-?>\r