Hi guys,
why this plugin doesn't work?
It doesn't access to function vars_parse_img_callback1
no one can help me?
up
why this plugin doesn't work?
It doesn't access to function vars_parse_img_callback1
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("parse_message", "vars_parse");
function vars_envy_info()
{
global $mybb, $db, $lang;
return array(
'name' => 'Global Plugin',
'description' => 'Questo plugin fa eseguire funzioni ed altre cose necessarie al funzionamento del forum.',
'author' => 'chack1172',
'version' => '1.0',
'codename' => '',
'compatibility' => '18*'
);
}
function vars_envy_activate()
{
}
function vars_envy_deactivate()
{
}
function vars_parse(&$message) {
$message = preg_replace_callback("#\[img\](\r\n?|\n?)(https?://([^<>\"']+?))\[/img\]#is", "vars_parse_img_callback1", $message);
}
function vars_parse_img($url, $dimensions=array(), $align='') {
global $lang, $fid, $pid, $mybb;
$url = trim($url);
$url = str_replace("\n", "", $url);
$url = str_replace("\r", "", $url);
$name = basename($url);
if(!file_exists(ROOT . "/uploads/threads/"))
mkdir(ROOT . "/uploads/threads/");
if(!file_exists(ROOT . "/uploads/threads/threads_{$tid}/"))
mkdir(ROOT . "/uploads/threads/threads_{$tid}/");
if(!file_exists(ROOT . "/uploads/threads/threads_{$tid}/post_{$pid}/"))
mkdir(ROOT . "/uploads/threads/threads_{$tid}/post_{$pid}/");
if(!file_exists(ROOT . "/uploads/threads/threads_{$tid}/post_{$pid}/{$name}")) {
$data = file_get_contents($url);
file_put_contents(ROOT . "/uploads/threads/threads_{$tid}/post_{$pid}/{$name}", $data);
}
$url = $mybb->settings['bburl'] . "/uploads/threads/threads_{$tid}/post_{$pid}/{$name}";
$css_align = '';
if($align == "right")
$css_align = " style=\"float: right;\"";
else if($align == "left")
$css_align = " style=\"float: left;\"";
$alt = basename($url);
$alt = htmlspecialchars_decode($alt);
if(my_strlen($alt) > 55)
$alt = my_substr($alt, 0, 40).'...'.my_substr($alt, -10);
$alt = htmlspecialchars_uni($alt);
$alt = $lang->sprintf($lang->posted_image, $alt);
if(isset($dimensions[0]) && $dimensions[0] > 0 && isset($dimensions[1]) && $dimensions[1] > 0)
return "<img src=\"{$url}fdd\" width=\"{$dimensions[0]}\" height=\"{$dimensions[1]}\" border=\"0\" alt=\"{$alt}\"{$css_align} />";
else
return "<img src=\"{$url}fd\" border=\"0\" alt=\"{$alt}\"{$css_align} />";
}
function vars_parse_img_callback1($matches) {
return $this->vars_parse_img($matches[2]);
}
no one can help me?
up