Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - budduke

Pages: [1] 2
1
Programming / working with string patterns...
« on: August 19, 2012, 01:20:35 AM »
I am terrible when it comes to string patterns and kind not find the info I need anywhere.
I want to perform a rtrim ($string,"search pattern")  on a string like this one..
$string="This is my data (want to keep this data) (want to delete this data and brackets)"
Anybody have any ideas what my "search pattern" should be to get rid of the second set of () and the data inside it?

Thanks!

2
[MOD] Facebook like/share/send button
Version 3.1

Demo My website http://www.budduke.com/gallery

based off of jeyjoo's modifications that was posted in the programming section of this site
versions history
1.0 initial version
1.1 fixed error in Header file insert pointed out by Jeyjoo in reply#2. Changed insert in header.html
1.2 fixed error when you had html code in your description field on your images. Changed insert for details.html
2.0 reworked the code so I think it will work correctly this time
2.1 Added Iframe for the like button for sites that need it.
3.0 reworked code to work with appid from facebook application
3.1 made this mod work better with version 2 of my facebook login mod

I have been reading everyone's attempts/problems regarding this and this is what I came up with...
Version 2.0 now works with your categorie thumbnail pages
Version 3.0 now has a main like button for your site.

Please read my post on how to create an application on facebook and other issues
http://www.4homepages.de/forum/index.php?topic=29422.msg157086#msg157086
You Must Create an Application on Facebook for this Mod to work

You only need to modify these files to make this work
your templates/header.html
your templates/details.html
your templates/thumbnail_bit.html New to version 2.0
includes/page_header.php New to version 2.0
includes/functions.php New to version 2.0
admin/settings.php New to Version 3.0
lang/english/admin.php New to Version 3.0
lang/english/main.php Optional New to Version 3.0
details.php (Mod no longer using this file, need to remove mod from this file if you have older version of this mod installed


Like always, Backup these files and Database before you begin

New for version 3.0
Step 0
you will need to download the attached file, unzip it, place the file in your root folder of your gallery, and run the installer file so it can place the fields in your settings database.
Delete this file after you run it.

Step 1
in your includes/page_header.php file Updated for version 3
search for
Code: [Select]
?>insert Before
Code: [Select]
//[MOD] Facebook Like Button
if ($array["details"]){
$sql = "SELECT image_name, cat_id, image_thumb_file, image_description
FROM ".IMAGES_TABLE."
WHERE image_id = $image_id AND image_active = 1";
$image_row = $site_db->query_firstrow($sql);
$facebook['image'] = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
$facebook['image'] = $script_url.substr($facebook['image'],1);
$facebook['title'] = $image_row['image_name'];
$facebook['type'] = "article";//this is what facebook says images should be filed under
$facebook['description'] = !empty($image_row['image_description']) ? strip_tags($image_row['image_description']) . ". " : "";
$facebook['url1'] = $site_sess->url($script_url."/".$self_url);
if (strpos($facebook['url1'],"&")){
$facebook['url1']=substr($facebook['url1'],0,strpos($facebook['url1'],"&"));
}
}
else{
$facebook['image'] = $config['fb_image'];
$facebook['title'] = $config['fb_title'];
$facebook['type'] = "website";// types setting for your default website
$facebook['description'] = strip_tags($config['fb_description']);
$facebook['url1'] = $config['fb_main_url'];
}
$facebook['main_url']= $config['fb_main_url'];
$site_template->register_vars(array(
"fb_title" => $facebook['title'],
"fb_image" => $facebook['image'],
"fb_type" => $facebook['type'],
"fb_desc" => $facebook['description'],
"fb_url1" => $facebook['url1'],
"fb_main_url" => $facebook['main_url'],
"fb_appid" => $config['fb_appid'],
"fb_admins" => $config['fb_admins'],
"fb_language" => ($lang['fb_language']) ? $lang['fb_language'] : $config['fb_language']
)
);
unset($facebook, $image_row);
//END [MOD] Facebook Like Button

Step 2.a (this insert is the same as my facebook login MOD V2 step 9.a)
in your templates/header.html file
search for
Code: [Select]
<html dir="{direction}">Replace with
Code: [Select]
<html dir="{direction}" xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://ogp.me/ns#" xmlns:fb="http://www.facebook.com/2008/fbml">

Step 2.b New to version 2.0, Updated for version 3
search for
Code: [Select]
<title>.....</title>insert After
Code: [Select]
<script src="http://connect.facebook.net/{fb_language}/all.js#xfbml=1"></script>
<meta property="fb:app_id" content="{fb_appid}"/>
<meta property="fb:admins" content="{fb_admins}"/>
<meta property="og:type" content="{fb_type}"/>
<meta property="og:site_name" content="{site_name}"/>
<meta property="og:url" content="{fb_url1}"/>
<meta property="og:title" content="{fb_title}"/>
<meta property="og:description" content="{fb_desc}"/>
<meta property="og:image" content="{fb_image}"/>

Step 2.c Optional New to version 2.0, Upated for version 3Updated for version 3.1
(this insert is the same ans my facebook login mod version 2 step 9.b)
Note: You do not have to place this code in your page.
Note: I have noticed the site loads faster with this code placed in it.
Note: I have noticed a flicker when some sites load with this code placed in them (That is why I am giving you the option)

Insert at the very end of the document
Code: [Select]
<div id="fb-root"></div>
    <script>
  window.fbAsyncInit = function() {      
        FB.init({
          appId: '{fb_appid}',
          cookie: true,
          xfbml: true
        });
        FB.Event.subscribe('auth.logout', function(response) {
          window.location = '{fb_logout_url}';
        });
      };
      (function() {
        var e = document.createElement('script'); e.async = true;
        e.src = document.location.protocol +
          '//connect.facebook.net/{fb_language}/all.js';
        document.getElementById('fb-root').appendChild(e);
      }());
</script>
Remove
Code: [Select]
<script src="http://connect.facebook.net/{fb_language}/all.js#xfbml=1"></script>from the code you placed in Step 2.b



Step 3.a  New to version 2.0
in your includes/functions.php file
Search for
Code: [Select]
global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile;Replace with
Code: [Select]
global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile, $script_url;//[MOD] Facebook Like Button
Step 3.b New to version 2.0
Search for
Code: [Select]
$rate_form = ""insert Before
Code: [Select]
 //[MOD] Facebook Like Button
  $fb_url= $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$image_row['image_id']);
  $fb_url= $script_url.substr($fb_url,1);
  if (strpos($fb_url,"&")){
$fb_url= substr($fb_url,0,strpos($fb_url,"&"));
}
  $site_template->register_vars("fb_url",$fb_url);
  //end [MOD] Facebook Like Button

Step 4 Changed in version 2.0
In your templates/details.html  and templates/thumbnail_bit.html file
Place this code where you want the like button to appear
Code: [Select]
<fb:like href="{fb_url}" layout="button_count" show_faces="false" width ="90"></fb:like>Or if you prefer or you site needs the IFRAME version of facebook's like button insert this code instead...
Code: [Select]
<iframe src="http://www.facebook.com/plugins/like.php?href={fb_url}&layout=button_count&show_faces=false&width=90&action=like&font&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>
Step 5.a New to version 3.0
(this insert is the same as my facebook login MOD V2 step 1.a)
In your admin/settings.php file
Search for
Code: [Select]
// end of functionsInsert Before
Code: [Select]
//[MOD] Facebook Like Button
function show_fb_language_options($setting_name, $setting_value) {
  global $fb_language_optionlist;
  echo "<select name=\"setting_item[".$setting_name."]\">";
  foreach ($fb_language_optionlist as $key => $val) {
    echo "<option value=\"$key\"";
    if ($setting_value == $key) {
      echo " selected=\"selected\"";
    }
    echo ">".$val."</option>";
  }
  echo "</select>";
}
//END [MOD] Facebook Like Button

Step 5.b New to version 3Updated in version 3.1
(this insert is the same as my facebook login MOD V2 step 1.b)
Search for
Code: [Select]
show_form_footer($lang['save_changes'], "", 2);
Insert Before
Code: [Select]
// [MOD] Facebook
  show_table_separator($setting_group["facebook"], 2, "setting_group_facebook");
  show_setting_row("fb_appid");
  if ($fb_mod_select==1 || $fb_mod_select==3){
   show_setting_row("fb_appsec");
  }
  if ($fb_mod_select>1){
   show_setting_row("fb_admins");
   show_setting_row("fb_title");
   show_setting_row("fb_main_url");
   show_setting_row("fb_image");
   show_setting_row("fb_description","textarea");
  }
  show_setting_row("fb_language","show_fb_language_options");
// END[MOD] Facebook

Step 6 New to version 3.0Updated for version 3.1
(this insert is the same as my facebook login V2 step 5)
Note: first line $fb_mod_select=2 (change to 3 if using both mods)
In your \lang\english\admin.php file
Search for
Code: [Select]
?>Insert Before
Code: [Select]
//[MOD] Facebook
$fb_mod_select=2; // 1="login button Mod", 2="like/share/send button Mod", 3="both Mods installed"
/*-- Setting-Group Facebook --*/
$setting_group["facebook"]="Facebook settings";
$setting['fb_appid'] = "Application ID";
$setting['fb_appsec'] = "Application Secret";
$setting['fb_admins'] = "List of facebook IDs as admins<br><span class=\"smalltext\">IDs seperated by commas</span>";
$setting['fb_main_url'] = "Full HTML path to your website<br><span class=\"smalltext\">What you placed in the connect URL on facebook</span>";
$setting['fb_image'] = "Full HTML path to your logo/image for your website";
$setting['fb_title'] = "What you would like the Main Title to say for your website";
$setting['fb_description'] = "Description displayed for your website<br><span class=\"smalltext\">HTML code will be removed</span>";
$setting['fb_language'] = "Default language to use for Facebook";
$fb_language_optionlist = array(
'ca_ES' => 'Catalan',
'cs_CZ' => 'Czech',
'cy_GB' => 'Welsh',
'da_DK' => 'Danish',
'de_DE' => 'German',
'eu_ES' => 'Basque',
'en_PI' => 'English (Pirate)',
'en_UD' => 'English (Upside Down)',
'ck_US' => 'Cherokee',
'en_US' => 'English (US)',
'es_LA' => 'Spanish',
'es_CL' => 'Spanish (Chile)',
'es_CO' => 'Spanish (Colombia)',
'es_ES' => 'Spanish (Spain)',
'es_MX' => 'Spanish (Mexico)',
'es_VE' => 'Spanish (Venezuela)',
'fb_FI' => 'Finnish (test)',
'fi_FI' => 'Finnish',
'fr_FR' => 'French (France)',
'gl_ES' => 'Galician',
'hu_HU' => 'Hungarian',
'it_IT' => 'Italian',
'ja_JP' => 'Japanese',
'ko_KR' => 'Korean',
'nb_NO' => 'Norwegian (bokmal)',
'nn_NO' => 'Norwegian (nynorsk)',
'nl_NL' => 'Dutch',
'pl_PL' => 'Polish',
'pt_BR' => 'Portuguese (Brazil)',
'pt_PT' => 'Portuguese (Portugal)',
'ro_RO' => 'Romanian',
'ru_RU' => 'Russian',
'sk_SK' => 'Slovak',
'sl_SI' => 'Slovenian',
'sv_SE' => 'Swedish',
'th_TH' => 'Thai',
'tr_TR' => 'Turkish',
'ku_TR' => 'Kurdish',
'zh_CN' => 'Simplified Chinese (China)',
'zh_HK' => 'Traditional Chinese (Hong Kong)',
'zh_TW' => 'Traditional Chinese (Taiwan)',
'fb_LT' => 'Leet Speak',
'af_ZA' => 'Afrikaans',
'sq_AL' => 'Albanian',
'hy_AM' => 'Armenian',
'az_AZ' => 'Azeri',
'be_BY' => 'Belarusian',
'bn_IN' => 'Bengali',
'bs_BA' => 'Bosnian',
'bg_BG' => 'Bulgarian',
'hr_HR' => 'Croatian',
'nl_BE' => 'Dutch (België)',
'en_GB' => 'English (UK)',
'eo_EO' => 'Esperanto',
'et_EE' => 'Estonian',
'fo_FO' => 'Faroese',
'fr_CA' => 'French (Canada)',
'ka_GE' => 'Georgian',
'el_GR' => 'Greek',
'gu_IN' => 'Gujarati',
'hi_IN' => 'Hindi',
'is_IS' => 'Icelandic',
'id_ID' => 'Indonesian',
'ga_IE' => 'Irish',
'jv_ID' => 'Javanese',
'kn_IN' => 'Kannada',
'kk_KZ' => 'Kazakh',
'la_VA' => 'Latin',
'lv_LV' => 'Latvian',
'li_NL' => 'Limburgish',
'lt_LT' => 'Lithuanian',
'mk_MK' => 'Macedonian',
'mg_MG' => 'Malagasy',
'ms_MY' => 'Malay',
'mt_MT' => 'Maltese',
'mr_IN' => 'Marathi',
'mn_MN' => 'Mongolian',
'ne_NP' => 'Nepali',
'pa_IN' => 'Punjabi',
'rm_CH' => 'Romansh',
'sa_IN' => 'Sanskrit',
'sr_RS' => 'Serbian',
'so_SO' => 'Somali',
'sw_KE' => 'Swahili',
'tl_PH' => 'Filipino',
'ta_IN' => 'Tamil',
'tt_RU' => 'Tatar',
'te_IN' => 'Telugu',
'ml_IN' => 'Malayalam',
'uk_UA' => 'Ukrainian',
'uz_UZ' => 'Uzbek',
'vi_VN' => 'Vietnamese',
'xh_ZA' => 'Xhosa',
'zu_ZA' => 'Zulu',
'km_KH' => 'Khmer',
'tg_TJ' => 'Tajik',
'ar_AR' => 'Arabic',
'he_IL' => 'Hebrew',
'ur_PK' => 'Urdu',
'fa_IR' => 'Persian',
'sy_SY' => 'Syriac',
'yi_DE' => 'Yiddish',
'gn_PY' => 'Guaraní',
'qu_PE' => 'Quechua',
'ay_BO' => 'Aymara',
'se_NO' => 'Northern Sámi',
'ps_AF' => 'Pashto',
'tl_ST' => 'Klingon'
);
//END [MOD] Facebook

Step 7 Optional New to Version 3.0
In your template files, you can now add a main like button for your site
Code: [Select]
<fb:like href="{fb_main_url}" layout="button_count" show_faces="false" width ="90"></fb:like>Or if you prefer or you site needs the IFRAME version of facebook's like button insert this code instead...
Code: [Select]
<iframe src="http://www.facebook.com/plugins/like.php?href={fb_main_url}&layout=button_count&show_faces=false&width=90&action=like&font&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>
Step 8 Optional New to Version 3.0
In your /lang/whatever language/main.php file
Search for
Code: [Select]
?>Insert Before
Code: [Select]
//[MOD] Facebook Like Button
$lang['fb_language'] = "en_US";
//END [MOD] Facebook Like Button
By placing the correct information for the language in your different language folders, when a user is using that language, the Like button will appear in the correct language. You can look at the array placed in step 6 for the correct format for entering the different languages

And you are finished...
New to Version 3.0
You now have a place in the ACP panel, under settings to place your facebook information so you do not have to edit your code all the time.
The app id is the one from the application you created in facebook,
Admins are facebook users you want to be admins for your pages,
The rest are fields for you to fill out for the main url link for your site used in step 7.

NOTES:
By placing the meta tags in the header like Jeyjoo sugested, the mod now passes validation tests  :)

The slowness you see in the like buttons appearing is facebook querying your pages to get the meta data before it displays the info. At this point, I can not find a way around this. I also noticed that when my categorie pages where loading, I had 40 guest hits from facebook for updating the like buttons. This may cause a problem with shared hosting. But after facebook caches your pages the hits should go down.

What about the Share button?
Facebook is no longer improving on the share button but they will continue to allow it to be used...
Here is the link for the steps you need to do to change it to the Share button
http://www.4homepages.de/forum/index.php?topic=29422.msg156985#msg156985

Send button?
Just came out, it allows you to send the link to just a couple of users or group and not posting on your profile...
You can still change the code in step #4 or add a new button with Send by
changing
Code: [Select]
<fb:like
to
Code: [Select]
<fb:send
and
Code: [Select]
</fb:like> to
Code: [Select]
</fb:send>
Or you can add the send function to the like button (like my site is displaying) that only makes one call to facebook for the one button by changing step 4 to

Code: [Select]
<fb:like href="{fb_url}" layout="button_count" show_faces="false" send="true" width ="90"></fb:like>Or if you prefer or you site needs the IFRAME version of facebook's like button with send button...
Code: [Select]
<iframe src="http://www.facebook.com/plugins/like.php?href={fb_url}&layout=button_count&show_faces=false&width=90&action=like&font&colorscheme=light&send=true&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px;" allowTransparency="true"></iframe>

I hope this helps!


These items need to be removed if you have version 1 of this mod installed...

In your details.php file
REMOVE
Code: [Select]
//MOD facebook like/share
$fb_url = $site_sess->url($script_url."/".$self_url);
$facebook_image = get_file_path($image_row['image_media_file'], "thumb", $cat_id, 0, 1);
$facebook_image = $script_url.substr($facebook_image,1);
if (strpos($fb_url,"&")){
$fb_url=substr($fb_url,0,strpos($fb_url,"&"));
}
$site_template->register_vars(array(
"facebook_title" => $image_name,//change this to what you want the title to be (image_name by default)
"facebook_image" => $facebook_image,
     "fb_url" => $fb_url)
);
unset($fb_url, $facebook_image);
//END MOD facebook like/share


in your templates/details.html file
REMOVE
Code: [Select]
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
<fb:like  href="{fb_url}" layout="button_count" show_faces="true" width ="40">
<meta property="og:url" content="{fb_url}"/>
<meta property="og:title" content="{facebook_title}"/>
<meta property="og:description" content="{detail_meta_description}"/>
<meta property="og:image" content="{facebook_image}" />
<meta property="og:type" content="company" />
<meta property="fb:admins" content="LIST OF FACEBOOK ADMIN IDS" />
</fb:like>


3
Programming / need education on Doctype at top of header...
« on: September 06, 2010, 06:59:49 PM »
Have been messing with a jquery code and all the normal templates in 4images and most of the free ones I have played with start with on the header.html file...
Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

The only way I could get the jquery script to look right was to change this to...
Code: [Select]
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

but when I changed this line then none of the templates looked correct, some white gaps can be seen above/below register area, ect...
I am assuming to use that line then all html codes have to start/end correctly like <div><p>paragraph</p></div>
Is that all I need to look at or is there more to it. w3 website is very cryptic and not very educational.

Thanks for any advice anyone can send my way...

4
I am slapping together a quick site for a friend and made a subdomain for him to use...
http://littlehighlanders.budduke.com
everything seems to work fine unless you are in the ACP or it happens when you press login/logout also...
it redirects you to
http://littlehighlanders.budduke.com/highlanders/index.php
instead of
http://littlehighlanders.budduke.com/index.php
That is the folder that I am using for his subdomain but it should not have the folder in the link anywhere.

I have not tried 1.7.7 to see if it is something new and I did not see any reference to this problem in my searching the forum so I thought I better ask.

Thanks for any help, my friend would like to have this site up and running by the weekend

5
Programming / Trying to understand the Caching system...
« on: July 10, 2010, 12:23:39 AM »
I did not see where would be the best place to ask this but can someone explain the cache system on 4images a little better for me?
Here is what I have ran into using one of my own mods...
User category area
http://www.4homepages.de/forum/index.php?topic=24628.msg134888#msg134888

when I have the cache turned on, the users trying to use this mod are getting strange things. like stuff not showing up, photos not being uploaded, ect...
when the cache finally caught up then the user had 5 of the same image uploaded because they kept trying over and over.
I have determined it is because it was pulling the cache pages instead of there newly uploaded pages so I turned it back off till I can figure it out better.

Is there a way to program the cache system so that when a user does something like the user upload/multi-upload that it would send a command that would re-cache the page that the user just changed? It even happens when they create a new category, it would need to do the same thing for the parent of that category to re-cache it so it would be there.

I noticed this at the top of most php pages in 4images...
Code: [Select]
define('GET_CACHES', 1);
define('ROOT_PATH', './');
define('GET_USER_ONLINE', 1);

if I change the GET_CACHES to 0 will that force that page to re-cache?

I saw I can disable caching for categories in the global file but that did not seem to help because my mod is using user_categories.php instead of just categories.php.
I love the speed of the caching system, I am just trying to figure out a way of making more useful for my site/users...
any help/documentation/advice would greatly be appreciated...

6
Programming / Any javascript Gurus out there?
« on: July 05, 2010, 01:19:01 AM »
I am working on my gallery quicklist again and I have all the bugs fixed except one and I can not figure out how or if it can even be fixed so I will try to ask here...

inside the javascript the link that is in the list is considered this. variable and it is being compared with the location. variable inside the script in this area...

Code: [Select]
case "location":
//MOD modifield for 4images page number problem
var locsub = location.href.replace(/&sessionid=([0-9]|[a-z]|[A-Z])*/g,"");
var locsub = locsub.replace(/&page=[0-9]*/,"");
var current = this.find("a").filter(function() { return this.href.toLowerCase() == locsub.toLowerCase(); });
//var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); });
//End Mod for 4images page number problem
if ( current.length ) {
current.addClass("selected").parents("ul, li").add( current.next() ).show();
}
break;

I am able to remove the sessionid and the page= from the string on the location. variable but I can not figure out how to get the sessionid out of the this. variable.
I created another variable called locsub with the sessionid and the page= removed but I can not figure out how to do it with the this. variable so that the two will become equal and highlight your location.

It really isn't a big deal but is the only bug I can not get rid of. The only time that this would happen is if the user opened a new web browser and only on the first initial links would have the sessionid in them and does not highlight where they are currently at in the list, but as soon as they click on something then the sessionid is applied and is no longer a problem.

I am re-writing the mod so it handles the $site_sess->url() better but now it adds the sessionid to the string which is giving me this little problem.
you can see what I have in the attached jpg...

Thank you for any help you can send my way, I am learning slowly :)

7
Facebook Connector VERSION 2.0 CAN BE FOUND HERE...
http://www.4homepages.de/forum/index.php?topic=27396.msg160225#msg160225

[MOD] Facebook Connector V1.0

DO NOT INSTALL VERSION 1 OF THIS MOD!
The Version one instructions are here for users to remove all entries from their galleries before installing version 2.
As of December 13th, facebook no longer supports the code that it is ran under.
I am currently working on version 2.0 of this mod using the new code but still have some testing to do with it first.
I am hoping to have it up and running by the end of January 2012.


This mod will give your users the ability to login to your 4images site using their Facebook account.
YOU MUST be running PHP Version 5 or greater with CURL and JSON running on your server for this mod to work.
check your phpinfo() or your provider to find out. My provider upgraded my account for free to the new PHP.

this mod is based on the facebook php-sdk kit that is available at...
http://github.com/facebook/php-sdk/
the package is new and constantly being updated, I will try to stay on top of it but no guarantee that this mod will work if they make any drastic changes to their code.

I used the folowing tutorials to help me create this mod, (I have to give them the credit, they did most of the hard work)
http://www.barattalo.it/facebook-connect-tutorial/
http://www.pakt.com/pakt/?id=5e17b48f5679ab47&t=How_to_add_Facebook_Connect_to_your_website_using_the_PHP_API
http://thinkdiff.net/facebook/php-sdk-graph-api-base-facebook-connect-tutorial/

This mod adds a login button to your userbox on your site.
When a user logs in for the first time with facebook, it will check their e-mail to see if they already have an account on your site and connect the facebook account to that account if found.
If the account is not found, it will auto-create an account on your site using their facebook fullname and adding numbers after it if needed.
it will also transfer their e-mail and website information to 4images database in the process. (facebook now allows this as long as you do not SPAM your visitors, they will disable your app if anyone complains)
It will not e-mail authenticate their account, I figure facebook already did this so it already lets them have full user access when logging in.
After installed and running, it is compatable with most of the facebook social addons if you wish to have them displayed on your site.
Is language friendly, check on the insert in the language/main.php file called $lang['fbl_lang'] for more information.
The Mod will ask your users for their facebook e-mail and website to add to the 4images database.
It will also ask for permission to post any share/like requests to there facebook profiles.

The only issue I have found is that facebook is wanting you to use SSL for comunications between them and your site, so far they have not inforced the issue and I am not sure how to add support for that,
so I modified the facebook.php file to turn the ssl verification off. Everyone on facebook is complaining about it also so hopefully they will not force the SSL issue or I think your entire gallery will have to be
behind a SSL certificate for it to work in the future but for now you should be good.

DEMO...
http://www.budduke.com

Version history...
V1.0 - initial release. (using a modified version 2.0.4 of the php-sdk kit)

You first need to go to Facebooks website and create an app under your account.
http://www.facebook.com/developers/createapp.php
click on the "set up new application" button.
In the set up page you have different fields to enter, but only these are needed (see attached pdf file in zip download to see my settings)
On the Basic tab; "name of the application" and your developer contact.
On the Connect tab; "Connect url", you should enter the root of your gallery, for the example: "http://www.yourwebsite.com/gallery/"
               "Base Domain", you should enter the root of your site, for the example: "www.yourwebsite.com"
Take note of the "application ID", "API key", and the "secret" (write down or be ready to copy this information. (DO NOT SHARE THIS INFO WITH ANYONE!)


Backup your database before adding this mod. It makes changes to your USERS table.
These are the modified files that you will need to backup before modifying.
categories.php
details.php
global.php
index.php
lightbox.php
login.php
member.php
postcards.php
register.php
rss.php
search.php
top.php
includes\page_header.php
includes\sessions.php
lang\english\main.php
your template\details.html
your template\header.html
your template\member_editprofile.html
your template\user_loginform.html
your template\user_logininfo.html

Lets get started...

Download and unzip the file attached and place the facebook folder with it's content in the root of your gallery.
Place the facebook_install.php file in the root of your gallery and run it to add the fields to your user table. (DELETE THIS FILE AFTER YOU RUN IT!)
Protect the facebook folder anyway you can, I placed an index.php file in it that will reroute anyone directory browsing to your homepage (replace with your website path in the index.php file)
or delete it if you are using another method to keep people out.

Copy the "application ID", "API key", "secret", and "base domain" information into the top of the FBMAIN.PHP file.

Now, onto modifying your current files...

in the categories.php, lightbox.php, member.php, register.php, rss.php, top.php, index.php, postcards.php, search.php, and details.php files...
find
Code: [Select]
$user_access = get_permission();insert after
Code: [Select]
include_once(ROOT_PATH.'facebook/fbstatus.php');//MOD facebook connect
in the login.php file...
find
Code: [Select]
if ($site_sess->login($user_name, $user_password, $auto_login)) {insert after
Code: [Select]
//MOD facebook connect
if ($fbme){
$fb_userinfo=$site_sess->return_user_info();
if ($fb_userinfo['user_email'] !== $fbme['email']){
redirect($facebook->getLogoutUrl(array('next' => dirname(curPageURL()).'/'.$url)));
}
}
//END MOD facebook connect

Also in the details.php file...
find
Code: [Select]
"prepend_head_title"        => $image_name . " - ",insert after
Code: [Select]
"facebook_title"        => $image_name,
in the global.php file...
find
Code: [Select]
if (!defined('ROOT_PATH')) {
  die("Security violation");
}
insert after
Code: [Select]
if (!defined("IN_CP")) include_once(ROOT_PATH.'facebook/fbmain.php'); //MOD facebook connect

find
Code: [Select]
?>insert before
Code: [Select]
//MOD facebook connect
$fb_status=0;
//END MOD facebook connect

in the lang/english/main.php file...
find
Code: [Select]
?>insert before
Code: [Select]
//-----------------------------------------------------
//--- Facebook connect -------------------------------------
//-----------------------------------------------------
$lang['fbl_confirm'] = "\"To logout of Facebook also Select 'OK'\"";
$lang['fbl_lang'] = "en_US";// please see http://www.facebook.com/translations/FacebookLocales.xml
$lang['fbl_change_password'] = "Attention Facebook Users!";
$lang['fbl_passmessage'] = "If your account was created when you signed in with your Facebook account, then your password was randomly created.<br> You will need to <b>logout</b> of this site and click on <b>'forgot password'</b> to have a new one sent to you.";
$lang['fbl_sharing'] = "Facebook Sharing";

in the includes\page_header.php file...
find
Code: [Select]
$site_template->register_vars($array);insert after
Code: [Select]
//MOD facebook connect
if (strstr($site_sess->url($script_url."/".$self_url),'?')){
$fbstatus="&fb_status=1";
}else{
$fbstatus="?fb_status=1";
}
$site_template->register_vars(array("fb_status"=>$fbstatus));
//END MOD facebook connect

find
Code: [Select]
//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------
insert before
Code: [Select]
//MOD facebook connect
$fbl_loggedin = ($fbme)?1:0;
$fb_url = $site_sess->url($script_url."/".$self_url);
if (strpos($fb_url,"&")){
$fb_url=substr($fb_url,0,strpos($fb_url,"&"));
}
$site_template->register_vars(array(
    "fb_appid" => FBAPPID,
"fbl_loggedin" => $fbl_loggedin,
"fbl_confirm" => $lang['fbl_confirm'],
"fbl_lang" => $lang['fbl_lang'],
"fbl_passmessage" => $lang['fbl_passmessage'],
"fbl_sharing" => $lang['fbl_sharing'],
"fb_url" => $fb_url)
);
unset($fbl_loggedin,$fb_url);
//END MOD facebook connect

in the includes\sessions.php file...
find
Code: [Select]
"user_icq" => "user_icq"replace with
Code: [Select]
"user_icq" => "user_icq",
  "fb_userid" => "fb_userid"
 
find
Code: [Select]
function logout($user_id) {insert before
Code: [Select]
//MOD facebook connect
  function fb_login($user_name = "", $user_password = "", $auto_login = 0, $set_auto_login = 1) {
    global $site_db, $user_table_fields;

    if (empty($user_name) || empty($user_password)) {
      return false;
    }
    $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_id = (isset($row[$user_table_fields['user_id']])) ? $row[$user_table_fields['user_id']] : GUEST;
    if ($user_id != GUEST) {
      if ($row[$user_table_fields['user_password']] == $user_password) {
        $sql = "UPDATE ".SESSIONS_TABLE."
                SET session_user_id = $user_id
                WHERE session_id = '".addslashes($this->session_id)."'";
        $site_db->query($sql);
        if ($set_auto_login) {
          $this->set_cookie_data("userpass", ($auto_login) ? $user_password : "");
        }
        $this->start_session($user_id, 1);
        return true;
      }
    }
    return false;
  }
//END MOD facebook connect

The following modifications are using the default template as a model...
yours may be different...


in the your_template_folder\header.html file...
find
Code: [Select]
<html dir="{direction}">insert after
Code: [Select]
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">

find
Code: [Select]
{if has_rss}insert before
Code: [Select]
<script language="JavaScript">
<!--
function fb_confirm_entry()
{
FB.getLoginStatus(function(response){
if (response.session){
input_box=confirm({fbl_confirm});
if (input_box==true){FB.logout(function(response){});}}});
}
-->
</script>

find
Code: [Select]
<body bgcolor="#FFFFFF" text="#0F5475" link="#0F5475" vlink="#0F5475" alink="#0F5475">
<br />
insert after
Code: [Select]
   <div id="fb-root"></div>
        <script type="text/javascript">
            window.fbAsyncInit = function() {
                FB.init({appId: '{fb_appid}', status: true, cookie: true, xfbml: true});

                /* All the events registered */
                FB.Event.subscribe('auth.login', function(response) {
                    // do something with response
                    login();
                });
                FB.Event.subscribe('auth.logout', function(response) {
                    // do something with response
                    logout();
                });
            };
            (function() {
                var e = document.createElement('script');
                e.type = 'text/javascript';
                e.src = document.location.protocol +
                    '//connect.facebook.net/{fbl_lang}/all.js';
                e.async = true;
                document.getElementById('fb-root').appendChild(e);
            }());

            function login(){
                document.location.href = '{self_full}{fb_status}';
            }
            function logout(){
                document.location.href = '{self_full}{fb_status}';
            }
</script>

in the your_template_folder\member_editprofile.html file...
at the end of the document or after the change password form insert this code
Code: [Select]
{if fbl_loggedin}
<br />
  <table width="100%" border="0" cellspacing="0" cellpadding="1">
    <tr>
      <td valign="top" class="head1">
        <table width="100%" border="0" cellpadding="4" cellspacing="0">
          <tr>
            <td colspan="2" valign="top" class="head1">{fbl_change_password}</td>
          </tr>
          <tr>
            <td class="row1">{fbl_passmessage}</td>
          </tr>
        </table>
      </td>
    </tr>
  </table>
{endif fbl_loggedin}

in the your_template_folder\user_loginform.html file...
find
Code: [Select]
» <a href="{url_register}">{lang_register}</a><br>&nbsp;</td>insert after
Code: [Select]
 </tr><tr><td valign="top" align="center">
{if fbl_loggedin}
<table width="100%" border="0"><tr><td align="right">
<fb:profile-pic uid='loggedinuser' facebook-logo='false'></fb:profile-pic></td><td valign="center" align="left"> Welcome,<BR> <fb:name uid='loggedinuser' useyou='false'></fb:name>
</td></tr></table>
{endif fbl_loggedin}
 <fb:login-button size="small" length="long" autologoutlink="true" perms="email,user_website,publish_stream"></fb:login-button>
</td>

in the your_template_folder\user_logininfo.html file...
find
Code: [Select]
» <a href="{url_logout}">{lang_logout}</a><br>&nbsp;</td>replace with
Code: [Select]
» <a href="{url_logout}" onclick="fb_confirm_entry()">{lang_logout}</a></td>
 </tr><tr><td valign="top" align="center">
{if fbl_loggedin}
<table width="100%" border="0"><tr><td align="right">
<fb:profile-pic uid='loggedinuser' facebook-logo='false'></fb:profile-pic></td><td valign="center" align="left"> Welcome,<BR> <fb:name uid='loggedinuser' useyou='false'></fb:name>
</td></tr></table>
{endif fbl_loggedin}
 <fb:login-button size="small" length="long" autologoutlink="true" perms="email,user_website,publish_stream"></fb:login-button>
 </td>
     
You can now integrate the social plugins that Facebook offers for your 4images site...
they can be found here... http://developers.facebook.com/plugins

I added the "Like and the Share" buttons to my details pages of my site with the following code...
in the your_template_folder\details.html file...
find
Code: [Select]
<tr>
                            <td valign="top" class="row2"><b>{lang_keywords}</b></td>
                            <td valign="top" class="row2">{image_keywords}</td>
                          </tr>
insert before
Code: [Select]
 <tr>
                            <td valign="top" class="row1" width="33%">
<b>{fbl_sharing}</b><br><br><center><fb:share-button  type="button_count" href="{fb_url}">
<meta name="title" content="{facebook_title}"/>
<meta name="description" content="{image_description}"/>
<link rel="image_src" href="{facebook_image}" />
</fb:share-button></center></td>
                            <td valign="top" class="row1">
<fb:like width="66%" href="{fb_url}">
<meta name="title" content="{facebook_title}"/>
</fb:like>
</td>
                          </tr>

The
Code: [Select]
<meta name="title" content="{facebook_title}"/> is using the imagename for its title.
If you are using a better dynamic title on your detail pages I would suggest replacing the {facebook_title} with the variable for that mod for a better title for your image.

There are allot of issues with the like/share buttons as of creating this mod,
sometimes they show thumbnails, sometimes not. sometimes adds correctly, sometimes not.
The issues are with facebook and not with anything I have done. (Do not ask me to fix anything regarding those issues unless you can prove it is in my code causing the problem!)

There are some unusual things that happen from time to time, and if anyone can look my coding over and see if it is secure I would appriciate it.
I also would have like putting the include statements in the global.php file instead of all the others but it never worked when I did that so if anyone can help there it would make future changes easier.



8
Programming / Working with DPI with images...
« on: December 05, 2009, 09:12:13 PM »
Is it possible to keep the DPI of images when you are resizing them with any of the graphic libraries?

I am posting this in regards to my [MOD] Multi Size Download of same image [ver 3.1]... but not really a question for just that mod so I thought I would post it here instead.

I noticed that when using the GD library to re-size from a larger file it comes across as 96dpi and not the original 250dpi the original file was in,
the only way I can think of fixing this would be to re-size my images on my computer using photoshop and uploading them to the server as the different size files to keep the DPI ratio consistent. Is this request beyond PHP ability or am I just not looking in the right spot?

Thanks for any direction/advice anyone can send my way...

9
Discussion & Troubleshooting / regarding lang files...
« on: June 27, 2009, 09:18:16 PM »
What am I overlooking????
I thought I could easily copy translated words from English to Russian into the Russian lang folder but nooooo way...
Here is what I tried...
I went to google's translate, put in my English sentence, clicked translate, copied translated sentence, pasted it in the Russian language file and it displayed all ??????????????????  for the sentence.
I then went to bing.com translator and it copied the data better but still not right.
I then opened the lang file in regular windows notepad, pasted the info into the file, it looked correct.
when I went to save it, it says I needed to save it as unicode format and I said yes.
Then the entire file from top to bottom was destroyed with all sorts of weird characters and nothing on the webpage was displayed correctly anymore so I had to revert back to the original lang file...

What am I not doing correctly and what is the proper way of doing this?

thanks for any help!

10
Mods & Plugins (Releases & Support) / [MOD] Left Gallery QuickList
« on: April 25, 2009, 10:31:46 PM »
[MOD] Left Gallery Quick List V1.03

I was asked by another person if this could be done or not so I gave it a try and it worked!
It is based on JQuery's Treeview script that can be found at
http://docs.jquery.com/Plugins/Treeview

Demo: http://www.budduke.com/gallery

Backup the following files before you begin...
includes/page_header.php
includes/functions.php
lang/english/main.php
your template folder/home.html
your template folder/categories.html
your template folder/header.html


Revisions:
1.0 first try at it
1.01 fixed page number problem with modifield jquery.treeview.js file
1.02 fixed session issue problems and location highlighting when page#rs involved.
  • replace the jquery.treeview.js file with the new one in the zip file attached
  • replace the insert in the header.html and the functions.php files to fix these issues
1.03 fixed the hide list till page load problem with the updated code.


Let's begin with the mod...


New files added in attached zip file (The Treeview script from jquery)
In your template folder create a folder and call it "quickscript" and copy all files from the zip folder to that directory along with a sub folder called images...
the finished path should look likt templates/your template directory/quickscript/images


in the includes/page_header.php file
look for
Code: [Select]
?>insert before
Code: [Select]
//-----------------------------------------------------
//--- MOD Left Quicklist -------------------------------
//-----------------------------------------------------
$left_quicklist = get_left_quicklist($cat_id);
$site_template->register_vars(array(
"left_quicklist"   => $left_quicklist,
"lang_left_quicklist" => $lang['left_quicklist']
));
unset($left_quicklist);
// END MOD Left quicklist

in the includes/functions.php file (updated for version 1.03)
look for
Code: [Select]
?>insert before
Code: [Select]
//MOD Left QuickList
function get_left_quicklist_bits($cat_id, $cid = 0, $depth = 1) {
  global $site_db, $drop_down_cat_cache, $cat_cache, $site_sess;
//config area
$left_quick_length=24; //length of category name, 0-3 =off (if on, will shorten name to fit with ... after it)
$adjust_depth=1; // try to adjust for depth for right side to line up
$with_folder=0; // if you want a folder to be displayed then set this to 1 (I thought it took to much screenspace)
//end config
  if (!isset($drop_down_cat_cache[$cid])) {
    return "";
  }
  $category_list = "";
  foreach ($drop_down_cat_cache[$cid] as $key => $category_id) {
    if (check_permission("auth_viewcat", $category_id)) {
$quick_cat_name=format_text($cat_cache[$category_id]['cat_name'],2);
$left_quick_length_var= $left_quick_length;
$test=strlen($quick_cat_name);
if ($adjust_depth && ($depth >1)){
$left_quick_length_var = $left_quick_length -(($depth-1)*3) -(($depth-1)*$with_folder);
}
if (($left_quick_length_var > 3)  && (strlen($quick_cat_name)> $left_quick_length_var) ){
$quick_cat_name= substr($quick_cat_name, 0, ($left_quick_length_var - 3))."...";
}
if ($with_folder){
$category_list .= "<li><span class='folder'><a href='".$site_sess->url('categories.php?'.URL_CAT_ID.'='.$category_id)."'>".$quick_cat_name."</a></span>";
}
else {
      $category_list .= "<li><a href='".$site_sess->url('categories.php?'.URL_CAT_ID.'='.$category_id)."'>".$quick_cat_name."</a>";
      }
 $result= get_left_quicklist_bits($cat_id, $category_id, $depth + 1);
  if ($result){
$category_list .= "<ul>".$result."</ul></li>";
}
else {
$category_list .= "</li>";
}
   }
   }
  unset($drop_down_cat_cache[$cid]);
  return $category_list;
}

function get_left_quicklist($cat_id) {
  global $drop_down_cat_cache, $cat_parent_cache;
  $category = "<ul id='left_quicklist_nav' class='filetree' style='display: none'>";
  $drop_down_cat_cache = array();
  $drop_down_cat_cache = $cat_parent_cache;
  $result= get_left_quicklist_bits($cat_id);
  if ($result){
$category .= $result."</ul>";
   }  
  return $category;
}
//END MOD Left QuickList


in the lang/english/main.php file
look for
Code: [Select]
?>insert before
Code: [Select]
//-----------------------------------------------------
//--- Left Quick List -------------------------------------
//-----------------------------------------------------
$lang['left_quicklist'] = "Gallery Quick List";


in your template folder/header.html file (updated for version 1.03)
look for
Code: [Select]
</head>insert before
Code: [Select]
<!-- MOD Left Quicklist -->
<link rel="stylesheet" href= "{template_url}/quickscript/jquery.treeview.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script src= "{template_url}/quickscript/jquery.treeview.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
var urlSessName = "<?=SESSION_NAME;?>";
var urlPageName = "<?=URL_PAGE;?>";
$(document).ready(function(){

// first example
$("#left_quicklist_nav").treeview({
collapsed: true,
unique: true,
persist: "location"
});
});
onload=function() {
     document.getElementById('left_quicklist_nav').style.display ='block';
 }
</script>
<!-- END MOD Left Quicklist -->


in both your template folder/home.html and your template folder/categories.html files
Place this code where you would like to display the list on the left side
My example look for
Code: [Select]
{endif random_image}insert after in both files...
Code: [Select]
 <!--MOD left Quicklist-->
                  <table width="150" border="0" cellspacing="0" cellpadding="0">
                    <tr>
                      <td class="head2" height="20"> <img src="{template_url}/images/spacer.gif" alt="" width="4" height="4" />{lang_left_quicklist}</td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                    <tr>
                      <td>
                        {left_quicklist}
                      </td>
                    </tr>
                    <tr>
                      <td class="tablebgcolor"><img src="{template_url}/images/spacer.gif" alt="" width="1" height="1" /></td>
                    </tr>
                  </table>
 <!-- END MOD Left Quicklist-->

In the includes/functions.php file you will see at the start of my functions some config settings that you can play with
If your sub categories go real real real deep you may want to place this somewhere else on your template to give it more room.

Inside the quickscript folder there is a jquery.treeview.css file that you can modify to fit into your template better.
The .treeview, .treeview ul and the .treeview ul both at the top of the css file were the best place I found to modify to get the background color to match your template.
There is also .treeview a.selected area that is the background color used for the category you are currently viewing

That is the end of modification, you should now have a quicklist on your site...






 

11
Mods & Plugins (Releases & Support) / [MOD] User Categories Area
« on: April 19, 2009, 11:10:01 PM »
MOD 2.02 User Categories Area

This mod was a big undertaking on my part out of necessity to use on my own website.
I saw other attempts to create this but they leave out things I needed so I borrowed their creations and made them work nicely together along with some of my own improvements

This mod makes changes to your database so please backup and test on a testing server before undertaking a public site!! You have been warned!!!

The mods that I used to create this one are…
http://www.4homepages.de/forum/index.php?topic=18564.0[MOD] V1.3 Let users add (sub-)categories / User erstellen (Sub-)Kategorien
http://www.4homepages.de/forum/index.php?topic=20657.0[MOD] - Multiupload (thunderstrike version)

I actually used the attachment on reply #35 of this thread, it worked fine for me.
Version 2.0 has added support for dropdown fields for additional user field MOD
http://www.4homepages.de/forum/index.php?topic=7112.0[MOD] Dropdown options for custom database fields
and
http://www.4homepages.de/forum/index.php?topic=7385.0[MOD] Select country and gender with gif when register
as my test fields.
you will need to install at least the first one to work with this mod. If you do not use these mods, my script will detect that and just not let you use that part of the setup.

Could not remember link of mod that I used but it was the auto resize mod with big folder mod
(if you need to use make sure you add all of this mod to your site first)

What does this mod do?
1. As administrator you can create a category that will house user categories of your choosing that they can upload files to and create/delete categories of their choosing under their user area.
1a. (NEW IN VER 2.0) Administrator can now set home categories based on additional_user_fields Dropdown lists MOD
2. You can set each user as either direct upload or validation on files.
3. When you give a user permission the system will create their category for them under the category that you choose in admin panel and give them the correct permissions to modify under their own sub categories.
3a. (NEW IN VER 2.0) You can set settings so any new user can create an area without your input
4. You can have a log of category creation/deletions created for this area to see if you have any problems with certain users.
5. With the multiupload mod added to this mod, the users can upload more than one file at a time.
6. I have added the big folder mod for uploading (can be turned on/off)
7. I have added if no image name inserted then it will use the filename instead (can be turned on/off)
8. Mod is template friendly (at least the templates I was playing with)
9. Look at screen shots attached to understand MOD better (Sorry, no demo site)

I have tested this mod on a fresh install of 4images 1.7.7 using the default template and everything works as it should.


A couple of notes before you get started.
1. I have always noticed that in the auto resize big folder mod, unless I installed in incorrectly, it would copy the original file to the big folder and resize the image to the max values set in the admin panel and displayed in the upload form. For the end user, I needed it to give them a max upload value like 1920X1200 and resize down to 480X480 for the details page, so I set the admin panel to 1920X1200 and in the constants.php file I made two new values of 480X480 for the details page. The end user now sees the 1920X1200 on the upload form and errors out when they try to upload bigger and I still get smaller file on my detail page. In order for this to work I had to do this modification to original auto resize mod

 In the includes/upload.php file
look for
Code: [Select]
if ($this->auto_image[$this->image_type]) {
        $ok = 1;
     }
replace with…
Code: [Select]
/*if ($this->auto_image[$this->image_type]) {
        $ok = 1;
     }*/ 

If you do not make this modification then the user can upload any dimension file they want as long as it does not reach the megabyte file size limit set in the admin panel.
2. I saw the [all in one] mod that does watermarks and histograms as well as the resize on upload; I do not use them so I have never installed that mod. If enough people ask I may install it and see how to insert that code into this mod.
3. I am not sure how this stands up in security. I tried all hacks I could think of and it seems pretty stable/secure,
4. If you look at the addition to the style.css file, you should be able to modify the colors/fonts to fit into your site without modifying a bunch of my code.
5. To make this mod fit into your template better, instead of using my user_categoriesform.html file, use one of your templates other main display files and place this information in the main body of the page and save it as user_categoriesform.html and it should work.
Code: [Select]
<span class="title">{lang_user_area}</span>
<hr size="1" />
{content}
{msg}

Revisions history…
2.02 major mistake in my coding regarding sessions
Changed files in version 2.02
Added new lang data to main.php file so admin.php language is not needed for end users and used just for the admin panel.
Please download new zip file for the changed files and also place the new language data in the main.php file.
  • changed user_multiupload.php in zip file.
  • changed includes/user_functions.php in zip file.
  • changed templates/default/member_user_multiupload_content.html in zip file.
2.01 major mistake in my coding,
Changed files in version 2.01
Please download new zip file
  • changed user_categories.php in zip file
  • changed user_multiupload.php in zip file.
  • changed includes/user_functions.php in zip file.
2.00 Added support for additional_user_fields dropdown MOD, cleaned some of the code up a little
1.03 found error when I added Captcha, updated user_categories.php file in zip file again.
1.02 found error in the database install file. please read note at bottom of post
1.01 added Captcha to adding new categories to stop automated scripts from killing site
Changed files in version 1.01
  • changed user_categories.php in zip file, please download new file
  • changed Global.php, look at first two changes in mods to see what is different
1.0 first try at it.

Things I would like to see added/modified are…
1. the [all in one mod] to handle everyone’s needs.
2. Would like a plug-in in the admin panel that could list all users with fields to change multiple settings for this mod in one shot like the batch image edit mod that V@no created.
3. make the log better, not sure if I did it correctly but it works for my purposes.
4. would like to give users the ability to move images between their own categories (don’t even know where to begin on that one) for now, they can just contact the admin to do it.



If you are ready to begin adding this mod, let’s get started…
Warning (NOT a 5 minute install) Took me 5 weeks to get it running this smooth for you…
BACKUP YOUR DATABASE AND FILES BEFORE YOU START!

New files added included in attached zip file…
install_user_categories.php  (delete after you run this file once!)
user_categories.php (UPDATED FILE FOR VER 2.0)
user_multiupload.php
includes/user_functions.php (UPDATED FILE FOR VER 2.0)
admin/plugins/user_categories_mod.php (NEW FILE FOR VER 2.0)
templates/your template folder/user_categoriesform.html
templates/your template folder/member_user_multiuploadform.html
templates/your template folder/member_user_multiuploadform_select.html
templates/your template folder/member_user_multiupload_content.html
templates/your template folder/images/user_multiupload.gif
templates/your template folder/images/user_multiupload_off.gif
templates/your template folder/images/folder_path.gif

Place the install_user_categories.php file in your gallery root directory and run the file to add the fields to your databases.
Delete this file from your root after you run it!
(Do not need to run this installer is upgrading from version 1.03 to 2.0 version of this mod)

The following fields are created in case you need to remove them for troubleshooting
Settings table-   
  • user_submitted_enable
  • user_submitted_maincat
  • user_submitted_default_direct
  • user_submitted_log
  • user_multiupload_size
  • user_submitted_default_create (NEW FOR ver2.0, will be autocreated if not there)
Groupaccess table-
  • auth_user_manage
   
Categories table-
  • auth_user_manage
   
Users table-
  • user_submitted_allow
  • user_submitted_direct
  • user_submitted_parent

The following files are modified (BACKUP FIRST!)
Categories.php
Global.php
Login.php (maybe?)
Logout.php (maybe?)
registar.php (new to list for ver 2.0)
Admin/admin_functions.php (new to list for ver 2.0)
Admin/categories.php
Admin/settings.php (mod can be removed from this file for ver 2.0)
Admin/usergroups.php
Includes/auth.php
Includes/constants.php
Includes/db_field_definitions.php
Includes/functions.php
Includes/page_header.php
Includes/sessions.php
Lang/English/main.php
Lang/English/admin.php
Templates/your template/categories.html
Templates/your template/style.css


Start of modifications...

in admin/admin_functions.php file... (New Modification for ver 2.0)

look for...
Code: [Select]
show_input_row($val[0], $field_name, $value);Replace with
Code: [Select]
  //MOD User Categories
  if (substr($field_name,0,21)=='user_submitted_parent'){
    show_user_parent_input_row($val[0],$field_name,$value);
  }
  else{
        show_input_row($val[0], $field_name, $value);
      }
  //END MOD User Categories

look for...
Code: [Select]
?>insert Before
Code: [Select]
//MOD User Categories
function show_user_parent_input_row($title, $name, $value = "", $size = "") {
  global $HTTP_POST_VARS;
  if (isset($HTTP_POST_VARS[$name])/* && $value == ""*/) {
    $value = stripslashes($HTTP_POST_VARS[$name]);
  }
  echo "<tr class=\"".get_row_bg()."\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>".show_user_parent_dropdown_list_mod($name,$value)."</p></td>\n</tr>\n";
}
function show_user_parent_dropdown_list_mod($setting_name, $setting_value){
$var = get_user_parent_dropdown_mod($setting_value,$setting_name);
return $var;
}
function get_user_parent_dropdown_mod($cat_id,$setting_name) {
  global $lang, $drop_down_cat_cache, $cat_parent_cache;
    $category = "\n<select name=\"".$setting_name."\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['no_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    $drop_down_cat_cache = array();
    $drop_down_cat_cache = $cat_parent_cache;
$category .= get_user_category_dropdown_bits($cat_id);
    $category .= "</select>\n";
return $category;
}
//END MOD User Categories

in admin/categories.php file...

look for
Code: [Select]
  "auth_postcomment" => AUTH_USERreplace with
Code: [Select]
  "auth_postcomment" => AUTH_USER,
  "auth_user_manage" => AUTH_ACL

look for
Code: [Select]
      $error_log[] = $lang['cat_delete_error']." <b>".format_text($cats['cat_name'], 2)."</b> (ID: ".$cats['cat_id'].")";
    }
insert after
Code: [Select]
//MOD User Categories
$sql = "UPDATE ".USERS_TABLE."
SET user_submitted_parent = 0
WHERE user_submitted_parent = ".$cats['cat_id'];
    $site_db->query($sql);
//END MOD User Categories
         

look for
Code: [Select]
    $error_log[] = $lang['cat_delete_error']." <b>".format_text($cat_cache[$cat_id]['cat_name'], 2)."</b> (ID: ".$cat_id.")";
  }
insert after
Code: [Select]
//MOD User Categories
$sql = "UPDATE ".USERS_TABLE."
SET user_submitted_parent = 0
WHERE user_submitted_parent = ".$cat_id;
    $site_db->query($sql);
//END MOD User Categories
         

look for Twice
Code: [Select]
  $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];insert after both places
Code: [Select]
  $auth_user_manage = $HTTP_POST_VARS['auth_user_manage'];
look for
Code: [Select]
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage
look for
Code: [Select]
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment";
replace with
Code: [Select]
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $auth_user_manage
look for
Code: [Select]
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
$sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage

look for
Code: [Select]
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
replace with
Code: [Select]
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, auth_user_manage = $auth_user_manage

look for
Code: [Select]
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
$sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage

look for twice
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace Both with
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage


in the admin/settings.php file (no longer needed for Ver 2.0) (mods can be removed from this file)

look for
Code: [Select]
// end of functionsinsert before (Remove this code for ver 2.0)
Code: [Select]
//MOD user categories
function show_category_dropdown_list($setting_name, $setting_value){
$var = get_user_category_dropdown($setting_value,"",2);
echo $var;
}
function show_user_submitted_log_options($setting_name, $setting_value) {
  global $user_submitted_log_optionlist;
  foreach ($user_submitted_log_optionlist as $key => $val) {
    echo "<input type=\"radio\" name=\"setting_item[".$setting_name."]\" value=\"$key\"";
    if ($setting_value == $key) {
      echo " checked=\"checked\"";
    }
    echo "> ".$val."<br />";
  }
}
//END MOD user categories

look for
Code: [Select]
  show_form_footer($lang['save_changes'], "", 2);
}
insert before (Remove this code for ver 2.0)
Code: [Select]
// MOD user Categories area
  show_table_separator($setting_group[XX], 2, "setting_group_XX");//replace XX with next number in sequence looking at above $setting_group
  show_setting_row("user_submitted_enable","radio");
  show_setting_row("user_submitted_maincat","show_category_dropdown_list");
  show_setting_row("user_submitted_default_direct", "radio");
  show_setting_row("user_submitted_log", "show_user_submitted_log_options");
  show_setting_row("user_multiupload_size");
//END MOD user Categories area

look at $setting_group[##] before this insert and add 1 to the number and replace both XX in the above insert with that new number
Write this new number down for later insert!
example, if last number is 10 your line from insert above should look like this...
 
Code: [Select]
show_table_separator($setting_group[11], 2, "setting_group_11");//replace XX with next number in sequence looking at above $setting_group 
in admin/usergroups.php file

look for
Code: [Select]
  "auth_postcomment"replace with
Code: [Select]
  "auth_postcomment",
  "auth_user_manage"

look for
Code: [Select]
    $auth_postcomment = (isset($auth[$key]['auth_postcomment']) && $auth[$key]['auth_postcomment'] == 1) ? 1 : 0;insert after
Code: [Select]
    $auth_user_manage = (isset($auth[$key]['auth_user_manage']) && $auth[$key]['auth_user_manage'] == 1) ? 1 : 0;
look for
Code: [Select]
    if ($auth_viewcat || $auth_viewimage || $auth_download || $auth_upload || $auth_directupload || $auth_vote || $auth_sendpostcard || $auth_readcomment || $auth_postcomment) {
      $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
              (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
              VALUES
              ($group_id, $key, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
replace with.. (make sure you do not have any other mod fields added in this area, you will need to re-add them)
Code: [Select]
    if ($auth_viewcat || $auth_viewimage || $auth_download || $auth_upload || $auth_directupload || $auth_vote || $auth_sendpostcard || $auth_readcomment || $auth_postcomment || $auth_user_manage) {
      $sql = "INSERT INTO ".GROUP_ACCESS_TABLE."
              (group_id, cat_id, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, auth_user_manage)
              VALUES
              ($group_id, $key, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $auth_user_manage)";

in registar.php file (New modification for ver 2.0)

look for
Code: [Select]
    $activationkey = get_random_key(USERS_TABLE, get_user_table_field("", $user_table_fields['user_activationkey']));
insert Before
Code: [Select]
//MOD User Categories
    $additional_field_sql .= ", user_submitted_allow, user_submitted_direct, user_submitted_parent";
    $additional_value_sql .= ", '".$config['user_submitted_default_create']."', '".$config['user_submitted_default_direct']."', '0'";
//END MOD User categories

in global.php file

look for
Code: [Select]
$captcha_path                = ROOT_PATH.'captcha';insert before changed in version 1.01
Code: [Select]
$captcha_enable_user_multiupload  = 0;//set to what you want it to be
$captcha_enable_user_category_add = 1;//set to what you want it to be

look for
Code: [Select]
if (!$captcha_enable) {
  $captcha_enable_comments     = 0;
  $captcha_enable_upload       = 0;
insert after changed in version 1.01
Code: [Select]
  $captcha_enable_user_multiupload  = 0;
  $captcha_enable_user_category_add = 0;
 
look for
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
replace with
Code: [Select]
$sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment,auth_user_manage

in categories.php file in your gallery root directory

look for
Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}
replace with
Code: [Select]
//-----------------------------------------------------
//--- Show Categories ---------------------------------
//-----------------------------------------------------
/*if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
}
*/
if (!check_permission("auth_upload", $cat_id)) {
  $upload_url = "";
  $upload_button = "<img src=\"".get_gallery_image("upload_off.gif")."\" border=\"0\" alt=\"\" />";
  if (isset($config['user_multiupload_size']) && $config['user_multiupload_size'] > 1 ) {
    $user_multiupload_url = "";
    $user_multiupload_button = "<img src=\"".get_gallery_image("user_multiupload_off.gif")."\" border=\"0\" alt=\"\" />";
  }
}
else {
  $upload_url = $site_sess->url(ROOT_PATH."member.php?action=uploadform&amp;".URL_CAT_ID."=".$cat_id);
  $upload_button = "<a href=\"".$upload_url."\"><img src=\"".get_gallery_image("upload.gif")."\" border=\"0\" alt=\"\" /></a>";
  if (isset($config['user_multiupload_size']) && $config['user_multiupload_size'] > 1 ) {
    if ($user_info['user_level'] == GUEST) {
      $user_multiupload_url = "";
      $user_multiupload_button = "<img src=\"".get_gallery_image("user_multiupload_off.gif")."\" border=\"0\" alt=\"\" />";
    }
    else {
      $user_multiupload_url = $site_sess->url(ROOT_PATH."user_multiupload.php?action=multiuploadform&amp;".URL_CAT_ID."=".$cat_id);
      $user_multiupload_button = "<a href=\"".$user_multiupload_url."\"><img src=\"".get_gallery_image("user_multiupload.gif")."\" border=\"0\" alt=\"\" /></a>";
    }
  }
}

look for
Code: [Select]
  "upload_button" => $upload_button,insert after
Code: [Select]
  "user_multiupload_button" => $user_multiupload_button,
in the includes/auth.php file

look for
Code: [Select]
, a.auth_postcommentreplace with
Code: [Select]
, a.auth_postcomment, a.auth_user_manage
in the includes/constants.php file

look for
Code: [Select]
?>insert before
Code: [Select]
//MOD user categories
define('USER_BIG_FOLDER' , '/big');//name of directory you are using for big or alternate download directory for big images
define('USER_DETAIL_WIDTH',480);// size width to display on detail page
define('USER_DETAIL_HEIGHT',480);// size height to display on detail page
define('USER_LOG_DIR', 'data/logs'); // directory to store log file in
define('USER_LOG_FILENAME', 'user_categories.log'); //name of log file
define('USER_AUTO_FILENAME', '1');//make 0 if you want to make user put a imageame in or set to 1 to use filename as imagename if left blank
define('USER_CAT_DESC', '1');//1= use auto description for main user cat description or 0 to leave blank
define('USER_AUTO_RESIZE', '1');// 1= use auto resize on upload, 0= do not use
//END MOD user categories

in the includes/db_field_definitions.php file

look for
Code: [Select]
?>insert before
Code: [Select]
//MOD user categories
$additional_user_fields['user_submitted_allow'] = array("Allowed to create a user category area", "radio", 1);
$additional_user_fields['user_submitted_direct'] = array("Allowed to direct upload to user category area", "radio", 1);
$additional_user_fields['user_submitted_parent'] = array("parent category for this user category area", "text", 1);
//END MOD user categories

in the includes/functions.php file

look for
Code: [Select]
?>insert before
Code: [Select]
// MOD user categories
function get_user_category_dropdown($cat_id, $jump = 0, $admin = 0, $i = 0) {
  global $lang, $drop_down_cat_cache, $cat_parent_cache;
  // $admin = 1  Main Cat (update/add cats)
  // $admin = 2  All Cats (find/validate images...)
  // $admin = 3  Select Cat (update/add image)
  // $admin = 4  No Cat (check new images)
  switch ($admin) {
  case 1:
    $category = "\n<select name=\"cat_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"156\">"."Your Main Root Gallery"."</option>\n";
    $category .= "<option value=\"156\">--------------</option>\n";
    break;

  case 2:
    $category = "\n<select name=\"setting_item[user_submitted_maincat]\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['main_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    $drop_down_cat_cache = array();
    $drop_down_cat_cache = $cat_parent_cache;
$category .= get_user_category_dropdown_bits($cat_id);
    $category .= "</select>\n";
return $category;
break;

  case 3:
    $i = ($i) ? "_".$i : "";
    $category = "\n<select name=\"cat_id".$i."\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 4:
    $category = "\n<select name=\"cat_id\" class=\"categoryselect\">\n";
    $category .= "<option value=\"0\">".$lang['no_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
    break;

  case 0:
  default:
    if ($jump) {
      $category = "\n<select name=\"".URL_CAT_ID."\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['jumpbox'].submit() }\" class=\"categoryselect\">\n";
    }
    else {
      $category = "\n<select name=\"".URL_CAT_ID."\" class=\"categoryselect\">\n";
    }
    $category .= "<option value=\"0\">".$lang['select_category']."</option>\n";
    $category .= "<option value=\"0\">-------------------------------</option>\n";
  } // end switch

  $drop_down_cat_cache = array();
  $drop_down_cat_cache = $cat_parent_cache;
  $category .= get_user_category_dropdown_bits($cat_id, $cat_id);
  $category .= "</select>\n";
  return $category;
}
function get_user_category_dropdown_bits($cat_id, $cid = 0, $depth = 1) {
  global $site_db, $drop_down_cat_cache, $cat_cache;
  if (!isset($drop_down_cat_cache[$cid])) {
    return "";
  }
  $category_list = "";
  foreach ($drop_down_cat_cache[$cid] as $key => $category_id) {
    if (check_permission("auth_upload", $category_id)) {
      $category_list .= "<option value=\"".$category_id."\"";
      if ($cat_id == $category_id) {
        $category_list .= " selected=\"selected\"";
      }
      if ($cat_cache[$category_id]['cat_parent_id'] == 0) {
        $category_list .= " class=\"dropdownmarker\"";
      }

      if ($depth > 1) {
        $category_list .= ">".str_repeat("--", $depth - 1)." ".format_text($cat_cache[$category_id]['cat_name'], 2)."</option>\n";
      }
      else {
        $category_list .= ">".format_text($cat_cache[$category_id]['cat_name'], 2)."</option>\n";
      }
      $category_list .= get_user_category_dropdown_bits($cat_id, $category_id, $depth + 1);
    }
  }
  unset($drop_down_cat_cache[$cid]);
  return $category_list;
}
// END MOD user categories

in the includes/page_header.php file

look for
Code: [Select]
  "url_upload" => (!empty($url_upload)) ? $site_sess->url($url_upload) : $site_sess->url(ROOT_PATH."member.php?action=uploadform"),insert after
Code: [Select]
  "url_user_multiupload" => (!empty($url_user_multiupload)) ? $site_sess->url($url_user_multiupload) : $site_sess->url(ROOT_PATH."user_multiupload.php"),
look for
Code: [Select]
//-----------------------------------------------------
//--- User Box ----------------------------------------
//-----------------------------------------------------
if ($user_info['user_level'] >= USER) {
  $site_template->register_vars("lang_loggedin_msg", preg_replace("/".$site_template->start."loggedin_user_name".$site_template->end."/siU", format_text($user_info['user_name'], 2), $lang['lang_loggedin_msg']));
insert after
Code: [Select]
// MOD User categories area
$user_submitted_allowed = 0;
if ($config['user_submitted_enable'] && $user_info['user_submitted_allow']){
$user_submitted_allowed = 1;
}
if ($user_info['user_submitted_parent']==0){
$user_submitted_url = "user_categories.php?action=createuser";
}
else {
$user_submitted_url = "user_categories.php";
}
$site_template->register_vars(array(
"user_submitted_allowed"   => $user_submitted_allowed,
"user_submitted_url" => $site_sess->url(ROOT_PATH.$user_submitted_url),
"lang_user_area" => $lang['usercat_user_area']
));
unset($user_submitted_allowed);
unset($user_submitted_url);
//END MOD User categories area
   
in the includes/sessions.php file

look for
Code: [Select]
  function logout($user_id) {
    global $site_db;
replace with
Code: [Select]
  function logout($user_id) {
    global $site_db,$site_sess;
$user_categories_log = $site_sess->get_session_var("user_categories_log");
if(isset($user_categories_log)){
include(ROOT_PATH.'includes/user_functions.php');
$var= user_categories_log_file($user_categories_log);
}

in the lang/english/admin.php file

look for
Code: [Select]
?>insert before (Updated insert for version 2.0)
Code: [Select]
// MOD user submited area
$lang['auth_user_manage'] = "User Manage";
$setting["user_submitted_area"] = "User Categories Area";
$setting["user_submitted_enable"] = "Enable user category area";
$setting["user_submitted_maincat"] = "Parent category for this area";
$setting["user_submitted_default_direct"] = "Allow direct upload as default setting";
$setting['user_submitted_log'] = "Would you like to record a log file for user activity?";
$setting['user_submitted_continue']= "Continue";
$user_submitted_log_optionlist = array(
  "0"  => "No",
  "1"  => "Yes, Record only errors",
  "2"  => "Yes, Record all activity"
);
// added for version 2.0
$user_submitted_enable_optionlist = array(
  "0"  => "No",
  "1"  => "Yes, Using one main area",
  "2"  => "Yes, Using category based on Additional User Field Dropdown Mod"
);
$setting['user_multiupload_size'] = "Set max value for user to upload images to gallery";
$setting['user_submitted_maincat_field']="Additional User Field Dropdown Field to use";
$setting['user_submitted_maincat1']="Main User Category Area using \"";
$setting['user_submitted_maincat2']="\" Dropdown Field";
$setting['user_submitted_maincat3']="Main User Category Area";
$setting['user_submitted_default_create']="Allow new users to create area without Admin involvement";
//end MOD user submitted area

in the lang/english/main.php file

look for
Code: [Select]
?>insert before (modified insert for version 2.0)
Code: [Select]
//-----------------------------------------------------
//--- User category area -------------------------------------
//-----------------------------------------------------
$lang['usercat_no_rights'] = 'You do not have the permission to access this page!';
$lang['usercat_create_abort'] = 'Your area was not created at this time.';
$lang['usercat_return_gallery'] = 'return to gallery';
$lang['usercat_aborted'] = 'changes were aborted';
$lang['usercat_catname1'] = ''; // this is the name of users main category when it is created(format "$lang['usercat_catname1'].$user_info['user_name'].$lang['usercat_catname2']")
$lang['usercat_catname2'] = '&#39;s collection'; //  (default is "username's collection")
$lang['usercat_catdesc1'] = 'This is '; //this is the description of users main category (format "$lang['usercat_catdesc1'].$user_info['user_name'].$lang['usercat_catdesc2']")
$lang['usercat_catdesc2'] = '&#39;s collection of uploaded files.'; // (default is "This is username's collection of files.")
$lang['usercat_deletehead'] = 'Summary of Deleting Categories';
$lang['usercat_create_main'] = 'Your area has not been created yet';
$lang['usercat_create_question'] = 'Do you wish to create your area now?';
$lang['usercat_area']= 'Your user area</span>';
$lang['usercat_editcat'] = 'Editing categories';
$lang['usercat_inside'] = ' inside ';
$lang['usercat_user_area'] = 'Your User Area';
$lang['usercat_edit'] = "[Edit]";
$lang['usercat_delete'] = "[Delete]";
$lang['usercat_add'] = "[Add Subcategory]";
$lang['usercat_upload'] = "[Upload Files]";
$lang['user_multiupload_file_title'] = "File no. ";
$lang['user_multiupload_select'] = "Select the number of images for upload:<br /><span class=\"smalltext\"><font color=\"red\">Note:</font> Check all field before upload.</span>";
$lang['user_multiupload_select_title'] = "Multiupload - select";
$lang['user_multiupload_file'] = "Multiupload files";
$lang['user_multiupload_empty_filename'] = "<br><span class='smalltext'>Will use filename if left blank</span>";
$lang['usercat_no_rights2'] = 'Based on your selections in your profile, You do not have the permission create an user area. Please contact Admin if you feel this is an error';
$lang['sub_categories'] = "Subcategories";
$lang['no_subcategories'] = "No subcategories added";
$lang['delete_cat_confirm'] = "Do you want to delete this category?<br />All subcategories as well as attached images and comments will be deleted!";
$lang['delete_cat_files_confirm'] = "Delete all image files from the server?";
$lang['cat_add_success'] = "Category added";
$lang['cat_add_error'] = "Error adding category";
$lang['cat_edit_success'] = "Category edited";
$lang['cat_edit_error'] = "Error editing category";
$lang['cat_delete_success'] = "Category deleted";
$lang['cat_delete_error'] = "Error while deleting category";
$lang['cat_order'] = "Category Order";
$lang['at_beginning'] = "At Beginning";
$lang['at_end'] = "At End";
$lang['after'] = "After";
$lang['nav_categories_add'] = "Add categories";
$lang['lostfield_error'] = "Please recheck the marked fields.";
$lang['image_delete_success'] = "Image deleted";
$lang['image_delete_error'] = "Error deleting image";
$lang['file_delete_success'] = "Image file deleted";
$lang['file_delete_error'] = "Error deleting image file.";
$lang['thumb_delete_success'] = "Thumbnail file deleted";
$lang['thumb_delete_error'] = "Error deleting thumbnail file";
$lang['comments_delete_success'] = "Comments deleted";
$lang['comments_delete_error'] = "Error deleting comments";
$lang['error_log_desc'] = "The following errors occurred:";
$lang['back_overview'] = "Back to overview";
$lang['save_changes'] = "Save changes";
$lang['back'] = "Back";
$lang['reset'] = "Reset";
$lang['add'] = "Add";
$lang['delete'] = "Delete";
$lang['field_category_name'] = "Category name";
$lang['field_description'] = "Description";
$lang['usercat_upload1'] = "Upload:";
$lang['usercat_url'] = "Url:";

in the templates/your template folder/categories.html file

look for
Code: [Select]
{upload_button}insert after or replace with
Code: [Select]
{user_multiupload_button}
in the templates/your template folder/user_logininfo.html file

look for
Code: [Select]
  &raquo; <a href="{url_control_panel}">{lang_control_panel}</a><br />insert after
Code: [Select]
{if user_submitted_allowed}
  &raquo; <a href="{user_submitted_url}">{lang_user_area}</a><br />
{endif user_submitted_allowed}

in the templates/your template folder/style.css file

insert at end of file
Code: [Select]
/* MOD User Categories
userhead1 is text in header at top
userhead2 is link text in header at top
user1 is text in table
user2 is link text in table
*/

.userhead1 {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}

.userhead2 {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.userhead2:link {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.userhead2:visited {
  background-color: #004C75;
  color: #fcdc43;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.userhead2:hover {
  background-color: #004C75;
  color: #FFFFFF;
  font-family: Tahoma, Verdana, Arial, Helvetica, sans-serif;
  font-size: 11px;
  font-weight: bold;
}
.user1 {
  color: #004C75;
}

.user2 {
  color: #004C75;
}
.user2:link {
  color: #004C75;
}
.user2:visited {
  color: #004C75;
}
.user2:hover {
  color: #000000;
}
/*END MOD user categories*/

not sure if you need these mods or not...
I had to insert them to get the site to redirect to the correct page when I login/logout.

in the login.php file

look for twice
Code: [Select]
&& !ereg("member.php", $url)replace Both with
Code: [Select]
&& !ereg("member.php", $url) && !ereg("user_multiupload.php", $url)
in the logout.php file

look for
Code: [Select]
&& !ereg("member.php", $url)replace with
Code: [Select]
&& !ereg("member.php", $url) && !ereg("user_multiupload.php", $url) && !ereg("user_categories.php", $url)

changes in 1.02
I made a big mistake in the install_user_categories.php file.
When it created the fields for the user database the field `user_submitted_parent` is suppose to be MEDIUMINT and not TINYINT(1)
I have changed the file to correct the error. You will need to delete the database fields created with the old one and run the new install_user_categories.php file to correct the error or if you know how to go into phpadmin and change the field to the correct fieldtype would be easier. I found it worked fine until you reached 128 for a category number.
Sorry for the oversite...

12
MOD Lightbox Limit for version 1.7.6

This mod allows you to limit the size of all users lightboxes by either total number of images or size of download zip file

This mod does not work on Remote files, I do not use them on my site and have not had the time to research that part of it.
NOTE:  the notes with BIG folder references in the function file, you need to change the /big/ to whatever you are using for your big folder.
            if you are not using a big folder mod, it should just skip that code and continue if it does not find a big folder.

I do not know if it will work on older version or not.

Please backup the following files and your database so things can be fixed easly in case something goes wrong

Modified files include
lightbox.php
globals.php
includes/functions.php
lang/english/main.php
Your template/lightbox.html

also you will need to run the attached lightbox_limit_install.php file in the root of your 4images gallery so it can add the new field to your lightbox database
or you can add it yourself by running this command in your phpadmin
Code: [Select]
ALTER TABLE `4images_lightboxes` ADD `lightbox_file_size` INT(11) NOT NULL DEFAULT '0'Make sure you delete the lightbox_limit_install.php file from your root folder after you run it!

The changes that need to be made in the functions file was tricky and mistakes can be made easly,
so I am just having you replace the entire lightbox functions with the ones I modified.
If you have other mods inside these functions, (add_to_lightbox, remove_from lightbox, clear_lightbox)
you may want to look at my replacing functions file and just put my mods inside of your files,
all my modified lines have "\\ Mod Lightbox Limit" labeled on them.

in includes/functions.php

search for...
Code: [Select]
function add_to_lightbox($id) {
  global $user_info, $site_db;
  $id = intval($id);
  if (!$id) {
    return false;
  }
  $lightbox_ids = $user_info['lightbox_image_ids'];
  $lightbox_array = explode(" ", $lightbox_ids);
  if (!in_array($id, $lightbox_array)) {
    $lightbox_ids .= " ".$id;
  }
  $user_info['lightbox_image_ids'] = trim($lightbox_ids);
  $user_info['lightbox_lastaction'] = time();
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id'];
  return ($site_db->query($sql)) ? 1 : 0;
}

function remove_from_lightbox($id) {
  global $user_info, $site_db;
  $lightbox_array = explode(" ",$user_info['lightbox_image_ids']);
  foreach ($lightbox_array as $key => $val) {
    if ($val == $id) {
      unset($lightbox_array[$key]);
    }
  }
  $user_info['lightbox_image_ids'] = trim(implode(" ", $lightbox_array));
  $user_info['lightbox_lastaction'] = time();
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id'];
  return ($site_db->query($sql)) ? 1 : 0;
}

function clear_lightbox() {
  global $user_info, $site_db;
  $current_time = time();
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_image_ids = '', lightbox_lastaction = $current_time
          WHERE user_id = ".$user_info['user_id'];
  if ($site_db->query($sql)) {
    $user_info['lightbox_image_ids'] = "";
    $user_info['lightbox_lastaction'] = $current_time;
    return true;
  }
  else {
    return false;
  }
}

Replace with...
Code: [Select]
function add_to_lightbox($id) {
  global $user_info, $site_db;
  global $lightbox_max_number_images, $lightbox_max_file_size; // Mod Lightbox Limit
  $id = intval($id);
  if (!$id) {
    return false;
  }
  $lightbox_ids = $user_info['lightbox_image_ids'];
  $lightbox_array = explode(" ", $lightbox_ids);
// Mod Lightbox Limit check if max # images reached
  if ($lightbox_max_number_images){ 
$lightbox_count = count($lightbox_array);
if ($lightbox_count == $lightbox_max_number_images){
return false; // would like to see a dialog popup saying max # images reached????
}
  }
// End Mod Lightbox Limit
  if (!in_array($id, $lightbox_array)) {
// Mod Lightbox Limit check size of lightbox zip file 
$sql = "SELECT cat_id, image_media_file
FROM ".IMAGES_TABLE."
WHERE image_id = '".$id."'" ;
$image_info = $site_db->query_firstrow($sql);
if (file_exists(MEDIA_PATH."/".$image_info[cat_id]."/big/".$image_info['image_media_file'])){  // replace big with your big folder lookup
$path = MEDIA_PATH."/".$image_info[cat_id]."/big/".$image_info['image_media_file'];} //use big folder image if found
else {$path = MEDIA_PATH."/".$image_info[cat_id]."/".$image_info['image_media_file'];}
$size = filesize($path);
$max_file_size = $lightbox_max_file_size * 1048576;
if(($user_info['lightbox_file_size'] + $size > $max_file_size) && ($lightbox_max_file_size > 0)){return false;} //would like to see a dialog saying filesize max reached????
$user_info['lightbox_file_size'] +=  $size;
// End Mod Lightbox Limit
$lightbox_ids .= " ".$id;
  }
  $user_info['lightbox_image_ids'] = trim($lightbox_ids);
  $user_info['lightbox_lastaction'] = time();
// Mod Lightbox Limit(added lighbox_file_size to sql variable)
  /*$sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id'];
  */
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."', lightbox_file_size = '".$user_info['lightbox_file_size']."'
          WHERE user_id = ".$user_info['user_id'];
// End Mod Lightbox Limit
  return ($site_db->query($sql)) ? 1 : 0;
}
function remove_from_lightbox($id) {
  global $user_info, $site_db;
  $lightbox_array = explode(" ",$user_info['lightbox_image_ids']);
  foreach ($lightbox_array as $key => $val) {
    if ($val == $id) {
      unset($lightbox_array[$key]);
// Mod Lightbox Limit
$sql = "SELECT cat_id, image_media_file
FROM ".IMAGES_TABLE."
WHERE image_id = '".$id."'" ;
$image_info = $site_db->query_firstrow($sql);
if (file_exists(MEDIA_PATH."/".$image_info[cat_id]."/big/".$image_info['image_media_file'])){  // your big folder lookup
$path = MEDIA_PATH."/".$image_info[cat_id]."/big/".$image_info['image_media_file'];} //use big folder image if found
else {$path = MEDIA_PATH."/".$image_info[cat_id]."/".$image_info['image_media_file'];}
$size = filesize($path);
$user_info['lightbox_file_size'] = $user_info['lightbox_file_size'] - $size;
if ($user_info['lightbox_file_size']<0){$user_info['lightbox_file_size']=0;}
// End Mod Lightbox Limit
}
  }
  $user_info['lightbox_image_ids'] = trim(implode(" ", $lightbox_array));
  $user_info['lightbox_lastaction'] = time();
// Mod Lightbox Limit (Added lightbox_file_size to sql variable)
  /*$sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."'
          WHERE user_id = ".$user_info['user_id'];
  */
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_lastaction = ".$user_info['lightbox_lastaction'].", lightbox_image_ids = '".$user_info['lightbox_image_ids']."', lightbox_file_size = '".$user_info['lightbox_file_size']."'
          WHERE user_id = ".$user_info['user_id'];
// End Mod Lightbox Limit
  return ($site_db->query($sql)) ? 1 : 0;
}

function clear_lightbox() {
  global $user_info, $site_db;
  $current_time = time();
// Mod Lightbox Limit
  /*$sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_image_ids = '', lightbox_lastaction = $current_time
          WHERE user_id = ".$user_info['user_id'];
  */
  $sql = "UPDATE ".LIGHTBOXES_TABLE."
          SET lightbox_image_ids = '', lightbox_lastaction = $current_time, lightbox_file_size = 0
          WHERE user_id = ".$user_info['user_id'];
// End Mod Lightbox Limit
  if ($site_db->query($sql)) {
    $user_info['lightbox_image_ids'] = "";
    $user_info['lightbox_lastaction'] = $current_time;
    $user_info['lightbox_file_size'] = 0; //Mod Lightbox Limit
return true;
  }
  else {
    return false;
  }
}

in Lightbox.php file

search for
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,

insert before
Code: [Select]
// Mod Lightbox Limit
$zip_file_size = round(($user_info['lightbox_file_size']/1048576),1);
// End Mod Lightbox limit

search for
Code: [Select]
  "lang_lightbox_lastaction" => $lang['lighbox_lastaction'],
 

insert after
Code: [Select]
// Mod Lightbox Limit
  "zip_file_size" => $zip_file_size,
  "lightbox_max_number_images" => $lightbox_max_number_images,
  "lightbox_max_file_size" => $lightbox_max_file_size,
  "lang_lightbox_max_img_1" => $lang[lightbox_max_img_1],
  "lang_lightbox_max_img_2" => $lang[lightbox_max_img_2],
  "lang_lightbox_max_zip_1" => $lang[lightbox_max_zip_1],
  "lang_lightbox_max_zip_2" => $lang[lightbox_max_zip_2],
// End Mod Lightbox Limit

in global.php file
NOTE: this is where you will set your limits for the lightboxes

Search for
Code: [Select]
?>
insert before
Code: [Select]
// Mod Lightbox Limit
$lightbox_max_number_images = 30; //set to 0 for no limt
$lightbox_max_file_size = 15; // is in MB, set to 0 for no limit
// End Mod Lightbox limit

the next 2 files to be modified are not necessary unless you want the limits posted on your lightbox pages.
See attached screenshot.jpg if you want to decide if you want to see this or not.

in lang/english/main.php file

search for
Code: [Select]
?>
insert before
Code: [Select]
// Mod Lightbox Limit
$lang['lightbox_max_img_1'] = "(You can choose up to ";
$lang['lightbox_max_img_2'] = " items for your lightbox)";
$lang['lightbox_max_zip_1'] = " Meg zip file is maximun allowed.<br>Your current zip file size is around ";
$lang['lightbox_max_zip_2'] = " Megs";
// End Mod Lightbox Limit

This mod may depend on your own template, this is just a reference for placing...
in template/lightbox.html file

search for
Code: [Select]
<b class="title">{lang_lightbox}</b>
replace with
Code: [Select]
<b class="title">{lang_lightbox}</b>{if lightbox_max_number_images} {lang_lightbox_max_img_1}{lightbox_max_number_images}{lang_lightbox_max_img_2}{endif lightbox_max_number_images}
search for
Code: [Select]
<td align="right">{download_button}
replace with
Code: [Select]
<td align="right">{download_button}{if lightbox_max_file_size}<br>{lightbox_max_file_size}{lang_lightbox_max_zip_1}{zip_file_size}{lang_lightbox_max_zip_2}{endif lightbox_max_file_size}
The only drawback to this mod is that if you reach the limit it just shows "error adding image" on page refresh...
But if you are like me and using V@no MOD Add/Remove image to/from lightbox without page refresh http://www.4homepages.de/forum/index.php?topic=5321.0
all you will get when limit reached is "you are unable to check the checkbox"
I have added in the // area the words "would like to see" where I feel a dialog or something should popup and tell the user they reached the limit on thier lightbox but I have tried a few tricks I know and they did not work.
Hopefully someone else can add to this mod and really make it nice!

I want to thank everyone that PMed me with ideas and the help along the way, I just took all the ideas and cleaned things up and made it look as good as I could.
Enjoy!

Buddy Duke

13
Mods & Plugins (Requests & Discussions) / lightbox mod???
« on: January 07, 2009, 01:14:45 AM »
Ran into an issue at my site and searched around saw allot of questions but no answers to this problem...
A user put a bunch of images in thier lightbox, they got an error when trying to zip download. My server could not create a zip file larger then 20meg in size so it gave up.

Is there a mod that can monitor how big the zip file is when trying to send the lightbox images so it can stop at the server level that it can handle and just download what it is able to?

I also saw people asking if you can limit the number of images in a lightbox without any answers... this would probably work for my site also if there is an answer for it.

Since I am currently having this problem I will probably look into the script myself to see what can be done but would prefer just adding a mod that can do it easier then I will be doing it...

any ideas out there?

thanks,

14
[MOD] Multi download size ver 4.7
This MOD will allow your users to download multiple different sizes of one image.
see the attached screenshot to see what it looks like.

* You can modify the sizes in the Global.php file to set the range you want your users to download.
* Added variables in the global.php file for easy customizing of mod for your site.(New to ver 2.1)
* Added variables that you can now set crop settings to get actual size when resizing (New to ver 3.0)
* You can now have text links and image links instead of dropdown list (New to ver 2.1)
* You can select if the catagory uses this option or the normal download/zip option instead.
* You can set the category to only allow sizes smaller then original to be downloaded (New to ver 2.0)
* Original file is an option on the list, if your user does not want it resized. (New to ver 2.0)
* You only need to upload one size of the file and the server will do the rest for you (I am lazy)
  all the other mods I saw wanted you to create all the different sizes before you uploaded them.
  This mod will create the resized images at the time the user is asking for them.
* Also, if nobody ever downloads a 640X480 image then you do not have the extra images on your server.
* The MOD does check to see if it already created the size so it does not have to create it twice.
* If file is not an image you will get the normal download button instead.(New to ver 3.1)
* You can now group the button/links/dropdown for easier navigation. (New to ver 4.0)
* Now instead of downloading the images, you can have a popup window instead if you choose. (New to ver 4.0)
* Have added where it will detect the users screen resolution for easier choosing. (New to ver 4.0)
* added more selections in default list for mobile phones (New to ver 4.0)
* added exact ratio selection taken from original file for size selections. is turned off by default (New to ver 4.2)
* added a template for popup window (New to ver 4.4)

I was having a hard time creating a way to remove the extra files if you delete images/or move them.
I wound up just making a plugin that you run in the admin cp that will erase all resized images from the server.

This MOD was tested on a fresh install of 1.7.11 and everything worked fine

Changes made in Version 4.7
--Fixed a problem where not downloading on mobile devices using the dropdown list.

Changes made in Version 4.6
--Fixed a problem where not displaying image name in popup window.

Changes made in Version 4.5
--Fixed a problem where it was pulling the sizes from the random image instead of the main image on detail page

Changes made in Version 4.4
--I fixed a division by 0 error warning that I was getting with this mod.
--Added template for popup window.
--Added annotation link to resized image (if using that mod)
Changes made in Version 4.3
--I had a major problem with dealing with sessions on my links. They are repaired on this release.
--Good news, you only have to replace the insert in the includes/functions.php file to fix this error.

backup your database in case something goes wrong and also backup these files before you proceed.
I would also suggest using it on a testing site and not your main one in case something crashes
These are the files that will be modified...
details.php
download.php
global.php
admin/categories.php
includes/constants.php
includes/functions.php
lang/english/admin.php
lang/english/main.php
template/your template you are using/details.html

The zip file attached contains the plugin and the installer and the graphic buttons for your site.

The plugin needs to be placed in the
admin/plugins folder

place the multi_download_install.php in your root folder of your gallery and run it once so it can install the
new multi_download field into your categories table.
Make sure you delete it afterward for security.

in the global.php file

look for
Code: [Select]
 $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcommentreplace with
Code: [Select]
 $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
Code: [Select]
?>insert Before (changed in version 2) (updated in version 4.0) (updated in version 4.2)
Code: [Select]
// MOD multi download
$download_multi_sizes= array(
array('group1',0,0), //Groups are created in this format, group1 name is associated with a language entry with the same name (the 0,0 is important!)
array('800x600',800,600),
array('1024x768',1024,768),
array('1280x960',1280,960),
array('1400x1050',1400,1050),
array('1600x1200',1600,1200),
array('2048x1536',2048,1536),
array('group2',0,0),
array('1280x720',1280,720),
array('1366x768',1366,768),
array('1920x1080',1920,1080),
array('2560x1440',2560,1440),
array('group3',0,0),
array('1280x800',1280,800),
array('1440x900',1440,900),
array('1680x1050',1680,1050),
array('1920x1200',1920,1200),
array('2560x1600',2560,1600),
array('group4',0,0),
array('96x65',96,65),
array('101x80',101,80),
array('128x128',128,128),
array('128x160',128,160),
array('174x132',174,132),
array('240x320',240,320),
array('group5',0,0),
array('240x160',240,160),
array('240x260',240,260),
array('240x240',240,240),
array('320x240',320,240)
);
// the first field is the name that is shown in the list that you choose from
// the second field is the width
// the third field is the height
$multi_download_var['type'] = 0; //0=dropdown, 1=text links, 2=image links
$multi_download_var['columns'] = 4; // #of columns in table for links, not used for dropdown
$multi_download_var['button']="gif"; //type of file for your image link buttons gif,jpg,png
$multi_download_var['bold_groups']=1; //Bold option group labels (only for text links and buttons), 1=yes, 0=no
$multi_download_var['center_groups']=1; //Center option group labels (only for text links and buttons), 1=yes, 0=no
$multi_download_var['show_resolution']=1;// Display user's display resolution, 1=yes, 0=no
$multi_download_var['download']=1; //display "select size to download at top of table" 1=yes, 0=no
$multi_download_var['table']=220; //width of table that will house this MOD, 220 is good for dropdown, 420 is good for others
$multi_download_var['show_table']=1; //show border and shading in back of MOD, 1=yes,0=no
$multi_download_var['show_original']=1; //display "original image" as an option 1=yes, 0=no
$multi_download_var['newline_original']=1; //place 'original size' button on its own line, 1=yes, 0=no
$multi_download_var['center_original']=1; //center 'original size' button with space that is left in row, 1=yes, 0=no
$multi_download_var['alt_image']=1; //Use Alt variable with image links, 1=yes,0=no
$multi_download_var['crop']=0; //crop image after resize  (see below)
/* what crop will do is resize image larger then size that is asked for unless it detects it will resize without and extra space.
then it will crop off the extra area to give you the actual size asked for (loosing part of your image)
0= do not crop
1= crop equally on both sides
2= crop top or left side
3= crop bottom or right side
4= resize and stretch to fit requested size (no crop)
*/
$multi_download_var['quality']= 90; //quality settings for resizing/cropping 10-100 (10=high compression, 100= lowest compression)
$multi_download_var['target']="";// for popup window instead of download replace the quote with  "TARGET = '_blank' "  
// You can also replace _blank with a name like mypopup and then all images will open in same popup window
$multi_download_var['ratio']=0; //Only sizes that fit size ratio of original will be available (must be exact match on ratio!)
// END MOD multi download
this was the original insert for removal purposes if upgrading from beta to ver 2 or above
Code: [Select]
// MOD multi download
$download_multi_sizes= array(
array('640X480',640,480),
array('800X600',800,600),
array('1024X768',1024,768),
array('1280X960',1280,960),
array('1400X1050',1400,1050),
array('1600X1200',1600,1200),
array('1280X800-wide',1280,800),
array('1440X900-wide',1440,900),
array('1680X1050-wide',1680,1050),
array('1920X1200-wide',1920,1200)
);
// the first field is the name that is shown in the list that you choose from
// the second field is the width
// the third field is the height

$multi_download_options_string="<BR><BR>
<form action='".ROOT_PATH.'download.php'."' method='post'>
<table border='0' cellspacing='1' cellpadding='0' width='210'  class='head1'>
<tr><td><table border='0' cellspacing='0' cellpadding='0' width='210' class='row2'><tr>
<td colspan='2' align='center'>".$lang['multi_select']."</TD></TR>
<TR class='row1'><TD><select name='multi_download_select'>";
$var=0;
while ($var < count($download_multi_sizes)){
$multi_download_options_string .="<option value='".$var."'>".$download_multi_sizes[$var][0]."</option>";
$var = $var +1;
}
$multi_download_options_string .="</select>";
// END Multi Download

in the admin/categories.php file

look for
Code: [Select]
$access_array = array(
  AUTH_ALL => $lang['all'],
  AUTH_USER => $lang['userlevel_registered'],
  AUTH_ACL => $lang['private'],
  AUTH_ADMIN => $lang['userlevel_admin']
);

insert after (new for ver2.0)
Code: [Select]
// MOD multi download
function show_radio_row_multi($title, $name, $value = 0) {
  global $HTTP_POST_VARS, $lang, $multi_download_optionlist;
  if (isset($HTTP_POST_VARS[$name])) {
    $value = $HTTP_POST_VARS[$name];
  }
  echo "<tr class=\"".get_row_bg()."\">\n";
  echo "<td><p class=\"rowtitle\">".$title."</p></td>\n<td><p>";
  foreach ($multi_download_optionlist as $key => $val) {
    echo "<input type=\"radio\" name=\"".$name."\" value=\"$key\"";
    if ($value == $key) {
      echo " checked=\"checked\"";
    }
    echo "> ".$val."<br />";
  }
  echo "</p></td>\n</tr>";
}
// END MOD multi download

look for 2 times
Code: [Select]
$auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];insert after Both places
Code: [Select]
// MOD Multi Download
  $multi_download = (isset($HTTP_POST_VARS['multi_download'])) ? intval($HTTP_POST_VARS['multi_download']) : 0;
// END MOD Multi download

look for
Code: [Select]
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcommentreplace with
Code: [Select]
(cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
Code: [Select]
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcommentreplace with
Code: [Select]
('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $multi_download
look for
Code: [Select]
 $permission_headline = $lang['permissions'];insert before (changed insert for ver 2.0)
Code: [Select]
// MOD multi download
  $value = intval($cat_row['multi_download']);
  show_radio_row_multi($lang['multi_option'],'multi_download',$value);
// END MOD multi download

look for
Code: [Select]
   $sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcommentreplace with
Code: [Select]
   $sql = "SELECT cat_name, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download

look for
Code: [Select]
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcommentreplace with
Code: [Select]
SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, multi_download = $multi_download
look for
Code: [Select]
 $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcommentreplace with
Code: [Select]
 $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, multi_download
look for
Code: [Select]
 show_table_separator($lang['permissions'], 2);insert before (changed insert for ver 2.0)
Code: [Select]
// MOD multi download
$value = intval($cat_row['multi_download']);
show_radio_row_multi($lang['multi_option'],'multi_download',$value);
// END MOD multi download

in the details.php file

look for
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."replace with
Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email").", c.multi_download
look for
Code: [Select]
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;insert after (Updated insert for ver 3.1)
Code: [Select]
// MOD multi download
$multi_download = $image_row['multi_download'];
if($multi_download){
if(!strpos(",jpg,jpeg,JPG,JPEG,png,gif",pathinfo($image_row['image_media_file'], PATHINFO_EXTENSION))){
$multi_download=0;
}
}
// END MOD multi download

look for
Code: [Select]
//-----------------------------------------------------
//---Clickstream---------------------------------------
//-----------------------------------------------------
insert before
Code: [Select]
//MOD multi download
if (!$multi_download){
$site_template->register_vars("yes_multi_download", 0);
$site_template->register_vars("not_multi_download", 1);
}
else{
$site_template->register_vars("yes_multi_download", 1);
$site_template->register_vars("not_multi_download", 0);
}
//END MOD multi download

in the download.php file

look for
Code: [Select]
 $sql = "SELECT image_id, cat_id, user_id, image_media_file, image_download_url, image_downloads
          FROM ".IMAGES_TABLE."
          WHERE image_id = $image_id AND image_active = 1";
  $image_row = $site_db->query_firstrow($sql);
insert before (updated insert for version 2.1)
Code: [Select]
// MOD multi download
  if ($_POST['action'] == "resize" || $_GET['action'] == "resize"){
$multi_download_select = (isset($HTTP_GET_VARS['multi_download_select'])) ? intval($HTTP_GET_VARS['multi_download_select']) : intval($HTTP_POST_VARS['multi_download_select']);
$size = MULTI_DOWNLOAD_SEP.$download_multi_sizes[$multi_download_select][0];
}
// END MOD multi download
Also on the first line of the "look for" code above (new replace for version 4.4)
add new code to the end of the first line so it looks like this (Updated the code for version 4.6)
Code: [Select]
 $sql = "SELECT image_id, cat_id, user_id, image_media_file, image_download_url, image_downloads, image_keywords, image_description, image_name

look for
Code: [Select]
 if ($user_info['user_level'] != ADMIN) {
    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_downloads = image_downloads + 1
            WHERE image_id = $image_id";
    $site_db->query($sql);
insert before (Updated insert for ver 3.0)(Updated insert for ver 4.4)
Code: [Select]
// MOD multi download
if ($size){
$multi_resize=get_file_path($regs[1].'.'.$regs[2], "big", $image_row['cat_id'], 0, 1);
if (!file_exists($multi_resize)){
$multi_resize = (is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".$regs[1].'.'.$regs[2] : MEDIA_PATH."/".$image_row['cat_id']."/".$regs[1].'.'.$regs[2];
}
$file['file_name'] = $file_name.(($size) ? "_".$size : "").".".$file_extension;
$multi_new_image=(is_local_file($image_row['image_media_file'])) ? dirname($image_row['image_media_file'])."/".MULTI_BIG_FOLDER."/".$file['file_name'] : MEDIA_PATH."/".$image_row['cat_id']."/".MULTI_BIG_FOLDER."/".$file['file_name'];
$file['file_path'] = $multi_new_image;
$multi_dir=dirname($multi_new_image);
if (!file_exists($multi_new_image)){
if (!@is_dir($multi_dir)){
$oldumask = umask(0);
$result = mkdir($multi_dir);
umask($oldumask);
if (!@is_dir($multi_dir) || !$result) {
$result = mkdir($multi_dir, 0755);
}
}
$multi_var = multi_download_resize($multi_resize,$multi_new_image,$multi_download_var['quality'],$download_multi_sizes[$multi_download_select][1],$download_multi_sizes[$multi_download_select][2]);
if ($multi_var !== $multi_resize){
$file['file_path'] = $multi_new_image;
//-------------------------------------------------------------------------------------------
// --- Annotate Resized Images ----------------------------------------------------------------------
//-------------------------------------------------------------------------------------------
if ($config['annotation_use'] && strtolower($file_extension == jpg)) {
require(ROOT_PATH.'includes/annotate.php');
$ann_user_name = ($user_info['user_name']);
annotate_image($file['file_path']);
}
//-------------------------------------------------------------------------------------------
}
else {
$file['file_name'] = $file_name.".".$file_extension;
$file['file_path'] = $multi_resize;
}
}
}

// END MOD multi download

look for (New for ver 4.0- only needed if you want a popup window instead of download)(Updated for V4.4 to include template)
Code: [Select]
send_file($file['file_name'], $file['file_path']);
Replace with (Updated in V4.6)
Code: [Select]
//MOD multi download for popup window
if (($multi_download_var['target']<>"") && $size){
   $meta_keywords  = !empty($image_row['image_keywords']) ? implode(", ", explode(",", $image_row['image_keywords'])) : "";
$meta_description = !empty($image_row['image_description']) ? strip_tags($image_row['image_description']) . ". " : "";
$image_name = format_text($image_row['image_name'], 2);
                                  $site_template->register_vars(array(
"img_url" => $file["file_path"],
"site_name" => $config['site_name'],
"charset" => $lang['charset'],
"direction" => $lang['direction'],
"detail_meta_description"   => $meta_description,
            "detail_meta_keywords"      => $meta_keywords,
            "prepend_head_title"        => $image_name . " - "
));
$site_template->print_template($site_template->parse_template("multi_popup"));
}
else{
        send_file($file['file_name'], $file['file_path']);
    }
//END MOD multi download for popup window

in the includes\constants.php file

look for
Code: [Select]
?>insert before
Code: [Select]
// MOD multi download
define ('MULTI_BIG_FOLDER' , 'big'); //This is the name of the 'big' folder or the name of a seperate subfolder for resizing of images.
define ("MULTI_DOWNLOAD_SEP","_resized_");//an underscore will be added to this variable before it is attached (which in this case will make 2 underscores)
//this is what this Mod uses as a seperator from all the files it creates on your server.
// the format will be 'yourfilename_ (whatever the sep is set for)(and the names of your option for that size).jpg'
//example: if I have an option for 1024X768 the new name would be 'yourfilename__resized_1024X768.jpg' notice the 2 underscores in a row at the beginning, one is built in and the other is an option that you can take away if needed.
//NOTE: when this mod is cleaning up it is looking for any file with '_ (whatever the sep is set for)' [example '__resized_'] is what the mod is looking for, (notice the 2 underscores in a row at the beginning)
//             I am assuming that you will not EVER have '__resized_' in any of your normal filenames, if you do, then you need to change the SEP variable to something that you will never use in a filename or you can have the MOD store the
//             resized images in a different subfolder then the 'big' folder that is above and then the seperator will not matter. The Mod will create the new subfolder on the fly while it is running.
// END MOD multi download

in the includes\functions.php file

look for
Code: [Select]
function show_image($image_row, $mode = "", $show_link = 1, $detailed_view = 0) {
  global $self_url, $site_template, $site_sess, $user_info, $config, $cat_cache, $lang, $additional_image_fields, $user_table_fields, $url_show_profile;
insert after (changed insert for ver 2.0) (updated insert for ver 2.1)
Code: [Select]
 global $download_multi_sizes, $multi_download_var, $site_db;// MOD multi downloadoriginal insert that needs replaced if upgrading from beta to ver 2.0
Code: [Select]
 global $multi_download_options_string;// MOD multi download
ONLY ADD THIS MODIFICATION IF IT IS NOT ALREADY THERE FROM THE BIG MOD! (NEW TO VER 2.0 and above)
look for
Code: [Select]
   $check_handle = "check_".$image_type."_type";
    $path = (($image_type == "media") ? (($cat_id) ? MEDIA_PATH."/".$cat_id : MEDIA_TEMP_PATH) : (($cat_id) ? THUMB_PATH."/".$cat_id : THUMB_TEMP_PATH))."/".$file_name;
    return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : $return_code;
replace with
Code: [Select]
// MOD multi download (with needed info for big directory if not using that mod)
    $check_handle = "check_".$image_type."_type";
//    $path = (($image_type == "media") ? (($cat_id) ? MEDIA_PATH."/".$cat_id : MEDIA_TEMP_PATH) : (($cat_id) ? THUMB_PATH."/".$cat_id : THUMB_TEMP_PATH))."/".$file_name;
//    return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : $return_code;
// Download file block insert BEGIN
    switch( $image_type ) {
 case "media":
   if( $cat_id ){
     $path = MEDIA_PATH."/".$cat_id;
}else{
 $path = MEDIA_TEMP_PATH;
                        }
   break;
      case "big":
        $path = MEDIA_PATH."/".$cat_id."/big";
   break;
      case "download":
        $path = MEDIA_PATH."/".$cat_id."/download";
   break;
 default:
   if( $cat_id ){
     $path = THUMB_PATH."/".$cat_id;
}else{
 $path = THUMB_TEMP_PATH;
                        }
   break;
}
$path .= "/".$file_name;
// Download file block insert END
    return ($check_handle($file_name) && file_exists($path)) ? (($in_admin && !preg_match("#(gif|jpg|jpeg|png)$#is", $file_name)) ? ICON_PATH."/".get_file_extension($file_name).".gif" : $path) : (($image_type != "big" && $image_type != "big") ? $return_code : ""); // Download file :: V@no big mod
// END MOD multi download (with needed info for big directory if not using that mod)

look for (new to ver 2.0)(Changed in ver 4.5, read this posthttp://www.4homepages.de/forum/index.php?topic=22741.msg163311;topicseen#msg163311 )
Code: [Select]
 $rate_form = "";
  if (check_permission("auth_vote", $image_row['cat_id'])) {
    $site_template->register_vars("rate", $lang['rate']);
    $rate_form = $site_template->parse_template("rate_form");
  }
  $site_template->register_vars("rate_form", $rate_form);
  $site_template->register_vars(array(
    "image" => get_media_code($image_row['image_media_file'], $image_row['image_id'], $image_row['cat_id'], $image_row['image_name'], $mode, $show_link, $detailed_view),
  ));
insert After (updated insert for ver 3.1) (updated for ver 4.1) (updated for ver 4.2)(updated/repaired for ver 4.3)(updated for ver 4.5)(updated for ver 4.7)
Code: [Select]
// MOD multi download
if ($detailed_view){
 $sql = "SELECT multi_download
        FROM ".CATEGORIES_TABLE."
        WHERE cat_id = ".$image_row['cat_id']." ";
 $result = $site_db->query_firstrow($sql);
 $multi_download = $result['multi_download'];
}
if ($multi_download && $detailed_view){
if (!check_permission("auth_download", $image_row['cat_id'])) {
$multi_download_options="&nbsp;&nbsp;<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
$allow_download = 0;
clear_download_token($image_row['image_id']);
}
else{
$multi_download_colvar = 0;
if ($multi_download_var['show_table']){
$multi_download_class1 = "class='head1'";
$multi_download_class2 = "class='row1'";
$multi_download_class3 = "class='row2'";
}
else {
$multi_download_class1 = "";
$multi_download_class2 = "";
$multi_download_class3 = "";
}
$multi_download_group0 = ($multi_download_var['center_groups'] ? "align='center'" : "");
// change the code below to change how your monitor resolution is displayed
$multi_download_resolution = "<TR ".$multi_download_class3."><TD colspan='".$multi_download_var['columns']."' align='center'><B>".$lang['multi_resolution']."<script type='text/javascript'>document.write(screen.width+'X'+screen.height)</script></B></TD></TR>";
if ($multi_download_var['bold_groups']){
$multi_download_group1= "<B>";
$multi_download_group2= "</B>";
}
else{
$multi_download_group1= "";
$multi_download_group2= "";
}
if (!$multi_download_var['type']){
$multi_download_options = "<BR><BR><form action='".$site_sess->url(ROOT_PATH."download.php")."' method='get'".$multi_download_var['target']."><table border='0' cellspacing='1' cellpadding='0' width='".$multi_download_var['table']."'  ".$multi_download_class1."><tr><td><table border='0' cellspacing='0' cellpadding='0' width='".$multi_download_var['table']."'>";
if ($multi_download_var['show_resolution']){
$multi_download_options .= $multi_download_resolution;
}
if ($multi_download_var['download']){
$multi_download_options .="<TR ".$multi_download_class3."><TD colspan='".$multi_download_var['columns']."' align='center'>".$lang['multi_select']."</TD></TR>";
}
$multi_download_options .="<TR ".$multi_download_class2."><TD><select name='multi_download_select'>";
}
else{
$multi_download_options = "<table border='0' cellspacing='1' cellpadding='0' width='".$multi_download_var['table']."' ".$multi_download_class1."><tr><td><table border='0' cellspacing='0' cellpadding='0' width='".$multi_download_var['table']."'>";
if ($multi_download_var['show_resolution']){
$multi_download_options .= $multi_download_resolution;
}
if ($multi_download_var['download']){
$multi_download_options .= "<tr ".$multi_download_class3."><TD colspan='".$multi_download_var['columns']."' align='center'>".$lang['multi_select']."</TD>";
}
}
$var=0;
$down_group=0;
$down_group_flag=0;
$multi_download_group="";
$multi_download_colvar=0;
if (ISSET($site_template->val_cache['download_width'])){
$max_width = $site_template->val_cache['download_width'];
$max_height = $site_template->val_cache['download_height'];
}
else {
$max_width = $site_template->val_cache['width'];
$max_height = $site_template->val_cache['height'];
}
$varcount= count($download_multi_sizes);
while ($var < $varcount){
if ($download_multi_sizes[$var][1] == '0'){
if ((!$down_group) && ($multi_download_group<>"")){
if (!$multi_download_var['type']) {
$multi_download_options .=$multi_download_group;
}
else{
if ($multi_download_colvar < $multi_download_var['columns']){
$multi_download_colvar1=($multi_download_var['columns'] - $multi_download_colvar);
$multi_download_group .= "<td align='center' colspan='".$multi_download_colvar1."'></td>";
}
$multi_download_options .= "<tr ".$multi_download_class2.">".$multi_download_group."</tr>";
}
}
if ($down_group && $down_group_flag){
if (!$multi_download_var['type']) {
$multi_download_group .= "</optgroup>";
}
else{
if ($multi_download_colvar < $multi_download_var['columns']){
$multi_download_colvar1=($multi_download_var['columns'] - $multi_download_colvar);
$multi_download_group .= "<td align='center' colspan='".$multi_download_colvar1."'></td>";
}
}
$multi_download_options .= $multi_download_group;
}
$down_group=1;
$down_group_flag=0;
if (!$multi_download_var['type']) {
$multi_download_group ="<optgroup label='".$lang['multi_down_'.$download_multi_sizes[$var][0]]."'>";
}
else{
$multi_download_group ="</tr><tr ".$multi_download_class3."><td colspan='".$multi_download_var['columns']."' ".$multi_download_group0.">".$multi_download_group1.$lang['multi_down_'.$download_multi_sizes[$var][0]].$multi_download_group2."</TD></TR><tr ".$multi_download_class2.">";
$multi_download_colvar = 0;
}
}
else{
if ((($download_multi_sizes[$var][1] <= $max_width && $download_multi_sizes[$var][2] <= $max_height)&&($multi_download =='2'))||($multi_download=='1')){
 if (((($max_width/$max_height)==($download_multi_sizes[$var][1]/$download_multi_sizes[$var][2]))&&($multi_download_var['ratio']))||(!$multi_download_var['ratio'])){
switch($multi_download_var['type']){
case (1) :
$multi_download_group .="<td align='center'><a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."'".$multi_download_var['target'].">".$download_multi_sizes[$var][0]."</a></td>";
break;
case (2) :
$multi_download_group .="<td align='center'><a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."'".$multi_download_var['target']."><img src='".get_gallery_image($download_multi_sizes[$var][0].".".$multi_download_var['button'])."' ";
if ($multi_download_var['alt_image']){
$multi_download_group .= "alt='".$download_multi_sizes[$var][0]."' ";
}
$multi_download_group .="border='0'></a></td>";
break;
case (0) :
default:
$multi_download_group .="<option value='".$var."'>".$download_multi_sizes[$var][0]."</option>";
break;
}
$down_group_flag=1;
$multi_download_colvar++;
 }
}
if (($multi_download_colvar == $multi_download_var['columns']) && ($multi_download_var['type']>0)){
$multi_download_colvar = 0;
$multi_download_group .="</tr><tr ".$multi_download_class2.">";
}
}
$var++;
}
if (($down_group==1) && (!$multi_download_var['type'])){
$multi_download_group .="</optgroup>";
}
if($down_group_flag){
$multi_download_options .=$multi_download_group;
}else{
$multi_download_colvar = 1;
}
$multi_download_colvar2= $multi_download_colvar;
$multi_download_colvar = $multi_download_var['columns'] - $multi_download_colvar;
if ($multi_download_var['center_original']){
$multi_download_colvar1= $multi_download_colvar;
}
else{
$multi_download_colvar1= 1;
$multi_download_colvar--;
}
switch ($multi_download_var['type']){
case(1):
if ($multi_download_var['newline_original']){
if ($multi_download_colvar2){
$multi_download_colvar1 = $multi_download_var['columns'] - $multi_download_colvar2;
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'></td>";
$multi_download_options .="</tr><tr ".$multi_download_class2.">";
}
if ($multi_download_var['center_original']){
$multi_download_colvar1=$multi_download_var['columns'];
}
else{
$multi_download_colvar1 =1 ;
$multi_download_colvar=$multi_download_var['columns'];
}
}
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'>";
if ($multi_download_var['show_original']){
$multi_download_options .= "<a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."' ".$multi_download_var['target'].">".$lang['original_size']."</a>";
}
$multi_download_options .= "</td>";
if (!$multi_download_var['center_original']){
$multi_download_options .= "<td colspan='".$multi_download_colvar."'></td>";
}
$multi_download_options .="</tr></table></td></tr></table>";
break;
case(2):
if ($multi_download_var['newline_original']){
if ($multi_download_colvar2){
$multi_download_colvar1 = $multi_download_var['columns'] - $multi_download_colvar2;
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'></td>";
$multi_download_options .="</tr><tr ".$multi_download_class2.">";
}
if ($multi_download_var['center_original']){
$multi_download_colvar1=$multi_download_var['columns'];
}
else{
$multi_download_colvar1 =1 ;
$multi_download_colvar=$multi_download_var['columns'];
}
}
$multi_download_options .="<td align='center' colspan='".$multi_download_colvar1."'>";
if ($multi_download_var['show_original']){
$multi_download_options .= "<a href='".$site_sess->url(ROOT_PATH."download.php?action=resize&".URL_IMAGE_ID."=".$image_row['image_id']."&multi_download_select=".$var)."' ".$multi_download_var['target']."><img src='".get_gallery_image("original_size.".$multi_download_var['button'])."' ";
if($multi_download_var['alt_image']){
$multi_download_options .= "alt='".$lang['original_size']."' ";
}
$multi_download_options .="border='0'></a>";
}
$multi_download_options .= "</td>";
if (!$multi_download_var['center_original']){
$multi_download_options .= "<td colspan='".$multi_download_colvar."'></td>";
}
$multi_download_options .="</tr></table></td></tr></table>";
break;
case(0):
default:
if ($multi_download_var['show_original']){
$multi_download_options .="<option value='".$var."'>".$lang['original_size']."</option>";
}
$multi_download_options .="</select>";
$multi_download_options .= "</td><td><input type='submit' name='download' value='".$lang['download']."' class='button' />
</TD></TR></TABLE></TABLE><input type='hidden' name='action' value='resize' />
<input type='hidden' name='image_id' value='".$image_row['image_id']."' /></form>";
break;
}
$allow_download = 1;
set_download_token($image_row['image_id']);
}
$site_template->register_vars("multi_download_options", $multi_download_options);
unset($multi_download_options);
}

// END MOD multi download

look for (this insert no longer needed in ver 2.0 or above) (left here so upgrade users can delete)
Code: [Select]
if (!check_permission("auth_sendpostcard", $image_row['cat_id'])) {insert before(remove this insert if upgrading from beta to ver 2.0)
Code: [Select]
// MOD multi download

if (!check_permission("auth_download", $image_row['cat_id'])) {
$multi_download_options="&nbsp;&nbsp;<img src=\"".get_gallery_image("download_off.gif")."\" border=\"0\" alt=\"\" />";
$allow_download = 0;
clear_download_token($image_row['image_id']);
}
else{
$multi_download_options = $multi_download_options_string;
    $multi_download_options .= "</td><td><input type='submit' name='download' value='".$lang['download']."' class='button' />
                   </TD></TR></TABLE></TABLE><input type='hidden' name='action' value='resize' />
                    <input type='hidden' name='image_id' value='".$image_row['image_id']."' /></form>";
//
$allow_download = 1;
    set_download_token($image_row['image_id']);

}
$site_template->register_vars("multi_download_options", $multi_download_options);
// END MOD multi download

look for
Code: [Select]
?>insert before (updated insert for ver 3.1)
Code: [Select]
// MOD multi download
function multi_download_resize($file, $new_file, $quality, $resize_width, $resize_height) {
  global $convert_options,$download_multi_sizes,$multi_download_var;
  if (!function_exists(init_convert_options)) {
require(ROOT_PATH.'includes/image_utils.php');
  }

  $convert_options = init_convert_options();
  $image_info = (defined("IN_CP")) ? getimagesize($file) : @getimagesize($file);
  if (!$image_info) {
    return false;
  }
  if ($resize_width==0){$resize_width=$image_info[0];}
  if ($resize_height==0){$resize_height=$image_info[1];}
  if ($multi_download_var['crop']){
$scale = max($resize_width/$image_info[0], $resize_height/$image_info[1]);
  }
  else{
$scale = min($resize_width/$image_info[0], $resize_height/$image_info[1]);
  }
$new_width = floor($scale*$image_info[0]);
$new_height = floor($scale*$image_info[1]);
$resize_handle = "resize_image_".$convert_options['convert_tool'];
if ((($scale == '1' || $scale == '0') && !$multi_download_var['crop']) || (($resize_width==$image_info[0]) && ($resize_height==$image_info[1]))){
return $file;
}
if (!$multi_download_var['crop']){
if($resize_handle($file, $new_file, $quality, $new_width, $new_height, $image_info)) {
@chmod($new_file, CHMOD_FILES);
return true;
}
else {
return false;
}
}
$crop_handle = "multi_download_resize_crop_image_".$convert_options['convert_tool'];
if ($resize_width == $new_width){
$multi_crop_st_w='0';
$multi_crop_end_w=$image_info['0'];
$multi_crop_end_h = (($image_info['0']*$resize_height)/$resize_width);
switch($multi_download_var['crop']){
case (2) :
$multi_crop_st_h= ($image_info['1']-$multi_crop_end_h);
break;
case (3) :
$multi_crop_st_h= '0';
break;
case (4) :
$multi_crop_st_h = '0';
$multi_crop_end_h = $image_info[1];
break;
case (1) :
default:
$multi_crop_st_h= (($image_info['1']-$multi_crop_end_h)/2);
break;
}
}
else{
$multi_crop_st_h='0';
$multi_crop_end_h=$image_info['1'];
$multi_crop_end_w = (($image_info['1']*$resize_width)/$resize_height);
switch($multi_download_var['crop']){
case (2) :
$multi_crop_st_w= ($image_info['0']-$multi_crop_end_w);
break;
case (3) :
$multi_crop_st_w= '0';
break;
case (4) :
$multi_crop_st_w = '0';
$multi_crop_end_w = $image_info[0];
break;
case (1) :
default:
$multi_crop_st_w = (($image_info['0']-$multi_crop_end_w)/2);
break;
}
}
if($crop_handle($file, $new_file, $quality, $resize_width, $resize_height, $image_info, $multi_crop_st_w,$multi_crop_st_h,$multi_crop_end_w,$multi_crop_end_h)) {
@chmod($new_file, CHMOD_FILES);
return true;
}
else {
return false;
}

}

function multi_download_resize_crop_image_gd($src, $dest, $quality, $width, $height, $image_info, $multi_crop_st_w, $multi_crop_st_h, $multi_crop_end_w, $multi_crop_end_h) {
  global $convert_options,$multi_download_var;

  $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
  if ($convert_options['convert_gd2']) {
    $thumb = imagecreatetruecolor($width, $height);
  }
  else {
    $thumb = imagecreate($width, $height);
  }
  $image_create_handle = "imagecreatefrom".$types[$image_info[2]];
  if ($image = $image_create_handle($src)) {
    if ($convert_options['convert_gd2']) {
      imagecopyresampled($thumb, $image, 0, 0, $multi_crop_st_w,$multi_crop_st_h, $width, $height, $multi_crop_end_w, $multi_crop_end_h);
    }
    else {
      imagecopyresized($thumb, $image, 0, 0, $multi_crop_st_w,$multi_crop_st_h, $width, $height, $multi_crop_end_w, $multi_crop_end_h);
    }

    if ($image_info[2] == 3) {
      $quality = 9;
    }

    $image_handle = "image".$types[$image_info[2]];
    $image_handle($thumb, $dest, $quality);
    imagedestroy($image);
    imagedestroy($thumb);
  }
  return (file_exists($dest)) ? 1 : 0;
}

function multi_download_resize_crop_image_im($src, $dest, $quality, $width, $height, $image_info, $multi_crop_st_w, $multi_crop_st_h, $multi_crop_end_w, $multi_crop_end_h) {
  global $convert_options,$multi_download_var;
  if ($multi_download_var['crop']==4){
$command = $convert_options['convert_path'];
$command .= " \"$src\" -quality ".$quality." -antialias -geometry $width"."x"."$height! -profile '*' -unsharp 0.5x1 \"$dest\"";
  }
  else{
$command = $convert_options['convert_path'];
$command .= " \"$src\" -crop ".$multi_crop_end_w."X".$multi_crop_end_h."+".$multi_crop_st_w."+".$multi_crop_st_h;
$command .= " -quality ".$quality." -antialias -geometry $width"."x"."$height -profile '*' -unsharp 0.5x1 \"$dest\"";
  }
  system($command);
  return (file_exists($dest)) ? 1 : 0;
}

function multi_download_resize_crop_image_netpbm($src, $dest, $quality, $width, $height, $image_info, $multi_crop_st_w,$multi_crop_st_h,$multi_crop_end_w,$multi_crop_end_h) {
  global $convert_options,$multi_download_var;

  $convert_path = $convert_options['convert_path'];
  $types = array(1 => "gif", 2 => "jpeg", 3 => "png");
  $target = ($width > $height) ? $width : $height;
  $command = $convert_path."/".check_executable($types[$image_info[2]]."topnm")." ".$src." | ";
  if ($multi_download_var['crop']==4){
$command .= $convert_path."/".check_executable("pnmscale")." --quiet -xsize=".$width." -ysize=".$height." | ";
  }
  else{
$command .= $convert_path."/".check_executable("pnmcut")."  --quiet ".$multi_crop_st_w." ".$multi_crop_st_h." ".$multi_crop_end_w." ".$multi_crop_end_h." | ";
$command .= $convert_path."/".check_executable("pnmscale")." --quiet -xysize ".$width." ".$height." | ";
  }
  if ($image_info[2] == 1) {
    $command .= $convert_path."/".check_executable("ppmquant")." 256 | " . $convert_path."/".check_executable("ppmtogif")." > ".$dest;
  }
  elseif ($image_info[2] == 3) {
    $command .= $convert_path."/".check_executable("pnmtopng")." > ".$dest;
  }
  else {
    $jpeg_exec = (file_exists($convert_path."/".check_executable("pnmtojpeg"))) ? check_executable("pnmtojpeg") : check_executable("ppmtojpeg");
    $command .= $convert_path."/".$jpeg_exec." --quality=".$quality." > ".$dest;
  }
  system($command);
  return (file_exists($dest)) ? 1 : 0;
}

if (!function_exists('check_big_type')) {  
function check_big_type($file_name) {
global $config;
return (in_array(get_file_extension($file_name), $config['allowed_mediatypes_array'])) ? 1 : 0;
}
function check_remote_big($remote_media_file) {
global $config;
return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $remote_media_file)) ? 1 : 0;
}
function check_local_big($local_media_file) {
global $config;
return (preg_match("#^((\.)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $local_media_file)) ? 1 : 0;
}
}

// END MOD multi download
this is the old insert that needs to be replaced if upgrading from beta to ver 2.0 or above
Code: [Select]
// MOD multi download
function multi_download_resize($file, $new_file, $quality, $resize_width, $resize_height) {
  global $convert_options;
  if (!function_exists(init_convert_options)) {
require(ROOT_PATH.'includes/image_utils.php');
  }
  $convert_options = init_convert_options();
  $image_info = (defined("IN_CP")) ? getimagesize($file) : @getimagesize($file);
  if (!$image_info) {
    return false;
  }
$scale = min($resize_width/$image_info[0], $resize_height/$image_info[1]);
$new_width = floor($scale*$image_info[0]);
$new_height = floor($scale*$image_info[1]);
$resize_handle = "resize_image_".$convert_options['convert_tool'];
if ($scale == '1'){
return $file;
}
elseif($resize_handle($file, $new_file, $quality, $new_width, $new_height, $image_info)) {
@chmod($new_file, CHMOD_FILES);
return true;
}
else {
return false;
}
}
// END MOD multi download

in the lang\english\admin.php file

look for
Code: [Select]
?>insert before (updated insert for ver 2.0)
Code: [Select]
//MOD multi downloads
$lang['multi_option'] = "Would you like to use multi-size download option for this category?";
$multi_download_optionlist = array(
  "0"  => "No",
  "1"  => "Yes, Allow all sizes to be selectable",
  "2"  => "Yes, Only allow smaller sizes then original to be selectable"
);
//END MOD multi downloads
original insert that needs to be replaced if upgrading from beta to ver 2.0
Code: [Select]
//MOD Multi Downloads
$lang['multi_option'] = "Are you using multi download option for this category?"
//END MOD Multi Downloads

in the lang\english\main.php file

look for
Code: [Select]
?>insert before (updated insert for version 2.1) (updated for ver 4.0)
Code: [Select]
// MOD multi download
$lang['download'] = "Download";
$lang['multi_select'] = "Select Size to Download";
$lang['original_size'] = "Original Size";
$lang['multi_resolution'] = "Your Screen Resolution is : ";
$lang['multi_down_group1'] = "4:3 Display";//create an entry for each one or your groups from the global.php file in this manor
$lang['multi_down_group2'] = "16:9 Display";
$lang['multi_down_group3'] = "16:10 Display";
$lang['multi_down_group4'] = "Mobile";
$lang['multi_down_group5'] = "Blackberry";
// END MOD multi download

in the template\your template\details.html file
the fun part.
my file I had something like this...
Code: [Select]
{lightbox_button}&nbsp;&nbsp;{postcard_button}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{download_button}&nbsp;&nbsp;{download_zip_button}I replaced this with
Code: [Select]
{lightbox_button}&nbsp;&nbsp;{postcard_button}{if not_multi_download}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{download_button}&nbsp;&nbsp;{download_zip_button}
{endif not_multi_download}
<!-- Mod multi downloads -->
{if yes_multi_download}
{multi_download_options}
{endif yes_multi_download}
<!-- end mod-->

what you are trying to do is to remove the download and zip buttons if you are using the multi download and display the multi download option instead.
different templates may be setup differently.

(New to version 4.4)
To create the template used for the popup window...
Create a file in your templates folder and call it "multi_popup.html"
Copy the following code into that file and save the file
Code: [Select]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html dir="{direction}">
<head>
<title>{prepend_head_title}{site_name}</title>
<meta http-equiv="content-type" content="text/html; charset={charset}">
<meta name="description" content="{detail_meta_description}{site_name}">
<meta name="keywords" content="{detail_meta_keywords}">
</head>
<body>
<img src="{img_url}"></img>
</body>
</html>

and you should be ready to go.

15
Mods & Plugins (Requests & Discussions) / [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('&lt;', '&gt;', '&quot;', '&amp;'),
    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


Pages: [1] 2
Post your comments here