public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $menuSelectedCategory = 'svn'; $session->set('selected_product_id', SystemProduct::SYS_PRODUCT_SVN_HOSTING); $isSVNAdministrator = $session->get('user/svn_administrator_flag'); $emptyName = false; $duplicateName = false; $emptyCode = false; $duplicateCode = false; $clientId = $session->get('client/id'); if ($request->request->has('confirm_new_svn_repository')) { $name = Util::cleanRegularInputField($request->request->get('name')); $code = Util::cleanRegularInputField($request->request->get('code')); $description = Util::cleanRegularInputField($request->request->get('description')); if (empty($name)) { $emptyName = true; } if (empty($code)) { $emptyCode = true; } else { $svn_repository_exists = $this->getRepository(SvnRepository::class)->getByCode(mb_strtolower($code), $clientId); if ($svn_repository_exists) { $duplicateCode = true; } } if (!$emptyName && !$emptyCode && !$duplicateName && !$duplicateCode) { $currentDate = Util::getServerCurrentDateTime(); $repoId = $this->getRepository(SvnRepository::class)->addRepo($clientId, $session->get('user/id'), $name, $description, $code, $currentDate); $repoPath = UbirimiContainer::get()['subversion.path'] . Util::slugify($session->get('client/company_domain')) . '/' . Util::slugify($name); /* create the repository on disk */ @mkdir(UbirimiContainer::get()['subversion.path'] . Util::slugify($session->get('client/company_domain')), 0700, true); @mkdir(UbirimiContainer::get()['subversion.path'] . Util::slugify($session->get('client/company_domain')) . '/' . Util::slugify($name), 0700, true); try { $this->getRepository(SvnRepository::class)->createSvn($repoPath); SVNUtils::createStandardDirectories($repoPath); /* add the user */ $this->getRepository(SvnRepository::class)->addUser($repoId, $session->get('user/id')); $this->getRepository(SvnRepository::class)->updateUserPermissions($repoId, $session->get('user/id'), 1, 1); /* apache config */ $this->getRepository(SvnRepository::class)->apacheConfig(Util::slugify($session->get('client/company_domain')), Util::slugify($name)); } catch (\Exception $e) { } $userEvent = new UserEvent(UserEvent::STATUS_NEW_SVN, $session->get('user/first_name'), $session->get('user/last_name'), $session->get('user/username'), null, $session->get('user/email'), array('svnRepoId' => $repoId, 'svnRepositoryName' => $name)); UbirimiContainer::get()['dispatcher']->dispatch(UbirimiEvents::USER, $userEvent); $this->getLogger()->addInfo('ADD SVN Repository ' . Util::slugify($name), $this->getLoggerContext()); return new RedirectResponse('/svn-hosting/administration/all-repositories'); } } return $this->render(__DIR__ . '/../../Resources/views/administration/AddRepository.php', get_defined_vars()); }
public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $loggedInUserId = $session->get('user/id'); $filenameData = apache_request_headers(); $filename = rawurldecode($filenameData['X_FILENAME']); $issueId = $request->request->get('issue_id'); if (!$session->has('added_attachments_in_screen')) { $session->set('added_attachments_in_screen', array()); } /* every attachment has its own dedicated sub-folder, so no editing on the upload filename will be done */ if ($filename) { $ext = substr($filename, strrpos($filename, '.') + 1); $filenameWithoutExtension = substr($filename, 0, strrpos($filename, '.')); $attachmentId = $this->getRepository(IssueAttachment::class)->add($issueId, Util::slugify($filenameWithoutExtension) . '.' . $ext, $loggedInUserId, Util::getServerCurrentDateTime()); if ($issueId == null) { $issueId = 'user_' . $loggedInUserId; } $uploadDirectory = Util::getAssetsFolder(SystemProduct::SYS_PRODUCT_YONGO) . $issueId; /* subfolders */ $uploadDirSubfolder = $uploadDirectory . '/' . $attachmentId; if (!file_exists($uploadDirectory)) { mkdir($uploadDirectory); } if (!file_exists($uploadDirSubfolder)) { mkdir($uploadDirSubfolder); } $newFileName = $uploadDirSubfolder . '/' . Util::slugify($filenameWithoutExtension) . '.' . $ext; file_put_contents($newFileName, file_get_contents('php://input')); $size = filesize($newFileName); $temp = $session->get('added_attachments_in_screen'); $temp[] = $attachmentId; $session->set('added_attachments_in_screen', $temp); $this->getRepository(IssueAttachment::class)->updateSizeById($attachmentId, $size); if (Util::isImage(Util::getExtension($filename))) { $thumbUploaddirSubfolder = $uploadDirSubfolder . '/thumbs'; if (!file_exists($thumbUploaddirSubfolder)) { mkdir($thumbUploaddirSubfolder); } $newThumbnailName = $thumbUploaddirSubfolder . '/' . Util::slugify($filenameWithoutExtension) . '.' . $ext; $image = new ZebraImage(); $image->jpeg_quality = 100; $image->chmod_value = 0755; $image->source_path = $newFileName; $image->target_path = $newThumbnailName; $image->resize(150, 150, ZEBRA_IMAGE_CROP_CENTER); } return new JsonResponse($attachmentId); } return new Response(''); }
public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $clientId = $session->get('client/id'); $loggedInUserId = $session->get('user/id'); $Id = $request->request->get('svn_id'); $repo = $this->getRepository(SvnRepository::class)->getById($Id); $this->getRepository(SvnRepository::class)->deleteById($Id); $this->getRepository(SvnRepository::class)->updateHtpasswd($repo['id'], $session->get('client/company_domain')); $this->getRepository(SvnRepository::class)->updateAuthz(); /* delete the content from hdd */ $companyDomain = Util::getSubdomain(); $path = UbirimiContainer::get()['subversion.path'] . Util::slugify($companyDomain) . '/' . Util::slugify($repo['name']); system("rm -rf {$path}"); /* refresh apache config */ $this->getRepository(SvnRepository::class)->refreshApacheConfig(); $this->getLogger()->addInfo('DELETE SVN Repository ' . $repo['name'], $this->getLoggerContext()); return new Response(''); }
public function indexAction(Request $request, SessionInterface $session) { Util::checkUserIsLoggedInAndRedirect(); $clientId = $session->get('client/id'); $loggedInUserId = $session->get('user/id'); $repoId = Util::cleanRegularInputField($request->get('id')); $menuSelectedCategory = 'svn'; $session->set('selected_product_id', SystemProduct::SYS_PRODUCT_SVN_HOSTING); $emptyCode = false; $duplicateCode = false; if ($request->request->has('confirm_edit_svn_repository')) { $repoId = Util::cleanRegularInputField($request->request->get('repo_id')); $code = Util::cleanRegularInputField($request->request->get('code')); $description = Util::cleanRegularInputField($request->request->get('description')); if (empty($code)) { $emptyCode = true; } else { $svn_repository_exists = $this->getRepository(SvnRepository::class)->getByCode(mb_strtolower($code), $clientId, $repoId); if ($svn_repository_exists) { $duplicateCode = true; } } if (!$emptyCode && !$duplicateCode) { $date = Util::getServerCurrentDateTime(); $this->getRepository(SvnRepository::class)->updateRepo($description, $code, $repoId, $date); $this->getLogger()->addInfo('UPDATE SVN Repository ' . Util::slugify($code), $this->getLoggerContext()); return new RedirectResponse('/svn-hosting/administration/all-repositories'); } } else { $svnRepo = $this->getRepository(SvnRepository::class)->getById($request->get('id')); if ($svnRepo['client_id'] != $clientId) { return new RedirectResponse('/general-settings/bad-link-access-denied'); } $name = $svnRepo['name']; $code = $svnRepo['code']; $description = $svnRepo['description']; } return $this->render(__DIR__ . '/../../Resources/views/administration/EditRepository.php', get_defined_vars()); }
public function refreshApacheConfig() { $text = ""; $query = "SELECT *\n FROM svn_repository\n LEFT JOIN client on svn_repository.client_id = client.id"; $stmt = UbirimiContainer::get()['db.connection']->prepare($query); $stmt->execute(); $result = $stmt->get_result(); while ($repo = $result->fetch_array(MYSQLI_ASSOC)) { $text .= "Use SubversionRepo " . Util::slugify($repo['company_domain']) . ' ' . Util::slugify($repo['name']) . "\n"; } file_put_contents(UbirimiContainer::get()['subversion.apache_config'], $text, LOCK_EX); }
<?php require_once __DIR__ . '/administration/_summary.php'; ?> </td> <td valign="top"> <table width="100%"> <tr> <td id="sectPeople" width="74%" class="sectionDetail" colspan="3"><span class="headerPageText sectionDetailTitle">Activity Stream (last 25 commits)</span></td> </tr> <tr> <td id="svn_activity_stream"> <?php $log = null; try { $log = SVNLog::log(UbirimiContainer::get()['subversion.path'] . Util::slugify($session->get('client/company_domain')) . '/' . Util::slugify($svnRepo['name'])); } catch (Exception $e) { } ?> <table> <?php if ($log) { ?> <?php $i = 0; ?> <?php foreach ($log as $key => $revision) { ?>
<?php use Ubirimi\Container\UbirimiContainer; use Ubirimi\Util; ?> <table width="100%"> <tr> <td id="sectIssueTypes" width="74%" class="sectionDetail" colspan="3"><span class="headerPageText sectionDetailTitle">Description</span></td> </tr> <tr> <td> <table> <tr> <td><span class="textLabel">Checkout URL:</span></td> <td><?php echo UbirimiContainer::get()['subversion.url'] . Util::slugify($session->get('client/company_domain')) . '/' . Util::slugify($svnRepo['name']) . '/trunk'; ?> </td> </tr> <tr> <td><span class="textLabel">Created by:</span></td> <td><?php echo $svnRepo['first_name'] . ' ' . $svnRepo['last_name']; ?> </td> </tr> <tr> <td><span class="textLabel">Created at:</span></td> <td><?php echo Util::getFormattedDate($svnRepo['date_created'], $clientSettings['timezone'], $clientSettings['timezone']); ?>
<br /> <br /> A new account has been set up for your <strong><?php echo $this->repoName; ?> </strong> SVN Repository. <br /> Bellow you will find the information to access the repository. <br /> <br /> Repository name: <?php echo $this->repoName; ?> <br /> Repository URL: <?php echo UbirimiContainer::get()['subversion.url'] . Util::slugify($this->clientData['company_domain']) . '/' . Util::slugify($this->repoName) . '/trunk'; ?> <br /> username: <?php echo $this->username; ?> <br /> <?php if (null != $this->password) { ?> password: <?php echo $this->password; ?> <?php } ?>