We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    Hi Scotty,

    it was already mentioned in this thread, but once again:

    Changing of the userimage is not possible if the type of the new image is .jpg. I already tried to add another mime type like this:

    		switch ($_FILES['photo']['type'])
    		{
    			case 'image/jpeg':
    				$image = imagecreatefromjpeg($userImage);
    				$ext = '.jpg';
    				break;
    
    			case 'image/jpg':
    				$image = imagecreatefromjpeg($userImage);
    				$ext = '.jpg';
    				break;


    But with no luck... At registration everything is okay. You can also try this at your demo site.
      • 29181
      • 480 Posts
      Is anyone else having issues with dob not being saved to the

      {prefix}web_user_attributes database correctly? I’m not sure why but when using the default templates and saving a date in the format it states I just get the first bit of the date saved.

      I looked at the MakeDateForDb function, and it states that the date needs to be in an alternative format to the one being stated in the template (Template says day first, function says month first). Either way it is still only saving the first part of the date to the database i.e. $dateArray[0]

      Now if I copy the function into a new php file e.g.

      <?php
      function MakeDateForDb($date = '11-12-1969')
      
      	{
      		// $date is a string like 01-22-1975.
      		if (strpos($date, '-'))
      		{
      			$dateArray = explode('-', $date);
      		}
      		else if (strpos($date, '/'))
      		{
      			$dateArray = explode('/', $date);
      		}
      		else
      		{
      			return $this->FormatMessage($this->LanguageArray[27]);
      		}
      		
      		$dateArray = explode('-', $date);
      		// $dateArray is somethink like [0]=01, [1]=22, [2]=1975
      		// make a unix timestamp out of the original date string.
      		$timestamp = mktime(0, 0, 0, $dateArray[0], $dateArray[1], $dateArray[2]);
      		echo $timestamp;
      	}
      	
      	MakeDateForDb();
      	?>


      it seems to output a correct timestamp like -4323600.

      Any ideas why?
        Adrian Lawley: www.adrianlawley.com
        • 17883
        • 1,039 Posts
        I think you try it with this format : 07/13/1967. This doesn´t work because of an error in the function.

        Just comment out this line:

        $dateArray = explode('-', $date);


        because it overrides the if clauses above.
          • 17883
          • 1,039 Posts
          it was already mentioned in this thread, but once again:

          Changing of the userimage is not possible if the type of the new image is .jpg.


          Solved. Occured only with IE6 which handles jpegs as image/pjpeg rolleyes Which surprise that this §"$"§$ Browser doesn´t even handle the file types correctly.

          Solution: Add this case to the image switch (around line 2850):

          	case 'image/pjpeg':
          				$image = imagecreatefromjpeg($userImage);
          				$ext = '.jpg';
          				break;
            • 29181
            • 480 Posts
            Quote from: MadeMyDay at Oct 17, 2007, 08:53 AM

            I think you try it with this format : 07/13/1967. This doesn´t work because of an error in the function.

            Just comment out this line:

            $dateArray = explode('-', $date);


            because it overrides the if clauses above.

            That was it...It was exploding the array during the if else function and then line 2471 was exploding it again thus returning only a value of the first array...

            function MakeDateForDb($date)
            	{
            		// $date is a string like 01-22-1975.
            		if (strpos($date, '-'))
            		{
            			$dateArray = explode('-', $date);
            		}
            		else if (strpos($date, '/'))
            		{
            			$dateArray = explode('/', $date);
            		}
            		else
            		{
            			return $this->FormatMessage($this->LanguageArray[27]);
            		}
            		
            		$dateArray = explode('-', $date);
            		// $dateArray is somethink like [0]=01, [1]=22, [2]=1975
            		// make a unix timestamp out of the original date string.
            		$timestamp = mktime(0, 0, 0, $dateArray[0], $dateArray[1], $dateArray[2]);
            		return $timestamp;
            	}
            

            needs to become
            function MakeDateForDb($date)
            	{
            		// $date is a string like 01-22-1975.
            		if (strpos($date, '-'))
            		{
            			$dateArray = explode('-', $date);
            		}
            		else if (strpos($date, '/'))
            		{
            			$dateArray = explode('/', $date);
            		}
            		else
            		{
            			return $this->FormatMessage($this->LanguageArray[27]);
            		}
            		
            		// $dateArray is somethink like [0]=01, [1]=22, [2]=1975
            		// make a unix timestamp out of the original date string.
            		$timestamp = mktime(0, 0, 0, $dateArray[0], $dateArray[1], $dateArray[2]);
            		return $timestamp;
            	}


            Hence the line around 2471 needs deleting or commenting out.

            Danke Marc!!!

            Taff
              Adrian Lawley: www.adrianlawley.com
              • 28033
              • 925 Posts
              I noticed another bug this morning, dealing with the viewprofile service.

              It seems that in the Userlist, WLPE properly parses HTML, such as
              . As an example, Scotty’s "signature" on my website’s WLPE install. Now, in the viewprofile page, the HTML is not parsed, and it shows the HTML.

              Maybe this is due to a line of code being in the Userlist function, but not being in the viewprofile function? It’s probably an easy fix, but I don’t have the time ATM to debug it. If someone could find a fix for this, I’d be very grateful. smiley

              (If a user does a normal manual line break (pressing the Enter key), it works fine, btw. It just does this w/ HTML.)
                My Snippets
                -> PopUpChunk v1.0
                • 33175
                • 711 Posts
                Quote from: MadeMyDay at Oct 12, 2007, 04:58 AM

                Changing of the userimage is not possible if the type of the new image is .jpg. I already tried to add another mime type like this:
                		switch ($_FILES['photo']['type'])
                		{
                			case 'image/jpeg':
                				$image = imagecreatefromjpeg($userImage);
                				$ext = '.jpg';
                				break;
                
                			case 'image/jpg':
                				$image = imagecreatefromjpeg($userImage);
                				$ext = '.jpg';
                				break;

                Good thing smiley
                A little tip smiley You can do the same thing with fewer line wink
                		switch ($_FILES['photo']['type'])
                		{
                			case 'image/jpeg':
                			case 'image/jpg':
                				$image = imagecreatefromjpeg($userImage);
                				$ext = '.jpg';
                				break;
                  Sorry for my english. I&#39;m french... My dictionary is near me, but it&#39;s only a dictionary !
                  • 33175
                  • 711 Posts
                  Hi all,

                  I found 2 bugs.

                  1) BUG : The dob is 01-01-1970 by default, I think we should be able not to specify it.
                  SOLUTION : In webloginpe.class.php, approx the line 1773, find this code
                  $modx->setPlaceholder('user.'.$key, strftime('%m-%d-%Y', $value));
                  

                  and replace it with
                  // CREDIT : Guillaume for not format an empty date
                  $value==0?'':$modx->setPlaceholder('user.'.$key, strftime('%m-%d-%Y', $value));
                  


                  2)BUG : When you want delete data from your profile you can’t : it is impossible to leave blank a field which was not empty.
                  SOLUTION : In webloginpe.class.php, in SaveUserProfile(), approx the line 880, replace the following code
                  		foreach ($generalElementsArray as $id => $field)
                  		{
                  			if ($field == 'photo')
                  			{
                  				if ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))
                  				{
                  					$_POST['photo'] = $this->CreateUserImage();
                  					if (!empty($this->Report))
                  					{
                  						return;
                  					}
                  				}
                  			}
                  			if (isset($_POST[$field]) && ($_POST[$field] !== ''))
                  			{
                  				if ($field == 'dob')
                  				{
                  					$_POST['dob'] = $this->MakeDateForDb($_POST['dob']);
                  				}
                  				// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                  				$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES)))."'";
                  			}
                  			else
                  			{
                  				unset ($generalElementsArray[$id]);
                  			}
                  		}
                  

                  and replace it with
                  		// CREDIT: Guillaume to delete data and for code optimisation
                  		foreach ($generalElementsArray as $field)
                  		{
                  			if ($field == 'photo')
                  			{
                  				if ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))
                  				{
                  					$_POST['photo'] = $this->CreateUserImage();
                  					if (!empty($this->Report))
                  					{
                  						return;
                  					}
                  				}
                  			}
                  			if ($field == 'dob' && trim($_POST['dob'])!='') // for not format an empty date else date is 0 (01-01-1970)
                  			{
                  				$_POST['dob'] = $this->MakeDateForDb($_POST['dob']);
                  			}
                  			if ($field!='photo' || ($_FILES['photo']['name'] !== '' && !empty($_FILES['photo']['name']))) // for update db with value and blank value (except if the field is 'photo')
                  			// CREDIT: Mike Reid (aka Pixelchutes) for the string escape code.
                  			$generalElementsUpdate[] = " `".$field."` = '".$modx->db->escape(stripslashes(htmlentities(trim($_POST[$field]), ENT_QUOTES)))."'";
                  		}
                  
                    Sorry for my english. I&#39;m french... My dictionary is near me, but it&#39;s only a dictionary !
                    • 26435
                    • 1,193 Posts
                    Awesome!
                    Thanks for posting those solutions.

                    -sD-
                    Dr. Scotty Delicious, DFPA.
                      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                      All of the above... in no specific order.


                      I send pointless little messages
                      • 7455
                      • 2,204 Posts
                      @Scotty:

                      any new versions? I am moving to a new server with alll my sites now it runs php 5 so I hope that this wil help.

                      Dimmy
                        follow me on twitter: @dimmy01