PageRenderTime 68ms CodeModel.GetById 26ms 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

Large files files are truncated, but you can click here to view the full file

  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_bo…

Large files files are truncated, but you can click here to view the full file