Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Code Snippet and functions - 8

Post your code snippets and functions for v7 here
1,011 posts | Last Activity on 03-10-2020 07:59 by Falk
Falk
Falk 03-10-2020 07:59, 23 days ago
Re: Facebook Comments Box for Each Profile They have Code Generators these days, you can try tinkering with it, https://developers.facebook.com/docs/plugins/comments/
SkeeredOfMyMind
SkeeredOfMyMind 03-10-2020 05:52, 23 days ago
Re: Facebook Comments Box for Each Profile I assume this does not work for PHP-Fusion 9.03? Any chance of this becoming an Infusion for 9.03 or updated for 9.03?
Falk
Re: Here is a tool for anyone experiencing the blank white page of death It will turn on all possible error reporting on Server and PHP level and display related errors correctly. It should give good pointers on what went wrong where.
SkeeredOfMyMind
SkeeredOfMyMind 12-09-2020 12:55, 1 month ago
Re: 2 Usefull extensions Incredible Douwe_Yntema, thanks for sharing. Please, please do keep sharing these, Infusions, Panels, and more too. I LOVE your work, it is FANTASTIC.
SkeeredOfMyMind
Re: Here is a tool for anyone experiencing the blank white page of death Awesome, thanks for sharing this, I've had this happen before and could not recover my site. Next time, hopefully, this works!
douwe_yntema
douwe_yntema 03-09-2020 19:58, 2 months ago
Re: 2 Usefull extensions Exactly
Wanabo
Wanabo 03-09-2020 19:44, 2 months ago
Re: 2 Usefull extensions Really nice extensions! If a user lost his password and can not for some reason use lostpassword I set it default to welcome+alittleextra and send him/her a mail. This is far more professional and easier!
douwe_yntema
douwe_yntema 02-09-2020 17:20, 2 months ago
Re: 2 Usefull extensions Thanks,

I was struggling the hole time with user passwords, so I made this. Maybe it can be included in future versions of PF.
Grimloch
Grimloch 01-09-2020 20:14, 2 months ago
Re: 2 Usefull extensions Very good. I added these codes to my new v8 system. Works great!
douwe_yntema
douwe_yntema 30-08-2020 14:16, 2 months ago
Re: 2 Usefull extensions For sites where the admin do the user management, I added two functions.

1- Add button for generating password

Open yoursite.com/includes/classes/UserFields.class.php, and search for (around line 229):

Code
 $this->html .= $this->basicInputField("user_new_password2", $locale['u135'], "64", $passRequired, "password", FALSE, "user_password");



Add the following code below:

Code
$this->html .= $this->basicInputField("generated_password", $locale['u135b'], "100", false, $locale['u126']);

 $this->html .= "\n";
 $this->html .= "\n";
 $this->html .= "\n";
 $this->html .= "";
 $this->html .= "function randomPassword(length) {";
 $this->html.= "var chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP1234567890';";
 $this->html .= "var pass = '';";
 $this->html .= "for (var x = 0; x < length; x++) {";
 $this->html.= "var i = Math.floor(Math.random() * chars.length);";
 $this->html .= "pass += chars.charAt(i);";
 $this->html .= "}";
 $this->html .= "inputform.user_new_password.value = pass;";
 $this->html .= "inputform.user_new_password2.value = pass;";
 $this->html .= "inputform.generated_password.value = pass;";
 $this->html .= "}";
 $this->html .= "";



Now open yoursite.com/locale/English/user_fields.php and search for (arround line 78):
Code
$locale['u135'] = "Confirm password";



add below:

Code

$locale['u135a'] = "Generate password";
$locale['u135b'] = "Generated password";




2- Send email to member when password has changed by admin

Open yoursite.com/includes/classes/UserFieldsInput.class.php and search for (arround line 74)
Code
private $_themeChanged = FALSE;



add below:
Code
private $_passwordchange = FALSE;



Search for (arround line 124):
Code
$this->_setCustomUserFieldsData();



add below:
Code
 if ($this->_passwordchange == TRUE) {
 require_once LOCALE.LOCALESET."admin/members_email.php";
 require_once INCLUDES."sendmail_include.php";

 $subject = $locale['email_passwordupd_subject'].$settings['sitename'];
 $replace_this = ["[USER_NAME]", "[PASSWORD]", "[SITENAME]", "[SITEUSERNAME]"];
 $replace_with = [$this->_userName, $this->_newUserPassword, $settings['sitename'], $settings['siteusername']];
 $message = str_replace($replace_this, $replace_with, $locale['email_passwordupd_message']);
 sendemail($this->_userName, $this->_userEmail, $settings['siteusername'], $settings['siteemail'], $subject, $message);
 $this->_passwordchange = FALSE;
 }
 



Search for (arround line 275)
Code
 if ($_isValidNewPassword === 0) {
 // New password is valid



add below
Code
$this->_passwordchange = TRUE;



Now open yoursite.com/locale/English/admin/member_email.php and search for (arround line 1)

Code
$locale['email_create_subject'] = "Account created at ";
$locale['email_create_message'] = "Hello [USER_NAME],
\r\n
Your account at [SITENAME] has been created.
\r\nYou can now login using the following details:
\r\n
Username: [USER_NAME]
\r\nPassword: [PASSWORD]
\r\nRegards,
\r\n[SITEUSERNAME]";



add below
Code

$locale['email_passwordupd_subject'] = "Password changed at ";
$locale['email_passwordupd_message'] = "Hello [USER_NAME],\n
Your password has been succesfully updated
Y\r\nYou can now login using the following details:
\r\n
Username: [USER_NAME]
\r\nPassword: [PASSWORD]
\r\nRegards,
\r\n[SITEUSERNAME]";

Chan
Chan 28-08-2020 11:50, 2 months ago
Re: Ver 8 why does not defined('DB_SHOUTBOX') work for me here? Great site. Glad it worked for you.
Grimloch
Grimloch 28-08-2020 05:59, 2 months ago
Re: Ver 8 why does not defined('DB_SHOUTBOX') work for me here? Who made the change to the title I set for this post????? Doesn't matter I suppose the fix worked fine.
Care to see??
https://whisperwillow.net
Grimloch
Grimloch 27-08-2020 19:20, 2 months ago
Re: Ver 8 why does not defined('DB_SHOUTBOX') work for me here? Thanks man. That did it; I had totally forgotten about that.
RobiNN
RobiNN 27-08-2020 19:08, 2 months ago
Re: Ver 8 why does not defined('DB_SHOUTBOX') work for me here? Please use Error log. Error says undefined DB_SHOUTBOX. V8 doesn't have autoloaded infusion_db.php.

Add this above your code
Code
if (!defined("DB_SHOUTBOX")) {
 define("DB_SHOUTBOX", DB_PREFIX."shoutbox");
}

Grimloch
Grimloch 27-08-2020 18:44, 2 months ago
Re: Ver 8 why does not defined('DB_SHOUTBOX') work for me here? Explanation. Why won't this work in 8.00.50?
Code
if (defined('DB_SHOUTBOX') && db_exists(DB_SHOUTBOX)) {
$result = dbquery("SELECT * FROM ".DB_SHOUTBOX."");
   if (dbrows($result) > 0) {
      $num_rows = dbrows($result);
        if ($num_rows) {
             $shouts = $num_rows;
         }
    }
} else { $shouts = 0; }


I have 2 shouts in the db.
Wanabo
Wanabo 15-08-2020 07:41, 2 months ago
Re: set_meta and add_to_meta not working. Yes! Fix is working. Tested:
set_meta("description", ...);
set_meta("keywords", ...);
add_to_meta("description", ...);
add_to_meta("keywords", ...);

Thanks for the quick fix.
RobiNN
RobiNN 14-08-2020 23:48, 2 months ago
Re: set_meta and add_to_meta not working. Fixed https://github.com/php-fusion/PHP-Fusion/commit/b981d7699685ee4c8d6314fc965f82b684ec4496
Wanabo
Wanabo 10-08-2020 21:40, 2 months ago
Re: set_meta and add_to_meta not working. Thanks for confirming. Hope a fix is available soon.
RobiNN
RobiNN 10-08-2020 21:27, 2 months ago
Re: set_meta and add_to_meta not working. Confirmed, the same problem is also in v9. (Both versions uses same OutputHandler class).
Wanabo
Wanabo 10-08-2020 21:14, 2 months ago
Re: set_meta and add_to_meta not working. I have the code below in an upper center panel. (just tiny part of it)
Code
set_meta("description", $data['forum_description']);



But when I take a look at the html source code the description is still default as set in table settings, column settings_name -> description, column settings_value -> blah blah

$data['forum_description'] is correctly retrieved out of the database, but also with plain text the set_meta and add_to_meta does not work.

What goes wrong here?
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.