' . chr(13); } global $wpdb; $table_name = $wpdb->prefix . "nb_data"; $table_notifications = $wpdb->prefix . "nb_nottypes"; if (function_exists('date_default_timezone_set')) { $timezone = date_default_timezone_get(); date_default_timezone_set(get_option('timezone_string')); } $phptime = date('y-m-d H:i:s',time()); if (function_exists('date_default_timezone_set')) { date_default_timezone_set($timezone); } if (get_option('pd_nb_debug','false') == 'true') { $content .= '' . chr(13); } $sql = "SELECT timebegin,timeend,content,bgcolor,fontcolor,nottype FROM " . $table_name . " WHERE ('" . $phptime ."' >= timebegin AND '" . $phptime . "' <= timeend AND status = 1) OR (timebegin IS NULL AND status = 1) ORDER BY timebegin"; if (get_option('pd_nb_debug','false') == 'true') { $content .= '' . chr(13); } $myrows = $wpdb->get_results( $sql ); if (get_option('pd_nb_debug','false') == 'true') { $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); } if (count($myrows) != 0) { // Create messages $initialbgcolor = ''; $initialfontcolor = ''; $messages = '"text": ['; $annmessages = '"text": ['; $annfontsize = '"fontSize": ['; $backgroundcolor ='"backgroundColor": ['; $fontcolor = '"fontColor": ['; $afontcolor = '"aFontColor": ['; $annimages = '"image": ['; $annnames = '"name": ['; foreach ($myrows as $myrows) { if (get_option('pd_nb_debug','false') == 'true') { $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); } $messages .= '"' . str_replace('"','\'',stripslashes($myrows->content)) . '",'; if (empty($myrows->bgcolor)) { if(empty($myrows->nottype)) { $rawbgcolor = get_option('pd_nb_barcolor','darkred'); $backgroundcolor .= '"' . $rawbgcolor . '",'; } else { $rawbgcolor = $wpdb->get_var( "SELECT bgcolor FROM " . $table_notifications . " WHERE id = " . $myrows->nottype ); $backgroundcolor .= '"' . $rawbgcolor . '",'; }; } else { $rawbgcolor = $myrows->bgcolor; $backgroundcolor .= '"' . $rawbgcolor . '",'; }; // check for initial background color, so no swapping occurs when first building up the bar if (empty($initialbgcolor)) { $initialbgcolor = $rawbgcolor; }; if (empty($myrows->fontcolor)) { if(empty($myrows->nottype)) { $rawfontcolor = get_option('pd_nb_fontcolor','white'); $fontcolor .= '"' . $rawfontcolor . '",'; $afontcolor .= '"' . $rawfontcolor . '",'; } else { $rawfontcolor = $wpdb->get_var( "SELECT fontcolor FROM " . $table_notifications . " WHERE id = " . $myrows->nottype ); $fontcolor .= '"' . $rawfontcolor . '",'; $afontcolor .= '"' . $rawfontcolor . '",'; }; } else { $rawfontcolor = $myrows->fontcolor; $fontcolor .= '"' . $rawfontcolor .'",'; $afontcolor .= '"' . $rawfontcolor .'",'; }; // check for initial fontcolor, so no swapping occurs when first building up the bar if (empty($initialfontcolor)) { $initialfontcolor = $rawfontcolor; }; $tmpnottext = $wpdb->get_var( "SELECT name FROM " . $table_notifications . " WHERE id = " . $myrows->nottype ); if (empty($tmpnottext)) { $annmessages .= '"' . get_option('pd_nb_bartext', 'IMPORTANT!') . '",'; } else { $annmessages .= '"' . str_replace('"','\'',stripslashes($tmpnottext)) . '",'; } $tmpnotsize = $wpdb->get_var( "SELECT size FROM " . $table_notifications . " WHERE id = " . $myrows->nottype ); if (empty($tmpnotsize)) { $annfontsize .= '"' . get_option('pd_nb_notsize','18') . 'pt",'; } else { $annfontsize .= '"' . $tmpnotsize . 'pt",'; } if (empty($myrows->nottype)) { $annimages .= '"",'; $annnames .= '"' . get_option('pd_nb_bartext') . '",'; } else { $tmpnoticon = $wpdb->get_results( "SELECT icon,name FROM " . $table_notifications . " WHERE id = " . $myrows->nottype ); foreach ($tmpnoticon as $tmpnoticon) { $annimages .= '"' . $tmpnoticon->icon . '",'; $annnames .= '"' . $tmpnoticon->name . '",'; } } } $messages = substr($messages, 0, -1); $backgroundcolor = substr($backgroundcolor, 0, -1); $fontcolor = substr($fontcolor, 0, -1); $annmessages = substr($annmessages, 0, -1); $annfontsize = substr($annfontsize, 0, -1); $annimages = substr($annimages, 0, -1); $annnames = substr($annnames,0 ,-1); $content .= '' . chr(13); } else { if (get_option('pd_nb_debug','false') == 'true') { $sql = "SELECT * from " . $table_name; $myrows = $wpdb->get_results($sql); $content .= '' .chr(13); foreach ($myrows as $myrows) { $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); } } } if (get_option('pd_nb_debug','false') == 'true') { $content .= '' . chr(13); } if (get_option('pd_nb_showversion','true') == 'true') { return chr(13) . '' . chr(13) . $content . ''; } else { return $content; } } ?>