[PC-BSD Commits] r8025 - in websites/pbidir.com: . bibivu/bin bibivu/sbin bibivu/slib bibivu/tpl/css/jquery bibivu/tpl/pbidir/images/download
svn at pcbsd.org
svn at pcbsd.org
Sat Nov 13 06:34:33 PST 2010
Author: fabry
Date: 2010-11-13 06:34:33 -0800 (Sat, 13 Nov 2010)
New Revision: 8025
Added:
websites/pbidir.com/bibivu/bin/updater.php
websites/pbidir.com/bibivu/tpl/css/jquery/jquery.lightbox-0.5.css
websites/pbidir.com/bibivu/tpl/pbidir/images/download/download.gif
websites/pbidir.com/bibivu/tpl/pbidir/images/download/download.png
Modified:
websites/pbidir.com/
websites/pbidir.com/bibivu/bin/bibivu_cron.php
websites/pbidir.com/bibivu/bin/start.php
websites/pbidir.com/bibivu/sbin/config.php
websites/pbidir.com/bibivu/slib/sessions.php
websites/pbidir.com/index.php
Log:
- bug fixes
- starting to work on automatic pbi releases import
- committed a possible system that will allow to send updates to the clients
Property changes on: websites/pbidir.com
___________________________________________________________________
Added: svn:ignore
+ .settings
.buildpath
.project
Modified: websites/pbidir.com/bibivu/bin/bibivu_cron.php
===================================================================
--- websites/pbidir.com/bibivu/bin/bibivu_cron.php 2010-11-13 12:51:51 UTC (rev 8024)
+++ websites/pbidir.com/bibivu/bin/bibivu_cron.php 2010-11-13 14:34:33 UTC (rev 8025)
@@ -18,97 +18,158 @@
set_time_limit(0);
switch($task){
case 'mirrors':
- $mirrors = load_library('mirror');
- $tmps = $mirrors->get_all(array(),array('last_update DESC'));
- foreach($tmps as $key=>$value){
- $filters = array();
- $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y');
- $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$value['id']);
- $dt = $mirrors->get_record($filters)->update_mirror('PBI/.zupdate');
- if($this->is_web()){
- echo $value['id'].': '.$value['name'].' - '.$value['url'].' => '.$dt.'<br />';
- flush();
- }
- }
- return true;
+ $this->cron_mirrors();
break;
case 'pbis_watcher':
-// $list = explode("\n",`/usr/local/bin/rsync --list-only -vaz isc.pcbsd.org::ftp | grep " PBI/" | sed -e "s,.* PBI/,PBI/,g" `);
- $list = explode("\n",`/usr/local/bin/rsync --list-only -vaz isc.pcbsd.org::ftp | sed -e "s,.* ,,g" `);
- $pbi_releases = load_library('pbi_release')->get_all();
- $list_problems = array();
- $list_problems_no_status = array();
- foreach($pbi_releases as $key=>$pbi_release){
- if($this->is_web()){
- echo $pbi_release['id'].' => '.$pbi_release['mirror_path'].' - ';
- }
- if($pbi_release['pbi_active']!='y' || $pbi_release['active']!='y'){
- if($this->is_web()){
- echo 'NOT ACTIVE<br />';
- }
- } elseif($pbi_release['current_status_id']==0 || $pbi_release['pbi_status_id']==0){
- $list_problems_no_status[] = $pbi_release;
- if($this->is_web()){
- echo 'NO STATUS<br />';
- }
- } else {
- $pbi_release['mirror_path'] = substr($pbi_release['mirror_path'],0,1)=='/'?substr($pbi_release['mirror_path'],1):$pbi_release['mirror_path'];
- if(!in_array($pbi_release['mirror_path'],$list)){
- $list_problems[] = $pbi_release;
- if($this->is_web()){
- echo 'not found<br />';
- }
- } else {
- if($this->is_web()){
- echo 'ok<br />';
- }
- }
- }
+ $this->cron_pbis_watcher();
+ break;
+ case 'process_index':
+ $this->cron_process_index();
+ break;
+ default:
+ echo $task;
+ }
+// } else {
+// //BAD BOY.. showig a white page
+// }
+ }
+
+ private function cron_mirrors(){
+ $mirrors = load_library('mirror');
+ $tmps = $mirrors->get_all(array(),array('last_update DESC'));
+ foreach($tmps as $key=>$value){
+ $filters = array();
+ $filters[] = array('field'=>'active', 'operator'=>'=', 'value'=>'y');
+ $filters[] = array('field'=>'id', 'operator'=>'=', 'value'=>$value['id']);
+ $dt = $mirrors->get_record($filters)->update_mirror('PBI/.zupdate');
+ if($this->is_web()){
+ echo $value['id'].': '.$value['name'].' - '.$value['url'].' => '.$dt.'<br />';
+ flush();
+ }
+ }
+ return true;
+ }
+
+ private function cron_pbis_watcher(){
+// $list = explode("\n",`/usr/local/bin/rsync --list-only -vaz isc.pcbsd.org::ftp | grep " PBI/" | sed -e "s,.* PBI/,PBI/,g" `);
+ $list = explode("\n",`/usr/local/bin/rsync --list-only -vaz isc.pcbsd.org::ftp | sed -e "s,.* ,,g" `);
+ $pbi_releases = load_library('pbi_release')->get_all();
+ $list_problems = array();
+ $list_problems_no_status = array();
+ foreach($pbi_releases as $key=>$pbi_release){
+ if($this->is_web()){
+ echo $pbi_release['id'].' => '.$pbi_release['mirror_path'].' - ';
+ }
+ if($pbi_release['pbi_active']!='y' || $pbi_release['active']!='y'){
+ if($this->is_web()){
+ echo 'NOT ACTIVE<br />';
+ }
+ } elseif($pbi_release['current_status_id']==0 || $pbi_release['pbi_status_id']==0){
+ $list_problems_no_status[] = $pbi_release;
+ if($this->is_web()){
+ echo 'NO STATUS<br />';
+ }
+ } else {
+ $pbi_release['mirror_path'] = substr($pbi_release['mirror_path'],0,1)=='/'?substr($pbi_release['mirror_path'],1):$pbi_release['mirror_path'];
+ if(!in_array($pbi_release['mirror_path'],$list)){
+ $list_problems[] = $pbi_release;
+ if($this->is_web()){
+ echo 'not found<br />';
}
- $body = '';
- if(count($list_problems)>0){
- //there are soe problems...
- //going to send the problems via email
- //only to root users
- $body .= 'the PBI watcher script found that those PBIs are in pbidir.com, but not in the main mirror (isc.pcbsd.org::ftp)'."\n\n";
- foreach($list_problems as $key=>$pbi_release){
- $body .= $pbi_release['id'].' => '.$pbi_release['mirror_path']."\n";
- }
+ } else {
+ if($this->is_web()){
+ echo 'ok<br />';
}
- if(count($list_problems_no_status)>0){
- //there are soe problems...
- //going to send the problems via email
- //only to root users
- $body .= 'the PBI watcher script found that those PBIs (or one of their release) do not have a valid status, you may wat to inactivate them'."\n\n";
- foreach($list_problems_no_status as $key=>$pbi_release){
- $body .= $pbi_release['pbi_id'].' => '.$pbi_release['pbi']."\n";
+ }
+ }
+ }
+ $body = '';
+ if(count($list_problems)>0){
+ //there are soe problems...
+ //going to send the problems via email
+ //only to root users
+ $body .= 'the PBI watcher script found that those PBIs are in pbidir.com, but not in the main mirror (isc.pcbsd.org::ftp)'."\n\n";
+ foreach($list_problems as $key=>$pbi_release){
+ $body .= $pbi_release['id'].' => '.$pbi_release['mirror_path']."\n";
+ }
+ }
+ if(count($list_problems_no_status)>0){
+ //there are soe problems...
+ //going to send the problems via email
+ //only to root users
+ $body .= 'the PBI watcher script found that those PBIs (or one of their release) do not have a valid status, you may wat to inactivate them'."\n\n";
+ foreach($list_problems_no_status as $key=>$pbi_release){
+ $body .= $pbi_release['pbi_id'].' => '.$pbi_release['pbi']."\n";
+ }
+ }
+ if($body!=''){
+ if($this->is_web()){
+ $body .= "\n".'Manually execute from the web';
+ }
+ $filters = array();
+ $filters[] = array('field'=>'group_id', 'operator'=>'=', 'value'=>'1');
+ $filters[] = array('field'=>'status', 'operator'=>'=', 'value'=>'active');
+ $users = load_library('user')->get_all($filters);
+ $mail =& load_library('email');
+ foreach($users as $key=>$user){
+ $mail->AddAddress($user['email']);
+ }
+ $mail->From = 'pbi_watcher at pbidir.com';
+ $mail->FromName = 'pbiDir watcher';
+ $mail->Subject = 'pbi watcher problems report';
+ $mail->Body = $body;
+ $mail->CharSet = 'UTF-8';
+ $mail->Send();
+ }
+ return true;
+ }
+
+ private function cron_process_index(){
+ $index_file = USRPATH.'/pbi-index-9';
+ $index_content = file($index_file);
+ echo '<pre>';
+// echo 'What are the possible Values for "status"?'."\n";
+// echo 'If there is a question mark in the index of the dictionary, can you explain what the values in that field are?'."\n";
+// echo 'Is there anything else that I could find ? maybe a description for the release ?'."\n";
+// echo 'And finally, what is the URL to phpMyAdmin ? my old one gives me a 404'."\n";
+ if(is_array($index_content)){
+ foreach($index_content as $index_line){
+ $tmps = explode(':', $index_line);
+ if(is_array($tmps)){
+ $line['valid'] = 1;
+ $line['alias'] = trim($tmps[0]);
+ $line['bits'] = trim($tmps[1]);
+ $line['ver'] = trim($tmps[2]);
+ $line['md5'] = trim($tmps[3]);
+ $line['date?'] = trim($tmps[4]);
+ $line['path'] = trim($tmps[5]);
+ $line['??'] = trim($tmps[6]);
+ $line['???'] = trim($tmps[7]);
+ $line['status'] = trim($tmps[8]);
+ $line['svn_path'] = '/pbi/modules/'.str_replace('/PBI/', '', substr($line['path'],0,strpos($line['path'],$line['alias']))).$line['alias'];
+ $line['conf_path'] = '/pbi/modules/'.str_replace('/PBI/', '', substr($line['path'],0,strpos($line['path'],$line['alias']))).$line['alias'].'/pbi.conf';
+ $line['conf_web'] = 'http://trac.pcbsd.org/browser'.$line['conf_path'].'?format=txt';
+ //let's parse the conmfig file
+ $pbi_conf = @file_get_contents($line['conf_web']);
+ if($pbi_conf!=''){
+ if(preg_match('/PBI_PROGWEB="(.*)"/', $pbi_conf, $match)){
+ $line['website'] = $match[1];
}
- }
- if($body!=''){
- if($this->is_web()){
- $body .= "\n".'Manually execute from the web';
+ if(preg_match('/PBI_PROGAUTHOR="(.*)"/', $pbi_conf, $match)){
+ $line['author'] = $match[1];
}
- $filters = array();
- $filters[] = array('field'=>'group_id', 'operator'=>'=', 'value'=>'1');
- $filters[] = array('field'=>'status', 'operator'=>'=', 'value'=>'active');
- $users = load_library('user')->get_all($filters);
- $mail =& load_library('email');
- foreach($users as $key=>$user){
- $mail->AddAddress($user['email']);
+ if(preg_match('/PBI_PROGICON="(.*)"/', $pbi_conf, $match)){
+ $line['icon'] = $line['svn_path'].'/resources/'.$match[1];
}
- $mail->From = 'pbi_watcher at pbidir.com';
- $mail->FromName = 'pbiDir watcher';
- $mail->Subject = 'pbi watcher problems report';
- $mail->Body = $body;
- $mail->CharSet = 'UTF-8';
- $mail->Send();
+ } else {
+ $line['error'] = 'pbi.conf cannot be read !!';
+ $line['valid'] = 0;
}
- return true;
- break;
+ print_r($line);
+ flush();
+ }
}
-// } else {
-// //BAD BOY.. showig a white page
-// }
+ }
}
}
?>
\ No newline at end of file
Modified: websites/pbidir.com/bibivu/bin/start.php
===================================================================
--- websites/pbidir.com/bibivu/bin/start.php 2010-11-13 12:51:51 UTC (rev 8024)
+++ websites/pbidir.com/bibivu/bin/start.php 2010-11-13 14:34:33 UTC (rev 8025)
@@ -116,7 +116,7 @@
$this->display->assign('task',$task);
$this->{'web_'.$task}();
} else {
- if($this->uri->get_num(1)==''){
+ if($this->uri->get_num(1,'')==''){
$this->display->assign('task','home');
$this->web_home();
} else {
Modified: websites/pbidir.com/bibivu/sbin/config.php
===================================================================
--- websites/pbidir.com/bibivu/sbin/config.php 2010-11-13 12:51:51 UTC (rev 8024)
+++ websites/pbidir.com/bibivu/sbin/config.php 2010-11-13 14:34:33 UTC (rev 8025)
@@ -8,9 +8,10 @@
*/
class config{
private $_cfg = array();
+ private $loaded = array();
public function __construct(){
}
-
+
public function get($key, $default=NULL){
if(!isset($this->_cfg[$key])){
if(strpos($key,'_')>0){
@@ -24,42 +25,46 @@
}
return $this->_cfg[$key];
}
-
+
public function load_config($conf = 'bibivu'){
//Here I have to load the configuration
//from memcache
//from file
//from DB
- static $loaded = array();
//load the config only one time
- if($conf!='' && !isset($loaded[$conf])){
+ if($conf!='' && !isset($this->loaded[$conf])){
//starting with a file, if exists
//etc/bibivu.conf.php
if(file_exists(ETCPATH.$conf.'.conf'.EXT)){
- require_once ETCPATH.$conf.'.conf'.EXT;
+ include ETCPATH.$conf.'.conf'.EXT;
if(isset($$conf)){
$this->_cfg[$conf] = $$conf;
-/*
- if(is_array($this->_cfg[$conf])){
- //need to create variables like VAR_firstElement
- foreach($this->_cfg[$conf] as $key=>$value){
- $this->_cfg[$conf.'_'.$key] = $value;
- }
- }
-*/
}
}
}
- $loaded[$conf] = true;
+ $this->loaded[$conf] = true;
return $this;
}
-
+
+ public function unload_config($conf = 'bibivu'){
+ //Here I have to load the configuration
+ //from memcache
+ //from file
+ //from DB
+ //load the config only one time
+ if($conf!=''){
+ unset($this->loaded[$conf]);
+ unset($this->_cfg[$conf]);
+ }
+ return $this;
+ }
+
public function set($key, $value){
$this->_cfg[$key] = $value;
$this->save_config();
return $this;
}
-
+
private function save_config(){
//Here I have to set the configuration
//to memcache
Modified: websites/pbidir.com/bibivu/slib/sessions.php
===================================================================
--- websites/pbidir.com/bibivu/slib/sessions.php 2010-11-13 12:51:51 UTC (rev 8024)
+++ websites/pbidir.com/bibivu/slib/sessions.php 2010-11-13 14:34:33 UTC (rev 8025)
@@ -10,13 +10,14 @@
$this->config['savepath'] = false;
$this->config['linksid'] = false;
$config = load_class('config')->load_config('sessions')->get('sessions');
+ load_class('config')->unload_config('sessions'); //cleaning up memory
if(is_array($config)){
foreach($config as $key=>$value){
$this->config[$key]=$value;
}
}
}
-
+
public function start(){
if(headers_sent()){
return false;
@@ -25,10 +26,31 @@
if($this->config['savepath']!== false) ini_set('session.save_path',$this->config['savepath']);
if($this->config['linksid']!== false) ini_set('session.use_trans_sid',1);
session_name($this->config['name']);
+ //this needs to be done a bit better to avoid session injections
+ //but it may work for now - GET first then POST
+ if(isset($_GET[session_name()]) && trim($_GET[session_name()])!=''){
+ @session_id($this->_sanitize_session_id($_GET[session_name()]));
+ }elseif(isset($_POST[session_name()]) && trim($_POST[session_name()])!=''){
+ @session_id($this->_sanitize_session_id($_POST[session_name()]));
+ }
session_start();
return true;
}
}
+
+ private function _sanitize_session_id($session_id){
+ return preg_replace('/[^a-z0-9-,]/i','',$session_id);
+ }
+
+ public function get_id(){
+ $sid = session_id();
+ if($sid==''){
+ //no session started??? let's start one
+ session_start();
+ }
+ return session_id();
+ }
+
/**
* Set session
*
@@ -43,7 +65,7 @@
public function set($name = '', $value = ''){
return $_SESSION[$this->config['prefix'].$name] = $value;
}
-
+
/**
* Fetch an item from the SESSION array
*
@@ -58,19 +80,19 @@
return NULL;
}
}
-
+
/**
* Delete a SESSION
*
* @param mixed
* @return void
*/
- public function delete($name = ''){
+ public function delete($key = ''){
if(isset($_SESSION[$this->config['prefix'].$key])){
unset($_SESSION[$this->config['prefix'].$key]);
}
}
-
+
/**
* Delete all the SESSIONs
*
@@ -91,5 +113,36 @@
return array();
}
}
+
+ /**
+ * RESET a session, close the current session
+ *
+ * @return void
+ */
+ public function reset(){
+ $this->delete_all();
+ if (ini_get('session.use_cookies')) {
+ $params = session_get_cookie_params();
+ setcookie(session_name(), '', time() - 42000,
+ $params['path'], $params['domain'],
+ $params['secure'], $params['httponly']
+ );
+ unset($_COOKIE[session_name()]);
+ }
+ session_destroy();
+ session_regenerate_id();
+ }
+
+ /**
+ * RESET a session, close the current session and creates a new one
+ *
+ * @return void
+ */
+ public function restart(){
+ unset($_GET[session_name()]);
+ unset($_POST[session_name()]);
+ $this->reset();
+ $this->start();
+ }
}
?>
\ No newline at end of file
Property changes on: websites/pbidir.com/bibivu/tpl/css/jquery/jquery.lightbox-0.5.css
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Property changes on: websites/pbidir.com/bibivu/tpl/pbidir/images/download/download.gif
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Property changes on: websites/pbidir.com/bibivu/tpl/pbidir/images/download/download.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: websites/pbidir.com/index.php
===================================================================
--- websites/pbidir.com/index.php 2010-11-13 12:51:51 UTC (rev 8024)
+++ websites/pbidir.com/index.php 2010-11-13 14:34:33 UTC (rev 8025)
@@ -135,7 +135,7 @@
$uri = load_class('uri', true, $config);
$startup = $uri->get(CLASS_KEY);
if($startup=='' || !load_class($startup, true)){
- $uri->set(CLASS_KEY,STARTUP);
+// $uri->set(CLASS_KEY,STARTUP);
load_class(STARTUP, true);
}
/*
More information about the Commits
mailing list