Beispiel #1
0
 /**
  * Writes a <site> tag representing the given Site object.
  *
  * @param Site $site
  */
 private function exportSite(Site $site)
 {
     if ($site->getType() !== Site::TYPE_UNKNOWN) {
         $siteAttr = ['type' => $site->getType()];
     } else {
         $siteAttr = null;
     }
     fwrite($this->sink, "\t" . Xml::openElement('site', $siteAttr) . "\n");
     fwrite($this->sink, "\t\t" . Xml::element('globalid', null, $site->getGlobalId()) . "\n");
     if ($site->getGroup() !== Site::GROUP_NONE) {
         fwrite($this->sink, "\t\t" . Xml::element('group', null, $site->getGroup()) . "\n");
     }
     if ($site->getSource() !== Site::SOURCE_LOCAL) {
         fwrite($this->sink, "\t\t" . Xml::element('source', null, $site->getSource()) . "\n");
     }
     if ($site->shouldForward()) {
         fwrite($this->sink, "\t\t" . Xml::element('forward', null, '') . "\n");
     }
     foreach ($site->getAllPaths() as $type => $path) {
         fwrite($this->sink, "\t\t" . Xml::element('path', ['type' => $type], $path) . "\n");
     }
     foreach ($site->getLocalIds() as $type => $ids) {
         foreach ($ids as $id) {
             fwrite($this->sink, "\t\t" . Xml::element('localid', ['type' => $type], $id) . "\n");
         }
     }
     // @todo: export <data>
     // @todo: export <config>
     fwrite($this->sink, "\t" . Xml::closeElement('site') . "\n");
 }
 function FormSiteIpExclude(&$template, $siteAdmin)
 {
     parent::Form($template);
     $this->siteAdmin = $siteAdmin;
     $o_site = new Site($siteAdmin);
     $this->a_ips = $o_site->getIpArray();
 }
 public function load()
 {
     parent::load();
     $model = new SupportCenters();
     $scs = $model->getindex();
     $this->view->scs = array();
     foreach ($this->sc_ids as $sc_id) {
         $this->view->scs[$sc_id] = $scs[$sc_id][0];
     }
     if (isset($_REQUEST["summary_attrs_showcontact"])) {
         $this->view->contacts = array();
         $cmodel = new SupportCenterContact();
         $contacts = $cmodel->getindex();
         //group by contact_type_id
         foreach ($this->sc_ids as $sc_id) {
             $types = array();
             if (isset($contacts[$sc_id])) {
                 foreach ($contacts[$sc_id] as $contact) {
                     if (!isset($types[$contact->contact_type])) {
                         $types[$contact->contact_type] = array();
                     }
                     $types[$contact->contact_type][] = $contact;
                 }
                 $this->view->contacts[$sc_id] = $types;
             }
         }
     }
     if (isset($_REQUEST["summary_attrs_showsites"])) {
         $model = new Site();
         $this->view->sites = $model->getgroupby("sc_id");
     }
 }
Beispiel #4
0
 public function getSiteCollection(array $where)
 {
     global $dRep, $INK_User;
     $values = array();
     $innerjoin = '';
     if (isset($where['userId'])) {
         $innerjoin = "INNER JOIN ink_sites_in_roles B on (A.siteId = B.SiteId)\n\t\t\t\t\t\t  INNER JOIN ink_user_in_roles C ON (B.roleId = C.roleId AND C.userId = ?)";
         $values[] = $where['userId'];
         unset($where['userId']);
     } else {
         if (isset($where['roleId'])) {
             $innerjoin = "INNER JOIN ink_sites_in_roles B on (A.siteId = B.SiteId AND B.roleId = ?)";
             $values[] = $where['roleId'];
             unset($where['roleId']);
         }
     }
     $where = count($where) > 0 ? 'WHERE ' . $this->sqlBuilder->createWhere($where, 'A') : '';
     $sql = "SELECT * FROM ink_customer_sites A {$innerjoin} {$where} AND softdelete  = ?;";
     $values[] = false;
     $data = $this->runManyQuery($sql, $values);
     $sites = array();
     foreach ($data as $index => $row) {
         $properties = array('id' => $row['siteId'], 'name' => $row['sitename'], 'url' => $row['siteurl'], 'templates' => $dRep->getTemplateCollection(array('site' => $row['siteId'])), 'ftp_url' => $row['ftp_url'], 'ftp_username' => $row['ftp_username'], 'ftp_password' => $row['ftp_password'], 'ftp_root' => $row['ftp_root'], 'ftp_passive' => $row['ftp_passv'], 'ftp_mode' => $row['ftp_mode'], 'ftp_port' => $row['ftp_port']);
         $site = new Site();
         $site->setProperties($properties);
         $sites[] = $site;
     }
     return $sites;
 }
 /**
  * Return the upstream for the given site
  *
  * @param Site $site
  * @return object The upstream information
  * @throws TerminusException
  */
 protected function getUpstreamUpdates($site)
 {
     if (empty($upstream = $site->getUpstream()->getUpdates())) {
         throw new TerminusException('There was a problem checking your upstream status. Please try again.');
     }
     return $upstream;
 }
 function FormSiteUrls(&$template, $siteAdmin)
 {
     parent::Form($template);
     $this->siteAdmin = $siteAdmin;
     $o_site = new Site($siteAdmin);
     $this->a_urls = $o_site->getUrls();
 }
Beispiel #7
0
 public static function createSampleSite($label)
 {
     $site = new Site();
     $v4PK = new PrimaryKey();
     $site->setPrimaryKey($v4PK->getId());
     $site->setShortName($label);
     return $site;
 }
 public function create($data, $save = true)
 {
     $site = new Site($this, $data);
     if ($save) {
         $site->save();
     }
     return $site;
 }
 /**
  * @see GenericArrayObject::preSetElement
  *
  * @since 1.21
  *
  * @param int|string $index
  * @param Site $site
  *
  * @return boolean
  */
 protected function preSetElement($index, $site)
 {
     if ($this->hasSite($site->getGlobalId())) {
         $this->removeSite($site->getGlobalId());
     }
     $this->byGlobalId[$site->getGlobalId()] = $index;
     $this->byInternalId[$site->getInternalId()] = $index;
     return true;
 }
Beispiel #10
0
 public static function getSiteKey(Site $site = null)
 {
     if ($site) {
         $siteKey = "site_" . $site->getId();
     } else {
         $siteKey = "default";
     }
     return $siteKey;
 }
 /**
  * @covers HashSiteStore::clear
  */
 public function testClear()
 {
     $store = new HashSiteStore();
     $site = new Site();
     $site->setGlobalId('arwiki');
     $store->saveSite($site);
     $this->assertCount(1, $store->getSites(), '1 site in store');
     $store->clear();
     $this->assertCount(0, $store->getSites(), '0 sites in store');
 }
 function FormSiteNewsletter(&$template, $siteAdmin, $newsletterId = null)
 {
     parent::Form($template);
     $this->siteAdmin = $siteAdmin;
     // case modify a newsletter
     if (!is_null($newsletterId)) {
         $o_site = new Site($siteAdmin);
         $this->newsletterId = $newsletterId;
         $this->newsletterName = $o_site->getNewsletterName($newsletterId);
     }
 }
 function needANewsletter($idSite)
 {
     $idNewsletter = $this->request->getAdminNewsletter();
     if (!$idNewsletter) {
         $o_site = new Site($idSite);
         $this->tpl->assign('newsletters_available', $o_site->getNewslettersSite());
         $this->tpl->template = "admin/newsletter_selection.tpl";
         return false;
     } else {
         return $idNewsletter;
     }
 }
/**
 *  Draws a form to move a service
 *  @param \Site $oldSite Site to which the service to be moved belongs
 *  @return null
 */
function drawMoveSite(\Site $oldSite)
{
    //Check the user has permission to see the page, will throw exception
    //if the user is not an admin
    checkUserIsAdmin();
    //Get a list of services and list of sites to select from
    $sites = \Factory::getSiteService()->getSitesBy();
    $services = $oldSite->getServices();
    //Put into an array to be passed to view
    $params = array('Sites' => $sites, 'Services' => $services, 'OldSite' => $oldSite->getShortName());
    show_view("admin/move_service_end_point.php", $params);
}
 function FormSitePartner(&$template, $siteAdmin, $partnerId = null)
 {
     parent::Form($template);
     $this->siteAdmin = $siteAdmin;
     // case modify a newsletter
     if (!is_null($partnerId)) {
         $o_site = new Site($siteAdmin);
         $this->partnerId = $partnerId;
         $this->partnerName = $o_site->getPartnerNameFromId($partnerId);
         $this->partnerUrls = $o_site->getPartnerUrlsId($partnerId);
     }
 }
 function needAPartner($idSite)
 {
     $idPartner = $this->request->getAdminPartner();
     if (!$idPartner) {
         $o_site = new Site($idSite);
         $this->tpl->assign('partners_available', $o_site->getPartnerSite());
         $this->tpl->template = "admin/partner_selection.tpl";
         return false;
     } else {
         return $idPartner;
     }
 }
Beispiel #17
0
 public function __construct(Site $site, &$session, $post)
 {
     $users = new Users($site);
     $email = strip_tags($post['email']);
     $password = strip_tags($post['password']);
     $root = $site->getRoot();
     if (isset($post['submitLogin'])) {
         $user = $users->login($email, $password);
         //$user = null;
         if ($user === null) {
             // Login failed
             $this->redirect = "/index.php?e";
             $session[View::ERROR_MSG] = "Incorrect username or password";
             return;
         } else {
             $session[User::SESSION_NAME] = $user;
             $this->redirect = "/tasks.php";
         }
     } else {
         if (isset($post['submitCreate'])) {
             $confirm = strip_tags($post['confirm-password']);
             $name = $post['name'];
             if ($name == "") {
                 $session[View::ERROR_MSG] = "Please enter your name";
                 $this->redirect = "/create-account.php?e";
                 return;
             }
             if ($email == "") {
                 $session[View::ERROR_MSG] = "Please enter your email address";
                 $this->redirect = "/create-account.php?e";
                 return;
             }
             if ($password !== $confirm) {
                 $session[View::ERROR_MSG] = "Passwords do not match";
                 $this->redirect = "/create-account.php?e";
                 return;
             }
             if (strlen($password) < 8) {
                 $session[View::ERROR_MSG] = "Password is too short";
                 $this->redirect = "/create-account.php?e";
                 return;
             }
             $ret = $users->createAccount($name, $email, $password);
             if ($ret !== null) {
                 $session[View::ERROR_MSG] = $ret;
                 $this->redirect = "/create-account.php?e";
                 return;
             }
             $this->redirect = "/";
         }
     }
 }
Beispiel #18
0
function submit(\Site $site, \User $user = null)
{
    //Only administrators can delete sites, double check user is an administrator
    checkUserIsAdmin();
    //save name to display later
    $params['Name'] = $site->getName();
    //remove Site
    try {
        \Factory::getSiteService()->deleteSite($site, $user);
    } catch (\Exception $e) {
        show_view('error.php', $e->getMessage());
        die;
    }
    show_view('/site/deleted_site.php', $params);
}
 public static function getSiteParameterField()
 {
     $source = Site::get()->map('ID', 'Title')->toArray();
     $source = array('0' => 'All') + $source;
     // works around ajax bug
     return DropdownField::create('Site', 'Site', $source)->setHasEmptyDefault(false);
 }
 /**
  * Create the bookmarklet that is appropriate for the client's User Agent
  *
  * @return array The array of actions to attach to the specified $plugin_id
  */
 private function get_bookmarklet()
 {
     $admin_url = Site::get_url('admin');
     $link_name = Options::get('title');
     $bookmarklet = "\n\t\t<p>Bookmark this link to leave the page when quoting:\n\t\t<a href=\"javascript:var w=window,d=document,gS='getSelection';location.href='{$admin_url}/publish?quote='+encodeURIComponent((''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text)).replace(/(^\\s+|\\s+\$)/g,''))+'&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(d.title);\">Quote on {$link_name}</a>\n\t\t<br>\n\t\tBookmark this link to open a new tab or window when quoting:\n\t\t<a href=\"javascript:var w=window,d=document,gS='getSelection';window.open('{$admin_url}/publish?quote='+encodeURIComponent((''+(w[gS]?w[gS]():d[gS]?d[gS]():d.selection.createRange().text)).replace(/(^\\s+|\\s+\$)/g,''))+'&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(d.title));void(0);\">Quote on {$link_name}</a>\n\t\t</p>";
     return $bookmarklet;
 }
 private function getSites()
 {
     $sites = array();
     $site = new Site();
     $site->setGlobalId('foobar');
     $sites[] = $site;
     $site = new MediaWikiSite();
     $site->setGlobalId('enwiktionary');
     $site->setGroup('wiktionary');
     $site->setLanguageCode('en');
     $site->addNavigationId('enwiktionary');
     $site->setPath(MediaWikiSite::PATH_PAGE, "https://en.wiktionary.org/wiki/\$1");
     $site->setPath(MediaWikiSite::PATH_FILE, "https://en.wiktionary.org/w/\$1");
     $sites[] = $site;
     return new SiteList($sites);
 }
Beispiel #22
0
 public function __construct($id)
 {
     $this->template = new SgiTemplate();
     $this->site = new Site($id);
     $this->navi_top = new Navigation("topnavi", -1, "top");
     if ($this->site->getParent() == -1) {
         $this->navi_left = new Navigation("leftnavi", $this->site->getId(), "left");
     } else {
         $parentSite = new Site($this->site->getParent());
         if ($parentSite->getParent() == -1) {
             $this->navi_left = new Navigation("leftnavi", $this->site->getParent(), "left");
         } else {
             $this->navi_left = new Navigation("leftnavi", $parentSite->getParent(), "left");
         }
     }
 }
Beispiel #23
0
 public function filter_theme_call_header($return, $theme)
 {
     if (User::identify() != FALSE) {
         Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery');
     }
     return $return;
 }
 public function refresh($id = null)
 {
     $server = self::load_gameserver($id);
     $server->update_stats();
     Site::flash("notice", "The game server has been refreshed");
     Redirect("admin/servers");
 }
Beispiel #25
0
 public function process()
 {
     parent::process();
     $form = $this->ui->getWidget('login_form');
     $form->process();
     if (!$form->isSubmitted() && isset($_GET['source'])) {
         $referrer = $form->getHiddenField('referrer');
         if ($referrer === null) {
             $referrer = $_GET['source'];
             if (isset($_GET['tags'])) {
                 $referrer .= '?' . $_GET['tags'];
             }
             $this->setReferrer($referrer);
         }
     }
     if ($form->isSubmitted() && !$form->hasMessage()) {
         $passphrase = $this->ui->getWidget('passphrase')->value;
         $this->app->session->activate();
         if ($this->app->session->login($passphrase)) {
             $uri = $form->getHiddenField('referrer') === null ? '' : $form->getHiddenField('referrer');
             if ($uri == 'login' || $uri == 'login?') {
                 $uri = '';
             }
             $this->app->relocate($uri, true, true);
         } else {
             $message = new SwatMessage(Site::_('Login Incorrect'), SwatMessage::WARNING);
             $message->secondary_content = sprintf('<ul><li>%s</li><li>%s</li></ul>', Site::_('Please check the spelling of the passphrase.'), sprintf(Site::_('Passphrase is case-sensitive. Make sure ' . 'your %sCaps Lock%s key is off.'), '<kbd>', '</kbd>'));
             $message->content_type = 'text/xml';
             $this->ui->getWidget('message_display')->add($message);
         }
     }
 }
Beispiel #26
0
 /**
  * Get all metadata for a collection.
  *
  * @param \WP_Post $lead_post The lead post from which to take the metadata.
  * @return array
  */
 public static function get_all_collection_meta($lead_post)
 {
     $title = self::get_collection_title($lead_post->post_type);
     $tags = [['name' => 'description', 'content' => Post::get_post_meta_description($lead_post)], ['property' => 'og:locale', 'content' => get_locale()], ['property' => 'og:type', 'content' => 'summary'], ['property' => 'og:title', 'content' => $title], ['property' => 'og:description', 'content' => Post::get_post_og_description($lead_post)], ['property' => 'og:url', 'content' => get_permalink($lead_post->ID)], ['property' => 'og:site_name', 'content' => get_bloginfo('title')], ['name' => 'twitter:card', 'content' => 'summary'], ['name' => 'twitter:title', 'content' => $title], ['name' => 'twitter:description', 'content' => Post::get_post_twitter_description($lead_post)]];
     $tags = array_merge($tags, Site::webmaster_tools());
     return ['title' => $title, 'tags' => $tags];
 }
Beispiel #27
0
 public function actionMark()
 {
     if (Yii::app()->request->isAjaxRequest && !Yii::app()->user->isGuest) {
         if (!isset($_GET['id'])) {
             throw new CHttpException(404, 'Страница не найденa');
         } else {
             $site_id = $_GET['id'];
             $site = Site::model()->findByPk($site_id);
             if ($site == null) {
                 throw new CHttpException(404, 'Страница не найденa');
             } else {
                 $mark = Mark::model()->find('site_id = :site_id AND user_id = :user_id', array('site_id' => $site->site_id, 'user_id' => Yii::app()->user->id));
                 if ($mark != null) {
                     $mark->delete();
                 }
                 $mark = new Mark();
                 $mark->user_id = Yii::app()->user->id;
                 $mark->site_id = $site_id;
                 $mark->value = $_POST['value'];
                 $mark->save();
                 print 'Ваш голос учтен';
                 Yii::app()->end();
             }
         }
     } else {
         throw new CHttpException(404, 'Страница не найдена');
     }
 }
 function __construct()
 {
     parent::Controller();
     $this->_get_sidebar_data();
     $this->load->module_model('CMS', 'Events_model');
     $this->Events_model->set_config('events/calendar');
 }
Beispiel #29
0
	/**
	 * Returns all theme information -- dir, path, theme.xml, screenshot url
	 * @return array An array of Theme data
	 **/
	public static function get_all_data()
	{
		if ( !isset( self::$all_data ) ) {
			foreach ( self::get_all() as $theme_dir => $theme_path ) {
				$themedata = array();
				$themedata['dir'] = $theme_dir;
				$themedata['path'] = $theme_path;
				$themedata['theme_dir'] = $theme_path;

				$themedata['info'] = simplexml_load_file( $theme_path . '/theme.xml' );
				if ( $themedata['info']->getName() != 'pluggable' || (string) $themedata['info']->attributes()->type != 'theme' ) {
					$themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png";
					$themedata['info']->description = '<span class="error">' . _t( 'This theme is a legacy theme that is not compatible with Habari ' ) . Version::get_habariversion() . '. <br><br>Please update your theme.</span>';
					$themedata['info']->license = '';
				}
				else {
					foreach ( $themedata['info'] as $name=>$value ) {
						$themedata[$name] = (string) $value;
					}

					if ( $screenshot = Utils::glob( $theme_path . '/screenshot.{png,jpg,gif}', GLOB_BRACE ) ) {
						$themedata['screenshot'] = Site::get_url( 'habari' ) . dirname( str_replace( HABARI_PATH, '', $theme_path ) ) . '/' . basename( $theme_path ) . "/" . basename( reset( $screenshot ) );
					}
					else {
						$themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png";
					}
				}
				
				self::$all_data[$theme_dir] = $themedata;
			}
		}
		return self::$all_data;
	}
 /**
  * Constructor for RenderCache
  *
  * Sets up paths and gets the list of groups from file
  */
 public static function __static()
 {
     //Define the cache path and url
     self::$cache_path = HABARI_PATH . '/' . self::$rel_cache_path;
     self::$cache_url = Site::get_url('habari') . '/' . self::$rel_cache_path;
     //If the cache directory doesn't exist, make it
     if (!is_dir(self::$cache_path)) {
         mkdir(self::$cache_path, 0755);
     }
     //Enable only if the cache directory now exists and is writable
     self::$enabled = is_dir(self::$cache_path) && is_writeable(self::$cache_path);
     //Give an error if the cache directory is not writable
     if (!self::$enabled) {
         Session::error(sprintf(_t("The cache directory '%s' is not writable - the cache is disabled. The user, or group, which your web server is running as, needs to have read, write, and execute permissions on this directory."), self::$cache_path), 'RenderCache');
         EventLog::log(sprintf(_t("The cache directory '%s' is not writable - the cache is disabled."), self::$cache_path), 'notice', 'RenderCache', 'habari');
         return;
     }
     //Get the list of group names
     $group_file = self::get_group_list_file();
     if (file_exists($group_file)) {
         self::$group_list = unserialize(file_get_contents($group_file));
     } else {
         self::$group_list = array();
     }
 }