function mediashare_randomblock_modify($blockinfo) { // Get current content $vars = pnBlockVarsFromContent($blockinfo['content']); // Defaults if (!isset($vars['type'])) { $vars['type'] = 'all'; } if (!isset($vars['albumId'])) { $vars['albumId'] = ''; } if (!isset($vars['cacheTime'])) { $vars['cacheTime'] = 30; } if (!isset($vars['html'])) { $vars['html'] = '<div class="mediashare-random-block"><a href="${originalURL}" target="_new"><img src="${thumbnailURL}" alt=""></a><br/><b>${title}</b><br/>Album: <a href="${albumURL}">${albumTitle}</a></div>'; } if (!isset($vars['useRefreshTime'])) { $vars['useRefreshTime'] = 0; } $render =& pnRender::getInstance('mediashare', false); $render->assign($vars); return $render->fetch('mediashare_block_random.html'); }
/** * modify block settings */ function template_firstblock_modify($blockinfo) { // Create output object $output = new pnHTML(); // Get current content $vars = pnBlockVarsFromContent($blockinfo['content']); // Defaults if (empty($vars['numitems'])) { $vars['numitems'] = 5; } // Create row $row = array(); $output->SetOutputMode(_PNH_RETURNOUTPUT); $row[] = $output->Text(_NUMITEMS); $row[] = $output->FormText('numitems', pnVarPrepForDisplay($vars['numitems']), 5, 5); $output->SetOutputMode(_PNH_KEEPOUTPUT); // Add row $output->SetInputMode(_PNH_VERBATIMINPUT); $output->TableAddRow($row, 'left'); $output->SetInputMode(_PNH_PARSEINPUT); // Return output return $output->GetOutput(); }
function blocks_menu_select($row) { global $pntheme; list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); // Break out options from our content field $vars = pnBlockVarsFromContent($row['content']); $row['content'] = ""; // Defaults if (empty($vars['style'])) { $vars['style'] = 1; } // What style of menu $output = '<tr><td class="pn-title">' . _MENU_FORMAT . '</td><td></td></tr>'; $output .= '<tr><td class="pn-normal">' . _MENU_AS_LIST . ':</td><td><input type="radio" name="style" value="1"'; if ($vars['style'] == 1) { $output .= ' checked'; } $output .= '></td></tr><tr><td class="pn-normal">' . _MENU_AS_DROPDOWN . ':</td><td><input type="radio" name="style" value="2"'; if ($vars['style'] == 2) { $output .= ' checked'; } $output .= ' /></td></tr>'; // What to display $output .= '<tr><td class="pn-title">' . _DISPLAY . '</td><td></td></tr>'; $output .= '<tr><td class="pn-normal">' . _MENU_MODULES . ':</td><td><input type="checkbox" value="1" name="displaymodules"'; if (!empty($vars['displaymodules'])) { $output .= ' checked'; } $output .= ' /></td></tr><tr><td class="pn-normal">' . _WAITINGCONT . ':</td><td><input type="checkbox" value="1" name="displaywaiting"'; if (!empty($vars['displaywaiting'])) { $output .= ' checked'; } $output .= ' /></td></tr>'; // Content $c = 1; $output .= "</table><table>"; $output .= "<tr><td valign=\"top\" class=\"pn-title\">" . _MENU_CONTENT . ":</td><td><table border=\"1\"><tr><td align=\"center\" class=\"pn-normal\" style=\"color:{$pntheme['table_header_text']}; background-color:{$pntheme['table_header']}; text-align:center\"><b>" . _TITLE . "</b></td><td align=\"center\" class=\"pn-normal\" style=\"color:{$pntheme['table_header_text']}; background-color:{$pntheme['table_header']}; text-align:center\"><b>" . _URL . "</b></td><td align=\"center\" class=\"pn-normal\" style=\"color:{$pntheme['table_header_text']}; background-color:{$pntheme['table_header']}; text-align:center\"><b>" . _MENU_DESCRIPTION . " </b><span class=\"pn-sub\"><b>(" . _OPTIONAL . ")</b></span></td><td align=\"center\" class=\"pn-normal\" style=\"color:{$pntheme['table_header_text']}; background-color:{$pntheme['table_header']}; text-align:center\"><b>" . _DELETE . "</b></td><td align=\"center\" class=\"pn-normal\" style=\"color:{$pntheme['table_header_text']}; background-color:{$pntheme['table_header']}; text-align:center\"><b>" . _INSERT_BLANK_AFTER . "</b></td></tr>"; if (!empty($vars['content'])) { $contentlines = explode("LINESPLIT", $vars['content']); foreach ($contentlines as $contentline) { $link = explode('|', $contentline); $output .= "<tr><td valign=\"top\"><input type=\"text\" name=\"linkname[{$c}]\" size=\"30\" maxlength=\"255\" value=\"" . pnVarPrepForDisplay($link[1]) . "\" class=\"pn-normal\"></td><td valign=\"top\"><input type=\"text\" name=\"linkurl[{$c}]\" size=\"30\" maxlength=\"255\" value=\"" . pnVarPrepForDisplay($link[0]) . "\" class=\"pn-normal\"></td><td valign=\"top\"><input type=\"text\" name=\"linkdesc[{$c}]\" size=\"30\" maxlength=\"255\" value=\"" . pnVarPrepForDisplay($link[2]) . "\" class=\"pn-normal\" /></td><td valign=\"top\"><input type=\"checkbox\" name=\"linkdelete[{$c}]\" value=\"1\" class=\"pn-normal\"></td><td valign=\"top\"><input type=\"checkbox\" name=\"linkinsert[{$c}]\" value=\"1\" class=\"pn-normal\" /></td></tr>\n"; $c++; } } $output .= "<tr><td><input type=\"text\" name=\"new_linkname\" size=\"30\" maxlength=\"255\" class=\"pn-normal\" /></td><td><input type=\"text\" name=\"new_linkurl\" size=\"30\" maxlength=\"255\" class=\"pn-normal\" /></td><td class=\"pn-normal\"><input type=\"text\" name=\"new_linkdesc\" size=\"30\" maxlength=\"255\" class=\"pn-normal\" /></td><td class=\"pn-normal\">" . _NEWONE . "</td><td class=\"pn-normal\"><input type=\"checkbox\" name=\"new_linkinsert\" value=\"1\" class=\"pn-normal\" /></td></tr>\n"; $output .= '</table></td></tr>'; return $output; }
function blocks_rss_refresh($row, $forceupdate = 0) { list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); // Get arguments $args = pnBlockVarsFromContent($row['content']); // Check for URL if (empty($args['rssurl'])) { return $row; } $past = time() - $row['refresh']; if (!$forceupdate && $row['unix_update'] > $past) { return $row; } $rss = parse_url($args['rssurl']); if (!isset($rss['port'])) { $rss['port'] = 80; } if (!isset($rss['query'])) { $rss['query'] = ''; } // retrive the rss file $fp = fsockopen($rss['host'], $rss['port'], $errno, $errstr, 10); if (!$fp) { $next_try = time() + 600; $column =& $pntable['blocks_column']; $sql = "UPDATE {$pntable['blocks']}\n SET {$column['last_update']}=" . pnVarPrepForStore($next_try) . "\n WHERE {$column['bid']}=" . pnVarPrepForStore($row['bid']); $result = $dbconn->Execute($sql); $row['title'] .= ' *'; return $row; } fputs($fp, 'GET ' . $rss['path'] . '?' . $rss['query'] . " HTTP/1.0\r\n"); // cocomp 2002/07/13 Added Referer & User-Agent as some sites won't give RSS // feed otherwise fputs($fp, 'HOST: ' . $rss['host'] . "\r\n"); fputs($fp, 'Referer: ' . pnGetBaseURL() . "\r\n"); fputs($fp, 'User-Agent: ' . pnConfigGetVar('Version_ID') . ': ' . pnConfigGetVar('Version_Sub') . ': ' . pnConfigGetVar('Version_Num') . "\r\n\r\n"); $rss_file = ''; $start_time = time(); while (!feof($fp)) { $line = fgets($fp, 4096); if (empty($go)) { if ($line[0] == '<') { $go = true; } /* * Fix on SF-bug #566489 */ if (preg_match("/[\n]?[\r]{1}[^\n]{1}/", $line)) { $line = preg_replace("/([\n]?[\r]{1})([^\n]{1})/", "\n\\2", $line); $lines = explode("\n", $line); $first = true; foreach ($lines as $line) { if ($first) { $first = !$first; } else { $rss_file[] = trim($line); } } } /* * End of fix */ } else { /* * Fix on SF-bug #566489 */ if (preg_match("/[\n]?[\r]{1}[^\n]{1}/", $line)) { $line = preg_replace("/([\n]?[\r]{1})([^\n]{1})/", "\n\\2", $line); $lines = explode("\r\n", $line); foreach ($lines as $line) { $rss_file[] = trim($line); } } else { $rss_file[] = trim($line); } /* * End of fix */ } if (time() - $start_time == 5) { // if the source server is too slow, we give up. 5 seconds is more then enough time fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); $column =& $pntable['blocks_column']; $sql = "UPDATE {$pntable['blocks']}\n SET {$column['last_update']}=0\n WHERE {$column['bid']}=" . pnVarPrepForStore($row['bid']); $result = $dbconn->Execute($sql); return $row; } } fputs($fp, "Connection: close\r\n\r\n"); fclose($fp); $struct = rss_parse_array($rss_file); // parse the file $channel_data = ''; $image_data = ''; $item_data = array(); $search_data = ''; $total_items = 0; $cur_block = ''; foreach ($struct as $v) { if (!is_array($v)) { continue; } if ($v['type'] == 'open') { switch ($v['tag']) { case 'channel': $cur_block = 'channel'; break; case 'image': $cur_block = 'image'; break; case 'item': $cur_block = 'item'; break; case 'textinput': $cur_block = 'textinput'; break; } } elseif ($v['type'] == 'close') { switch ($v['tag']) { case 'channel': $cur_block = ''; break; case 'image': $cur_block = ''; break; case 'item': $cur_block = ''; $total_items++; break; case 'textinput': $cur_block = ''; break; } } elseif ($v['type'] == 'complete') { $tag = $v['tag']; switch ($cur_block) { case 'channel': $channel_data[$tag] = $v['value']; break; case 'image': $image_data[$tag] = $v['value']; break; case 'item': $item_data[$total_items][$tag] = $v['value']; break; case 'textinput': $search_data[$tag] = $v['value']; break; } } } // start generating content $content = ''; // image & link if (!empty($args['showimage'])) { // cocomp 2002/07/13 - prevent E_ALL errors check for $image_data if (isset($image_data) && is_array($image_data)) { if (isset($image_data['url']) && $image_data['url'] != 'http://yoursite.com/images/logo.gif') { if (!$image_data['link']) { $image_data['link'] = $channel_data['link']; } if (!$image_data['title']) { $image_data['title'] = $channel_data['title']; } if (!isset($image_data['description'])) { if ($channel_data['description']) { $image_data['description'] = $channel_data['description']; } else { $image_data['description'] = 'No description provided...'; } } if (!isset($image_data['width'])) { $image_data['width'] = 88; } if (!isset($image_data['height'])) { $image_data['height'] = 31; } if ($args['altstyle']) { $content .= "<a class=\"pn-normal\" href=\"{$image_data['link']}\" target=\"_blank\" title=\"{$image_data['description']}\">\n" . "<img src=\"{$image_data['url']}\" border=\"0\" alt=\"{$image_data['title']}\" width=\"{$image_data['width']}\" height=\"{$image_data['height']}\"></a>\n" . "<br>\n"; } else { $content .= "<div align=\"center\" style=\"text-align:center\"><a class=\"pn-normal\" href=\"{$image_data['link']}\" target=\"_blank\" title=\"{$image_data['description']}\">\n" . "<img src=\"{$image_data['url']}\" border=\"0\" alt=\"{$image_data['title']}\" width=\"{$image_data['width']}\" height=\"{$image_data['height']}\"></a>\n" . "</div>"; } } } } // pub date if (isset($channel_data['pubDate'])) { $content .= "<div align=\"center\" style=\"text-align:center\">\n" . "<b>({$channel_data['pubDate']})</b></div>"; } // items if ($total_items > $args['maxitems']) { // we don't want a bunch of empty item spaces $total_items = $args['maxitems']; } for ($i = 0; $i < $total_items; $i++) { if ($i) { if ($args['altstyle']) { $content .= "\n"; } else { $content .= "<hr noshade size=\"1\" width=\"50%\">\n"; } } if (empty($item_data[$i]['title'])) { $item_data[$i]['title'] = '<i>[no title]</i>'; } // cocomp 2002/07/13 prevent E_ALL errors check for $item_data[$i]['link'] if (isset($item_data[$i]['link'])) { if ($args['altstyle']) { $content .= '<font class="pn-normal"><strong><big>·</big></strong> </font><a class="pn-normal" href="' . $item_data[$i]['link'] . '" title="' . $item_data[$i]['title'] . '" target="_blank">' . $item_data[$i]['title'] . '</a><br>'; } else { $content .= '<a href="' . $item_data[$i]['link'] . '" title="' . $item_data[$i]['title'] . '" target="_blank" class="pn-normal">' . $item_data[$i]['title'] . '</a><br>'; } } if (!empty($args['showdescriptions']) && isset($item_data[$i]['description'])) { $content .= '<font class="pn-normal"><i>' . $item_data[$i]['description'] . '</i></font><br>'; } } // search if (!empty($args['showsearch'])) { if (isset($search_data['link']) && isset($search_data['name']) && isset($search_data['title'])) { if ($args['altstyle']) { $content .= '<br>'; } else { $content .= '<hr noshade size="1" width="50%">'; } $content .= "<center><form method=\"get\" action=\"{$search_data['link']}\" target=\"_blank\">\n"; if ($search_data['description']) { $content .= htmlspecialchars($search_data['description']) . '<br>'; } $content .= "<input type=\"text\" name=\"{$search_data['name']}\" size=\"15\"><br><input type=\"submit\" value=\"{$search_data['title']}\"></form></center>\n"; } // copyright if (isset($channel_data['copyright'])) { $content .= "<font class=\"pn-normal\">{$channel_data['copyright']}</font>\n"; } // done with rdf file if ($args['altstyle']) { $content .= "<br><a class=\"pn-normal\" href=\"{$channel_data['link']}\" target=\"_blank\"><b>_RSSREADMORE</b></a>\n"; } else { $content .= "<div align=\"right\" style=\"text-align:right\"><a class=\"pn-normal\" href=\"{$channel_data['link']}\" target=\"_blank\"><b>_RSSREADMORE</b></a></div>\n"; } $content = "<font class=\"pn-normal\">{$content}</font>\n"; } $args['headlines'] = $content; $row['content'] = pnBlockVarsToContent($args); $column =& $pntable['blocks_column']; // cocomp 2002/07/13 cross db compatibility - changed now() to DBTimestamp $sql = "UPDATE {$pntable['blocks']}\n SET {$column['content']}='" . pnVarPrepForStore($row['content']) . "',\n {$column['last_update']}=" . $dbconn->DBTimestamp(time()) . "\n WHERE {$column['bid']}=" . pnVarPrepForStore($row['bid']); $result = $dbconn->Execute($sql); if ($dbconn->ErrorNo() != 0) { $row['title'] .= ' *'; } return $row; }
function blocks_past_select($row) { list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); // Break out options from our content field $vars = pnBlockVarsFromContent($row['content']); // Defaults if (empty($vars['limit'])) { $vars['limit'] = 10; } $row['content'] = ""; // Number of stories $output = "<tr><td class=\"pn-normal\">Maximum number of stories to display:</td><td><input type=\"text\" name=\"limit\" size=\"2\" value=\"" . pnVarPrepForDisplay($vars['limit']) . "\"></td></tr>"; return $output; }
function blocks_stories_select($row) { list($dbconn) = pnDBGetConn(); $pntable = pnDBGetTables(); // Break out options from our content field $vars = pnBlockVarsFromContent($row['content']); // Defaults if (empty($vars['storiestype'])) { $vars['storiestype'] = 2; } if (empty($vars['topic'])) { $vars['topic'] = -1; } if (empty($vars['category'])) { $vars['category'] = -1; } if (empty($vars['limit'])) { $vars['limit'] = 10; } $row['content'] = ""; // Which stories to list $output = '<tr><td class="pn-normal">' . _STORIESDISPLAYALL . ':</td><td><input type="radio" name="storiestype" value="2"'; if ($vars['storiestype'] == 2) { $output .= ' checked'; } $output .= '></td></tr><tr><td class="pn-normal">' . _STORIESDISPLAYFRONTPAGE . ':</td><td><input type="radio" name="storiestype" value="3"'; if ($vars['storiestype'] == 3) { $output .= ' checked'; } $output .= '></td></tr><tr><td class="pn-normal">' . _STORIESDISPLAYNONFRONTPAGE . ':</td><td><input type="radio" name="storiestype" value="1"'; if ($vars['storiestype'] == 1) { $output .= ' checked'; } $output .= '></td></tr>'; // Which topic $output .= '<tr><td class="pn-normal">' . _STORIESTOPIC . ':</td><td><select name="topic" size="1">'; $output .= '<option value="-1\\"'; if ($vars['topic'] == -1) { $output .= " selected"; } $output .= '>' . _ALL . '</option>'; $topicscolumn =& $pntable['topics_column']; $query = "SELECT {$topicscolumn['tid']},\n {$topicscolumn['topicname']}\n FROM {$pntable['topics']}\n ORDER BY {$topicscolumn['topicname']}"; $result = $dbconn->Execute($query); while (!$result->EOF) { list($tid, $tname) = $result->fields; $result->MoveNext(); $output .= "<option value=\"{$tid}\""; if ($vars['topic'] == $tid) { $output .= ' selected'; } $output .= '>' . pnVarPrepForDisplay($tname) . '</option>'; } $output .= '</select></td></tr>'; // Which category $output .= '<tr><td class="pn-normal">' . _STORIESCATEGORY . ':</td><td><select name="category" size="1">'; $output .= "<option value=\"-1\""; if ($vars['category'] == -1) { $output .= ' selected'; } $output .= '>' . _ALL . '</option>'; $storiescatcolumn =& $pntable['stories_cat_column']; $query = "SELECT {$storiescatcolumn['catid']},\n {$storiescatcolumn['title']}\n FROM {$pntable['stories_cat']}\n ORDER BY {$storiescatcolumn['title']}"; $result = $dbconn->Execute($query); while (!$result->EOF) { list($catid, $cattitle) = $result->fields; $result->MoveNext(); $output .= "<option value=\"{$catid}\""; if ($vars['category'] == $catid) { $output .= ' selected'; } $output .= ">" . pnVarPrepForDisplay($cattitle) . "</option>"; } $output .= "</select></td></tr>"; // Number of stories $output .= '<tr><td class="pn-normal">' . _STORIESMAXNUM . ':</td><td><input type="text" name="limit" size="2" value="' . pnVarPrepForDisplay($vars['limit']) . '"></td></tr>'; return $output; }