/** * returns the url in a link */ public function getUrl($full_path = false) { if ($full_path) { return sprintf('<a href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $this->url, $this->title); } else { return sprintf('<a href="%s">%s</a>', $this->url, $this->title); } }
private function load() { if ($this->key_id) { $key = new Key($this->key_id); } else { $key = Key::getHomeKey(); } $this->url = PHPWS_Core::getHomeHttp() . $key->url; $this->tag = md5($this->url); $this->file = QR_IMAGE_DIR . $this->tag . '_' . $this->size . '.png'; $this->image = QR_IMAGE_HTTP . $this->tag . '_' . $this->size . '.png'; }
public static function registerModule($module, &$content) { if (is_file(PHPWS_SOURCE_DIR . 'mod/' . $module . '/conf/rss.php')) { $reg_file = PHPWS_Core::getConfigFile($module, 'rss.php'); } else { $reg_file = false; } if ($reg_file == FALSE) { PHPWS_Boost::addLog($module, dgettext('rss', 'No RSS file found.')); return FALSE; } PHPWS_Core::initModClass('rss', 'Channel.php'); include $reg_file; $oChannel = new RSS_Channel(); $oChannel->module = $module; if (!isset($channel) || !is_array($channel)) { $content[] = dgettext('rss', 'RSS file found but no channel information.'); PHPWS_Boost::addLog($module, dgettext('rss', 'RSS file found but no channel information.')); } $oModule = new PHPWS_Module($module); if (!empty($channel['title'])) { $oChannel->title = strip_tags($channel['title']); } else { $oChannel->title = $oModule->proper_name; } if (!empty($channel['description'])) { $oChannel->description = strip_tags($channel['description']); } if (!empty($channel['link'])) { $oChannel->link = strip_tags($channel['link']); } else { $oChannel->link = PHPWS_Core::getHomeHttp(); } $result = $oChannel->save(); if (PHPWS_Error::isError($result)) { PHPWS_Error::log($result); PHPWS_Boost::addLog($module, dgettext('rss', 'An error occurred registering to RSS module.')); $content[] = dgettext('rss', 'An error occurred registering to RSS module.'); return NULL; } else { $content[] = sprintf(dgettext('rss', 'RSS registration to %s module successful.'), $oModule->proper_name); return TRUE; } }
public function getTag($embed = false) { $filter = $this->getFilter(); $is_video = preg_match('/^audio/i', $this->file_type) ? false : true; $tpl['WIDTH'] = $this->width; $tpl['HEIGHT'] = $this->height; $tpl['IMAGE'] = $this->getThumbnail(null, false); $thumbnail = $this->thumbnailPath(); $tpl['FILE_DIRECTORY'] = $this->file_directory; $path = $this->getPath(); if (!preg_match('/^(https?|rtmp):/', $path)) { $path = PHPWS_Core::getHomeHttp() . $path; } $tpl['FILE_PATH'] = $path; $tpl['FILE_NAME'] = $this->file_name; $tpl['ID'] = 'media' . $this->id; $tpl['source_http'] = $tpl['SOURCE_HTTP'] = PHPWS_SOURCE_HTTP; // check for filter file if ($this->embedded) { $filter_tpl = sprintf('%smod/filecabinet/inc/embed/rtmp/embed.tpl', PHPWS_SOURCE_DIR); } else { $filter_exe = PHPWS_SOURCE_DIR . "mod/filecabinet/templates/filters/media/filter.php"; $filter_tpl = PHPWS_SOURCE_DIR . "mod/filecabinet/templates/filters/{$filter}.tpl"; if (is_file($filter_exe)) { include $filter_exe; } } return PHPWS_Template::process($tpl, 'filecabinet', $filter_tpl, true); }
$default['scrollbars'] = 'yes'; $default['resizable'] = 'yes'; $default['width'] = '400'; $default['height'] = '300'; $default['titlebar'] = 'no'; $default['link_title'] = ''; $default['window_name'] = 'default' . rand(); $default['class'] = 'js-open-window'; $default['center'] = 1; if (isset($data['type'])) { if ($data['type'] == 'button') { $bodyfile = PHPWS_SOURCE_DIR . 'javascript/open_window/body2.js'; } } if (isset($data['center'])) { $data['center'] = (bool) $data['center'] ? 1 : 0; } $site_address = PHPWS_Core::getHomeHttp(); if (!stristr($data['address'], $site_address)) { $data['address'] = $site_address . $data['address']; } if (!empty($data['secure'])) { if (!isset($_GLOBALS['open_window_reset'])) { unset($_SESSION['secure_open_window']); $_GLOBALS['open_window_reset'] = true; } $rand = PHPWS_Text::randomString(); $data['address'] .= '&owpop=' . $rand; $_SESSION['secure_open_window'][] = $rand; $data['id'] = $rand; }
public function viewImage($id, $view_folder = true) { Layout::addStyle('filecabinet'); PHPWS_Core::initModClass('filecabinet', 'Image.php'); $image = new PHPWS_Image($id); $folder = new Folder($image->folder_id); if (!$folder->allow()) { $content = dgettext('filecabinet', 'Sorry, the file you requested is off limits.'); Layout::add($content); return; } $tpl['TITLE'] = $image->title; if ($image->width > FC_MAX_IMAGE_POPUP_WIDTH || $image->height > FC_MAX_IMAGE_POPUP_HEIGHT) { if (FC_MAX_IMAGE_POPUP_WIDTH < FC_MAX_IMAGE_POPUP_HEIGHT) { $ratio = FC_MAX_IMAGE_POPUP_WIDTH / $image->width; $image->width = FC_MAX_IMAGE_POPUP_WIDTH; $image->height = $image->height * $ratio; } else { $ratio = FC_MAX_IMAGE_POPUP_HEIGHT / $image->height; $image->height = FC_MAX_IMAGE_POPUP_HEIGHT; $image->width = $image->width * $ratio; } $tpl['IMAGE'] = sprintf('<a href="%s">%s</a>', $image->getPath(), $image->getTag()); } else { $tpl['IMAGE'] = $image->getTag(); } $tpl['DESCRIPTION'] = $image->getDescription(); $tpl['CLOSE'] = javascript('close_window'); if ($view_folder && $folder->public_folder) { $db = new PHPWS_DB('images'); $db->setLimit(1); $db->addWhere('folder_id', $image->folder_id); $db->addWhere('title', $image->title, '>'); $db->addOrder('title'); $next_img = $db->getObjects('PHPWS_Image'); if (!empty($next_img)) { $next_link = Icon::show('next', dgettext('filecabinet', 'Next image')); $tpl['NEXT'] = sprintf('<a id="next-link" href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $next_img[0]->popupAddress(), $next_link); } $db->resetWhere(); $db->resetOrder(); $db->addWhere('folder_id', $image->folder_id); $db->addWhere('title', $image->title, '<'); $db->addOrder('title desc'); $prev_img = $db->getObjects('PHPWS_Image'); if (!empty($prev_img)) { $prev_link = Icon::show('previous', dgettext('filecabinet', 'Previous image')); $tpl['PREV'] = sprintf('<a id="prev-link" href="%s%s">%s</a>', PHPWS_Core::getHomeHttp(), $prev_img[0]->popupAddress(), $prev_link); } } $content = PHPWS_Template::process($tpl, 'filecabinet', 'image_view.tpl'); Layout::nakedDisplay($content); }
public function emailRegistration() { $peep =& $this->peep; $sheet =& $this->sheet; $slot =& $this->slot; PHPWS_Core::initCoreClass('Mail.php'); $full_name = $peep->first_name . $peep->last_name; if (preg_match('@["\'\\.]@', $full_name)) { $name = str_replace('"', "'", $peep->first_name . ' ' . $peep->last_name); $send_to = sprintf('"%s" <%s>', $name, $peep->email); } else { $send_to = sprintf('%s %s <%s>', $peep->first_name, $peep->last_name, $peep->email); } $subject = dgettext('signup', 'Signup confirmation'); if (!empty($sheet->contact_email)) { $reply_to = $from = $sheet->contact_email; } else { $reply_to = $from = PHPWS_Settings::get('users', 'site_contact'); } $site_title = Layout::getPageTitle(true); $link = PHPWS_Core::getHomeHttp() . 'index.php?module=signup&uop=confirm&h=' . $peep->hashcheck . '&p=' . $peep->id; $message[] = sprintf(dgettext('signup', 'Greetings from %s,'), $site_title); $message[] = ''; $message[] = dgettext('signup', 'Click the link below to confirm your participation in the following:'); $message[] = ''; $message[] = sprintf(dgettext('signup', 'Signup event : %s'), $sheet->title); $message[] = sprintf(dgettext('signup', 'Slot : %s'), $slot->title); $message[] = $link; $message[] = ''; $message[] = dgettext('signup', 'You have one hour to confirm your application.'); $mail = new PHPWS_Mail(); $mail->addSendTo($send_to); $mail->setSubject($subject); $mail->setFrom($from); $mail->setReplyTo($reply_to); $mail->setMessageBody(implode("\n", $message)); return $mail->send(); }
/** * Returns a RSS feed. Cached result is returned if exists. */ public function view() { $cache_key = $this->module . '_cache_key'; $content = PHPWS_Cache::get($cache_key, RSS_CACHE_TIMEOUT); if (!empty($content)) { return $content; } if (empty($this->_feeds)) { $this->loadFeeds(); } $home_http = PHPWS_Core::getHomeHttp(); $template['CHANNEL_TITLE'] = $this->EncodeString($this->title); $template['CHANNEL_ADDRESS'] = $this->getAddress(); $template['HOME_ADDRESS'] = $home_http; $template['CHANNEL_DESCRIPTION'] = $this->EncodeString($this->description); $template['LANGUAGE'] = CURRENT_LANGUAGE; // change later $template['SEARCH_LINK'] = sprintf('%sindex.php?module=search&mod_title=%s&user=search', $home_http, $this->module); $template['SEARCH_DESCRIPTION'] = sprintf('Search in %s', $this->title); $template['SEARCH_NAME'] = 'search'; $template['COPYRIGHT'] = PHPWS_Settings::get('rss', 'copyright'); $template['WEBMASTER'] = PHPWS_Settings::get('rss', 'webmaster'); $template['MANAGING_EDITOR'] = PHPWS_Settings::get('rss', 'editor'); // $template['LAST_BUILD_DATE'] = $this->_last_build_date; $timezone = strftime('%z'); $timezone = substr($timezone, 0, 3) . ':' . substr($timezone, 3, 2); if ($this->_feeds) { foreach ($this->_feeds as $key) { $itemTpl = NULL; $url = preg_replace('/^\\.\\//', '', $key->url); $url = $home_http . preg_replace('/&(?!amp;)/', '&', $url); $itemTpl['ITEM_LINK'] = $url; $itemTpl['ITEM_TITLE'] = $this->EncodeString($key->title); $itemTpl['ITEM_GUID'] = $url; $itemTpl['ITEM_LINK'] = $url; $itemTpl['ITEM_SOURCE'] = sprintf('%sindex.php?module=rss&mod_title=%s', $home_http, $this->module); $itemTpl['ITEM_DESCRIPTION'] = strip_tags(trim($this->EncodeString($key->summary))); $itemTpl['ITEM_AUTHOR'] = $key->creator; // $itemTpl['ITEM_PUBDATE'] = $key->getCreateDate('%Y-%m-%d %H:%M:%S CST'); $itemTpl['ITEM_PUBDATE'] = $this->rssDate($key->create_date); $itemTpl['ITEM_DC_DATE'] = $key->getCreateDate('%Y-%m-%dT%H:%M:%S') . $timezone; $itemTpl['ITEM_DC_TYPE'] = 'Text'; //pull from db later $itemTpl['ITEM_DC_CREATOR'] = $key->creator; $itemTpl['ITEM_SOURCE_TITLE'] = $this->EncodeString($this->title); $template['item-listing'][] = $itemTpl; } } if (PHPWS_Settings::get('rss', 'rssfeed') == 2) { $tpl_file = 'rss20.tpl'; } else { $tpl_file = 'rss10.tpl'; } $content = PHPWS_Template::process($template, 'rss', $tpl_file); $content = utf8_encode($content); PHPWS_Cache::save($cache_key, $content); return $content; }
public static function sendToAlternate($alternate, $search_phrase) { $file = PHPWS_Core::getConfigFile('search', 'alternate.php'); if (!$file) { PHPWS_Core::errorPage(); exit; } include $file; if (!isset($alternate_search_engine) || !is_array($alternate_search_engine) || !isset($alternate_search_engine[$alternate])) { PHPWS_Core::errorPage(); exit; } $gosite =& $alternate_search_engine[$alternate]; $query_string = str_replace(' ', '+', $search_phrase); $site = urlencode(PHPWS_Core::getHomeHttp(FALSE, FALSE, FALSE)); $url = sprintf($gosite['url'], $query_string, $site); header('location: ' . $url); exit; }
function step2() { $db = Convert::getSourceDB('mod_wiki_interwiki'); $batch = new Batches('convert_wiki_interwiki'); $total = $db->count(); if ($total < 1) { $batch->clear(); $_SESSION['wiki_convert_step'] = 3; Convert::forward(PHPWS_Core::getHomeHttp() . 'index.php?command=convert&package=wiki'); return dgettext('wiki', 'No interwiki links to convert.'); } $batch->setTotalItems($total); $batch->setBatchSet(5); if (isset($_REQUEST['reset_batch'])) { $batch->clear(); } $content[] = dgettext('wiki', 'Converting interwiki links...'); if (!$batch->load()) { $content[] = dgettext('wiki', 'Batch previously run.'); } else { $result = runBatch($db, $batch); if (is_array($result)) { $content[] = dgettext('wiki', 'Some errors occurred when trying to convert the following interwiki links:'); $content[] = '<ul><li>' . implode('</li><li>', $result) . '</li></ul>'; return implode('<br />', $content); } } $percent = $batch->percentDone(); $content[] = Convert::getGraph($percent); $batch->completeBatch(); if (!$batch->isFinished()) { Convert::forward($batch->getAddress()); } else { $batch->clear(); $_SESSION['wiki_convert_step'] = 3; Convert::forward(PHPWS_Core::getHomeHttp() . 'index.php?command=convert&package=wiki'); } return implode('<br />', $content); }
public function admin() { switch ($_REQUEST['dop']) { case 'delete_document': if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) { Current_User::disallow(); } $this->document->delete(); PHPWS_Core::returnToBookmark(); break; case 'post_document_upload': if (!$this->folder->id || !Current_User::authorized('filecabinet', 'edit_folders', $this->folder->id, 'folder')) { Current_User::disallow(); } $this->postDocumentUpload(); javascript('close_refresh'); Layout::nakedDisplay(); //\PHPWS_Core::goBack(); break; case 'upload_document_form': if (!$this->folder->id || !Current_User::secured('filecabinet', 'edit_folders', $this->folder->id, 'folder')) { Current_User::disallow(); } $this->loadDocument(filter_input(INPUT_GET, 'file_id', FILTER_VALIDATE_INT)); $this->edit(); echo Layout::wrap($this->content, 'Document Upload', true); exit; case 'add_access': if (!Current_User::authorized('filecabinet')) { Current_User::disallow(); } $keyword = null; $this->loadDocument(); // document exists, try making a shortcut if ($this->document->id) { PHPWS_Core::initModClass('access', 'Shortcut.php'); $shortcut = new Access_Shortcut(); if (isset($_GET['keyword'])) { $keyword = $_GET['keyword']; } if (empty($keyword)) { $keyword = $this->document->title; } $result = $shortcut->setKeyword($keyword); $new_keyword = $shortcut->keyword; // if setKeyword returns a false or error, we have them pick a different name if (!$result || PHPWS_Error::isError($result)) { $message = dgettext('filecabinet', 'Access shortcut name already in use. Please enter another.'); $success = false; } else { $shortcut->setUrl('filecabinet', $this->document->getViewLink()); $shortcut->save(); $success = true; $message = '<p>' . dgettext('filecabinet', 'Access shortcut successful!') . '</p>'; $message .= '<a href="' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '">' . PHPWS_Core::getHomeHttp() . $shortcut->keyword . '</a>'; } } else { $message = dgettext('filecabinet', 'File not found'); // not really a success but prevents a repost prompt $success = true; } echo json_encode(array('success' => $success, 'message' => $message, 'keyword' => $new_keyword)); exit; } }
/** * Makes links relative to home site */ public static function makeRelative(&$text, $prefix = true, $inlink_only = false) { $address = addslashes(PHPWS_Core::getHomeHttp()); if ($prefix) { $pre = './'; } else { $pre = ''; } if ($inlink_only) { $src = '@(src|href)="' . $address . '@'; $rpl = "\\1=\"{$pre}"; $text = preg_replace($src, $rpl, $text); } else { $text = str_replace($address, $pre, $text); } }
public static function notifyUser($user, $password) { PHPWS_Core::initCoreClass('Mail.php'); $page_title = Layout::getPageTitle(true); $body[] = sprintf(dgettext('users', '%s created an user account for you.'), $page_title); $body[] = dgettext('users', 'You may log-in using the following information:'); $body[] = sprintf(dgettext('users', 'Site address: %s'), PHPWS_Core::getHomeHttp()); $body[] = sprintf(dgettext('users', 'Username: %s'), $user->username); $body[] = sprintf(dgettext('users', 'Password: %s'), $password); $body[] = dgettext('users', 'Please change your password immediately after logging in.'); $mail = new PHPWS_Mail(); $mail->addSendTo($user->email); $mail->setSubject(sprintf(dgettext('users', '%s account created'), $page_title)); $mail->setFrom(PHPWS_User::getUserSetting('site_contact')); $mail->setReplyTo(PHPWS_User::getUserSetting('site_contact')); $mail->setMessageBody(implode("\n\n", $body)); $result = $mail->send(); return $result; }
private function emailApprovalNeeded() { $db = \Database::getDB(); $t = $db->addTable('prop_contacts'); $t->addFieldConditional('approved', 0); $rows = $db->select(); $count = count($rows); if ($count == 0) { return; } $vars['site_title'] = \Layout::getPageTitle(true); $vars['site_address'] = \PHPWS_Core::getHomeHttp() . 'index.php?module=properties&aop=approve'; $vars['count'] = $count > 1 ? "{$count} submissions" : "one submission"; $template = new \Template($vars); $template->setModuleTemplate('properties', 'reminder.html'); $content = $template->get(); $this->emailContact('Property Manager Approval Required', $content, \PHPWS_Settings::get('properties', 'approver_email')); }
/** * Sends email to Wiki Admin if option enabled * * @author Greg Meiste <*****@*****.**> */ function sendEmail() { if (PHPWS_Settings::get('wiki', 'monitor_edits')) { $pagetitle = WikiManager::formatTitle(strip_tags($_REQUEST['page'])); $message = PHPWS_Settings::get('wiki', 'email_text'); $message = str_replace('[page]', $pagetitle, $message); $message = str_replace('[url]', PHPWS_Core::getHomeHttp() . (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $_REQUEST['page'], $message); PHPWS_Core::initCoreClass('Mail.php'); $mail = new PHPWS_Mail(); $mail->addSendTo(PHPWS_Settings::get('wiki', 'admin_email')); $mail->setSubject(sprintf(dgettext('wiki', '%s updated!'), $pagetitle)); $mail->setFrom(PHPWS_User::getUserSetting('site_contact')); $mail->setMessageBody($message); $mail->send(); } }
public static function loadHeaderTags(&$template) { $page_metatags = null; $theme = Layout::getCurrentTheme(); $key = Key::getCurrent(); if (Key::checkKey($key, false)) { $page_metatags = Layout::getMetaPage($key->id); if (PHPWS_Error::isError($page_metatags)) { PHPWS_Error::log($page_metatags); $page_metatags = null; } } if (!isset($_SESSION['javascript_enabled'])) { $jsHead[] = '<noscript><meta http-equiv="refresh" content="0;url=index.php?nojs=1&ret=' . urlencode(PHPWS_Core::getCurrentUrl()) . '"/></noscript>'; } if (isset($_GET['nojs'])) { $_SESSION['javascript_enabled'] = false; PHPWS_Core::reroute(urldecode($_GET['ret'])); } elseif (!isset($_SESSION['javascript_enabled'])) { $_SESSION['javascript_enabled'] = true; } if (isset($GLOBALS['Layout_JS'])) { foreach ($GLOBALS['Layout_JS'] as $script => $javascript) { $jsHead[] = $javascript['head']; } } if (!empty($jsHead)) { $template['JAVASCRIPT'] = implode("\n", $jsHead); } Layout::importStyleSheets(); Layout::submitHeaders($theme, $template); if (!empty($GLOBALS['Layout_Links'])) { $template['STYLE'] .= "\n" . implode("\n", $GLOBALS['Layout_Links']); } $template['METATAGS'] = Layout::getMetaTags($page_metatags); if ($page_metatags) { $template['PAGE_TITLE'] = $page_metatags['page_title'] . PAGE_TITLE_DIVIDER . $_SESSION['Layout_Settings']->getPageTitle(true); } else { $template['PAGE_TITLE'] = $_SESSION['Layout_Settings']->getPageTitle(); } $template['ONLY_TITLE'] = $_SESSION['Layout_Settings']->getPageTitle(TRUE); // Depricated // The Site's Name, as set in Layout 'Meta Tags' interface. $template['SITE_NAME'] = $_SESSION['Layout_Settings']->getPageTitle(TRUE); $template['BASE'] = Layout::getBase(); $template['HTTP'] = PHPWS_Core::getHttp(); // 'http' or 'https' // Complete URL of the site's home page $template['HOME_URL'] = PHPWS_Core::getHomeHttp(true, true, true); }
private function disapproveContact($id) { $id = (int) $id; $contact = new Contact($id); $db = \Database::newDB(); $tbl = $db->addTable('prop_contacts'); $tbl->addFieldConditional('id', $id); $db->delete(); $vars = array('first_name' => $contact->getFirstName(), 'last_name' => $contact->getLastName(), 'site_title' => \Layout::getPageTitle(true), 'site_address' => \PHPWS_Core::getHomeHttp(true), 'email_address' => \PHPWS_Settings::get('properties', 'email')); $template = new \Template($vars); $template->setModuleTemplate('properties', 'disapprovalLetter.html'); $content = $template->get(); $this->emailInfo('Manager account not approved', $content, $contact->getEmailAddress()); }
/** * Writes the config/core/config.php file. Assumes one does not already * exist * @return unknown_type */ public function writeConfigFile() { require_once 'File.php'; $location = PHPWS_SOURCE_DIR . 'config/core/'; if (!file_exists($location)) { // Try to make configuration directory $result = mkdir($location); if ($result === false) { $this->messages[] = 'Cannot create core configuration directory ' . $location; return false; } } if (!is_writable($location)) { $this->messages[] = 'Cannot write file to ' . $location; return false; } $filename = $location . 'config.php'; if (is_file($filename)) { $this->messages[] = dgettext('core', 'Configuration file already exists.'); return false; } $config_file[] = '<?php'; $config_file[] = sprintf("define('PHPWS_SOURCE_DIR', '%s');", PHPWS_SOURCE_DIR); $config_file[] = sprintf("define('PHPWS_HOME_DIR', '%s');", PHPWS_SOURCE_DIR); $config_file[] = sprintf("define('SITE_HASH', '%s');", md5(rand())); $config_file[] = sprintf("define('PHPWS_DSN', '%s');", $_SESSION['configSettings']['dsn']); if (isset($_SESSION['configSettings']['dbprefix'])) { $config_file[] = sprintf("define('PHPWS_TABLE_PREFIX', '%s');", $_SESSION['configSettings']['dbprefix']); } $config_file[] = '?>'; if (!file_put_contents($filename, implode("\n", $config_file))) { return false; } else { $source_http = sprintf("<?php\ndefine('PHPWS_SOURCE_HTTP', '//%s');\n?>", str_replace('setup/', '', PHPWS_Core::getHomeHttp(false))); return file_put_contents($location . 'source.php', $source_http); } }
/** * Adds the full url to relative image links */ public function appendImages($text) { $url = PHPWS_Core::getHomeHttp(); return preg_replace('@(src=")\\./(images)@', '\\1' . $url . '\\2', $text); }