wird zB in LinkTag_Mail_Data.php verwendet, deshalb public
183074
public function encodeMail($address)
    {
        if ($this->_getRenderer() instanceof Kwf_Component_Renderer_Mail) {
            return $text;
        }
        $address = trim($address);
        $address = preg_replace('/^(.+)@(.+)\.([^\.\s]+)$/i',
            '$1'.$this->_atEncoding.'$2'.$this->_dotEncoding.'$3',
            $address
        );
        return $address;
    }
444491
public function callbackSubmit()
    {

        $email       = $this->form->value("email");
        $password    = $this->form->value("password");

        $user = new User();
        $user->setDb($this->di->get("db"));
        $res = $user->verifyPassword($email, $password);

        if (!$res) {
            $this->form->rememberValues();
            $this->form->addOutput("Användarnamnet eller lösenordet stämmer inte överens.", "flash");

            return false;
        }

        if (!$user->isActive($email)) {
            $this->form->addOutput("Kontot är inte aktiverat.", "flash");
            return false;
        }

        $this->di->get("session")->set("user", $user->email);
        $this->di->get("session")->set("userid", $user->id);


        $this->di->get("response")->redirect("user");
        return true;
    }
1011850
function encodeEmail_debutpage($email, $name = null)
    {

        $email = preg_replace("/\"/", "\\\"", $email);

        if ($name == null) {
            $name = $email;
        }

        $old = "document.write('<a CLASS=infoacceuil ".
            "href=\"mailto:$email\">$name</a>')";

        $output = "";

        for ($i=0; $i < pia_strlen($old); $i++) {
            $output = $output . '%' . bin2hex(pia_substr($old, $i, 1));
        }

        $output = '<script type="text/javascript">eval(unescape(\''.
            $output.'\'))</script>';
        $output .= '<noscript><div>Vous devez accepter le Javascript'.
            ' pour voir l\'email</div></noscript>';
        return $output;
    }
1358252
function prefs_table($args)
    {
        global $CURR_SECTION;

        $this->add_texts('localization');

        $rcmail        = rcmail::get_instance();
        $dont_override = $rcmail->config->get('dont_override', array());

        if ($args['section'] == 'folders' && !in_array('archive_mbox', $dont_override)) {
            $mbox = $rcmail->config->get('archive_mbox');
            $type = $rcmail->config->get('archive_type');

            // load folders list when needed
            if ($CURR_SECTION) {
                $select = $rcmail->folder_selector(array(
                        'noselection'   => '---',
                        'realnames'     => true,
                        'maxlength'     => 30,
                        'folder_filter' => 'mail',
                        'folder_rights' => 'w',
                        'onchange'      => "if ($(this).val() == 'INBOX') $(this).val('')",
                ));
            }
            else {
                $select = new html_select();
            }

            $args['blocks']['main']['options']['archive_mbox'] = array(
                'title'   => $this->gettext('archivefolder'),
                'content' => $select->show($mbox, array('name' => "_archive_mbox"))
            );

            // add option for structuring the archive folder
            $archive_type = new html_select(array('name' => '_archive_type', 'id' => 'ff_archive_type'));
            $archive_type->add($this->gettext('none'), '');
            $archive_type->add($this->gettext('archivetypeyear'), 'year');
            $archive_type->add($this->gettext('archivetypemonth'), 'month');
            $archive_type->add($this->gettext('archivetypesender'), 'sender');
            $archive_type->add($this->gettext('archivetypefolder'), 'folder');

            $args['blocks']['archive'] = array(
                'name' => rcube::Q($this->gettext('settingstitle')),
                'options' => array('archive_type' => array(
                        'title'   => $this->gettext('archivetype'),
                        'content' => $archive_type->show($type)
                    )
                )
            );
        }
        else if ($args['section'] == 'server' && !in_array('read_on_archive', $dont_override)) {
            $chbox = new html_checkbox(array('name' => '_read_on_archive', 'id' => 'ff_read_on_archive', 'value' => 1));
            $args['blocks']['main']['options']['read_on_archive'] = array(
                'title'   => $this->gettext('readonarchive'),
                'content' => $chbox->show($rcmail->config->get('read_on_archive') ? 1 : 0)
            );
        }

        return $args;
    }
782719
public function track_open()
    {
        $oUri     = Factory::service('Uri');
        $oEmailer = Factory::service('Emailer', 'nails/module-email');

        $sRef  = $oUri->segment(3);
        $sGuid = $oUri->segment(4);
        $sHash = $oUri->segment(5);

        // --------------------------------------------------------------------------

        if (!$sRef || !$oEmailer->validateHash($sRef, $sGuid, $sHash)) {
            show404();
        }

        // --------------------------------------------------------------------------

        //  Fetch the email
        $oEmailer->trackOpen($sRef);

        // --------------------------------------------------------------------------

        /**
         * Render out a tiny, tiny image
         * Thanks http://probablyprogramming.com/2009/03/15/the-tiniest-gif-ever
         */

        header('Content-Type: image/gif');
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
        header('Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT');
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header('Cache-Control: post-check=0, pre-check=0', false);
        header('Pragma: no-cache');

        echo base64_decode('R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');

        // --------------------------------------------------------------------------

        /**
         * Kill script, th, th, that's all folks. Stop the output class from hijacking
         * our headers and setting an incorrect Content-Type
         */

        exit(0);
    }
208034
protected function form_app_webdof($click = false){
   	    $args = func_get_args();
		if(isset($args[0]))$click = $args[0];
		
		
		
        $div = 'APP_WEBDOF';
		$title = 'Webfan PragmaMx Module Setup';
		$homepage = 'http://www.webfan.de/Downloads-lid-webdof-php-library-63.html';
		$appKey = 'apps_webdof';
		
		
     	$html = '';
		$html.= '<a name="'.$appKey.'"></a>';  

		 $html.= '<div class="webfanWikiBoxouter" style="background-size: contain; background-attachment: hidden;  background: url(\'\') #E8F9FF;vertical-align:top;">';		
	    $html.= $this->render_app_head_table($title, $appKey, $div, $homepage, 
	                'http://webfan.de/bilder/domainundhomepagespeicher/produkte/kurzbeschreibung/24.247.247THP.produktbild_artikelbeschreibung.jpg',
	                $click);
		 $html.= '<div id="'.$div.'" style="display:none;">';	  		
	     $html.= '[ <b><a title="webdof php library" href="'.$homepage.'" target="_blank" style="color:black;">Homepage</a></b> ]';
	
		 $html.= '<span class="webfan-blue" style="font-size:14px;font-weight:bold;">webdof php library</span>, '.$this->lang('__REQUIRED_BY_WEBFAN_PMX_MODULES__').'. <br />Version/update check, InstallShield, API Modul / API-D Interfaces, Cronjobverwaltung, Languagestrings-Manager, Plugin-System, Fast-Cache...<br />';
		
	
			 
			
			 $Installer = null; 
			 $li = false;
			 $pmx = false;
			 if(count($this->detect[self::GROUP_APPS][self::APP_PMX]) === 0){
			 	$html.= '<a href="#apps_pmx" style="color:red;">'.$this->e('PragmaMx required.').'</a><br />';
				$pmx = false;
			 }else{
			 	$li = true;
				$pmx = true;
			 }
			 
		 if(count($this->detect[self::GROUP_APPS][self::APP_WEBDOF]) > 0)$li = true;	 

         if($li === true){
         	$Installer = new \webfan\InstallShield\PragmaMx\WebfanModulesSetup($this);
			
			$html.= $Installer->render_form_install();
			 
            foreach($this->detect[self::GROUP_APPS][self::APP_WEBDOF] as $dir => $app){
         	
            }
		 			 
		 }
		 

		        $html.= $this->render_app_close_x( $div, $homepage);
		        $html.= '</div>';	
			$html.= '</div>';	
			
	
			
		return $html;	
   }
781912
function publishHandlerEmbed( $element, &$params )
    {
        $ret = null;

        $href = $element->getAttribute( 'href' );
        //washing href. single and double quotes replaced with their urlencoded form
        $href = str_replace( array('\'','"'), array('%27','%22'), $href );

        if ( $href != null )
        {
            if ( preg_match( "@^ezobject://[0-9]+$@" , $href ) )
            {
                $objectID = substr( strrchr( $href, "/" ), 1 );

                // protection from self-embedding
                if ( $objectID == $this->contentObjectID )
                {
                    $this->handleError( eZXMLInputParser::ERROR_DATA,
                                        ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', 'Object %1 can not be embeded to itself.', '', array( $objectID ) ) );

                    $element->removeAttribute( 'href' );
                    return $ret;
                }

                $element->setAttribute( 'object_id', $objectID );

                if ( !in_array( $objectID, $this->relatedObjectIDArray ) )
                {
                    $this->relatedObjectIDArray[] = $objectID;
                }
            }
            elseif ( preg_match( "@^eznode://.+$@" , $href ) )
            {
                $nodePath = substr( strchr( $href, "/" ), 2 );

                if ( preg_match( "@^[0-9]+$@", $nodePath ) )
                {
                    $nodeID = $nodePath;
                    $node = eZContentObjectTreeNode::fetch( $nodeID, false, false );
                    if ( !$node )
                    {
                        $this->handleError( eZXMLInputParser::ERROR_DATA,
                                            ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', "Node '%1' does not exist.", '', array( $nodeID ) ) );

                        $element->removeAttribute( 'href' );
                        return $ret;
                    }
                }
                else
                {
                    $node = eZContentObjectTreeNode::fetchByURLPath( $nodePath, false );
                    if ( !$node )
                    {
                        $this->handleError( eZXMLInputParser::ERROR_DATA,
                                            ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', 'Node \'%1\' does not exist.', '', array( $nodePath ) ) );

                        $element->removeAttribute( 'href' );
                        return $ret;
                    }
                    $nodeID = $node['node_id'];
                    $element->setAttribute( 'show_path', 'true' );
                }

                $element->setAttribute( 'node_id', $nodeID );
                $objectID = $node['id'];

                // protection from self-embedding
                if ( $objectID == $this->contentObjectID )
                {
                    $this->handleError( eZXMLInputParser::ERROR_DATA,
                                        ezpI18n::tr( 'kernel/classes/datatypes/ezxmltext', 'Object %1 can not be embeded to itself.', '', array( $objectID ) ) );

                    $element->removeAttribute( 'href' );
                    return $ret;
                }

                if ( !in_array( $objectID, $this->relatedObjectIDArray ) )
                {
                     $this->relatedObjectIDArray[] = $objectID;
                 }
            }
            else
            {
                $this->isInputValid = false;
                $this->Messages[] = ezpI18n::tr( 'kernel/classes/datatypes', 'Invalid reference in &lt;embed&gt; tag. Note that <embed> tag supports only \'eznode\' and \'ezobject\' protocols.' );
                $element->removeAttribute( 'href' );
                return $ret;
            }
        }

        $element->removeAttribute( 'href' );
        $this->convertCustomAttributes( $element );
        return $ret;
    }
343204
function handleTag_a() {
    if ($this->parser->isStartTag) {
      $this->buffer();
      if (isset($this->parser->tagAttributes['title'])) {
        $this->parser->tagAttributes['title'] = $this->decode($this->parser->tagAttributes['title']);
      } else {
        $this->parser->tagAttributes['title'] = null;
      }
      $this->parser->tagAttributes['href'] = $this->decode(trim($this->parser->tagAttributes['href']));
      $this->stack();
    } else {
      $tag = $this->unstack();
      $buffer = $this->unbuffer();

      if (empty($tag['href']) && empty($tag['title'])) {
        # empty links... testcase mania, who would possibly do anything like that?!
        $this->out('['.$buffer.']()', true);
        return;
      }

      if ($buffer == $tag['href'] && empty($tag['title'])) {
        # <http://example.com>
        $this->out('<'.$buffer.'>', true);
        return;
      }

      $bufferDecoded = $this->decode(trim($buffer));
      if (substr($tag['href'], 0, 7) == 'mailto:' && 'mailto:'.$bufferDecoded == $tag['href']) {
        if (is_null($tag['title'])) {
          # <mail@example.com>
          $this->out('<'.$bufferDecoded.'>', true);
          return;
        }
        # [mail@example.com][1]
        # ...
        #  [1]: mailto:mail@example.com Title
        $tag['href'] = 'mailto:'.$bufferDecoded;
      }
	    if ($this->linksAfterEachParagraph!=='inline'){
	      # [This link][id]
	      foreach ($this->stack['a'] as $tag2) {
	        if ($tag2['href'] == $tag['href'] && $tag2['title'] === $tag['title']) {
	          $tag['linkID'] = $tag2['linkID'];
	          break;
	        }
	      }
	      if (!isset($tag['linkID'])) {
	        $tag['linkID'] = count($this->stack['a']) + 1;
	        array_push($this->stack['a'], $tag);
	      }

	      $this->out('['.trim($buffer).']['.$tag['linkID'].']', true);
	    }
	    else {
		    # [This link|title](url)
		    if ($tag['title'])
			    $buffer.="|".$tag['title'];
		    $this->out('['.trim($buffer).']('.$tag['href'].')', true);
	    }
    }
  }
1269877
public function detect_emails()
	{
		$this->loop_text_nodes(function($child) {
			preg_match_all("/(?:[a-zA-Z0-9\-\._]){1,}@(?:[a-zA-Z0-9\-\.]{1,255}\.[a-zA-Z]{1,20})/",
				$child->get_text(),
				$matches,
				PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE);

			if(count($matches[0]) == 0)
				return;

			$replacment = array();
			$last_pos   = 0;

			foreach($matches[0] as $match)
			{
				$url      = new Node_Container_Tag('email', array());
				$url_text = new Node_Text($match[0]);
				$url->add_child($url_text);

				$replacment[] = new Node_Text(substr($child->get_text(), $last_pos, $match[1] - $last_pos));
				$replacment[] = $url;
				$last_pos = $match[1] + strlen($match[0]);
			}

			$replacment[] = new Node_Text(substr($child->get_text(), $last_pos));
			$child->parent()->replace_child($child, $replacment);
		}, $this->get_excluded_tags(BBCode::AUTO_DETECT_EXCLUDE_EMAIL));

		return $this;
	}
518412
public function previewAction()
    {
        //wyszukiwanie wiadomości
        if (null === $mail = (new \Cms\Orm\CmsMailQuery)->findPk($this->id)) {
            $this->getResponse()->redirect('cmsAdmin', 'mail', 'index');
        }
        $this->view->message = $mail->message;
    }
111180
function PclZip($p_zipname)
  {

    // ----- Tests the zlib
    if (!function_exists('gzopen'))
    {
      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
    }

    // ----- Set the attributes
    $this->zipname = $p_zipname;
    $this->zip_fd = 0;
    $this->magic_quotes_status = -1;

    // ----- Return
    return;
  }
888584
static function publishUpdateUser( $parentNodeIDs, $defaultUserPlacement, $userAttributes, $isUtf8Encoding = false )
    {
        if ( !is_array( $userAttributes ) or
             !isset( $userAttributes[ 'login' ] ) or empty( $userAttributes[ 'login' ] ) )
        {
            eZDebug::writeWarning( 'Empty user login passed.', __METHOD__ );
            return false;
        }

        if ( ( !is_array( $parentNodeIDs ) or count( $parentNodeIDs ) < 1 ) and
             !is_numeric( $defaultUserPlacement ) )
        {
            eZDebug::writeWarning( 'No one parent node IDs was passed for publishing new user (login = "' .
                                   $userAttributes[ 'login' ] . '")',
                                   __METHOD__ );
            return false;
        }
        $parentNodeIDs[] = $defaultUserPlacement;
        $parentNodeIDs = array_unique( $parentNodeIDs );


        $login      = $userAttributes[ 'login' ];
        $first_name = $userAttributes[ 'first_name' ];
        $last_name  = $userAttributes[ 'last_name' ];
        $email      = $userAttributes[ 'email' ];

        if ( $isUtf8Encoding )
        {
            $first_name = utf8_decode( $first_name );
            $last_name = utf8_decode( $last_name );
        }

        $user = eZUser::fetchByName( $login );
        $createNewUser = ( is_object( $user ) ) ? false : true;

        if ( $createNewUser )
        {
            if ( !isset( $first_name ) or empty( $first_name ) or
                 !isset( $last_name ) or empty( $last_name ) or
                 !isset( $email ) or empty( $email ) )
            {
                eZDebug::writeWarning( 'Cannot create user with empty first name (last name or email).', __METHOD__ );
                return false;
            }

            $ini = eZINI::instance();
            $userClassID = $ini->variable( "UserSettings", "UserClassID" );
            $userCreatorID = $ini->variable( "UserSettings", "UserCreatorID" );
            $defaultSectionID = $ini->variable( "UserSettings", "DefaultSectionID" );

            $class = eZContentClass::fetch( $userClassID );
            $contentObject = $class->instantiate( $userCreatorID, $defaultSectionID );

            $contentObject->store();

            $userID = $contentObjectID = $contentObject->attribute( 'id' );

            $version = $contentObject->version( 1 );
            $version->setAttribute( 'modified', time() );
            $version->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
            $version->store();

            $user = eZLDAPUser::create( $userID );
            $user->setAttribute( 'login', $login );
        }
        else
        {
            $userID = $contentObjectID = $user->attribute( 'contentobject_id' );
            $contentObject = eZContentObject::fetch( $userID );
            $version = $contentObject->attribute( 'current' );
        }

        //================= common part 1: start ========================
        $contentObjectAttributes = $version->contentObjectAttributes();

        // find and set 'name' and 'description' attributes (as standard user group class)
        $firstNameIdentifier = 'first_name';
        $lastNameIdentifier = 'last_name';
        $firstNameAttribute = null;
        $lastNameAttribute = null;

        foreach ( $contentObjectAttributes as $attribute )
        {
            if ( $attribute->attribute( 'contentclass_attribute_identifier' ) == $firstNameIdentifier )
            {
                $firstNameAttribute = $attribute;
            }
            else if ( $attribute->attribute( 'contentclass_attribute_identifier' ) == $lastNameIdentifier )
            {
                $lastNameAttribute = $attribute;
            }
        }
        //================= common part 1: end ==========================

        // If we are updating an existing user, we must find out if some data should be changed.
        // In that case, we must create a new version and publish it.
        if ( !$createNewUser )
        {
            $userDataChanged = false;
            $firstNameChanged = false;
            $lastNameChanged = false;
            $emailChanged = false;

            if ( $firstNameAttribute and $firstNameAttribute->attribute( 'data_text' ) != $first_name )
            {
                $firstNameChanged = true;
            }
            $firstNameAttribute = false; // We will load this again from the new version we will create, if it has changed
            if ( $lastNameAttribute and $lastNameAttribute->attribute( 'data_text' ) != $last_name )
            {
                $lastNameChanged = true;
            }
            $lastNameAttribute = false; // We will load this again from the new version we will create, if it has changed
            if ( $user->attribute( 'email' ) != $email )
            {
                $emailChanged = true;
            }

            if ( $firstNameChanged or $lastNameChanged or $emailChanged )
            {
                $userDataChanged = true;
                // Create new version
                $version = $contentObject->createNewVersion();
                $contentObjectAttributes = $version->contentObjectAttributes();
                foreach ( $contentObjectAttributes as $attribute )
                {
                    if ( $attribute->attribute( 'contentclass_attribute_identifier' ) == $firstNameIdentifier )
                    {
                        $firstNameAttribute = $attribute;
                    }
                    else if ( $attribute->attribute( 'contentclass_attribute_identifier' ) == $lastNameIdentifier )
                    {
                        $lastNameAttribute = $attribute;
                    }
                }
            }
        }

        //================= common part 2: start ========================
        if ( $firstNameAttribute )
        {
            $firstNameAttribute->setAttribute( 'data_text', $first_name );
            $firstNameAttribute->store();
        }
        if ( $lastNameAttribute )
        {
            $lastNameAttribute->setAttribute( 'data_text', $last_name );
            $lastNameAttribute->store();
        }

        if ( !isset( $userDataChanged ) or $userDataChanged === true )
        {
            $contentClass = $contentObject->attribute( 'content_class' );
            $name = $contentClass->contentObjectName( $contentObject );
            $contentObject->setName( $name );
        }

        if ( !isset( $emailChanged ) or $emailChanged === true )
        {
            $user->setAttribute( 'email', $email );
        }

        $user->setAttribute( 'password_hash', "" );
        $user->setAttribute( 'password_hash_type', self::PASSWORD_HASH_EMPTY );
        $user->store();

        $debugArray = array( 'Updating user data',
                             'createNewUser' => $createNewUser,
                             'userDataChanged' => isset( $userDataChanged ) ? $userDataChanged : null,
                             'login' => $login,
                             'first_name' => $first_name,
                             'last_name' => $last_name,
                             'email' => $email,
                             'firstNameAttribute is_object' => is_object( $firstNameAttribute ),
                             'lastNameAttribute is_object' => is_object( $lastNameAttribute ),
                             'content object id' => $contentObjectID,
                             'version id' => $version->attribute( 'version' )
        );
        eZDebug::writeNotice( var_export( $debugArray, true ), __METHOD__ );
        //================= common part 2: end ==========================

        if ( $createNewUser )
        {
            reset( $parentNodeIDs );
            // prepare node assignments for publishing new user
            foreach( $parentNodeIDs as $parentNodeID )
            {
                $newNodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $contentObjectID,
                                                                      'contentobject_version' => 1,
                                                                      'parent_node' => $parentNodeID,
                                                                      // parent_remote_id in node assignment holds remote id of the tree node,
                                                                      // not of the parent location or of the node assignment itself
                                                                      'parent_remote_id' => uniqid( 'LDAP_' ),
                                                                      'is_main' => ( $defaultUserPlacement == $parentNodeID ? 1 : 0 ) ) );
                $newNodeAssignment->store();
            }

            $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
                                                                                         'version' => 1 ) );
        }
        else
        {
            if ( $userDataChanged )
            {
                // Publish object
                $operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
                                                                                             'version' => $version->attribute( 'version' ) ) );
                // Refetch object
                $contentObject = eZContentObject::fetch( $contentObjectID );
                $version = $contentObject->attribute( 'current' );
            }

            $LDAPIni = eZINI::instance( 'ldap.ini' );
            $keepGroupAssignment = ( $LDAPIni->hasVariable( 'LDAPSettings', 'KeepGroupAssignment' ) ) ?
                ( $LDAPIni->variable( 'LDAPSettings', 'KeepGroupAssignment' ) == "enabled" ) : false;

            if ( $keepGroupAssignment == false )
            {
                $objectIsChanged = false;

                $db = eZDB::instance();
                $db->begin();

                // First check existing assignments, remove any that should not exist
                $assignedNodesList = $contentObject->assignedNodes();
                $existingParentNodeIDs = array();
                foreach ( $assignedNodesList as $node )
                {
                    $parentNodeID = $node->attribute( 'parent_node_id' );
                    if ( !in_array( $parentNodeID, $parentNodeIDs ) )
                    {
                        $node->removeThis();
                        $objectIsChanged = true;
                    }
                    else
                    {
                        $existingParentNodeIDs[] = $parentNodeID;
                    }
                }

                // Then check assignments that should exist, add them if they are missing
                foreach( $parentNodeIDs as $parentNodeID )
                {
                    if ( !in_array( $parentNodeID, $existingParentNodeIDs ) )
                    {
                        $newNode = $contentObject->addLocation( $parentNodeID, true );
                        $newNode->updateSubTreePath();
                        $newNode->setAttribute( 'contentobject_is_published', 1 );
                        $newNode->sync();
                        $existingParentNodeIDs[] = $parentNodeID;
                        $objectIsChanged = true;
                    }
                }

                // Then ensure that the main node is correct
                $currentMainParentNodeID = $contentObject->attribute( 'main_parent_node_id' );
                if ( $currentMainParentNodeID != $defaultUserPlacement )
                {
                    $existingNode = eZContentObjectTreeNode::fetchNode( $contentObjectID, $defaultUserPlacement );
                    if ( !is_object( $existingNode ) )
                    {
                        eZDebug::writeError( "Cannot find assigned node as $defaultUserPlacement's child.", __METHOD__ );
                    }
                    else
                    {
                        $existingNodeID = $existingNode->attribute( 'node_id' );
                        $versionNum = $version->attribute( 'version' );
                        eZContentObjectTreeNode::updateMainNodeID( $existingNodeID, $contentObjectID, $versionNum, $defaultUserPlacement );
                        $objectIsChanged = true;
                    }
                }

                $db->commit();

                // Finally, clear object view cache if something was changed
                if ( $objectIsChanged )
                {
                    eZContentCacheManager::clearObjectViewCache( $contentObjectID, true );
                }
            }
        }

        eZUser::updateLastVisit( $userID );
        //eZUser::setCurrentlyLoggedInUser( $user, $userID );
        // Reset number of failed login attempts
        eZUser::setFailedLoginAttempts( $userID, 0 );
        return $user;
    }
1179256
public function run()
	{
		// Input a digit >0 ?
		if ( 0 == (int)$this->intBID )
		{
		    if ( 0 == (int)$this->intDEFBID ) 
		    {
		        header('HTTP/1.1 501 Not Implemented');
		    	throw new \ErrorException('Invalid Banner ID (' . \Input::get('bid') . ')',2,1,basename(__FILE__),__LINE__);
		    }
		}

		//Banner oder Kategorie Banner (Default Banner)
		if ( 0 < (int)$this->intBID ) 
		{
			//normaler Banner
			$banner_not_viewed = false;
    		// Check whether the Banner ID exists
    		$objBanners = \Database::getInstance()
                                ->prepare("SELECT 
                                                tb.id
                                              , tb.banner_url
                                              , tb.banner_jumpTo
                                              , tbs.banner_clicks
                                           FROM 
                                                tl_banner tb
                                              , tl_banner_stat tbs
                                           WHERE 
                                                tb.id=tbs.id 
                                           AND 
                                                tb.id=?")
                                ->execute($this->intBID);
    		
    		if (!$objBanners->next()) 
    		{
    			$objBanners = \Database::getInstance()
                                    ->prepare("SELECT 
                                                    tb.id
                                                  , tb.banner_url
                                                  , tb.banner_jumpTo
                                               FROM 
                                                    tl_banner tb
                                               WHERE 
                                                    tb.id=?")
                                    ->execute($this->intBID);
	    		
	    		if (!$objBanners->next()) 
	    		{
	    			header('HTTP/1.1 501 Not Implemented');
	    			throw new \ErrorException('Banner ID not found',2,1,basename(__FILE__),__LINE__);
	    		} 
	    		else 
	    		{
	    			$banner_not_viewed = true;
	    		}
    		}
    		
			$banner_stat_update = false;
		    if ($this->checkUserAgent()       === false 
		     && $this->checkBot()             === false 
		     && $this->getSetReClickBlocker() === false
		       ) 
		    { 
		    	// keine User Agent Filterung
		    	// kein Bot
		    	// kein ReClick 
		    	$banner_stat_update = true;
		    }
		    
		    if ($banner_stat_update === true) 
		    {
                if ($banner_not_viewed === false) 
                {
                	//Update
                	$tstamp = time();
	                $banner_clicks = $objBanners->banner_clicks + 1;
	                \Database::getInstance()->prepare("UPDATE 
                                                            tl_banner_stat 
                                                       SET 
                                                            tstamp=?
                                                          , banner_clicks=? 
                                                       WHERE 
                                                            id=?")
                                            ->executeUncached($tstamp, $banner_clicks, $this->intBID);
    			} 
    			else 
    			{
    				//Insert
    				 $arrSet = array
		            (
		                'id'     => $this->intBID,
		                'tstamp' => time(),
		                'banner_clicks' => 1
		            );
				    \Database::getInstance()->prepare("INSERT IGNORE INTO tl_banner_stat %s")
                                            ->set($arrSet)
                                            ->execute();
    			}
		    }
    		
    		//Banner Ziel per Page?
            if ($objBanners->banner_jumpTo >0) 
            {
            	//url generieren
            	$objBannerNextPage = \Database::getInstance()
                                            ->prepare("SELECT 
                                                            id
                                                          , alias 
                                                       FROM 
                                                            tl_page 
                                                       WHERE 
                                                            id=?")
                                            ->limit(1)
                                            ->execute($objBanners->banner_jumpTo);
            	
            	if ($objBannerNextPage->numRows)
            	{
           	        $objPage = \PageModel::findWithDetails($objBanners->banner_jumpTo); 
                    $objBanners->banner_url = \Controller::generateFrontendUrl($objBannerNextPage->fetchAssoc(),
                                                                               null,
                                                                               $objPage->rootLanguage);
            	} 
            }
            $banner_redirect = $this->getRedirectType($this->intBID);
        } 
        else 
        {
            // Default Banner from Category
            // Check whether the Banner ID exists
    		$objBanners = \Database::getInstance()
                                ->prepare("SELECT 
                                                id
                                              , banner_default_url AS banner_url
                                           FROM 
                                                tl_banner_category
                                           WHERE 
                                                id=?")
                                ->execute($this->intDEFBID);
    		
            if (!$objBanners->next()) 
            {
                header('HTTP/1.1 501 Not Implemented');
            	throw new \ErrorException('Default Banner ID not found',2,1,basename(__FILE__),__LINE__);
            }
            $banner_redirect = '303';
        }

		$banner_url = ampersand($objBanners->banner_url);
		// 301 Moved Permanently
		// 302 Found
		// 303 See Other
		// 307 Temporary Redirect (ab Contao 3.1)
		$this->redirect($banner_url, $banner_redirect); 
	}
884274
public static function linksToHtml($str, $allow_email=false, $link_markup=null)
    {

        ### Convert Email Tags ###
        if(!$allow_email){
            $str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", '<b> \\2 AT \\3 </b>', $str);
        } else {
            $str = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", ' <a href="mailto:\\2@\\3">\\2@\\3</a>', $str);
        }

        ### phrase links ###
        $str = preg_replace( "~\[(?:url|link)=(http.*?)\](.*?)\[\/(?:url|link)\]~", "<a class=\"blank\" href=\"\\1\">\\2</a>", $str);

        $link = $link_markup ? $link_markup : '(LINK)';
        ### url links ###\\2://\\3
        //$str = preg_replace("#(\s|\n)([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", ' <a href="\\2://\\3" title="\\2://\\3">'.$link.'</a>', $str);

        $str = preg_replace_callback("#(^|\s)([a-z]+?://[\w\-\.,\?!%\*\#:;~\\&$@\/=\+]+)#i", function($match) use($link){
            $href = $match[2];
            $end_punct = '';

            if(preg_match("~[\.\?\!]$~", $href, $matchx)){
                $end_punct = $matchx[0];
                $href = substr($href,0,-1);
            }
            return $match[1].'<a href="'.$href.'" title="'.$href.'">'.$link.'</a>'.$end_punct;
        }, $str);

        return $str;
    }
547765
public static function link($srcObject, $srcId, $destObject, $destId)
    {
        $i = 0;
        //kopiowanie plików
        foreach (CmsFileQuery::byObject($srcObject, $srcId)->find() as $file) {
            $newFile = clone $file;
            $newFile->object = $destObject;
            $newFile->objectId = $destId;
            $newFile->id = null;
            $newFile->save();
            $i++;
        }
        return $i;
    }
1075658
public static function send()
    {
        //rezultat wysyłania
        $result = ['error' => 0, 'success' => 0];
        //pobieranie maili
        $emails = (new Orm\CmsMailQuery)
            ->join('cms_mail_definition')->on('cms_mail_definition_id')
            ->join('cms_mail_server', 'cms_mail_definition')->on('cms_mail_server_id')
            ->whereActive()->equals(0)
            ->andFieldDateSendAfter()->lessOrEquals(date('Y-m-d H:i:s'))
            ->orderAscDateSendAfter()
            ->limit(500)
            ->find();
        //brak maili do wysyłki
        if (count($emails) == 0) {
            return $result;
        }
        //tymczasowy stan (w wysyłce)
        foreach ($emails as $email) {
            $email->active = 2;
            $email->save();
        }
        //wysyłka pojedynczego maila
        foreach ($emails as $email) {
            //instancja PHPMailer'a
            $mail = new \PHPMailer(true);
            try {
                $mail->CharSet = 'utf-8';
                //ustawiam SMTP
                $mail->isSMTP();
                //ustawianie hosta
                $mail->Host = $email->getJoined('cms_mail_server')->address;
                //ustawianie portu
                $mail->Port = $email->getJoined('cms_mail_server')->port;
                //jezeli podana nazwa uzytkownika i haslo to wlaczamy uwierzytelnienie
                if ($email->getJoined('cms_mail_server')->username && $email->getJoined('cms_mail_server')->password) {
                    //uwierzytelnianie serwera
                    $mail->SMTPAuth = true;
                    //typ uwierzytelniania
                    $mail->AuthType = 'LOGIN';
                    //uzytkownik SMTP
                    $mail->Username = $email->getJoined('cms_mail_server')->username;
                    //haslo SMTP
                    $mail->Password = $email->getJoined('cms_mail_server')->password;
                }
                if ($email->getJoined('cms_mail_server')->ssl != 'plain') {
                    //szyfrowanie polaczenia
                    $mail->SMTPSecure = $email->getJoined('cms_mail_server')->ssl;
                }
                //ustawianie treści wiadomości
                $mail->Body = strip_tags($email->message);
                //jezeli HTML to ustawiam typ wiadomości na HTML
                if ($email->getJoined('cms_mail_definition')->html) {
                    $mail->isHTML(true);
                    $mail->Body = $email->message;
                }
                //ustawianie "from"
                $mail->setFrom($email->getJoined('cms_mail_server')->from, $email->fromName);
                //ustawianie "do"
                $recipients = explode(';', $email->to);
                foreach ($recipients as $recipient) {
                    $mail->addAddress(trim($recipient));
                }
                //ustawianie reply
                if ($email->replyTo) {
                    $mail->addReplyTo($email->replyTo);
                }
                //ustawianie tematu
                $mail->Subject = $email->subject;
                //dołączanie załączników
                $attachments = unserialize($email->attachements);
                if (!empty($attachments)) {
                    foreach ($attachments as $fileName => $filePath) {
                        if (!file_exists($filePath)) {
                            continue;
                        }
                        $file = [
                            'content' => base64_encode(file_get_contents($filePath)),
                            'type' => \Mmi\FileSystem::mimeType($filePath)
                        ];
                        $mail->addStringAttachment(base64_decode($file['content']), $fileName, 'base64', $file['type'], 'attachment');
                    }
                }
                //wysyłka maila
                $mail->send();
                //logowanie wysyłki
                \Mmi\App\FrontController::getInstance()->getLogger()->info('Sent: ' . $email->to . ' ' . $email->subject);
                //czyszczenie załączników
                $email->attachements = null;
                //ustawienie pol po wysłaniu
                $email->active = 1;
                $email->dateSent = date('Y-m-d H:i:s');
                $email->save();
                //podwyzszenie licznika udanych
                $result['success'] ++;
            } catch (\Exception $e) {
                //bład wysyłki
                \Mmi\App\FrontController::getInstance()->getLogger()->warning($e->getMessage());
                //podwyzszenie licznika nieudanych
                $result['error'] ++;
            }
        }
        return $result;
    }
1081567
static public function linkEmailAddresses($text, array $attribs = array()) {
        $htmlAttribs = array();
        foreach ($attribs as $name => $value) {
            $htmlAttribs[] = $name . '="' . $value . '"';
        }
        $htmlAttribs = implode(' ', $htmlAttribs);
        $htmlAttribs = $htmlAttribs ? ' ' . $htmlAttribs : '';

        $regexp = '/[a-zA-Z0-9\.-_+]+@[a-zA-Z0-9\.\-_]+\.([a-zA-Z]{2,})/';
        $text = preg_replace($regexp, "<a href=\"mailto:$0\"$htmlAttribs>$0</a>", $text);
        return $text;
    }