PageRenderTime 63ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_myblog/admin.myblog.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 1828 lines | 1572 code | 175 blank | 81 comment | 118 complexity | 2fee42202c94248d5405f7619989d302 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. (defined('_VALID_MOS') OR defined('_JEXEC')) or die('Direct Access to this location is not allowed.');
  3. global $sectionid, $database, $_MY_CONFIG, $section, $catid, $jax, $sections, $mainframe;
  4. include_once(dirname(dirname(dirname(dirname(__FILE__)))) . '/components/libraries/cmslib/spframework.php');
  5. $cms =& cmsInstance('CMSCore');
  6. $cms->load('helper', 'url');
  7. require_once($cms->get_path('root').'/components/com_myblog/defines.myblog.php');
  8. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  9. include_once($cms->get_path('root') . '/includes/sef.php');
  10. }elseif(cmsVersion() == _CMS_JOOMLA15){
  11. //include_once($cms->get_path('root') . '/plugins/system/sef.php');
  12. }
  13. if(!class_exists('AzrulJXCachedTemplate'))
  14. include_once($cms->get_path('plugins') . '/system/pc_includes/template.php');
  15. if(!defined('JAX_SITE_ROOT'))
  16. require_once ($cms->get_path('plugins') . '/system/pc_includes/ajax.php');
  17. require_once ($cms->get_path('root') . '/components/com_myblog/functions.myblog.php');
  18. require_once ($cms->get_path('root') . "/administrator/components/com_myblog/config.myblog.php");
  19. require_once ($cms->get_path('root') . "/administrator/components/com_myblog/functions.admin.php");
  20. $_MY_CONFIG = new MYBLOG_Config();
  21. $sectionid = $_MY_CONFIG->sectionid;
  22. $catid = $_MY_CONFIG->catid;
  23. $sections = $_MY_CONFIG->get('managedSections');
  24. if ($sections == "")
  25. $sections = "-1";
  26. $jax = new JAX($cms->get_path('plugin-live') . "/system/pc_includes");
  27. $jax->setReqURI($cms->get_path('live') . "/administrator/index2.php");
  28. if(@isset($_REQUEST['task']) && ($_REQUEST['task'] == 'azrul_ajax')){
  29. // Only include ajax file if needed
  30. require_once('ajax.myblog.php');
  31. }
  32. $jax->process();
  33. $cid = cmsGetVar('cid', 0,'REQUEST');
  34. $task = cmsGetVar('task', '', 'POST');
  35. $title = '';
  36. if (empty ($task)){
  37. $task = cmsGetVar('task' ,'comments', 'GET');
  38. }
  39. if ($task == "xajax") {
  40. showAjaxedAdmin();
  41. } else {
  42. ob_start();
  43. showAjaxedAdmin($task);
  44. $panel = ob_get_contents();
  45. ob_end_clean();
  46. ob_start();
  47. $content = '';
  48. $title = '';
  49. switch ($task) {
  50. case "config" :
  51. if(cmsVersion() != _CMS_JOOMLA15)
  52. $title = 'Configuration';
  53. showConfig();
  54. break;
  55. case "savesettings" :
  56. saveConfig();
  57. break;
  58. case "license":
  59. if(cmsVersion() != _CMS_JOOMLA15)
  60. $title = 'License Agreement';
  61. showLicense();
  62. break;
  63. case "info" :
  64. showInfo();
  65. break;
  66. case "publish" :
  67. case "publishEntries" :
  68. publishBlog($cid, 1, $option);
  69. break;
  70. case "unpublish" :
  71. case "unpublishEntries" :
  72. publishBlog($cid, 0, $option);
  73. break;
  74. case "publishBots" :
  75. publishBots($cid, 1, $option);
  76. break;
  77. case "unpublishBots" :
  78. publishBots($cid, 0, $option);
  79. break;
  80. case "publishMambots" :
  81. publishMambots($cid, 1, $option);
  82. break;
  83. case "unpublishMambots" :
  84. publishMambots($cid, 0, $option);
  85. break;
  86. case "addBot" :
  87. addBot();
  88. break;
  89. case "saveBot" :
  90. saveBot();
  91. break;
  92. case "deleteBots" :
  93. deleteBots($cid, $option);
  94. break;
  95. case "frontpage" :
  96. frontpageBlog($cid, 1, $option);
  97. break;
  98. case "unfrontpage" :
  99. frontpageBlog($cid, 0, $option);
  100. break;
  101. case "category" :
  102. if(cmsVersion() != _CMS_JOOMLA15)
  103. $title = 'Manage Tags';
  104. showCategories();
  105. break;
  106. case "about" :
  107. showAbout();
  108. break;
  109. // case "bots" :
  110. //
  111. // showBots();
  112. // break;
  113. case "orderup" :
  114. case "orderdown" :
  115. orderBot(intval($cid[0]), ($task == 'orderup' ? -1 : 1), $option, $client);
  116. break;
  117. case "install" :
  118. showInstallWizard();
  119. break;
  120. case "saveInstall" :
  121. saveInstall();
  122. break;
  123. case "exitInstall" :
  124. cmsRedirect("index2.php?option=com_myblog", "Installation complete.Thank you for using MyBlog!");
  125. break;
  126. case "remove":
  127. case "deleteEntries" :
  128. removeBlogs($cid);
  129. break;
  130. case "contentmambots" :
  131. if(cmsVersion() != _CMS_JOOMLA15)
  132. $title = 'Content mambots integration';
  133. showMambots();
  134. break;
  135. case "maintenance":
  136. if(cmsVersion() != _CMS_JOOMLA15)
  137. $title = 'Maintenance';
  138. showMaintenance();
  139. break;
  140. case "fixlinks":
  141. myFixLinks();
  142. cmsRedirect("index2.php?option=$option&task=maintenance", "$new_permalinks new permalinks added. $modified_permalinks permalinks modified.");
  143. break;
  144. case "clearcache":
  145. myClearCache();
  146. cmsRedirect('index2.php?option=com_myblog&task=maintenance', 'Cache cleared.');
  147. break;
  148. case 'fixdashboardlinks':
  149. myFixDashboardLinks();
  150. cmsRedirect("index2.php?option=$option&task=maintenance", "My Blog dashboard link fixed.");
  151. break;
  152. case "fixIntrotext":
  153. fixIntrotext();
  154. break;
  155. case 'latestnews':
  156. /**
  157. * Show latest news for My Blog
  158. **/
  159. if(cmsVersion() != _CMS_JOOMLA15)
  160. $title = "Latest updates";
  161. showLatestNews();
  162. break;
  163. case 'dashboard':
  164. /**
  165. * Show dashboard
  166. **/
  167. //showDashboard();
  168. showNewDashboard();
  169. break;
  170. case "blogs" :
  171. default :
  172. if(cmsVersion() != _CMS_JOOMLA15)
  173. $title = 'List blog entries';
  174. showBlogs();
  175. break;
  176. }
  177. $content = ob_get_contents();
  178. ob_end_clean();
  179. $content = str_replace(array('{CONTENT}', '{TITLE}'), array($content, $title), $panel);
  180. echo $content;
  181. }
  182. function _recreateTables() {
  183. global $database, $option;
  184. $db =& cmsInstance('CMSDb');
  185. $db->query("DROP TABLE `#__myblog_categories`");
  186. $db->query("CREATE TABLE IF NOT EXISTS `#__myblog_categories` ( `id` int(10) unsigned NOT NULL auto_increment,`name` varchar(50) NOT NULL default '',PRIMARY KEY (`id`) ) TYPE=MyISAM");
  187. $db->query("DROP TABLE `#__myblog_content_categories`");
  188. $db->query("CREATE TABLE IF NOT EXISTS `#__myblog_content_categories` ( `id` int(10) unsigned NOT NULL auto_increment,`contentid` int(10) unsigned NOT NULL default '0',`category` int(10) unsigned NOT NULL default '0',PRIMARY KEY (`id`) ) TYPE=MyISAM");
  189. $db->query("DROP TABLE `#__myblog_images`");
  190. $db->query("CREATE TABLE IF NOT EXISTS `#__myblog_images` ( `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,`filename` TEXT NOT NULL DEFAULT '',`contentid` INTEGER UNSIGNED NOT NULL DEFAULT 0,`user_id` INTEGER UNSIGNED NOT NULL DEFAULT 0,PRIMARY KEY(`id`) ) TYPE=MYISAM");
  191. $db->query("DROP TABLE `#__myblog_permalinks`");
  192. $db->query("CREATE TABLE IF NOT EXISTS `#__myblog_permalinks` ( `contentid` INTEGER UNSIGNED NOT NULL,`permalink` TEXT NOT NULL DEFAULT '',PRIMARY KEY(`contentid`) ) TYPE=MYISAM");
  193. return;
  194. }
  195. /**
  196. * Create sample data for My Blog if new installation
  197. */
  198. function _importSampleData() {
  199. global $database, $option, $my, $sectionid;
  200. $cms =& cmsInstance('CMSCore');
  201. $db =& cmsInstance('CMSDb');
  202. $cms->load('libraries', 'user');
  203. $title = mysql_real_escape_string('Welcome to MyBlog!');
  204. $content = mysql_real_escape_string('<p>Hello,</p><p> Thank you for using <strong>MyBlog!</strong>,the premier blogging tool for the popular Content Management System-Joomla!.<strong>MyBlog!</strong> is a feature packed,AJAX enabled replacement for the Joomla! Blog component.</p><p>&nbsp;</p><div style="text-align:center"><img src="components/com_myblog/images/icon.png" border="0" alt="icon.png" hspace="4" vspace="4" width="199" height="60" /></div><p>&nbsp;</p><p>&nbsp;Among the features currently implemented are:</p><ul><li><strong>MyBlog! </strong>Dashboard</li></ul><blockquote> <ul><li>Quick search and linking of previous posts while writing a blog entry</li><li>Tags / Tagclouds</li><li> Easy image upload and browsing using MyBlog!&#39;s own image browser</li><li>SEF friendly permanent links for each blog entry</li><li> Single-click publishing/unpublishing</li><li>AJAXed page view of my blog entries </li></ul></blockquote> <ul><li><strong>MyBlog! </strong>Admin</li></ul><blockquote><ul><li>Publishing/posting permissions</li><li>3rd party MyBlog! addons support similar to Mambots</li><li><a href="http://www.azrul.com/product/joomla_comment_system.html">Jomcomment</a> integration</li><li>Moderate blogs,tags/categories</li></ul></blockquote><ul><li> <strong>MyBlog!</strong> Frontpage view</li></ul><blockquote><ul><li>Browse blogs by keyword,blogger,or tags</li><li>Simple and easy view of all blog entries / my blog entries <br /></li><li>Templating support</li><li><a href="http://del.icio.us">del.icio.us</a> &bull;<a href="http://www.digg.com/">digg</a> &bull;<a href="http://www.spurl.net">spurl</a> &bull;<a href="http://reddit.com/">reddit</a> &bull;<a href="http://www.furl.net">furl</a> social bookmarking support</li></ul></blockquote><ul><li> Future features:</li></ul><ul><li>RSS feeds</li><li>Trackbacks</li><li>More ready-made templates</li><li>Community-builder support</li><li>Archived view of posts</li><li> and more...! </li></ul><p>As part of our product improvement process,we would like you to submit any queries,suggestions,or comments regarding MyBlog! on our <a href="http://www.azrul.com/forum/index.php/board,6.0.html">forums at Azrul.com</a>.</p><p> Thank you!</p><p>-MyBlog Dev Team.</p><p>&nbsp;</p>');
  205. $strSQL = "INSERT INTO #__content SET "
  206. . "created_by='{$cms->user->id}', "
  207. . "title='{$title}', "
  208. . "introtext='{$content}', "
  209. . "state='1', "
  210. . "created='2007-01-18 09:58:56', "
  211. . "modified='2007-01-18 10:01:34', "
  212. . "sectionid='{$sectionid}'";
  213. $db->query($strSQL);
  214. $insertid = $db->insertid();
  215. $db->query("INSERT into #__myblog_permalinks SET contentid='$insertid',permalink='welcome-to-myblog.html'");
  216. $categories = array (
  217. 'gadgets',
  218. 'sports',
  219. 'myblog'
  220. );
  221. foreach ($categories as $cat) {
  222. $db->query("INSERT INTO #__myblog_categories SET name='$cat'");
  223. }
  224. $cid = $insertid;
  225. $db->query("SELECT id from #__myblog_categories WHERE name='myblog'");
  226. $catid = $db->get_valuet();
  227. $db->query("INSERT into #__myblog_content_categories SET contentid='$cid',category='$catid'");
  228. $db->query("INSERT into #__myblog_user SET user_id='{$cms->user->id}',description='Write something to describe your blog'");
  229. return "Sample data imported.";
  230. }
  231. /** NOT USED
  232. * Show Installation Wizard
  233. */
  234. function showInstallWizard() {
  235. $step = "";
  236. if (isset ($_GET['step']))
  237. $step = $_GET['step'];
  238. switch ($step) {
  239. case "menus" :
  240. showInstallMenus();
  241. break;
  242. case "settings" :
  243. showInstallSettings();
  244. break;
  245. case "data" :
  246. showInstallData();
  247. break;
  248. default :
  249. break;
  250. }
  251. }
  252. /** NOT USED
  253. * Show page to create menus
  254. */
  255. function showInstallMenus() {
  256. global $database, $option;
  257. $db =& cmsInstance('CMSDb');
  258. ?> <form action="index2.php?option=com_myblog&task=install" method="POST" name="adminForm"> <table cellpadding="4" cellspacing="0" border="0" width="100%"> <tr> <td width="100%" class="sectionname">&nbsp;</td> </tr> </table> <table width="860px" border="0" cellspacing="0" cellpadding="0" class="mytable" width="860px"> <th colspan="3">Setup Menus</th> <tr> <td width="23%"><b>Menu Type</b></td> <td width="25%"><select name="menutype" id="menutype"> <?php $database->setQuery("SELECT distinct(menutype) FROM #__menu");$menutypes=$database->loadObjectList();foreach ($menutypes as $menu) { echo "<option value=\"$menu->menutype\">$menu->menutype</option>";} ?> </select></td> <td width="52%">&nbsp;</td> </tr> <tr> <td><strong>Name</strong></td> <td><input type="text" name="menuname" id="menuname" value="" size="40"/></td> <td>&nbsp;</td> </tr> <tr> <td><strong>Link to</strong></td> <td><select name="menulink" id="menulink"> <option value="dashboard">MyBlog Dashboard Home</option> <option value="write">Write a new MyBlog entry</option> <option value="viewall">View all MyBlog entries</option> <option value="viewuser">View user's MyBlog entries only</option> </select></td> <td>&nbsp;</td> </tr> <tr> <td><strong>Open in</strong></td> <td><select name="menutarget" id="menutarget"> <option value="0">Current Window</option> <option value="1">New Window</option> </select></td> <td>&nbsp;</td> </tr> <tr> <td><strong>Access Level</strong></td> <td> <?php
  259. $query = "SELECT id AS value,name AS text" . "\n FROM #__groups" . "\n ORDER BY id";
  260. $db->query($query);
  261. $groups = $db->get_object_list();
  262. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  263. $access = mosHTML :: selectList($groups, 'menuaccess', 'class="inputbox" size="3"', 'value', 'text', "1");
  264. }elseif(cmsVersion() == _CMS_JOOMLA15){
  265. $access = JHTML::_('select.genericlist', $groups, 'menuaccess', 'class="inputbox" size="1"','value', 'text',"1");
  266. }
  267. echo $access;
  268. ?> </td> <td>&nbsp;</td> </tr> <tr> <td colspan="3">&nbsp;</td> </tr> </table> <input type="hidden" name="option" value="<?php echo $option;?>"> <input type="hidden" name="act" value="<?php ?>"> <input type="hidden" name="task" value="saveInstall"> <input type="hidden" name="step" value="menus"> <input type="hidden" name="boxchecked" value="0"> </form> <?php }
  269. function showInstallSettings() {
  270. ob_start();
  271. showConfig();
  272. $installContent=ob_get_contents();
  273. ob_end_clean();
  274. $installContent=str_replace("</form>","<input type=\"hidden\" name=\"step\" value=\"settings\" /></form>",$installContent);
  275. echo $installContent;
  276. }
  277. function showInstallData() {
  278. global $database,$option,$sectionid;
  279. $db =& cmsInstance('CMSDb');
  280. ?>
  281. <form action="index2.php?option=com_myblog&task=install" method="POST" name="adminForm">
  282. <table cellpadding="4" cellspacing="0" border="0" width="100%"> <tr> <td width="100%" class="sectionname">&nbsp;</td> </tr>
  283. </table>
  284. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="adminlist"> <th colspan="3">Setup Data</th>
  285. <?php $db->query("SELECT count(*) from #__content WHERE sectionid=$sectionid");
  286. $contentcount = $db->get_value();
  287. if ($contentcount > 0) { ?> <tr> <td width="23%"><b>Previous installation detected.<br/>Recreate tables?</b></td> <td width="25%">
  288. <input id="freshinstall0" class="inputbox" type="radio" checked="checked" value="no" name="freshinstall"/>
  289. <label for="freshinstall0">No</label>
  290. <input id="freshinstall1" class="inputbox" type="radio" value="yes" onclick="alert('Warning:All previous MyBlog content,image upload and category data will be deleted if you select yes.');" name="freshinstall"/>
  291. <label for="freshinstall1">Yes</label></td>
  292. <td width="52%">Note:All MyBlog image upload,category and content data tables will be lost if 'yes' is selected.</td> </tr> <?php } ?>
  293. <tr> <td width="23%"><b>Import data from</b></td> <td width="25%"><select name="source" id="source">
  294. <option value="none">(none)</option>
  295. <option value="sample">Sample Data</option>
  296. <?php $db->query("SELECT name from #__components WHERE name='Mamblog'");
  297. if ($db->get_value()) echo '<option value="mamblog">Mamblog</option>';?>
  298. <option value="joomla">Joomla!</option> </select></td> <td width="52%">&nbsp;</td> </tr> <tr> <td colspan="3">&nbsp;</td> </tr> </table>
  299. <input type="hidden" name="option" value="<?php echo $option;?>"> <input type="hidden" name="act" value="<?php ?>">
  300. <input type="hidden" name="task" value="saveInstall"> <input type="hidden" name="step" value="data">
  301. <input type="hidden" name="boxchecked" value="0"> </form> <?php
  302. }
  303. function showInstallPanel(){
  304. global $mainframe;
  305. $cms =& cmsInstance('CMSCore');
  306. ?>
  307. <link rel="stylesheet" type="text/css" href="<?php echo $cms->get_path('live');?>/components/com_myblog/css/niftyCorners.css">
  308. <script type="text/javascript" src="<?php echo $cms->get_path('live');?>/components/com_myblog/js/nifty.js"></script>
  309. <script type="text/javascript"> window.onload=function(){
  310. if(!NiftyCheck())
  311. return;
  312. Rounded("div#sideNav","all","#FFF","#F8F8F8","border #ccc");
  313. }
  314. </script>
  315. <div class="loading" id="loadingDiv" style="display:none;">
  316. <img src="<?php echo $cms->get_path('live');?>/components/com_myblog/images/busy.gif" width="16" height="16" align="absmiddle">&nbsp;Loading...</div>
  317. <div style="background-color:#F8F8F8" id="sideNav">
  318. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  319. <tr> <td scope="col">
  320. <div> <h3 align="center">Installation</h3> </div>
  321. <div class="sideNavTitle">Steps</div>
  322. <div class="sideNavContent">
  323. <p><a href="index2.php?option=com_myblog&task=install&step=menus">Create Menus</a></p>
  324. <p><a href="index2.php?option=com_myblog&task=install&step=settings">General settings</a>
  325. </p> <p><a href="index2.php?option=com_myblog&task=install&step=data">Setup Data</a></p> </div>
  326. <div class="sideNavTitle">About / Support </div> <div class="sideNavContent">
  327. <p><a href="index2.php?option=com_myblog&task=about">About My Blog </a></p> <p>License Information </p>
  328. <p>Support</p> </div></td> </tr> </table> </div>
  329. <p align="center">
  330. <?php $cms =& cmsInstance("CMSCore");
  331. require_once( $cms->get_path("root").'/includes/domit/xml_domit_lite_include.php' );
  332. $xmlDoc=new DOMIT_Lite_Document();$xmlDoc->resolveErrors( true );
  333. $myblog_version="n/a";if ($xmlDoc->loadXML( $cms->get_path("root")."/administrator/components/com_myblog/myblog.xml",false,true )) {
  334. $root=&$xmlDoc->documentElement;$element =&$root->getElementsByPath('version',1);$myblog_version =$element ? $element->getText():'';} echo "Version $myblog_version";?></p> <?php }
  335. function showAjaxedAdmin($task){
  336. global $database, $mainframe, $option, $jax;
  337. $cms =& cmsInstance('CMSCore');
  338. //Get the task and set the width of the admin table if the task is dashboard
  339. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO)
  340. $task = mosGetParam($_GET,'task','');
  341. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $cms->get_path('live') . "/components/com_myblog/css/admin_style.css\" />";
  342. ?>
  343. <script src="<?php echo $cms->get_path('live');?>/includes/js/tabs/tabpane_mini.js" type="text/javascript"></script>
  344. <?php echo $jax->getScript();?>
  345. <style type="text/css">
  346. .loading {
  347. font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-weight:bold;color:#000000;background-color:#FFFF99;padding:4
  348. ppublishBlog( $cid=null,$publish=1,$option )x 16px;
  349. /* position:absolute; **/
  350. top:0px;
  351. right:0px;
  352. } -->
  353. </style>
  354. <table width="100%" border="0" cellspacing="4" cellpadding="6" align="left">
  355. <tr> <td width="10%" valign="top" align="left">
  356. <?php if ($task=='install') showInstallPanel();
  357. else showSidePanel();?>
  358. </td>
  359. <td width="90%" valign="top" align="left">
  360. <div id="mainAdminContent">
  361. <img src="<?php echo $cms->get_path('live'); ?>/administrator/components/com_myblog/logo.png" />
  362. <h1>{TITLE}</h1>
  363. <div>{CONTENT}</div>
  364. </td>
  365. </tr>
  366. </table>
  367. <?php
  368. }
  369. /**
  370. * Called via AJAX to view a blog entry from list of blog entries
  371. */
  372. function viewEntry($contentid)
  373. {
  374. $db =& cmsInstance('CMSDb');
  375. global $database, $sections, $mainframe;
  376. $db->query("SELECT c.*,p.permalink from #__content as c,#__myblog_permalinks as p WHERE c.id=p.contentid and c.id='$contentid' and c.sectionid in ($sections)");
  377. $row = $db->get_object_list();
  378. $objResponse = new JAXResponse();
  379. if ($row)
  380. {
  381. $row = $row[0];
  382. $content = '<td colspan="6">'. $row->fulltext . '</td>';
  383. # Add mosConfig_live_site to all relative URLs, since we are in /administrator instead of /
  384. $content = preg_replace("/(<\s*(a|img)\s+[^>]*(href|src)\s*=\s*[\"'])(?!http)([^\"'>]+)[\"'>]/i", "$1".$cms->get_path('live') ."/$4\"", $content);
  385. $row->introtext = preg_replace("/([\x80-\xFF])/e", "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)", $row->introtext);
  386. $row->fulltext = preg_replace("/([\x80-\xFF])/e", "chr(0xC0|ord('\\1')>>6).chr(0x80|ord('\\1')&0x3F)", $row->fulltext);
  387. //$objResponse->addAssign("$contentid"."_content", "innerHTML", str_replace("&quot;", '"', $content));
  388. $objResponse->addScriptCall("eval","if (document.getElementById('$contentid"."_content').style.display=='none')
  389. document.getElementById('$contentid"."_content').style.display='';
  390. else
  391. document.getElementById('$contentid"."_content').style.display='none';
  392. var entryCell = document.createElement('td');
  393. entryCell.colSpan='6';
  394. entryCell.style.textAlign='left';
  395. entryCell.innerHTML = '".str_replace("&#39;", "\'", str_replace("&quot;", '\"', str_replace('\&#39;', "\\\&#39;", addslashes(str_replace(array("\r","\n"), array(" ", " "), $row->introtext . ($row->introtext!="" ? "<p>=======================</p>" : "") . $row->fulltext)))))."';
  396. var emptyCell = document.createElement('td');
  397. var content_el = document.getElementById('$contentid"."_content');
  398. if (document.getElementById('$contentid"."_content').style.display!='none')
  399. document.getElementById('$contentid"."_content').appendChild(entryCell);
  400. if (document.getElementById('$contentid"."_content').style.display=='none' && content_el.firstChild)
  401. content_el.removeChild(content_el.firstChild);
  402. if (document.getElementById('$contentid"."_content').style.display=='none' && content_el.firstChild)
  403. content_el.removeChild(content_el.firstChild);");
  404. }
  405. $objResponse->sendResponse();
  406. }
  407. /**
  408. * Publish selected blog entry
  409. */
  410. function publishBlog($cid = null, $publish = 1, $option) {
  411. global $database, $mainframe;
  412. $cms =& cmsInstance('CMSCore');
  413. $cms->load('helper', 'url');
  414. $db =& cmsInstance('CMSDb');
  415. if (!is_array($cid) || count($cid) < 1) {
  416. $action = $publish ? 'publish' : 'unpublish';
  417. echo "<script> alert('Select an item to $action');window.history.go(-1);</script>\n";
  418. exit;
  419. }
  420. $cids = implode(',', $cid);
  421. $db->query("UPDATE #__content SET state='$publish' WHERE id IN ($cids)");
  422. $mosmsg = $publish ? 'Blog entries published' : 'Blog entries unpublished';
  423. $server_string = htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES);
  424. $server_string = str_replace('&amp;', '&',$server_string);
  425. $server_string = preg_replace('/(&mosmsg=.*)/', '', $server_string);
  426. cmsRedirect("index2.php?" . $server_string. '&mosmsg='. urlencode($mosmsg));
  427. }
  428. /**
  429. * Publish selected myblog bots
  430. */
  431. function publishBots($cid = null, $publish = 1, $option) {
  432. global $database;
  433. $cms =& cmsInstance('CMSCore');
  434. $cms->load('helper', 'url');
  435. $db =& cmsInstance('CMSDb');
  436. if (!is_array($cid) || count($cid) < 1) {
  437. $action = $publish ? 'publish' : 'unpublish';
  438. echo "<script> alert('Select an item to $action');window.history.go(-1);</script>\n";
  439. exit;
  440. }
  441. $cids = implode(',', $cid);
  442. $db->query("UPDATE #__myblog_bots SET published='$publish' WHERE id IN ($cids)");
  443. cmsRedirect("index2.php?option=$option&task=bots");
  444. }
  445. /**
  446. * Publish selected Mambots
  447. */
  448. function publishMambots($cid = null, $publish = 1, $option) {
  449. global $database;
  450. $cms =& cmsInstance('CMSCore');
  451. $cms->load('helper', 'url');
  452. $db =& cmsInstance('CMSDb');
  453. if (!is_array($cid) || count($cid) < 1) {
  454. $action = $publish ? 'publish' : 'unpublish';
  455. echo "<script> alert('Select an item to $action');window.history.go(-1);</script>\n";
  456. exit;
  457. }
  458. $cids = implode(',', $cid);
  459. $db->query("UPDATE #__myblog_mambots SET my_published='$publish' WHERE mambot_id IN ($cids)");
  460. cmsRedirect("index2.php?option=$option&task=contentmambots");
  461. }
  462. /**
  463. * Show List of tags
  464. */
  465. function showCategories() {
  466. global $mainframe, $option, $_MY_CONFIG;
  467. $cms =& cmsInstance('CMSCore');
  468. $cms->load('helper', 'url');
  469. $cms->load('model', 'tag', 'com_myblog');
  470. $db =& cmsInstance('CMSDb');
  471. $db->query("SELECT * FROM #__myblog_categories ORDER BY name ASC");
  472. $rows = $db->get_object_list();
  473. $iso = cmsGetISO();
  474. $jq = $cms->get_path('live') . '/administrator/components/com_myblog/js/jquery-1.2.6.pack.js';
  475. ?>
  476. <script src="<?php echo $jq;?>" type="text/javascript"></script>
  477. <script type="text/javascript">
  478. jQuery.noConflict();
  479. jQuery(document).ready(
  480. function() {
  481. showEditLink();
  482. showEditSlug();
  483. bindDefaultLink();
  484. }
  485. );
  486. function bindDefaultLink(){
  487. jQuery('.defaultTag, .notDefaultTag').each(function(){
  488. jQuery(this).click(function(){
  489. setDefaultTag(jQuery(this));
  490. });
  491. });
  492. }
  493. function setDefaultTag(obj){
  494. var id = obj.parent().parent().find('span.tagname').attr('orgid');
  495. var set = '0';
  496. if(obj.hasClass('defaultTag')){
  497. obj.parent().append('<a href="javascript:void();" class="notDefaultTag"></a>');
  498. obj.remove();
  499. } else {
  500. obj.parent().append('<a href="javascript:void();" class="defaultTag"></a>');
  501. obj.remove();
  502. set = '1';
  503. }
  504. jax.call('myblog', 'myxSetDefaultCategory', id, set);
  505. bindDefaultLink();
  506. }
  507. function showEditLink(){
  508. jQuery('#categoryTable tr span.editlink').each(function() {
  509. var orgId = jQuery(this).attr('orgid');
  510. var orgVal = jQuery(this).attr('orgval');
  511. if(jQuery('#categoryTable tr span.tagname input') != null){
  512. orgVal = orgVal.replace(/\'/g,'\\\'');
  513. var edit = '<a href="javascript:void(0);" onclick="editTag(\'' + orgId +'\',\'' + orgVal +'\')">Edit</a>';
  514. edit += '<span class="errornotice"></span>';
  515. jQuery(this).html(edit);
  516. }
  517. });
  518. }
  519. function showEditSlug(){
  520. jQuery('#categoryTable tr span.editslug').each(function() {
  521. var orgId = jQuery(this).attr('orgid');
  522. var orgVal = jQuery(this).attr('orgval');
  523. if(jQuery('#categoryTable tr span.slugname input') != null){
  524. var edit = '<a href="javascript:void(0);" onclick="editSlug(\'' + orgId +'\',\'' + orgVal +'\')">Edit</a>';
  525. edit += '<span class="errornotice"></span>';
  526. jQuery(this).html(edit);
  527. }
  528. });
  529. }
  530. function editTag(id, value){
  531. // restore old values from 'orgval' attr
  532. jQuery('#categoryTable tr span.tagname input').each(function() {
  533. // Restore edit link
  534. showEditLink();
  535. jQuery(this).parent().html(jQuery(this).parent().attr('orgval'));
  536. });
  537. // Add the input, save & cancel button
  538. var html = '<input type="text" id="tag" value="' + value + '" size="30" />';
  539. html += '<a href="javascript:void(0);" class="saveTag">Save</a> | ';
  540. html += '<a href="javascript:void(0);" class="cancelSaveTag">Cancel</a>';
  541. jQuery('#row' + id + ' span span.tagname').html(html);
  542. jQuery('#row' + id + ' span.editlink').html('');
  543. // set focus to current input box
  544. jQuery('#tag').focus();
  545. // Bind save button
  546. jQuery('#categoryTable tr span.tagname a:first').unbind('click');
  547. jQuery('#categoryTable tr span.tagname a:first').click(function () {
  548. var newTag = jQuery(this).prev().val();
  549. jQuery(this).parent().attr('orgval', newTag);
  550. jQuery('#categoryTable tr span.tagname input').each(function() {
  551. jQuery(this).parent().html(jQuery(this).parent().attr('orgval'));
  552. });
  553. if(newTag == value){
  554. showEditLink();
  555. return;
  556. }
  557. jax.call('myblog','myxUpdateCategory',id, newTag, value);
  558. showEditLink();
  559. });
  560. // Bind the cancel button
  561. jQuery('#categoryTable tr span.tagname a:last').unbind('click');
  562. jQuery('#categoryTable tr span.tagname a:last').click(function () {
  563. jQuery('#categoryTable tr span.tagname input').each(function() {
  564. jQuery(this).parent().html(jQuery(this).parent().attr('orgval'));
  565. });
  566. showEditLink();
  567. });
  568. }
  569. function editSlug(id, value){
  570. // restore old values from 'orgval' attr
  571. jQuery('#categoryTable tr span.slugname input').each(function() {
  572. // Restore edit link
  573. showEditSlug();
  574. jQuery(this).parent().html(jQuery(this).parent().attr('orgval'));
  575. });
  576. // Add the input, save & cancel button
  577. var html = '<input type="text" id="slug" value="' + value + '" size="30" />';
  578. html += '<a href="javascript:void(0);" class="saveTag">Save</a> | ';
  579. html += '<a href="javascript:void(0);" class="cancelSaveTag">Cancel</a>';
  580. jQuery('#row' + id + ' span span.slugname').html(html);
  581. jQuery('#row' + id + ' span.editslug').html('');
  582. // set focus to current input box
  583. jQuery('#slug').focus();
  584. // Bind save button
  585. jQuery('#categoryTable tr span.slugname a:first').unbind('click');
  586. jQuery('#categoryTable tr span.slugname a:first').click(function () {
  587. var slug = jQuery(this).prev().val();
  588. jQuery(this).parent().attr('orgval', slug);
  589. jQuery('#categoryTable tr span.slugname input').each(function() {
  590. var val = jQuery(this).parent().attr('orgval');
  591. // We know we dont allow '
  592. val = val.replace(/\'/g,'');
  593. jQuery(this).parent().html(val);
  594. });
  595. if(slug == value){
  596. showEditSlug();
  597. return;
  598. }
  599. jax.icall('myblog','myxUpdateSlug',id, slug, value);
  600. showEditSlug();
  601. });
  602. // Bind the cancel button
  603. jQuery('#categoryTable tr span.slugname a:last').unbind('click');
  604. jQuery('#categoryTable tr span.slugname a:last').click(function () {
  605. jQuery('#categoryTable tr span.slugname input').each(function() {
  606. jQuery(this).parent().html(jQuery(this).parent().attr('orgval'));
  607. });
  608. showEditSlug();
  609. });
  610. }
  611. function addTagRow(tagName, slug , rowId, hasDefault){
  612. var rowClass = jQuery('#categoryTable tr:last').hasClass('row0') ? 'row1' : 'row0';
  613. var html = '<tr id="row' + rowId + '" class="' + rowClass + '">';
  614. slug = slug.replace(/\'/g,'\\\'');
  615. slug = slug.replace(/\"/g,'\\"');
  616. slug = slug.replace(/\\/g,'\\\\');
  617. slug = slug.replace(/\0/g,'\\0');
  618. if(hasDefault == '1'){
  619. html += '<td align="center"><a href="javascript:void(0);" class="notDefaultTag">X</a></td>';
  620. }
  621. html += '<td><span onclick="jax.icall(\'myblog\',\'myxDeleteCategory\',\'' + rowId + '\');" class="CommonTextButtonSmall">Delete</span></td>';
  622. html += '<td>';
  623. html += ' <span>';
  624. html += ' <span class="tagname" orgval="' + tagName + '" orgid="' + rowId + '">' + tagName + '</span>';
  625. html += ' <span class="editlink" orgval="' + tagName + '" orgid="' + rowId + '">'+ tagName;
  626. html += ' <a href="javascript:void(0);"></a>';
  627. html += ' </span>';
  628. html += ' </span>';
  629. html += '</td>';
  630. html += '<td>';
  631. html += ' <span>';
  632. html += ' <span class="slugname" orgval="' + slug + '" orgid="' + rowId + '">' + slug;
  633. html += ' <a href="javascript:void(0);"></a>';
  634. html += ' </span>';
  635. html += ' <span class="editslug" orgval="' + slug + '" orgid="' + rowId + '">'
  636. html += ' <a href="javascript:void(0);"></a>';
  637. html += ' </span>';
  638. html += ' </span>';
  639. html += '</td>';
  640. html += '</tr>';
  641. jQuery('#categoryTable').append(html);
  642. showEditLink();
  643. showEditSlug();
  644. bindDefaultLink();
  645. }
  646. </script>
  647. <div class="myInfo">
  648. Use this page to create / delete and edit tags which can then be assigned into your blog entries.<strong>Tag Slugs</strong> are actually
  649. an alternative text which will be used in the URL. This prevents My Blog from searching incorrect tags due to special encoded
  650. characters.
  651. </div>
  652. <h3 id="tagnotice"></h1>
  653. <table width="100%" border="0" cellpadding="0" cellspacing="0" class="adminlist">
  654. <thead>
  655. <tr>
  656. <?php if($_MY_CONFIG->get('allowDefaultTags')): ?>
  657. <th width="10%" style="text-align: center;">Default</th>
  658. <?php endif; ?>
  659. <th width="10%" scope="col">Action</th>
  660. <th width="39%" scope="col">Tag</th>
  661. <th width="39%">Slug</th>
  662. </tr>
  663. </thead>
  664. <tbody id="categoryTable">
  665. <?php
  666. $i = 0;
  667. foreach ($rows as $row){
  668. $tagObj = new MYTag();
  669. $tagObj->load($row->id);
  670. ?>
  671. <tr id="row<?php echo $row->id; ?>" class="row<?php echo $i;?>">
  672. <?php if($_MY_CONFIG->get('allowDefaultTags')): ?>
  673. <td align="center">
  674. <?php if($row->default && $row->default == '1'){ ?>
  675. <a href="javascript:void(0);" class="defaultTag">X</a>
  676. <?php } else {?>
  677. <a href="javascript:void(0);" class="notDefaultTag">X</a>
  678. <?php } ?>
  679. <?php endif; ?>
  680. </td>
  681. <td>
  682. <span onclick="jax.icall('myblog','myxDeleteCategory','<?php echo $row->id;?>');" class="CommonTextButtonSmall">Delete</span>
  683. </td>
  684. <td>
  685. <span>
  686. <span class="tagname" orgval="<?php echo $row->name; ?>" orgid="<?php echo $row->id;?>">
  687. <?php echo $row->name; ?>
  688. </span>
  689. <span class="editlink" orgval="<?php echo $row->name; ?>" orgid="<?php echo $row->id;?>">
  690. <a href="javascript:void(0);"></a>
  691. </span>
  692. </span>
  693. </td>
  694. <td>
  695. <span>
  696. <span class="slugname" orgval="<?php echo $tagObj->getSlug(); ?>" orgid="<?php echo $row->id;?>">
  697. <?php echo $tagObj->getSlug(); ?>
  698. </span>
  699. <span class="editslug" orgval="<?php echo $tagObj->getSlug(); ?>" orgid="<?php echo $row->id;?>">
  700. <a href="javascript:void(0);"></a>
  701. </span>
  702. </span>
  703. </td>
  704. </tr>
  705. <?php
  706. $i = ($i > 0) ? 0 : 1;
  707. }
  708. ?>
  709. </tbody>
  710. </table>
  711. <p>
  712. <form action="" method="post" name="formNewCat" id="formNewCat" onsubmit="jax.icall('myblog','myxAddCategory',document.getElementById('newCat').value);return false;">
  713. <input name="newCat" id="newCat" type="text" class="CommonTextButtonSmall" size="48" maxlength="48">
  714. <span class="CommonTextButtonSmall" onclick="jax.icall('myblog','myxAddCategory',document.getElementById('newCat').value);">Add New Tag</span>
  715. &nbsp;&nbsp;<span id="categoryerror" class="errorMsg"></span>
  716. </form>
  717. </p>
  718. <?php
  719. }
  720. function fixIntrotext(){
  721. global $database, $_MY_CONFIG, $sections;
  722. $cms =& cmsInstance('CMSCore');
  723. $cms->load('helper', 'url');
  724. $db =& cmsInstance('CMSDb');
  725. $db->query("SELECT id,`fulltext` FROM #__content WHERE sectionid IN ($sections) and `introtext` = '' ");
  726. $rows = $db->get_object_list();
  727. $num_fixed = 0;
  728. if ($rows and count($rows)>0)
  729. {
  730. foreach ($rows as $row)
  731. {
  732. $id = $row->id;
  733. $fulltext = $row->fulltext;
  734. # get introtext (first X characters)
  735. $introtext = getIntrotext($fulltext, $_MY_CONFIG->get('introLength'), '{readmore}');
  736. # get fulltext (fulltext - introtext)
  737. $fulltext = substr($fulltext, strlen($introtext));
  738. $db->query("UPDATE #__content SET `introtext`='$introtext', `fulltext`='$fulltext' WHERE id='$id'");
  739. //if ($database->query())
  740. $num_fixed++;
  741. }
  742. }
  743. cmsRedirect("index2.php?option=com_myblog&task=maintenance", "$num_fixed entries fixed.");
  744. }
  745. function myFixLinks()
  746. {
  747. global $database, $_MY_CONFIG, $sections;
  748. $db =& cmsInstance('CMSDb');
  749. # Fix content entries without permalinks
  750. $db->query("SELECT c.id,c.title,p.contentid FROM #__content as c LEFT OUTER JOIN #__myblog_permalinks as p ON ( c.id=p.contentid ) WHERE p.contentid IS NULL and c.sectionid IN ($sections)");
  751. $rows = $db->get_object_list();
  752. $new_permalinks = 0;
  753. if ($rows) {
  754. $new_permalinks = count($rows);
  755. foreach ($rows as $row) {
  756. // remove unwanted chars
  757. $title = $row->title;
  758. $link = myTitleToLink(trim($title . ".html"));
  759. //removes unwanted character from url including !.
  760. $link = preg_replace('/[!@#$%\^&*\(\)\+=\{\}\[\]|\\<">,\\/\^\*;:\?\'\\\]/', "", $link);
  761. $db->query("SELECT * from #__myblog_permalinks WHERE permalink='$link' and contentid!='$row->id'");
  762. $linkExists = $db->get_value();
  763. if ($linkExists) {
  764. // remove unwanted chars
  765. $link = myTitleToLink(trim($title));
  766. //$link = preg_replace('/[!@#$%\^&*\(\)\+=\{\}\[\]|\\<">,\\/\^\*;:\?\'\\\]/', "", $link);
  767. $plink = "$link-$uid.html";
  768. $db->query("SELECT contentid from #__myblog_permalinks WHERE permalink='$plink' and contentid!='$row->id'");
  769. $count = 0;
  770. while ($db->get_value()) {
  771. $count++;
  772. $plink = "$link-{$row->id}-$count.html";
  773. $db->query("SELECT contentid from #__myblog_permalinks WHERE permalink='$plink' and contentid!='$row->id'");
  774. }
  775. //$plink = urlencode($plink);
  776. $db->query("INSERT INTO #__myblog_permalinks SET permalink='$plink',contentid='$row->id'");
  777. } else {
  778. //$link = urlencode($link);
  779. $db->query("INSERT INTO #__myblog_permalinks SET permalink='$link',contentid='$row->id'");
  780. }
  781. }
  782. }
  783. # ensure all permalinks are 'safe'
  784. $db->query("SELECT contentid, permalink from #__myblog_permalinks");
  785. $permalinks = $db->get_object_list();
  786. $modified_permalinks = 0;
  787. if ($permalinks)
  788. {
  789. $modified_permalinks = count($permalinks);
  790. foreach ($permalinks as $permalink)
  791. {
  792. $uid = $permalink->contentid;
  793. $link = $permalink->permalink;
  794. $link = myTitleToLink(trim($link));
  795. $db->query("SELECT * from #__myblog_permalinks WHERE permalink='$link' and contentid!='$uid'");
  796. $linkExists = $db->get_value();
  797. if ($linkExists) { # if link exists, find a unique permalink
  798. // remove unwanted characters
  799. //$link = preg_replace('/[!@#$%\^&*\(\)\+=\{\}\[\]|\\<">,\\/\^\*;:\?\'\\\]/', "", $link);
  800. //$link = myTitleToLink(trim($title));
  801. if (substr($link, strlen($link)-5, 5)==".html")
  802. $link = substr($link, 0, strlen($link)-5);
  803. $plink = "$link-$uid.html";
  804. $db->query("SELECT contentid from #__myblog_permalinks WHERE permalink='$plink' and contentid!='$uid'");
  805. $count = 0;
  806. while ($db->get_value()) {
  807. $count++;
  808. $plink = "$link-$uid-$count.html";
  809. $db->query("SELECT contentid from #__myblog_permalinks WHERE permalink='$plink' and contentid!='$uid'");
  810. }
  811. //$plink = urlencode($plink);
  812. $db->query("UPDATE #__myblog_permalinks SET permalink='$plink' WHERE contentid='$uid'");
  813. } else {
  814. $db->query("UPDATE #__myblog_permalinks SET permalink='$link' WHERE contentid=$uid");
  815. }
  816. }
  817. }
  818. }
  819. function showMaintenance() {
  820. $cms =& cmsInstance('CMSCore');
  821. include_once($cms->get_path('root') . '/administrator/components/com_myblog/admin.myblog.html.php');
  822. myAdminMaintenance();
  823. ?>
  824. &nbsp;&nbsp;
  825. <?php
  826. }
  827. /**
  828. * Show latest news from our RSS Feeds
  829. */
  830. function showLatestNews(){
  831. $cms =& cmsInstance('CMSCore');
  832. // Load our cmslib library lastrss
  833. $cms->load('libraries','lastrss');
  834. $rss = $cms->lastrss;
  835. $rss->cache_dir = $cms->get_path('root') . '/cache';
  836. $rss->cache_time = 120;
  837. $rss->date_format = 'M d, Y g:i:s A';
  838. $rss->CDATA = 'content';
  839. // Variables declarations that will be used in this function
  840. $url = 'http://support.azrul.com/rss/index.php?_m=news&_a=view&group=default';
  841. $html = "<div style=\"width:640px;\"><p>";
  842. if ($rs = $rss->get($url)){
  843. $rs = $rss->get($url);
  844. foreach ($rs['items'] as $item) {
  845. $html .= "<div style=\"padding:8px;border-bottom:1px dotted #666666;\"><div style=\"font-weight:bold\"><a parent=\"_blank\"href=\"{$item['link']}\">{$item['title']}</a></div>"
  846. . "<div>{$item['pubDate']}</div><div>{$item['description']}</div></div>";
  847. }
  848. if ($rs['items_count'] <= 0)
  849. $html .= "<li>Sorry, no items found in the RSS file :-(</li>";
  850. }else
  851. $html .= "Sorry: It's not possible to reach RSS file $url\n<br />";
  852. $html .= "</p></div>";
  853. echo $html;
  854. }
  855. /**
  856. * Shows Configuration sEttings page
  857. */
  858. function showConfig() {
  859. global $database, $mainframe, $option;
  860. $cms =& cmsInstance('CMSCore');
  861. $db =& cmsInstance('CMSDb');
  862. require_once($cms->get_path('root') . "/administrator/components/com_myblog/config.myblog.php");
  863. $config = new MYBLOG_Config();
  864. echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"" .$cms->get_path('live') ."/components/com_myblog/css/admin_style.css\" />";
  865. # Get templates list
  866. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  867. $file_list = mosReadDirectory($cms->get_path('root') . "/components/com_myblog/templates", "");
  868. }elseif(cmsVersion() == _CMS_JOOMLA15){
  869. $file_list = JFolder::folders($cms->get_path('root') . "/components/com_myblog/templates", "");
  870. }
  871. $t_list = array ();
  872. $temp_lists = array();
  873. $filecount = 0;
  874. foreach ($file_list as $val) {
  875. if (!strstr($val, "svn") and !strstr($val, "admin") and !strstr($val, "_default")){
  876. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  877. $t_list[] = mosHTML :: makeOption($val, $val);
  878. }elseif(cmsVersion() == _CMS_JOOMLA15){
  879. $t_list[] = JHTML::_('select.option', $val, $val);
  880. }
  881. $temp_lists[$val] = $val;
  882. }
  883. }
  884. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  885. $templates = mosHTML :: selectList($t_list, 'template', 'class="inputbox" size="1"', 'value', 'text', $config->get('template'));
  886. }elseif(cmsVersion() == _CMS_JOOMLA15){
  887. $templates = JHTML::_('select.genericlist', $t_list, 'template', 'class="inputbox" size="1"','value', 'text', $config->get('template'));
  888. }
  889. $db->query("SELECT id,title FROM #__sections ORDER BY title ASC");
  890. $rows = $db->get_object_list();
  891. $sect_rows = count($rows);
  892. $managedSections = "<select name=\"managedSections[]\" size=\"" . count($rows) . "\" multiple>";
  893. $sectionid = $config->get('postSection');
  894. $catid = $config->get('catid');
  895. $sectionsArray = explode(",", $config->get('managedSections'));
  896. array_walk($sectionsArray, "trim");
  897. #var_dump($sectionsArray);
  898. #Get the list of the sections
  899. $sect_lists = array();
  900. #Get the selected section lists.
  901. $sel_sect_lists = array();
  902. #var_dump($rows);
  903. if ($rows) {
  904. foreach ($rows as $row) {
  905. $managedSections .= "<option value='$row->id' ";
  906. if (in_array($row->id, $sectionsArray)) {
  907. $managedSections .= "selected";
  908. $sel_sect_lists[] = $row->id;
  909. }
  910. $managedSections .= ">$row->title</option>";
  911. $sect_lists[$row->id] = $row->title;
  912. }
  913. }
  914. #var_dump($sel_sect_lists);
  915. $managedSections .= "</select>";
  916. $db->query("SELECT id,title FROM #__sections ORDER BY title ASC");
  917. $rows = $db->get_object_list();
  918. $sect_rows = count($rows);
  919. $postInSection = "<select name=\"postSection\">"; // Post entries in section
  920. $postSection = $config->get('postSection');
  921. #Get the section lists so that we can display it to user to
  922. #select which section to save new entries at.
  923. $save_sect_lists = array();
  924. if ($rows) {
  925. foreach ($rows as $row) {
  926. $postInSection .= "<option value='$row->id' ";
  927. if ($postSection == $row->id)
  928. $postInSection .= "selected";
  929. $postInSection .= ">$row->title</option>";
  930. $save_sect_lists[$row->id] = $row->title;
  931. }
  932. }
  933. $postInSection .= "</select>";
  934. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  935. $lang_file_list = mosReadDirectory($cms->get_path('root') . "/components/com_myblog/language", "");
  936. }elseif(cmsVersion() == _CMS_JOOMLA15){
  937. $lang_file_list = JFolder::files($cms->get_path('root') . "/components/com_myblog/language", "");
  938. }
  939. $lang_list = array ();
  940. $lang_filecount = 0;
  941. $lang_lists = array();
  942. foreach ($lang_file_list as $val) {
  943. if (!strstr($val, "svn") and substr($val, strlen($val)-4, 4)==".php"){
  944. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  945. $lang_list[] = mosHTML :: makeOption($val,substr($val, 0, strlen($val)-4));
  946. }elseif(cmsVersion() == _CMS_JOOMLA15){
  947. $lang_list[] = JHTML::_('select.option', $val,substr($val, 0, strlen($val)-4));
  948. }
  949. $lang_lists[$val] = substr($val,0,-4);
  950. }
  951. }
  952. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  953. $lang_files = mosHTML :: selectList($lang_list, 'language', 'class="inputbox" size="1"', 'value', 'text', $config->get('language'));
  954. }elseif(cmsVersion() == _CMS_JOOMLA15){
  955. $lang_files = JHTML::_('select.genericlist', $lang_list, 'language', 'class="inputbox" size="1"','value', 'text', $config->get('language'));
  956. }
  957. #Load the html data from config_template.php file
  958. include ($cms->get_path('root') . "/administrator/components/com_myblog/templates/config_template.php");
  959. }
  960. function showNewDashboard()
  961. {
  962. ?>
  963. <link href="<?php echo MY_COM_LIVE; ?>/css/azwindow.css" rel="stylesheet" type="text/css" />
  964. <link href="<?php echo MY_COM_LIVE; ?>/css/style.css" rel="stylesheet" type="text/css" />
  965. <link rel="stylesheet" href="<?php echo MY_COM_LIVE; ?>/css/ui.css" type="text/css" media="screen" />
  966. <script type="text/javascript" language="javascript" src="<?php echo MY_COM_LIVE; ?>/js/myblog.js"></script>
  967. <?php
  968. }
  969. /**
  970. * Show dashboard in the back end.
  971. **/
  972. function showDashboard(){
  973. $cms =& cmsInstance('CMSCore');
  974. $site = $cms->get_path('live');
  975. $poweredBy = getPoweredByLink();
  976. //Check if there is id passed. If there is id it means we need to edit the blog
  977. $blogId = cmsGetVar('id', '', 'GET');
  978. if(isset($blogId) && !empty($blogId)){
  979. $dbLink = rtrim($cms->get_path('live') ,'/') . '/index2.php?option=com_myblog&task=write&keepThis=true&TB_iframe=true&no_html=1&id=' . $blogId;
  980. }
  981. else{
  982. $dbLink = rtrim($cms->get_path('live') ,'/') . '/index2.php?option=com_myblog&task=write&keepThis=true&TB_iframe=true&no_html=1&id=0';
  983. }
  984. // top position should be lowe in J1.5
  985. $winTop = (cmsVersion() != _CMS_JOOMLA15)? '140px':'180px';
  986. $winBottom = (cmsVersion() != _CMS_JOOMLA15)? '0':'40';
  987. $html = '';
  988. $html .= <<<SHOWHTML
  989. <script type="text/javascript">//<![CDATA[
  990. function azrulWindowSave(entryid){
  991. }
  992. // redirect to list view
  993. function azrulWindowSaveClose(){
  994. window.location = '$site/administrator/index2.php?option=com_myblog&task=blogs';
  995. }
  996. function editWindowTitle(nt){
  997. jax.$('azrulEditorMessage').innerHTML = nt;
  998. }
  999. var yPos;
  1000. if (window.innerHeight != null)
  1001. {
  1002. yPos = window.innerHeight;
  1003. } else if (document.documentElement && document.documentElement.clientHeight)
  1004. {
  1005. yPos = document.documentElement.clientHeight;
  1006. } else
  1007. {
  1008. yPos = document.body.clientHeight;
  1009. }
  1010. yPos=yPos-230;
  1011. //]]></script>
  1012. <style type="text/css">
  1013. div #azrulWindow{
  1014. -moz-border-radius-bottomleft:7px;
  1015. -moz-border-radius-bottomright:7px;
  1016. -moz-border-radius-topleft:7px;
  1017. -moz-border-radius-topright:7px;
  1018. -moz-box-sizing:border-box;
  1019. background-color:/*#F2F5F7;*/ #cdcdcd;
  1020. border:1px solid /*#D0E4FD;*/ #898989;
  1021. margin:20px 10px 30px;
  1022. padding:2px 10px;
  1023. width:805px;
  1024. position: absolute;
  1025. }
  1026. div #azrulWindowContent{
  1027. border-left: 1px solid #898989;
  1028. border-right: 1px solid #898989;
  1029. }
  1030. div #azrulWindowClose{
  1031. padding: 5px;
  1032. border-bottom: 1px solid #898989;
  1033. }
  1034. div #azrulWindowTitle{
  1035. border-bottom: 1px solid #898989;
  1036. padding: 5px;
  1037. }
  1038. div #azrulWindowFooter{
  1039. font-size: 10px;
  1040. font-family: verdana;
  1041. border-top: 1px solid #898989;
  1042. padding: 4px;
  1043. text-align: right;
  1044. }
  1045. </style>
  1046. <div id="azrulWindow" style="top:$winTop;width: 780px;">
  1047. <table cellpadding="0" cellspacing="0" width="100%">
  1048. <tr>
  1049. <td id="azrulWindowTitle" width="95%">MyBlog Editor <span id="azrulEditorMessage"></span></td>
  1050. <td id="azrulWindowClose" width="5%"><a href="index2.php?option=com_myblog&task=blogs">Close</a></td>
  1051. </tr>
  1052. <tr>
  1053. <td colspan="2" id="azrulWindowContent">
  1054. <iframe id="azrulContentFrame" src="$dbLink" frameborder="0" style="width:100%;" scrolling="no"></iframe>
  1055. </td>
  1056. </tr>
  1057. </table>
  1058. <div id="azrulWindowFooter">$poweredBy</div>
  1059. </div>
  1060. <link href="MY_COM_LIVE/css/style.css" rel="stylesheet" type="text/css" />
  1061. <link rel="stylesheet" href="MY_COM_LIVE/css/ui.css" type="text/css" media="screen" />
  1062. <script type="text/javascript">//<![CDATA[
  1063. iframe = document.getElementById("azrulContentFrame");
  1064. yPos = yPos - $winBottom;
  1065. if(yPos < 480){
  1066. yPos = 480;
  1067. }
  1068. iframe.style.height = (yPos) + 'px';
  1069. //]]></script>
  1070. SHOWHTML;
  1071. echo $html;
  1072. }
  1073. /**
  1074. * Save configuration settings
  1075. */
  1076. function saveConfig() {
  1077. global $database, $option, $sectionid, $mainframe;
  1078. $cms =& cmsInstance('CMSCore');
  1079. $cms->load('helper', 'url');
  1080. $db =& cmsInstance('CMSDb');
  1081. require_once($cms->get_path('root') . "/administrator/components/com_myblog/config.myblog.php");
  1082. $config = new MYBLOG_Config();
  1083. $note = "";
  1084. # Disable technorati pings if xmlrpc extension not found
  1085. if (!function_exists('xmlrpc_encode_request')) {
  1086. $note = "Note:x-m-l RPC extension in PHP is disabled.Ping Technorati set to 0";
  1087. }
  1088. $config->save();
  1089. $config = new MYBLOG_Config();
  1090. $managedSections = $config->get('managedSections');
  1091. $sections = $managedSections;
  1092. # Fix content entries without permalinks
  1093. $db->query("SELECT c.id,c.title,p.contentid FROM #__content as c LEFT OUTER JOIN #__myblog_permalinks as p ON ( c.id=p.contentid ) WHERE p.contentid IS NULL and c.sectionid IN ($sections)");
  1094. $rows = $db->get_object_list();
  1095. if ($rows) {
  1096. foreach ($rows as $row) {
  1097. // remove unwanted chars
  1098. $title = $row->title;
  1099. $link = myTitleToLink(trim($title . ".html"));
  1100. //$link = preg_replace('/[!@#$%\^&*\(\)\+=\{\}\[\]|\\<">,\\/\^\*;:\?\'\\\]/', "", $link);
  1101. $db->query("SELECT * from #__myblog_permalinks WHERE permalink='$link' and contentid!='$row->id'");
  1102. $linkExists = $db->get_value();
  1103. if ($linkExists) {
  1104. // remove unwanted chars
  1105. $link = myTitleToLink(trim($title));
  1106. //$link = preg_replace('/[!@#$%\^&*\(\)\+=\{\}\[\]|\\<">,\\/\^\*;:\?\'\\\]/', "", $link);
  1107. $plink = "$link-$uid.html";
  1108. $db->query("SELECT contentid from #__myblog_permalinks WHERE permalink='$plink' and contentid!='$row->id'");
  1109. $count = 0;
  1110. while ($db->get_value()) {
  1111. $count++;
  1112. $plink = "$link-{$row->id}-$count.html";
  1113. $db->query("SELECT contentid from #__myblog_permalinks WHERE permalink='$plink' and contentid!='$row->id'");
  1114. }
  1115. //$plink = urlencode($plink);
  1116. $db->query("UPDATE #__myblog_permalinks SET permalink='$plink' WHERE `contentid`='$row->id'");
  1117. } else {
  1118. //$link = urlencode($link);
  1119. $db->query("INSERT INTO #__myblog_permalinks SET permalink='$link',contentid='$row->id'");
  1120. }
  1121. }
  1122. }
  1123. $redirect = "index2.php?option=com_myblog&task=config";
  1124. cmsRedirect($redirect, "Settings saved.$note");
  1125. }
  1126. /**
  1127. * Save My Blog bot
  1128. */
  1129. function saveBot() {
  1130. global $database, $mainframe, $option;
  1131. $cms =& cmsInstance('CMSCore');
  1132. $cms->load('helper', 'url');
  1133. require_once($cms->get_path('root') . "/administrator/components/com_myblog/config.myblog.php");
  1134. $published = $_POST['published'];
  1135. $filename = $_POST['filename'];
  1136. $folder = $_POST['folder'];
  1137. $botName = $_POST['botName'];
  1138. if ($published == "" or $filename == "" or $folder == "") {
  1139. echo "<script> alert('" . $row->getError() . "');window.history.go(-1);</script>\n";
  1140. exit ();
  1141. }
  1142. $db->query("SELECT * from #__myblog_bots WHERE folder='$folder' AND filename='$filename'");
  1143. if ($db->get_value()) {
  1144. cmsRedirect("index2.php?option=com_myblog&task=bots", "Bot already exists.Error adding bot.");
  1145. return;
  1146. }
  1147. $db->query("SELECT max(ordering) from #__myblog_bots");
  1148. $ordering = $db->get_value() + 1;
  1149. $db->query("INSERT INTO #__myblog_bots SET name='$botName',published='$published',ordering='$ordering',folder='$folder',filename='$filename'");
  1150. cmsRedirect("index2.php?option=com_myblog&task=bots", "Bot added.");
  1151. }
  1152. /**
  1153. * Show My Blog backend's side panel
  1154. */
  1155. function showSidePanel() {
  1156. global $mainframe;
  1157. $cms =& cmsInstance('CMSCore');
  1158. $jax = new JAX($cms->get_path('plugin-live') . "/system/pc_includes");
  1159. $jax->setReqURI($cms->get_path('live') . "/administrator/index2.php");
  1160. // Load dashboard stuffs
  1161. showNewDashboard();
  1162. // Try login user.
  1163. $cms->load('libraries' , 'user');
  1164. $strSQL = "SELECT session_id FROM #__session WHERE `userid`={$cms->user->id}";
  1165. $cms->db->query( $strSQL );
  1166. $cms->load('libraries' , 'user');
  1167. $userId = $cms->user->id;
  1168. $sessionId = $cms->db->get_value();
  1169. $link = rtrim($cms->get_path('live') ,'/') . '/index2.php?option=com_myblog&task=write&no_html=1&id=0&session=' . $userId . ':' . $sessionId;
  1170. if(cmsVersion() == _CMS_JOOMLA15)
  1171. $link = rtrim($cms->get_path('live') ,'/') . '/index.php?option=com_myblog&tmpl=component&task=write&no_html=1&id=0&session=' . $userId . ':' . $sessionId;
  1172. ?>
  1173. <link rel="stylesheet" type="text/css" href="<?php echo $cms->get_path('live');?>/components/com_myblog/css/niftyCorners.css">
  1174. <script type="text/javascript" src="<?php echo $cms->get_path('live');?>/components/com_myblog/js/nifty.js"></script>
  1175. <script type="text/javascript"> window.onload=function(){ if(!NiftyCheck()) return;Rounded("div#sideNav","all","#FFF","#F8F8F8","border #ccc");}
  1176. </script> <div class="loading" id="loadingDiv" style="display:none;">
  1177. <img src="<?php echo $cms->get_path('live');?>/components/com_myblog/images/busy.gif" width="16" height="16" align="absmiddle">&nbsp;Loading...</div>
  1178. <div style="background-color:#F8F8F8" id="sideNav"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td scope="col">
  1179. <div> <h3 align="center">Admin Panel </h3> </div> <div class="sideNavTitle"><img hspace="2" style="vertical-align: middle;" src="components/com_myblog/images/Options_16x16.gif"/>Configuration</div>
  1180. <div class="sideNavContent"> <p><a href="index2.php?option=com_myblog&task=config">General Settings </a></p>
  1181. <p><a href="index2.php?option=com_myblog&task=category">Tags</a></p>
  1182. <p><a href="index2.php?option=com_myblog&task=contentmambots">Content Mambots Integration</a>
  1183. </p> <p><a href="index2.php?option=com_myblog&task=maintenance">Maintenance</a></div>
  1184. <div class="sideNavTitle"><img hspace="2" style="vertical-align: middle;" src="components/com_myblog/images/Documents_16x16.gif"/>Manage Blog Entries</div> <div class="sideNavContent">
  1185. <p>
  1186. <a href="javascript:void(0);" onclick="myAzrulShowWindow('<?php echo $link; ?>');">Write New Entry</a>
  1187. </p>
  1188. <p><a href="index2.php?option=com_myblog&task=blogs&limitstart=0" >View all </a></p>
  1189. <p><a href="index2.php?option=com_myblog&task=blogs&limitstart=0&publish=0" >View unpublished entries</a></p>
  1190. </div> <div class="sideNavTitle"><img hspace="2" style="vertical-align: middle;" src="components/com_myblog/images/Information_16x16.gif"/>About / Support </div> <div class="sideNavContent">
  1191. <p><a href="index2.php?option=com_myblog&task=about">About My Blog </a></p>
  1192. <p>
  1193. <a href="index2.php?option=com_myblog&task=latestnews">Check for latest news</a>
  1194. </p>
  1195. <p><a href="index2.php?option=com_myblog&task=license">License Information</a> </p>
  1196. <p>Support</p> </div></td> </tr> </table> </div> <p align="center">
  1197. <?php $cms =& cmsInstance("CMSCore");
  1198. require_once( $cms->get_path("root").'/includes/domit/xml_domit_lite_include.php' );
  1199. $xmlDoc=new DOMIT_Lite_Document();$xmlDoc->resolveErrors( true );
  1200. $myblog_version="n/a";
  1201. if ($xmlDoc->loadXML( $cms->get_path("root")."/administrator/components/com_myblog/myblog.xml",false,true )) {
  1202. $root=&$xmlDoc->documentElement;
  1203. $element =&$root->getElementsByPath('version',1);
  1204. $myblog_version =$element ? $element->getText():'';
  1205. }
  1206. echo "Version $myblog_version";?></p>
  1207. <?php
  1208. }
  1209. /**
  1210. * View list of blog entries
  1211. */
  1212. function showBlogs() {
  1213. global $mainframe, $_MY_CONFIG;
  1214. $cms = & cmsInstance('CMSCore');
  1215. $cms->load('helper', 'url');
  1216. $db = $cms->db;
  1217. require_once($cms->get_path('root') . "/components/com_myblog/functions.myblog.php");
  1218. require_once($cms->get_path('root') . "/administrator/components/com_myblog/config.myblog.php");
  1219. $_MY_CONFIG = new MYBLOG_Config();
  1220. $limit =intval( $mainframe->getUserStateFromRequest( "viewlistlimit",'limit',$mainframe->getCfg('list_limit') ) );
  1221. $limitstart =intval( $mainframe->getUserStateFromRequest( "view{com_myblog}limitstart",'limitstart',0 ) );
  1222. $search = $mainframe->getUserStateFromRequest("search{com_myblog}", 'search', '');
  1223. $search = $db->_escape(trim(strtolower($search)));
  1224. //$limit = mosGetParam($_GET, 'limit', $_MY_CONFIG->get('numEntry'));
  1225. $publish = "";
  1226. if (isset ($_GET['publish']))
  1227. $publish = intval($_GET['publish']);
  1228. $where = array ();
  1229. if ($search) {
  1230. $where[] = "LOWER(comment) LIKE '%$search%'";
  1231. }
  1232. if (is_int($publish)){
  1233. $where[] = "STATE=$publish";
  1234. }
  1235. $where[] = "sectionid IN (" . $_MY_CONFIG->get('managedSections') . ")";
  1236. $db->query("SELECT count(*) FROM #__content" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : ""));
  1237. $total = $db->get_value();
  1238. $pagination = myPagination($total, $limitstart , $limit);
  1239. $db->query("SELECT * FROM #__content" . (count($where) ? "\nWHERE " . implode(' AND ', $where) : "") . "\n ORDER BY id DESC " . "\nLIMIT $pagination->limitstart,$pagination->limit");
  1240. $rows = $db->get_object_list();
  1241. $total = count($rows);
  1242. //$$limit = 10;
  1243. // Try login user.
  1244. $cms->load('libraries' , 'user');
  1245. $strSQL = "SELECT session_id FROM #__session WHERE `userid`={$cms->user->id}";
  1246. $cms->db->query( $strSQL );
  1247. $cms->load('libraries' , 'user');
  1248. $userId = $cms->user->id;
  1249. $sessionId = $cms->db->get_value();
  1250. ?>
  1251. <script type="text/javascript" language="javascript">
  1252. function toggleEntry(id){
  1253. var entry = document.getElementById(id + '_content');
  1254. if(entry.style.display == 'none')
  1255. entry.style.display = '';
  1256. else
  1257. entry.style.display = 'none';
  1258. }
  1259. </script>
  1260. <form action="index2.php?<?php echo htmlspecialchars($_SERVER['QUERY_STRING'],ENT_QUOTES); ?>" method="POST" name="adminForm">
  1261. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="adminlist">
  1262. <thead>
  1263. <tr>
  1264. <th width="2%" class="title">
  1265. <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows );?>);" />
  1266. </th>
  1267. <th width="10%">Date</th>
  1268. <th width="25%">Title</th>
  1269. <th width="5%">Published</th>
  1270. <th width="5%">Edit</th>
  1271. <th width="30%">Tags</th>
  1272. <th width="20%">Author</th>
  1273. </tr>
  1274. </thead>
  1275. <tbody>
  1276. <?php
  1277. $i=0;$n=1;
  1278. if ($rows) {
  1279. foreach($rows as $row){
  1280. $task=$row->state ? 'unpublish':'publish';
  1281. $img=$row->state ? 'publish_g.png':'publish_x.png';
  1282. $isFp = $db->get_value();
  1283. $taskFp=$isFp ? 'unfrontpage':'frontpage';
  1284. $imgFp=$isFp ? 'tick.png':'publish_x.png';
  1285. ?>
  1286. <tr>
  1287. <td>
  1288. <input type='checkbox' id='cb<?php echo $i;?>' name='cid[]' value='<?php echo $row->id;?>' onclick='isChecked(this.checked);' />
  1289. </td>
  1290. <td>
  1291. <?php
  1292. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  1293. echo mosFormatDate($row->created, "%d %b %Y<br/>%H:%M:%S");
  1294. }elseif(cmsVersion() == _CMS_JOOMLA15){
  1295. echo JHTML::_('date', $row->created);
  1296. }
  1297. ?>
  1298. </td>
  1299. <td>
  1300. <a href="javascript:void(0);" onclick="toggleEntry('<?php echo $row->id; ?>');"><?php echo htmlspecialchars($row->title);?></a>
  1301. </td>
  1302. <td width="5%" align="center">
  1303. <a href="javascript:void(0);" onclick="jax.icall('myblog','myxTogglePublishAdmin','<?php echo $row->id;?>');">
  1304. <img id="pubImg<?php echo $row->id;?>" src="images/<?php echo $img;?>" hspace="8" width="12" height="12" border="0" alt="" /></a>
  1305. </td>
  1306. <td align="center">
  1307. [&nbsp;<a href="javascript:void(0);" onclick="myAzrulShowWindow('<?php echo rtrim($cms->get_path('live') ,'/');?>/index2.php?option=com_myblog&task=write&no_html=1&id=<?php echo $row->id;?>&session=<?php echo $userId . ':' . $sessionId;?>');">Edit</a>&nbsp;]
  1308. </td>
  1309. <td><?php echo myCategoriesURLGet($row->id,false,false,false);?></td>
  1310. <td align="center">
  1311. <?php echo myUserGetName($row->created_by);?>
  1312. </td>
  1313. </tr>
  1314. <tr id="<?php echo $row->id; ?>_content" style="display: none;">
  1315. <td colspan="7"><?php echo $row->introtext . $row->fulltext; ?></td>
  1316. </tr>
  1317. <?php $i++;
  1318. }
  1319. }
  1320. ?>
  1321. </tbody>
  1322. <tfoot>
  1323. <tr>
  1324. <td colspan="7">
  1325. <input type="hidden" name="option" value="com_myblog" />
  1326. <input type="hidden" name="task" value="blogs" />
  1327. <input type="hidden" name="boxchecked" value="0" />
  1328. <div style="width:100%;"><?php echo $pagination->footer;?></div>
  1329. </td>
  1330. <tr>
  1331. </tfoot>
  1332. </table>
  1333. </form>
  1334. <?php
  1335. }
  1336. /**
  1337. * Delete selected blog entries
  1338. */
  1339. function removeBlogs($cid){
  1340. global $database, $mainframe;
  1341. $cms =& cmsInstance('CMSCore');
  1342. $cms->load('helper', 'url');
  1343. $db =& cmsInstance('CMSDb');
  1344. if ($cid and !empty($cid)) {
  1345. foreach ($cid as $uid) {
  1346. $db->query("DELETE FROM #__content WHERE id=$uid");
  1347. $db->query("DELETE FROM #__myblog_permalinks WHERE contentid=$uid");
  1348. $db->query("DELETE FROM #__myblog_images WHERE contentid=$uid");
  1349. $db->query("DELETE FROM #__myblog_content_categories WHERE contentid=$uid");
  1350. }
  1351. }
  1352. cmsRedirect($cms->get_path('live')."/administrator/index2.php?option=com_myblog&task=blogs&limitstart=0","Blog entries deleted.");
  1353. }
  1354. /**
  1355. * Show list of myblog bots
  1356. */
  1357. function showBots(){
  1358. global $database, $mainframe, $option, $_MY_CONFIG;
  1359. $cms =& cmsInstance("CMSCore");
  1360. require_once($cms->get_path("root")."/components/com_myblog/functions.myblog.php");
  1361. require_once($cms->get_path("root")."/administrator/components/com_myblog/config.myblog.php");
  1362. $_MY_CONFIG=new MYBLOG_Config();$publish="";
  1363. if (isset($_GET['publish'])) $publish= intval($_GET['publish']);
  1364. $cms->db->query( "SELECT count(*) FROM #__myblog_bots");
  1365. $total = $cms->db->get_value();
  1366. $cms->db->query( "SELECT * FROM #__myblog_bots" ."\n ORDER BY ordering ASC ");
  1367. $rows = $cms->db->get_object_list();
  1368. $total = count($rows);?>
  1369. <form action="index2.php?option=com_myblog&task=bots&publish=<?php echo $publish;?>" method="post" name="adminForm">
  1370. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="adminlist"> <tr> <th width="2%" class="title">
  1371. <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows );?>);" /></th>
  1372. <th width="35%">&nbsp;Bot Name</th> <th width="20%">&nbsp;Folder</th> <th width="20%">&nbsp;Filename</th> <th width="5%">&nbsp;Published</th>
  1373. <th width="15%">&nbsp;&nbsp;Order</th> </tr> <?php $i=0;
  1374. foreach($rows as $row){
  1375. $task=$row->published ? 'unpublish':'publish';
  1376. $img=$row->published ? 'publish_g.png':'publish_x.png';?>
  1377. <tr id='bot<?php echo $i ?>'> <td>
  1378. <input type='checkbox' id='cb<?php echo $i;?>' name='cid[]' value='<?php echo $row->id;?>' onclick='isChecked(this.checked);' /></td>
  1379. <td>&nbsp;<?php echo $row->name;?></td> <td>&nbsp;<?php echo $row->folder;?></td> <td>&nbsp;<?php echo $row->filename;?></td>
  1380. <td align="right"><a href="javascript:void(0);" onclick="jax.icall('myblog','myxToggleBotPublish','<?php echo $row->id;?>');return false;">
  1381. <img id="pubImg<?php echo $row->id;?>" src="images/<?php echo $img;?>" hspace="8" width="12" height="12" border="0" alt="" /></a></td>
  1382. <td>&nbsp;&nbsp;
  1383. <?php
  1384. if ($i > 0) {
  1385. echo '<a href="javascript:void(0);" onClick="jax.icall(\'myblog\',\'orderBot\',\''.$row->id.'\',\''.$i.'\',\'1\');" title="'.'Order Up'.'"> <img src="images/uparrow.png" width="12" height="12" border="0" alt="'.'Order Up'.'"> </a>';
  1386. } else {
  1387. echo '&nbsp;';} ?> <?php
  1388. if ($i < $total-1 && $i>0) {
  1389. echo '<a href="javascript:void(0);" onClick="jax.icall(\'myblog\',\'orderBot\',\''.$row->id.'\',\''.$i.'\',\'-1\');" title="'.'Order Down'.'"> <img src="images/downarrow.png" width="12" height="12" border="0" alt="'.'Order Down'.'"> </a>';
  1390. } else {
  1391. echo '&nbsp;';
  1392. } ?> </td> </tr>
  1393. <?php $i++;
  1394. } ?>
  1395. </table>
  1396. <input type="hidden" name="option" value="com_myblog" />
  1397. <input type="hidden" name="task" value="bots" />
  1398. <input type="hidden" name="boxchecked" value="0" />
  1399. <input type="hidden" name="limitstart" value="<?php ?>"> <input type="hidden" name="limit" value="<?php ?>">
  1400. </form></div></td> </tr> </table>
  1401. <?php }
  1402. function addBot(){
  1403. global $mainframe, $option;
  1404. $cms =& cmsInstance("CMSCore"); ?>
  1405. <p> <form action="index2.php?option=com_myblog&task=saveBot" method="post" name="adminForm">
  1406. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="adminlist"> <th colspan="3">Add New MyBlog Bot</th>
  1407. <tr> <td><strong>Bot Name</strong></td> <td><input type="text" id="botName" name="botName" size="40" /></td> <td>&nbsp;</td> </tr>
  1408. <tr> <td width="23%"><b>Folder</b></td> <td width="25%"><select name="folder" id="folder">
  1409. <?php $curr_dir=$cms->get_path("root")."/components/com_myblog/plugins";
  1410. if ($dir_handle=opendir($curr_dir)) {
  1411. while (($file=readdir($dir_handle))!==false) {
  1412. if (is_dir($curr_dir."/".$file) and $file!="." and $file!=".."){
  1413. echo '<option value="'.$file.'">'.$file.'</option>\n';
  1414. }
  1415. }
  1416. closedir($dir_handle);} ?> </select></td> <td width="52%">&nbsp;</td> </tr> <tr>
  1417. <td><strong>Filename</strong></td> <td><input type="text" id="filename" name="filename" size="30" />.php</td>
  1418. <td>&nbsp;</td> </tr> <tr> <td><strong>Publish</strong></td> <td>
  1419. <?php echo mosHTML::yesnoRadioList( 'published','class="inputbox"',"0");?></td> <td>&nbsp;</td> </tr> <tr> <td colspan="3">&nbsp;</td> </tr> </table>
  1420. <input type="hidden" name="option" value="com_myblog">
  1421. <input type="hidden" name="task" value="saveBot">
  1422. <input type="hidden" name="boxchecked" value="0"> </form> </p>
  1423. <?php } function showAbout(){ ?>
  1424. <table width="100%" border="0" cellspacing="0" cellpadding="4">
  1425. <tr>
  1426. <td>
  1427. <p>About MyBlog for Joomla! </p>
  1428. <p>MyBlog brings the power of Ajax to Joomla CMS.</p>
  1429. <h3>Blog in style using MyBlog! </h3>
  1430. <p>Thank you for using My Blog - a WordPress-like blogging tool for Joomla! Developed by the Team at Pocketcraft Software that created JomComment,
  1431. My Blog is designed to be an easy to use, neat, yet fully featured blogging component for Joomla!, replacing existing blogging solutions
  1432. like Mamblog and Joomla!'s own content editor. </p>
  1433. <p>Features include: <blockquote>
  1434. - trackback<br/>
  1435. - RSS<br/>
  1436. - custom template system<br/>
  1437. - simple and easy to use blog editor with Myblog's own custom made image browser<br/>
  1438. - admin control over blogging<br/>
  1439. - tags<br/>
  1440. - Joomla content mambot integration<br/>
  1441. - blog posts search<br/>
  1442. - and much more!</blockquote>
  1443. </p>
  1444. <p>
  1445. Visit us at <a href="http://www.azrul.com">http://www.azrul.com</a> to find out more about other exciting Joomla! components we have to offer.
  1446. </p>
  1447. </td> </tr> </table> <?php
  1448. }
  1449. /**
  1450. * Show list of content mambots
  1451. **/
  1452. function showMambots(){
  1453. global $mainframe, $_MY_CONFIG;
  1454. require_once(MY_LIBRARY_PATH . '/plugins.class.php');
  1455. $plugins = new MYPlugins();
  1456. $cms =& cmsInstance('CMSCore');
  1457. $cms->load('helper', 'url');
  1458. $limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit",'limit',$mainframe->getCfg('list_limit') ) );
  1459. $limitstart = intval( $mainframe->getUserStateFromRequest( "view{com_myblog}limitstart",'limitstart',0 ) );
  1460. $publish = cmsGetVar('publish','','GET');
  1461. $plugins->init();
  1462. $rows = $plugins->get($limitstart, $limit);
  1463. $total = count($rows);
  1464. $pagination = myPagination($total, $limitstart, $limit);
  1465. ?>
  1466. <div>
  1467. <span style="color:red;font-weight: bold;">NOTE:</span>
  1468. Content Mambot integration is by default only enabled when you view a blog entry.<br />
  1469. To enable Content Mambot integration on the list of blog entries, make sure
  1470. <b>'Use mambots on My Blog frontpage?'</b> settings in <b>General Settings->Layout</b>
  1471. is set to <b>'Yes'</b>.
  1472. </div>
  1473. <br />
  1474. <form action="#" method="POST" name="adminForm">
  1475. <table width="100%" border="0" cellspacing="0" cellpadding="0" class="adminlist">
  1476. <thead>
  1477. <tr>
  1478. <th width="2%" class="title">
  1479. <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $rows );?>);" />
  1480. </th>
  1481. <th width="35%">&nbsp;Bot Name</th>
  1482. <th width="5%">&nbsp;Published</th>
  1483. <th width="55%">&nbsp;</th>
  1484. </tr>
  1485. </thead>
  1486. <tbody>
  1487. <?php
  1488. $i=0;
  1489. foreach($rows as $row){
  1490. $task = $row->my_published ? 'unpublish' : 'publish';
  1491. $img = $row->my_published ? 'publish_g.png' : 'publish_x.png';
  1492. $mambotsToKeep = ',' . $row->mambot_id;
  1493. ?>
  1494. <tr id="bot<?php echo $i;?>">
  1495. <td>
  1496. <input type='checkbox' id='cb<?php echo $i;?>' name='cid[]' value='<?php echo $row->mambot_id;?>' onclick='isChecked(this.checked);' />
  1497. </td>
  1498. <td>
  1499. &nbsp;<?php echo $row->name;?>
  1500. </td>
  1501. <td align="center">
  1502. <a href="javascript:void(0);" onclick="jax.call('myblog','myxToggleMambotPublish','<?php echo $row->mambot_id;?>');return false;">
  1503. <img id="pubImg<?php echo $row->mambot_id;?>" src="images/<?php echo $img;?>" hspace="8" width="12" height="12" border="0" alt="" />
  1504. </a>
  1505. </td>
  1506. <td>
  1507. &nbsp;
  1508. </td>
  1509. </tr>
  1510. <?php
  1511. $i++;
  1512. }
  1513. ?>
  1514. </tbody>
  1515. <tr>
  1516. <td colspan="4">
  1517. <input type="hidden" name="option" value="com_myblog" />
  1518. <input type="hidden" name="task" value="contentmambots" />
  1519. <input type="hidden" name="boxchecked" value="0" />
  1520. <br />
  1521. <div style="width:100%;">
  1522. <?php echo $pagination->footer;?>
  1523. </div>
  1524. </td>
  1525. </tr>
  1526. </tfoot>
  1527. </table>
  1528. </form>
  1529. <?php
  1530. //$db->query("DELETE FROM #__myblog_mambots WHERE mambot_id NOT IN ($mambotsToKeep)");
  1531. }
  1532. ?>
  1533. <?php
  1534. function showLicense() {
  1535. ?>
  1536. <table cellpadding="4" cellspacing="0" border="0" width="100%">
  1537. <tr>
  1538. <td>
  1539. <H3>SOFTWARE LICENSE AND LIMITED WARRANTY </H3>
  1540. <p>This is a legally binding agreement between you and <em>Pocketcraft Software</em>. By installing and/or using this software, you are agreeing to become bound by the terms of this agreement.</p>
  1541. <p>If you do not agree to the terms of this agreement, do not use this software. </p>
  1542. <p><strong>GRANT OF LICENSE</strong>. <em>Pocketcraft Software</em> grants to you a non-exclusive right to use this software program (hereinafter the "Software") in accordance with the terms contained in this Agreement. You may use the Software on a single computer. If you have purchased a site license, you may use the Software on the number of websites defined by and in accordance with the site license.</p>
  1543. <p><strong>UPGRADES</strong>. If you acquired this software as an upgrade of a previous version, this Agreement replaces and supercedes any prior Agreements. You may not continue to use any prior versions of the Software, and nor may you distribute prior versions to other parties.</p>
  1544. <p><strong>OWNERSHIP OF SOFTWARE</strong>. <em>Pocketcraft Software</em> retains the copyright, title, and ownership of the Software and the written materials.</p>
  1545. <p><strong>COPIES</strong>. You may make as many copies of the software as you wish, as long as you guarantee that the software can only be used on one website (joomla installation) in any one instance. You may not distribute copies of the Software or accompanying written materials to others.</p>
  1546. <p><strong>TRANSFERS</strong>. You may not transfer the Software to another person provided that you have a written permission from <em>Pocketcraft Software</em> . You may not transfer the Software from one website to another. In no event may you transfer, assign, rent, lease, sell, or otherwise dispose of the Software on a temporary basis.</p>
  1547. <p><strong>TERMINATION</strong>. This Agreement is effective until terminated. This Agreement will terminate automatically without notice from <em>Pocketcraft Software</em> if you fail to comply with any provision of this Agreement. Upon termination you shall destroy the written materials and all copies of the Software, including modified copies, if any.</p>
  1548. <p><strong>DISCLAIMER OF WARRANTY</strong>. <em>Pocketcraft Software</em> disclaims all other warranties, express or implied, including, but not limited to, any implied warranties of merchantability, fitness for a particular purpose and noninfringement.</p>
  1549. <p><strong>OTHER WARRANTIES EXCLUDED</strong>. <em>Pocketcraft Software</em> shall not be liable for any direct, indirect, consequential, exemplary, punitive or incidental damages arising from any cause even if <em>Pocketcraft Software</em> has been advised of the possibility of such damages. Certain jurisdictions do not permit the limitation or exclusion of incidental damages, so this limitation may not apply to you.</p>
  1550. <p>In no event will <em>Pocketcraft Software</em> be liable for any amount greater than what you actually paid for the Software. Should any other warranties be found to exist, such warranties shall be limited in duration to 15 days following the date you install the Software.</p>
  1551. <p><strong>EXPORT LAWS</strong>. You agree that you will not export the Software or documentation.</p>
  1552. <p><strong>PROPERTY</strong>. This software, including its code, documentation, appearance, structure, and organization is an exclusive product of the <em>Pocketcraft Software</em>, which retains the property rights to the software, its copies, modifications, or merged parts.</p>
  1553. <p>&nbsp;</p>
  1554. </td>
  1555. </tr>
  1556. </table>
  1557. <?php
  1558. }