Images as Links mod
-----
| Author | Message | |
|---|---|---|
|
Carter |
||
| Fri Mar 16, 2007 12:15 am Post subject: Images as Links mod | ||
|
I found this mod waaaay back in the day in phpbbhacks - I was wondering if you could help me tweak it a little Thoul.
Code: ###############################################
## Hack Title: Images and links mod ## Hack Version: 1.0.2 ## Author: Retorq ## Description: ## Controls images being shown as images or links in the forum topics ## Every user can set options in their profile, or admins can do so for users (in the ACP). ## NEW: Also at the top of each topic there is a link to bypass the users settings for that one topic for that one time. ## ## Options currently possible: ## - Images: yes / link (no) ## ## This is extremely handy for people accessing your forum with a modem, ## low resolution screens or the viewing of questionalbe forum topics at work. ## This has been retested and is fully working with mixed links and all possible post/image variations in a post. ## ## Compatibility: ## 2.0.6 (although with some minor searching you should be able to make it work on prior versions) ## ## Installation Level: ## Moderate ## Installation Time: ## 10 - 15 minutes ## Files To Edit: 9 ## viewtopic.php ## admin/admin_users.php ## includes/usercp_avatar.php ## includes/usercp_register.php ## includes/usercp_viewprofile.php ## language/lang_english/lang_main.php ## templates/subSilver/admin/user_edit_body.tpl ## templates/subSilver/profile_add_body.tpl ## NEW: templates/subSilver/viewtopic_body.tpl ## ## History: ## 1.0.2: Third release, revised some of the code in the viewtopic.php file, added link for bypass. ## 1.0.1: Second release, fixed spelling errors, and added helpful text for users ## 1.0.0: First official release ## ## Author Notes: ## You'll notice this mod uses the same layout / naming convention as "Freakin' Booty"'s Dis(Allow) Sig and Avatar mod. ## To me, all three of these go hand in hand to give the user the ultimate control over the "content" of the forums being displayed. ## Note that disabling images does not "break" sigs, avatars, or smileys (like Invision). ## Many thanks to JKeats for pointing out "issues" in the original code and for his bypass and IMAGE LINK ideas. ## ## Support: ## http://www.digitalhijinx.com ## ## Copyright: ## ©2003 Images as links mod 1.0.2 - Retorq ## ############################################### # #-----[ DATABASE UPDATES ]-------------------------------- # If your pbpbb_users table is labeld differently please make that change below # You can paste this into your MYSQL Control Center app, you do have that prog don't you?? # I have not tested this with any other DB formats, I can not imagine much modification would be needed ALTER TABLE (phpbb_users) ADD COLUMN user_ou_img tinyint(1) DEFAULT 0; # #-----[ OPEN ]-------------------------------------------- # viewtopic.php # #-----[ FIND ]-------------------------------------------- # include($phpbb_root_path . 'includes/bbcode.'.$phpEx); # #-----[ AFTER, ADD ]------------------------------------ # $view_pics=$HTTP_GET_VARS['view_pics']; # #-----[ FIND ]-------------------------------------------- # $sql = "SELECT u.username, u.user_id, u.user_posts, u.user_from, u.user_website, u.user_email, u.user_icq, u.user_aim, u.user_yim, u.user_regdate, u.user_msnm, u.user_viewemail, u.user_rank, u.user_sig, u.user_sig_bbcode_uid, u.user_avatar, u.user_avatar_type, u.user_allowavatar, u.user_allowsmile, p.*, pt.post_text, pt.post_subject, pt.bbcode_uid FROM " . POSTS_TABLE . " p, " . USERS_TABLE . " u, " . POSTS_TEXT_TABLE . " pt WHERE p.topic_id = $topic_id # #-----[ INLINE, FIND ]------------------------------------ # p.*, # #-----[ BEFORE, ADD ]-------------------------------------- # u.user_ou_img, # #-----[ FIND ]-------------------------------------------- # // // Parse message and/or sig for BBCode if reqd // # #-----[ BEFORE, ADD ]------------------------------------ # // // Images as links mod // if (($userdata['user_ou_img'] == 0) && (preg_match("#gif|jp[e]?g#is", $message) && $view_pics != 1) ) { $message = preg_replace('#\[img:.*?\]#is', " ", $message); $message = preg_replace('#\[/img:.*?\]#is', " ", $message); $message = ereg_replace("[[:alpha:]]+://[ ;^<>[:space:]]+(gif|jp[e]?g) ;", "<a href=\"\\0\" target=new>IMAGE ATTACHED</a>", $message); } # #-----[ OPEN ]-------------------------------------------- # admin/admin_users.php # #-----[ FIND ]-------------------------------------------- # $popuppm = ( isset( $HTTP_POST_VARS['popup_pm']) ) ? ( ( $HTTP_POST_VARS['popup_pm'] ) ? TRUE : 0 ) : TRUE; # #-----[ AFTER, ADD ]-------------------------------------- # $user_ou_img = ( isset($HTTP_POST_VARS['user_ou_img']) ) ? intval( $HTTP_POST_VARS['user_ou_img'] ) : 1; # #-----[ FIND ]-------------------------------------------- # $sql = "UPDATE " . USERS_TABLE . " SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", $aim) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_sig_bbcode_uid = '$signature_bbcode_uid', user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowavatar = $user_allowavatar, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_allow_pm = $user_allowpm, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_gender = $gender, user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_active = $user_status, user_rank = $user_rank" . $avatar_sql . ", user_birthday = $birthday, user_next_birthday_greeting=$next_birthday_greeting WHERE user_id = $user_id"; # #-----[ INLINE, FIND ]------------------------------------ # , user_popup_pm = $popuppm # #-----[ AFTER, ADD ]-------------------------------------- # , user_ou_img = $user_ou_img # #-----[ FIND ]-------------------------------------------- # $popuppm = $this_userdata['user_popup_pm']; # #-----[ AFTER, ADD ]-------------------------------------- # $user_ou_img = $this_userdata['user_ou_img']; # #-----[ FIND ]-------------------------------------------- # $s_hidden_fields .= '<input type="hidden" name="popup_pm" value="' . $popuppm . '" />'; # #-----[ AFTER, ADD ]-------------------------------------- # $s_hidden_fields .= '<input type="hidden" name="user_ou_img" value="' . $user_ou_img . '" />'; # #-----[ FIND ]-------------------------------------------- # 'POPUP_PM_NO' => (!$popuppm) ? 'checked="checked"' : '', # #-----[ AFTER, ADD ]-------------------------------------- # 'ALWAYS_ALLOW_IMAGES_YES' => ( $user_ou_img ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_IMAGES_NO' => ( !$user_ou_img ) ? 'checked="checked"' : '', # #-----[ FIND ]-------------------------------------------- # 'L_POPUP_ON_PRIVMSG' => $lang['Popup_on_privmsg'], # #-----[ AFTER, ADD ]-------------------------------------- # 'L_ALWAYS_ALLOW_IMAGES' => $lang['Always_allow_images'], 'L_NO_IMAGES' => $lang['No, display images as links'], # #-----[ OPEN ]-------------------------------------------- # includes/usercp_avatar.php # #-----[ FIND ]-------------------------------------------- # function display_avatar_gallery($mode, &$category, &$user_id, &$email, &$current_email, &$coppa, &$username, &$email, &$new_password, &$cur_password, &$password_confirm, &$icq, &$aim, &$msn, &$yim, &$website, &$location, &$occupation, &$interests, &$signature, &$viewemail, &$notifypm, &$popuppm, &$notifyreply, &$attachsig, &$allowhtml, &$allowbbcode, &$allowsmilies, &$hideonline, &$style, &$language, &$timezone, &$dateformat) # #-----[ INLINE, FIND ]------------------------------------ # ) # #-----[ BEFORE, ADD ]------------------------------------- # , &$user_ou_img # #-----[ FIND ]-------------------------------------------- # $params = array('coppa', 'user_id', 'username', 'email', 'current_email', 'cur_password', 'new_password', 'password_confirm', 'icq', 'aim', 'msn', 'yim', 'website', 'location', 'occupation', 'interests', 'signature', 'viewemail', 'notifypm', 'popuppm', 'notifyreply', 'attachsig', 'allowhtml', 'allowbbcode', 'allowsmilies', 'hideonline', 'style', 'language', 'timezone', 'dateformat'); # #-----[ INLINE, FIND ]------------------------------------ # ); # #-----[ BEFORE, ADD ]------------------------------------- # , 'user_ou_img' # #-----[ OPEN ]-------------------------------------------- # includes/usercp_register.php # #-----[ FIND ]-------------------------------------------- # $popup_pm = ( isset($HTTP_POST_VARS['popup_pm']) ) ? ( ($HTTP_POST_VARS['popup_pm']) ? TRUE : 0 ) : TRUE; # #-----[ AFTER, ADD ]-------------------------------------- # $user_ou_img = ( isset($HTTP_POST_VARS['user_ou_img']) ) ? intval( $HTTP_POST_VARS['user_ou_img'] ) : 1; # #-----[ FIND ]-------------------------------------------- # $sql = "UPDATE " . USERS_TABLE . " SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail, user_aim = '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', user_yim = '" . str_replace("\'", "''", $yim) . "', user_msnm = '" . str_replace("\'", "''", $msn) . "', user_attachsig = $attachsig, user_allowsmile = $allowsmilies, user_allowhtml = $allowhtml, user_allowbbcode = $allowbbcode, user_allow_viewonline = $allowviewonline, user_notify = $notifyreply, user_notify_pm = $notifypm, user_popup_pm = $popuppm, user_timezone = $user_timezone, user_dateformat = '" . str_replace("\'", "''", $user_dateformat) . "', user_lang = '" . str_replace("\'", "''", $user_lang) . "', user_style = $user_style, user_active = $user_active, user_actkey = '" . str_replace("\'", "''", $user_actkey) . "'" . $avatar_sql . " WHERE user_id = $user_id"; # #-----[ INLINE, FIND ]------------------------------------ # , user_popup_pm = $popup_pm # #-----[ AFTER, ADD ]-------------------------------------- # , user_ou_img = $user_ou_img # #-----[ FIND ]-------------------------------------------- # $sql = "INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail, user_aim, user_yim, user_msnm, user_attachsig, user_allowsmile, user_allowhtml, user_allowbbcode, user_allow_viewonline, user_notify, user_notify_pm, user_popup_pm, user_timezone, user_dateformat, user_lang, user_style, user_level, user_allow_pm, user_active, user_actkey) VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail, '" . str_replace("\'", "''", str_replace(' ', '+', $aim)) . "', '" . str_replace("\'", "''", $yim) . "', '" . str_replace("\'", "''", $msn) . "', $attachsig, $allowsmilies, $allowhtml, $allowbbcode, $allowviewonline, $notifyreply, $notifypm, $popuppm, $user_timezone, '" . str_replace("\'", "''", $user_dateformat) . "', '" . str_replace("\'", "''", $user_lang) . "', $user_style, 0, 1, "; # #-----[ INLINE, FIND ]------------------------------------ # , user_popup_pm # #-----[ AFTER, ADD ]-------------------------------------- # , user_ou_img # #-----[ INLINE, FIND ]------------------------------------ # , $popup_pm # #-----[ AFTER, ADD ]-------------------------------------- # , $user_ou_img # #-----[ FIND ]-------------------------------------------- # $popup_pm = $userdata['user_popup_pm']; # #-----[ AFTER, ADD ]-------------------------------------- # $user_ou_img = $userdata['user_ou_img']; # #-----[ FIND ]-------------------------------------------- # display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail, $notifypm, $popuppm, $notifyreply, $attachsig, $allowhtml, $allowbbcode, $allowsmilies, $allowviewonline, $user_style, $user_lang, $user_timezone, $user_dateformat); # #-----[ INLINE, FIND ]------------------------------------ # ); # #-----[ BEFORE, ADD ]------------------------------------- # , $user_ou_img # #-----[ FIND ]-------------------------------------------- # 'POPUP_PM_NO' => ( !$popup_pm ) ? 'checked="checked"' : '', # #-----[ AFTER, ADD ]-------------------------------------- # 'ALWAYS_ALLOW_IMAGES_YES' => ( $user_ou_img ) ? 'checked="checked"' : '', 'ALWAYS_ALLOW_IMAGES_NO' => ( !$user_ou_img ) ? 'checked="checked"' : '', # #-----[ FIND ]-------------------------------------------- # 'L_POPUP_ON_PRIVMSG_EXPLAIN' => $lang['Popup_on_privmsg_explain'], # #-----[ AFTER, ADD ]-------------------------------------- # 'L_ALWAYS_ALLOW_IMAGES' => $lang['Always_allow_images'], 'L_NO_IMAGES' => $lang['No, display images as links'], # #-----[ OPEN ]-------------------------------------------- # # Make sure to edit this file for every language installed # language/lang_english/lang_main.php # #-----[ FIND ]-------------------------------------------- # // // That's all Folks! // ------------------------------------------------- # #-----[ BEFORE, ADD ]------------------------------------- # // // Images as links mod // $lang['Always_allow_images'] = 'Allow images in posts'; $lang['No_images'] = 'No, display images as links'; $lang['View_all_images'] = 'View all images in this topic'; # #-----[ OPEN ]-------------------------------------------- # # Make sure to edit this file for every template installed # templates/subSilver/admin/user_edit_body.tpl # #-----[ FIND ]-------------------------------------------- # <tr> <td class="row1"><span class="gen">{L_ALWAYS_ALLOW_SMILIES}</span&g t;</td> <td class="row2"> <input type="radio" name="allowsmilies" value="1" {ALWAYS_ALLOW_SMILIES_YES} /> <span class="gen">{L_YES}</span> & nbsp; <input type="radio" name="allowsmilies" value="0" {ALWAYS_ALLOW_SMILIES_NO} /> <span class="gen">{L_NO}</span></td> </tr> # #-----[ AFTER, ADD ]-------------------------------------- # <tr> <td class="row1"><span class="gen">{L_ALWAYS_ALLOW_IMAGES}</span> ;</td> <td class="row2"><span class="gen"><input type="radio" name="user_ou_img" value="1" {ALWAYS_ALLOW_IMAGES_YES} />{L_YES} <input type="radio" name="user_ou_img" value="0" {ALWAYS_ALLOW_IMAGES_NO} />{L_NO_IMAGES}</span></td> </tr> # #-----[ OPEN ]-------------------------------------------- # # Make sure to edit this file for every template installed # templates/subSilver/profile_add_body.tpl # #-----[ FIND ]-------------------------------------------- # <tr> <td class="row1"><span class="gen">{L_ALWAYS_ALLOW_SMILIES}:</s pan></td> <td class="row2"> <input type="radio" name="allowsmilies" value="1" {ALWAYS_ALLOW_SMILIES_YES} /> <span class="gen">{L_YES}</span> & nbsp; <input type="radio" name="allowsmilies" value="0" {ALWAYS_ALLOW_SMILIES_NO} /> <span class="gen">{L_NO}</span></td> </tr> # #-----[ AFTER, ADD ]-------------------------------------- # <tr> <td class="row1"><span class="gen">{L_ALWAYS_ALLOW_IMAGES}:</sp an></td> <td class="row2"> <input type="radio" name="user_ou_img" value="1" {ALWAYS_ALLOW_IMAGES_YES} /> <span class="gen">{L_YES}</span> & nbsp; <input type="radio" name="user_ou_img" value="0" {ALWAYS_ALLOW_IMAGES_NO} /> <span class="gen">{L_NO_IMAGES}</span></td&g t; </tr> # #-----[ OPEN ]-------------------------------------------- # # Make sure to edit this file for every template installed # templates/subSilver/viewtopic_body.tpl # #-----[ FIND ]-------------------------------------------- # <td class="catHead" colspan="2" height="28"><span class="nav"><a href="{U_VIEW_OLDER_TOPIC}" class="nav">{L_VIEW_PREVIOUS_TOPIC}</a> :: <a href="{U_VIEW_NEWER_TOPIC}" class="nav">{L_VIEW_NEXT_TOPIC}</a> </span></td> # #-----[ REPLACE WITH ]-------------------------------------- # <td class="catHead" colspan="2" height="28"><span class="nav"><a class="nav" href="{U_VIEW_TOPIC}&view_pics=1">{L_V IEW_ALL_IMAGES}</a> :: <a href="{U_VIEW_OLDER_TOPIC}" class="nav">{L_VIEW_PREVIOUS_TOPIC}</a> :: <a href="{U_VIEW_NEWER_TOPIC}" class="nav">{L_VIEW_NEXT_TOPIC}</a> </span></td> # #-----[ SAVE & CLOSE ALL FILES ]-------------------------- Basically the way the code stands now, it puts a link on the top of every topic that says "View all images in this topic" - even if you don't have the option to turn off images selected. Is there a way to tweak this hack so that it can check to see if the user has selected the option to turn images into links, and if they have, ONLY then display the "View all images in this topic" link? Right now I've got it hidden by log-in switches, but that's not good enough, as it's sort of a useless link if the user doesn't have images turned off. Would you be able to help? |
||
|
Thoul |
||
| Fri Mar 16, 2007 9:47 am Post subject: Re: Images as Links mod | ||
|
Wow, I haven't seen one of Retorq's mods in a while. It's a shame too, he had some good ideas about stuff. I remember this one, I used to use it myself.
The tweaks are easy enough. In viewtopic.php, find the line that says: Code: $template->assign_vars(array(
Before it, add: Code: if ( !$userdata['user_ou_img'] )
{ $template->assign_block_vars('show_img_link', array()); } Then just put the link in a switch like this: Code: <!-- BEGIN show_img_link -->
<a class="nav" href="{U_VIEW_TOPIC}&view_pics=1">{L_VIEW_ALL_IMAGES}</a> <!-- END show_img_link --> And that's that. |
||
|
Carter |
||
| Thu Mar 22, 2007 11:52 pm Post subject: Re: Images as Links mod | ||
|
Thoul you rock so hard.
|
||
Page 1 of 1