Author Topic: [MOD] SMF integration  (Read 137255 times)

0 Members and 1 Guest are viewing this topic.

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
[MOD] SMF integration
« on: September 07, 2008, 09:29:36 PM »
OK here we go...
This is a BETA mod that will allow you to log into 4images and automatically log you into the SMF forum.
The version of SMF that I am using is 1.1.5 (not sure if things are the same in other versions or not)
My site is laid out like this
root\gallery is my 4images gallery
root\forums is my smf forum
the 2 sets of files that you will need to install are from another programmer.
Not sure about the copyrights so I am just providing a link to get them
first file...
http://www.simplemachines.org/download/?tools
download the SMF 1.1.x API file and place smf_api.php file in the root of your smf forum (mine is root\forums)
second file...
http://vgb.org.ru/download
download the smf_api2.zip file and unzip it into the root of your smf forum also.

This is just to get everyone started, it does work on my site but some little things have cropped up but I thought if
some better programmers looked over these changes they may have a better way or an easier way to make all this happen.

now for the modified files (BACKUP! FIRST)
on the 4images side...
global.php
member.php
includes\functions.php
includes\sessions.php

on the SMF side...
The main modification on the smf side is to turn off the login,registar,and forgot password buttons anywhere in the user area. the password still works for the administration side of it.
I believe I also had to uncheck the(Show a quick login on every page) in the admin settings.
(BACKUP! FIRST)
sources\profiles.php
sources\themes.php
themes\default\index.template.php
themes\default\profile.template.php
themes\default\language\index.english.php
and based on whever other themes you have installed
mine would be...
themes\pinkblitz\boardindex.template.php
themes\pinkblitz\index.template.php

Now the changes...
Lets start on the 4images side...

in the global.php file

look for
Code: [Select]
$table_prefix = "4images_";
add after
Code: [Select]
// MOD SMF integration
$SMF_user_email = "TTtt";
//END MOD SMF

in the includes/Functions.php file

look for
Code: [Select]
function un_htmlspecialchars($text) {
  $text = str_replace(
    array('<', '>', '"', '&'),
    array('<',    '>',    '"',      '&'),
    $text
  );

  return $text;
}
replace with
Code: [Select]
//MOD SMF integration
if (!function_exists('un_htmlspecialchars')) {
function un_htmlspecialchars($chars) {
  //$chars = preg_replace("/(&#)([0-9]*)(;)/esiU", "chr(intval('\\2'))", $chars);
  $chars = str_replace("&gt;", ">", $chars);
  $chars = str_replace("&lt;", "<", $chars);
  $chars = str_replace("&quot;", "\"", $chars);
  $chars = str_replace("&amp;", "&", $chars);
  return $chars;
}
}
//function un_htmlspecialchars($text) {
//  $text = str_replace(
//    array('&lt;', '&gt;', '&quot;', '&amp;'),
//    array('<',    '>',    '"',      '&'),
//    $text
//  );

//  return $text;
//}
//END SMF

in the includes\sessions.php file

look for
Code: [Select]
//-----------------------------------------------------
//--- End Configuration -------------------------------
//-----------------------------------------------------
add after and look at comment in code
Code: [Select]
//MOD SMF integration
require(ROOT_PATH.'../../forums/smf_api_2.php'); //change paths to your forums directory
require(ROOT_PATH.'../../forums/smf_api.php');     //change paths to your forums directory
global $smf_settings, $smf_user_info;
//END MOD SMF

look for
Code: [Select]
    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_password")."
            FROM ".USERS_TABLE."
            WHERE ".get_user_table_field("", "user_name")." = '$user_name' AND ".get_user_table_field("", "user_level")." <> ".USER_AWAITING;
    $row = $site_db->query_firstrow($sql);
replace with
Code: [Select]
//MOD SMF integration
    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_password").get_user_table_field(", ", "user_name").get_user_table_field(", ", "user_email")."
            FROM ".USERS_TABLE."
            WHERE ".get_user_table_field("", "user_name")." = '$user_name' AND ".get_user_table_field("", "user_level")." <> ".USER_AWAITING;
    $row = $site_db->query_firstrow($sql);
//    $sql = "SELECT ".get_user_table_field("", "user_id").get_user_table_field(", ", "user_password")."
//            FROM ".USERS_TABLE."
//            WHERE ".get_user_table_field("", "user_name")." = '$user_name' AND ".get_user_table_field("", "user_level")." <> ".USER_AWAITING;
//    $row = $site_db->query_firstrow($sql);
$user_name = $row[2];
$user_email = $row[3];
$smf_user_password = $user_password;
//END SMF

look for
Code: [Select]
        $this->start_session($user_id, 1);
add after
Code: [Select]
// MOD SMF integration
if (!smf_api_get_user($user_name,$smf_user_password)){
smf_api_register($user_name, $smf_user_password, $user_email);
}
smf_api_login(7200, $user_name, $smf_user_password, false);
// END MOD SMF

look for
Code: [Select]
    $this->session_info = array();
add after
Code: [Select]
// MOD SMF integration
    smf_api_logout();
smf_sessionDestroy($user_id);
//END MOD SMF

in the member.php file

look for
Code: [Select]
    if ($checkuser = $site_db->query_firstrow($sql)) {
add after
Code: [Select]
//MOD SMF integration
  $smf_user_password = $checkuser[$user_table_fields['user_password']];
// END MOD SMF

look for
Code: [Select]
      $sql = "UPDATE ".USERS_TABLE."
              SET ".get_user_table_field("", "user_password")." = '".md5($user_password)."'
              WHERE ".get_user_table_field("", "user_id")." = ".$checkuser[$user_table_fields['user_id']];
      $site_db->query($sql);
add after
Code: [Select]
//MOD SMF integration
  $smf_user_name = $checkuser[$user_table_fields['user_name']];
  smf_api_get_user($smf_user_name,$smf_user_password);
  $smf_user_info['id']=$smf_user_info['ID_MEMBER'];
  $smf_user_info['username']=$smf_user_name;
  $smf_user_id = $smf_user_info['ID_MEMBER'];
  smf_api_update_user($smf_user_id, "", $user_password); 
//END MOD SMF

look for
Code: [Select]
    $sql = "UPDATE ".USERS_TABLE."
            SET ".get_user_table_field("", "user_email")." = '$user_email', ".get_user_table_field("", "user_showemail")." = $user_showemail, ".get_user_table_field("", "user_allowemails")." = $user_allowemails, ".get_user_table_field("", "user_invisible")." = $user_invisible, ".get_user_table_field("", "user_homepage")." = '$user_homepage', ".get_user_table_field("", "user_icq")." = '$user_icq'".$additional_sql."
            WHERE ".get_user_table_field("", "user_id")." = ".$user_info['user_id'];
    $site_db->query($sql);
add after
Code: [Select]
//MOD SMF integration
$smf_user_id = $smf_user_info['ID_MEMBER'];
smf_api_update_user($smf_user_id, "", "",$user_email);
//END MOD SMF

look for
Code: [Select]
if ($action == "updatepassword") {
  $txt_clickstream = $lang['control_panel'];
  if ($user_info['user_level'] == GUEST) {
    show_error_page($lang['no_permission']);
    exit;
  }
  $error = 0;
add after
Code: [Select]
//MOD SMF integration
  $smf_user_password = $HTTP_POST_VARS['user_password'];
//END MOD SMF

look for
Code: [Select]
  if (!$error) {
    $sql = "UPDATE ".USERS_TABLE."
            SET ".get_user_table_field("", "user_password")." = '$user_password'
            WHERE ".get_user_table_field("", "user_id")." = ".$user_info['user_id'];
    $site_db->query($sql);
add after
Code: [Select]
//MOD SMF integration
$smf_user_id = $smf_user_info['ID_MEMBER'];
smf_api_update_user($smf_user_id, "", $smf_user_password);
//END MOD SMF

Now the SMF side of things...
in the sources\profile.php file

look for
Code: [Select]
elseif ((allowedTo('profile_remove_own') && $context['user']['is_owner']) || allowedTo('profile_remove_any'))
$_REQUEST['sa'] = 'deleteAccount';
replace with
Code: [Select]
//MOD 4images integration
//elseif ((allowedTo('profile_remove_own') && $context['user']['is_owner']) || allowedTo('profile_remove_any'))
// $_REQUEST['sa'] = 'deleteAccount';
//END MOD 4images

look for
Code: [Select]
if (($context['user']['is_owner'] && allowedTo('profile_remove_own')) || allowedTo('profile_remove_any'))
$context['profile_areas']['profile_action']['areas']['deleteAccount'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=deleteAccount">' . $txt['deleteAccount'] . '</a>';
replace with
Code: [Select]
//MOD 4images integration
//if (($context['user']['is_owner'] && allowedTo('profile_remove_own')) || allowedTo('profile_remove_any'))
// $context['profile_areas']['profile_action']['areas']['deleteAccount'] = '<a href="' . $scripturl . '?action=profile;u=' . $memID . ';sa=deleteAccount">' . $txt['deleteAccount'] . '</a>';
//END MOD 4images

look for
Code: [Select]
$profile_vars['emailAddress'] = '\'' . $_POST['emailAddress'] . '\'';
replace with
Code: [Select]
//MOD 4images integration
//$profile_vars['emailAddress'] = '\'' . $_POST['emailAddress'] . '\'';
$profile_vars['emailAddress'] = '\'' . $emailAddress . '\'';
//END MOD 4images

in the sources/themes.php file

look for
Code: [Select]
if ($context[\'user\'][\'is_guest\'])
{
echo \'
<a href="\', $scripturl, \'?action=login">\', ($settings[\'use_image_buttons\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/\' . $context[\'user\'][\'language\'] . \'/login.gif" alt="\' . $txt[34] . \'" border="0" />\' : $txt[34]), \'</a>\', $context[\'menu_separator\'], \'
<a href="\', $scripturl, \'?action=register">\', ($settings[\'use_image_buttons\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/\' . $context[\'user\'][\'language\'] . \'/register.gif" alt="\' . $txt[97] . \'" border="0" />\' : $txt[97]), \'</a>\';
}

Otherwise, they might want to [logout]...
else
echo \'
<a href="\', $scripturl, \'?action=logout;sesc=\', $context[\'session_id\'], \'">\', ($settings[\'use_image_buttons\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/\' . $context[\'user\'][\'language\'] . \'/logout.gif" alt="\' . $txt[108] . \'" border="0" />\' : $txt[108]), \'</a>\';
replace with
Code: [Select]
//MOD 4images integration
//if ($context[\'user\'][\'is_guest\'])
//{
// echo \'
// <a href="\', $scripturl, \'?action=login">\', ($settings[\'use_image_buttons\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/\' . $context[\'user\'][\'language\'] . \'/login.gif" alt="\' . $txt[34] . \'" border="0" />\' : $txt[34]), \'</a>\', $context[\'menu_separator\'], \'
// <a href="\', $scripturl, \'?action=register">\', ($settings[\'use_image_buttons\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/\' . $context[\'user\'][\'language\'] . \'/register.gif" alt="\' . $txt[97] . \'" border="0" />\' : $txt[97]), \'</a>\';
//}
//
// Otherwise, they might want to [logout]...
//else
// echo \'
// <a href="\', $scripturl, \'?action=logout;sesc=\', $context[\'session_id\'], \'">\', ($settings[\'use_image_buttons\'] ? \'<img src="\' . $settings[\'images_url\'] . \'/\' . $context[\'user\'][\'language\'] . \'/logout.gif" alt="\' . $txt[108] . \'" border="0" />\' : $txt[108]), \'</a>\';
//END MOD 4images

in the themes/default/index.template.php file

look for
Code: [Select]
if ($context['user']['is_guest'])
echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
</td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
</td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
</td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
replace with
Code: [Select]
//MOD 4images integration
//if ($context['user']['is_guest'])
// echo ($current_action == 'login' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
// <td valign="top" class="maintab_' , $current_action == 'login' ? 'active_back' : 'back' , '">
// <a href="', $scripturl, '?action=login">' , $txt[34] , '</a>
// </td>' , $current_action == 'login' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// If the user is a guest, also show [register] button.
//if ($context['user']['is_guest'])
// echo ($current_action == 'register' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
// <td valign="top" class="maintab_' , $current_action == 'register' ? 'active_back' : 'back' , '">
// <a href="', $scripturl, '?action=register">' , $txt[97] , '</a>
// </td>' , $current_action == 'register' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';


// Otherwise, they might want to [logout]...
//if ($context['user']['is_logged'])
// echo ($current_action == 'logout' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
// <td valign="top" class="maintab_' , $current_action == 'logout' ? 'active_back' : 'back' , '">
// <a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '">' , $txt[108] , '</a>
// </td>' , $current_action == 'logout' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
//END MOD 4images

in the themes\default\languages\index.english.php file

look for
Code: [Select]
$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
replace with
Code: [Select]
//MOD 4images integration
//$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>. Please <a href="' . $scripturl . '?action=login">login</a> or <a href="' . $scripturl . '?action=register">register</a>.';
$txt['welcome_guest'] = 'Welcome, <b>' . $txt[28] . '</b>.';
//END MOD 4images

in the themes/default/profile.template.php file

look for
Code: [Select]
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr><tr>
<td width="40%"><b', (isset($context['modify_error']['bad_email']) || isset($context['modify_error']['no_email']) || isset($context['modify_error']['email_taken']) ? ' style="color: red;"' : ''), '>', $txt[69], ': </b><div class="smalltext">', $txt[679], '</div></td>
<td><input type="text" name="emailAddress" size="30" value="', $context['member']['email'], '" /></td>
</tr>';
replace with
Code: [Select]
//MOD 4images integration
// echo '
<!-- <tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr><tr>
<td width="40%"><b', (isset($context['modify_error']['bad_email']) || isset($context['modify_error']['no_email']) || isset($context['modify_error']['email_taken']) ? ' style="color: red;"' : ''), '>', $txt[69], ': </b><div class="smalltext">', $txt[679], '</div></td>
<td><input type="text" name="emailAddress" size="30" value="', $context['member']['email'], '" /></td>
</tr>';
-->
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr><tr>
<td width="40%"><b', (isset($context['modify_error']['bad_email']) || isset($context['modify_error']['no_email']) || isset($context['modify_error']['email_taken']) ? ' style="color: red;"' : ''), '>', $txt[69], ': </b><div class="smalltext"></div></td>
<td> '.$context['member']['email']. '</td>
</tr>';
//END MOD 4images

look for
Code: [Select]
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr><tr>
<td width="40%"><b', (isset($context['modify_error']['bad_new_password']) ? ' style="color: red;"' : ''), '>', $txt[81], ': </b><div class="smalltext">', $txt[596], '</div></td>
<td><input type="password" name="passwrd1" size="20" /></td>
</tr><tr>
<td width="40%"><b>', $txt[82], ': </b></td>
<td><input type="password" name="passwrd2" size="20" /></td>
</tr>';

// This section allows the user to enter secret question/answer so they can reset a forgotten password.
echo '
<tr>
<td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
</tr><tr>
<td width="40%"><b>', $txt['pswd1'], ':</b><div class="smalltext">', $txt['secret_desc'], '</div></td>
<td><input type="text" name="secretQuestion" size="50" value="', $context['member']['secret_question'], '" /></td>
</tr><tr>
<td width="40%"><b>', $txt['pswd2'], ':</b><div class="smalltext">', $txt['secret_desc2'], '</div></td>
<td><input type="text" name="secretAnswer" size="20" /><span class="smalltext" style="margin-left: 4ex;"><a href="', $scripturl, '?action=helpadmin;help=secret_why_blank" onclick="return reqWin(this.href);">', $txt['secret_why_blank'], '</a></span></td>
</tr>';
replace with
Code: [Select]
//MOD 4images integration
//echo '
// <tr>
// <td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
// </tr><tr>
// <td width="40%"><b', (isset($context['modify_error']['bad_new_password']) ? ' style="color: red;"' : ''), '>', $txt[81], ': </b><div class="smalltext">', $txt[596], '</div></td>
// <td><input type="password" name="passwrd1" size="20" /></td>
// </tr><tr>
// <td width="40%"><b>', $txt[82], ': </b></td>
// <td><input type="password" name="passwrd2" size="20" /></td>
// </tr>';

// This section allows the user to enter secret question/answer so they can reset a forgotten password.
//echo '
// <tr>
// <td colspan="2"><hr width="100%" size="1" class="hrcolor" /></td>
// </tr><tr>
// <td width="40%"><b>', $txt['pswd1'], ':</b><div class="smalltext">', $txt['secret_desc'], '</div></td>
// <td><input type="text" name="secretQuestion" size="50" value="', $context['member']['secret_question'], '" /></td>
// </tr><tr>
// <td width="40%"><b>', $txt['pswd2'], ':</b><div class="smalltext">', $txt['secret_desc2'], '</div></td>
// <td><input type="text" name="secretAnswer" size="20" /><span class="smalltext" style="margin-left: 4ex;"><a href="', $scripturl, '?action=helpadmin;help=secret_why_blank" onclick="return reqWin(this.href);">', $txt['secret_why_blank'], '</a></span></td>
// </tr>';
//END MOD 4images

The following changes are in any theme that your end users get to choose.
Mainly you are taking away any logins, registration, or forgot password stuff
Not sure if it is in the same location in each theme but these are the changes I did to mine

in the themes/pinkblitz/boardindex.template.php file

look for
Code: [Select]
// Show the login bar. (it's only true if they are logged out anyway.)
if ($context['show_login_bar'])
{
echo '
<tr>
<td class="titlebg" colspan="2">', $txt[34], ' <a href="', $scripturl, '?action=reminder" class="smalltext">(' . $txt[315] . ')</a></td>
</tr>
<tr>
<td class="windowbg" width="20" align="center">
<a href="', $scripturl, '?action=login"><img src="', $settings['images_url'], '/icons/login.gif" alt="', $txt[34], '" /></a>
</td>
<td class="windowbg2" valign="middle">
<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
<table border="0" cellpadding="2" cellspacing="0" align="center" width="100%"><tr>
<td valign="middle" align="left">
<label for="user"><b>', $txt[35], ':</b><br />
<input type="text" name="user" id="user" size="15" /></label>
</td>
<td valign="middle" align="left">
<label for="passwrd"><b>', $txt[36], ':</b><br />
<input type="password" name="passwrd" id="passwrd" size="15" /></label>
</td>
<td valign="middle" align="left">
<label for="cookielength"><b>', $txt[497], ':</b><br />
<input type="text" name="cookielength" id="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" /></label>
</td>
<td valign="middle" align="left">
<label for="cookieneverexp"><b>', $txt[508], ':</b><br />
<input type="checkbox" name="cookieneverexp" id="cookieneverexp" checked="checked" class="check" /></label>
</td>
<td valign="middle" align="left">
<input type="submit" value="', $txt[34], '" />
</td>
</tr></table>
</form>
</td>
</tr>';
}
replace with
Code: [Select]
//MOD 4images integration
// Show the login bar. (it's only true if they are logged out anyway.)
//if ($context['show_login_bar'])
//{
// echo '
// <tr>
// <td class="titlebg" colspan="2">', $txt[34], ' <a href="', $scripturl, '?action=reminder" class="smalltext">(' . $txt[315] . ')</a></td>
// </tr>
// <tr>
// <td class="windowbg" width="20" align="center">
// <a href="', $scripturl, '?action=login"><img src="', $settings['images_url'], '/icons/login.gif" alt="', $txt[34], '" /></a>
// </td>
// <td class="windowbg2" valign="middle">
// <form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" style="margin: 0;">
// <table border="0" cellpadding="2" cellspacing="0" align="center" width="100%"><tr>
// <td valign="middle" align="left">
// <label for="user"><b>', $txt[35], ':</b><br />
// <input type="text" name="user" id="user" size="15" /></label>
// </td>
// <td valign="middle" align="left">
// <label for="passwrd"><b>', $txt[36], ':</b><br />
// <input type="password" name="passwrd" id="passwrd" size="15" /></label>
// </td>
// <td valign="middle" align="left">
// <label for="cookielength"><b>', $txt[497], ':</b><br />
// <input type="text" name="cookielength" id="cookielength" size="4" maxlength="4" value="', $modSettings['cookieTime'], '" /></label>
// </td>
// <td valign="middle" align="left">
// <label for="cookieneverexp"><b>', $txt[508], ':</b><br />
// <input type="checkbox" name="cookieneverexp" id="cookieneverexp" checked="checked" class="check" /></label>
// </td>
// <td valign="middle" align="left">
// <input type="submit" value="', $txt[34], '" />
// </td>
// </tr></table>
// </form>
// </td>
// </tr>';
//}
//END MOD 4images

in the themes/pinkblitz/index.template.php file

look for
Code: [Select]
<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" style="margin: 4px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<input type="text" name="user"  size="10" />
<input type="password" name="passwrd"  size="10" />
<input type="submit" value="', $txt[34], '" />
<input type="hidden" name="hash_passwrd" value="" />
</form>', $context['current_time'],'<br />';
replace with
Code: [Select]
//MOD 4images integration
<!--
<form action="', $scripturl, '?action=login2" method="post" accept-charset="', $context['character_set'], '" style="margin: 4px 0;"', empty($context['disable_login_hashing']) ? ' onsubmit="hashLoginPassword(this, \'' . $context['session_id'] . '\');"' : '', '>
<input type="text" name="user"  size="10" />
<input type="password" name="passwrd"  size="10" />
<input type="submit" value="', $txt[34], '" />
<input type="hidden" name="hash_passwrd" value="" />
</form> --><br />', $context['current_time'],'<br />';
//END MOD 4images

look for
Code: [Select]
// If the user is a guest, show [login] button.
if ($context['user']['is_guest'])
echo '<li', $current_action == 'login' ? ' id="chosen"' : '', '><a href="', $scripturl, '?action=login"><span>' , $txt[34] , '</span></a></li>';

// If the user is a guest, also show [register] button.
if ($context['user']['is_guest'])
echo '<li', $current_action == 'register' ? ' id="chosen"' : '', '><a href="', $scripturl, '?action=register"><span>' , $txt[97] , '</span></a></li>';

// Otherwise, they might want to [logout]...
if ($context['user']['is_logged'])
echo '<li', $current_action == 'logout' ? ' id="chosen"' : '', '><a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '"><span>' , $txt[108] , '</span></a></li>';
replace with
Code: [Select]
//MOD 4images integration
// If the user is a guest, show [login] button.
// 4images hack
//if ($context['user']['is_guest'])
//echo '<li', $current_action == 'login' ? ' id="chosen"' : '', '><a href="', $scripturl, '?action=login"><span>' , $txt[34] , '</span></a></li>';

// If the user is a guest, also show [register] button.
//4images hack
//if ($context['user']['is_guest'])
//echo '<li', $current_action == 'register' ? ' id="chosen"' : '', '><a href="', $scripturl, '?action=register"><span>' , $txt[97] , '</span></a></li>';

// Otherwise, they might want to [logout]...
//4images hack
//if ($context['user']['is_logged'])
//echo '<li', $current_action == 'logout' ? ' id="chosen"' : '', '><a href="', $scripturl, '?action=logout;sesc=', $context['session_id'], '"><span>' , $txt[108] , '</span></a></li>';
//END MOD 4images

This is posted as a BETA to see how it works for everyone else...
How to get your smf forums to show up inside of 4images?
I used this mod and it worked for my site
http://www.4homepages.de/forum/index.php?topic=19843.0

Curious how it works, and any problems that anyone runs into.
PLEASE only use this on a test site and do not run it on your main site until you are comfortable that it is working the way you like it to.

the one thing is if you delete someone on the 4images side they do not get deleted on the forum side but I just log into the forum and delete them myself right now until I can find a fix.

I posted this because SMF comes up allot over the years on the board and I would like to see it move forward...
Buddy Duke

« Last Edit: May 25, 2009, 03:58:56 PM by budduke »
Buddy Duke
www.budduke.com

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
[MOD] SMF integration
« Reply #1 on: September 07, 2008, 10:07:28 PM »
WOW! Nice Dude!

Im testing it on a test Site !!!!!

Offline EdwinK

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] SMF integration
« Reply #2 on: September 08, 2008, 11:22:26 PM »
From reading this, it looks great. I just dare not do the needed changes.

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] SMF integration
« Reply #3 on: September 10, 2008, 07:14:29 PM »
hi,
you really mean
Quote
in the includes/page_header.php file

i think, you mean the session.php ?

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] SMF integration
« Reply #4 on: September 10, 2008, 07:51:20 PM »
Quote
hi,
you really mean


in the includes/page_header.php file

i think, you mean the session.php ?

Yes, you are correct. I modified the original post.
Thanks for doublchecking my work. I had it in the file list correct
Buddy Duke
www.budduke.com

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: [MOD] SMF integration
« Reply #5 on: September 11, 2008, 01:50:26 PM »
I Have a Problem:
Code: [Select]
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /var/www/html/web574/html/cbvote/forum/smf_api.php on line 162

Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/html/web574/html/cbvote/includes/page_header.php on line 431

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/html/web574/html/cbvote/includes/functions.php on line 513

functions.php - The COde is to long, show the Attachment


Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] SMF integration
« Reply #6 on: September 12, 2008, 01:28:42 AM »
for Phisker B,
looked over the files you sent me and made the changes that I thought would work...
I did not modify your extra themes because you need to find where to turn off the login options yourself.
I am not using all the different mods that you have in your code but placed my mods in the best places I could find.
I counted quite a few mods 11 or so?

looked over and did not see where there were any conflicts in variables or anything like that, not sure why it is not working.

regarding your recent post with the valid result warnings...
I get the first one all the time and have searched all over the  net regarding it and everyone says the same thing,
nothing to worry about, turn off your logging or flush your logs from time to time. so I have not searched beyound that.
The last 2 results seem to be with another mod and it does not look like any of the variables are crossing each other in any way.

If you completely remove all the SMF integration mods, do the warnings go away on the pageheader and functions?

PS: I see that you removed all remarks at the top of all the files regarding 4images,
I am assuming that you have paid for a license to remove those referrences?

Do not PM me regaring repairing your site for you, that is up for you to do. I will do my best to lead you in the correct direction,
but you may have to start with a fresh install of 4images and apply my mod first and then start adding each of the others untill
we determine when the conflict begins. Are you willing to do that? I do not have the time to install all the mods that you are using
because they would have no use on my site whatsoever.
If you want to pm me any questions or post them here that is fine, and if I need to see one of your files I will ask for it.

sorry for the long winded message but I do this for fun and do not have all the time in the world to be working on other people sites for them.
but I do enjoy learning and working through problems and that is why I posted the integration so all of us that want to use it can get it
to function the best way possible for 4images...


Buddy Duke
www.budduke.com

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] SMF integration
« Reply #7 on: September 12, 2008, 09:39:33 AM »
hi,
i have a problem too:
if i comment an image or edit my profile i get a message called: "No database selected" on a white site.
stupid thing: the comment is done and the profile is edit.
i think it is a little problem but i can't find it..
do you know that problem?

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] SMF integration
« Reply #8 on: September 12, 2008, 04:30:38 PM »
Quote
if i comment an image or edit my profile i get a message called: "No database selected" on a white site.
stupid thing: the comment is done and the profile is edit.

Interesting, is your SMF forum installed and running correctly before you did this mod?
I am able to change my profiles all the time, big test playing with that.
It sounds like it does not see the SMF part of your site.
You can also try turning on the maintence page on the SMF and see what type of message you get then.

I am currently at work right now so I will look a little deeper when I get home tonight and see what I can see.

Can you PM me your session.php so I can compare it with mine?
Buddy Duke
www.budduke.com

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] SMF integration
« Reply #9 on: September 13, 2008, 01:06:31 AM »
to Loda,

check PM'd you the modified sessions file, see if it fixes the problem or not...
it seems like you put the logout info for SMF in the wrong spot,
will have to recheck my original post to see if there are 2 places that you can place that file.

also, your file said 1.7 version, do you know which one it actually is? Some of the functioned where created differently
but they seemed to aclomplish the same thing...
Buddy Duke
www.budduke.com

Offline Loda

  • Sr. Member
  • ****
  • Posts: 353
    • View Profile
    • Fotosucht Schweiz
Re: [MOD] SMF integration
« Reply #10 on: September 13, 2008, 02:14:57 PM »
hi,
thank you very much for your help.
the problem isn't fixed. i think my problem is the old 4images version. i want to check it on a new actually version.

Offline lesmond

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] SMF integration
« Reply #11 on: October 14, 2008, 09:51:59 PM »
I seem to be having problems with the api files, my forum is in the root, not in its own folder, this is what I am getting when I try the access 4images page, I have 4images in its own folder within the root.
Code: [Select]
Warning: require(./public_html/xxxxxxl.co.uk/smf_api_2.php) [function.require]: failed to open stream: No such file or directory in /home/uk/public_html/xxxxxx.co.uk/4images/includes/sessions.php on line 57

Warning: require(./public_html/xxxxxxl.co.uk/smf_api_2.php) [function.require]: failed to open stream: No such file or directory in /home/uk/public_html/xxxxxx.co.uk/4images/includes/sessions.php on line 57
and in the sessions.php I have this..
Code: [Select]
//MOD SMF integration
require(ROOT_PATH.'public_html/xxxxxx.co.uk/smf_api_2.php'); //change paths to your forums directory
require(ROOT_PATH.'public_html/xxxxxxl.co.uk/smf_api.php');     //change paths to your forums directory
global $smf_settings, $smf_user_info;
//END MOD SMF

I have tried it number of ways, but not having any luck at all  :oops:

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] SMF integration
« Reply #12 on: October 15, 2008, 12:14:55 PM »
I seem to be having problems with the api files, my forum is in the root, not in its own folder, this is what I am getting when I try the access 4images page, I have 4images in its own folder within the root.
Code: [Select]
Warning: require(./public_html/xxxxxxl.co.uk/smf_api_2.php) [function.require]: failed to open stream: No such file or directory in /home/uk/public_html/xxxxxx.co.uk/4images/includes/sessions.php on line 57

Warning: require(./public_html/xxxxxxl.co.uk/smf_api_2.php) [function.require]: failed to open stream: No such file or directory in /home/uk/public_html/xxxxxx.co.uk/4images/includes/sessions.php on line 57
and in the sessions.php I have this..
Code: [Select]
//MOD SMF integration
require(ROOT_PATH.'public_html/xxxxxx.co.uk/smf_api_2.php'); //change paths to your forums directory
require(ROOT_PATH.'public_html/xxxxxxl.co.uk/smf_api.php');     //change paths to your forums directory
global $smf_settings, $smf_user_info;
//END MOD SMF

I have tried it number of ways, but not having any luck at all  :oops:

If I remember correctly, the root_path is the path to the root of your gallery and not the root of the server.
I would try...
Code: [Select]
require(ROOT_PATH.'../smf_api_2.php'); //change paths to your forums directory
require(ROOT_PATH.'../smf_api.php');     //change paths to your forums directory

I am not where I can test it for you but I think the "../" will take it up one directory level which should take it to the forum directory.
Buddy Duke
www.budduke.com

Offline lesmond

  • Pre-Newbie
  • Posts: 8
    • View Profile
Re: [MOD] SMF integration
« Reply #13 on: October 15, 2008, 05:10:21 PM »

If I remember correctly, the root_path is the path to the root of your gallery and not the root of the server.
I would try...
Code: [Select]
require(ROOT_PATH.'../smf_api_2.php'); //change paths to your forums directory
require(ROOT_PATH.'../smf_api.php');     //change paths to your forums directory

I am not where I can test it for you but I think the "../" will take it up one directory level which should take it to the forum directory.

OK that worked, I can see the page, but I am now getting this error at the top of the page...
Code: [Select]
Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/xxxxxx/public_html/xxxxxx.co.uk/smf_api.php on line 162
Line 162 in smf_api.php is....
Code: [Select]
156  $request = smf_query("
157 SELECT variable, value
158 FROM {$db_prefix}settings", __FILE__, __LINE__);
159 $smf_settings = array();
160 while ($row = @mysql_fetch_row($request))
161 $smf_settings[$row[0]] = $row[1];
162 mysql_free_result($request);
163  }

Offline budduke

  • Hero Member
  • *****
  • Posts: 506
    • View Profile
    • http://www.budduke.com
Re: [MOD] SMF integration
« Reply #14 on: October 16, 2008, 12:18:42 AM »
I did not actually make the smf_api code itself so I am not sure about that warning but I do get it also, but not at the top of my pages.
It fills up my log files on my site and I just go in a delete them from time to time.
I wonder if you can just rem out line 162? (see my example in the code)
Code: [Select]
156  $request = smf_query("
157 SELECT variable, value
158 FROM {$db_prefix}settings", __FILE__, __LINE__);
159 $smf_settings = array();
160 while ($row = @mysql_fetch_row($request))
161 $smf_settings[$row[0]] = $row[1];
162 //mysql_free_result($request);
163  }

when I first started seeing the error I googled around and everyone said to just ignore it because it is not a problem...
I think the command is just suppose to release the memory that the sql command was using for the function but I always thought it did that also when the function was finished.

Maybe some other programmer can chime in to explain it any better and wether it needs to be in the code or not?
Buddy Duke
www.budduke.com