Dream Portal is a portal system designed to function with Simple Machines Forum (aka SMF).

It allows you to easily manage your site and webpages in an SMF environment. Place Modules on different actions and non-actions of your SMF forum using a simple drag-and-drop approach. Users can also create and save multiple layouts by name and assign pages to any layout(s). Bundled with Dream Pages and Dream Menu helps put the power and ease of customizing your SMF forum right at your fingertips.

Dream Portal allows you the ability to easily customize your SMF forum and site with many different possibilities helping to make customization truly what dreams are made of!

DreamPortal1.0.5.zip
File size: 221KB
Download count: 1272
DreamPortal1.0.5.tar.gz
File size: 176KB
Download count: 141
Download

There's a New Sheriff in Town and his name...
Last Poster: SoLoGHoST in Announcements | Yesterday at 09:35:42 PM

Re: DP works with SMF 2.0.1?
Last Poster: pixeleyes in English Support | February 21, 2012, 10:28:40 AM

Re: DP works with SMF 2.0.1?
Last Poster: Xarcell in English Support | February 21, 2012, 09:50:52 AM

DP works with SMF 2.0.1?
Last Poster: pixeleyes in English Support | February 21, 2012, 07:27:35 AM

Re: Reset Impression Count
Last Poster: SoLoGHoST in Modules | February 17, 2012, 06:27:57 AM

Author Topic: PHP Params Question  (Read 622 times)

0 Members and 1 Guest are viewing this topic.

Xarcell

  • Project Manager
  • Dreamist
  • *
  • Posts: 753
  • Dreamy
    • View Profile
PHP Params Question
« on: December 23, 2011, 10:48:43 PM »
I'm having a problem. Maybe you can help me resolve this. If I use:

Code: [Select]
   if ($today < strtotime(''.$params['year'].'-'.$params['month'].'-'.$params['day'].'')){
 
      echo 'not time';
   }
   
   else{
   echo 'it\'s time';
   }

It works. However, if I add the parameters like so, it no longer works.

Code: [Select]
$today = strtotime(date("Y-m-d"));
   
   if ($today < strtotime('' . $params['year'] . '-' . $params['month'] . '-' . $params['day'] . '')){
      echo 'Not time yet';
   }
   
   else{
      echo 'it\'s here!';
   }

WTF?
#1
*
SoLoGHoST
  • Dreamist
  • Posts: 1878
Re: PHP Params Question - January 03, 2012, 04:38:13 AM
Try:  $today = strtotime(date("Y-n-j"));

n = numeric month without leading 0's
j = numeric day without leading 0's

PHP Date Function

Not really sure how you are defining $today in your first example though.

Honestly, this should work fine also:

Code: [Select]
if ($today < strtotime($params['year'] . '-' . $params['month'] . '-' . $params['day']))
Last Edit: January 03, 2012, 04:50:58 AM by SoLoGHoST

#2
*
Xarcell
  • Dreamist
  • Posts: 753
Re: PHP Params Question - January 04, 2012, 03:12:51 PM
Ok, I tried that, it seems to work better. I'm still having a problem though. I'm making a Ad-Space mod, nothing fancy. The admin can upload the ad he wants to use, or it automatically the default image. You can even upload your own default image. Everything works except for one thing. When I upload my Ad image, it doesn't save. The page reloads as if nothing happens. If I upload a default image, it works fine. However, the Ad image uploaded doesn't save.

Can you see any reason why this happens?

In script.php
Code: [Select]
function module_adspace($params)
{
global $context, $settings, $txt;

$today = strtotime(date("Y-m-d"));
   
   if ($today < strtotime($params['year'] . '-' . $params['month'] . '-' . $params['day'] && !empty($params['imgad']))){
   
      echo '<a href="'.$params['linkad'].'" target="_blank"><img src="'.$params['imgad'][0]['href'].'" width="'.$params['width'].'" height="'.$params['height'].'" title="'.$params['titlead'].'" alt="'.$params['altad'].'" /></a>';
   }
   
   elseif (!empty($params['imgdef'])){
      echo '<a href="'.$params['linkdef'].'" target="_blank"><img src="'.$params['imgdef'][0]['href'].'" width="'.$params['width'].'" height="'.$params['height'].'" title="'.$params['titledef'].'" alt="'.$params['altdef'].'" /></a>';
   }
   
   else{
   echo '<img src="./Themes/default/dreamportal/modules/adspace/default.jpg" width="'.$params['width'].'" height="'.$params['height'].'" title="'.$params['titledef'].'" alt="'.$params['altdef'].'" />';
   }

In info.xml
Code: [Select]
<param  name="imgad" type="file_input">1:image/gif;image/png;image/jpeg</param>

Thanks.

#3
*
SoLoGHoST
  • Dreamist
  • Posts: 1878
Re: PHP Params Question - January 04, 2012, 05:51:33 PM
Well, I can see a problem just after looking at it for 2 seconds...

Code: [Select]
if ($today < strtotime($params['year'] . '-' . $params['month'] . '-' . $params['day'] && !empty($params['imgad']))){

Should be this instead:
Code: [Select]
if ($today < strtotime($params['year'] . '-' . $params['month'] . '-' . $params['day']) && !empty($params['imgad'])){

#4
*
Xarcell
  • Dreamist
  • Posts: 753
Re: PHP Params Question - January 04, 2012, 06:33:28 PM
I see the error you pointed out and corrected it. Although, it still didn't fix the problem of the file not saving in module admin after image upload for the ad. Thanks for helping debug this...

I don't think I will make anymore modules after this, because I hate coming to you for help so often.

EDIT: I have attached the whole package, in case it helps. I also attached a test image for the ad placement in case you need it. It is the same dimensions as the default ad.
Last Edit: January 04, 2012, 06:36:07 PM by Xarcell

#5
*
SoLoGHoST
  • Dreamist
  • Posts: 1878
Re: PHP Params Question - January 05, 2012, 11:47:18 PM
I don't mind you coming to me for help Xarcell.  And I apologize if I come across condescending at times, not my goal at all!  So, please ask as many questions as you like.  I'm just getting a bit frustrated trying to juggle a million different things going on in my life right now and than there's Dream Portal.  But I really don't want to discourage you from making modules.  It's actually 1 of the most positive things that I see about other people in my life right now.  The fact that you are trying to help out gives me hope that this world is not such a bad place afterall.

In any case, thanks for all of your contributions to DP 1.1 Xarcell.  Atleast for modules, you have totally outdone yourself!

P.S. - Still working on DP 1.1 Revision Release #10, so after this is Released, will take a quick peek at this module.  Bookmarking...

#6
*
Xarcell
  • Dreamist
  • Posts: 753
Re: PHP Params Question - February 06, 2012, 04:15:40 PM
I wanted to come back to this and ask if you've had a chance to look at it?

Thanks.

#7
*
SoLoGHoST
  • Dreamist
  • Posts: 1878
Re: PHP Params Question - February 07, 2012, 12:15:45 AM
So this is still a problem even in the newest DP Revision Release??  It should've been fixed in the newest DP Revision Release...

#8
*
SoLoGHoST
  • Dreamist
  • Posts: 1878
Re: PHP Params Question - February 07, 2012, 01:29:10 AM
Well, took me about 15 minutes to discover the problem with your code...

In info.xml, you defined this:
Code: [Select]
<param  name="month" type="select">0:0;1;2;3;4;5;6;7;8;9;10;11</param>

and this:

Code: [Select]
<param  name="day" type="select">0:0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;15;16;17;18;19;20;21;22;23;24;25;26;27;28;29;30</param>

And in the script.php file, you are calling these parameters directly when they are needed.

The problem, as you might see, is that both the month and the day are BEHIND 1.  You set January to 0, and December is set to 11, so this will return 0 for the month of January, instead of 1.  So every month will be behind a month when you call upon the parameters within the script.php file.  And you are doing the same thing for the days.  You can fix this in 2 ways.

Change your parameter definition in info.xml to start at 1 instead of 0 for info.xml... example for the month parameter definition...

Code: [Select]
<param  name="month" type="select">0:1;2;3;4;5;6;7;8;9;10;11;12</param>

And make sure to change the language files as well.  And do the same for the days, unless you want it to expire and not show on the expiration day, which I don't think you want, so you'll need to fix the day parameter definition as well.

That should fix your problem, because strtotime() is calculating a month and a day behind, currently, from what you have set in the Admin for this module.


 

  • • Users: 1
  • • Guests: 27

 Top 5 Posters

1878 Posts

1425 Posts

753 Posts

503 Posts

365 Posts
Welcome, Guest.
Please login or register.

 
 
 

Did you miss your activation email?

 Shoutbox

SHOUTBOX NOT FOR SUPPORT!

 Calendar

  • Su M Tu W Th F Sa
    1 2 3 4 5 6 7
    8 9 10 11 12 13 14
    15 16 17 18 19 20 21
    22 23 24 25 26 27 28
    29 30 31
  • Su M Tu W Th F Sa
    1 2 3 4
    5 6 7 8 9 10 11
    12 13 14 15 16 17 18
    19 20 21 22 23 24 25
    26 27 28 29
  • Su M Tu W Th F Sa
    1 2 3
    4 5 6 7 8 9 10
    11 12 13 14 15 16 17
    18 19 20 21 22 23 24
    25 26 27 28 29 30 31

No calendar events were found.