MyBB Community Forums

Full Version: plugin - how to show error from plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
hi all,

i have written a plugin which checks how many youtube videos are added in message/thread/post.

it individualy checks all videos, and finds if they are ios/iphone compatible.

if video is not ios compatible it shows error. all the code is working fine, but i am not able to show errror. the error is not showing and post is submitting.

any idea???


my code is attacked in a separate php file.
===================================



<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}


// user report hooks
$plugins->add_hook("parse_message_start", "haltmedia_run");
# tried with all following but no luck yet.
//$plugins->add_hook("parse_message_end", "haltmedia_run");
//$plugins->add_hook("parse_message", "haltmedia_run");
//$plugins->add_hook("post_output_page", "haltmedia_run");
//$plugins->add_hook("text_parse_message", "haltmedia_run");

function haltmedia_run(&$message){
echo 'i am here ' . THIS_SCRIPT." File: ".__FILE__ . " Line: " .__LINE__; #i am here newthread.php File: C:\wamp\www\propertytribes\inc\plugins\yts.php Line: 11
$data_in_post = $message;
$lines = explode(PHP_EOL, $data_in_post);
$pattern = 'http://www.youtube.com/watch?v=';

if(preg_match_all("#\[video=youtube](.*?)\[/video]#s", $data_in_post, $addresses))
{
foreach ($addresses[1] as $key => $val) {
if (strlen(strstr($val, $pattern)) > 0) {
$videoid = substr($val, strlen($pattern));
}
$feedURL2= trim('http://gdata.youtube.com/feeds/api/videos/'.$videoid); # i.e, http://gdata.youtube.com/feeds/api/videos/kffacxfA7G4
$input = @file_get_contents($feedURL2);
$iphone = 1;
$msgip= '';
$flv = '';
if (strlen(strstr($input, "format='1'")) > 0) {
$iphone = 1;
$msgip.="IPhone=YES";
} else {
$iphone = 0;
$msgip.="IPhone=NO";
}
if (strlen(strstr($input, "format='5'")) > 0) {
$flv .=",FLASH=YES";
} else {
$flv .=",FLASH=NO";
}

if(!$iphone){

$error = 'this video does not support for ios : remove ti : '.$addresses[0][$key];
error($error);

#tried the following too but no luck
// $error_inline.= $error;
// eval("\$errorr_inline = \"".$templates->get("error_inline")."\";");
// output_page($error_inline);
// break;
// exit;
// return $message;
}
}
}
}

function yts_info() {
return array(
"name" => "youtube video stop",
"description" => 'The Youtube Video Plugin Checks whether youtube video for ios is supported or not.',
"website" => '',
"author" => "[email protected]",
"authorsite" => "",
"version" => "1.0",
"guid" => "yts123youname789goeshere000",
"compatibility" => "16*"
);
}

function yts_install(){
global $db, $mybb, $templates, $lang, $plugins;
}

function yts_activate(){
global $db, $mybb, $templates, $lang, $plugins;
$yts_group = array(
'gid' => 'NULL',
'name' => 'yts',
'title' => 'Youtube Video Check For iPhone',
'description' => 'Settings For youtube Video check for iPhone.',
'disporder' => "1",
'isdefault' => 'no',
);

$dup_group_title ='';
$errors= '';
$query = $db->simple_select("settinggroups", "title", "name='yts'");
if($db->num_rows($query) > 0)
{
$dup_group_title = $db->fetch_field($query, 'title');
}
if(empty($dup_group_title) || $dup_group_title == null ){
$db->insert_query('settinggroups', $yts_group);
}
rebuild_settings();
}

function yts_uninstall()
{
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yts'");
rebuild_settings();
}

function yts_deactivate() {
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='yts'");
rebuild_settings();
}
?>


=== videos i am using here :



/*
try these videos in post or thread or in reply.

video=youtube]http://www.youtube.com/watch?v=_OBlgSz8sSM[/video]
video=youtube]http://www.youtube.com/watch?v=d_czxTedXpc[/video]
video=dailymotion]http://www.dailymotion.com/video/xkm1em_adalat-29th-august-2011-at-www-apnatvforum-com-pk_shortfilms[/video]
video=youtube]http://www.youtube.com/watch?v=6Jlv8F9cerA[/video]
video=youtube]http://www.youtube.com/watch?v=zBbMAJgBymA[/video]

video=dailymotion]http://www.dailymotion.com/video/xkm1em_adalat-29th-august-2011-at-www-apnatvforum-com-pk_shortfilms[/video]

video=youtube]http://www.youtube.com/watch?v=4JipHEz53sU[/video]


*/
Paste the code somewhere it'll be easier to read, like pastebin.com
i have attaced a separate php file ,the whole plugin ??? let me know if you cant see it.
(2012-02-02, 10:24 AM)Beardy Wrote: [ -> ]Paste the code somewhere it'll be easier to read, like pastebin.com

i have attaced a separate php file ,the whole plugin ??? let me know if you cant see it.
hi all dudes, i am astonished , no body has replied me yet.

any one from development or support team???
hi all dudes, i am astonished , no body has replied me yet.

any one from development or support team???
(2012-02-02, 10:24 AM)Beardy Wrote: [ -> ]Paste the code somewhere it'll be easier to read, like pastebin.com

No, simply put all of your plugin code that you want us to read in [php] tags Smile
(2012-02-02, 10:34 PM)Tom K. Wrote: [ -> ]
(2012-02-02, 10:24 AM)Beardy Wrote: [ -> ]Paste the code somewhere it'll be easier to read, like pastebin.com

No, simply put all of your plugin code that you want us to read in [php] tags Smile

That would still display the code in a small box, and since the container on this forum is small enough, long lines would be frivolous to read.

And the code tags don't support scrolling for mobile users, which is why I needed him to put it somewhere more universally readable because I could neither waste bandwidth downloading the file or be bothered trying to read the code in his post on a mobile.
See this thread, the solution to it will work for you too I believe http://community.mybb.com/thread-112321.html
(2012-02-02, 10:52 PM)euantor Wrote: [ -> ]See this thread, the solution to it will work for you too I believe http://community.mybb.com/thread-112321.html

yes, that should work if he follows the whole process
(2012-02-02, 10:41 PM)Beardy Wrote: [ -> ]And the code tags don't support scrolling for mobile users, which is why I needed him to put it somewhere more universally readable because I could neither waste bandwidth downloading the file or be bothered trying to read the code in his post on a mobile.

/offtopic downloading the file consumes less bandwidth than visiting a website with a logo and other images which besides that also displays the file you've downloaded (not counting CSS files, Javascript files and of course the page itself) - I'm referring to pastebin.
(2012-02-03, 02:33 PM)Pirata Nervo Wrote: [ -> ]/offtopic downloading the file consumes less bandwidth than visiting a website with a logo and other images which besides that also displays the file you've downloaded (not counting CSS files, Javascript files and of course the page itself) - I'm referring to pastebin.

I had access to the cached images from pastebin the previous time I had visited it on my phone, and when I attempted to download the file it just hung in the queue, and if my connection would have dropped half way through download the entire file would have been cancelled.
(2012-02-03, 02:43 PM)Beardy Wrote: [ -> ]
(2012-02-03, 02:33 PM)Pirata Nervo Wrote: [ -> ]/offtopic downloading the file consumes less bandwidth than visiting a website with a logo and other images which besides that also displays the file you've downloaded (not counting CSS files, Javascript files and of course the page itself) - I'm referring to pastebin.

Loading a website over a 3G network is able to cut the work into segments, and also has access to the cache'd images from pastebin the previous time I had visited it on my phone.

When I attempted to download the file it just hung in the queue, and if my connection would have dropped half way through download the entire file would have been cancelled.

Oh yeah if you had visited it in the past yes, it should not download those images, neither the javascript or css files. However, it will still download the HTML page containing more than the actual file.

I'm not entirely sure what you mean by "3G network is able to cut the work into segments" but the bandwidth consumed at the end of the month is obviously bigger when you download a webpage like that one rather than just downloading the file itself - unless I'm missing something here.
Pages: 1 2