News:

Wondering if this will always be free?  See why free is better.

Main Menu

SMF Links

Started by SMFHacks.com Team, July 12, 2006, 12:33:28 AM

Previous topic - Next topic

mickjav

Added a final Edit which I sort of borrowed from the Galleries stats  ;D

Added info here: https://www.databasedreams.co.uk/support/index.php?action=showcases;sa=view;id=61


the Librarian is on Its way, due late 25 - early 2026

mickjav

Been working on my links and noticed what may be an error

In both EditLink & EditLink2 links you have a call to is_not_guest, but this may allow a member who has been demoted to edit their links even if their group does not allow it.


the Librarian is on Its way, due late 25 - early 2026

vbgamer45

 is_not_guest() only stops guests from editing any link. since that membergroup you can't check who owns what link.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mickjav

Quote from: vbgamer45 on June 02, 2024, 11:48:20 PMis_not_guest() only stops guests from editing any link. since that membergroup you can't check who owns what link.

I didn't see the code below
if (!allowedTo('edit_links_any') && (!allowedTo('edit_links_own') || $row['ID_MEMBER'] != $user_info['id']))


the Librarian is on Its way, due late 25 - early 2026

vbgamer45

yeah so that check is checking if the user doesn't have permission to edit any link, or if they can't edit their own links, and last if the member doesn't own the link if they have edit own link permission
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mickjav

This will allow you to add a domain to the table below, which, if used, will pop up a message

Add table:
{db_prefix}links_disallowed_domains
Field: domain, varchar(50), primary


Add To "Links.english"
$txt['smflinks_domain_not_allowed'] = 'This domain is not allowed!!';
Code (Find) Select
fatal_error($txt['smflinks_err_linkmuststart'],false);
Code (Add below) Select
$link_domain = GetDomain($url);

$domain_query = $smcFunc['db_query']('', '
SELECT domain
FROM {db_prefix}links_disallowed_domains
WHERE domain = {string:this_domain}',
[
'this_domain' => $link_domain
]
);

if ($smcFunc['db_affected_rows']() != 0)
fatal_error($txt['smflinks_domain_not_allowed'], false);

Add Function "Note I got function from net"
function GetDomain($url)
{
  $pieces = parse_url($url);
  $domain = isset($pieces['host']) ? $pieces['host'] : $pieces['path'];
  if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $regs)) {
    return $regs['domain'];
  }
  return false;
}


the Librarian is on Its way, due late 25 - early 2026

mickjav

Just putting final touches to a new section I'm adding to my links mod

This uses code borrowed from Gallery mod for uploading files and copying text field

Should anybody be interested in a copy, let me know.



the Librarian is on Its way, due late 25 - early 2026

mickjav

Hi @vbgamer45

Been looks for the modsettings, I've found the edit functions and template but can't seem to find the defaults are set or initially loaded from.

I am adding a new page to admin section, so want to be able to load these settings with all others.

I'm prob being blind again, lol

PS, I'm using 4.1


the Librarian is on Its way, due late 25 - early 2026

mickjav

Just thought I should check the sql files as prob added there, have to wait till morning lol


the Librarian is on Its way, due late 25 - early 2026

vbgamer45

Yeah would be in the install script is where they are setup.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mickjav

Further to my post https://www.simplemachines.org/community/index.php?msg=4175623

This will also allow members to add links from the menu.

This may also help with the Online Safety Act 2025 as it allows you to prevent links being add like

bitly.com
shorturl.at
t.ly
tinyurl.com
If these domains are used they could point anyware and I'm sure there are more


Code ("add to Modifications.english") Select
$txt['smflinks_icon_add_menu'] = 'Add link';
$txt['smflinks_icon_add_disallowed_domains'] = 'Add Disallowed Domains';

Code ("Add To Links.english") Select
$txt['smflinks_icon_domain'] = 'Add Domain';
$txt['smflinks_icon_domain_error'] = 'The Domain you are trying to add has already been added!!';
$txt['smflinks_domain_title'] = 'Adding New Domain';

Code ("Add To LinksHooks below 'show' => allowedTo('view_smflinks')") Select
'sub_buttons' => array(
                    'viewlinks' => array(
                        'title' => $txt['smflinks_menu_view'],
                        'href' => $scripturl . '?action=links',
                        'show' => allowedTo('view_smflinks'),
                            ),
                    'addlink' => array(
                        'title' => $txt['smflinks_icon_add_menu'],
                        'href' => $scripturl . '?action=links;sa=addlink',
                        'show' => allowedTo('add_links'),
                            ),
                    'adddisdomin' => array(
                        'title' => $txt['smflinks_icon_add_disallowed_domains'],
                        'href' => $scripturl . '?action=links;sa=disdominadd',
                        'show' => allowedTo('links_manage_cat'),
                            ),

                ),                                ),

Code ("Add To Links2.1.template") Select
function template_add_disallowed_domain()
{
    global $scripturl, $txt, $context, $sourcedir;
   
 
    echo'<div class="cat_bar">

            <h3 class="catbg">'.$txt['smflinks_domain_title'].'</h3>

        </div>

        <div id="advanced_search" class="roundframe">

        <form method="post" enctype="multipart/form-data" name="addicon" id="reciprocal" action="' . $scripturl . '?action=links;sa=adddisdomin" onsubmit="submitonce(this);">

            <dl id="search_options" class="settings">
               
                <dt>
                    <strong>',$txt['smflinks_icon_domain'],':</strong>
                </dt>
                <dd>
                    <input type="text" size="50" name="domain" value=""  maxlength="60"/>
                </dd>

            </dl>';

                echo'<br /><div style="text-align: right;">

                <input type="submit" name="send" class="button" value="'. $txt['smflinks_icon_domain'] . '" /></div>

        </form></div>

        <span class="lowerframe"></span>';
       
}

Code ("Add To links2 at bottom on subactions") Select
        'disdominadd' => 'ShowAddDisallowedDomains',
        'adddisdomin' => 'DoAddDisallowedDomains',

Code ("Add To Bottom of Links2") Select
    function ShowAddDisallowedDomains()
{
    global $context, $txt, $smcFunc, $scripturl, $modSettings;

    isAllowedTo('links_manage_cat');           
   
        // Setup Intial Link Tree
    $context['linktree'][] = array(
        'url' => $scripturl . '?action=links',
        'name' => $txt['smflinks_menu']
    );
        // Load the main index links template
    $context['sub_template']  = 'add_disallowed_domain';
}

    function DoAddDisallowedDomains()
{
    global $context, $txt, $smcFunc, $scripturl;
       
    isAllowedTo('links_manage_cat');
                   
    if (empty($_REQUEST['domain']))
        fatal_error($txt['smflinks_icon_no_domain_error'], false);
   
    $domain = $smcFunc['htmlspecialchars']($_REQUEST['domain'],ENT_QUOTES);
   
    //Check The Domin Hasent been added
        $dbquery = $smcFunc['db_query']('', '
        SELECT domain
            FROM {db_prefix}links_disallowed_domains
        WHERE domain = {string:this_domin}',
            [
            'this_domin' => (string) $domain
            ]
        );
       
        if ($smcFunc['db_num_rows']($dbquery) != 0)
            fatal_error($txt['smflinks_icon_domain_error'], false);
       
        $smcFunc['db_free_result']($dbquery);

    //Now Add The Record to table
        $smcFunc['db_insert']('insert',
            '{db_prefix}links_disallowed_domains',
                [   
                    'domain' => 'string'
                ],
                [
                    (string) $domain
                ],
            []
        );
   
    redirectexit('action=links');
}


the Librarian is on Its way, due late 25 - early 2026

vbgamer45

Good stuff we need the links_disallowed_domains table structure though.
Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mickjav

Quote from: vbgamer45 on December 26, 2024, 10:37:44 AMGood stuff we need the links_disallowed_domains table structure though.

It's in the original post https://www.simplemachines.org/community/index.php?msg=4175623


the Librarian is on Its way, due late 25 - early 2026

vbgamer45

Community Suite for SMF - Grow your forum with SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com - Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

mickjav

I forgot to do the Edit link so if you have already added the code from the original post.

https://www.simplemachines.org/community/index.php?msg=4175623



Code ( Find in function EditLink2()) Select
if (empty($catid))
fatal_error($txt['smflinks_nocatselected'],false);

Code (Add Below) Select
$link_domain = GetDomain($url);

$domain_query = $smcFunc['db_query']('', '
SELECT domain
FROM {db_prefix}links_disallowed_domains
WHERE domain = {string:this_domain}',
[
'this_domain' => $link_domain
]
);

if ($smcFunc['db_affected_rows']() != 0)
fatal_error($txt['smflinks_domain_not_allowed'], false);

You need this to prevent users from editing a link so it uses a disallowed domain.

mick

PS I will add the whole lot to my code library should anybody need it all in one place


the Librarian is on Its way, due late 25 - early 2026

mickjav



the Librarian is on Its way, due late 25 - early 2026

mickjav

I have tested this on my the librian forum which has a clean version of SMF links but should you have ay problems let me know.

My version is here https://www.databasedreams.co.uk/charts/links/?sa=reciprocal

https://www.databasedreams.co.uk/support/index.php?action=showcases;sa=view;id=66


the Librarian is on Its way, due late 25 - early 2026

Advertisement: