<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[SMF] sintassi php]]></title><description><![CDATA[<p dir="auto">Parse error: syntax error, unexpected T_IF, expecting ')' in /<em><strong>/</strong></em>*/Sources/ManagePosts.php on line 279</p>
<pre><code>			// Update the actual settings.
	updateSettings(array(
		'removeNestedQuotes' =&gt; empty($_POST['removeNestedQuotes']) ? '0' : '1',
		//*The boards for post_prefix
</code></pre>
<p dir="auto"><strong>if (in_array(0, $_POST['post_prefix_boards']))</strong><br />
$_POST['post_prefix_boards'] = 0;<br />
else<br />
$_POST['post_prefix_boards'] = implode(',', $_POST['post_prefix_boards']);</p>
<pre><code>	// Fix UTF-8 stuff.
	$_POST['post_prefix'] = preg_replace('~&amp;amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&amp;#$1;', $_POST['post_prefix']);
	$_POST['post_prefix'] = preg_replace('~&amp;(#\d*)?$~', '', $_POST['post_prefix']);
</code></pre>
<p dir="auto">quella evidenzionata e la 279 l'errore dice che c'è qualche errore di parentesi come risolvo?</p>
]]></description><link>https://dev.connect.gt/topic/178982/smf-sintassi-php</link><generator>RSS for Node</generator><lastBuildDate>Wed, 25 Nov 2026 10:31:04 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/178982.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Oct 2012 08:30:18 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SMF] sintassi php on Wed, 24 Oct 2012 10:37:32 GMT]]></title><description><![CDATA[<p dir="auto">il file completo e questo</p>
<pre><code>&lt;?php

if (!defined('SMF'))
    die('Hacking attempt...');

/*    This file contains all the screens that control settings for topics and
    posts.

    void ManagePostSettings()
        - the main entrance point for the 'Posts and topics' screen.
        - accessed from ?action=postsettings.
        - calls the right function based on the given sub-action.
        - defaults to sub-action 'posts'.
        - requires (and checks for) the admin_forum permission.

    void SetCensor()
        - shows an interface to set and test word censoring.
        - requires the moderate_forum permission.
        - uses the Admin template and the edit_censored sub template.
        - tests the censored word if one was posted.
        - uses the censor_vulgar, censor_proper, censorWholeWord, and
          censorIgnoreCase settings.
        - accessed from ?action=postsettings;sa=censor.

    void ModifyPostSettings()
        - set any setting related to posts and posting.
        - requires the admin_forum permission
        - uses the edit_post_settings sub template of the Admin template.
        - accessed from ?action=postsettings;sa=posts.

    void ModifyBBCSettings()
        - set a few Bulletin Board Code settings.
        - requires the admin_forum permission
        - uses the edit_bbc_settings sub template of the Admin template.
        - accessed from ?action=postsettings;sa=bbc.
        - loads a list of Bulletin Board Code tags to allow disabling tags.

    void ModifyTopicSettings()
        - set any setting related to topics.
        - requires the admin_forum permission
        - uses the edit_topic_settings sub template of the Admin template.
        - accessed from ?action=postsettings;sa=topics.
*/

function ManagePostSettings()
{
    global $context, $txt, $scripturl;

    // Boldify "Posts and Topics" on the admin bar.
    adminIndex('posts_and_topics');

    $subActions = array(
        'posts' =&gt; array('ModifyPostSettings', 'admin_forum'),
        'bbc' =&gt; array('ModifyBBCSettings', 'admin_forum'),
        'censor' =&gt; array('SetCensor', 'moderate_forum'),
        'topics' =&gt; array('ModifyTopicSettings', 'admin_forum'),
    );

    // Default the sub-action to 'view ban list'.
     $_REQUEST['sa'] = isset($_REQUEST['sa']) &amp;&amp;  isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] :  (allowedTo('admin_forum') ? 'posts' : 'censor');

    // Make sure you can do this.
    isAllowedTo($subActions[$_REQUEST['sa']][1]);

    $context['page_title'] = $txt['manageposts_title'];

    // Tabs for browsing the different ban functions.
    $context['admin_tabs'] = array(
        'title' =&gt; $txt['manageposts_title'],
        'help' =&gt; 'posts_and_topics',
        'description' =&gt; $txt['manageposts_description'],
        'tabs' =&gt; array()
    );
    if (allowedTo('admin_forum'))
    {
        $context['admin_tabs']['tabs'][] = array(
            'title' =&gt; $txt['manageposts_settings'],
            'description' =&gt; $txt['manageposts_settings_description'],
            'href' =&gt; $scripturl . '?action=postsettings;sa=posts',
            'is_selected' =&gt; $_REQUEST['sa'] == 'posts',
        );
        $context['admin_tabs']['tabs'][] = array(
            'title' =&gt; $txt['manageposts_bbc_settings'],
            'description' =&gt; $txt['manageposts_bbc_settings_description'],
            'href' =&gt; $scripturl . '?action=postsettings;sa=bbc',
            'is_selected' =&gt; $_REQUEST['sa'] == 'bbc',
        );
    }
    if (allowedTo('moderate_forum'))
        $context['admin_tabs']['tabs'][] = array(
            'title' =&gt; $txt[135],
            'description' =&gt; $txt[141],
            'href' =&gt; $scripturl . '?action=postsettings;sa=censor',
            'is_selected' =&gt; $_REQUEST['sa'] == 'censor',
            'is_last' =&gt; !allowedTo('admin_forum'),
        );
    if (allowedTo('admin_forum'))
        $context['admin_tabs']['tabs'][] = array(
            'title' =&gt; $txt['manageposts_topic_settings'],
            'description' =&gt; $txt['manageposts_topic_settings_description'],
            'href' =&gt; $scripturl . '?action=postsettings;sa=topics',
            'is_selected' =&gt; $_REQUEST['sa'] == 'topics',
            'is_last' =&gt; true,
        );

    // Call the right function for this sub-acton.
    $subActions[$_REQUEST['sa']][0]();
}

// Set the censored words.
function SetCensor()
{
    global $txt, $modSettings, $context;

    if (!empty($_POST['save_censor']))
    {
        // Make sure censoring is something they can do.
        checkSession();

        $censored_vulgar = array();
        $censored_proper = array();

        // Rip it apart, then split it into two arrays.
        if (isset($_POST['censortext']))
        {
            $_POST['censortext'] = explode("\n", strtr($_POST['censortext'], array("\r" =&gt; '')));

            foreach ($_POST['censortext'] as $c)
                list ($censored_vulgar[], $censored_proper[]) = array_pad(explode('=', trim($c)), 2, '');
        }
        elseif (isset($_POST['censor_vulgar'], $_POST['censor_proper']))
        {
            if (is_array($_POST['censor_vulgar']))
            {
                foreach ($_POST['censor_vulgar'] as $i =&gt; $value)
                    if ($value == '')
                    {
                        unset($_POST['censor_vulgar'][$i]);
                        unset($_POST['censor_proper'][$i]);
                    }

                $censored_vulgar = $_POST['censor_vulgar'];
                $censored_proper = $_POST['censor_proper'];
            }
            else
            {
                $censored_vulgar = explode("\n", strtr($_POST['censor_vulgar'], array("\r" =&gt; '')));
                $censored_proper = explode("\n", strtr($_POST['censor_proper'], array("\r" =&gt; '')));
            }
        }

        // Set the new arrays and settings in the database.
        $updates = array(
            'censor_vulgar' =&gt; implode("\n", $censored_vulgar),
            'censor_proper' =&gt; implode("\n", $censored_proper),
            'censorWholeWord' =&gt; empty($_POST['censorWholeWord']) ? '0' : '1',
            'censorIgnoreCase' =&gt; empty($_POST['censorIgnoreCase']) ? '0' : '1',
        );

        updateSettings($updates);
    }

    if (isset($_POST['censortest']))
    {
        $censorText = htmlspecialchars(stripslashes($_POST['censortest']), ENT_QUOTES);
        $context['censor_test'] = strtr(censorText($censorText), array('"' =&gt; '&amp;quot;'));
    }

    // Set everything up for the template to do its thang.
    $censor_vulgar = explode("\n", $modSettings['censor_vulgar']);
    $censor_proper = explode("\n", $modSettings['censor_proper']);

    $context['censored_words'] = array();
    for ($i = 0, $n = count($censor_vulgar); $i &lt; $n; $i++)
    {
        if (empty($censor_vulgar[$i]))
            continue;

        // Skip it, it's either spaces or stars only.
        if (trim(strtr($censor_vulgar[$i], '*', ' ')) == '')
            continue;

          $context['censored_words'][htmlspecialchars(trim($censor_vulgar[$i]))] =  isset($censor_proper[$i]) ? htmlspecialchars($censor_proper[$i]) : '';
    }

    $context['sub_template'] = 'edit_censored';
    $context['page_title'] = $txt[135];
}

// Modify all settings related to posts and posting.
function ModifyPostSettings()
{
    global $context, $txt, $db_prefix, $modSettings;

    // Setup the template.
    $context['sub_template'] = 'edit_post_settings';
    //Load the jump to data.
    loadJumpTo();
    $context['page_title'] = $txt['manageposts_settings'];

    // Saving?
    if (isset($_POST['save_settings']))
    {
        checkSession();

        // Let's find out if they want things way too long...
        if (!empty($_POST['max_messageLength']) &amp;&amp; $_POST['max_messageLength'] != $modSettings['max_messageLength'])
        {
            $request = db_query("
                SHOW COLUMNS
                FROM {$db_prefix}messages", false, false);
            if ($request !== false)
            {
                while ($row = mysql_fetch_assoc($request))
                    if ($row['Field'] == 'body')
                        $body_type = $row['Type'];
                mysql_free_result($request);
            }

            $request = db_query("
                SHOW INDEX
                FROM {$db_prefix}messages", false, false);
            if ($request !== false)
            {
                while ($row = mysql_fetch_assoc($request))
                     if ($row['Column_name'] == 'body' &amp;&amp;  (isset($row['Index_type']) &amp;&amp; $row['Index_type'] == 'FULLTEXT'  || isset($row['Comment']) &amp;&amp; $row['Comment'] == 'FULLTEXT'))
                        $fulltext = true;
                mysql_free_result($request);
            }

            if (isset($body_type) &amp;&amp; $_POST['max_messageLength'] &gt; 65535 &amp;&amp; $body_type == 'text')
            {
                // !!! Show an error message?!
                // MySQL only likes fulltext indexes on text columns... for now?
                if (!empty($fulltext))
                    $_POST['max_messageLength'] = 65535;
                else
                {
                    // Make it longer so we can do their limit.
                    db_query("
                        ALTER TABLE {$db_prefix}messages
                        CHANGE COLUMN body body mediumtext", __FILE__, __LINE__);
                }
            }
            elseif (isset($body_type) &amp;&amp; $_POST['max_messageLength'] &lt;= 65535 &amp;&amp; $body_type != 'text')
            {
                // Shorten the column so we can have the benefit of fulltext searching again!
                db_query("
                    ALTER TABLE {$db_prefix}messages
                    CHANGE COLUMN body body text", __FILE__, __LINE__);
            }
        }

        // Update the actual settings.
        updateSettings(array('removeNestedQuotes' =&gt; empty($_POST['removeNestedQuotes']) ? '0' : '1'));
            // The boards for post_prefix
        if (in_array(0, $_POST['post_prefix_boards']))
            $_POST['post_prefix_boards'] = 0;
        else
            $_POST['post_prefix_boards'] = implode(',', $_POST['post_prefix_boards']);

        // Fix UTF-8 stuff.
         $_POST['post_prefix'] =  preg_replace('~&amp;amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~',  '&amp;#$1;', $_POST['post_prefix']);
        $_POST['post_prefix'] = preg_replace('~&amp;(#\d*)?$~', '', $_POST['post_prefix']);
            'enableEmbeddedFlash' =&gt; empty($_POST['enableEmbeddedFlash']) ? '0' : '1',
            'enableSpellChecking' =&gt; empty($_POST['enableSpellChecking']) ? '0' : '1',
            'max_messageLength' =&gt; empty($_POST['max_messageLength']) ? '0' : (int) $_POST['max_messageLength'],
            'fixLongWords' =&gt; empty($_POST['fixLongWords']) ? '0' : (int) $_POST['fixLongWords'],
            'topicSummaryPosts' =&gt; empty($_POST['topicSummaryPosts']) ? '0' : (int) $_POST['topicSummaryPosts'],
            'spamWaitTime' =&gt; empty($_POST['spamWaitTime']) ? '0' : (int) $_POST['spamWaitTime'],
            'edit_wait_time' =&gt; empty($_POST['edit_wait_time']) ? '0' : (int) $_POST['edit_wait_time'],
            'post_prefix' =&gt; htmlspecialchars($_POST['post_prefix'], ENT_QUOTES),
            'post_prefix_boards' =&gt; $_POST['post_prefix_boards'],
            'edit_disable_time' =&gt; empty($_POST['edit_disable_time']) ? '0' : (int) $_POST['edit_disable_time'],
        ));
    }

    // Check if your PHP is able to use spell checking.
    // Explode post_prefix boards
    if (!empty($modSettings['post_prefix_boards']) &amp;&amp; $modSettings['post_prefix_boards'] != '0')
    $modSettings['post_prefix_boards'] = explode(',', $modSettings['post_prefix_boards']);
    $context['spellcheck_installed'] = function_exists('pspell_new');
}

// Bulletin Board Code...a lot of Bulletin Board Code.
function ModifyBBCSettings()
{
    global $context, $txt, $modSettings, $helptxt;

    // Setup the template.
    $context['sub_template'] = 'edit_bbc_settings';
    $context['page_title'] = $txt['manageposts_bbc_settings_title'];

    // Ask parse_bbc() for its bbc code list.
    $temp = parse_bbc(false);
    $bbcTags = array();
    foreach ($temp as $tag)
        $bbcTags[] = $tag['tag'];

    $bbcTags = array_unique($bbcTags);
    $totalTags = count($bbcTags);

    // The number of columns we want to show the BBC tags in.
    $numColumns = 3;

    // In case we're saving.
    if (isset($_POST['save_settings']))
    {
        checkSession();

        if (!isset($_POST['enabledTags']))
            $_POST['enabledTags'] = array();
        elseif (!is_array($_POST['enabledTags']))
            $_POST['enabledTags'] = array($_POST['enabledTags']);

        // Update the actual settings.
        updateSettings(array(
            'enableBBC' =&gt; empty($_POST['enableBBC']) ? '0' : '1',
            'enablePostHTML' =&gt; empty($_POST['enablePostHTML']) ? '0' : '1',
            'autoLinkUrls'  =&gt; empty($_POST['autoLinkUrls']) ? '0' : '1',
            'disabledBBC' =&gt; implode(',', array_diff($bbcTags, $_POST['enabledTags'])),
        ));
    }

    $context['bbc_columns'] = array();
    $tagsPerColumn = ceil($totalTags / $numColumns);
    $disabledTags = empty($modSettings['disabledBBC']) ? array() : explode(',', $modSettings['disabledBBC']);

    $col = 0;
    $i = 0;
    foreach ($bbcTags as $tag)
    {
        if ($i % $tagsPerColumn == 0 &amp;&amp; $i != 0)
            $col++;

        $context['bbc_columns'][$col][] = array(
            'tag' =&gt; $tag,
            'is_enabled' =&gt; !in_array($tag, $disabledTags),
            // !!! 'tag_' . ?
            'show_help' =&gt; isset($helptxt[$tag]),
        );

        $i++;
    }

    $context['bbc_all_selected'] = empty($disabledTags);
}

// Function for modifying topic settings. Not very exciting.
function ModifyTopicSettings()
{
    global $context, $txt, $modSettings;

    // Setup the template.
    $context['sub_template'] = 'edit_topic_settings';
    $context['page_title'] = $txt['manageposts_topic_settings'];

    // Wanna save this page?
    if (isset($_POST['save_settings']))
    {
        checkSession();

        // Update the actual settings.
        updateSettings(array(
            'enableStickyTopics' =&gt; empty($_POST['enableStickyTopics']) ? '0' : '1',
            'enableParticipation' =&gt; empty($_POST['enableParticipation']) ? '0' : '1',
            'oldTopicDays' =&gt; empty($_POST['oldTopicDays']) ? '0' : (int) $_POST['oldTopicDays'],
            'defaultMaxTopics' =&gt; empty($_POST['defaultMaxTopics']) ? '0' : (int) $_POST['defaultMaxTopics'],
            'defaultMaxMessages' =&gt; empty($_POST['defaultMaxMessages']) ? '0' : (int) $_POST['defaultMaxMessages'],
            'hotTopicPosts' =&gt; empty($_POST['hotTopicPosts']) ? '0' : (int) $_POST['hotTopicPosts'],
            'hotTopicVeryPosts' =&gt; empty($_POST['hotTopicVeryPosts']) ? '0' : (int) $_POST['hotTopicVeryPosts'],
            'enableAllMessages' =&gt; empty($_POST['enableAllMessages']) ? '0' : (int) $_POST['enableAllMessages'],
            'enablePreviousNext' =&gt; empty($_POST['enablePreviousNext']) ? '0' : '1',
        ));
    }
}

?&gt;
</code></pre>
<p dir="auto">ora mi dice questo:<br />
<strong>Parse error</strong>:  syntax error, unexpected T_DOUBLE_ARROW in <strong>/</strong><em>/</em>***/Sources/ManagePosts.php** on line <strong>286</strong></p>
]]></description><link>https://dev.connect.gt/post/1092752</link><guid isPermaLink="true">https://dev.connect.gt/post/1092752</guid><dc:creator><![CDATA[cooly]]></dc:creator><pubDate>Wed, 24 Oct 2012 10:37:32 GMT</pubDate></item></channel></rss>