[Phpcms-plugins-cvs] linkcounter4phpCMS linkcounter.php,NONE,1.1 .cvsignore,NONE,1.1
Brought to you by:
mjahn
From: Martin J. <mj...@us...> - 2005-02-24 00:02:03
|
Update of /cvsroot/phpcms-plugins/linkcounter4phpCMS In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15184 Added Files: linkcounter.php .cvsignore Log Message: initial import --- NEW FILE: .cvsignore --- ?project* project.index --- NEW FILE: linkcounter.php --- <?php /** * linkCounter4phpCMS * * <b>License</b> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @author Martin Jahn <mj...@us...> * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @copyright Copyright (c) 2005, Martin Jahn * @version $Id: linkcounter.php,v 1.1 2005/02/24 00:01:52 mjahn Exp $ * @package linkCounter4phpCMS */ /* * $Log: linkcounter.php,v $ * Revision 1.1 2005/02/24 00:01:52 mjahn * initial import * */ $limiter = '::'; $datafile = $_SERVER ['DOCUMENT_ROOT'].'/cms/logs/linkcounter.log'; error_reporting (E_ALL - E_NOTICE); $data = parse_ini_file ($datafile, true); if (isset ($_GET ['url'])) { $url = urldecode (strip_tags ($_GET ['url'])); if (!strstr ($url, '://')) { $url = 'http://'.$url; } $temp = parse_url ($url); $url = $temp ['scheme'].'://'.$temp['host']; if ($temp ['port'] != '') { $url .= ':'.$temp ['port']; } if ($temp ['path'] != '') { $url .= $temp ['path']; } if ($temp ['query'] != '') { $url .= '?'.$temp [ 'query']; } // redirect to the url // increase the correspondending counter if (isset ($data [$url])) { $data [$url] = $data [$url] + 1; } else { $data [$url] = 1; } include_once ('Log.php'); $logger =& Log::factory ('file', dirname ($datafile).'/exit.log', 'Linkcounter', array ('filename'=>dirname ($datafile).'/exitrss.log')); $logger->log($url.' from '.$_SERVER ['REMOTE_ADDR'], PEAR_LOG_NOTICE); write_ini_file ($datafile, $data); header ('Location: '.$url, true); return; } elseif (isset ($_GET ['c_url'])) { // echo the counter of the given id } else { // plugin functionality $keys = get_object_vars ($PageContent); foreach ($keys as $id=>$value) { if (strtoupper ($id) !== $id) { continue; } if (substr ($id, 0, 15) === 'CONTENT_PLUGIN_' || substr ($id, 0, 4) === 'MENU' || substr ($id, 0, 7) === 'PROJECT' || substr ($id, 0, 6) === 'SCRIPT') { continue; } $text = trim (implode ($value)); if ($text == '') { continue; } echo $id."\n"; if (!preg_match_all ('°'.$limitwer.'([a-zA-Z0-9]+)'.$limiter.'°im', $text, $links)) { continue; } ob_start (); print_r ($links); $PageContent->{$id} = array (ob_get_contents ()); ob_end_clean(); } } function write_ini_file($path, $assoc_array) { foreach($assoc_array as $key => $item) { if(is_array($item)) { $content .= "\n[{$key}]\n"; foreach ($item as $key2 => $item2) { if(is_numeric($item2) || is_bool($item2)) $content .= "{$key2} = {$item2}\n"; else $content .= "{$key2} = \"{$item2}\"\n"; } } else { if(is_numeric($item) || is_bool($item)) $content .= "{$key} = {$item}\n"; else $content .= "{$key} = \"{$item}\"\n"; } } if(!$handle = fopen($path, 'w')) { return false; } if(!fwrite($handle, $content)) { return false; } fclose($handle); return true; } ?> |