prefix . "nb_data"; $table_notifications = $wpdb->prefix . "nb_nottypes"; $phptime = nb_get_tzepoch_time(time()); if (get_option('pd_nb_debug','false') == 'true') { $content .= '' . chr(13); } $sql = "SELECT name,epochtimebegin,epochtimeend,timebegin,timeend,content,bgcolor,fontcolor,nottype FROM " . $table_name . " WHERE ('" . $phptime ."' >= epochtimebegin AND '" . $phptime . "' <= epochtimeend AND status = 1) OR (epochtimebegin IS NULL AND status = 1) ORDER BY epochtimeend"; if (get_option('pd_nb_debug','false') == 'true') { $content .= '' . chr(13); } $myrows = $wpdb->get_results( $sql ); if (count($myrows) != 0) { 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); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); } // 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); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' . chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $content .= '' .chr(13); $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','16') . '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_showversion','true') == 'true' || get_option('pd_nb_debug','false') == 'true') { return chr(13) . '' . chr(13) . $content . ''; } else { return $content; } } ?>