Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2007-07-26 19:23:57


Author: dgregor
Date: 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
New Revision: 7554
URL: http://svn.boost.org/trac/boost/changeset/7554

Log:
Fix eol-style and mime-types
Properties modified:
   svnmanager/.htaccess (contents, props changed)
   svnmanager/GroupModule/AdminPage.php (contents, props changed)
   svnmanager/GroupModule/CreatePage.php (contents, props changed)
   svnmanager/GroupModule/DataModule.php (contents, props changed)
   svnmanager/GroupModule/EditPage.php (contents, props changed)
   svnmanager/GroupModule/EditSelectPage.php (contents, props changed)
   svnmanager/GroupModule/RemovePage.php (contents, props changed)
   svnmanager/MainModule/DataModule.php (contents, props changed)
   svnmanager/MainModule/StartPage.php (contents, props changed)
   svnmanager/RepositoryModule/AdminPage.php (contents, props changed)
   svnmanager/RepositoryModule/CreatePage.php (contents, props changed)
   svnmanager/RepositoryModule/DataModule.php (props changed)
   svnmanager/RepositoryModule/DumpAnnouncePage.php (contents, props changed)
   svnmanager/RepositoryModule/DumpOutputPage.php (contents, props changed)
   svnmanager/RepositoryModule/DumpPage.php (contents, props changed)
   svnmanager/RepositoryModule/EditPage.php (contents, props changed)
   svnmanager/RepositoryModule/EditSelectPage.php (contents, props changed)
   svnmanager/RepositoryModule/GroupPrivilegesEditPage.php (props changed)
   svnmanager/RepositoryModule/GroupPrivilegesPage.php (contents, props changed)
   svnmanager/RepositoryModule/LoadPage.php (contents, props changed)
   svnmanager/RepositoryModule/RecoverPage.php (contents, props changed)
   svnmanager/RepositoryModule/RemovePage.php (contents, props changed)
   svnmanager/RepositoryModule/UserPrivilegesEditPage.php (props changed)
   svnmanager/RepositoryModule/UserPrivilegesPage.php (contents, props changed)
   svnmanager/UserModule/ActivatePage.php (contents, props changed)
   svnmanager/UserModule/AddPage.php (contents, props changed)
   svnmanager/UserModule/AdminPage.php (contents, props changed)
   svnmanager/UserModule/DataModule.php (contents, props changed)
   svnmanager/UserModule/EditPage.php (contents, props changed)
   svnmanager/UserModule/EditSelectPage.php (contents, props changed)
   svnmanager/UserModule/InvitePage.php (contents, props changed)
   svnmanager/UserModule/LoginPage.php (contents, props changed)
   svnmanager/UserModule/RemovePage.php (contents, props changed)
   svnmanager/global/MenuBar.php (contents, props changed)
   svnmanager/global/SVNManagerUser.php (contents, props changed)
   svnmanager/library/class.accessfile.php (contents, props changed)
   svnmanager/library/class.phpmailer.php (props changed)
   svnmanager/library/class.smtp.php (contents, props changed)
Text files modified:
   svnmanager/.htaccess | 2
   svnmanager/GroupModule/AdminPage.php | 62
   svnmanager/GroupModule/CreatePage.php | 108 +-
   svnmanager/GroupModule/DataModule.php | 232 ++--
   svnmanager/GroupModule/EditPage.php | 342 +++---
   svnmanager/GroupModule/EditSelectPage.php | 96
   svnmanager/GroupModule/RemovePage.php | 114 +-
   svnmanager/MainModule/DataModule.php | 238 ++--
   svnmanager/MainModule/StartPage.php | 40
   svnmanager/RepositoryModule/AdminPage.php | 94
   svnmanager/RepositoryModule/CreatePage.php | 118 +-
   svnmanager/RepositoryModule/DumpAnnouncePage.php | 78
   svnmanager/RepositoryModule/DumpOutputPage.php | 94
   svnmanager/RepositoryModule/DumpPage.php | 98
   svnmanager/RepositoryModule/EditPage.php | 246 ++--
   svnmanager/RepositoryModule/EditSelectPage.php | 96
   svnmanager/RepositoryModule/GroupPrivilegesPage.php | 96
   svnmanager/RepositoryModule/LoadPage.php | 208 ++--
   svnmanager/RepositoryModule/RecoverPage.php | 146 +-
   svnmanager/RepositoryModule/RemovePage.php | 128 +-
   svnmanager/RepositoryModule/UserPrivilegesPage.php | 96
   svnmanager/UserModule/ActivatePage.php | 146 +-
   svnmanager/UserModule/AddPage.php | 130 +-
   svnmanager/UserModule/AdminPage.php | 78
   svnmanager/UserModule/DataModule.php | 350 +++---
   svnmanager/UserModule/EditPage.php | 360 +++---
   svnmanager/UserModule/EditSelectPage.php | 122 +-
   svnmanager/UserModule/InvitePage.php | 292 ++--
   svnmanager/UserModule/LoginPage.php | 58
   svnmanager/UserModule/RemovePage.php | 106 +-
   svnmanager/global/MenuBar.php | 92
   svnmanager/global/SVNManagerUser.php | 436 ++++----
   svnmanager/library/class.accessfile.php | 382 +++---
   svnmanager/library/class.smtp.php | 2078 ++++++++++++++++++++--------------------
   34 files changed, 3681 insertions(+), 3681 deletions(-)

Modified: svnmanager/.htaccess
==============================================================================
--- svnmanager/.htaccess (original)
+++ svnmanager/.htaccess 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1 +1 @@
-deny from all
+deny from all

Modified: svnmanager/GroupModule/AdminPage.php
==============================================================================
--- svnmanager/GroupModule/AdminPage.php (original)
+++ svnmanager/GroupModule/AdminPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,32 +1,32 @@
-<?php
-class AdminPage extends TPage
-{
-
- public function onInit($param)
- {
- parent::onInit($param);
- $this->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
-
- public function onClickCreateBtn($sender, $param)
- {
- $this->Application->transfer("Group:CreatePage");
- }
-
- public function onClickRemoveBtn($sender, $param)
- {
- $this->Application->transfer("Group:RemovePage");
- }
-
- public function onClickEditBtn($sender, $param)
- {
- $this->Application->transfer("Group:EditSelectPage");
- }
-
-}
+<?php
+class AdminPage extends TPage
+{
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $this->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+
+ public function onClickCreateBtn($sender, $param)
+ {
+ $this->Application->transfer("Group:CreatePage");
+ }
+
+ public function onClickRemoveBtn($sender, $param)
+ {
+ $this->Application->transfer("Group:RemovePage");
+ }
+
+ public function onClickEditBtn($sender, $param)
+ {
+ $this->Application->transfer("Group:EditSelectPage");
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/GroupModule/CreatePage.php
==============================================================================
--- svnmanager/GroupModule/CreatePage.php (original)
+++ svnmanager/GroupModule/CreatePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,54 +1,54 @@
-<?php
-/*
- * Created on 31-Jan-2005
- *
- */
-class CreatePage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
-
- public function isNotTaken($sender, $param)
- {
- $name = $this->Name->getText();
- $param->isValid=!$this->Module->isTaken($name);
- }
-
- public function onConfirmBtn($sender, $param)
- {
- if($this->IsValid)
- {
- $name = $this->Name->Text;
- $groupid = $this->Module->createGroup($name );
- //$this->Application->transfer("Group:AdminPage");
- $this->CreatePanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
-
- $this->setViewState('GroupID', $groupid, '');
- }
-
- }
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer("Group:AdminPage");
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Group:AdminPage");
- }
-
- public function onEdit($sender, $param)
- {
- $groupid = $this->getViewState('GroupID', '');
- $this->Application->transfer('Group:EditPage', array('GroupID' => $groupid) );
- }
-}
-?>
+<?php
+/*
+ * Created on 31-Jan-2005
+ *
+ */
+class CreatePage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+
+ public function isNotTaken($sender, $param)
+ {
+ $name = $this->Name->getText();
+ $param->isValid=!$this->Module->isTaken($name);
+ }
+
+ public function onConfirmBtn($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ $name = $this->Name->Text;
+ $groupid = $this->Module->createGroup($name );
+ //$this->Application->transfer("Group:AdminPage");
+ $this->CreatePanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+
+ $this->setViewState('GroupID', $groupid, '');
+ }
+
+ }
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer("Group:AdminPage");
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Group:AdminPage");
+ }
+
+ public function onEdit($sender, $param)
+ {
+ $groupid = $this->getViewState('GroupID', '');
+ $this->Application->transfer('Group:EditPage', array('GroupID' => $groupid) );
+ }
+}
+?>

Modified: svnmanager/GroupModule/DataModule.php
==============================================================================
--- svnmanager/GroupModule/DataModule.php (original)
+++ svnmanager/GroupModule/DataModule.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,117 +1,117 @@
-<?php
-/*
- * Created on 17-Jan-2005
- *
- * DataModule of groups, where all actual changes into database and
- * input file regarding Groups are done.
- *
- */
-using('System.Data');
-
-class DataModule extends TModule
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- require("config.php");
- $this->Database->setDataSourceName($dsn);
- }
-
- public function getUsername($id)
- {
- $user = $this->Database->Execute("SELECT * FROM users WHERE id='$id'");
- if($user)
- return $user->fields['name'];
- else
- return null;
- }
-
- public function getUserId($name)
- {
- $id = $this->Database->Execute("SELECT * FROM users WHERE name='$name'");
- if($id)
- return $id->fields['id'];
- else
- return null;
- }
-
- public function removeUser($id, $userid)
- {
- $exists = $this->Database->Execute("SELECT * FROM usersgroups WHERE userid='$userid' AND groupid='$id'");
- if($exists->recordCount()>0)
- {
- $result = $this->Database->Execute("DELETE FROM usersgroups WHERE userid='$userid' AND groupid='$id'");
- $this->rebuildAccessFile();
- }
- $exists->Close();
- }
-
- public function addUser($id, $userid)
- {
- $exists = $this->Database->Execute("SELECT * FROM usersgroups WHERE userid='$userid' AND groupid='$id'");
- if($exists->recordCount()==0)
- {
- $result = $this->Database->Execute("INSERT INTO usersgroups (userid, groupid) VALUES ('$userid', '$id')");
- $result->Close();
- $this->rebuildAccessFile();
- }
- $exists->Close();
-
- }
-
- public function isTaken($name)
- {
- $result = $this->Database->Execute("SELECT * FROM groups WHERE name='$name'");
- return $result->RecordCount() > 0;
- }
-
- public function createGroup($name)
- {
- $userid = $this->User->getId();
- $result = $this->Database->Execute("INSERT INTO groups (id, name, adminid) VALUES (null, '$name', '$userid')");
- $groupid = $this->Database->Insert_ID();
- $result->Close();
- $this->rebuildAccessFile();
- return $groupid;
- }
-
- public function deleteGroup($id)
- {
- //Delete access of group
- $result = $this->Database->Execute("DELETE FROM groupprivileges WHERE groupid='$id'");
- $result->Close();
- $result = $this->Database->Execute("DELETE FROM groups WHERE id='$id'");
- $result->Close();
- $this->rebuildAccessFile();
- }
-
- public function renameGroup($id, $newname)
- {
- $result = $this->Database->Execute("UPDATE groups SET name='$newname' WHERE id='$id'");
- $result->Close();
- $this->rebuildAccessFile();
- }
-
- public function changeGroupOwner($id, $newownerid)
- {
- $result = $this->Database->Execute("UPDATE groups SET adminid='$newownerid' WHERE id='$id'");
- $result->Close();
- $this->rebuildAccessFile();
- }
-
- public function areGroups()
- {
- $result = $this->Database->Execute("SELECT * FROM groups");
- return $result->recordCount()>0;
- }
-
- function rebuildAccessFile()
- {
- require_once("./svnmanager/library/class.accessfile.php");
- $accessfile = new AccessFile();
- $accessfile->createFromDatabase();
- }
-
-}
+<?php
+/*
+ * Created on 17-Jan-2005
+ *
+ * DataModule of groups, where all actual changes into database and
+ * input file regarding Groups are done.
+ *
+ */
+using('System.Data');
+
+class DataModule extends TModule
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ require("config.php");
+ $this->Database->setDataSourceName($dsn);
+ }
+
+ public function getUsername($id)
+ {
+ $user = $this->Database->Execute("SELECT * FROM users WHERE id='$id'");
+ if($user)
+ return $user->fields['name'];
+ else
+ return null;
+ }
+
+ public function getUserId($name)
+ {
+ $id = $this->Database->Execute("SELECT * FROM users WHERE name='$name'");
+ if($id)
+ return $id->fields['id'];
+ else
+ return null;
+ }
+
+ public function removeUser($id, $userid)
+ {
+ $exists = $this->Database->Execute("SELECT * FROM usersgroups WHERE userid='$userid' AND groupid='$id'");
+ if($exists->recordCount()>0)
+ {
+ $result = $this->Database->Execute("DELETE FROM usersgroups WHERE userid='$userid' AND groupid='$id'");
+ $this->rebuildAccessFile();
+ }
+ $exists->Close();
+ }
+
+ public function addUser($id, $userid)
+ {
+ $exists = $this->Database->Execute("SELECT * FROM usersgroups WHERE userid='$userid' AND groupid='$id'");
+ if($exists->recordCount()==0)
+ {
+ $result = $this->Database->Execute("INSERT INTO usersgroups (userid, groupid) VALUES ('$userid', '$id')");
+ $result->Close();
+ $this->rebuildAccessFile();
+ }
+ $exists->Close();
+
+ }
+
+ public function isTaken($name)
+ {
+ $result = $this->Database->Execute("SELECT * FROM groups WHERE name='$name'");
+ return $result->RecordCount() > 0;
+ }
+
+ public function createGroup($name)
+ {
+ $userid = $this->User->getId();
+ $result = $this->Database->Execute("INSERT INTO groups (id, name, adminid) VALUES (null, '$name', '$userid')");
+ $groupid = $this->Database->Insert_ID();
+ $result->Close();
+ $this->rebuildAccessFile();
+ return $groupid;
+ }
+
+ public function deleteGroup($id)
+ {
+ //Delete access of group
+ $result = $this->Database->Execute("DELETE FROM groupprivileges WHERE groupid='$id'");
+ $result->Close();
+ $result = $this->Database->Execute("DELETE FROM groups WHERE id='$id'");
+ $result->Close();
+ $this->rebuildAccessFile();
+ }
+
+ public function renameGroup($id, $newname)
+ {
+ $result = $this->Database->Execute("UPDATE groups SET name='$newname' WHERE id='$id'");
+ $result->Close();
+ $this->rebuildAccessFile();
+ }
+
+ public function changeGroupOwner($id, $newownerid)
+ {
+ $result = $this->Database->Execute("UPDATE groups SET adminid='$newownerid' WHERE id='$id'");
+ $result->Close();
+ $this->rebuildAccessFile();
+ }
+
+ public function areGroups()
+ {
+ $result = $this->Database->Execute("SELECT * FROM groups");
+ return $result->recordCount()>0;
+ }
+
+ function rebuildAccessFile()
+ {
+ require_once("./svnmanager/library/class.accessfile.php");
+ $accessfile = new AccessFile();
+ $accessfile->createFromDatabase();
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/GroupModule/EditPage.php
==============================================================================
--- svnmanager/GroupModule/EditPage.php (original)
+++ svnmanager/GroupModule/EditPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,172 +1,172 @@
-<?php
-
-class EditPage extends TPage
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- $groupid = $_GET['GroupID'];
-
- $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE id='$groupid'");
-
- $fields = $results->fields;
- $adminid = $fields['adminid'];
-
- if(!$this->User->isAdmin() && $this->User->getId()!=$adminid)
- {
- echo "Not enough rights to change this group!";
- exit(-1);
- }
-
- if(!$this->isPostBack())
- {
- $name = $fields['name'];
-
- $members = array();
- $membernames = array();
-
- $membresults = $this->Module->Database->Execute("SELECT * FROM usersgroups WHERE groupid='$groupid'");
-
- while(!$membresults->EOF)
- {
- $fields = $membresults->fields;
- $members[] = $fields['userid'];
- $membernames[] = $this->Module->getUsername($fields['userid']);
- $membresults->MoveNext();
- }
- $membresults->Close();
-
- $group = array(
- 'id' => $groupid,
- 'name' => $name,
- 'adminid' => $adminid,
- 'members' => $members,
- 'membernames' => $membernames
- );
-
- $this->setSelectedGroup($group);
-
- $uresults = $this->Module->Database->Execute("SELECT * FROM users ORDER BY name");
- $users = array();
- while(!$uresults->EOF)
- {
- $users[] = $uresults->fields['name'];
- $uresults->MoveNext();
- }
- $uresults->Close();
- sort($users);
-
- $this->Owner->setDataSource($users);
- $this->Members->setDataSource($users);
- $this->dataBind();
-
- $this->Name->setText($name);
-
- $items=$this->Owner->Items;
- $ownername = $this->Module->getUsername($adminid);
- foreach($items as $item)
- if($item->getText()==$ownername)
- $item->setSelected(true);
- else
- $item->setSelected(false);
-
- $items=$this->Members->Items;
- foreach($items as $item)
- $item->Selected=(in_array($item->Text, $membernames));
- }
- }
-
- public function isValidName($sender, $param)
- {
- $group = $this->getSelectedGroup();
- $name = $this->Name->getText();
-
- $param->isValid=false;
-
- if($name == $group['name'])
- $param->isValid=true;
- else
- {
- $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE name='$name'");
- if($results->RecordCount()==0)
- $param->isValid=true;
- }
- return;
- }
-
- public function onConfirmButton($sender, $param)
- {
- if($this->IsValid)
- {
- $changes=false;
- $group=$this->getSelectedGroup();
-
- //Check if name is changed
- if($this->Name->getText()!=$group['name'])
- {
- $changes=true;
- $this->Module->renameGroup($group['id'], $this->Name->getText());
- }
-
- //Check if owner is changed
- if($this->Owner->getSelectedItem()->getText()!=$this->Module->getUsername($group['adminid']))
- {
- $newid = $this->Module->getUserId($this->Owner->getSelectedItem()->getText());
- $this->Module->changeGroupOwner($group['id'], $newid);
- }
-
- //Check if the members are changed
- $items=$this->Members->getItems();
- foreach($items as $item)
- {
- $mname = $item->getText();
-
- if($item->isSelected())
- {
- //New selected
- if(!in_array($mname, $group['membernames']))
- {
- $changes=true;
- $id = $this->Module->getUserId($mname);
- $this->Module->addUser($group['id'], $id);
- }
- } else {
- //New unselected
- if(in_array($mname, $group['membernames']))
- {
- $changes=true;
- $id = $this->Module->getUserId($mname);
- $this->Module->removeUser($group['id'], $id);
- }
- }
- }
-
- //$this->Application->transfer('Group:AdminPage');
- $this->ChangePanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
-
- }
- }
-
- public function onCancelButton($sender, $param)
- {
- $this->Application->transfer('Group:AdminPage');
- }
-
- public function setSelectedGroup($group)
- {
- $this->setViewState('SelectedGroup', $group, '');
- }
-
- public function getSelectedGroup()
- {
- return $this->getViewState('SelectedGroup', '');
- }
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Group:AdminPage");
- }
-
+<?php
+
+class EditPage extends TPage
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+
+ $groupid = $_GET['GroupID'];
+
+ $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE id='$groupid'");
+
+ $fields = $results->fields;
+ $adminid = $fields['adminid'];
+
+ if(!$this->User->isAdmin() && $this->User->getId()!=$adminid)
+ {
+ echo "Not enough rights to change this group!";
+ exit(-1);
+ }
+
+ if(!$this->isPostBack())
+ {
+ $name = $fields['name'];
+
+ $members = array();
+ $membernames = array();
+
+ $membresults = $this->Module->Database->Execute("SELECT * FROM usersgroups WHERE groupid='$groupid'");
+
+ while(!$membresults->EOF)
+ {
+ $fields = $membresults->fields;
+ $members[] = $fields['userid'];
+ $membernames[] = $this->Module->getUsername($fields['userid']);
+ $membresults->MoveNext();
+ }
+ $membresults->Close();
+
+ $group = array(
+ 'id' => $groupid,
+ 'name' => $name,
+ 'adminid' => $adminid,
+ 'members' => $members,
+ 'membernames' => $membernames
+ );
+
+ $this->setSelectedGroup($group);
+
+ $uresults = $this->Module->Database->Execute("SELECT * FROM users ORDER BY name");
+ $users = array();
+ while(!$uresults->EOF)
+ {
+ $users[] = $uresults->fields['name'];
+ $uresults->MoveNext();
+ }
+ $uresults->Close();
+ sort($users);
+
+ $this->Owner->setDataSource($users);
+ $this->Members->setDataSource($users);
+ $this->dataBind();
+
+ $this->Name->setText($name);
+
+ $items=$this->Owner->Items;
+ $ownername = $this->Module->getUsername($adminid);
+ foreach($items as $item)
+ if($item->getText()==$ownername)
+ $item->setSelected(true);
+ else
+ $item->setSelected(false);
+
+ $items=$this->Members->Items;
+ foreach($items as $item)
+ $item->Selected=(in_array($item->Text, $membernames));
+ }
+ }
+
+ public function isValidName($sender, $param)
+ {
+ $group = $this->getSelectedGroup();
+ $name = $this->Name->getText();
+
+ $param->isValid=false;
+
+ if($name == $group['name'])
+ $param->isValid=true;
+ else
+ {
+ $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE name='$name'");
+ if($results->RecordCount()==0)
+ $param->isValid=true;
+ }
+ return;
+ }
+
+ public function onConfirmButton($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ $changes=false;
+ $group=$this->getSelectedGroup();
+
+ //Check if name is changed
+ if($this->Name->getText()!=$group['name'])
+ {
+ $changes=true;
+ $this->Module->renameGroup($group['id'], $this->Name->getText());
+ }
+
+ //Check if owner is changed
+ if($this->Owner->getSelectedItem()->getText()!=$this->Module->getUsername($group['adminid']))
+ {
+ $newid = $this->Module->getUserId($this->Owner->getSelectedItem()->getText());
+ $this->Module->changeGroupOwner($group['id'], $newid);
+ }
+
+ //Check if the members are changed
+ $items=$this->Members->getItems();
+ foreach($items as $item)
+ {
+ $mname = $item->getText();
+
+ if($item->isSelected())
+ {
+ //New selected
+ if(!in_array($mname, $group['membernames']))
+ {
+ $changes=true;
+ $id = $this->Module->getUserId($mname);
+ $this->Module->addUser($group['id'], $id);
+ }
+ } else {
+ //New unselected
+ if(in_array($mname, $group['membernames']))
+ {
+ $changes=true;
+ $id = $this->Module->getUserId($mname);
+ $this->Module->removeUser($group['id'], $id);
+ }
+ }
+ }
+
+ //$this->Application->transfer('Group:AdminPage');
+ $this->ChangePanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+
+ }
+ }
+
+ public function onCancelButton($sender, $param)
+ {
+ $this->Application->transfer('Group:AdminPage');
+ }
+
+ public function setSelectedGroup($group)
+ {
+ $this->setViewState('SelectedGroup', $group, '');
+ }
+
+ public function getSelectedGroup()
+ {
+ return $this->getViewState('SelectedGroup', '');
+ }
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Group:AdminPage");
+ }
+
 }
\ No newline at end of file

Modified: svnmanager/GroupModule/EditSelectPage.php
==============================================================================
--- svnmanager/GroupModule/EditSelectPage.php (original)
+++ svnmanager/GroupModule/EditSelectPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,49 +1,49 @@
-<?php
-
-class EditSelectPage extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM groups ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE adminid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['adminid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'groupname' => $fields['name'],
- 'admin' => $owner
- );
-
- $results->MoveNext();
- $this->GroupTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onSelectGroup($sender, $param)
- {
- $groupid = $param->parameter;
- $this->Application->transfer('Group:EditPage', array('GroupID' => $groupid) );
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Group:AdminPage');
- }
-
-}
+<?php
+
+class EditSelectPage extends TPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM groups ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE adminid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['adminid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'groupname' => $fields['name'],
+ 'admin' => $owner
+ );
+
+ $results->MoveNext();
+ $this->GroupTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onSelectGroup($sender, $param)
+ {
+ $groupid = $param->parameter;
+ $this->Application->transfer('Group:EditPage', array('GroupID' => $groupid) );
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Group:AdminPage');
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/GroupModule/RemovePage.php
==============================================================================
--- svnmanager/GroupModule/RemovePage.php (original)
+++ svnmanager/GroupModule/RemovePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,58 +1,58 @@
-<?php
-class RemovePage extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM groups ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE adminid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['adminid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'groupname' => $fields['name'],
- 'admin' => $owner
- );
-
- $results->MoveNext();
- $this->GroupTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onDeleteGroup($sender, $param)
- {
- $id = $param->parameter;
- $this->Module->deleteGroup($id);
-
- $this->RemovePanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
-
- //$this->Application->transfer('Repository:AdminPage');
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Group:AdminPage');
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Group:AdminPage");
- }
-
-}
+<?php
+class RemovePage extends TPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM groups ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE adminid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['adminid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'groupname' => $fields['name'],
+ 'admin' => $owner
+ );
+
+ $results->MoveNext();
+ $this->GroupTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onDeleteGroup($sender, $param)
+ {
+ $id = $param->parameter;
+ $this->Module->deleteGroup($id);
+
+ $this->RemovePanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+
+ //$this->Application->transfer('Repository:AdminPage');
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Group:AdminPage');
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Group:AdminPage");
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/MainModule/DataModule.php
==============================================================================
--- svnmanager/MainModule/DataModule.php (original)
+++ svnmanager/MainModule/DataModule.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,120 +1,120 @@
-<?php
-/*
- * Created on 17-Jan-2005
- *
- */
-using('System.Data');
-
-class DataModule extends TModule
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- //$this->Database->setDataSourceName($this->Application->getUserParameter('DSN'));
-
- require("config.php");
- $this->Database->setDataSourceName($dsn);
- $this->Database->SetFetchMode("Associative");
- //echo "Checking database..<br\>";
-
- $tables = $this->Database->MetaTables();
-
- //If this is an empty database, we create the tables
- //(This is only tested with a sqlite database)
- if(sizeof($tables)==0)
- {
- //Create tables
- echo "No database found, trying to create one at config specified Data Source Name: $dsn!...";
-
- //Groupprivileges
- $this->Database->Execute(
- "CREATE TABLE groupprivileges (" .
- "id integer primary key," .
- "groupid integer not null default '0'," .
- "repositoryid integer not null default '0'," .
- "access tinyint(4) not null default '0'," .
- "path varchar(255) not null default ''" .
- ");" );
-
- //Groups
- $this->Database->Execute("
- CREATE TABLE groups (
- id integer primary key,
- name varchar(32) NOT NULL default '',
- adminid integer NOT NULL default '0'
- );");
-
- //Repositories
- $this->Database->Execute("
- CREATE TABLE repositories (
- id integer primary key,
- name varchar(32) NOT NULL default '',
- ownerid integer NOT NULL default '0'
- );
- ");
-
- $this->Database->Execute("
- CREATE TABLE userprivileges (
- id integer primary key,
- userid integer NOT NULL default '0',
- repositoryid integer NOT NULL default '0',
- access tinyint(4) NOT NULL default '0',
- path varchar(255) NOT NULL default ''
- );
- ");
-
-
- //Users
- $this->Database->Execute("
- CREATE TABLE users (
- id integer primary key,
- name varchar(32) NOT NULL default '',
- password varchar(32) NOT NULL default '',
- email varchar(128) NOT NULL default '',
- admin tinyint(4) NOT NULL default '0',
- repositorygrants tinyint(11) NOT NULL default '0'
- );
- ");
-
- //Usersgroups
- $this->Database->Execute("
- CREATE TABLE usersgroups (
- userid integer default '0',
- groupid integer default '0'
- );
- ");
-
- //Usertickets
- $this->Database->Execute("
- CREATE TABLE usertickets (
- email varchar(128) NOT NULL default '',
- ticket varchar(32) NOT NULL default '',
- repositorygrants tinyint(11) NOT NULL default '0'
- );
- ");
-
- echo "done!</br>";
- echo "Please reload page!";
- exit(0);
- }
-
- //Database should contain following tables
- $check = array();
- $check[]="groupprivileges";
- $check[]="groups";
- $check[]="repositories";
- $check[]="userprivileges";
- $check[]="users";
- $check[]="usersgroups";
- $check[]="usertickets";
-
- if($check!=$tables)
- {
- echo "Something wrong with database!";
- exit(-1);
- }
-
- }
-
-}
+<?php
+/*
+ * Created on 17-Jan-2005
+ *
+ */
+using('System.Data');
+
+class DataModule extends TModule
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ //$this->Database->setDataSourceName($this->Application->getUserParameter('DSN'));
+
+ require("config.php");
+ $this->Database->setDataSourceName($dsn);
+ $this->Database->SetFetchMode("Associative");
+ //echo "Checking database..<br\>";
+
+ $tables = $this->Database->MetaTables();
+
+ //If this is an empty database, we create the tables
+ //(This is only tested with a sqlite database)
+ if(sizeof($tables)==0)
+ {
+ //Create tables
+ echo "No database found, trying to create one at config specified Data Source Name: $dsn!...";
+
+ //Groupprivileges
+ $this->Database->Execute(
+ "CREATE TABLE groupprivileges (" .
+ "id integer primary key," .
+ "groupid integer not null default '0'," .
+ "repositoryid integer not null default '0'," .
+ "access tinyint(4) not null default '0'," .
+ "path varchar(255) not null default ''" .
+ ");" );
+
+ //Groups
+ $this->Database->Execute("
+ CREATE TABLE groups (
+ id integer primary key,
+ name varchar(32) NOT NULL default '',
+ adminid integer NOT NULL default '0'
+ );");
+
+ //Repositories
+ $this->Database->Execute("
+ CREATE TABLE repositories (
+ id integer primary key,
+ name varchar(32) NOT NULL default '',
+ ownerid integer NOT NULL default '0'
+ );
+ ");
+
+ $this->Database->Execute("
+ CREATE TABLE userprivileges (
+ id integer primary key,
+ userid integer NOT NULL default '0',
+ repositoryid integer NOT NULL default '0',
+ access tinyint(4) NOT NULL default '0',
+ path varchar(255) NOT NULL default ''
+ );
+ ");
+
+
+ //Users
+ $this->Database->Execute("
+ CREATE TABLE users (
+ id integer primary key,
+ name varchar(32) NOT NULL default '',
+ password varchar(32) NOT NULL default '',
+ email varchar(128) NOT NULL default '',
+ admin tinyint(4) NOT NULL default '0',
+ repositorygrants tinyint(11) NOT NULL default '0'
+ );
+ ");
+
+ //Usersgroups
+ $this->Database->Execute("
+ CREATE TABLE usersgroups (
+ userid integer default '0',
+ groupid integer default '0'
+ );
+ ");
+
+ //Usertickets
+ $this->Database->Execute("
+ CREATE TABLE usertickets (
+ email varchar(128) NOT NULL default '',
+ ticket varchar(32) NOT NULL default '',
+ repositorygrants tinyint(11) NOT NULL default '0'
+ );
+ ");
+
+ echo "done!</br>";
+ echo "Please reload page!";
+ exit(0);
+ }
+
+ //Database should contain following tables
+ $check = array();
+ $check[]="groupprivileges";
+ $check[]="groups";
+ $check[]="repositories";
+ $check[]="userprivileges";
+ $check[]="users";
+ $check[]="usersgroups";
+ $check[]="usertickets";
+
+ if($check!=$tables)
+ {
+ echo "Something wrong with database!";
+ exit(-1);
+ }
+
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/MainModule/StartPage.php
==============================================================================
--- svnmanager/MainModule/StartPage.php (original)
+++ svnmanager/MainModule/StartPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,20 +1,20 @@
-<?php
-/*
- * Created on 17-Jan-2005
- *
- */
-
-class StartPage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
-
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
-}
-?>
+<?php
+/*
+ * Created on 17-Jan-2005
+ *
+ */
+
+class StartPage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+}
+?>

Modified: svnmanager/RepositoryModule/AdminPage.php
==============================================================================
--- svnmanager/RepositoryModule/AdminPage.php (original)
+++ svnmanager/RepositoryModule/AdminPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,48 +1,48 @@
-<?php
-class AdminPage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- $this->dataBind();
- }
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
- public function onClickCreateBtn($sender, $param)
- {
- $this->Application->transfer("Repository:CreatePage");
- }
- public function onClickRemoveBtn($sender, $param)
- {
- $this->Application->transfer("Repository:RemovePage");
- }
- public function onClickEditBtn($sender, $param)
- {
- $this->Application->transfer("Repository:EditSelectPage");
- }
- public function onClickUserPrivilegesBtn($sender, $param)
- {
- $this->Application->transfer("Repository:UserPrivilegesPage");
- }
- public function onClickGroupPrivilegesBtn($sender, $param)
- {
- $this->Application->transfer("Repository:GroupPrivilegesPage");
- }
-
- public function onClickDumpBtn($sender, $param)
- {
- $this->Application->transfer("Repository:DumpPage");
- }
-
- public function onClickLoadBtn($sender, $param)
- {
- $this->Application->transfer("Repository:LoadPage");
- }
- public function onClickRecoverBtn($sender, $param)
- {
- $this->Application->transfer("Repository:RecoverPage");
- }
-}
+<?php
+class AdminPage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ $this->dataBind();
+ }
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+ public function onClickCreateBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:CreatePage");
+ }
+ public function onClickRemoveBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:RemovePage");
+ }
+ public function onClickEditBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:EditSelectPage");
+ }
+ public function onClickUserPrivilegesBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:UserPrivilegesPage");
+ }
+ public function onClickGroupPrivilegesBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:GroupPrivilegesPage");
+ }
+
+ public function onClickDumpBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:DumpPage");
+ }
+
+ public function onClickLoadBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:LoadPage");
+ }
+ public function onClickRecoverBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:RecoverPage");
+ }
+}
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/CreatePage.php
==============================================================================
--- svnmanager/RepositoryModule/CreatePage.php (original)
+++ svnmanager/RepositoryModule/CreatePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,59 +1,59 @@
-<?php
-/*
- * Created on 31-Jan-2005
- *
- */
-class CreatePage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
-
- public function isNotTaken($sender, $param)
- {
- $name = strtolower( $this->Name->getText() );
- $param->isValid=!$this->Module->isTaken($name);
- }
-
- public function onConfirmBtn($sender, $param)
- {
- if($this->IsValid)
- {
- $name = strtolower($this->Name->Text);
-
- //Decrease the number of repositorygrants of this (normal) user
- if(!$this->User->isAdmin())
- {
- $userid = $this->User->getId();
- $grants = $this->Module->getGrants($userid);
- $grants--;
- $this->Module->updateGrants($userid, $grants);
- }
-
- $this->Module->createRepository($this->User->getId(), $name );
- $this->CreatePanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- //$this->Application->transfer("Repository:AdminPage");
- }
-
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
-
-}
-?>
+<?php
+/*
+ * Created on 31-Jan-2005
+ *
+ */
+class CreatePage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+
+ public function isNotTaken($sender, $param)
+ {
+ $name = strtolower( $this->Name->getText() );
+ $param->isValid=!$this->Module->isTaken($name);
+ }
+
+ public function onConfirmBtn($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ $name = strtolower($this->Name->Text);
+
+ //Decrease the number of repositorygrants of this (normal) user
+ if(!$this->User->isAdmin())
+ {
+ $userid = $this->User->getId();
+ $grants = $this->Module->getGrants($userid);
+ $grants--;
+ $this->Module->updateGrants($userid, $grants);
+ }
+
+ $this->Module->createRepository($this->User->getId(), $name );
+ $this->CreatePanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ //$this->Application->transfer("Repository:AdminPage");
+ }
+
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
+
+}
+?>

Modified: svnmanager/RepositoryModule/DumpAnnouncePage.php
==============================================================================
--- svnmanager/RepositoryModule/DumpAnnouncePage.php (original)
+++ svnmanager/RepositoryModule/DumpAnnouncePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,40 +1,40 @@
-<?php
-class DumpAnnouncePage extends TPage
-{
-
- function OnInit($param)
- {
- parent::onInit($param);
-
- include("config.php");
-
- $repositoryid = $_GET['RepositoryID'];
-
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
- $fields = $results->fields;
- $ownerid = $fields['ownerid'];
- $name = $fields['name'];
-
- if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
- {
- echo "Not enough rights to change this repository!";
- exit(-1);
- }
-
- $servername =$_SERVER['SERVER_NAME'];
- $page = $_SERVER['PHP_SELF'];
- $url = "https://$servername$page?page=Repository:DumpOutputPage&RepositoryID=$repositoryid";
-
- $this->StartLink->setNavigateUrl("$url");
- header("Refresh: 3; URL=$url");
-
- }
-
- public function OnGoBack($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
-}
-
+<?php
+class DumpAnnouncePage extends TPage
+{
+
+ function OnInit($param)
+ {
+ parent::onInit($param);
+
+ include("config.php");
+
+ $repositoryid = $_GET['RepositoryID'];
+
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
+ $fields = $results->fields;
+ $ownerid = $fields['ownerid'];
+ $name = $fields['name'];
+
+ if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
+ {
+ echo "Not enough rights to change this repository!";
+ exit(-1);
+ }
+
+ $servername =$_SERVER['SERVER_NAME'];
+ $page = $_SERVER['PHP_SELF'];
+ $url = "https://$servername$page?page=Repository:DumpOutputPage&RepositoryID=$repositoryid";
+
+ $this->StartLink->setNavigateUrl("$url");
+ header("Refresh: 3; URL=$url");
+
+ }
+
+ public function OnGoBack($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
+}
+
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/DumpOutputPage.php
==============================================================================
--- svnmanager/RepositoryModule/DumpOutputPage.php (original)
+++ svnmanager/RepositoryModule/DumpOutputPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,48 +1,48 @@
-<?php
-class DumpOutputPage extends TPage
-{
-
- function OnInit($param)
- {
- parent::onInit($param);
-
- include("config.php");
-
- $repositoryid = $_GET['RepositoryID'];
-
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
- $fields = $results->fields;
- $ownerid = $fields['ownerid'];
- $name = $fields['name'];
-
-
- if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
- {
- echo "Not enough rights to change this repository!";
- exit(-1);
- }
-
- $filename = $name.".dump";
-
-
- if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {
- // IE Bug in download name workaround
- error_log("ini_set");
- ini_set( 'zlib.output_compression','Off' );
- }
-
- header('Cache-Control:');
- header('Pragma:');
- header( "Content-Type: application/octet-stream");
- header( "Content-Disposition: attachment; filename=\"$filename\"");
- header( "Content-Transfer-Encoding: binary" );
- passthru( $svnadmin_cmd." dump ".$svn_repos_loc.DIRECTORY_SEPARATOR.$name );
- exit(0);
- //$this->Application->transfer('Repository:AdminPage');
-
-
- }
-
-}
-
+<?php
+class DumpOutputPage extends TPage
+{
+
+ function OnInit($param)
+ {
+ parent::onInit($param);
+
+ include("config.php");
+
+ $repositoryid = $_GET['RepositoryID'];
+
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
+ $fields = $results->fields;
+ $ownerid = $fields['ownerid'];
+ $name = $fields['name'];
+
+
+ if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
+ {
+ echo "Not enough rights to change this repository!";
+ exit(-1);
+ }
+
+ $filename = $name.".dump";
+
+
+ if(isset($_SERVER['HTTP_USER_AGENT']) && preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT'])) {
+ // IE Bug in download name workaround
+ error_log("ini_set");
+ ini_set( 'zlib.output_compression','Off' );
+ }
+
+ header('Cache-Control:');
+ header('Pragma:');
+ header( "Content-Type: application/octet-stream");
+ header( "Content-Disposition: attachment; filename=\"$filename\"");
+ header( "Content-Transfer-Encoding: binary" );
+ passthru( $svnadmin_cmd." dump ".$svn_repos_loc.DIRECTORY_SEPARATOR.$name );
+ exit(0);
+ //$this->Application->transfer('Repository:AdminPage');
+
+
+ }
+
+}
+
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/DumpPage.php
==============================================================================
--- svnmanager/RepositoryModule/DumpPage.php (original)
+++ svnmanager/RepositoryModule/DumpPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,50 +1,50 @@
-<?php
-class DumpPage extends TPage
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['ownerid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'repositoryname' => $fields['name'],
- 'owner' => $owner
- );
-
- $results->MoveNext();
- $this->RepositoryTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onDumpRepository($sender, $param)
- {
- $id = $param->parameter;
-
- $this->Application->transfer('Repository:DumpAnnouncePage', array('RepositoryID' => $id));
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
-}
+<?php
+class DumpPage extends TPage
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['ownerid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'repositoryname' => $fields['name'],
+ 'owner' => $owner
+ );
+
+ $results->MoveNext();
+ $this->RepositoryTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onDumpRepository($sender, $param)
+ {
+ $id = $param->parameter;
+
+ $this->Application->transfer('Repository:DumpAnnouncePage', array('RepositoryID' => $id));
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/EditPage.php
==============================================================================
--- svnmanager/RepositoryModule/EditPage.php (original)
+++ svnmanager/RepositoryModule/EditPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,124 +1,124 @@
-<?php
-class EditPage extends TPage
-{
-
- public function onInit($param)
- {
- parent::onInit($param);
-
- $repositoryid = $_GET['RepositoryID'];
-
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
- $fields = $results->fields;
- $ownerid = $fields['ownerid'];
-
- if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
- {
- echo "Not enough rights to change this repository!";
- exit(-1);
- }
-
- $ownername = $this->Module->getUserName($ownerid);
-
- $repository = array(
- 'id' => $fields['id'],
- 'name' => $fields['name'],
- 'ownerid' => $ownerid,
- 'ownername' => $ownername,
- );
-
- $this->setSelectedRepository($repository);
-
- $this->Name->setText($fields['name']);
-
- $uresults = $this->Module->Database->Execute("SELECT name FROM users ORDER BY name");
-
- $users = array();
- while(!$uresults->EOF)
- {
- $users[] = $uresults->fields['name'];
- $uresults->MoveNext();
- }
- $uresults->Close();
- sort($users);
-
- $this->Owner->setDataSource($users);
- $this->dataBind();
-
- $items=$this->Owner->Items;
- foreach($items as $item)
- if($item->getText()==$ownername)
- $item->setSelected(true);
- else
- $item->setSelected(false);
-
- }
-
- public function isValidName($sender, $param)
- {
- $repository = $this->getSelectedRepository();
- $name = $this->Name->getText();
-
- $param->isValid=false;
-
- if($name == $repository['name'])
- $param->isValid=true;
- else
- {
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE name='$name'");
- if($results->RecordCount()==0)
- $param->isValid=true;
- }
- return;
- }
-
- public function setSelectedRepository($repos)
- {
- $this->setViewState('SelectedRepository', $repos, '');
- }
-
- public function getSelectedRepository()
- {
- return $this->getViewState('SelectedRepository', '');
- }
-
- public function onConfirmButton($sender, $param)
- {
- if($this->IsValid)
- {
- $changes=false;
- $repository=$this->getSelectedRepository();
-
- if($this->Name->getText()!=$repository['name'])
- {
- $this->Module->renameRepository($repository['id'], $this->Name->getText());
- }
-
- if($this->Owner->getSelectedItem()->getText()!=$repository['ownername'])
- {
- $newname = $this->Owner->getSelectedItem()->getText();
- error_log("name:$newname");
- $results = $this->Module->Database->Execute("SELECT id FROM users WHERE name='$newname'");
- $newownerid = $results->fields['id'];
- error_log("id:$newownerid");
- $results->Close();
-
- $this->Module->changeRepositoryOwner($repository['id'], $newownerid);
- }
-
- //$this->Application->transfer('Repository:AdminPage');
- $this->EditPanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- }
- }
- public function onCancelButton($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
+<?php
+class EditPage extends TPage
+{
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+
+ $repositoryid = $_GET['RepositoryID'];
+
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
+ $fields = $results->fields;
+ $ownerid = $fields['ownerid'];
+
+ if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
+ {
+ echo "Not enough rights to change this repository!";
+ exit(-1);
+ }
+
+ $ownername = $this->Module->getUserName($ownerid);
+
+ $repository = array(
+ 'id' => $fields['id'],
+ 'name' => $fields['name'],
+ 'ownerid' => $ownerid,
+ 'ownername' => $ownername,
+ );
+
+ $this->setSelectedRepository($repository);
+
+ $this->Name->setText($fields['name']);
+
+ $uresults = $this->Module->Database->Execute("SELECT name FROM users ORDER BY name");
+
+ $users = array();
+ while(!$uresults->EOF)
+ {
+ $users[] = $uresults->fields['name'];
+ $uresults->MoveNext();
+ }
+ $uresults->Close();
+ sort($users);
+
+ $this->Owner->setDataSource($users);
+ $this->dataBind();
+
+ $items=$this->Owner->Items;
+ foreach($items as $item)
+ if($item->getText()==$ownername)
+ $item->setSelected(true);
+ else
+ $item->setSelected(false);
+
+ }
+
+ public function isValidName($sender, $param)
+ {
+ $repository = $this->getSelectedRepository();
+ $name = $this->Name->getText();
+
+ $param->isValid=false;
+
+ if($name == $repository['name'])
+ $param->isValid=true;
+ else
+ {
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE name='$name'");
+ if($results->RecordCount()==0)
+ $param->isValid=true;
+ }
+ return;
+ }
+
+ public function setSelectedRepository($repos)
+ {
+ $this->setViewState('SelectedRepository', $repos, '');
+ }
+
+ public function getSelectedRepository()
+ {
+ return $this->getViewState('SelectedRepository', '');
+ }
+
+ public function onConfirmButton($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ $changes=false;
+ $repository=$this->getSelectedRepository();
+
+ if($this->Name->getText()!=$repository['name'])
+ {
+ $this->Module->renameRepository($repository['id'], $this->Name->getText());
+ }
+
+ if($this->Owner->getSelectedItem()->getText()!=$repository['ownername'])
+ {
+ $newname = $this->Owner->getSelectedItem()->getText();
+ error_log("name:$newname");
+ $results = $this->Module->Database->Execute("SELECT id FROM users WHERE name='$newname'");
+ $newownerid = $results->fields['id'];
+ error_log("id:$newownerid");
+ $results->Close();
+
+ $this->Module->changeRepositoryOwner($repository['id'], $newownerid);
+ }
+
+ //$this->Application->transfer('Repository:AdminPage');
+ $this->EditPanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ }
+ }
+ public function onCancelButton($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
 }
\ No newline at end of file

Modified: svnmanager/RepositoryModule/EditSelectPage.php
==============================================================================
--- svnmanager/RepositoryModule/EditSelectPage.php (original)
+++ svnmanager/RepositoryModule/EditSelectPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,49 +1,49 @@
-<?php
-class EditSelectPage extends TPage
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['ownerid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'repositoryname' => $fields['name'],
- 'owner' => $owner
- );
-
- $results->MoveNext();
- $this->RepositoryTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onSelectRepository($sender, $param)
- {
- $id = $param->parameter;
- $this->Application->transfer('Repository:EditPage', array('RepositoryID' => $id));
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
-}
+<?php
+class EditSelectPage extends TPage
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['ownerid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'repositoryname' => $fields['name'],
+ 'owner' => $owner
+ );
+
+ $results->MoveNext();
+ $this->RepositoryTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onSelectRepository($sender, $param)
+ {
+ $id = $param->parameter;
+ $this->Application->transfer('Repository:EditPage', array('RepositoryID' => $id));
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/GroupPrivilegesPage.php
==============================================================================
--- svnmanager/RepositoryModule/GroupPrivilegesPage.php (original)
+++ svnmanager/RepositoryModule/GroupPrivilegesPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,49 +1,49 @@
-<?php
-class GroupPrivilegesPage extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['ownerid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'repositoryname' => $fields['name'],
- 'owner' => $owner
- );
-
- $results->MoveNext();
- $this->RepositoryTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onSelectRepository($sender, $param)
- {
- $id = $param->parameter;
- $this->Application->transfer('Repository:GroupPrivilegesEditPage', array('RepositoryID' => $id));
-
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
-
+<?php
+class GroupPrivilegesPage extends TPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['ownerid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'repositoryname' => $fields['name'],
+ 'owner' => $owner
+ );
+
+ $results->MoveNext();
+ $this->RepositoryTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onSelectRepository($sender, $param)
+ {
+ $id = $param->parameter;
+ $this->Application->transfer('Repository:GroupPrivilegesEditPage', array('RepositoryID' => $id));
+
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+
 }
\ No newline at end of file

Modified: svnmanager/RepositoryModule/LoadPage.php
==============================================================================
--- svnmanager/RepositoryModule/LoadPage.php (original)
+++ svnmanager/RepositoryModule/LoadPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,104 +1,104 @@
-<?php
-/*
- * Created on 31-Jan-2005
- *
- */
-class LoadPage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- if(!$this->isPostBack() && !$this->Module->hasGrants())
- {
- echo "Not enough rights or grants to create Repository";
- exit(-1);
- }
-
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
-
- public function isNotTaken($sender, $param)
- {
- $name = $this->Name->getText();
- $param->isValid=!$this->Module->isTaken($name);
- }
-
- function onFileUploadFailed($sender,$param){
- switch($this->FileUpload->UploadError) {
- case UPLOAD_ERR_INI_SIZE:
- $message="The uploaded file exceeds the upload_max_filesize directive in php.ini.";
- break;
- case UPLOAD_ERR_FORM_SIZE:
- $message="The uploaded file exceeds the Maxfilesize";
- break;
- case UPLOAD_ERR_PARTIAL:
- $message="The uploaded file was only partially uploaded";
- break;
- case UPLOAD_ERR_NO_FILE:
- $message="No file was uploaded";
- break;
- case UPLOAD_ERR_NO_TMP_DIR:
- $message="Missing a temporary folder";
- break;
- default:
- $message="Unknown ErrorCode: " . $this->ImageUpload->UploadError;
- }
- $this->MessageLabel->SetText($message);
- }
-
- function onFileUpload($sender,$param) {
- $uploadedFile = $this->FileUpload->LocalName . ".dump";
- $this->setViewState('uploadedFile',$uploadedFile);
- copy($this->FileUpload->LocalName, $uploadedFile);
- }
-
- public function onConfirmBtn($sender, $param)
- {
- require("config.php");
-
- if($this->IsValid && $this->FileUpload->Uploaded)
- {
- //Decrease the number of repositorygrants of this (normal) user
- if(!$this->User->isAdmin())
- {
- $userid = $this->User->getId();
- $grants = $this->Module->getGrants($userid);
- $grants--;
- $this->Module->updateGrants($userid, $grants);
- }
-
- $name = $this->Name->Text;
- $this->Module->createRepository($this->User->getId(), $name );
-
- //Fill the Repository with dump file
- $uploadedFile = $this->getViewState('uploadedFile');
- exec($svnadmin_cmd." load ".$svn_repos_loc.DIRECTORY_SEPARATOR.$name." < $uploadedFile");
-
- //Remove the temporarily dump file
- unlink($uploadedFile);
-
- $this->FormPanel->setVisible(false);
- $this->SuccessPanel->setVisible(true);
-
- //$this->Application->transfer("Repository:AdminPage");
- }
-
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
-
-}
-?>
+<?php
+/*
+ * Created on 31-Jan-2005
+ *
+ */
+class LoadPage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if(!$this->isPostBack() && !$this->Module->hasGrants())
+ {
+ echo "Not enough rights or grants to create Repository";
+ exit(-1);
+ }
+
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+
+ public function isNotTaken($sender, $param)
+ {
+ $name = $this->Name->getText();
+ $param->isValid=!$this->Module->isTaken($name);
+ }
+
+ function onFileUploadFailed($sender,$param){
+ switch($this->FileUpload->UploadError) {
+ case UPLOAD_ERR_INI_SIZE:
+ $message="The uploaded file exceeds the upload_max_filesize directive in php.ini.";
+ break;
+ case UPLOAD_ERR_FORM_SIZE:
+ $message="The uploaded file exceeds the Maxfilesize";
+ break;
+ case UPLOAD_ERR_PARTIAL:
+ $message="The uploaded file was only partially uploaded";
+ break;
+ case UPLOAD_ERR_NO_FILE:
+ $message="No file was uploaded";
+ break;
+ case UPLOAD_ERR_NO_TMP_DIR:
+ $message="Missing a temporary folder";
+ break;
+ default:
+ $message="Unknown ErrorCode: " . $this->ImageUpload->UploadError;
+ }
+ $this->MessageLabel->SetText($message);
+ }
+
+ function onFileUpload($sender,$param) {
+ $uploadedFile = $this->FileUpload->LocalName . ".dump";
+ $this->setViewState('uploadedFile',$uploadedFile);
+ copy($this->FileUpload->LocalName, $uploadedFile);
+ }
+
+ public function onConfirmBtn($sender, $param)
+ {
+ require("config.php");
+
+ if($this->IsValid && $this->FileUpload->Uploaded)
+ {
+ //Decrease the number of repositorygrants of this (normal) user
+ if(!$this->User->isAdmin())
+ {
+ $userid = $this->User->getId();
+ $grants = $this->Module->getGrants($userid);
+ $grants--;
+ $this->Module->updateGrants($userid, $grants);
+ }
+
+ $name = $this->Name->Text;
+ $this->Module->createRepository($this->User->getId(), $name );
+
+ //Fill the Repository with dump file
+ $uploadedFile = $this->getViewState('uploadedFile');
+ exec($svnadmin_cmd." load ".$svn_repos_loc.DIRECTORY_SEPARATOR.$name." < $uploadedFile");
+
+ //Remove the temporarily dump file
+ unlink($uploadedFile);
+
+ $this->FormPanel->setVisible(false);
+ $this->SuccessPanel->setVisible(true);
+
+ //$this->Application->transfer("Repository:AdminPage");
+ }
+
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+
+}
+?>

Modified: svnmanager/RepositoryModule/RecoverPage.php
==============================================================================
--- svnmanager/RepositoryModule/RecoverPage.php (original)
+++ svnmanager/RepositoryModule/RecoverPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,74 +1,74 @@
-<?php
-class RecoverPage extends TPage
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['ownerid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'repositoryname' => $fields['name'],
- 'owner' => $owner
- );
-
- $results->MoveNext();
- $this->RepositoryTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onSelectRepository($sender, $param)
- {
- $repositoryid = $param->parameter;
- //$this->Application->transfer('Repository:EditPage', array('RepositoryID' => $id));
- include("config.php");
-
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
- $fields = $results->fields;
- $ownerid = $fields['ownerid'];
- $name = $fields['name'];
-
- if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
- {
- echo "Not enough rights to recover this repository!";
- exit(-1);
- }
-
- exec( $svnadmin_cmd." recover ".$svn_repos_loc.DIRECTORY_SEPARATOR.$name );
-
- $this->TablePanel->setVisible(false);
- $this->MessageLabel->setText("Tried to recover Repository!");
- $this->ResultPanel->setVisible(true);
-
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
-
-}
+<?php
+class RecoverPage extends TPage
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['ownerid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'repositoryname' => $fields['name'],
+ 'owner' => $owner
+ );
+
+ $results->MoveNext();
+ $this->RepositoryTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onSelectRepository($sender, $param)
+ {
+ $repositoryid = $param->parameter;
+ //$this->Application->transfer('Repository:EditPage', array('RepositoryID' => $id));
+ include("config.php");
+
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE id='$repositoryid'");
+ $fields = $results->fields;
+ $ownerid = $fields['ownerid'];
+ $name = $fields['name'];
+
+ if(!$this->User->isAdmin() && $this->User->getId()!=$ownerid)
+ {
+ echo "Not enough rights to recover this repository!";
+ exit(-1);
+ }
+
+ exec( $svnadmin_cmd." recover ".$svn_repos_loc.DIRECTORY_SEPARATOR.$name );
+
+ $this->TablePanel->setVisible(false);
+ $this->MessageLabel->setText("Tried to recover Repository!");
+ $this->ResultPanel->setVisible(true);
+
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/RemovePage.php
==============================================================================
--- svnmanager/RepositoryModule/RemovePage.php (original)
+++ svnmanager/RepositoryModule/RemovePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,65 +1,65 @@
-<?php
-class RemovePage extends TPage
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['ownerid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'repositoryname' => $fields['name'],
- 'owner' => $owner
- );
-
- $results->MoveNext();
- $this->RepositoryTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onDeleteRepository($sender, $param)
- {
- $id = $param->parameter;
- $this->Module->deleteRepository($id);
- //Increase the number of repositorygrants of this (normal) user
- if(!$this->User->isAdmin())
- {
- $userid = $this->User->getId();
- $grants = $this->Module->getGrants($userid);
- $grants++;
- $this->Module->updateGrants($userid, $grants);
- }
-
- $this->RemovePanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-
-}
+<?php
+class RemovePage extends TPage
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['ownerid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'repositoryname' => $fields['name'],
+ 'owner' => $owner
+ );
+
+ $results->MoveNext();
+ $this->RepositoryTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onDeleteRepository($sender, $param)
+ {
+ $id = $param->parameter;
+ $this->Module->deleteRepository($id);
+ //Increase the number of repositorygrants of this (normal) user
+ if(!$this->User->isAdmin())
+ {
+ $userid = $this->User->getId();
+ $grants = $this->Module->getGrants($userid);
+ $grants++;
+ $this->Module->updateGrants($userid, $grants);
+ }
+
+ $this->RemovePanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/RepositoryModule/UserPrivilegesPage.php
==============================================================================
--- svnmanager/RepositoryModule/UserPrivilegesPage.php (original)
+++ svnmanager/RepositoryModule/UserPrivilegesPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,49 +1,49 @@
-<?php
-class UserPrivilegesPage extends TPage
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- $userid = $this->User->getId();
-
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['ownerid']);
- $data[] = array(
- 'id' => $fields['id'],
- 'repositoryname' => $fields['name'],
- 'owner' => $owner
- );
-
- $results->MoveNext();
- $this->RepositoryTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onSelectRepository($sender, $param)
- {
- $id = $param->parameter;
- $this->Application->transfer('Repository:UserPrivilegesEditPage', array('RepositoryID' => $id));
-
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('Repository:AdminPage');
- }
-
-
+<?php
+class UserPrivilegesPage extends TPage
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $userid = $this->User->getId();
+
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['ownerid']);
+ $data[] = array(
+ 'id' => $fields['id'],
+ 'repositoryname' => $fields['name'],
+ 'owner' => $owner
+ );
+
+ $results->MoveNext();
+ $this->RepositoryTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onSelectRepository($sender, $param)
+ {
+ $id = $param->parameter;
+ $this->Application->transfer('Repository:UserPrivilegesEditPage', array('RepositoryID' => $id));
+
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('Repository:AdminPage');
+ }
+
+
 }
\ No newline at end of file

Modified: svnmanager/UserModule/ActivatePage.php
==============================================================================
--- svnmanager/UserModule/ActivatePage.php (original)
+++ svnmanager/UserModule/ActivatePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,73 +1,73 @@
-<?php
-/*
- * Created on 20-Jan-2005
- *
- */
-class ActivatePage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- if(isset($_GET['ticket']))
- {
- $this->setTicket($_GET['ticket']);
- }
- $this->dataBind();
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- }
-
- function getTicket()
- {
- return $this->getViewState('Ticket','');
- }
- function setTicket($value)
- {
- $this->setViewState('Ticket',$value,'');
- }
-
- function isValidTicket()
- {
- return $this->Module->isValidTicket($this->getTicket());
- }
-
- public function isUsernameTaken($sender,$param)
- {
- $param->isValid=!$this->Module->isUsernameTaken(strtolower($this->Username->Text));
- }
-
- public function onConfirmBtn($sender, $param)
- {
- $ticket = $this->Module->getTicket($this->getTicket());
-
- $username=strtolower($this->Username->Text);
- $fullname=$this->Fullname->Text;
- $password=$this->Password->Text;
-
- if($this->IsValid)
- {
-
- //Add user
- $this->Module->createAccount( $username,
- $fullname,
- $password,
- $ticket['email'],
- 0, //No admin rights
- $ticket['repositorygrants'],
- $ticket['groups'] );
-
- //Remove ticket
- $this->Module->removeTicket($this->getTicket());
-
- //Login
- $this->User->login($username, $password);
-
- $this->Application->Transfer("Main:StartPage");
-
- }
- }
-}
-?>
+<?php
+/*
+ * Created on 20-Jan-2005
+ *
+ */
+class ActivatePage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ if(isset($_GET['ticket']))
+ {
+ $this->setTicket($_GET['ticket']);
+ }
+ $this->dataBind();
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ }
+
+ function getTicket()
+ {
+ return $this->getViewState('Ticket','');
+ }
+ function setTicket($value)
+ {
+ $this->setViewState('Ticket',$value,'');
+ }
+
+ function isValidTicket()
+ {
+ return $this->Module->isValidTicket($this->getTicket());
+ }
+
+ public function isUsernameTaken($sender,$param)
+ {
+ $param->isValid=!$this->Module->isUsernameTaken(strtolower($this->Username->Text));
+ }
+
+ public function onConfirmBtn($sender, $param)
+ {
+ $ticket = $this->Module->getTicket($this->getTicket());
+
+ $username=strtolower($this->Username->Text);
+ $fullname=$this->Fullname->Text;
+ $password=$this->Password->Text;
+
+ if($this->IsValid)
+ {
+
+ //Add user
+ $this->Module->createAccount( $username,
+ $fullname,
+ $password,
+ $ticket['email'],
+ 0, //No admin rights
+ $ticket['repositorygrants'],
+ $ticket['groups'] );
+
+ //Remove ticket
+ $this->Module->removeTicket($this->getTicket());
+
+ //Login
+ $this->User->login($username, $password);
+
+ $this->Application->Transfer("Main:StartPage");
+
+ }
+ }
+}
+?>

Modified: svnmanager/UserModule/AddPage.php
==============================================================================
--- svnmanager/UserModule/AddPage.php (original)
+++ svnmanager/UserModule/AddPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,66 +1,66 @@
-<?php
-class AddPage extends TPage
-{
-
- public function onInit($param)
- {
- parent::onInit($param);
-
- }
-
- public function onCheckUsername($sender, $param)
- {
- $username = strtolower($this->UserName->getText());
- if(!$this->Module->isUsernameTaken($username))
- $param->isValid=true;
- else
- $param->isValid=false;
- return;
- }
-
- public function onCheckPassword($sender, $param)
- {
- $userid = $this->User->getId();
- $password = $this->UserPassword->getText();
-
- if($this->Module->checkPassword($userid, $password))
- $param->isValid=true;
- else
- $param->isValid=false;
- return;
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('User:AdminPage');
- }
-
- public function onConfirmBtn($sender, $param)
- {
- //Add user if parameters are validated
- if($this->isValid())
- {
- $username = strtolower($this->UserName->getText());
- $fullname = $this->FullName->getText();
- $password = $this->Password->getText();
- $email = $this->Email->getText();
- $grants = $this->Grants->getText();
- if($this->Admin->isChecked())
- $admin=255;
- else
- $admin=0;
-
- $this->Module->createAccount( $username, $fullname, $password, $email, $admin, $grants, "" );
-
- $this->AddPanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- }
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-
-}
+<?php
+class AddPage extends TPage
+{
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+
+ }
+
+ public function onCheckUsername($sender, $param)
+ {
+ $username = strtolower($this->UserName->getText());
+ if(!$this->Module->isUsernameTaken($username))
+ $param->isValid=true;
+ else
+ $param->isValid=false;
+ return;
+ }
+
+ public function onCheckPassword($sender, $param)
+ {
+ $userid = $this->User->getId();
+ $password = $this->UserPassword->getText();
+
+ if($this->Module->checkPassword($userid, $password))
+ $param->isValid=true;
+ else
+ $param->isValid=false;
+ return;
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('User:AdminPage');
+ }
+
+ public function onConfirmBtn($sender, $param)
+ {
+ //Add user if parameters are validated
+ if($this->isValid())
+ {
+ $username = strtolower($this->UserName->getText());
+ $fullname = $this->FullName->getText();
+ $password = $this->Password->getText();
+ $email = $this->Email->getText();
+ $grants = $this->Grants->getText();
+ if($this->Admin->isChecked())
+ $admin=255;
+ else
+ $admin=0;
+
+ $this->Module->createAccount( $username, $fullname, $password, $email, $admin, $grants, "" );
+
+ $this->AddPanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ }
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+
+}
 ?>
\ No newline at end of file

Modified: svnmanager/UserModule/AdminPage.php
==============================================================================
--- svnmanager/UserModule/AdminPage.php (original)
+++ svnmanager/UserModule/AdminPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,39 +1,39 @@
-<?php
-/*
- * Created on 19-jan-2005
- *
- */
-class AdminPage extends TPage
-{
- public function onInit($param)
- {
- parent::onInit($param);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->dataBind();
- }
-
- public function onClickInviteBtn($sender,$param)
- {
- $this->Application->transfer("User:InvitePage");
- }
-
- public function onClickEditBtn($sender,$param)
- {
- $this->Application->transfer("User:EditSelectPage");
- }
-
- public function onClickRemoveBtn($sender,$param)
- {
- $this->Application->transfer("User:RemovePage");
- }
-
- public function onClickAddBtn($sender, $param)
- {
- $this->Application->transfer("User:AddPage");
- }
-}
-?>
+<?php
+/*
+ * Created on 19-jan-2005
+ *
+ */
+class AdminPage extends TPage
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->dataBind();
+ }
+
+ public function onClickInviteBtn($sender,$param)
+ {
+ $this->Application->transfer("User:InvitePage");
+ }
+
+ public function onClickEditBtn($sender,$param)
+ {
+ $this->Application->transfer("User:EditSelectPage");
+ }
+
+ public function onClickRemoveBtn($sender,$param)
+ {
+ $this->Application->transfer("User:RemovePage");
+ }
+
+ public function onClickAddBtn($sender, $param)
+ {
+ $this->Application->transfer("User:AddPage");
+ }
+}
+?>

Modified: svnmanager/UserModule/DataModule.php
==============================================================================
--- svnmanager/UserModule/DataModule.php (original)
+++ svnmanager/UserModule/DataModule.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,48 +1,48 @@
-<?php
-/*
- * Created on 17-Jan-2005
- *
- */
-
-using('System.Data');
-
-class DataModule extends TModule
-{
- public function onLoad($param)
- {
- parent::onLoad($param);
- //$this->Database->setDataSourceName($this->Application->getUserParameter('DSN'));
- require("config.php");
- $this->Database->setDataSourceName($dsn);
- }
-
- public function loadAccount($name='')
- {
- if(empty($name))
- $name=$this->User->getUsername();
- $result=$this->Database->Execute("SELECT * FROM user WHERE name='$username'");
- if($result->RecordCount()>0)
- return $result->fields;
- else
- return null;
- }
-
- public function createAccount($name, $fullname, $password, $email, $admin, $repositorygrants, $groupstr)
- {
- require("config.php");
-
- //Add user to svn password file
- //Escape special strings in htpasswd command
- $password = eregi_replace('"', '\"', $password);
- if(!file_exists("$svn_passwd_file"))
- {
- exec("$htpassword_cmd -cmb $svn_passwd_file $name \"$password\"");
- } else {
- exec("$htpassword_cmd -bm $svn_passwd_file $name \"$password\"");
- }
-
- $md5_pw = md5($password);
- $account = $this->Database->Execute("INSERT INTO users (id, name, fullname, password, email, admin, repositorygrants) VALUES (null, '$name', '$fullname', '$md5_pw', '$email', '$admin', '$repositorygrants')");
+<?php
+/*
+ * Created on 17-Jan-2005
+ *
+ */
+
+using('System.Data');
+
+class DataModule extends TModule
+{
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ //$this->Database->setDataSourceName($this->Application->getUserParameter('DSN'));
+ require("config.php");
+ $this->Database->setDataSourceName($dsn);
+ }
+
+ public function loadAccount($name='')
+ {
+ if(empty($name))
+ $name=$this->User->getUsername();
+ $result=$this->Database->Execute("SELECT * FROM user WHERE name='$username'");
+ if($result->RecordCount()>0)
+ return $result->fields;
+ else
+ return null;
+ }
+
+ public function createAccount($name, $fullname, $password, $email, $admin, $repositorygrants, $groupstr)
+ {
+ require("config.php");
+
+ //Add user to svn password file
+ //Escape special strings in htpasswd command
+ $password = eregi_replace('"', '\"', $password);
+ if(!file_exists("$svn_passwd_file"))
+ {
+ exec("$htpassword_cmd -cmb $svn_passwd_file $name \"$password\"");
+ } else {
+ exec("$htpassword_cmd -bm $svn_passwd_file $name \"$password\"");
+ }
+
+ $md5_pw = md5($password);
+ $account = $this->Database->Execute("INSERT INTO users (id, name, fullname, password, email, admin, repositorygrants) VALUES (null, '$name', '$fullname', '$md5_pw', '$email', '$admin', '$repositorygrants')");
 
                 // Put user into the initial set of groups
                 $groups = explode (";", $groupstr);
@@ -68,79 +68,79 @@
                 $this->rebuildAccessFile();
 
                 return $account;
- //return $this->Database->Execute("INSERT INTO users (name, password, email, admin, repositorygrants) VALUES ('$name', MD5('$password'), '$email', '$admin', '$repositorygrants')");
- }
-
- public function updateAccount($id, $name, $fullname, $email, $admin, $repositorygrants)
- {
- return $this->Database->Execute("UPDATE users SET name='$name', fullname='$fullname', email='$email', admin='$admin', repositorygrants='$repositorygrants' WHERE id='$id'");
- }
-
- public function updatePassword($id, $password)
- {
- require("config.php");
-
- $results = $this->Database->Execute("SELECT name FROM users WHERE id='$id'");
- $name = $results->fields['name'];
-
- //Escape special strings in htpasswd command
- $password = eregi_replace('"', '\"', $password);
- exec("$htpassword_cmd -mb $svn_passwd_file $name \"$password\"");
-
- $md5_pw = md5($password);
- $this->Database->Execute("UPDATE users SET password='$md5_pw' WHERE id='$id'");
- //$this->Database->Execute("UPDATE users SET password=MD5('$password') WHERE id='$id'");
- return;
- }
-
- public function isUsernameTaken($name)
- {
- $result=$this->Database->Execute("SELECT * FROM users WHERE name='$name'");
- return $result->RecordCount()>0;
- }
-
- public function isEmailTaken($email)
- {
- $result=$this->Database->Execute("SELECT * FROM users WHERE email='$email'");
- return $result->RecordCount()>0;
- }
-
- public function isValidTicket($ticket)
- {
- $result=$this->Database->Execute("SELECT * FROM usertickets WHERE ticket='$ticket'");
- return $result->RecordCount()>0;
- }
-
- public function hasTicket($email)
- {
- $result=$this->Database->Execute("SELECT * FROM usertickets WHERE email='$email'");
- return $result->RecordCount()>0;
- }
-
- public function createTicket($email, $ticket, $repos, $groups)
- {
- $result = $this->Database->Execute("INSERT INTO usertickets (email, ticket, repositorygrants, groups) VALUES ('$email', '$ticket', '$repos', '$groups')");
- }
-
- public function getTicket($ticket)
- {
- $result = $this->Database->Execute("SELECT email, ticket, repositorygrants, groups FROM usertickets WHERE ticket='$ticket'");
- return $result->fields;
- }
-
- public function removeTicket($ticket)
- {
- $result = $this->Database->Execute("DELETE FROM usertickets WHERE ticket='$ticket'");
- }
- public function getUsername($id)
- {
- $user = $this->Database->Execute("SELECT * FROM users WHERE id='$id'");
- if($user)
- return $user->fields['name'];
- else
- return null;
- }
-
+ //return $this->Database->Execute("INSERT INTO users (name, password, email, admin, repositorygrants) VALUES ('$name', MD5('$password'), '$email', '$admin', '$repositorygrants')");
+ }
+
+ public function updateAccount($id, $name, $fullname, $email, $admin, $repositorygrants)
+ {
+ return $this->Database->Execute("UPDATE users SET name='$name', fullname='$fullname', email='$email', admin='$admin', repositorygrants='$repositorygrants' WHERE id='$id'");
+ }
+
+ public function updatePassword($id, $password)
+ {
+ require("config.php");
+
+ $results = $this->Database->Execute("SELECT name FROM users WHERE id='$id'");
+ $name = $results->fields['name'];
+
+ //Escape special strings in htpasswd command
+ $password = eregi_replace('"', '\"', $password);
+ exec("$htpassword_cmd -mb $svn_passwd_file $name \"$password\"");
+
+ $md5_pw = md5($password);
+ $this->Database->Execute("UPDATE users SET password='$md5_pw' WHERE id='$id'");
+ //$this->Database->Execute("UPDATE users SET password=MD5('$password') WHERE id='$id'");
+ return;
+ }
+
+ public function isUsernameTaken($name)
+ {
+ $result=$this->Database->Execute("SELECT * FROM users WHERE name='$name'");
+ return $result->RecordCount()>0;
+ }
+
+ public function isEmailTaken($email)
+ {
+ $result=$this->Database->Execute("SELECT * FROM users WHERE email='$email'");
+ return $result->RecordCount()>0;
+ }
+
+ public function isValidTicket($ticket)
+ {
+ $result=$this->Database->Execute("SELECT * FROM usertickets WHERE ticket='$ticket'");
+ return $result->RecordCount()>0;
+ }
+
+ public function hasTicket($email)
+ {
+ $result=$this->Database->Execute("SELECT * FROM usertickets WHERE email='$email'");
+ return $result->RecordCount()>0;
+ }
+
+ public function createTicket($email, $ticket, $repos, $groups)
+ {
+ $result = $this->Database->Execute("INSERT INTO usertickets (email, ticket, repositorygrants, groups) VALUES ('$email', '$ticket', '$repos', '$groups')");
+ }
+
+ public function getTicket($ticket)
+ {
+ $result = $this->Database->Execute("SELECT email, ticket, repositorygrants, groups FROM usertickets WHERE ticket='$ticket'");
+ return $result->fields;
+ }
+
+ public function removeTicket($ticket)
+ {
+ $result = $this->Database->Execute("DELETE FROM usertickets WHERE ticket='$ticket'");
+ }
+ public function getUsername($id)
+ {
+ $user = $this->Database->Execute("SELECT * FROM users WHERE id='$id'");
+ if($user)
+ return $user->fields['name'];
+ else
+ return null;
+ }
+
         public function getUserId($name)
         {
                 $id = $this->Database->Execute("SELECT * FROM users WHERE name='$name'");
@@ -150,64 +150,64 @@
                         return null;
         }
         
- public function rebuildAccessFile()
- {
- require_once("./svnmanager/library/class.accessfile.php");
- $accessfile = new AccessFile();
- $accessfile->createFromDatabase();
- }
-
- public function deleteUser($id)
-{
- require("config.php");
-
- //Change Groups
- $this->Database->Execute("UPDATE groups SET adminid='1' WHERE adminid='$id'");
-
- //Change Repositories
- $this->Database->Execute("UPDATE repositories SET ownerid='1' WHERE ownerid='$id'");
-
- //Remove user from group(s)
- $this->Database->Execute("DELETE FROM usersgroups WHERE userid='$id'");
+ public function rebuildAccessFile()
+ {
+ require_once("./svnmanager/library/class.accessfile.php");
+ $accessfile = new AccessFile();
+ $accessfile->createFromDatabase();
+ }
+
+ public function deleteUser($id)
+{
+ require("config.php");
+
+ //Change Groups
+ $this->Database->Execute("UPDATE groups SET adminid='1' WHERE adminid='$id'");
+
+ //Change Repositories
+ $this->Database->Execute("UPDATE repositories SET ownerid='1' WHERE ownerid='$id'");
+
+ //Remove user from group(s)
+ $this->Database->Execute("DELETE FROM usersgroups WHERE userid='$id'");
  
         //Remove user's privileges
         $this->Database->Execute("DELETE FROM userprivileges WHERE userid='$id'");
-
- //Klaus Drechsler, 12.08.2005:
- //bugfix: select name was after the user has been deletetd
- $results = $this->Database->Execute("SELECT name FROM users WHERE id='$id'");
- $name = $results->fields['name'];
-
- //Remove user
- $this->Database->Execute("DELETE FROM users WHERE id='$id'");
-
- //$results = $this->Database->Execute("SELECT name FROM users WHERE id='$id'");
- //$name = $results->fields['name'];
-
- exec("$htpassword_cmd -D $svn_passwd_file $name");
-
- $this->rebuildAccessfile();
-}
- public function checkPassword($userid, $password)
- {
- //Check if admin is config file defined administrator (id=0)
- if($userid=='0')
- {
- require("config.php");
- if($password==$admin_temp_password)
- return true;
- else
- return false;
- }
-
- $md5_pw = md5($password);
- $result = $this->Module->Database->Execute("SELECT * FROM users WHERE id='$userid' AND password='$md5_pw'");
- return $result->RecordCount()>0;
-
- }
-
-
-
-}
-
+
+ //Klaus Drechsler, 12.08.2005:
+ //bugfix: select name was after the user has been deletetd
+ $results = $this->Database->Execute("SELECT name FROM users WHERE id='$id'");
+ $name = $results->fields['name'];
+
+ //Remove user
+ $this->Database->Execute("DELETE FROM users WHERE id='$id'");
+
+ //$results = $this->Database->Execute("SELECT name FROM users WHERE id='$id'");
+ //$name = $results->fields['name'];
+
+ exec("$htpassword_cmd -D $svn_passwd_file $name");
+
+ $this->rebuildAccessfile();
+}
+ public function checkPassword($userid, $password)
+ {
+ //Check if admin is config file defined administrator (id=0)
+ if($userid=='0')
+ {
+ require("config.php");
+ if($password==$admin_temp_password)
+ return true;
+ else
+ return false;
+ }
+
+ $md5_pw = md5($password);
+ $result = $this->Module->Database->Execute("SELECT * FROM users WHERE id='$userid' AND password='$md5_pw'");
+ return $result->RecordCount()>0;
+
+ }
+
+
+
+}
+
 ?>
\ No newline at end of file

Modified: svnmanager/UserModule/EditPage.php
==============================================================================
--- svnmanager/UserModule/EditPage.php (original)
+++ svnmanager/UserModule/EditPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,181 +1,181 @@
-<?php
-class EditPage extends TPage
-{
-
- public function onInit($param)
- {
- parent::onInit($param);
-
- $userid = $_GET['UserID'];
-
- if(!$this->User->isAdmin() && $userid!=$this->User->getId())
- {
- echo "Not enough rights to change this user!";
- exit(-1);
- }
-
- $results = $this->Module->Database->Execute("SELECT * FROM users WHERE id='$userid'");
- $fields = $results->fields;
-
- $user = array(
- 'id' => $fields['id'],
- 'name' => $fields['name'],
- 'fullname' => $fields['fullname'],
- 'email' => $fields['email'],
- 'admin' => $fields['admin'],
- 'grants' => $fields['repositorygrants']
- );
-
- $this->setSelectedUser($user);
-
- $this->UserID->setText($fields['id']);
- $this->UserName->setText($fields['name']);
- $this->FullName->setText($fields['fullname']);
- $this->Email->setText($fields['email']);
- if($fields['admin']==255)
- $this->Admin->setChecked(true);
- else
- $this->Admin->setChecked(false);
- $this->Grants->setText($fields['repositorygrants']);
- if(!$this->User->isAdmin())
- {
- $this->Grants->setEnabled(false);
- $this->Admin->setEnabled(false);
- }
- else
- {
- $this->Grants->setEnabled(true);
- $this->Admin->setEnabled(true);
- }
- }
-
- function getSelectedUser()
- {
- return $this->getViewState('SelectedUser','');
- }
-
- function setSelectedUser($value)
- {
- $this->setViewState('SelectedUser',$value,'');
- }
-
- function isSelectedUserAdmin()
- {
- $user = $this->getSelectedUser();
- return $user['admin']==255;
- }
-
- function onRequirePassword($sender, $param)
- {
- $pw = $this->Password->getText();
- $id = $this->User->getId();
- if($this->Module->checkPassword($id, $pw))
- $param->isValid=true;
- else
- $param->isValid=false;
- return;
- }
-
-
- public function onCheckUserName($sender, $param)
- {
- $user = $this->getSelectedUser();
- $oldname = $user['name'];
- $newname = $this->UserName->getText();
-
- if($oldname==$newname)
- {
- $param->isValid=true;
- return;
- }
-
- if($this->Module->isUsernameTaken($newname))
- $param->isValid=false;
- else
- $param->isValid=true;
-
- return;
- }
-
- public function onConfirmBtn($sender, $param)
- {
-
- if($this->IsValid)
- {
- $user = $this->getSelectedUser();
- $newuser = $this->getSelectedUser();
-
- $changes=false;
-
- if(strtolower($this->UserName->getText())!=$user['name'])
- {
- $changes=true;
- $newuser['name']=strtolower($this->UserName->getText());
- }
-
- if ($this->FullName->getText() != $user['fullname'])
- {
- $changes = true;
- $newuser['fullname'] = $this->FullName->getText();
- }
-
- if(strtolower($this->Email->getText())!=$user['email'])
- {
- $changes=true;
- $newuser['email']=strtolower($this->Email->getText());
- }
-
- if($this->User->isAdmin())
- {
- //Admin checkbox changed?
- if($user['admin']==255)
- if($this->Admin->Checked==false)
- {
- $changes=true;
- $newuser['admin']=0;
- }
- if($user['admin']!=255)
- if($this->Admin->Checked==true)
- {
- $changes=true;
- $newuser['admin']=255;
- }
-
- //Nr of grants changed?
- if($this->Grants->getText()!=$user['grants'])
- {
- $changes=true;
- $newuser['grants']=$this->Grants->getText();
- }
- }
-
- //Password changed?
- if( $this->NewPassword->getText()!="" ) $changes=true;
-
-
- //Check for changed passwords, if so: update password
- if($this->NewPassword->getText()!="")
- {
- $this->Module->updatePassword($user['id'], $this->NewPassword->getText());
- }
-
- $this->Module->updateAccount($user['id'], $newuser['name'], $newuser['fullname'], $newuser['email'], $newuser['admin'], $newuser['grants']);
-
- $this->EditPanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- }
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('User:AdminPage');
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-
-}
-
+<?php
+class EditPage extends TPage
+{
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+
+ $userid = $_GET['UserID'];
+
+ if(!$this->User->isAdmin() && $userid!=$this->User->getId())
+ {
+ echo "Not enough rights to change this user!";
+ exit(-1);
+ }
+
+ $results = $this->Module->Database->Execute("SELECT * FROM users WHERE id='$userid'");
+ $fields = $results->fields;
+
+ $user = array(
+ 'id' => $fields['id'],
+ 'name' => $fields['name'],
+ 'fullname' => $fields['fullname'],
+ 'email' => $fields['email'],
+ 'admin' => $fields['admin'],
+ 'grants' => $fields['repositorygrants']
+ );
+
+ $this->setSelectedUser($user);
+
+ $this->UserID->setText($fields['id']);
+ $this->UserName->setText($fields['name']);
+ $this->FullName->setText($fields['fullname']);
+ $this->Email->setText($fields['email']);
+ if($fields['admin']==255)
+ $this->Admin->setChecked(true);
+ else
+ $this->Admin->setChecked(false);
+ $this->Grants->setText($fields['repositorygrants']);
+ if(!$this->User->isAdmin())
+ {
+ $this->Grants->setEnabled(false);
+ $this->Admin->setEnabled(false);
+ }
+ else
+ {
+ $this->Grants->setEnabled(true);
+ $this->Admin->setEnabled(true);
+ }
+ }
+
+ function getSelectedUser()
+ {
+ return $this->getViewState('SelectedUser','');
+ }
+
+ function setSelectedUser($value)
+ {
+ $this->setViewState('SelectedUser',$value,'');
+ }
+
+ function isSelectedUserAdmin()
+ {
+ $user = $this->getSelectedUser();
+ return $user['admin']==255;
+ }
+
+ function onRequirePassword($sender, $param)
+ {
+ $pw = $this->Password->getText();
+ $id = $this->User->getId();
+ if($this->Module->checkPassword($id, $pw))
+ $param->isValid=true;
+ else
+ $param->isValid=false;
+ return;
+ }
+
+
+ public function onCheckUserName($sender, $param)
+ {
+ $user = $this->getSelectedUser();
+ $oldname = $user['name'];
+ $newname = $this->UserName->getText();
+
+ if($oldname==$newname)
+ {
+ $param->isValid=true;
+ return;
+ }
+
+ if($this->Module->isUsernameTaken($newname))
+ $param->isValid=false;
+ else
+ $param->isValid=true;
+
+ return;
+ }
+
+ public function onConfirmBtn($sender, $param)
+ {
+
+ if($this->IsValid)
+ {
+ $user = $this->getSelectedUser();
+ $newuser = $this->getSelectedUser();
+
+ $changes=false;
+
+ if(strtolower($this->UserName->getText())!=$user['name'])
+ {
+ $changes=true;
+ $newuser['name']=strtolower($this->UserName->getText());
+ }
+
+ if ($this->FullName->getText() != $user['fullname'])
+ {
+ $changes = true;
+ $newuser['fullname'] = $this->FullName->getText();
+ }
+
+ if(strtolower($this->Email->getText())!=$user['email'])
+ {
+ $changes=true;
+ $newuser['email']=strtolower($this->Email->getText());
+ }
+
+ if($this->User->isAdmin())
+ {
+ //Admin checkbox changed?
+ if($user['admin']==255)
+ if($this->Admin->Checked==false)
+ {
+ $changes=true;
+ $newuser['admin']=0;
+ }
+ if($user['admin']!=255)
+ if($this->Admin->Checked==true)
+ {
+ $changes=true;
+ $newuser['admin']=255;
+ }
+
+ //Nr of grants changed?
+ if($this->Grants->getText()!=$user['grants'])
+ {
+ $changes=true;
+ $newuser['grants']=$this->Grants->getText();
+ }
+ }
+
+ //Password changed?
+ if( $this->NewPassword->getText()!="" ) $changes=true;
+
+
+ //Check for changed passwords, if so: update password
+ if($this->NewPassword->getText()!="")
+ {
+ $this->Module->updatePassword($user['id'], $this->NewPassword->getText());
+ }
+
+ $this->Module->updateAccount($user['id'], $newuser['name'], $newuser['fullname'], $newuser['email'], $newuser['admin'], $newuser['grants']);
+
+ $this->EditPanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ }
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('User:AdminPage');
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+
+}
+
 ?>
\ No newline at end of file

Modified: svnmanager/UserModule/EditSelectPage.php
==============================================================================
--- svnmanager/UserModule/EditSelectPage.php (original)
+++ svnmanager/UserModule/EditSelectPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,61 +1,61 @@
-<?php
-/*
- * Created on 17-feb-2005
- *
- */
-
-class EditSelectPage extends TPage
-{
-
- public function onInit($param)
- {
- parent::onInit($param);
-
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- if($this->User->isAdmin())
- $results=$this->Module->Database->Execute("SELECT * FROM users ORDER BY name");
- else
- $this->Application->transfer('User:EditPage', array('UserID' => $this->User->getID()));
-
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
-
- $data[] = array(
- 'userid' => $fields['id'],
- 'username' => $fields['name'],
- 'fullname' => $fields['fullname'],
- 'email' => $fields['email']
- );
-
- $results->MoveNext();
- }
- $results->Close();
- $this->UserTable->setDataSource($data);
- }
-
- $this->dataBind();
-
- }
-
- public function onUserSelected($sender, $param)
- {
- $userid = $param->parameter;
- $this->Application->transfer('User:EditPage', array('UserID' => $userid) );
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer('User:AdminPage');
- }
-
-}
-?>
+<?php
+/*
+ * Created on 17-feb-2005
+ *
+ */
+
+class EditSelectPage extends TPage
+{
+
+ public function onInit($param)
+ {
+ parent::onInit($param);
+
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+
+ if($this->User->isAdmin())
+ $results=$this->Module->Database->Execute("SELECT * FROM users ORDER BY name");
+ else
+ $this->Application->transfer('User:EditPage', array('UserID' => $this->User->getID()));
+
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+
+ $data[] = array(
+ 'userid' => $fields['id'],
+ 'username' => $fields['name'],
+ 'fullname' => $fields['fullname'],
+ 'email' => $fields['email']
+ );
+
+ $results->MoveNext();
+ }
+ $results->Close();
+ $this->UserTable->setDataSource($data);
+ }
+
+ $this->dataBind();
+
+ }
+
+ public function onUserSelected($sender, $param)
+ {
+ $userid = $param->parameter;
+ $this->Application->transfer('User:EditPage', array('UserID' => $userid) );
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer('User:AdminPage');
+ }
+
+}
+?>

Modified: svnmanager/UserModule/InvitePage.php
==============================================================================
--- svnmanager/UserModule/InvitePage.php (original)
+++ svnmanager/UserModule/InvitePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,146 +1,146 @@
-<?php
-/*
- * Created on 19-jan-2005
- *
- * On this page the administrators can send invitation emails to new users
- *
- */
-class InvitePage extends TPage
-{
-
- /*
- * Load the list of groups that the new user will be a part of.
- */
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- /* Extract the set of groups that the invited user can be a part of. */
- $userid = $this->User->getId();
- if($this->User->IsAdmin())
- $results = $this->Module->Database->Execute("SELECT * FROM groups ORDER BY name");
- else
- $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE adminid='$userid'");
-
- if ($results) {
- # Gather the complete list of groups into an array
- $groups = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- $owner = $this->Module->getUserName($fields['adminid']);
- $groups[] = $fields['name'];
- $results->MoveNext();
- }
- $results->Close();
-
- if (! $this->isPostBack()) {
- $this->Groups->setDataSource($groups);
- $this->dataBind();
- }
- }
- }
-
- /*
- * Check if email address belongs to existing user
- */
- public function isEmailTaken($sender, $param)
- {
- $param->isValid=!$this->Module->isEmailTaken($this->Email->Text);
- }
-
- /*
- * Check if there is a pending ticket for this email address
- */
- public function hasTicket($sender, $param)
- {
- $param->isValid=!$this->Module->hasTicket($this->Email->Text);
- }
-
- /*
- * On confirmation, send the e-mail address an invitation to
- * make an account on this server.
- */
- public function onConfirmBtn($sender, $param)
- {
- if($this->IsValid)
- {
- require("config.php");
- require("./svnmanager/library/class.phpmailer.php");
-
- $email = $this->Email->Text;
- $repos = (int)$this->Repos->Text;
-
- // Which groups will this user start in?
- $groups = "";
- $items = $this->Groups->getItems();
- foreach($items as $item)
- {
- if ($item->isSelected())
- {
- if ($groups == "")
- $groups = $item->getText();
- else
- $groups = $groups . ";" . $item->getText();
- }
- }
-
- //Ticket string is MD5 hash of email address, nr of repos grants, initial groups & random number
- $rnd = rand(1,1000000);
- $ticket = md5($email.$repos.$groups.$rnd);
- $servername =$_SERVER['SERVER_NAME'];
- $page = $_SERVER['PHP_SELF'];
- $message =
- "Your are invited to create an account on the $servername server. Please follow the link to activate your account:\n".
- "\n".
- "https://$servername$page?page=User:ActivatePage&ticket=$ticket\n".
- "\n".
- "Regards";
-
- $mail = new PHPMailer();
- $mail->From = "boost-owner_at_[hidden]";
- $mail->FromName = "Boost Moderators";
- $mail->Host = "$smtp_server";
- $mail->Mailer = "smtp";
- $mail->Body = $message;
- $mail->AddAddress($email);
- $mail->Subject = "Boost Subversion Repository Account Invitation";
-
- //Email invitation and Store ticket into database
- if(!$mail->Send())
- {
- echo "Something went wrong sending email, please contact server administrator!";
- exit(-1);
- } else {
-
- $this->Module->createTicket($email, $ticket, $repos, $groups); //Put the ticket into the database
-
- //Show confirmation
- $this->InvitationPanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- }
- }
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-
- public function setSelectedGroups($group)
- {
- $this->setViewState('SelectedGroups', $group, '');
- }
-
- public function getSelectedGroups()
- {
- return $this->getViewState('SelectedGroups', '');
- }
-
-}
-?>
+<?php
+/*
+ * Created on 19-jan-2005
+ *
+ * On this page the administrators can send invitation emails to new users
+ *
+ */
+class InvitePage extends TPage
+{
+
+ /*
+ * Load the list of groups that the new user will be a part of.
+ */
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+
+ /* Extract the set of groups that the invited user can be a part of. */
+ $userid = $this->User->getId();
+ if($this->User->IsAdmin())
+ $results = $this->Module->Database->Execute("SELECT * FROM groups ORDER BY name");
+ else
+ $results = $this->Module->Database->Execute("SELECT * FROM groups WHERE adminid='$userid'");
+
+ if ($results) {
+ # Gather the complete list of groups into an array
+ $groups = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ $owner = $this->Module->getUserName($fields['adminid']);
+ $groups[] = $fields['name'];
+ $results->MoveNext();
+ }
+ $results->Close();
+
+ if (! $this->isPostBack()) {
+ $this->Groups->setDataSource($groups);
+ $this->dataBind();
+ }
+ }
+ }
+
+ /*
+ * Check if email address belongs to existing user
+ */
+ public function isEmailTaken($sender, $param)
+ {
+ $param->isValid=!$this->Module->isEmailTaken($this->Email->Text);
+ }
+
+ /*
+ * Check if there is a pending ticket for this email address
+ */
+ public function hasTicket($sender, $param)
+ {
+ $param->isValid=!$this->Module->hasTicket($this->Email->Text);
+ }
+
+ /*
+ * On confirmation, send the e-mail address an invitation to
+ * make an account on this server.
+ */
+ public function onConfirmBtn($sender, $param)
+ {
+ if($this->IsValid)
+ {
+ require("config.php");
+ require("./svnmanager/library/class.phpmailer.php");
+
+ $email = $this->Email->Text;
+ $repos = (int)$this->Repos->Text;
+
+ // Which groups will this user start in?
+ $groups = "";
+ $items = $this->Groups->getItems();
+ foreach($items as $item)
+ {
+ if ($item->isSelected())
+ {
+ if ($groups == "")
+ $groups = $item->getText();
+ else
+ $groups = $groups . ";" . $item->getText();
+ }
+ }
+
+ //Ticket string is MD5 hash of email address, nr of repos grants, initial groups & random number
+ $rnd = rand(1,1000000);
+ $ticket = md5($email.$repos.$groups.$rnd);
+ $servername =$_SERVER['SERVER_NAME'];
+ $page = $_SERVER['PHP_SELF'];
+ $message =
+ "Your are invited to create an account on the $servername server. Please follow the link to activate your account:\n".
+ "\n".
+ "https://$servername$page?page=User:ActivatePage&ticket=$ticket\n".
+ "\n".
+ "Regards";
+
+ $mail = new PHPMailer();
+ $mail->From = "boost-owner_at_[hidden]";
+ $mail->FromName = "Boost Moderators";
+ $mail->Host = "$smtp_server";
+ $mail->Mailer = "smtp";
+ $mail->Body = $message;
+ $mail->AddAddress($email);
+ $mail->Subject = "Boost Subversion Repository Account Invitation";
+
+ //Email invitation and Store ticket into database
+ if(!$mail->Send())
+ {
+ echo "Something went wrong sending email, please contact server administrator!";
+ exit(-1);
+ } else {
+
+ $this->Module->createTicket($email, $ticket, $repos, $groups); //Put the ticket into the database
+
+ //Show confirmation
+ $this->InvitationPanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ }
+ }
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+
+ public function setSelectedGroups($group)
+ {
+ $this->setViewState('SelectedGroups', $group, '');
+ }
+
+ public function getSelectedGroups()
+ {
+ return $this->getViewState('SelectedGroups', '');
+ }
+
+}
+?>

Modified: svnmanager/UserModule/LoginPage.php
==============================================================================
--- svnmanager/UserModule/LoginPage.php (original)
+++ svnmanager/UserModule/LoginPage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,29 +1,29 @@
-<?php
-/*
- * Created on 17-Jan-2005
- *
- */
-class LoginPage extends TPage
-{
- public function onLogin($sender,$param)
- {
- $param->isValid=$this->User->login($this->Username->Text,$this->Password->Text);
- }
-
- public function onClickLoginBtn($sender,$param)
- {
- if($this->IsValid)
- {
- //$this->User->login($this->Username->Text);
- $redirectUrl=$this->User->getRedirectUrl();
-
- if(empty($redirectUrl) || $this->Page)
- $this->Application->transfer();
- else
- $this->Application->redirect($redirectUrl);
- }
- }
-}
-
-
-?>
+<?php
+/*
+ * Created on 17-Jan-2005
+ *
+ */
+class LoginPage extends TPage
+{
+ public function onLogin($sender,$param)
+ {
+ $param->isValid=$this->User->login($this->Username->Text,$this->Password->Text);
+ }
+
+ public function onClickLoginBtn($sender,$param)
+ {
+ if($this->IsValid)
+ {
+ //$this->User->login($this->Username->Text);
+ $redirectUrl=$this->User->getRedirectUrl();
+
+ if(empty($redirectUrl) || $this->Page)
+ $this->Application->transfer();
+ else
+ $this->Application->redirect($redirectUrl);
+ }
+ }
+}
+
+
+?>

Modified: svnmanager/UserModule/RemovePage.php
==============================================================================
--- svnmanager/UserModule/RemovePage.php (original)
+++ svnmanager/UserModule/RemovePage.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,54 +1,54 @@
-<?php
-class RemovePage extends TPage
-{
-
- public function onLoad($param)
- {
- parent::onLoad($param);
-
- //Fill TRepeater with user names
- $results=$this->Module->Database->Execute("SELECT * FROM users ORDER BY name");
- if($results)
- {
- $data = array();
- while(!$results->EOF)
- {
- $fields = $results->fields;
- //Skip current user
- if($fields['id']!=$this->User->getId())
- {
- $data[] = array(
- 'userid' => $fields['id'],
- 'username' => $fields['name'],
- 'email' => $fields['email']
- );
- }
- $results->MoveNext();
- $this->UserTable->setDataSource($data);
- }
- $results->Close();
- }
-
- $this->dataBind();
- }
-
- public function onDeleteUser($sender, $param)
- {
- $userid = $param->parameter;
- $this->Module->deleteUser($userid);
- //$this->Application->transfer('User:AdminPage');
- $this->RemovePanel->setVisible(false);
- $this->ConfirmationPanel->setVisible(true);
- }
-
- public function onCancelBtn($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-
- public function onGoBack($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-}
+<?php
+class RemovePage extends TPage
+{
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+
+ //Fill TRepeater with user names
+ $results=$this->Module->Database->Execute("SELECT * FROM users ORDER BY name");
+ if($results)
+ {
+ $data = array();
+ while(!$results->EOF)
+ {
+ $fields = $results->fields;
+ //Skip current user
+ if($fields['id']!=$this->User->getId())
+ {
+ $data[] = array(
+ 'userid' => $fields['id'],
+ 'username' => $fields['name'],
+ 'email' => $fields['email']
+ );
+ }
+ $results->MoveNext();
+ $this->UserTable->setDataSource($data);
+ }
+ $results->Close();
+ }
+
+ $this->dataBind();
+ }
+
+ public function onDeleteUser($sender, $param)
+ {
+ $userid = $param->parameter;
+ $this->Module->deleteUser($userid);
+ //$this->Application->transfer('User:AdminPage');
+ $this->RemovePanel->setVisible(false);
+ $this->ConfirmationPanel->setVisible(true);
+ }
+
+ public function onCancelBtn($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+
+ public function onGoBack($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+}
 ?>
\ No newline at end of file

Modified: svnmanager/global/MenuBar.php
==============================================================================
--- svnmanager/global/MenuBar.php (original)
+++ svnmanager/global/MenuBar.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,46 +1,46 @@
-<?php
-/*
- * Created on 18-Jan-2005
- *
- */
-class MenuBar extends TControl
-{
- public function onInit($param)
- {
- parent::onInit($param);
- }
-
- public function onLoad($param)
- {
- parent::onLoad($param);
- $this->dataBind();
- }
-
- public function onClickLoginBtn($sender, $param)
- {
- $this->User->onAuthorizationRequired($this->Page);
- }
-
- public function onClickLogoutBtn($sender, $param)
- {
- $this->User->logout();
- $this->Application->transfer("Main:StartPage");
- }
-
- public function onClickUserBtn($sender, $param)
- {
- $this->Application->transfer("User:AdminPage");
- }
-
- public function onClickGroupBtn($sender, $param)
- {
- $this->Application->transfer("Group:AdminPage");
- }
-
- public function onClickRepositoryBtn($sender, $param)
- {
- $this->Application->transfer("Repository:AdminPage");
- }
-}
-
-?>
+<?php
+/*
+ * Created on 18-Jan-2005
+ *
+ */
+class MenuBar extends TControl
+{
+ public function onInit($param)
+ {
+ parent::onInit($param);
+ }
+
+ public function onLoad($param)
+ {
+ parent::onLoad($param);
+ $this->dataBind();
+ }
+
+ public function onClickLoginBtn($sender, $param)
+ {
+ $this->User->onAuthorizationRequired($this->Page);
+ }
+
+ public function onClickLogoutBtn($sender, $param)
+ {
+ $this->User->logout();
+ $this->Application->transfer("Main:StartPage");
+ }
+
+ public function onClickUserBtn($sender, $param)
+ {
+ $this->Application->transfer("User:AdminPage");
+ }
+
+ public function onClickGroupBtn($sender, $param)
+ {
+ $this->Application->transfer("Group:AdminPage");
+ }
+
+ public function onClickRepositoryBtn($sender, $param)
+ {
+ $this->Application->transfer("Repository:AdminPage");
+ }
+}
+
+?>

Modified: svnmanager/global/SVNManagerUser.php
==============================================================================
--- svnmanager/global/SVNManagerUser.php (original)
+++ svnmanager/global/SVNManagerUser.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,218 +1,218 @@
-<?php
-/*
- * Created on 17-Jan-2005
- *
- */
-class SVNManagerUser extends TUser
-{
- //Code used from Prado's blog example
-
- private $userId='';
- private $userName='';
- private $userEmail='';
- private $redirectUrl='';
- private $isAdmin=false; //Is superadmin
- private $ownsGroup=false; //Admins any groups
- private $ownsRepository=false; //Owns any repository
- private $configAdmin=false; //True if this is administrator from config file
-
- public function setId($id)
- {
- $this->userId=$id;
- }
-
- public function getId()
- {
- return $this->userId;
- }
-
- public function setName($name)
- {
- $this->userName = $name;
- }
-
- public function getName()
- {
- return $this->userName;
- }
-
- public function setEmail($email)
- {
- $this->userEmail = $email;
- }
-
- public function getEmail()
- {
- return $this->userEmail;
- }
-
- public function setRedirectUrl($url)
- {
- $this->redirectUrl=$url;
- }
-
- public function getRedirectUrl()
- {
- return $this->redirectUrl;
- }
-
- public function setAdmin($admin)
- {
- $this->isAdmin = $admin;
- }
-
- public function isAdmin()
- {
- return $this->isAdmin;
- }
-
- public function setGroup($group)
- {
- $this->ownsGroup=$group;
- }
-
- public function ownsGroup()
- {
- return $this->ownsGroup;
- }
-
- public function setRepository($repos)
- {
- $this->ownsRepository=$repos;
- }
-
- public function ownsRepository()
- {
- return $this->ownsRepository;
- }
-
- public function setConfigAdmin($cadmin)
- {
- $this->configAdmin = $cadmin;
- }
-
- public function isConfigAdmin()
- {
- return $this->configAdmin;
- }
-
- public function onAuthenticationRequired($pageName)
- {
- $this->setRedirectUrl($_SERVER['REQUEST_URI']);
- pradoGetApplication()->transfer('User:LoginPage');
- }
-
- public function onAuthorizationRequired($page)
- {
- $this->onAuthenticationRequired($page->ID);
- }
-
- public function needsRepositoryMenu()
- {
- if($this->isConfigAdmin()) return false;
- if($this->isAdmin())return true;
- if($this->ownsRepository()) return true;
-
- //Has grants
- $adodb = new TAdodb;
- require("config.php");
-
- $adodb->setDataSourceName($dsn);
- $adodb->SetFetchMode("Associative");
- $userid=$this->getId();
-
- $result = $adodb->Execute("SELECT * FROM users WHERE id='$userid'");
- $fields = $result->fields;
-
- if($fields['repositorygrants']>0)
- return true;
-
- return false;
- }
-
- public function login( $name, $password = '')
- {
- $authenticated=false;
-
- $adodb = new TAdodb;
-
- //$adodb->setDataSourceName($this->Application->getUserParameter('DSN'));
- require("config.php");
- $adodb->setDataSourceName($dsn);
-
- $adodb->SetFetchMode("Associative");
-
- //Check if there are any admin users
- $result=$adodb->Execute("SELECT * FROM users WHERE admin=255");
-
- //Check with config.php password if there are no admin users
- if($result->RecordCount()==0)
- {
- if($name==$admin_name && $password==$admin_temp_password)
- {
- $this->setEmail("no_at_[hidden]");
- $this->setId(0);
- $this->setAdmin(true);
- $this->setGroup(false);
- $this->setRepository(false);
- $this->setAuthenticated(true);
- $this->setConfigAdmin(true);
- $result->Close();
- return true;
- }
- }
- $result->Close();
-
- //Check for database user
- $md5_pw = md5($password);
- $result=$adodb->Execute("SELECT * FROM users WHERE name='$name' AND password='$md5_pw'");
- //$result=$adodb->Execute("SELECT * FROM users WHERE name='$name' AND password = MD5('$password')");
- if($result->RecordCount()>0)
- {
- $authenticated = true;
- $fields = $result->fields;
- $userid = $fields['id'];
-
- $email = $fields['email'];
-
- $this->setEmail($email);
-
- $this->setId($userid);
-
- if($fields['admin']==255) //Level 255 is superadmin
- $this->setAdmin(true);
- else
- $this->setAdmin(false);
-
- $groups = $adodb->Execute("SELECT * FROM groups WHERE adminid='$userid'");
- if($groups->RecordCount()>0)
- $this->setGroup(true);
- else
- $this->setGroup(false);
-
- $repos = $adodb->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
- if($repos->RecordCount()>0)
- $this->setRepository(true);
- else
- {
- $repos = $adodb->Execute("SELECT repositorygrants FROM users WHERE id='$userid'");
- if($repos->fields['repositorygrants']>0)
- $this->setRepository(true);
- else
- $this->setRepository(false);
- }
- }
- $result->Close();
- $this->setAuthenticated($authenticated);
- return $authenticated;
- }
-
- public function logout()
- {
- parent::logout();
- $this->setAdmin(false);
- $this->setGroup(false);
- $this->setRepository(false);
- }
-}
-?>
+<?php
+/*
+ * Created on 17-Jan-2005
+ *
+ */
+class SVNManagerUser extends TUser
+{
+ //Code used from Prado's blog example
+
+ private $userId='';
+ private $userName='';
+ private $userEmail='';
+ private $redirectUrl='';
+ private $isAdmin=false; //Is superadmin
+ private $ownsGroup=false; //Admins any groups
+ private $ownsRepository=false; //Owns any repository
+ private $configAdmin=false; //True if this is administrator from config file
+
+ public function setId($id)
+ {
+ $this->userId=$id;
+ }
+
+ public function getId()
+ {
+ return $this->userId;
+ }
+
+ public function setName($name)
+ {
+ $this->userName = $name;
+ }
+
+ public function getName()
+ {
+ return $this->userName;
+ }
+
+ public function setEmail($email)
+ {
+ $this->userEmail = $email;
+ }
+
+ public function getEmail()
+ {
+ return $this->userEmail;
+ }
+
+ public function setRedirectUrl($url)
+ {
+ $this->redirectUrl=$url;
+ }
+
+ public function getRedirectUrl()
+ {
+ return $this->redirectUrl;
+ }
+
+ public function setAdmin($admin)
+ {
+ $this->isAdmin = $admin;
+ }
+
+ public function isAdmin()
+ {
+ return $this->isAdmin;
+ }
+
+ public function setGroup($group)
+ {
+ $this->ownsGroup=$group;
+ }
+
+ public function ownsGroup()
+ {
+ return $this->ownsGroup;
+ }
+
+ public function setRepository($repos)
+ {
+ $this->ownsRepository=$repos;
+ }
+
+ public function ownsRepository()
+ {
+ return $this->ownsRepository;
+ }
+
+ public function setConfigAdmin($cadmin)
+ {
+ $this->configAdmin = $cadmin;
+ }
+
+ public function isConfigAdmin()
+ {
+ return $this->configAdmin;
+ }
+
+ public function onAuthenticationRequired($pageName)
+ {
+ $this->setRedirectUrl($_SERVER['REQUEST_URI']);
+ pradoGetApplication()->transfer('User:LoginPage');
+ }
+
+ public function onAuthorizationRequired($page)
+ {
+ $this->onAuthenticationRequired($page->ID);
+ }
+
+ public function needsRepositoryMenu()
+ {
+ if($this->isConfigAdmin()) return false;
+ if($this->isAdmin())return true;
+ if($this->ownsRepository()) return true;
+
+ //Has grants
+ $adodb = new TAdodb;
+ require("config.php");
+
+ $adodb->setDataSourceName($dsn);
+ $adodb->SetFetchMode("Associative");
+ $userid=$this->getId();
+
+ $result = $adodb->Execute("SELECT * FROM users WHERE id='$userid'");
+ $fields = $result->fields;
+
+ if($fields['repositorygrants']>0)
+ return true;
+
+ return false;
+ }
+
+ public function login( $name, $password = '')
+ {
+ $authenticated=false;
+
+ $adodb = new TAdodb;
+
+ //$adodb->setDataSourceName($this->Application->getUserParameter('DSN'));
+ require("config.php");
+ $adodb->setDataSourceName($dsn);
+
+ $adodb->SetFetchMode("Associative");
+
+ //Check if there are any admin users
+ $result=$adodb->Execute("SELECT * FROM users WHERE admin=255");
+
+ //Check with config.php password if there are no admin users
+ if($result->RecordCount()==0)
+ {
+ if($name==$admin_name && $password==$admin_temp_password)
+ {
+ $this->setEmail("no_at_[hidden]");
+ $this->setId(0);
+ $this->setAdmin(true);
+ $this->setGroup(false);
+ $this->setRepository(false);
+ $this->setAuthenticated(true);
+ $this->setConfigAdmin(true);
+ $result->Close();
+ return true;
+ }
+ }
+ $result->Close();
+
+ //Check for database user
+ $md5_pw = md5($password);
+ $result=$adodb->Execute("SELECT * FROM users WHERE name='$name' AND password='$md5_pw'");
+ //$result=$adodb->Execute("SELECT * FROM users WHERE name='$name' AND password = MD5('$password')");
+ if($result->RecordCount()>0)
+ {
+ $authenticated = true;
+ $fields = $result->fields;
+ $userid = $fields['id'];
+
+ $email = $fields['email'];
+
+ $this->setEmail($email);
+
+ $this->setId($userid);
+
+ if($fields['admin']==255) //Level 255 is superadmin
+ $this->setAdmin(true);
+ else
+ $this->setAdmin(false);
+
+ $groups = $adodb->Execute("SELECT * FROM groups WHERE adminid='$userid'");
+ if($groups->RecordCount()>0)
+ $this->setGroup(true);
+ else
+ $this->setGroup(false);
+
+ $repos = $adodb->Execute("SELECT * FROM repositories WHERE ownerid='$userid'");
+ if($repos->RecordCount()>0)
+ $this->setRepository(true);
+ else
+ {
+ $repos = $adodb->Execute("SELECT repositorygrants FROM users WHERE id='$userid'");
+ if($repos->fields['repositorygrants']>0)
+ $this->setRepository(true);
+ else
+ $this->setRepository(false);
+ }
+ }
+ $result->Close();
+ $this->setAuthenticated($authenticated);
+ return $authenticated;
+ }
+
+ public function logout()
+ {
+ parent::logout();
+ $this->setAdmin(false);
+ $this->setGroup(false);
+ $this->setRepository(false);
+ }
+}
+?>

Modified: svnmanager/library/class.accessfile.php
==============================================================================
--- svnmanager/library/class.accessfile.php (original)
+++ svnmanager/library/class.accessfile.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,195 +1,195 @@
-<?php
-class AccessFile
-{
-
- private $database;
-
- function __construct()
- {
- require("config.php");
- $this->database = new TAdodb;
- $this->database->setDataSourceName($dsn);
- }
-
- private function getUserName($userid)
- {
+<?php
+class AccessFile
+{
+
+ private $database;
+
+ function __construct()
+ {
+ require("config.php");
+ $this->database = new TAdodb;
+ $this->database->setDataSourceName($dsn);
+ }
+
+ private function getUserName($userid)
+ {
                 //User 0 is the '*' referring to all users in the svn access file
                 if($userid==0) return "*";
                 
- $user = $this->database->Execute("SELECT * FROM users WHERE id='$userid'");
- if($user)
- return $user->fields['name'];
- else
- return null;
- }
-
- /*
- * Access:
- * 0 = no access
- * 1 = r
- * 2 = w
- * 3 = rw
- */
- public function createFromDatabase()
- {
- $accessfile = "";
-
- //Groups
- $groups = $this->database->Execute("SELECT * FROM groups ORDER BY name");
-
- if ($groups) {
- $accessfile .= "[groups]\n";
-
- while (!$groups->EOF) {
- $groupname = $groups->fields['name'];
- $groupid = $groups->fields['id'];
-
- $test = $this->database->Execute("SELECT * FROM usersgroups");
-
- $usergroups = $this->database->Execute("SELECT * FROM usersgroups WHERE groupid='$groupid'");
-
- if ($usergroups) {
-
- $accessfile .= "$groupname = ";
- $first = true;
- while (!$usergroups->EOF) {
- $userid = $usergroups->fields['userid'];
-
- $username = $this->getUserName($userid);
-
- if ($username == null) {
- error_log("Database inconsistent, can't find user that exists in group!'");
- exit (-1);
- }
-
- if ($first) {
- $first = false;
- } else {
- $accessfile .= ", ";
- }
-
- $accessfile .= "$username";
- $usergroups->MoveNext();
- }
- $usergroups->Close();
- $accessfile .= "\n";
- }
-
- $groups->MoveNext();
- }
- $groups->Close();
- }
-
- $accessfile .= "\n";
-
- //Access
- $repositories = $this->database->Execute("SELECT * FROM repositories");
-
- while (!$repositories->EOF) {
- $repositoryname = $repositories->fields['name'];
- $repositoryid = $repositories->fields['id'];
- $ownerid = $repositories->fields['ownerid'];
- $ownername = $this->getUserName($ownerid);
-
- if ($ownername == null) {
- error_log("Database inconsistent, can't find user that owns repository!'");
- exit (-1);
- }
- $accessfile .= "[$repositoryname:/]\n";
- $accessfile .= "$ownername = rw\n";
- $lastUrl = "$repositoryname:/";
-
- //User privileges
- $userprivileges = $this->database->Execute("SELECT * FROM userprivileges WHERE repositoryid='$repositoryid'");
- if ($userprivileges)
- while (!$userprivileges->EOF) {
- $username = $this->getUsername($userprivileges->fields['userid']);
- if ($username == null) {
- error_log("Database inconsistent, can't find user that has privilege'");
- exit;
- }
- $access = $userprivileges->fields['access'];
- $path = $userprivileges->fields['path'];
-
- $currUrl="$repositoryname:$path";
- if( $currUrl != $lastUrl ) { $accessfile .= "[$repositoryname:$path]\n"; $lastUrl=$currUrl; }
- $accessfile .= "$username = ";
- switch ($access) {
- case 0 :
- break;
- case 1 :
- $accessfile .= "r";
- break;
- case 2 :
- $accessfile .= "w";
- break;
- case 3 :
- $accessfile .= "rw";
- break;
- }
- $accessfile .= "\n";
- $userprivileges->MoveNext();
- }
- $userprivileges->Close();
-
- //Group privileges
- $groupprivileges = $this->database->Execute("SELECT * FROM groupprivileges WHERE repositoryid='$repositoryid'");
- if ($groupprivileges)
- while (!$groupprivileges->EOF) {
- $groupid = $groupprivileges->fields['groupid'];
- $group = $this->database->Execute("SELECT * FROM groups WHERE id='$groupid'");
- if (!$group) {
- error_log("Database inconsistent, can't find group that has privilege'");
- exit;
- }
- $groupname = $group->fields['name'];
- $access = $groupprivileges->fields['access'];
- $path = $groupprivileges->fields['path'];
-
- $currUrl = "$repositoryname:$path";
- if( $currUrl != $lastUrl ) { $accessfile .= "[$repositoryname:$path]\n"; $lastUrl=$currUrl; }
- $accessfile .= "@$groupname = ";
- switch ($access) {
- case 0 :
- break;
- case 1 :
- $accessfile .= "r";
- break;
- case 2 :
- $accessfile .= "w";
- break;
- case 3 :
- $accessfile .= "rw";
- break;
- }
- $accessfile .= "\n";
- $groupprivileges->MoveNext();
- }
- $groupprivileges->Close();
- $accessfile .= "\n";
- $repositories->MoveNext();
- }
- $repositories->Close();
-
- require ("config.php");
- $filename = $svn_access_file;
-
- // if (is_writable($filename))
- // {
- if (!$handle = fopen($filename, 'w')) {
- echo "Cannot open file ($filename)";
- exit;
- }
- if (fwrite($handle, $accessfile) === FALSE) {
- echo "Cannot write to file ($filename)";
- exit;
- }
-
- fclose($handle);
- // } else {
- // error_log("File not writable");
- // }
-
- }
-
+ $user = $this->database->Execute("SELECT * FROM users WHERE id='$userid'");
+ if($user)
+ return $user->fields['name'];
+ else
+ return null;
+ }
+
+ /*
+ * Access:
+ * 0 = no access
+ * 1 = r
+ * 2 = w
+ * 3 = rw
+ */
+ public function createFromDatabase()
+ {
+ $accessfile = "";
+
+ //Groups
+ $groups = $this->database->Execute("SELECT * FROM groups ORDER BY name");
+
+ if ($groups) {
+ $accessfile .= "[groups]\n";
+
+ while (!$groups->EOF) {
+ $groupname = $groups->fields['name'];
+ $groupid = $groups->fields['id'];
+
+ $test = $this->database->Execute("SELECT * FROM usersgroups");
+
+ $usergroups = $this->database->Execute("SELECT * FROM usersgroups WHERE groupid='$groupid'");
+
+ if ($usergroups) {
+
+ $accessfile .= "$groupname = ";
+ $first = true;
+ while (!$usergroups->EOF) {
+ $userid = $usergroups->fields['userid'];
+
+ $username = $this->getUserName($userid);
+
+ if ($username == null) {
+ error_log("Database inconsistent, can't find user that exists in group!'");
+ exit (-1);
+ }
+
+ if ($first) {
+ $first = false;
+ } else {
+ $accessfile .= ", ";
+ }
+
+ $accessfile .= "$username";
+ $usergroups->MoveNext();
+ }
+ $usergroups->Close();
+ $accessfile .= "\n";
+ }
+
+ $groups->MoveNext();
+ }
+ $groups->Close();
+ }
+
+ $accessfile .= "\n";
+
+ //Access
+ $repositories = $this->database->Execute("SELECT * FROM repositories");
+
+ while (!$repositories->EOF) {
+ $repositoryname = $repositories->fields['name'];
+ $repositoryid = $repositories->fields['id'];
+ $ownerid = $repositories->fields['ownerid'];
+ $ownername = $this->getUserName($ownerid);
+
+ if ($ownername == null) {
+ error_log("Database inconsistent, can't find user that owns repository!'");
+ exit (-1);
+ }
+ $accessfile .= "[$repositoryname:/]\n";
+ $accessfile .= "$ownername = rw\n";
+ $lastUrl = "$repositoryname:/";
+
+ //User privileges
+ $userprivileges = $this->database->Execute("SELECT * FROM userprivileges WHERE repositoryid='$repositoryid'");
+ if ($userprivileges)
+ while (!$userprivileges->EOF) {
+ $username = $this->getUsername($userprivileges->fields['userid']);
+ if ($username == null) {
+ error_log("Database inconsistent, can't find user that has privilege'");
+ exit;
+ }
+ $access = $userprivileges->fields['access'];
+ $path = $userprivileges->fields['path'];
+
+ $currUrl="$repositoryname:$path";
+ if( $currUrl != $lastUrl ) { $accessfile .= "[$repositoryname:$path]\n"; $lastUrl=$currUrl; }
+ $accessfile .= "$username = ";
+ switch ($access) {
+ case 0 :
+ break;
+ case 1 :
+ $accessfile .= "r";
+ break;
+ case 2 :
+ $accessfile .= "w";
+ break;
+ case 3 :
+ $accessfile .= "rw";
+ break;
+ }
+ $accessfile .= "\n";
+ $userprivileges->MoveNext();
+ }
+ $userprivileges->Close();
+
+ //Group privileges
+ $groupprivileges = $this->database->Execute("SELECT * FROM groupprivileges WHERE repositoryid='$repositoryid'");
+ if ($groupprivileges)
+ while (!$groupprivileges->EOF) {
+ $groupid = $groupprivileges->fields['groupid'];
+ $group = $this->database->Execute("SELECT * FROM groups WHERE id='$groupid'");
+ if (!$group) {
+ error_log("Database inconsistent, can't find group that has privilege'");
+ exit;
+ }
+ $groupname = $group->fields['name'];
+ $access = $groupprivileges->fields['access'];
+ $path = $groupprivileges->fields['path'];
+
+ $currUrl = "$repositoryname:$path";
+ if( $currUrl != $lastUrl ) { $accessfile .= "[$repositoryname:$path]\n"; $lastUrl=$currUrl; }
+ $accessfile .= "@$groupname = ";
+ switch ($access) {
+ case 0 :
+ break;
+ case 1 :
+ $accessfile .= "r";
+ break;
+ case 2 :
+ $accessfile .= "w";
+ break;
+ case 3 :
+ $accessfile .= "rw";
+ break;
+ }
+ $accessfile .= "\n";
+ $groupprivileges->MoveNext();
+ }
+ $groupprivileges->Close();
+ $accessfile .= "\n";
+ $repositories->MoveNext();
+ }
+ $repositories->Close();
+
+ require ("config.php");
+ $filename = $svn_access_file;
+
+ // if (is_writable($filename))
+ // {
+ if (!$handle = fopen($filename, 'w')) {
+ echo "Cannot open file ($filename)";
+ exit;
+ }
+ if (fwrite($handle, $accessfile) === FALSE) {
+ echo "Cannot write to file ($filename)";
+ exit;
+ }
+
+ fclose($handle);
+ // } else {
+ // error_log("File not writable");
+ // }
+
+ }
+
 }
\ No newline at end of file

Modified: svnmanager/library/class.smtp.php
==============================================================================
--- svnmanager/library/class.smtp.php (original)
+++ svnmanager/library/class.smtp.php 2007-07-26 19:23:53 EDT (Thu, 26 Jul 2007)
@@ -1,1039 +1,1039 @@
-<?php
-////////////////////////////////////////////////////
-// SMTP - PHP SMTP class
-//
-// Version 1.02
-//
-// Define an SMTP class that can be used to connect
-// and communicate with any SMTP server. It implements
-// all the SMTP functions defined in RFC821 except TURN.
-//
-// Author: Chris Ryan
-//
-// License: LGPL, see LICENSE
-////////////////////////////////////////////////////
-
-/**
- * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
- * commands except TURN which will always return a not implemented
- * error. SMTP also provides some utility methods for sending mail
- * to an SMTP server.
- * @package PHPMailer
- * @author Chris Ryan
- */
-class SMTP
-{
- /**
- * SMTP server port
- * @var int
- */
- var $SMTP_PORT = 25;
-
- /**
- * SMTP reply line ending
- * @var string
- */
- var $CRLF = "\r\n";
-
- /**
- * Sets whether debugging is turned on
- * @var bool
- */
- var $do_debug; # the level of debug to perform
-
- /**#@+
- * @access private
- */
- var $smtp_conn; # the socket to the server
- var $error; # error if any on the last call
- var $helo_rply; # the reply the server sent to us for HELO
- /**#@-*/
-
- /**
- * Initialize the class so that the data is in a known state.
- * @access public
- * @return void
- */
- function SMTP() {
- $this->smtp_conn = 0;
- $this->error = null;
- $this->helo_rply = null;
-
- $this->do_debug = 0;
- }
-
- /*************************************************************
- * CONNECTION FUNCTIONS *
- ***********************************************************/
-
- /**
- * Connect to the server specified on the port specified.
- * If the port is not specified use the default SMTP_PORT.
- * If tval is specified then a connection will try and be
- * established with the server for that number of seconds.
- * If tval is not specified the default is 30 seconds to
- * try on the connection.
- *
- * SMTP CODE SUCCESS: 220
- * SMTP CODE FAILURE: 421
- * @access public
- * @return bool
- */
- function Connect($host,$port=0,$tval=30) {
- # set the error val to null so there is no confusion
- $this->error = null;
-
- # make sure we are __not__ connected
- if($this->connected()) {
- # ok we are connected! what should we do?
- # for now we will just give an error saying we
- # are already connected
- $this->error =
- array("error" => "Already connected to a server");
- return false;
- }
-
- if(empty($port)) {
- $port = $this->SMTP_PORT;
- }
-
- #connect to the smtp server
- $this->smtp_conn = fsockopen($host, # the host of the server
- $port, # the port to use
- $errno, # error number if any
- $errstr, # error message if any
- $tval); # give up after ? secs
- # verify we connected properly
- if(empty($this->smtp_conn)) {
- $this->error = array("error" => "Failed to connect to server",
- "errno" => $errno,
- "errstr" => $errstr);
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": $errstr ($errno)" . $this->CRLF;
- }
- return false;
- }
-
- # sometimes the SMTP server takes a little longer to respond
- # so we will give it a longer timeout for the first read
- // Windows still does not have support for this timeout function
- if(substr(PHP_OS, 0, 3) != "WIN")
- socket_set_timeout($this->smtp_conn, $tval, 0);
-
- # get any announcement stuff
- $announce = $this->get_lines();
-
- # set the timeout of any socket functions at 1/10 of a second
- //if(function_exists("socket_set_timeout"))
- // socket_set_timeout($this->smtp_conn, 0, 100000);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
- }
-
- return true;
- }
-
- /**
- * Performs SMTP authentication. Must be run after running the
- * Hello() method. Returns true if successfully authenticated.
- * @access public
- * @return bool
- */
- function Authenticate($username, $password) {
- // Start authentication
- fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "AUTH not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded username
- fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 334) {
- $this->error =
- array("error" => "Username not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- // Send encoded password
- fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($code != 235) {
- $this->error =
- array("error" => "Password not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns true if connected to a server otherwise false
- * @access private
- * @return bool
- */
- function Connected() {
- if(!empty($this->smtp_conn)) {
- $sock_status = socket_get_status($this->smtp_conn);
- if($sock_status["eof"]) {
- # hmm this is an odd situation... the socket is
- # valid but we aren't connected anymore
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE:" . $this->CRLF .
- "EOF caught while checking if connected";
- }
- $this->Close();
- return false;
- }
- return true; # everything looks good
- }
- return false;
- }
-
- /**
- * Closes the socket and cleans up the state of the class.
- * It is not considered good to use this function without
- * first trying to use QUIT.
- * @access public
- * @return void
- */
- function Close() {
- $this->error = null; # so there is no confusion
- $this->helo_rply = null;
- if(!empty($this->smtp_conn)) {
- # close the connection and cleanup
- fclose($this->smtp_conn);
- $this->smtp_conn = 0;
- }
- }
-
-
- /***************************************************************
- * SMTP COMMANDS *
- *************************************************************/
-
- /**
- * Issues a data command and sends the msg_data to the server
- * finializing the mail transaction. $msg_data is the message
- * that is to be send with the headers. Each header needs to be
- * on a single line followed by a <CRLF> with the message headers
- * and the message body being seperated by and additional <CRLF>.
- *
- * Implements rfc 821: DATA <CRLF>
- *
- * SMTP CODE INTERMEDIATE: 354
- * [data]
- * <CRLF>.<CRLF>
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 552,554,451,452
- * SMTP CODE FAILURE: 451,554
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Data($msg_data) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Data() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"DATA" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 354) {
- $this->error =
- array("error" => "DATA command not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- # the server is ready to accept data!
- # according to rfc 821 we should not send more than 1000
- # including the CRLF
- # characters on a single line so we will break the data up
- # into lines by \r and/or \n then if needed we will break
- # each of those into smaller lines to fit within the limit.
- # in addition we will be looking for lines that start with
- # a period '.' and append and additional period '.' to that
- # line. NOTE: this does not count towards are limit.
-
- # normalize the line breaks so we know the explode works
- $msg_data = str_replace("\r\n","\n",$msg_data);
- $msg_data = str_replace("\r","\n",$msg_data);
- $lines = explode("\n",$msg_data);
-
- # we need to find a good way to determine is headers are
- # in the msg_data or if it is a straight msg body
- # currently I'm assuming rfc 822 definitions of msg headers
- # and if the first field of the first line (':' sperated)
- # does not contain a space then it _should_ be a header
- # and we can process all lines before a blank "" line as
- # headers.
- $field = substr($lines[0],0,strpos($lines[0],":"));
- $in_headers = false;
- if(!empty($field) && !strstr($field," ")) {
- $in_headers = true;
- }
-
- $max_line_length = 998; # used below; set here for ease in change
-
- while(list(,$line) = @each($lines)) {
- $lines_out = null;
- if($line == "" && $in_headers) {
- $in_headers = false;
- }
- # ok we need to break this line up into several
- # smaller lines
- while(strlen($line) > $max_line_length) {
- $pos = strrpos(substr($line,0,$max_line_length)," ");
- $lines_out[] = substr($line,0,$pos);
- $line = substr($line,$pos + 1);
- # if we are processing headers we need to
- # add a LWSP-char to the front of the new line
- # rfc 822 on long msg headers
- if($in_headers) {
- $line = "\t" . $line;
- }
- }
- $lines_out[] = $line;
-
- # now send the lines to the server
- while(list(,$line_out) = @each($lines_out)) {
- if(strlen($line_out) > 0)
- {
- if(substr($line_out, 0, 1) == ".") {
- $line_out = "." . $line_out;
- }
- }
- fputs($this->smtp_conn,$line_out . $this->CRLF);
- }
- }
-
- # ok all the message data has been sent so lets get this
- # over with aleady
- fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "DATA not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Expand takes the name and asks the server to list all the
- * people who are members of the _list_. Expand will return
- * back and array of the result or false if an error occurs.
- * Each value in the array returned has the format of:
- * [ <full-name> <sp> ] <path>
- * The definition of <path> is defined in rfc 821
- *
- * Implements rfc 821: EXPN <SP> <string> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 550
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string array
- */
- function Expand($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Expand() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "EXPN not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- # parse the reply and place in our array to return to user
- $entries = explode($this->CRLF,$rply);
- while(list(,$l) = @each($entries)) {
- $list[] = substr($l,4);
- }
-
- return $list;
- }
-
- /**
- * Sends the HELO command to the smtp server.
- * This makes sure that we and the server are in
- * the same known state.
- *
- * Implements from rfc 821: HELO <SP> <domain> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 501, 504, 421
- * @access public
- * @return bool
- */
- function Hello($host="") {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Hello() without being connected");
- return false;
- }
-
- # if a hostname for the HELO wasn't specified determine
- # a suitable one to send
- if(empty($host)) {
- # we need to determine some sort of appopiate default
- # to send to the server
- $host = "localhost";
- }
-
- // Send extended hello first (RFC 2821)
- if(!$this->SendHello("EHLO", $host))
- {
- if(!$this->SendHello("HELO", $host))
- return false;
- }
-
- return true;
- }
-
- /**
- * Sends a HELO/EHLO command.
- * @access private
- * @return bool
- */
- function SendHello($hello, $host) {
- fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => $hello . " not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- $this->helo_rply = $rply;
-
- return true;
- }
-
- /**
- * Gets help information on the keyword specified. If the keyword
- * is not specified then returns generic help, ussually contianing
- * A list of keywords that help is available on. This function
- * returns the results back to the user. It is up to the user to
- * handle the returned data. If an error occurs then false is
- * returned with $this->error set appropiately.
- *
- * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
- *
- * SMTP CODE SUCCESS: 211,214
- * SMTP CODE ERROR : 500,501,502,504,421
- * @access public
- * @return string
- */
- function Help($keyword="") {
- $this->error = null; # to avoid confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Help() without being connected");
- return false;
- }
-
- $extra = "";
- if(!empty($keyword)) {
- $extra = " " . $keyword;
- }
-
- fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 211 && $code != 214) {
- $this->error =
- array("error" => "HELP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return $rply;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command.
- *
- * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,421
- * @access public
- * @return bool
- */
- function Mail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Mail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "MAIL not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the command NOOP to the SMTP server.
- *
- * Implements from rfc 821: NOOP <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500, 421
- * @access public
- * @return bool
- */
- function Noop() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Noop() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"NOOP" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "NOOP not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the quit command to the server and then closes the socket
- * if there is no error or the $close_on_error argument is true.
- *
- * Implements from rfc 821: QUIT <CRLF>
- *
- * SMTP CODE SUCCESS: 221
- * SMTP CODE ERROR : 500
- * @access public
- * @return bool
- */
- function Quit($close_on_error=true) {
- $this->error = null; # so there is no confusion
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Quit() without being connected");
- return false;
- }
-
- # send the quit command to the server
- fputs($this->smtp_conn,"quit" . $this->CRLF);
-
- # get any good-bye messages
- $byemsg = $this->get_lines();
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
- }
-
- $rval = true;
- $e = null;
-
- $code = substr($byemsg,0,3);
- if($code != 221) {
- # use e as a tmp var cause Close will overwrite $this->error
- $e = array("error" => "SMTP server rejected quit command",
- "smtp_code" => $code,
- "smtp_rply" => substr($byemsg,4));
- $rval = false;
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $e["error"] . ": " .
- $byemsg . $this->CRLF;
- }
- }
-
- if(empty($e) || $close_on_error) {
- $this->Close();
- }
-
- return $rval;
- }
-
- /**
- * Sends the command RCPT to the SMTP server with the TO: argument of $to.
- * Returns true if the recipient was accepted false if it was rejected.
- *
- * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,552,553,450,451,452
- * SMTP CODE ERROR : 500,501,503,421
- * @access public
- * @return bool
- */
- function Recipient($to) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Recipient() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "RCPT not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Sends the RSET command to abort and transaction that is
- * currently in progress. Returns true if successful false
- * otherwise.
- *
- * Implements rfc 821: RSET <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE ERROR : 500,501,504,421
- * @access public
- * @return bool
- */
- function Reset() {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Reset() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"RSET" . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "RSET failed",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
-
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in.
- *
- * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function Send($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Send() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SEND not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in and send them an email.
- *
- * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendAndMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendAndMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SAML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * Starts a mail transaction from the email address specified in
- * $from. Returns true if successful or false otherwise. If True
- * the mail transaction is started and then one or more Recipient
- * commands may be called followed by a Data command. This command
- * will send the message to the users terminal if they are logged
- * in or mail it to them if they are not.
- *
- * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE SUCCESS: 552,451,452
- * SMTP CODE SUCCESS: 500,501,502,421
- * @access public
- * @return bool
- */
- function SendOrMail($from) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called SendOrMail() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250) {
- $this->error =
- array("error" => "SOML not accepted from server",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return true;
- }
-
- /**
- * This is an optional command for SMTP that this class does not
- * support. This method is here to make the RFC821 Definition
- * complete for this class and __may__ be implimented in the future
- *
- * Implements from rfc 821: TURN <CRLF>
- *
- * SMTP CODE SUCCESS: 250
- * SMTP CODE FAILURE: 502
- * SMTP CODE ERROR : 500, 503
- * @access public
- * @return bool
- */
- function Turn() {
- $this->error = array("error" => "This method, TURN, of the SMTP ".
- "is not implemented");
- if($this->do_debug >= 1) {
- echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
- }
- return false;
- }
-
- /**
- * Verifies that the name is recognized by the server.
- * Returns false if the name could not be verified otherwise
- * the response from the server is returned.
- *
- * Implements rfc 821: VRFY <SP> <string> <CRLF>
- *
- * SMTP CODE SUCCESS: 250,251
- * SMTP CODE FAILURE: 550,551,553
- * SMTP CODE ERROR : 500,501,502,421
- * @access public
- * @return int
- */
- function Verify($name) {
- $this->error = null; # so no confusion is caused
-
- if(!$this->connected()) {
- $this->error = array(
- "error" => "Called Verify() without being connected");
- return false;
- }
-
- fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
-
- $rply = $this->get_lines();
- $code = substr($rply,0,3);
-
- if($this->do_debug >= 2) {
- echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
- }
-
- if($code != 250 && $code != 251) {
- $this->error =
- array("error" => "VRFY failed on name '$name'",
- "smtp_code" => $code,
- "smtp_msg" => substr($rply,4));
- if($this->do_debug >= 1) {
- echo "SMTP -> ERROR: " . $this->error["error"] .
- ": " . $rply . $this->CRLF;
- }
- return false;
- }
- return $rply;
- }
-
- /*******************************************************************
- * INTERNAL FUNCTIONS *
- ******************************************************************/
-
- /**
- * Read in as many lines as possible
- * either before eof or socket timeout occurs on the operation.
- * With SMTP we can tell if we have more lines to read if the
- * 4th character is '-' symbol. If it is a space then we don't
- * need to read anything else.
- * @access private
- * @return string
- */
- function get_lines() {
- $data = "";
- while($str = fgets($this->smtp_conn,515)) {
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data was \"$data\"" .
- $this->CRLF;
- echo "SMTP -> get_lines(): \$str is \"$str\"" .
- $this->CRLF;
- }
- $data .= $str;
- if($this->do_debug >= 4) {
- echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
- }
- # if the 4th character is a space then we are done reading
- # so just break the loop
- if(substr($str,3,1) == " ") { break; }
- }
- return $data;
- }
-
-}
-
-
- ?>
+<?php
+////////////////////////////////////////////////////
+// SMTP - PHP SMTP class
+//
+// Version 1.02
+//
+// Define an SMTP class that can be used to connect
+// and communicate with any SMTP server. It implements
+// all the SMTP functions defined in RFC821 except TURN.
+//
+// Author: Chris Ryan
+//
+// License: LGPL, see LICENSE
+////////////////////////////////////////////////////
+
+/**
+ * SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
+ * commands except TURN which will always return a not implemented
+ * error. SMTP also provides some utility methods for sending mail
+ * to an SMTP server.
+ * @package PHPMailer
+ * @author Chris Ryan
+ */
+class SMTP
+{
+ /**
+ * SMTP server port
+ * @var int
+ */
+ var $SMTP_PORT = 25;
+
+ /**
+ * SMTP reply line ending
+ * @var string
+ */
+ var $CRLF = "\r\n";
+
+ /**
+ * Sets whether debugging is turned on
+ * @var bool
+ */
+ var $do_debug; # the level of debug to perform
+
+ /**#@+
+ * @access private
+ */
+ var $smtp_conn; # the socket to the server
+ var $error; # error if any on the last call
+ var $helo_rply; # the reply the server sent to us for HELO
+ /**#@-*/
+
+ /**
+ * Initialize the class so that the data is in a known state.
+ * @access public
+ * @return void
+ */
+ function SMTP() {
+ $this->smtp_conn = 0;
+ $this->error = null;
+ $this->helo_rply = null;
+
+ $this->do_debug = 0;
+ }
+
+ /*************************************************************
+ * CONNECTION FUNCTIONS *
+ ***********************************************************/
+
+ /**
+ * Connect to the server specified on the port specified.
+ * If the port is not specified use the default SMTP_PORT.
+ * If tval is specified then a connection will try and be
+ * established with the server for that number of seconds.
+ * If tval is not specified the default is 30 seconds to
+ * try on the connection.
+ *
+ * SMTP CODE SUCCESS: 220
+ * SMTP CODE FAILURE: 421
+ * @access public
+ * @return bool
+ */
+ function Connect($host,$port=0,$tval=30) {
+ # set the error val to null so there is no confusion
+ $this->error = null;
+
+ # make sure we are __not__ connected
+ if($this->connected()) {
+ # ok we are connected! what should we do?
+ # for now we will just give an error saying we
+ # are already connected
+ $this->error =
+ array("error" => "Already connected to a server");
+ return false;
+ }
+
+ if(empty($port)) {
+ $port = $this->SMTP_PORT;
+ }
+
+ #connect to the smtp server
+ $this->smtp_conn = fsockopen($host, # the host of the server
+ $port, # the port to use
+ $errno, # error number if any
+ $errstr, # error message if any
+ $tval); # give up after ? secs
+ # verify we connected properly
+ if(empty($this->smtp_conn)) {
+ $this->error = array("error" => "Failed to connect to server",
+ "errno" => $errno,
+ "errstr" => $errstr);
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": $errstr ($errno)" . $this->CRLF;
+ }
+ return false;
+ }
+
+ # sometimes the SMTP server takes a little longer to respond
+ # so we will give it a longer timeout for the first read
+ // Windows still does not have support for this timeout function
+ if(substr(PHP_OS, 0, 3) != "WIN")
+ socket_set_timeout($this->smtp_conn, $tval, 0);
+
+ # get any announcement stuff
+ $announce = $this->get_lines();
+
+ # set the timeout of any socket functions at 1/10 of a second
+ //if(function_exists("socket_set_timeout"))
+ // socket_set_timeout($this->smtp_conn, 0, 100000);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $announce;
+ }
+
+ return true;
+ }
+
+ /**
+ * Performs SMTP authentication. Must be run after running the
+ * Hello() method. Returns true if successfully authenticated.
+ * @access public
+ * @return bool
+ */
+ function Authenticate($username, $password) {
+ // Start authentication
+ fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "AUTH not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ // Send encoded username
+ fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 334) {
+ $this->error =
+ array("error" => "Username not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ // Send encoded password
+ fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($code != 235) {
+ $this->error =
+ array("error" => "Password not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Returns true if connected to a server otherwise false
+ * @access private
+ * @return bool
+ */
+ function Connected() {
+ if(!empty($this->smtp_conn)) {
+ $sock_status = socket_get_status($this->smtp_conn);
+ if($sock_status["eof"]) {
+ # hmm this is an odd situation... the socket is
+ # valid but we aren't connected anymore
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE:" . $this->CRLF .
+ "EOF caught while checking if connected";
+ }
+ $this->Close();
+ return false;
+ }
+ return true; # everything looks good
+ }
+ return false;
+ }
+
+ /**
+ * Closes the socket and cleans up the state of the class.
+ * It is not considered good to use this function without
+ * first trying to use QUIT.
+ * @access public
+ * @return void
+ */
+ function Close() {
+ $this->error = null; # so there is no confusion
+ $this->helo_rply = null;
+ if(!empty($this->smtp_conn)) {
+ # close the connection and cleanup
+ fclose($this->smtp_conn);
+ $this->smtp_conn = 0;
+ }
+ }
+
+
+ /***************************************************************
+ * SMTP COMMANDS *
+ *************************************************************/
+
+ /**
+ * Issues a data command and sends the msg_data to the server
+ * finializing the mail transaction. $msg_data is the message
+ * that is to be send with the headers. Each header needs to be
+ * on a single line followed by a <CRLF> with the message headers
+ * and the message body being seperated by and additional <CRLF>.
+ *
+ * Implements rfc 821: DATA <CRLF>
+ *
+ * SMTP CODE INTERMEDIATE: 354
+ * [data]
+ * <CRLF>.<CRLF>
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 552,554,451,452
+ * SMTP CODE FAILURE: 451,554
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Data($msg_data) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Data() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"DATA" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 354) {
+ $this->error =
+ array("error" => "DATA command not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ # the server is ready to accept data!
+ # according to rfc 821 we should not send more than 1000
+ # including the CRLF
+ # characters on a single line so we will break the data up
+ # into lines by \r and/or \n then if needed we will break
+ # each of those into smaller lines to fit within the limit.
+ # in addition we will be looking for lines that start with
+ # a period '.' and append and additional period '.' to that
+ # line. NOTE: this does not count towards are limit.
+
+ # normalize the line breaks so we know the explode works
+ $msg_data = str_replace("\r\n","\n",$msg_data);
+ $msg_data = str_replace("\r","\n",$msg_data);
+ $lines = explode("\n",$msg_data);
+
+ # we need to find a good way to determine is headers are
+ # in the msg_data or if it is a straight msg body
+ # currently I'm assuming rfc 822 definitions of msg headers
+ # and if the first field of the first line (':' sperated)
+ # does not contain a space then it _should_ be a header
+ # and we can process all lines before a blank "" line as
+ # headers.
+ $field = substr($lines[0],0,strpos($lines[0],":"));
+ $in_headers = false;
+ if(!empty($field) && !strstr($field," ")) {
+ $in_headers = true;
+ }
+
+ $max_line_length = 998; # used below; set here for ease in change
+
+ while(list(,$line) = @each($lines)) {
+ $lines_out = null;
+ if($line == "" && $in_headers) {
+ $in_headers = false;
+ }
+ # ok we need to break this line up into several
+ # smaller lines
+ while(strlen($line) > $max_line_length) {
+ $pos = strrpos(substr($line,0,$max_line_length)," ");
+ $lines_out[] = substr($line,0,$pos);
+ $line = substr($line,$pos + 1);
+ # if we are processing headers we need to
+ # add a LWSP-char to the front of the new line
+ # rfc 822 on long msg headers
+ if($in_headers) {
+ $line = "\t" . $line;
+ }
+ }
+ $lines_out[] = $line;
+
+ # now send the lines to the server
+ while(list(,$line_out) = @each($lines_out)) {
+ if(strlen($line_out) > 0)
+ {
+ if(substr($line_out, 0, 1) == ".") {
+ $line_out = "." . $line_out;
+ }
+ }
+ fputs($this->smtp_conn,$line_out . $this->CRLF);
+ }
+ }
+
+ # ok all the message data has been sent so lets get this
+ # over with aleady
+ fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "DATA not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Expand takes the name and asks the server to list all the
+ * people who are members of the _list_. Expand will return
+ * back and array of the result or false if an error occurs.
+ * Each value in the array returned has the format of:
+ * [ <full-name> <sp> ] <path>
+ * The definition of <path> is defined in rfc 821
+ *
+ * Implements rfc 821: EXPN <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 550
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string array
+ */
+ function Expand($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Expand() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"EXPN " . $name . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "EXPN not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ # parse the reply and place in our array to return to user
+ $entries = explode($this->CRLF,$rply);
+ while(list(,$l) = @each($entries)) {
+ $list[] = substr($l,4);
+ }
+
+ return $list;
+ }
+
+ /**
+ * Sends the HELO command to the smtp server.
+ * This makes sure that we and the server are in
+ * the same known state.
+ *
+ * Implements from rfc 821: HELO <SP> <domain> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 501, 504, 421
+ * @access public
+ * @return bool
+ */
+ function Hello($host="") {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Hello() without being connected");
+ return false;
+ }
+
+ # if a hostname for the HELO wasn't specified determine
+ # a suitable one to send
+ if(empty($host)) {
+ # we need to determine some sort of appopiate default
+ # to send to the server
+ $host = "localhost";
+ }
+
+ // Send extended hello first (RFC 2821)
+ if(!$this->SendHello("EHLO", $host))
+ {
+ if(!$this->SendHello("HELO", $host))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Sends a HELO/EHLO command.
+ * @access private
+ * @return bool
+ */
+ function SendHello($hello, $host) {
+ fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER: " . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => $hello . " not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ $this->helo_rply = $rply;
+
+ return true;
+ }
+
+ /**
+ * Gets help information on the keyword specified. If the keyword
+ * is not specified then returns generic help, ussually contianing
+ * A list of keywords that help is available on. This function
+ * returns the results back to the user. It is up to the user to
+ * handle the returned data. If an error occurs then false is
+ * returned with $this->error set appropiately.
+ *
+ * Implements rfc 821: HELP [ <SP> <string> ] <CRLF>
+ *
+ * SMTP CODE SUCCESS: 211,214
+ * SMTP CODE ERROR : 500,501,502,504,421
+ * @access public
+ * @return string
+ */
+ function Help($keyword="") {
+ $this->error = null; # to avoid confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Help() without being connected");
+ return false;
+ }
+
+ $extra = "";
+ if(!empty($keyword)) {
+ $extra = " " . $keyword;
+ }
+
+ fputs($this->smtp_conn,"HELP" . $extra . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 211 && $code != 214) {
+ $this->error =
+ array("error" => "HELP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return $rply;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command.
+ *
+ * Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,421
+ * @access public
+ * @return bool
+ */
+ function Mail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Mail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "MAIL not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the command NOOP to the SMTP server.
+ *
+ * Implements from rfc 821: NOOP <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500, 421
+ * @access public
+ * @return bool
+ */
+ function Noop() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Noop() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"NOOP" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "NOOP not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the quit command to the server and then closes the socket
+ * if there is no error or the $close_on_error argument is true.
+ *
+ * Implements from rfc 821: QUIT <CRLF>
+ *
+ * SMTP CODE SUCCESS: 221
+ * SMTP CODE ERROR : 500
+ * @access public
+ * @return bool
+ */
+ function Quit($close_on_error=true) {
+ $this->error = null; # so there is no confusion
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Quit() without being connected");
+ return false;
+ }
+
+ # send the quit command to the server
+ fputs($this->smtp_conn,"quit" . $this->CRLF);
+
+ # get any good-bye messages
+ $byemsg = $this->get_lines();
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $byemsg;
+ }
+
+ $rval = true;
+ $e = null;
+
+ $code = substr($byemsg,0,3);
+ if($code != 221) {
+ # use e as a tmp var cause Close will overwrite $this->error
+ $e = array("error" => "SMTP server rejected quit command",
+ "smtp_code" => $code,
+ "smtp_rply" => substr($byemsg,4));
+ $rval = false;
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $e["error"] . ": " .
+ $byemsg . $this->CRLF;
+ }
+ }
+
+ if(empty($e) || $close_on_error) {
+ $this->Close();
+ }
+
+ return $rval;
+ }
+
+ /**
+ * Sends the command RCPT to the SMTP server with the TO: argument of $to.
+ * Returns true if the recipient was accepted false if it was rejected.
+ *
+ * Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,552,553,450,451,452
+ * SMTP CODE ERROR : 500,501,503,421
+ * @access public
+ * @return bool
+ */
+ function Recipient($to) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Recipient() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "RCPT not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Sends the RSET command to abort and transaction that is
+ * currently in progress. Returns true if successful false
+ * otherwise.
+ *
+ * Implements rfc 821: RSET <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE ERROR : 500,501,504,421
+ * @access public
+ * @return bool
+ */
+ function Reset() {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Reset() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"RSET" . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "RSET failed",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in.
+ *
+ * Implements rfc 821: SEND <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function Send($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Send() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SEND FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SEND not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in and send them an email.
+ *
+ * Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendAndMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendAndMail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SAML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Starts a mail transaction from the email address specified in
+ * $from. Returns true if successful or false otherwise. If True
+ * the mail transaction is started and then one or more Recipient
+ * commands may be called followed by a Data command. This command
+ * will send the message to the users terminal if they are logged
+ * in or mail it to them if they are not.
+ *
+ * Implements rfc 821: SOML <SP> FROM:<reverse-path> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE SUCCESS: 552,451,452
+ * SMTP CODE SUCCESS: 500,501,502,421
+ * @access public
+ * @return bool
+ */
+ function SendOrMail($from) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called SendOrMail() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"SOML FROM:" . $from . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250) {
+ $this->error =
+ array("error" => "SOML not accepted from server",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * This is an optional command for SMTP that this class does not
+ * support. This method is here to make the RFC821 Definition
+ * complete for this class and __may__ be implimented in the future
+ *
+ * Implements from rfc 821: TURN <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250
+ * SMTP CODE FAILURE: 502
+ * SMTP CODE ERROR : 500, 503
+ * @access public
+ * @return bool
+ */
+ function Turn() {
+ $this->error = array("error" => "This method, TURN, of the SMTP ".
+ "is not implemented");
+ if($this->do_debug >= 1) {
+ echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF;
+ }
+ return false;
+ }
+
+ /**
+ * Verifies that the name is recognized by the server.
+ * Returns false if the name could not be verified otherwise
+ * the response from the server is returned.
+ *
+ * Implements rfc 821: VRFY <SP> <string> <CRLF>
+ *
+ * SMTP CODE SUCCESS: 250,251
+ * SMTP CODE FAILURE: 550,551,553
+ * SMTP CODE ERROR : 500,501,502,421
+ * @access public
+ * @return int
+ */
+ function Verify($name) {
+ $this->error = null; # so no confusion is caused
+
+ if(!$this->connected()) {
+ $this->error = array(
+ "error" => "Called Verify() without being connected");
+ return false;
+ }
+
+ fputs($this->smtp_conn,"VRFY " . $name . $this->CRLF);
+
+ $rply = $this->get_lines();
+ $code = substr($rply,0,3);
+
+ if($this->do_debug >= 2) {
+ echo "SMTP -> FROM SERVER:" . $this->CRLF . $rply;
+ }
+
+ if($code != 250 && $code != 251) {
+ $this->error =
+ array("error" => "VRFY failed on name '$name'",
+ "smtp_code" => $code,
+ "smtp_msg" => substr($rply,4));
+ if($this->do_debug >= 1) {
+ echo "SMTP -> ERROR: " . $this->error["error"] .
+ ": " . $rply . $this->CRLF;
+ }
+ return false;
+ }
+ return $rply;
+ }
+
+ /*******************************************************************
+ * INTERNAL FUNCTIONS *
+ ******************************************************************/
+
+ /**
+ * Read in as many lines as possible
+ * either before eof or socket timeout occurs on the operation.
+ * With SMTP we can tell if we have more lines to read if the
+ * 4th character is '-' symbol. If it is a space then we don't
+ * need to read anything else.
+ * @access private
+ * @return string
+ */
+ function get_lines() {
+ $data = "";
+ while($str = fgets($this->smtp_conn,515)) {
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data was \"$data\"" .
+ $this->CRLF;
+ echo "SMTP -> get_lines(): \$str is \"$str\"" .
+ $this->CRLF;
+ }
+ $data .= $str;
+ if($this->do_debug >= 4) {
+ echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF;
+ }
+ # if the 4th character is a space then we are done reading
+ # so just break the loop
+ if(substr($str,3,1) == " ") { break; }
+ }
+ return $data;
+ }
+
+}
+
+
+ ?>


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk