Example #1
0
 /**
  */
 public function minify()
 {
     if (!is_executable($this->_opts['java']) || !is_readable($this->_opts['closure'])) {
         $this->_opts['logger']->log('The java path or Closure location can not be accessed.', Horde_Log::ERR);
         return parent::minify();
     }
     $cmd = trim(escapeshellcmd($this->_opts['java']) . ' -jar ' . escapeshellarg($this->_opts['closure']));
     if (isset($this->_opts['sourcemap']) && is_array($this->_data)) {
         $this->_sourcemap = Horde_Util::getTempFile();
         $cmd .= ' --create_source_map ' . escapeshellarg($this->_sourcemap) . ' --source_map_format=V3';
         $suffix = "\n//# sourceMappingURL=" . $this->_opts['sourcemap'];
     } else {
         $suffix = '';
     }
     if (isset($this->_opts['cmdline'])) {
         $cmd .= ' ' . trim($this->_opts['cmdline']);
     }
     if (is_array($this->_data)) {
         $js = '';
         foreach ($this->_data as $val) {
             $cmd .= ' ' . $val;
         }
     } else {
         $js = $this->_data;
     }
     $cmdline = new Horde_JavascriptMinify_Util_Cmdline();
     return $cmdline->runCmd($js, $cmd, $this->_opts['logger']) . $suffix . $this->_sourceUrls();
 }
Example #2
0
 /**
  * Renders a token into text matching the requested format.
  *
  * @param array $options  The "options" portion of the token (second
  *                        element).
  *
  * @return string  The text rendered from the token options.
  */
 public function token($options)
 {
     if (!isset($options['attr']['alt'])) {
         $options['attr']['alt'] = $options['src'];
     }
     if (strpos($options['src'], '://') === false) {
         if ($options['src'][0] != '/') {
             if (strpos($options['src'], ':')) {
                 list($page, $options['src']) = explode(':', $options['src'], 2);
             } else {
                 $page = Horde_Util::getFormData('page');
                 if ($page == 'EditPage') {
                     $page = Horde_Util::getFormData('referrer');
                 }
                 if (empty($page)) {
                     $page = 'Wiki/Home';
                 }
             }
             $params = array('page' => $page, 'mime' => '1', 'file' => $options['src']);
             $options['src'] = $GLOBALS['registry']->downloadUrl($options['src'], $params)->setRaw(true);
         }
     } else {
         $options['src'] = new Horde_Url(Horde::externalUrl($options['src']));
         $options['src']->setRaw(true);
     }
     // Send external links through Horde::externalUrl().
     if (isset($options['attr']['link']) && strpos($options['attr']['link'], '://')) {
         $href = htmlspecialchars($options['attr']['link']);
         unset($options['attr']['link']);
         return Horde::link(Horde::externalUrl($href), $href) . $this->_token($options) . '</a>';
     } else {
         return $this->_token($options);
     }
 }
Example #3
0
File: task.php Project: horde/horde
/**
 * Copyright 2001-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Jon Parise <*****@*****.**>
 * @author Jan Schneider <*****@*****.**>
 */
function _delete($task_id, $tasklist_id)
{
    global $injector, $nag_shares, $notification, $registry;
    if (!empty($task_id)) {
        try {
            $task = Nag::getTask($tasklist_id, $task_id);
            $task->loadChildren();
            try {
                $share = $nag_shares->getShare($tasklist_id);
            } catch (Horde_Share_Exception $e) {
                throw new Nag_Exception($e);
            }
            if (!$share->hasPermission($registry->getAuth(), Horde_Perms::DELETE)) {
                $notification->push(_("Access denied deleting task."), 'horde.error');
            } else {
                $storage = $injector->getInstance('Nag_Factory_Driver')->create($tasklist_id);
                try {
                    $storage->delete($task_id);
                } catch (Nag_Exception $e) {
                    $notification->push(sprintf(_("There was a problem deleting %s: %s"), $task->name, $e->getMessage()), 'horde.error');
                }
                $notification->push(sprintf(_("Deleted %s."), $task->name), 'horde.success');
            }
        } catch (Nag_Exception $e) {
            $notification->push(sprintf(_("Error deleting task: %s"), $e->getMessage()), 'horde.error');
        }
    }
    /* Return to the last page or to the task list. */
    if ($url = Horde_Util::getFormData('url')) {
        header('Location: ' . $url);
        exit;
    }
    Horde::url('list.php', true)->redirect();
}
Example #4
0
/**
 * Does an FTP upload to save the configuration.
 */
function _uploadFTP($params)
{
    global $registry, $notification;
    $params['hostspec'] = 'localhost';
    try {
        $vfs = Horde_Vfs::factory('ftp', $params);
    } catch (Horde_Vfs_Exception $e) {
        $notification->push(sprintf(_("Could not connect to server \"%s\" using FTP: %s"), $params['hostspec'], $e->getMessage()), 'horde.error');
        return false;
    }
    /* Loop through the config and write to FTP. */
    $no_errors = true;
    foreach ($GLOBALS['session']->get('horde', 'config/') as $app => $config) {
        $path = $registry->get('fileroot', $app) . '/config';
        /* Try to back up the current conf.php. */
        if ($vfs->exists($path, 'conf.php')) {
            try {
                $vfs->rename($path, 'conf.php', $path, '/conf.bak.php');
                $notification->push(_("Successfully saved backup configuration."), 'horde.success');
            } catch (Horde_Vfs_Exception $e) {
                $notification->push(sprintf(_("Could not save a backup configuation: %s"), $e->getMessage()), 'horde.error');
            }
        }
        try {
            $vfs->writeData($path, 'conf.php', $config);
            $notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success');
            $GLOBALS['session']->remove('horde', 'config/' . $app);
        } catch (Horde_Vfs_Exception $e) {
            $no_errors = false;
            $notification->push(sprintf(_("Could not write configuration for \"%s\": %s"), $app, $e->getMessage()), 'horde.error');
        }
    }
    $registry->rebuild();
    return $no_errors;
}
Example #5
0
 /**
  * Renders this page in content mode.
  *
  * @return string  The page content.
  * @throws Wicked_Exception
  */
 public function content()
 {
     global $wicked;
     $days = (int) Horde_Util::getGet('days', 3);
     $summaries = $wicked->getRecentChanges($days);
     if (count($summaries) < 10) {
         $summaries = $wicked->mostRecent(10);
     }
     $bydate = array();
     $changes = array();
     foreach ($summaries as $page) {
         $page = new Wicked_Page_StandardPage($page);
         $createDate = $page->versionCreated();
         $tm = localtime($createDate, true);
         $createDate = mktime(0, 0, 0, $tm['tm_mon'], $tm['tm_mday'], $tm['tm_year'], $tm['tm_isdst']);
         $version_url = $page->pageUrl()->add('version', $page->version());
         $diff_url = Horde::url('diff.php')->add(array('page' => $page->pageName(), 'v1' => '?', 'v2' => $page->version()));
         $diff_alt = sprintf(_("Show changes for %s"), $page->version());
         $diff_img = Horde::img('diff.png', $diff_alt);
         $pageInfo = array('author' => $page->author(), 'name' => $page->pageName(), 'url' => $page->pageUrl(), 'version' => $page->version(), 'version_url' => $version_url, 'version_alt' => sprintf(_("Show version %s"), $page->version()), 'diff_url' => $diff_url, 'diff_alt' => $diff_alt, 'diff_img' => $diff_img, 'created' => $page->formatVersionCreated(), 'change_log' => $page->changeLog());
         $bydate[$createDate][$page->versionCreated()][$page->version()] = $pageInfo;
     }
     krsort($bydate);
     foreach ($bydate as $bysecond) {
         $day = array();
         krsort($bysecond);
         foreach ($bysecond as $pageList) {
             krsort($pageList);
             $day = array_merge($day, array_values($pageList));
         }
         $changes[] = array('date' => $day[0]['created'], 'pages' => $day);
     }
     return $changes;
 }
Example #6
0
 public function processRequest(Horde_Controller_Request $request, Horde_Controller_Response $response)
 {
     $id = Horde_Util::getFormData('bookmark');
     $gateway = $this->getInjector()->getInstance('Trean_Bookmarks');
     $notification = $this->getInjector()->getInstance('Horde_Notification');
     try {
         $bookmark = $gateway->getBookmark($id);
         $old_url = $bookmark->url;
         $bookmark->url = Horde_Util::getFormData('bookmark_url');
         $bookmark->title = Horde_Util::getFormData('bookmark_title');
         $bookmark->description = Horde_Util::getFormData('bookmark_description');
         $bookmark->tags = Horde_Util::getFormData('treanBookmarkTags');
         if ($old_url != $bookmark->url) {
             $bookmark->http_status = '';
         }
         $bookmark->save();
         $result = array('data' => 'saved');
     } catch (Horde_Exception $e) {
         $notification->push(sprintf(_("There was an error saving the bookmark: %s"), $e->getMessage()), 'horde.error');
         $result = array('error' => $e->getMessage());
     }
     if (Horde_Util::getFormData('format') == 'json') {
         $response->setContentType('application/json');
         $response->setBody(json_encode($result));
     } else {
         $response->setRedirectUrl(Horde_Util::getFormData('url', Horde::url('browse.php', true)));
     }
 }
Example #7
0
 function close($focus = false)
 {
     echo '</form>' . "\n";
     if (Horde_Util::getGet('reply_focus')) {
         echo '<script type="text/javascript">document.getElementById("message_body").focus()</script>';
     }
 }
Example #8
0
 /**
  */
 public function menu($menu)
 {
     $scope = Horde_Util::getGet('scope', 'agora');
     /* Agora Home. */
     $url = Horde::url('forums.php')->add('scope', $scope);
     $menu->add($url, _("_Forums"), 'forums.png', null, null, null, dirname($_SERVER['PHP_SELF']) == $GLOBALS['registry']->get('webroot') && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null);
     /* Thread list, if applicable. */
     if (isset($GLOBALS['forum_id'])) {
         $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('threads.php')), _("_Threads"), 'threads.png');
         if ($scope == 'agora' && $GLOBALS['registry']->getAuth()) {
             $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('messages/edit.php')), _("New Thread"), 'newmessage.png');
         }
     }
     if ($scope == 'agora' && Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
         $menu->add(Horde::url('editforum.php'), _("_New Forum"), 'newforum.png', null, null, null, Horde_Util::getFormData('agora') ? '__noselection' : null);
     }
     if (Agora_Driver::hasPermission(Horde_Perms::DELETE, 0, $scope)) {
         $url = Horde::url('moderate.php')->add('scope', $scope);
         $menu->add($url, _("_Moderate"), 'moderate.png');
     }
     if ($GLOBALS['registry']->isAdmin()) {
         $menu->add(Horde::url('moderators.php'), _("_Moderators"), 'hot.png');
     }
     $url = Horde::url('search.php')->add('scope', $scope);
     $menu->add($url, _("_Search"), 'search.png');
 }
Example #9
0
File: Zip.php Project: horde/horde
 /**
  * Return the rendered information about the Horde_Mime_Part object.
  *
  * URL parameters used by this function:
  *   - zip_contents: (integer) If set, show contents of ZIP file.
  *
  * @return array  See Horde_Mime_Viewer_Driver::render().
  */
 protected function _renderInfo()
 {
     global $injector;
     $vars = $injector->getInstance('Horde_Variables');
     if (!$this->getConfigParam('show_contents') && !$vars->zip_contents) {
         $status = new IMP_Mime_Status($this->_mimepart, _("This is a compressed file."));
         $status->addMimeAction('zipViewContents', _("Click to display the file contents."));
         $status->icon('mime/compressed.png');
         return array($this->_mimepart->getMimeId() => array('data' => '', 'status' => $status, 'type' => 'text/html; charset=UTF-8'));
     }
     $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mime'));
     $view->addHelper('Text');
     $view->downloadclass = 'zipdownload';
     $view->files = array();
     $view->tableclass = 'zipcontents';
     $zlib = Horde_Util::extensionExists('zlib');
     foreach ($this->_getZipInfo() as $key => $val) {
         $file = new stdClass();
         $file->name = $val['name'];
         $file->size = IMP::sizeFormat($val['size']);
         /* TODO: Add ability to render in-browser for filetypes we can
          *       handle. */
         if (!empty($val['size']) && strstr($val['attr'], 'D') === false && ($zlib && $val['method'] == 0x8 || $val['method'] == 0x0)) {
             $file->download = $this->getConfigParam('imp_contents')->linkView($this->_mimepart, 'download_render', '', array('class' => 'iconImg downloadAtc', 'jstext' => _("Download"), 'params' => array('zip_attachment' => $key)));
         } else {
             $file->download = '';
         }
         $view->files[] = $file;
     }
     return array($this->_mimepart->getMimeId() => array('data' => $view->render('compressed'), 'type' => 'text/html; charset=UTF-8'));
 }
Example #10
0
 /**
  * Const'r
  *
  * @see Horde_Image_Base::_construct
  */
 public function __construct($params, $context = array())
 {
     if (!Horde_Util::loadExtension('imagick')) {
         throw new Horde_Image_Exception('Required PECL Imagick extension not found.');
     }
     parent::__construct($params, $context);
     ini_set('imagick.locale_fix', 1);
     $this->_imagick = new Imagick();
     if (!empty($params['filename'])) {
         $this->loadFile($params['filename']);
     } elseif (!empty($params['data'])) {
         $this->loadString($params['data']);
     } else {
         $this->_width = max(array($this->_width, 1));
         $this->_height = max(array($this->_height, 1));
         try {
             $this->_imagick->newImage($this->_width, $this->_height, $this->_background);
         } catch (ImagickException $e) {
             throw new Horde_Image_Exception($e);
         }
     }
     try {
         $this->_imagick->setImageFormat($this->_type);
     } catch (ImagickException $e) {
         throw new Horde_Image_Exception($e);
     }
 }
Example #11
0
 /**
  * Get faces
  *
  * @param string $file Picture filename
  * @throws Horde_Exception
  */
 protected function _getFaces($file)
 {
     if (!Horde_Util::loadExtension('facedetect')) {
         throw new Ansel_Exception('You do not have the facedetect extension enabled in PHP');
     }
     return face_detect($file, $this->_defs);
 }
Example #12
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $storage1 = new Horde_SessionHandler_Storage_File(array('path' => self::$dir));
     $storage2 = new Horde_SessionHandler_Storage_File(array('path' => Horde_Util::createTempDir()));
     self::$handler = new Horde_SessionHandler_Storage_Stack(array('stack' => array($storage1, $storage2)));
 }
Example #13
0
    public function html($active = true)
    {
        if (!$this->contact) {
            echo '<h3>' . _("The requested contact was not found.") . '</h3>';
            return;
        }
        if (!$this->contact->hasPermission(Horde_Perms::DELETE)) {
            if (!$this->contact->hasPermission(Horde_Perms::READ)) {
                echo '<h3>' . _("You do not have permission to view this contact.") . '</h3>';
                return;
            } else {
                echo '<h3>' . _("You only have permission to view this contact.") . '</h3>';
                return;
            }
        }
        echo '<div id="DeleteContact"' . ($active ? '' : ' style="display:none"') . '>';
        ?>
        <form action="<?php 
        echo Horde::url('delete.php');
        ?>
" method="post">
        <?php 
        echo Horde_Util::formInput();
        ?>
        <input type="hidden" name="url" value="<?php 
        echo htmlspecialchars(Horde_Util::getFormData('url'));
        ?>
" />
        <input type="hidden" name="source" value="<?php 
        echo htmlspecialchars($this->contact->driver->getName());
        ?>
" />
        <input type="hidden" name="key" value="<?php 
        echo htmlspecialchars($this->contact->getValue('__key'));
        ?>
" />
        <div class="headerbox" style="padding: 8px">
         <p><?php 
        echo _("Permanently delete this contact?");
        ?>
</p>
         <input type="submit" class="horde-delete" name="delete" value="<?php 
        echo _("Delete");
        ?>
" />
        </div>
        </form>
        </div>
        <?php 
        if ($active && $GLOBALS['browser']->hasFeature('dom')) {
            if ($this->contact->hasPermission(Horde_Perms::READ)) {
                $view = new Turba_View_Contact($this->contact);
                $view->html(false);
            }
            if ($this->contact->hasPermission(Horde_Perms::EDIT)) {
                $delete = new Turba_View_EditContact($this->contact);
                $delete->html(false);
            }
        }
    }
Example #14
0
 /**
  */
 public function minify()
 {
     if (!is_executable($this->_opts['java']) || !is_readable($this->_opts['closure'])) {
         $this->_opts['logger']->log('The java path or Closure location can not be accessed.', Horde_Log::ERR);
         return parent::minify();
     }
     /* --warning_level QUIET - closure default is "DEFAULT" which will
      * cause code with compiler warnings to output bad js (see Bug
      * #13789) */
     $cmd = trim(escapeshellcmd($this->_opts['java']) . ' -jar ' . escapeshellarg($this->_opts['closure']) . ' --warning_level QUIET');
     if (isset($this->_opts['sourcemap']) && is_array($this->_data)) {
         $this->_sourcemap = Horde_Util::getTempFile();
         $cmd .= ' --create_source_map ' . escapeshellarg($this->_sourcemap) . ' --source_map_format=V3';
         $suffix = "\n//# sourceMappingURL=" . $this->_opts['sourcemap'];
     } else {
         $suffix = '';
     }
     if (isset($this->_opts['cmdline'])) {
         $cmd .= ' ' . trim($this->_opts['cmdline']);
     }
     if (is_array($this->_data)) {
         $js = '';
         foreach ($this->_data as $val) {
             $cmd .= ' ' . $val;
         }
     } else {
         $js = $this->_data;
     }
     $cmdline = new Horde_JavascriptMinify_Util_Cmdline();
     return $cmdline->runCmd($js, $cmd, $this->_opts['logger']) . $suffix . $this->_sourceUrls();
 }
Example #15
0
 /**
  * Const'r
  *
  */
 public function __construct($bookmarks = null, $browser = null)
 {
     $this->_bookmarks = $bookmarks;
     if ($browser) {
         $this->_browser = $browser;
     } else {
         $this->_browser = $GLOBALS['injector']->getInstance('Trean_TagBrowser');
     }
     $action = Horde_Util::getFormData('actionID', '');
     switch ($action) {
         case 'remove':
             $tag = Horde_Util::getFormData('tag');
             if (isset($tag)) {
                 $this->_browser->removeTag($tag);
                 $this->_browser->save();
             }
             break;
         case 'add':
         default:
             // Add new tag to the stack, save to session.
             $tag = Horde_Util::getFormData('tag');
             if (isset($tag)) {
                 $this->_browser->addTag($tag);
                 $this->_browser->save();
             }
     }
     // Check for empty tag search.. then do what?
     $this->_noSearch = $this->_browser->tagCount() < 1;
 }
Example #16
0
 /**
  * @throws Turba_Exception
  */
 public function execute()
 {
     // If cancel was clicked, return false.
     if ($this->_vars->get('submitbutton') == _("Cancel")) {
         Horde::url('', true)->redirect();
     }
     if (!$GLOBALS['registry']->getAuth() || $this->_addressbook->get('owner') != $GLOBALS['registry']->getAuth()) {
         throw new Turba_Exception(_("You do not have permissions to delete this address book."));
     }
     $driver = $GLOBALS['injector']->getInstance('Turba_Factory_Driver')->create($this->_addressbook->getName());
     if ($driver->hasCapability('delete_all')) {
         try {
             $driver->deleteAll();
         } catch (Turba_Exception $e) {
             Horde::log($e->getMessage(), 'ERR');
             throw $e;
         }
     }
     // Address book successfully deleted from backend, remove the share.
     try {
         $GLOBALS['injector']->getInstance('Turba_Shares')->removeShare($this->_addressbook);
     } catch (Horde_Share_Exception $e) {
         Horde::log($e->getMessage(), 'ERR');
         throw new Turba_Exception($e);
     }
     if ($GLOBALS['session']->get('turba', 'source') == Horde_Util::getFormData('deleteshare')) {
         $GLOBALS['session']->remove('turba', 'source');
     }
 }
Example #17
0
 /**
  */
 protected function _changePassword($user, $oldpass, $newpass)
 {
     if (!Horde_Util::loadExtension('expect')) {
         throw new Passwd_Exception(_("expect extension cannot be loaded"));
     }
     // Set up parameters
     foreach (array('logfile', 'loguser', 'timeout') as $val) {
         if (isset($this->_params[$val])) {
             ini_set('expect.' . $val, $this->_params[$val]);
         }
     }
     // Open connection
     $call = sprintf('ssh %s@%s %s', $user, $this->_params['host'], $this->_params['program']);
     if (!($this->_stream = expect_popen($call))) {
         throw new Passwd_Exception(_("Unable to open expect stream"));
     }
     // Log in
     $this->_ctl('(P|p)assword.*', _("Could not login to system (no password prompt)"));
     // Send login password
     fwrite($this->_stream, $oldpass . "\n");
     // Expect old password prompt
     $this->_ctl('((O|o)ld|login|current).* (P|p)assword.*', _("Could not start passwd program (no old password prompt)"));
     // Send old password
     fwrite($this->_stream, $oldpass . "\n");
     // Expect new password prompt
     $this->_ctl('(N|n)ew.* (P|p)assword.*', _("Could not change password (bad old password?)"));
     // Send new password
     fwrite($this->_stream, $newpass . "\n");
     // Expect reenter password prompt
     $this->_ctl("((R|r)e-*enter.*(P|p)assword|Retype new( UNIX)? password|(V|v)erification|(V|v)erify|(A|a)gain).*", _("New password not valid (too short, bad password, too similar, ...)"));
     // Send new password
     fwrite($this->_stream, $newpass . "\n");
     // Expect successfully message
     $this->_ctl('((P|p)assword.* changed|successfully)', _("Could not change password."));
 }
Example #18
0
 public function login()
 {
     $auth = $GLOBALS['registry']->getAuth();
     if (!empty($auth)) {
         $this->urlFor(array('controller' => 'index', 'action' => 'index'))->redirect();
     }
     $this->title = _("Login");
     $this->post = $this->urlFor(array('controller' => 'index', 'action' => 'login'));
     if (isset($_POST['horde_user']) && isset($_POST['horde_pass'])) {
         /* Destroy any existing session on login and make sure to use a
          * new session ID, to avoid session fixation issues. */
         $GLOBALS['registry']->getCleanSession();
         if ($this->koward->auth->authenticate(Horde_Util::getPost('horde_user'), array('password' => Horde_Util::getPost('horde_pass')))) {
             $entry = sprintf('Login success for %s [%s] to Horde', $GLOBALS['registry']->getAuth(), $_SERVER['REMOTE_ADDR']);
             Horde::log($entry, 'NOTICE');
             $type = $this->koward->getType();
             if (!empty($type) && isset($this->koward->objects[$type]['default_view'])) {
                 $url = $this->urlFor($this->koward->objects[$type]['default_view']);
             } else {
                 if (isset($this->koward->conf['koward']['default_view'])) {
                     $url = $this->urlFor($this->koward->conf['koward']['default_view']);
                 } else {
                     $url = $this->urlFor(array('controller' => 'index', 'action' => 'index'));
                 }
             }
             $url->redirect();
         }
         $entry = sprintf('FAILED LOGIN for %s [%s] to Horde', Horde_Util::getFormData('horde_user'), $_SERVER['REMOTE_ADDR']);
         Horde::log($entry, 'ERR');
     }
     if ($reason = $this->koward->auth->getLogoutReasonString()) {
         $this->koward->notification->push(str_replace('<br />', ' ', $reason), 'horde.message');
     }
 }
Example #19
0
 /**
  */
 protected function _content()
 {
     global $page_output;
     $name = strval(new Horde_Support_Randomid());
     $page_output->addScriptFile('vatid.js', 'horde');
     $page_output->addInlineScript(array('$("' . $name . '").observe("submit", HordeBlockVatid.onSubmit.bindAsEventListener(HordeBlockVatid))'), true);
     return '<form style="padding:2px" action="' . $this->_ajaxUpdateUrl() . '" id="' . $name . '">' . Horde_Util::formInput() . Horde::label('vatid', _("VAT identification number:")) . '<br /><input type="text" length="14" name="vatid" />' . '<br /><input type="submit" id="vatbutton" value="' . _("Check") . '" class="horde-default" /> ' . Horde_Themes_Image::tag('loading.gif', array('alt' => _("Checking"), 'attr' => array('style' => 'display:none'))) . '<div class="vatidResults"></div>' . '</form>';
 }
Example #20
0
 /**
  * Constructs a new Turba LDAP driver object.
  *
  * @param string $name   The source name
  * @param array $params  Hash containing additional configuration parameters.
  *
  * @return Turba_Driver_Ldap
  */
 public function __construct($name = '', array $params = array())
 {
     if (!Horde_Util::extensionExists('ldap')) {
         throw new Turba_Exception(_("LDAP support is required but the LDAP module is not available or not loaded."));
     }
     $params = array_merge(array('charset' => '', 'deref' => LDAP_DEREF_NEVER, 'multiple_entry_separator' => ', ', 'port' => 389, 'root' => '', 'scope' => 'sub', 'server' => 'localhost'), $params);
     parent::__construct($name, $params);
 }
Example #21
0
 public static function addFeedLink()
 {
     $rss = Horde::url('rss.php', true, -1);
     if ($label = Horde_Util::getFormData('label')) {
         $rss->add('label', $label);
     }
     $GLOBALS['page_output']->addLinkTag(array('href' => $rss, 'title' => _("Bookmarks Feed")));
 }
Example #22
0
File: Ftp.php Project: horde/horde
 /**
  * Constructor.
  *
  * @param array $params  Optional parameters:
  * <pre>
  * 'hostspec' - (string) The hostname or IP address of the FTP server.
  *              DEFAULT: 'localhost'
  * 'port' - (integer) The server port to connect to.
  *          DEFAULT: 21
  * </pre>
  *
  * @throws Horde_Auth_Exception
  */
 public function __construct(array $params = array())
 {
     if (!Horde_Util::extensionExists('ftp')) {
         throw new Horde_Auth_Exception(__CLASS__ . ': Required FTP extension not found. Compile PHP with the --enable-ftp switch.');
     }
     $params = array_merge(array('hostspec' => 'localhost', 'port' => 21), $params);
     parent::__construct($params);
 }
Example #23
0
 /**
  * Constructor.
  *
  * @throws Ingo_Exception
  */
 public function __construct(array $params = array())
 {
     if (!Horde_Util::extensionExists('ldap')) {
         throw new Ingo_Exception(_("LDAP support is required but the LDAP module is not available or not loaded."));
     }
     $default_params = array('hostspec' => 'localhost', 'port' => 389, 'script_attribute' => 'mailSieveRuleSource');
     parent::__construct(array_merge($default_params, $params));
 }
Example #24
0
 /**
  * Constructor.
  *
  * @param array $params  Optional parameters:
  * <pre>
  * 'app' - (string) The name of the authenticating application.
  *         DEFAULT: horde
  * 'service' - (string) The name of the SASL service to use when
  *             authenticating.
  *             DEFAULT: php
  * </pre>
  *
  * @throws Horde_Auth_Exception
  */
 public function __construct(array $params = array())
 {
     if (!Horde_Util::extensionExists('sasl')) {
         throw new Horde_Auth_Exception('Horde_Auth_Peclsasl:: requires the sasl PECL extension to be loaded.');
     }
     $params = array_merge(array('app' => 'horde', 'service' => 'php'), $params);
     parent::__construct($params);
     sasl_server_init($this->_params['app']);
 }
Example #25
0
 /**
  * The function to use as a callback to _renderInfo().
  *
  * @param integer $key  The position of the file in the zip archive.
  * @param array $val    The information array for the archived file.
  *
  * @return string  The content-type of the output.
  */
 protected function _IMPcallback($key, $val)
 {
     $name = preg_replace('/(&nbsp;)+$/', '', $val['name']);
     if (!empty($val['size']) && strstr($val['attr'], 'D') === false && ($val['method'] == 0x8 && Horde_Util::extensionExists('zlib') || $val['method'] == 0x0)) {
         $mime_part = clone $this->_mimepart;
         $mime_part->setName(basename($name));
         $val['name'] = str_replace($name, $this->getConfigParam('imp_contents')->linkView($mime_part, 'download_render', $name, array('jstext' => sprintf(_("View %s"), str_replace('&nbsp;', ' ', $name)), 'class' => 'fixed', 'params' => array('zip_attachment' => urlencode($key) + 1))), $val['name']);
     }
     return $val;
 }
Example #26
0
 /**
  * The function to use as a callback to _toHTML().
  *
  * @param integer $key  The position of the file in the zip archive.
  * @param array $val    The information array for the archived file.
  *
  * @return string  The content-type of the output.
  */
 protected function _whupsCallback($key, $val)
 {
     $name = preg_replace('/(&nbsp;)+$/', '', $val['name']);
     if (!empty($val['size']) && strstr($val['attr'], 'D') === false && ($val['method'] == 0x8 && Horde_Util::extensionExists('zlib') || $val['method'] == 0x0)) {
         $mime_part = $this->_mimepart;
         $mime_part->setName(basename($name));
         $val['name'] = str_replace($name, Horde::url('view.php')->add(array('actionID' => 'view_file', 'type' => Horde_Util::getFormData('type'), 'file' => Horde_Util::getFormData('file'), 'ticket' => Horde_Util::getFormData('ticket'), 'zip_attachment' => $key + 1))->link() . $name . '</a>', $val['name']);
     }
     return $val;
 }
Example #27
0
 /**
  * Constructor.
  *
  * @param array $params  Optional parameters:
  * <pre>
  * 'service' - (string) The name of the PAM service to use when
  *             authenticating.
  *             DEFAULT: php
  * </pre>
  *
  * @throws Horde_Auth_Exception
  */
 public function __construct(array $params = array())
 {
     if (!Horde_Util::extensionExists('pam')) {
         throw new Horde_Auth_Exception('PAM authentication is not available.');
     }
     if (!empty($params['service'])) {
         ini_set('pam.servicename', $params['service']);
     }
     parent::__construct($params);
 }
Example #28
0
 public function setUp()
 {
     if (!self::$conf) {
         $this->markTestSkipped('No test configuration');
     }
     $conf = self::$conf;
     $conf['paths']['cvsps_home'] = Horde_Util::createTempDir(true, $conf['paths']['cvsps_home']);
     $conf['sourceroot'] = __DIR__ . '/repos/cvs';
     $this->vcs = Horde_Vcs::factory('Cvs', $conf);
 }
Example #29
0
 /**
  */
 protected function _init()
 {
     global $injector, $notification;
     /* Redirect if forward is not available. */
     $this->_assertCategory('Ingo_Rule_System_Forward', _("Forward"));
     if ($this->vars->submitbutton == _("Return to Rules List")) {
         Ingo_Basic_Filters::url()->redirect();
     }
     /* Get the forward object and rule. */
     $ingo_storage = $injector->getInstance('Ingo_Factory_Storage')->create();
     $forward = $ingo_storage->getSystemRule('Ingo_Rule_System_Forward');
     /* Build form. */
     $form = new Ingo_Form_Forward($this->vars);
     /* Perform requested actions. Ingo_Form_Forward does token checking
      * for us. */
     if ($form->validate($this->vars)) {
         $forward->addresses = $this->vars->addresses;
         $forward->keep = $this->vars->keep_copy == 'on';
         try {
             if ($this->vars->submitbutton == _("Save and Enable")) {
                 $forward->disable = true;
                 $notify = _("Rule Enabled");
             } elseif ($this->vars->submitbutton == _("Save and Disable")) {
                 $forward->disable = false;
                 $notify = _("Rule Disabled");
             } else {
                 $notify = _("Changes saved.");
             }
             $ingo_storage->updateRule($forward);
             $notification->push($notify, 'horde.success');
             $injector->getInstance('Ingo_Factory_Script')->activateAll();
         } catch (Ingo_Exception $e) {
             $notification->push($e);
         }
     }
     /* Add buttons depending on the above actions. */
     $form->setCustomButtons($forward->disable);
     /* Set default values. */
     if (!$form->isSubmitted()) {
         $this->vars->keep_copy = $forward->keep;
         $this->vars->addresses = implode("\n", $forward->addresses);
     }
     /* Set form title. */
     $form_title = _("Forward");
     if ($forward->disable) {
         $form_title .= ' [<span class="horde-form-error">' . _("Disabled") . '</span>]';
     }
     $form_title .= ' ' . Horde_Help::link('ingo', 'forward');
     $form->setTitle($form_title);
     $this->header = _("Forwards Edit");
     Horde::startBuffer();
     Horde_Util::pformInput();
     $form->renderActive(new Horde_Form_Renderer(array('encode_title' => false, 'varrenderer_driver' => array('ingo', 'ingo'))), $this->vars, self::url(array('append_session' => -1)), 'post');
     $this->output = Horde::endBuffer();
 }
Example #30
0
 function getPDF()
 {
     $tmp_file = Horde_Util::getTempFile('fax', true, '/tmp');
     $fp = fopen($tmp_file, 'wb');
     fwrite($fp, $this->_data);
     fclose($fp);
     /* Convert the page from the postscript file to PDF. */
     $command = sprintf('%s %s -', $this->_cmd['ps2pdf'], $tmp_file);
     Horde::log('Executing command: ' . $command, 'DEBUG');
     passthru($command);
 }