EzPortal - Portal Software for Forums

EzPortal - Made to Fit Your SMF Forum - Glad You Found Us!
+- +-

UserBox

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Recent Posts

New built in translations for six langauges! by EzPortal
March 26, 2024, 11:15:32 pm

Smiley missing in shoutbox 2.1.4 by hustreamload
July 26, 2023, 08:14:02 am

Re: Theme Select Box question? by Shades
March 15, 2023, 06:49:49 pm

Re: Theme Select Box question? by Shades
March 09, 2023, 02:09:24 pm

Re: Theme Select Box question? by Shades
March 09, 2023, 01:55:53 pm

Re: Theme Select Box question? by EzPortal
March 09, 2023, 01:47:42 pm

Re: Theme Select Box question? by Shades
March 09, 2023, 01:34:07 pm

Re: Theme Select Box question? by EzPortal
March 09, 2023, 12:20:17 pm

+- HTML Menu


Sample HTML Block Usage - You May Custom Code it, as needed!

Recent Topics ezBlock

New built in translations for six langauges! by EzPortal
March 26, 2024, 11:15:32 pm

Smiley missing in shoutbox 2.1.4 by hustreamload
July 26, 2023, 08:14:02 am

Theme Select Box question? by Shades
March 15, 2023, 06:49:49 pm

Where is the facebook button color? by EzPortal
February 28, 2023, 06:45:09 pm

Display on Mobile - SMF 2.1.3 and EZ 5.5.2 by BugginIn
December 29, 2022, 04:07:13 pm

Blocks Help by Riggs1973
November 20, 2022, 12:59:30 pm

Surface ol lite theme release Free! by Steffen K.
November 18, 2022, 03:57:24 am

Undefined index: href by EzPortal
October 04, 2022, 08:49:59 pm

SMF-ezportal_column_5.cache): failed to open stream: No such file or directory by EzPortal
June 04, 2022, 11:40:13 am

Arcade block error: failed to open stream: No such file or directory by Shades
May 20, 2022, 02:47:13 pm

Author Topic: How insert Php code in Php block  (Read 5427 times)

0 Members and 1 Guest are viewing this topic.

Offline fotografo74

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
How insert Php code in Php block
« on: March 16, 2015, 02:30:23 am »
Hi,
i have problems with this Mod : http://custom.simplemachines.org/mods/index.php?mod=3334
When i insert the Php code on Php block, to show Newsletter form, i have " ezBlock unable to run PHP syntax error!" message in block
Is there special way to insert php code in php block?
Thanks

PS This is the code inserted in Php block

Code: [Select]
global $modSettings, $txt, $scripturl, $context;

// make sure newletter is installed and enabled
if (!empty($modSettings['newsltr_news']) OR !empty($modSettings['newsltr_events']) OR !empty($modSettings['newsltr_topic_count']))
{
$context['user']['newsltr'] = array('next_ltr_date'=>'', 'period'=>'', 'email'=>'',);
if (!$context['user']['is_guest'])
{
global $smcFunc;
$result = $smcFunc['db_query']('', '
SELECT email, next_ltr_date, period
FROM smf_hcb_newsletter
WHERE email = \'' . $context['user']['email'] . '\'
LIMIT 1'
);

if ($row = $smcFunc['db_fetch_assoc']($result))
$context['user']['newsltr'] = $row;
$smcFunc['db_free_result']($result);
}

echo '
<div class="smalltext">
<form action="',$scripturl,'?action=NewsSubscribe" method="post" accept-charset="',$context['character_set'],'" name="newsSubscriber">
<input type="hidden" name="sc" value="', $context['session_id'], '" />
<input type="hidden" name="lastaction" value="forum" />' . $context['forum_name'] . ' ' . $txt['newsubscribe_mod_title'];

if ($context['user']['is_guest'])
echo $txt['newsubscribe_mod_email'] . '<input type="text" clasa="input_text" maxlength="255" size="25" value="' . $context['user']['newsltr']['email'] . '" name="email" />';
else
echo '
<input type="hidden" name="email" value="', $context['user']['email'], '" />';
if ($context['user']['is_guest'] OR empty($context['user']['newsltr']['email']))
echo '
<input type="submit" class="button_submit" name="subscribe" value="' . $txt['newsubscribe_mod_subscribe'] .'"/>
<br /><Input type="radio" name ="period" value="7"' . (($context['user']['newsltr']['period'] == 7) ? ' checked' :'')  . '>' .
$txt['newsubscribe_mod_week'] . '
<br /><Input type="radio" name ="period" value="14"' . (($context['user']['newsltr']['period'] == 14) ? ' checked' :'')  . '>' .
$txt['newsubscribe_mod_fort'] . '
<br /><Input type="radio" name ="period" value="30"' . ((empty($context['user']['newsltr']['period']) OR $context['user']['newsltr']['period'] == 30) ? ' checked' : '')  . '>' . $txt['newsubscribe_mod_month'];
if ($context['user']['is_guest'] OR !empty($context['user']['newsltr']['email']))
echo ($context['user']['is_guest'] ? '<br />' : $txt['newsubscribe_mod_next'] . date(' j F', $context['user']['newsltr']['next_ltr_date'])) . '<input type="submit" class="button_submit" name="unsubscribe"  value="' . $txt['newsubscribe_mod_unsubscribe'] .'"/>';
echo '
</form>
</div>';


Offline EzPortal

  • Administrator
  • *****
  • Posts: 1299
  • Karma: 67
Re: How insert Php code in Php block
« Reply #1 on: March 16, 2015, 07:01:05 am »
Try this instead
Code: [Select]
global $modSettings, $txt, $scripturl, $context;

// make sure newletter is installed and enabled
if (!empty($modSettings['newsltr_news']) OR !empty($modSettings['newsltr_events']) OR !empty($modSettings['newsltr_topic_count']))
{
$context['user']['newsltr'] = array('next_ltr_date'=>'', 'period'=>'', 'email'=>'',);
if (!$context['user']['is_guest'])
{
global $smcFunc;
$result = $smcFunc['db_query']('', '
SELECT email, next_ltr_date, period
FROM smf_hcb_newsletter
WHERE email = \'' . $context['user']['email'] . '\'
LIMIT 1'
);

if ($row = $smcFunc['db_fetch_assoc']($result))
$context['user']['newsltr'] = $row;
$smcFunc['db_free_result']($result);
}

echo '
<div class="smalltext">
<form action="',$scripturl,'?action=NewsSubscribe" method="post" accept-charset="',$context['character_set'],'" name="newsSubscriber">
<input type="hidden" name="sc" value="', $context['session_id'], '" />
<input type="hidden" name="lastaction" value="forum" />' . $context['forum_name'] . ' ' . $txt['newsubscribe_mod_title'];

if ($context['user']['is_guest'])
echo $txt['newsubscribe_mod_email'] . '<input type="text" clasa="input_text" maxlength="255" size="25" value="' . $context['user']['newsltr']['email'] . '" name="email" />';
else
echo '
<input type="hidden" name="email" value="', $context['user']['email'], '" />';
if ($context['user']['is_guest'] OR empty($context['user']['newsltr']['email']))
echo '
<input type="submit" class="button_submit" name="subscribe" value="' . $txt['newsubscribe_mod_subscribe'] .'"/>
<br /><Input type="radio" name ="period" value="7"' . (($context['user']['newsltr']['period'] == 7) ? ' checked' :'')  . '>' .
$txt['newsubscribe_mod_week'] . '
<br /><Input type="radio" name ="period" value="14"' . (($context['user']['newsltr']['period'] == 14) ? ' checked' :'')  . '>' .
$txt['newsubscribe_mod_fort'] . '
<br /><Input type="radio" name ="period" value="30"' . ((empty($context['user']['newsltr']['period']) OR $context['user']['newsltr']['period'] == 30) ? ' checked' : '')  . '>' . $txt['newsubscribe_mod_month'];
if ($context['user']['is_guest'] OR !empty($context['user']['newsltr']['email']))
echo ($context['user']['is_guest'] ? '<br />' : $txt['newsubscribe_mod_next'] . date(' j F', $context['user']['newsltr']['next_ltr_date'])) . '<input type="submit" class="button_submit" name="unsubscribe"  value="' . $txt['newsubscribe_mod_unsubscribe'] .'"/>';
echo '
</form>
</div>';

}
Like ezPortal? Support me at https://www.patreon.com/vbgamer45/

Offline fotografo74

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: How insert Php code in Php block
« Reply #2 on: March 16, 2015, 08:45:12 am »
Thanks, but i have the same error :(

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
9451 Views
Last post February 17, 2010, 02:47:00 pm
by EzPortal
0 Replies
4960 Views
Last post August 20, 2010, 04:01:03 am
by JoeMumme
1 Replies
8022 Views
Last post December 11, 2010, 07:21:34 am
by Guardian
2 Replies
5029 Views
Last post March 20, 2012, 02:24:00 pm
by NETSHAQ
2 Replies
5171 Views
Last post May 19, 2014, 04:23:15 pm
by gregm784

+-SMF Gallery

Quick Menu


Powered by EzPortal