Esempio n. 1
0
 /**
  * A JParameter object holding the parameters for the plugin
  *
  * @var		A JParameter object
  * @access	public
  * @since	1.5
  */
 public function onCheck()
 {
     $mainframe = JFactory::getApplication();
     //Check System requirements for the editor
     define('JCK_BASE', JPATH_CONFIGURATION . DS . 'plugins' . DS . 'editors' . DS . 'jckeditor');
     if (!JFolder::exists(JCK_BASE)) {
         return;
     }
     $perms = fileperms(JPATH_CONFIGURATION . DS . 'index.php');
     $perms = decoct($perms & 0777);
     $default_fperms = '0644';
     $default_dperms = '0755';
     if ($perms == 777 || $perms == 666) {
         $default_fperms = '0666';
         $default_dperms = '0777';
     }
     $fperms = JCK_BASE . DS . 'config.js';
     if (!stristr(PHP_OS, 'WIN') && JPath::canChmod(JCK_BASE) && $perms != decoct(fileperms($fperms) & 0777)) {
         $path = JCK_BASE . DS . 'plugins';
         if (!JPath::setPermissions($path, $default_fperms, $default_dperms)) {
             $mainframe->enqueueMessage(JText::_('Auto correction failed for incorrect file permissions for the JCK Editor'), 'error');
         }
     }
     $mainframe->enqueueMessage(JText::_('System checked and updated'));
 }
Esempio n. 2
0
 public static function uploader()
 {
     $params = modPwebcontactHelper::getParams();
     // check if upload is enabled
     if (!$params->get('show_upload', 0)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Uploader disabled');
         }
         return array('status' => 402, 'files' => array());
     }
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $path = $params->get('upload_path');
     if (!JFolder::exists($path)) {
         JFolder::create($path, 0777);
     }
     if (!is_writable($path) and JPath::canChmod($path)) {
         JPath::setPermissions($path, null, '0777');
     }
     if (!is_writable($path)) {
         if (PWEBCONTACT_DEBUG) {
             modPwebcontactHelper::setLog('Upload dir is not writable');
         }
         return array('status' => 403, 'files' => array());
     }
     // load uploader
     $uploader = new modPWebContactUploader(array('upload_dir' => $params->get('upload_path'), 'upload_url' => $params->get('upload_url'), 'accept_file_types' => '/(\\.|\\/)(' . $params->get('upload_allowed_ext', '.+') . ')$/i', 'max_file_size' => (double) $params->get('upload_size_limit', 1) * 1024 * 1024, 'image_versions' => array(), 'delete_type' => 'POST'), false, array(1 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 3 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_3'), 4 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_4'), 6 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_6'), 7 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_7'), 8 => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_8'), 'post_max_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_ERR_1'), 'max_file_size' => JText::_('MOD_PWEBCONTACT_UPLOAD_SIZE_ERR'), 'accept_file_types' => JText::_('MOD_PWEBCONTACT_UPLOAD_TYPE_ERR')));
     $response = $uploader->handleRequest();
     if (PWEBCONTACT_DEBUG) {
         modPwebcontactHelper::setLog('Uploader exit');
     }
     return $response;
 }
Esempio n. 3
0
 /**
  * Determines if a given path is writable in the current environment
  *
  * @param   string  $path  Path to check
  *
  * @return  boolean  True if writable
  *
  * @since   4.0
  */
 public static function isWritable($path)
 {
     if (JFactory::getConfig()->get('config.ftp_enable')) {
         return true;
     } else {
         while (!file_exists($path)) {
             $path = dirname($path);
         }
         return is_writable($path) || JPath::isOwner($path) || JPath::canChmod($path);
     }
 }
Esempio n. 4
0
 /**
  * A JParameter object holding the parameters for the plugin
  *
  * @var		A JParameter object
  * @access	public
  * @since	1.5
  */
 public function onCheck()
 {
     //Check System requirements for the editor
     define('JCK_BASE', JPATH_CONFIGURATION . DS . 'plugins' . DS . 'editors' . DS . 'jckeditor');
     if (!JFolder::exists(JCK_BASE)) {
         return;
     }
     $perms = fileperms(JPATH_CONFIGURATION . DS . 'index.php');
     $perms = decoct($perms & 0777);
     $default_fperms = '0644';
     $default_dperms = '0755';
     if ($perms == 777 || $perms == 666) {
         $default_fperms = '0666';
         $default_dperms = '0777';
     }
     $fperms = JCK_BASE . DS . 'config.js';
     if (!stristr(PHP_OS, 'WIN') && JPath::canChmod(JCK_BASE) && $perms != decoct(fileperms($fperms) & 0777)) {
         $path = JCK_BASE . DS . 'plugins';
         if (!JPath::setPermissions($path, $default_fperms, $default_dperms)) {
             $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_AUTO_CORRECTION_FAILED_INCORRECT_FILE_PERMISSION'), 'error');
         }
     }
     $this->app->enqueueMessage(JText::_('COM_JCKMAN_CPANEL_SYSTEM_CHECKED_AND_UPDATED'));
 }
Esempio n. 5
0
		<table cellpadding="1">
			<tr>
				<td width="220">
					<span class="componentheading">
						<?php 
echo _JOOMAP_CSS;
?>
:
						<?php 
echo is_writable($template_path) ? '<strong style="color:green;">' . _JOOMAP_CFG_WRITEABLE . '</strong>' : '<strong style="color:red;">' . _JOOMAP_CFG_UNWRITEABLE . '</strong>';
?>
					</span>
				</td>
	
				<?php 
if (JPath::canChmod($template_path) && is_writable($template_path)) {
    ?>
	
				<td>
					<input type="checkbox" id="disable_write" name="disable_write" value="1" />
					<label for="disable_write"><?php 
    echo _JOOMAP_MSG_MAKE_UNWRITEABLE;
    ?>
</label>
				</td>
	
				<?php 
} else {
    ?>
	
				<td>
Esempio n. 6
0
 /**
  * Set default folder permissions
  *
  * @param string $path The full file path
  * @param string $buffer The buffer to write
  * @return boolean True on success
  * @since 1.5
  */
 function setFolderPermissions($folder, $options)
 {
     // Get the options as a JObject for easier handling.
     $options = JArrayHelper::toObject($options, 'JObject');
     // Initialise variables.
     $ftpFlag = false;
     $ftpRoot = $options->ftpRoot;
     // Determine if the path is "chmodable".
     if (!JPath::canChmod(JPath::clean(JPATH_SITE . DS . $folder))) {
         $ftpFlag = true;
     }
     // Do NOT use ftp if it is not enabled
     if (empty($options->ftpEnable)) {
         $ftpFlag = false;
     }
     if ($ftpFlag == true) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $client =& JFTP::getInstance($options['ftpHost'], $options['ftpPort']);
         $client->login($options['ftpUser'], $options['ftpPassword']);
         //Translate path for the FTP account
         $path = JPath::clean($ftpRoot . "/" . $folder);
         /*
          * chmod using ftp
          */
         if (!$client->chmod($path, '0755')) {
             $ret = false;
         }
         $client->quit();
         $ret = true;
     } else {
         $path = JPath::clean(JPATH_SITE . DS . $folder);
         if (!@chmod($path, octdec('0755'))) {
             $ret = false;
         } else {
             $ret = true;
         }
     }
     return $ret;
 }
Esempio n. 7
0
    /**
     * method to install the component
     *
     * @return void
     */
    function install()
    {
        $db = JFactory::getDBO();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_advertis` (\n\t\t\t\t  `aid` int(11) NOT NULL auto_increment,\n\t\t\t\t  `user_id` int(11) NOT NULL default '0',\n\t\t\t\t  `company` varchar(100) NOT NULL default '',\n\t\t\t\t  `description` varchar(255) default NULL,\n\t\t\t\t  `website` varchar(255) default NULL,\n\t\t\t\t  `address` varchar(100) default NULL,\n\t\t\t\t  `country` varchar(100) default NULL,\n\t\t\t\t  `city` varchar(100) default NULL,\n\t\t\t\t  `state` varchar(100) default NULL,\n\t\t\t\t  `zip` varchar(12) default NULL,\n\t\t\t\t  `telephone` varchar(20) default NULL,\n\t\t\t\t  `fax` varchar(20) default NULL,\n\t\t\t\t  `logo` varchar(255) default NULL,\n\t\t\t\t  `email_daily_report` enum('Y','N') default 'N',\n\t\t\t\t  `email_weekly_report` enum('Y','N') default 'N',\n\t\t\t\t  `email_month_report` enum('Y','N') default 'N',\n\t\t\t\t  `email_campaign_expiration` enum('Y','N') default 'N',\n\t\t\t\t  `approved` enum('Y','N','P') character set latin1 default 'P',\n\t\t\t\t  `lastreport` bigint(20) default NULL,\n\t\t\t\t  `weekreport` bigint(20) default NULL,\n\t\t\t\t  `monthreport` bigint(20) default NULL,\n\t\t\t\t  `paywith` text NOT NULL,\n\t\t\t\t  `apr_ads` enum('G','Y','N') default 'G',\n\t\t\t\t  `apr_cmp` enum('G','Y','N') default 'G',\n\t\t\t\t  `key` varchar(100) default NULL,\n\t\t\t\t  `ordering` int(10) NOT NULL default '0',\n\t\t\t\t  `checked_out` int(10) NOT NULL default '0',\n\t\t\t\t  PRIMARY KEY  (`aid`),\n\t\t\t\t  KEY `user_id` (`user_id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_banners` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `advertiser_id` int(11) NOT NULL DEFAULT '0',\n\t\t\t  `title` varchar(255) NOT NULL DEFAULT '',\n\t\t\t  `description` varchar(255) DEFAULT NULL,\n\t\t\t  `media_type` enum('Standard','Advanced','Popup','Flash','TextLink','Transition','Floating','Jomsocial') DEFAULT 'Standard',\n\t\t\t  `image_url` varchar(255) DEFAULT NULL,\n\t\t\t  `swf_url` varchar(255) DEFAULT NULL,\n\t\t\t  `target_url` varchar(255) DEFAULT NULL,\n\t\t\t  `width` smallint(5) unsigned DEFAULT NULL,\n\t\t\t  `height` smallint(5) unsigned DEFAULT NULL,\n\t\t\t  `ad_code` mediumtext,\n\t\t\t  `use_ad_code_in_netscape` enum('N','Y') DEFAULT 'N',\n\t\t\t  `ad_code_netscape` mediumtext,\n\t\t\t  `parameters` mediumtext,\n\t\t\t  `approved` enum('Y','N','P') CHARACTER SET latin1 DEFAULT 'P',\n\t\t\t  `zone` int(11) NOT NULL DEFAULT '0',\n\t\t\t  `frequency` int(11) DEFAULT NULL,\n\t\t\t  `created` date DEFAULT NULL,\n\t\t\t  `ordering` int(8) NOT NULL DEFAULT '0',\n\t\t\t  `keywords` varchar(255) DEFAULT NULL,\n\t\t\t  `key` varchar(100) DEFAULT NULL,\n\t\t\t  `channel_id` int(11) DEFAULT NULL,\n\t\t\t  `ad_start_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t  `ad_end_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t  `checked_out` int(10) NOT NULL DEFAULT '0',\n\t\t\t  `image_content` varchar(255) NOT NULL,\n\t\t\t  `ad_headline` varchar(255) NOT NULL,\n\t\t\t  `ad_text` text NOT NULL,\n\t\t\t  `access` int(3) NOT NULL,\n\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_campaign` (\n\t\t\t\t  `id` int(11) NOT NULL auto_increment,\n\t\t\t\t  `aid` int(11) NOT NULL default '0',\n\t\t\t\t  `name` varchar(255) NOT NULL default '',\n\t\t\t\t  `notes` text,\n\t\t\t\t  `default` enum('Y','N') NOT NULL default 'N',\n\t\t\t\t  `start_date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t\t\t  `type` enum('cpm','pc','fr','in') NOT NULL default 'cpm',\n\t\t\t\t  `quantity` int(11) default '0',\n\t\t\t\t  `validity` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t\t\t  `cost` decimal(5,2) default '0.00',\n\t\t\t\t  `otid` int(11) default '0',\n\t\t\t\t  `approved` enum('Y','N','P') character set latin1 default 'P',\n\t\t\t\t  `status` tinyint(1) NOT NULL default '1',\n\t\t\t\t  `exp_notice` int(11) NOT NULL default '0',\n\t\t\t\t  `key` varchar(100) default NULL,\n\t\t\t\t  `params` varchar(255) default NULL,\n\t\t\t\t  `renewcmp` int(3) NOT NULL DEFAULT '0',\n\t\t\t\t  `activities` text NOT NULL,\n\t\t\t\t  `ordering` int(10) NOT NULL default '0',\n\t\t\t\t  `checked_out` int(10) NOT NULL default '0',\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_campaign_banner` (\n\t\t\t\t  `campaign_id` int(11) NOT NULL default '0',\n\t\t\t\t  `banner_id` int(11) NOT NULL default '0',\n\t\t\t\t  `relative_weighting` int(11) NOT NULL default '100',\n\t\t\t\t  `thumb` varchar(255) default NULL,\n\t\t\t\t  `zone` int(11) default NULL,\n\t\t\t\t  PRIMARY KEY  (`campaign_id`,`banner_id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_channels` (\n\t\t\t\t  `id` int(11) NOT NULL auto_increment,\n\t\t\t\t  `name` varchar(100) NOT NULL,\n\t\t\t\t  `banner_id` int(11) default '0',\n\t\t\t\t  `advertiser_id` int(11) default '0',\n\t\t\t\t  `public` enum('Y','N') NOT NULL default 'N',\n\t\t\t\t  `created` datetime default NULL,\n\t\t\t\t  `created_by` int(11) default NULL,\n\t\t\t\t  `from` enum('F','B') NOT NULL default 'B',\n\t\t\t\t  `ordering` int(10) NOT NULL default '0',\n\t\t\t\t  `checked_out` int(10) NOT NULL default '0',\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_channel_set` (\n\t\t\t\t  `id` int(11) NOT NULL auto_increment,\n\t\t\t\t  `channel_id` int(11) NOT NULL,\n\t\t\t\t  `type` varchar(25) NOT NULL,\n\t\t\t\t  `logical` varchar(25) NOT NULL,\n\t\t\t\t  `option` varchar(25) NOT NULL,\n\t\t\t\t  `data` text NOT NULL,\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_currencies` (\n\t\t\t\t  `id` int(11) NOT NULL auto_increment,\n\t\t\t\t  `plugname` varchar(30) NOT NULL default '',\n\t\t\t\t  `currency_name` varchar(20) NOT NULL default '',\n\t\t\t\t  `currency_full` varchar(50) NOT NULL default '',\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_order` (\n\t\t\t\t  `oid` int(11) NOT NULL auto_increment,\n\t\t\t\t  `tid` int(11) NOT NULL default '0',\n\t\t\t\t  `aid` int(11) NOT NULL default '0',\n\t\t\t\t  `type` enum('cpm','pc','fr', 'in') NOT NULL default 'cpm',\n\t\t\t\t  `quantity` int(11) NOT NULL default '0',\n\t\t\t\t  `cost` decimal(10,2) NOT NULL default '0.00',\n\t\t\t\t  `order_date` date NOT NULL default '0000-00-00',\n\t\t\t\t  `payment_type` varchar(20) NOT NULL,\n\t\t\t\t  `card_number` varchar(20) default NULL,\n\t\t\t\t  `expiration` varchar(4) default NULL,\n\t\t\t\t  `card_name` varchar(255) default NULL,\n\t\t\t\t  `notes` varchar(255) NOT NULL default '',\n\t\t\t\t  `status` enum('not_paid','paid','rejected') default 'not_paid',\n\t\t\t\t  `pack_id` enum('0','1') NOT NULL default '0',\n\t\t\t\t  `currency` varchar(50) NOT NULL,\n\t\t\t\t  `promocodeid` int(3) NOT NULL,\n\t\t\t\t  `ordering` int(10) NOT NULL default '0',\n\t\t\t\t  `checked_out` int(10) NOT NULL default '0',\n\t\t\t\t  PRIMARY KEY  (`oid`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_order_type` (\n\t\t\t\t  `tid` int(11) NOT NULL auto_increment,\n\t\t\t\t  `description` varchar(255) NOT NULL default '',\n\t\t\t\t  `pack_description` text NOT NULL,\n\t\t\t\t  `quantity` int(11) NOT NULL default '0',\n\t\t\t\t  `type` enum('cpm','pc','fr', 'in') NOT NULL default 'cpm',\n\t\t\t\t  `cost` decimal(10,2) NOT NULL default '0.00',\n\t\t\t\t  `validity` mediumtext,\n\t\t\t\t  `sid` int(11) NOT NULL default '0',\n\t\t\t\t  `published` tinyint(1) NOT NULL default '1',\n\t\t\t\t  `visibility` tinyint(4) NOT NULL default '1',\n\t\t\t\t  `zones` text NOT NULL,\n\t\t\t\t  `zones_wildcard` text,\n\t\t\t\t  `ordering` int(11) NOT NULL default '0',\n\t\t\t\t  `hide_after` tinyint(2) NOT NULL default '0',\n\t\t\t\t  `location` int(11) NOT NULL,\n\t\t\t\t  `checked_out` int(10) NOT NULL default '0',\n\t\t\t\t  PRIMARY KEY  (`tid`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_package_zone` (\n\t\t\t\t  `package_id` int(11) NOT NULL,\n\t\t\t\t  `zone_id` int(11) NOT NULL,\n\t\t\t\t  PRIMARY KEY  (`package_id`,`zone_id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_plugins` (\n\t\t\t\t  `id` int(11) NOT NULL auto_increment,\n\t\t\t\t  `name` varchar(40) NOT NULL default '',\n\t\t\t\t  `classname` varchar(40) NOT NULL default '',\n\t\t\t\t  `value` text NOT NULL,\n\t\t\t\t  `filename` varchar(40) NOT NULL default '',\n\t\t\t\t  `type` varchar(10) NOT NULL default 'payment',\n\t\t\t\t  `published` int(11) NOT NULL default '0',\n\t\t\t\t  `def` varchar(30) NOT NULL default '',\n\t\t\t\t  `sandbox` int(11) NOT NULL default '0',\n\t\t\t\t  `reqhttps` int(11) NOT NULL default '0',\n\t\t\t\t  `display_name` varchar(20) default NULL,\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_plugin_settings` (\n\t\t\t\t  `pluginid` int(11) NOT NULL default '0',\n\t\t\t\t  `setting` varchar(200) NOT NULL default '',\n\t\t\t\t  `description` text NOT NULL,\n\t\t\t\t  `value` text NOT NULL,\n\t\t\t\t  KEY `pluginid` (`pluginid`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_promocodes` (\n\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `title` varchar(200) NOT NULL DEFAULT '',\n\t\t\t\t  `code` varchar(100) NOT NULL DEFAULT '',\n\t\t\t\t  `codelimit` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `amount` float NOT NULL DEFAULT '0',\n\t\t\t\t  `codestart` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `codeend` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `forexisting` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `published` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `aftertax` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `promotype` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `used` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `ordering` int(11) NOT NULL DEFAULT '0',\n\t\t\t\t  `checked_out` int(11) unsigned NOT NULL DEFAULT '0',\n\t\t\t\t  `checked_out_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\t\t  PRIMARY KEY (`id`),\n\t\t\t\t  UNIQUE KEY `code` (`code`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_settings` (\n\t\t\t\t  `id` int(11) NOT NULL default '1',\n\t\t\t\t  `lastsend` bigint(20) NOT NULL default '0',\n\t\t\t\t  `adminemail` text,\n\t\t\t\t  `fromemail` text,\n\t\t\t\t  `fromname` text,\n\t\t\t\t  `imgfolder` text,\n\t\t\t\t  `maxchars` int(11) default NULL,\n\t\t\t\t  `captcha` tinyint(4) NOT NULL default '0',\n\t\t\t\t  `allowstand` varchar(2) default NULL,\n\t\t\t\t  `allowadcode` varchar(2) default NULL,\n\t\t\t\t  `allowpopup` varchar(2) default NULL,\n\t\t\t\t  `allowswf` varchar(2) default NULL,\n\t\t\t\t  `allowtxtlink` varchar(2) default NULL,\n\t\t\t\t  `allowtrans` varchar(2) default NULL,\n\t\t\t\t  `allowfloat` varchar(2) default NULL,\n\t\t\t\t  `txtafterreg` text,\n\t\t\t\t  `bodyafterreg` text,\n\t\t\t\t  `sbafterreg` text,\n\t\t\t\t  `bodyactivation` text,\n\t\t\t\t  `sbactivation` text,\n\t\t\t\t  `bodyrep` text,\n\t\t\t\t  `sbrep` text,\n\t\t\t\t  `bodycmpappv` text,\n\t\t\t\t  `sbcmpappv` text,\n\t\t\t\t  `bodycmpdis` text,\n\t\t\t\t  `sbcmpdis` text,\n\t\t\t\t  `bodyadappv` text,\n\t\t\t\t  `sbadappv` text,\n\t\t\t\t  `bodyaddisap` text,\n\t\t\t\t  `sbaddisap` text,\n\t\t\t\t  `bodyadvdis` text,\n\t\t\t\t  `sbadvdis` text,\n\t\t\t\t  `bodynewad` text,\n\t\t\t\t  `sbnewad` text,\n\t\t\t\t  `bodynewcmp` text,\n\t\t\t\t  `sbnewcmp` text,\n\t\t\t\t  `bodycmpex` text,\n\t\t\t\t  `sbcmpex` text,\n\t\t\t\t  `bodynewuser` text,\n\t\t\t\t  `sbnewuser` text,\n\t\t\t\t  `currencydef` text,\n\t\t\t\t  `indextbl` int(2) NOT NULL default '0',\n\t\t\t\t  `askterms` enum('0','1') NOT NULL default '0',\n\t\t\t\t  `termsid` int(11) NOT NULL,\n\t\t\t\t  `overviewcontent` text NOT NULL,\n\t\t\t\t  `showpreview` tinyint(2) NOT NULL default '1',\n\t\t\t\t  `show` varchar(255) NOT NULL default 'captcha;refresh;',\n\t\t\t\t  `mandatory` varchar(50) default NULL,\n\t\t\t\t  `params` varchar(255) default NULL,\n\t\t\t\t  `sbafterregaa` text,\n\t\t\t\t  `bodyafterregaa` text,\n\t\t\t\t  `countryloc` varchar(150) NOT NULL default 'geoip/countries',\n\t\t\t\t  `cityloc` varchar(150) NOT NULL default 'geoip/GeoLiteCity.dat',\n\t\t\t\t  `codeloc` varchar(150) NOT NULL default 'geoip/code',\n\t\t\t\t  `payment` varchar(50) NOT NULL,\n\t\t\t\t  `geoparams` text NOT NULL,\n\t\t\t\t  `limit_ip` int(10) NOT NULL default '100',\n\t\t\t\t  `sbcmpexpadm` text NOT NULL,\n\t\t\t\t  `bodycmpexpadm` text NOT NULL,\n\t\t\t\t  `version` varchar(100) default '2.0.10',\n\t\t\t\t  `forcehttps` int(3) NOT NULL default '0',\n\t\t\t\t  `jomfields` varchar(255) DEFAULT NULL,\n\t\t\t\t  `allow_add_keywords` int(3) NOT NULL DEFAULT '0',\n\t\t\t\t  `imagetools` int(3) NOT NULL DEFAULT '1',\n\t\t\t\t  `sbadchanged` text NOT NULL,\n\t\t\t\t  `boadchanged` text NOT NULL,\n\t\t\t\t  `last_check_date` datetime NOT NULL,\n\t\t\t\t  `showpromocode` int(3) NOT NULL DEFAULT '0',\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_stat` (\n\t\t\t\t  `entry_date` datetime NOT NULL default '0000-00-00 00:00:00',\n\t\t\t\t  `ip_address` bigint(15) NOT NULL default '0',\n\t\t\t\t  `advertiser_id` int(11) NOT NULL default '0',\n\t\t\t\t  `campaign_id` int(11) NOT NULL default '0',\n\t\t\t\t  `banner_id` int(11) NOT NULL default '0',\n\t\t\t\t  `type` enum('click','impressions') NOT NULL default 'impressions',\n\t\t\t\t  `how_many` int(9) NOT NULL default '0',\n\t\t\t\t  KEY `idxip_address` (`ip_address`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_states` (\n\t\t\t\t  `id` int(20) NOT NULL auto_increment,\n\t\t\t\t  `state` varchar(30) NOT NULL default '',\n\t\t\t\t  `country` varchar(30) NOT NULL default '',\n\t\t\t\t  PRIMARY KEY  (`id`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_zone` (\n\t\t\t\t  `zoneid` int(11) NOT NULL default '0',\n\t\t\t\t  `banners` tinyint(2) unsigned NOT NULL default '0',\n\t\t\t\t  `banners_cols` tinyint(2) NOT NULL default '1',\n\t\t\t\t  `z_title` text NOT NULL,\n\t\t\t\t  `z_ordering` int(11) NOT NULL default '0',\n\t\t\t\t  `z_position` varchar(50) default NULL,\n\t\t\t\t  `show_title` tinyint(3) unsigned NOT NULL default '1',\n\t\t\t\t  `suffix` text NOT NULL,\n\t\t\t\t  `rotatebanners` enum('0','1') NOT NULL default '0',\n\t\t\t\t  `rotating_time` int(11) NOT NULL default '10000',\n\t\t\t\t  `rotaterandomize` enum('0','1') NOT NULL default '1',\n\t\t\t\t  `show_adv_link` tinyint(1) NOT NULL default '1',\n\t\t\t\t  `cellpadding` int(11) NOT NULL default '0',\n\t\t\t\t  `link_taketo` tinyint(1) NOT NULL default '0',\n\t\t\t\t  `taketo_url` varchar(255) default NULL,\n\t\t\t\t  `itemid` int(10) default '0',\n\t\t\t\t  `defaultad` int(8) default NULL,\n\t\t\t\t  `keywords` tinyint(2) NOT NULL default '0',\n\t\t\t\t  `adparams` varchar(255) NOT NULL,\n\t\t\t\t  `ignorestyle` enum('0','1') NOT NULL default '0',\n\t\t\t\t  `textadparams` varchar(255) NOT NULL,\n\t\t\t\t  `zone_text_below` text NOT NULL,\n\t\t\t\t  `zone_content_location` int(3) NOT NULL DEFAULT '0',\n\t\t\t\t  `zone_content_visibility` int(3) NOT NULL DEFAULT '0',\n\t\t\t\t  `ordering` int(10) NOT NULL default '0',\n\t\t\t\t  `checked_out` int(10) NOT NULL default '0',\n\t\t\t\t  `inventory_zone` int(3) NOT NULL default '0',\n\t\t\t\t  PRIMARY KEY  (`zoneid`)\n\t\t\t\t) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_statistics` (\n\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `entry_date` date NOT NULL DEFAULT '0000-00-00',\n\t\t\t\t  `impressions` longtext,\n\t\t\t\t  `click` longtext,\n\t\t\t\t  PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
        $db->setQuery($sql);
        $db->query();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_ips` (\n\t\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t\t  `entry_date` date NOT NULL DEFAULT '0000-00-00',\n\t\t\t\t  `ips_impressions` longtext,\n\t\t\t\t  `ips_clicks` longtext NOT NULL,\n\t\t\t\t  PRIMARY KEY (`id`)\n\t\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
        $db->setQuery($sql);
        $db->query();
        // 27.04.2012 modification made by Alin
        //$imagepath = str_replace("/administrator", "", JPATH_BASE);
        //$imagepath = $imagepath . "/images/stories";
        $imagepath = JPATH_SITE . "/images/stories";
        // check if the stories folder exists, if not create it
        $full_path2 = $imagepath;
        if (!JFolder::exists($full_path2)) {
            JFolder::create($full_path2);
        }
        if (JPath::canChmod($full_path2)) {
            JPath::setPermissions($full_path2);
        }
        // 27.04.2012 modification made by Alin
        //$imagepath = str_replace("/administrator", "", JPATH_BASE);
        //$imagepath = $imagepath . "/images/stories/";
        $imagepath = JPATH_SITE . "/images/stories";
        $newimgfolder = 'ad_agency';
        // 27.04.2012 modification made by Alin
        //$full_path = JFolder::makeSafe($imagepath . $newimgfolder);
        //$full_path = JFolder::makeSafe($imagepath."/".$newimgfolder);
        $full_path = $imagepath . "/" . $newimgfolder;
        if (!JFolder::exists($full_path)) {
            JFolder::create($full_path);
            // mkdir ( $imagepath . $newimgfolder );
        }
        if (JPath::canChmod($full_path)) {
            JPath::setPermissions($full_path);
        }
        $this->installAlertUploadPlugins();
        $this->addNewColumns();
        $database = JFactory::getDBO();
        $db = JFactory::getDBO();
        $sql = "CREATE TABLE IF NOT EXISTS `#__ad_agency_jomsocial` (\n\t\t\t  `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t  `ad_id` int(10) NOT NULL,\n\t\t\t  `field_id` int(11) NOT NULL,\n\t\t\t  `value` text NOT NULL,\n\t\t\t  PRIMARY KEY (`id`)\n\t\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8;";
        $db->setQuery($sql);
        $db->query();
        $sql = "SHOW columns FROM `#__ad_agency_settings`";
        $database->setQuery($sql);
        $res_confs = $database->loadColumn();
        if (!in_array("blacklist", $res_confs)) {
            $sql = "ALTER TABLE `#__ad_agency_settings` ADD `blacklist` longtext NULL ";
            $db->setQuery($sql);
            $db->query();
        }
        if (!in_array("jomfields", $res_confs)) {
            $sql = "ALTER TABLE `#__ad_agency_settings` ADD `jomfields` VARCHAR( 255 ) NULL ";
            $db->setQuery($sql);
            $db->query();
        }
        if (!in_array("forcehttps", $res_confs)) {
            $sql = "ALTER TABLE `#__ad_agency_settings` ADD `forcehttps` int(3) NOT NULL default '0' ";
            $db->setQuery($sql);
            $db->query();
        }
        $sql = "SHOW columns FROM `#__ad_agency_campaign`";
        $database->setQuery($sql);
        $res_confs = $database->loadColumn();
        if (!in_array("renewcmp", $res_confs)) {
            $sql = "ALTER TABLE `#__ad_agency_campaign` ADD `renewcmp` int(3) NOT NULL DEFAULT '0'";
            $db->setQuery($sql);
            $db->query();
        }
        $sql = "ALTER TABLE `#__ad_agency_settings` CHANGE `params` `params` TEXT CHARACTER \n\t\t\t\t   SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL ";
        $db->setQuery($sql);
        $db->query();
        //see if we have any settings in the settings table and add the default email settings
        $sql = "SELECT `txtafterreg` FROM `#__ad_agency_settings` LIMIT 1";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $textafterreg = $database->loadColumn();
        $txtafterreg = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
						<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
						<div id="adg-mail-cont">
						<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
						<div>
						<div class="adg-mail-title-wrap">
						<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span>Thank you {name}!</h2>
						</div>
						<div class="adg-mail-text-wrap">
						<p class="adg-mail-text">Thank you for registering to our Ad Agency. Your account is pending approval. We will notify you by email when your account is approved. Please save your login information for future reference: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"> <span style="display: block;"><strong class="adg-block">Username</strong> - {login} </span> <strong class="adg-block">Password</strong> - {password}</span></p>
						</div>
						</div>
						</div>
						</div>
						</div>
						</div>';
        $bdyafterreg = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span>Hello {name}!</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">We have approved your application! Now you can login to our site with the following information and manage your account, add banners, create campaigns,etc. <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"> <span style="display: block;"><strong class="adg-block">Username</strong> - {login} </span></span></p>
					<p class="adg-mail-text">Ad Agency Manager</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $afterregaap = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
						<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
						<div id="adg-mail-cont">
						<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
						<div>
						<div class="adg-mail-title-wrap">
						<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
						</div>
						<div class="adg-mail-text-wrap">
						<p class="adg-mail-text">Thank you for registering to our Ad Agency. Your account is now approved.</p>
						<p class="adg-mail-text">Your login information is listed below. <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Username</strong> - {login} </span> <strong class="adg-block">Password</strong> - {password}</span></p>
						</div>
						</div>
						</div>
						</div>
						</div>
						</div>';
        $afterregneedsapp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
						<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
						<div id="adg-mail-cont">
						<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
						<div>
						<div class="adg-mail-title-wrap">
						<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
						</div>
						<div class="adg-mail-text-wrap">
						<p class="adg-mail-text">Thank you for registering to our Ad Agency. Your account is now pending approval. We will send you an email as soon as we approve it. <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Username</strong> - {login} </span> <strong class="adg-block">Password</strong> - {password}</span></p>
						<p class="adg-mail-text">Please click the following link to activate your user account: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Activation link</strong> - {activate_url} </span> </span></p>
						<p class="adg-mail-text">This will give you access to our site as a user, not as advertiser. When we approve your advertiser account, we will notify you via email.</p>
						<p class="adg-mail-text">Ad Agency Manager</p>
						</div>
						</div>
						</div>
						</div>
						</div>
						</div>';
        $reportemail = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
						<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
						<div id="adg-mail-cont">
						<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
						<div>
						<div class="adg-mail-title-wrap">
						<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear {name}!</h2>
						</div>
						<div class="adg-mail-text-wrap">
						<p class="adg-mail-text">The following is a clicks and impressions report for {daterange} <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Campaign Name:</strong> - {campaign} </span> <strong class="adg-block">Total clicks:</strong> - {clicks} <br /> <strong class="adg-block">Total impressions:</strong> - {impressions} </span></p>
						<p class="adg-mail-text">{used_for_more_campaigns}</p>
						<p class="adg-mail-text">You may login to your advertiser interface for more detailed reports.</p>
						<p class="adg-mail-text">Thank you!</p>
						<p class="adg-mail-text">Admin</p>
						</div>
						</div>
						</div>
						</div>
						</div>
						</div>';
        $campapp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">Your campaign {campaign} has been approved!</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $campdisapp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
						<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
						<div id="adg-mail-cont">
						<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
						<div>
						<div class="adg-mail-title-wrap">
						<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
						</div>
						<div class="adg-mail-text-wrap">
						<p class="adg-mail-text">Your campaign {campaign} has been suspended by an administrator!</p>
						</div>
						</div>
						</div>
						</div>
						</div>
						</div>';
        $bannerapp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">Your banner {banner} been approved!</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $bannerdisapp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">Your banner {banner} has been dissapproved.</p>
					<p class="adg-mail-text">Possible reasons:</p>
					<ul>
					<li>Banner is in the wrong size</li>
					<li>Banner is inappropriate to our needs</li>
					<li>Banner has p**n or other problems</li>
					</ul>
					<p class="adg-mail-text">If you have any questions regarding this, please reply to this email.</p>
					<p class="adg-mail-text">Thank you,</p>
					<p class="adg-mail-text">Ad Agency Admin</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $advdisapp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Hello {name}!</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">Your advertiser account on our Ad Agency has been disapproved.</p>
					<p class="adg-mail-text">Possible reasons:</p>
					<ul>
					<li>We do not accept new advertisers at this point</li>
					<li>We do not advertise your kind of products on our site</li>
					</ul>
					<p class="adg-mail-text">If you have any questions regarding this, please reply to this email.</p>
					<p class="adg-mail-text">Thank you,</p>
					<p class="adg-mail-text">Ad Agency Admin</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $campexp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear {name}!</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">Campaign {campaign} has expired {expire_date}. Please click on the link below to start a new campaign with the same package:</p>
					<p class="adg-mail-text"><span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> {campaign_renew_URL}</span> </span></p>
					<p class="adg-mail-text">To purchase a different package, click here:</p>
					<p class="adg-mail-text"><span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> {packages_url}</span> </span></p>
					<p class="adg-mail-text">Admin</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $adminbanneradd = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
						<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
						<div id="adg-mail-cont">
						<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
						<div>
						<div class="adg-mail-title-wrap">
						<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear admin,</h2>
						</div>
						<div class="adg-mail-text-wrap">
						<p class="adg-mail-text">A new banner/ad was added: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Advertiser Name:</strong> {name} <br /> <strong class="adg-block">Company Name:</strong> {company} <br /> <strong class="adg-block">Email:</strong> {email} <br /> <strong class="adg-block">Phone:</strong> {phone} <br /> <strong class="adg-block">Banner Name::</strong> {banner} <br /> <strong class="adg-block">Banner Preview:</strong> {banner_preview_url} <br /> <br /> ---------------------------------------- <br /> <strong class="adg-block">Status:</strong>{approval_status} <br /> ---------------------------------------- <br /> </span> </span></p>
						<p class="adg-mail-text">To approve this ad, click on this URL or copy and paste it into your browser window: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">{approve_banner_url}</strong> </span> </span></p>
						<p class="adg-mail-text">To decline this ad, click on this URL or copy and paste it into your browser window: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">{decline_banner_url}</strong> </span> </span></p>
						</div>
						</div>
						</div>
						</div>
						</div>
						</div>';
        $admincampadd = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear admin,</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">A new campaign was added: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Advertiser Name:</strong> {name} <br /> <strong class="adg-block">Company Name:</strong> {company} <br /> <strong class="adg-block">Email:</strong> {email} <br /> <strong class="adg-block">Phone:</strong> {phone} <br /> <strong class="adg-block">Campaign Name:</strong> {campaign} <br /> <strong class="adg-block">Package name used to create this campaign::</strong> {package} <br /> <br /> ---------------------------------------- <br /> <strong class="adg-block">Status:</strong>{approval_status} <br /> ---------------------------------------- <br /> </span> </span></p>
					<p class="adg-mail-text">To approve this campaign, click on this URL or copy and paste it into your browser window: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">{approve_campaign_url} </strong> </span> </span></p>
					<p class="adg-mail-text">To decline this campaign, click on this URL or copy and paste it into your browser window: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">{decline_campaign_url}</strong> </span> </span></p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $adminadvreg = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear admin,</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">The following advertiser has signed up to your advertising program. <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">Full Name:</strong> {name} <br /> <strong class="adg-block">Email:</strong> {email} <br /> <strong class="adg-block">Phone:</strong> {phone} <br /> <strong class="adg-block">URL:</strong> {url} <br /> <strong class="adg-block">Username:</strong> {username} <br /> <strong class="adg-block">Company Name:</strong> {company} <br /> <strong class="adg-block">Description:</strong> {description} <br /> <strong class="adg-block">Street :</strong> {street} <br /> <strong class="adg-block">Country :</strong> {country} <br /> <strong class="adg-block">State/Province:</strong> {state} <br /> <strong class="adg-block">Zip Code:</strong> {zipcode} <br /> ---------------------------------------- <br /> <strong class="adg-block">Status:</strong> {approval_status} <br /> ---------------------------------------- <br /> </span> </span></p>
					<p class="adg-mail-text">To approve this advertiser, click on this URL or copy and paste it into your browser window: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">{approve_advertiser_url} </strong> </span> </span></p>
					<p class="adg-mail-text">To decline this advertiser, click on this URL or copy and paste it into your browser window: <span class="adg-mail-info" style="background: #E5F6FF; border-radius: 4px; border: 1px solid #A3E0FF; padding: 10px; display: block; margin-top: 10px;"><span style="display: block;"> <strong class="adg-block">{decline_advertiser_url}</strong> </span> </span></p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $admincampexp = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear admin,</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">Campaign {campaign} of company {company} has expired {expire_date}.</p>
					<p class="adg-mail-text">Admin</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        $admincampmod = '<div id="adg-mail-gwrap" style="background: #eee; padding: 20px 0;">
					<div id="adg-mail-wrap" style="width: 75%; position: relative; margin: auto;">
					<div id="adg-mail-cont">
					<div style="background: #fff; padding: 10px; border-radius: 4px; border: 1px solid #ccc;">
					<div>
					<div class="adg-mail-title-wrap">
					<h2 class="adg-mail-title" style="font-size: 22px; background: #444; margin: -11px -11px 0px -11px; border-radius: 4px 4px 0 0; padding: 15px 10px; lineheight: 40px; color: #fff;"><span style="background: #FFFFFF; border-radius: 3px; box-shadow: 0 0 1px #000000; font-size: 20px; margin-right: 10px; padding: 0 6px;"><img src="components/com_adagency/images/envelope.png" alt="ij" width="15px" height="auto" /></span> Dear admin,</h2>
					</div>
					<div class="adg-mail-text-wrap">
					<p class="adg-mail-text">The ad {banner} has been modified by {name}.</p>
					<p class="adg-mail-text">Ad status: {approval_status}</p>
					</div>
					</div>
					</div>
					</div>
					</div>
					</div>';
        if (@(!$textafterreg["0"])) {
            $no_setting_in_db = true;
            $config = new JConfig();
            $sql = "INSERT INTO `#__ad_agency_settings` (`id`, `lastsend`, `adminemail`, `fromemail`, `fromname`, `imgfolder`, `maxchars`, `captcha`, `allowstand`, `allowadcode`, `allowpopup`, `allowswf`, `allowtxtlink`, `allowtrans`, `allowfloat`, `txtafterreg`, `bodyafterreg`, `sbafterreg`, `bodyactivation`, `sbactivation`, `bodyrep`, `sbrep`, `bodycmpappv`, `sbcmpappv`, `bodycmpdis`, `sbcmpdis`, `bodyadappv`, `sbadappv`, `bodyaddisap`, `sbaddisap`, `bodyadvdis`, `sbadvdis`, `bodynewad`, `sbnewad`, `bodynewcmp`, `sbnewcmp`, `bodycmpex`, `sbcmpex`, `bodynewuser`, `sbnewuser`, `currencydef`, `indextbl`, `askterms`, `termsid`, `overviewcontent`, `showpreview`, `show`, `mandatory`, `params`, `sbafterregaa`, `bodyafterregaa`, `geoparams`, `sbcmpexpadm`, `bodycmpexpadm`, `sbadchanged`, `boadchanged`) VALUES\n\t(1, " . time() . ", '" . $config->mailfrom . "', '" . $config->mailfrom . "', 'Ad Agency', 'ad_agency', 250, 0, '1', '1', '1', '1', '1', '1', '1', '" . $txtafterreg . "', '" . $bdyafterreg . "', 'Thank you for registering at iJoomla Ad Agency', '" . $afterregneedsapp . "', 'Thank you for registering at iJoomla Ad Agency', '" . $reportemail . "', 'Subject Report', '" . $campapp . "', 'Campaign Approved', '" . $campdisapp . "', 'Campaign {campaign} has been suspended', '" . $bannerapp . "', '{banner}  Approved', '" . $bannerdisapp . "', 'Banner {banner} has been suspended', '" . $advdisapp . "', 'Your account on iJoomla Ad Agency has been suspended', '" . $adminbanneradd . "', '{name} has added a banner {banner}', '" . $admincampadd . "', '{name} has added a campaign {campaign}', '" . $campexp . "', 'Campaign {campaign} has expired', '" . $adminadvreg . "', '{name} has joined the Ad Agency', 'USD', 0, '0', 0, '<p>Welcome to our advertising opportunity page.</p><p>MySiteName is one of the most trafficked sites about MySiteTopic on the web. It gets well over X unique visitors a month and close to X pageviews.</p><p>How to get started</p><p>Step 1: <a href=\"index.php?option=com_adagency&amp;controller=adagencyAdvertisers&amp;task=register\">Register as an advertiser</a><br />Step 2: <a href=\"index.php?option=com_adagency&amp;controller=adagencyAds&amp;task=addbanners\">Add banners/ads</a><br />Step 3: <a href=\"index.php?option=com_adagency&amp;controller=adagencyCampaigns&amp;task=edit&amp;cid=0\">Start a campaign</a><br />Step 4: Get traffic to your site</p>\n\t<p>{packages}</p>', 0, 'zinfo;aftercamp2;wizzard;url;phone;', '', 'a:5:{s:11:\"click_limit\";s:2:\"10\";s:12:\"jquery_front\";s:1:\"0\";s:11:\"jquery_back\";s:1:\"0\";s:10:\"timeformat\";s:1:\"0\";s:8:\"jom_back\";s:1:\"1\";}', 'Thank you for registering to our advertising program', '" . $afterregaap . "', 'a:9:{s:14:\"allowcontinent\";s:1:\"1\";s:12:\"allowlatlong\";s:1:\"1\";s:12:\"allowcountry\";s:1:\"1\";s:2:\"c1\";s:1:\"1\";s:2:\"c2\";s:1:\"1\";s:2:\"c3\";s:1:\"1\";s:2:\"c4\";s:1:\"1\";s:2:\"c5\";s:1:\"1\";s:2:\"c6\";s:1:\"1\";}', 'Campaign {campaign} has expired', '" . $admincampexp . "', 'Ad {banner} has been modified by {name}', '" . $admincampmod . "');\n\t";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $database->query();
        }
        // Check for zones
        $sql = "SELECT * FROM #__ad_agency_zone";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $isZone = $database->loadColumn();
        $sql = "SELECT * FROM #__ad_agency_advertis";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $isAdvert = $database->loadColumn();
        $sql = "SELECT * FROM #__ad_agency_banners";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $isAd = $database->loadColumn();
        $sql = "SELECT * FROM #__ad_agency_campaign";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $isCamp = $database->loadColumn();
        if ($isZone == NULL && $isAdvert == NULL && $isAd == NULL && $isCamp == NULL && isset($no_setting_in_db)) {
            $sql = "SELECT id FROM #__users WHERE username = '******' ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $existingUID = $database->loadColumn();
            $existingUID = $existingUID["0"];
            $ok = true;
            if (!$existingUID) {
                // if the user doesn't exist then we create it
                $acl =& JFactory::getACL();
                jimport('joomla.application.component.helper');
                $usersParams =& JComponentHelper::getParams('com_users');
                $user = JFactory::getUser(0);
                $data = array();
                $usertype = 'Registered';
                $data['name'] = 'iJoomla';
                $data['username'] = '******';
                $data['email'] = '*****@*****.**';
                $data['gid'] = 18;
                $password = $this->random_password();
                $data['password'] = $password;
                $data['password2'] = $password;
                $data['sendEmail'] = 0;
                $data['block'] = 0;
                if (!$user->bind($data)) {
                    $ok = false;
                }
                if (!$user->save()) {
                    $ok = false;
                }
                $sql = "SELECT id FROM #__users WHERE username = '******' ";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $existingUID = $database->loadColumn();
                $existingUID = $existingUID["0"];
            }
            if ($existingUID) {
                $sql = "INSERT INTO `#__ad_agency_advertis` (`aid`, `user_id`, `company`, `description`, `website`, `address`, `country`, `city`, `state`, `zip`, `telephone`, `fax`, `logo`, `email_daily_report`, `email_weekly_report`, `email_month_report`, `email_campaign_expiration`, `approved`, `lastreport`, `weekreport`, `monthreport`, `paywith`, `apr_ads`, `apr_cmp`, `key`, `ordering`, `checked_out`) VALUES\n\t(2, " . $existingUID . ", '', NULL, 'http://ijoomla.com', NULL, NULL, NULL, NULL, NULL, '', '10', NULL, 'N', 'N', 'N', 'N', 'Y', 1373395233, 1373395233, 1373395233, '', 'G', 'G', NULL, 0, 0);\n\t";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
                // make default user registered
                $sql = "select count(*) from #__user_usergroup_map where `user_id`=" . intval($existingUID);
                $database->setQuery($sql);
                $database->query();
                $exist_map = $database->loadColumn();
                $exist_map = $exist_map["0"];
                if ($exist_map == 0) {
                    $sql = "INSERT INTO `#__user_usergroup_map` (`user_id` ,`group_id`) VALUES ('" . $existingUID . "', '2');";
                    $database->setQuery($sql);
                    $database->query();
                }
            }
            $sql = "SELECT id FROM #__users WHERE username = '******' ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $existingUID = $database->loadColumn();
            $existingUID = $existingUID["0"];
            $ok = true;
            if (!$existingUID) {
                // if the user doesn't exist then we create it
                $acl =& JFactory::getACL();
                jimport('joomla.application.component.helper');
                $usersParams =& JComponentHelper::getParams('com_users');
                $user = JFactory::getUser(0);
                $data = array();
                $usertype = 'Registered';
                $data['name'] = 'JomSocial';
                $data['username'] = '******';
                $data['email'] = '*****@*****.**';
                $data['gid'] = 18;
                $password = $this->random_password();
                $data['password'] = $password;
                $data['password2'] = $password;
                $data['sendEmail'] = 0;
                $data['block'] = 0;
                if (!$user->bind($data)) {
                    $ok = false;
                }
                if (!$user->save()) {
                    $ok = false;
                }
                $sql = "SELECT id FROM #__users WHERE username = '******' ";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $existingUID = $database->loadColumn();
                $existingUID = $existingUID["0"];
            }
            if ($existingUID) {
                $sql = "INSERT INTO `#__ad_agency_advertis` (`aid`, `user_id`, `company`, `description`, `website`, `address`, `country`, `city`, `state`, `zip`, `telephone`, `fax`, `logo`, `email_daily_report`, `email_weekly_report`, `email_month_report`, `email_campaign_expiration`, `approved`, `lastreport`, `weekreport`, `monthreport`, `paywith`, `apr_ads`, `apr_cmp`, `key`, `ordering`, `checked_out`) VALUES\n\t(1, " . $existingUID . ", '', NULL, 'http://jomsocial.com', NULL, NULL, NULL, NULL, NULL, '', '10', NULL, 'N', 'N', 'N', 'N', 'Y', 1373395050, 1373395050, 1373395050, '', 'G', 'G', '', 0, 0);\n\t";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
                // make default user registered
                $sql = "select count(*) from #__user_usergroup_map where `user_id`=" . intval($existingUID);
                $database->setQuery($sql);
                $database->query();
                $exist_map = $database->loadColumn();
                $exist_map = $exist_map["0"];
                if ($exist_map == 0) {
                    $sql = "INSERT INTO `#__user_usergroup_map` (`user_id` ,`group_id`) VALUES ('" . $existingUID . "', '2');";
                    $database->setQuery($sql);
                    $database->query();
                }
            }
            // Add the default advertiser if no advertiser - END
            // Add the default zones if there is no zone - BEGIN
            if ($ok) {
                $sql = "INSERT INTO `#__modules` (`title`, `note`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`, `language`)  VALUES  ('Zone - Banners', '', '', 0, 'position-7', 0, '0000-00-00 00:00:00', '2013-07-09 18:56:46', '0000-00-00 00:00:00', 1, 'mod_ijoomla_adagency_zone', 1, 1, '{\"moduleclass_sfx\":\"\",\"cache\":\"0\"}', 0, ''),\n('Zone - Text Ads', '', '', 0, 'position-7', 0, '0000-00-00 00:00:00', '2013-07-09 18:56:33', '0000-00-00 00:00:00', 1, 'mod_ijoomla_adagency_zone', 1, 1, '{\"moduleclass_sfx\":\"\",\"cache\":\"0\"}', 0, ''),\n('Floating, Transitions, Popups', '', '', 0, 'debug', 0, '0000-00-00 00:00:00', '2013-07-09 18:57:15', '0000-00-00 00:00:00', 1, 'mod_ijoomla_adagency_zone', 1, 0, '{\"moduleclass_sfx\":\"\",\"cache\":\"0\"}', 0, ''), ('Inventory Zone', '', '', 0, 'position-7', 0, '0000-00-00 00:00:00', '2013-07-09 18:59:37', '0000-00-00 00:00:00', 1, 'mod_ijoomla_adagency_zone', 1, 1, '{\"moduleclass_sfx\":\"\",\"cache\":\"0\"}', 0, '');";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                if (!$database->query()) {
                    $ok = false;
                }
            }
            $sql = "SELECT id FROM `#__modules` WHERE title = 'Zone - Banners' and module = 'mod_ijoomla_adagency_zone' ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $leftZoneId = $database->loadColumn();
            $leftZoneId = $leftZoneId["0"];
            if ($leftZoneId) {
                $sql = "INSERT INTO `#__ad_agency_zone` (`zoneid`, `banners`, `banners_cols`, `z_title`, `z_ordering`, `z_position`, `show_title`, `suffix`, `rotatebanners`, `rotating_time`, `rotaterandomize`, `show_adv_link`, `cellpadding`, `link_taketo`, `taketo_url`, `itemid`, `defaultad`, `keywords`, `adparams`, `ignorestyle`, `textadparams`, `zone_text_below`, `zone_content_location`, `zone_content_visibility`, `ordering`, `checked_out`, `inventory_zone`) VALUES (" . $leftZoneId . ", 1, 2, 'Zone - Banners', 0, 'position-7', 1, 'moduleclass_sfx=', '0', 10000, '1', 0, 1, 3, 'http://', 0, 0, 0, 'a:5:{s:8:\"standard\";s:1:\"1\";s:9:\"affiliate\";s:1:\"1\";s:5:\"flash\";s:1:\"1\";s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 'a:2:{s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 0, 0, 0, 0, 0)";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
                // Assign module to all pages
                $sql = "INSERT INTO `#__modules_menu` (`moduleid` ,`menuid`) VALUES ('" . $leftZoneId . "', '0');";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                if (!$database->query()) {
                    $ok = false;
                }
            }
            $sql = "SELECT id FROM `#__modules` WHERE title = 'Zone - Text Ads' and module = 'mod_ijoomla_adagency_zone' ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $rightZoneId = $database->loadColumn();
            $rightZoneId = $rightZoneId["0"];
            if ($rightZoneId) {
                $sql = "INSERT INTO `#__ad_agency_zone` (`zoneid`, `banners`, `banners_cols`, `z_title`, `z_ordering`, `z_position`, `show_title`, `suffix`, `rotatebanners`, `rotating_time`, `rotaterandomize`, `show_adv_link`, `cellpadding`, `link_taketo`, `taketo_url`, `itemid`, `defaultad`, `keywords`, `adparams`, `ignorestyle`, `textadparams`, `zone_text_below`, `zone_content_location`, `zone_content_visibility`, `ordering`, `checked_out`, `inventory_zone`) VALUES (" . $rightZoneId . ", 2, 1, 'Zone - Text Ads', 0, 'position-7', 1, 'moduleclass_sfx=', '0', 10000, '1', 1, 1, 3, 'http://', 0, 0, 0, 'a:3:{s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";s:6:\"textad\";s:1:\"1\";}', '', 'a:6:{s:6:\"mxsize\";s:2:\"50\";s:6:\"mxtype\";s:1:\"w\";s:2:\"ia\";s:1:\"l\";s:8:\"wrap_img\";s:1:\"1\";s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 0, 0, 0, 0, 0);\n\t";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
                // Assign module to all pages
                $sql = "INSERT INTO `#__modules_menu` (`moduleid` ,`menuid`) VALUES ('" . $rightZoneId . "', '0');";
                $database->setQuery($sql);
                if (!$database->query()) {
                    $ok = false;
                }
            }
            $sql = "SELECT id FROM `#__modules` WHERE title = 'Floating, Transitions, Popups' and module = 'mod_ijoomla_adagency_zone' ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $floatingZoneId = $database->loadColumn();
            $floatingZoneId = $floatingZoneId["0"];
            if ($floatingZoneId) {
                $sql = "INSERT INTO `#__ad_agency_zone` (`zoneid`, `banners`, `banners_cols`, `z_title`, `z_ordering`, `z_position`, `show_title`, `suffix`, `rotatebanners`, `rotating_time`, `rotaterandomize`, `show_adv_link`, `cellpadding`, `link_taketo`, `taketo_url`, `itemid`, `defaultad`, `keywords`, `adparams`, `ignorestyle`, `textadparams`, `zone_text_below`, `zone_content_location`, `zone_content_visibility`, `ordering`, `checked_out`, `inventory_zone`) VALUES (" . $floatingZoneId . ", 1, 1, 'Floating, Transitions, Popups', 0, 'debug', 0, 'moduleclass_sfx=', '0', 10000, '1', 0, 1, 3, 'http://', 0, 0, 0, 'a:5:{s:5:\"popup\";s:1:\"1\";s:10:\"transition\";s:1:\"1\";s:8:\"floating\";s:1:\"1\";s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 'a:2:{s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 0, 0, 0, 0, 0);";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
                // Assign module to all pages
                $sql = "INSERT INTO `#__modules_menu` (`moduleid` ,`menuid`) VALUES ('" . $floatingZoneId . "', '0');";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                if (!$database->query()) {
                    $ok = false;
                }
            }
            $sql = "SELECT id FROM `#__modules` WHERE title = 'Inventory Zone' and module = 'mod_ijoomla_adagency_zone' ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $inventoryZoneId = $database->loadColumn();
            $inventoryZoneId = $inventoryZoneId["0"];
            if ($inventoryZoneId) {
                $sql = "INSERT INTO `#__ad_agency_zone` (`zoneid`, `banners`, `banners_cols`, `z_title`, `z_ordering`, `z_position`, `show_title`, `suffix`, `rotatebanners`, `rotating_time`, `rotaterandomize`, `show_adv_link`, `cellpadding`, `link_taketo`, `taketo_url`, `itemid`, `defaultad`, `keywords`, `adparams`, `ignorestyle`, `textadparams`, `zone_text_below`, `zone_content_location`, `zone_content_visibility`, `ordering`, `checked_out`, `inventory_zone`) VALUES (" . $inventoryZoneId . ", 2, 2, 'Inventory Zone', 0, 'position-7', 1, '', '0', 10000, '1', 1, 1, 3, 'http://', 0, 0, 0, 'a:5:{s:8:\"standard\";s:1:\"1\";s:9:\"affiliate\";s:1:\"1\";s:5:\"flash\";s:1:\"1\";s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 'a:2:{s:5:\"width\";s:0:\"\";s:6:\"height\";s:0:\"\";}', '', 0, 0, 0, 0, 1);";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
                // Assign module to all pages
                $sql = "INSERT INTO `#__modules_menu` (`moduleid` ,`menuid`) VALUES ('" . $inventoryZoneId . "', '0');";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                if (!$database->query()) {
                    $ok = false;
                }
            }
            // Add the default zones if there is no zone - END
            // Add the default banners if there are none - BEGIN
            if ($leftZoneId && $rightZoneId && $floatingZoneId && $inventoryZoneId) {
                $sql = "INSERT INTO `#__ad_agency_banners` (`id`, `advertiser_id`, `title`, `description`, `media_type`, `image_url`, `swf_url`, `target_url`, `width`, `height`, `ad_code`, `use_ad_code_in_netscape`, `ad_code_netscape`, `parameters`, `approved`, `zone`, `frequency`, `created`, `ordering`, `keywords`, `key`, `channel_id`, `ad_start_date`, `ad_end_date`, `checked_out`) VALUES (1, 2, 'iJoomla SEO 120*240', '', 'Advanced', NULL, NULL, NULL, 120, 240, '<a href=\"ad_url\" target=\"_top\"><img src=\"http://ijoomla.com/affiliates/accounts/default1/banners/abbd7714.gif\" alt=\"SEO\" title=\"SEO\" width=\"120\" height=\"240\" /></a><img style=\"border:0\" src=\"http://www.ijoomla.com/affiliates/scripts/imp.php?a_aid=ijoomla&amp;a_bid=abbd7714\" width=\"1\" height=\"1\" alt=\"\" />', 'N', NULL, 'a:2:{s:13:\"target_window\";s:6:\"_blank\";s:9:\"linktrack\";s:55:\"http://seo.ijoomla.com?a_aid=ijoomla&amp;a_bid=abbd7714\";}', 'Y', 0, NULL, '2010-11-24', 3, '', '', -1, '1969-12-31 19:00:00', '0000-00-00 00:00:00', 0),\n(2, 2, 'iJoomla SEO', '', 'TextLink', '', NULL, 'http://seo.ijoomla.com/', '', '', NULL, 'N', NULL, 'a:22:{s:11:\"font_family\";s:0:\"\";s:9:\"font_size\";s:2:\"14\";s:11:\"title_color\";s:6:\"0066CC\";s:11:\"font_weight\";s:18:\"lighter underlined\";s:8:\"alt_text\";s:67:\"Become a search engine magnet with this amazing Joomla Extension ! \";s:10:\"alt_text_t\";s:11:\"iJoomla SEO\";s:10:\"alt_text_a\";s:13:\"Learn More >>\";s:13:\"font_family_b\";s:0:\"\";s:11:\"font_size_b\";s:2:\"12\";s:10:\"body_color\";s:6:\"000000\";s:13:\"font_weight_b\";s:6:\"normal\";s:13:\"font_family_a\";s:0:\"\";s:11:\"font_size_a\";s:2:\"12\";s:12:\"action_color\";s:6:\"0066CC\";s:13:\"font_weight_a\";s:18:\"lighter underlined\";s:6:\"border\";s:1:\"0\";s:7:\"padding\";s:1:\"0\";s:12:\"border_color\";s:6:\"000000\";s:8:\"bg_color\";s:6:\"FFFFFF\";s:5:\"align\";s:4:\"left\";s:13:\"target_window\";s:6:\"_blank\";s:7:\"img_alt\";s:24:\"http://seo2.ijoomla.com/\";}', 'Y', 0, NULL, '2010-11-24', 0, '', '', -1, '1969-12-31 19:00:00', '0000-00-00 00:00:00', 0),\n(3, 2, 'iJoomla Surveys 125*125', '', 'Advanced', NULL, NULL, NULL, 125, 125, '<a href=\"ad_url\" target=\"_top\"><img src=\"http://www.ijoomla.com/affiliates/accounts/default1/banners/fa5650ff.gif\" alt=\"Surveys\" title=\"Surveys\" width=\"125\" height=\"125\" /></a><img style=\"border:0\" src=\"http://www.ijoomla.com/affiliates/scripts/imp.php?a_aid=ijoomla&a_bid=fa5650ff\" width=\"1\" height=\"1\" alt=\"\" />                                                                                                                                ', 'N', NULL, 'a:2:{s:13:\"target_window\";s:6:\"_blank\";s:9:\"linktrack\";s:0:\"\";}', 'Y', 0, NULL, '2010-11-24', 2, '', '', -1, '1969-12-31 19:00:00', '0000-00-00 00:00:00', 0),\n(4, 2, 'Guru 125*125', '', 'Advanced', NULL, NULL, NULL, 125, 125, '<a href=\"ad_url\" target=\"_top\"><img src=\"http://ijoomla.com/affiliates/accounts/default1/banners/42945100.gif\" alt=\"\" title=\"\" width=\"125\" height=\"125\" /></a><img style=\"border:0\" src=\"http://www.ijoomla.com/affiliates/scripts/imp.php?a_aid=ijoomla&amp;a_bid=42945100\" width=\"1\" height=\"1\" alt=\"\" />', 'N', NULL, 'a:2:{s:13:\"target_window\";s:6:\"_blank\";s:9:\"linktrack\";s:56:\"http://guru.ijoomla.com?a_aid=ijoomla&amp;a_bid=42945100\";}', 'Y', 0, NULL, '2010-11-24', 1, '', '', -1, '1969-12-31 19:00:00', '0000-00-00 00:00:00', 0),\n(5, 1, 'JomSocial 250*250', '', 'Advanced', NULL, NULL, NULL, 250, 250, '                                                        <a href=\"ad_url\" target=\"_blank\"><img src=\"http://www.ijoomla.com/affiliates/accounts/default1/banners/957f42d0.png\" alt=\"Start a Social Network\" title=\"Start a Social Network\" width=\"200\" height=\"200\" /></a><img style=\"border:0\" src=\"http://www.ijoomla.com/affiliates/scripts/imp.php?a_aid=ijoomla&amp;a_bid=957f42d0\" width=\"1\" height=\"1\" alt=\"\" />', 'N', NULL, 'a:2:{s:13:\"target_window\";s:6:\"_blank\";s:9:\"linktrack\";s:58:\"http://www.jomsocial.com/?a_aid=ijoomla&amp;a_bid=957f42d0\";}', 'Y', 0, NULL, '2013-07-09', 4, '', '', NULL, '2013-07-09 00:00:00', '0000-00-00 00:00:00', 0),\n(6, 1, 'JomSocial 160*140', '', 'Advanced', NULL, NULL, NULL, 160, 140, '<a href=\"ad_url\" target=\"_blank\"><img src=\"http://www.ijoomla.com/affiliates/accounts/default1/banners/79b4a921.png\" alt=\"Start a Social Network\" title=\"Start a Social Network\" width=\"160\" height=\"140\" /></a><img style=\"border:0\" src=\"http://www.ijoomla.com/affiliates/scripts/imp.php?a_aid=ijoomla&amp;a_bid=79b4a921\" width=\"1\" height=\"1\" alt=\"\" />', 'N', NULL, 'a:2:{s:13:\"target_window\";s:6:\"_blank\";s:9:\"linktrack\";s:58:\"http://www.jomsocial.com/?a_aid=ijoomla&amp;a_bid=79b4a921\";}', 'Y', 0, NULL, '2013-07-09', 4, '', '', NULL, '2013-07-09 00:00:00', '0000-00-00 00:00:00', 0);\n\t";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                $database->query();
            }
            // Add the default banners if there are none - END
            // Add the default packages if there are none - BEGIN
            $sql = "INSERT INTO `#__ad_agency_order_type` (`tid`, `description`, `pack_description`, `quantity`, `type`, `cost`, `validity`, `sid`, `published`, `visibility`, `zones`, `zones_wildcard`, `ordering`, `hide_after`, `location`, `checked_out`) VALUES\n\t(1, '1000 Impressions', 'Try our advertising system with 1000 free impressions!', 1000, 'cpm', 0.00, '', 0, 1, 1, '', NULL, 3, 1, " . $leftZoneId . ", 0),\n\t(2, '1 Month Text Ads', 'One month of advertising your text ad on our site', 0, 'fr', 49.99, '1|day', 0, 1, 1, '', NULL, 2, 0, " . $leftZoneId . ", 0),\n\t(3, 'Internal Package ', 'This package is for internal use, it''s invisible on front end. Use it to display your own banners.', 0, 'fr', 0.00, '10|year', 0, 1, 0, '', NULL, 1, 0, " . $rightZoneId . ", 0),\n\t(4, '100 Clicks', 'This package will get you 100 clicks of your banners.', 100, 'pc', 99.99, '', 0, 1, 1, '', NULL, 4, 0, " . $leftZoneId . ", 0),\n\t(6, 'Inventory Package', 'This package has a limit on how many times it can be purchased for a time period.', 0, 'in', 99.00, '1|month', 0, 1, 1, '', NULL, 0, 0, 0, 0);";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            if (!$database->query()) {
                $ok = false;
            }
            // Add the default packages if there are none - END
            // Add the default campaign if there is none - BEGIN
            $sql = "INSERT INTO `#__ad_agency_campaign` (`id`, `aid`, `name`, `notes`, `default`, `start_date`, `type`, `quantity`, `validity`, `cost`, `otid`, `approved`, `status`, `exp_notice`, `key`, `params`, `renewcmp`, `activities`, `ordering`, `checked_out`) VALUES (3, 2, 'iJoomla Campaign', '', 'Y', '2013-07-09 19:06:28', 'fr', 0, '2023-07-09 19:06:28', 0.00, 3, 'Y', 1, 0, NULL, 'a:1:{s:6:\"adslim\";i:999;}', 0, '', 0, 0),\n(4, 1, 'JomSocial Campaign', '', 'Y', '2013-07-09 19:07:11', 'fr', 0, '2023-07-09 19:07:11', 0.00, 3, 'Y', 1, 0, NULL, 'a:1:{s:6:\"adslim\";i:999;}', 0, '', 0, 0); ";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            if (!$database->query()) {
                $ok = false;
            }
            // Set banners to campaigns - BEGIN
            if ($ok) {
                $sql = "INSERT INTO `#__ad_agency_campaign_banner` (`campaign_id`, `banner_id`, `relative_weighting`, `thumb`, `zone`) VALUES\n\t\t\t\t\t\t(3, 3, 100, NULL, " . intval($leftZoneId) . "),\n\t\t\t\t\t\t(3, 4, 100, NULL, " . intval($leftZoneId) . "),\n\t\t\t\t\t\t(3, 1, 100, NULL, " . intval($leftZoneId) . "),\n\t\t\t\t\t\t(3, 2, 100, NULL, " . intval($rightZoneId) . "),\n\t\t\t\t\t\t(4, 5, 100, NULL, " . intval($leftZoneId) . ");\n\t\t\t\t\t\t";
                $sqlz[] = $sql;
                $database->setQuery($sql);
                if (!$database->query()) {
                    $ok = false;
                }
            }
            // Set banners to campaigns - END
            // Add the default campaign if there is none - END
            // Update to 2.0.3
            $sql = "INSERT INTO `#__ad_agency_package_zone` (`package_id`, `zone_id`) VALUES\n\t\t\t\t\t(1, " . intval($leftZoneId) . "),\n\t\t\t\t\t(2, " . intval($rightZoneId) . "),\n\t\t\t\t\t(3, " . intval($leftZoneId) . "),\n\t\t\t\t\t(3, " . intval($rightZoneId) . "),\n\t\t\t\t\t(3, " . intval($floatingZoneId) . "),\n\t\t\t\t\t(4, " . intval($leftZoneId) . "),\n\t\t\t\t\t(5, " . intval($leftZoneId) . "),\n\t\t\t\t\t(6, " . intval($inventoryZoneId) . ");";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $db->query();
            // - end update 2.0.3
        }
        $sql = "SELECT aid,user_id FROM #__ad_agency_advertis ORDER BY aid ASC LIMIT 1";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $first_adv = $database->loadObject();
        $sql = "SELECT * FROM `#__ad_agency_channels` ORDER BY id DESC LIMIT 1";
        $sqlz[] = $sql;
        $database->setQuery($sql);
        $new_channels = $database->loadColumn();
        // Add channels - BEGIN
        if (!$new_channels && isset($first_adv) && $first_adv != NULL) {
            $sql = "INSERT INTO `#__ad_agency_channels` (`id`, `name`, `banner_id`, `advertiser_id`, `public`, `created`, `created_by`, `from`) VALUES\n\t\t\t(1, 'United States', 0, '" . $first_adv->aid . "', 'Y', '2010-11-26 00:00:00', " . $first_adv->user_id . ", 'B'),\n\t\t\t(2, 'Europe', 0, '" . $first_adv->aid . "', 'Y', '2010-11-26 00:00:00', " . $first_adv->user_id . ", 'B'),\n\t\t\t(3, 'California', 0, '" . $first_adv->aid . "', 'Y', '2010-11-26 00:00:00', " . $first_adv->user_id . ", 'B'),\n\t\t\t(4, 'San Diego and Los Angeles', 0, '" . $first_adv->aid . "', 'Y', '2010-11-26 00:00:00', " . $first_adv->user_id . ", 'B'),\n\t\t\t(5, 'Beverly Hills', 0, '" . $first_adv->aid . "', 'Y', '2010-11-26 00:00:00', " . $first_adv->user_id . ", 'B'),\n\t\t\t(6, 'Germany', 0, '" . $first_adv->aid . "', 'Y', '2010-11-26 00:00:00', " . $first_adv->user_id . ", 'B');";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $database->query();
            $sql = "INSERT INTO `#__ad_agency_channel_set` (`id`, `channel_id`, `type`, `logical`, `option`, `data`) VALUES\n\t\t\t(1, 1, 'country', 'AND', 'is', '[\"US\"]'),\n\t\t\t(2, 2, 'continent', 'AND', 'is', '[\"EU\"]'),\n\t\t\t(3, 3, 'region', 'AND', 'is', '[\"US\",\"CA\"]'),\n\t\t\t(4, 4, 'dma', 'AND', '==', '[\"825\",\"803\"]'),\n\t\t\t(5, 5, 'postalcode', 'AND', '==', '[\"90210\"]'),\n\t\t\t(6, 6, 'country', 'AND', 'is', '[\"DE\"]');";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $database->query();
            $sql = "ALTER TABLE `#__ad_agency_settings` CHANGE `countryloc` `countryloc` VARCHAR( 150 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT 'geoip/countries'";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $database->query();
            $sql = "UPDATE `#__ad_agency_settings` SET `countryloc` = 'geoip/countries'";
            $sqlz[] = $sql;
            $database->setQuery($sql);
            $database->query();
        }
        // Add channels - END
        // v.1.6.7 updates - END
        jimport('joomla.filesystem.archive');
        // Insert Itemid part
        if (!isset($db)) {
            $db =& JFactory::getDBO();
        }
        $sql = "SELECT id FROM #__menu_types WHERE `menutype` = 'adagency' ";
        $sqlz[] = $sql;
        $db->setQuery($sql);
        $res = $db->loadColumn();
        $sql = "SELECT extension_id FROM #__extensions WHERE `element` = 'com_adagency' ";
        $sqlz[] = $sql;
        $db->setQuery($sql);
        $componentid = $db->loadColumn();
        $componentid = $componentid["0"];
        if (!$componentid) {
            $sql = "SELECT extension_id FROM #__extensions ORDER BY extension_id DESC LIMIT 1";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $componentid = $db->loadColumn();
            $componentid = $componentid["0"]++;
        }
        if ($res == NULL) {
            $sql = "INSERT INTO `#__menu_types` (`menutype`, `title`, `description`) VALUES ('adagency', 'Ad Agency', 'Ad Agency Advertiser Menu');";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $db->query();
        }
        $sql = "select count(*) from #__menu where `link`='index.php?option=com_adagency&view=adagencycpanel'";
        $db->setQuery($sql);
        $db->query();
        $count_menu = $db->loadColumn();
        $count_menu = $count_menu["0"];
        if ($count_menu == "0") {
            $sql = "INSERT INTO `#__menu` (`menutype`, `title`, `alias`, `note`, `path`, `link`, `type`, `published`, `parent_id`, `level`, `component_id`, `checked_out`, `checked_out_time`, `browserNav`, `access`, `img`, `template_style_id`, `params`, `lft`, `rgt`, `home`, `language`, `client_id`) VALUES\n\t( 'adagency', 'Control Panel', 'my-adagency-control-panel', '', 'adagency-cpanel', 'index.php?option=com_adagency&view=adagencycpanel', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'My profile', 'my-advertising-profile', '', 'adagency-profile', 'index.php?option=com_adagency&view=adagencyadvertisers&layout=editform', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'Ads', 'my-adagency-ads', '', 'adagency-ads', 'index.php?option=com_adagency&view=adagencyads', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'Campaigns', 'my-adagency-campaigns', '', 'adagency-campaigns', 'index.php?option=com_adagency&view=adagencycampaigns', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'Reports', 'my-adagency-reports', '', 'adagency-reports', 'index.php?option=com_adagency&view=adagencyreports', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'Packages', 'my-adagency-packages', '', 'adagency-packages', 'index.php?option=com_adagency&view=adagencypackage', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'My Orders', 'my-adagency-orders', '', 'adagency-orders', 'index.php?option=com_adagency&view=adagencyorders', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0),\n\t( 'adagency', 'Overview', 'my-adagency-overview', '', 'adagency-overview', 'index.php?option=com_adagency&view=adagencyadvertisers&layout=overview', 'component', 1, 1, 1, " . $componentid . ", 0, '0000-00-00 00:00:00', 0, 1, '', 0, '{\"menu-anchor_title\":\"\",\"menu-anchor_css\":\"\",\"menu_image\":\"\",\"menu_text\":1,\"page_title\":\"\",\"show_page_heading\":0,\"page_heading\":\"\",\"pageclass_sfx\":\"\",\"menu-meta_description\":\"\",\"menu-meta_keywords\":\"\",\"robots\":\"\",\"secure\":0}', 0, 1, 0, '*', 0)";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $db->query();
            $sql = "INSERT INTO `#__modules` (`title`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `published`, `module`, `access`, `showtitle`, `params`, `client_id`) VALUES\n\t\t\t('Ad Agency', '', 2, 'left', 0, '0000-00-00 00:00:00', 0, 'mod_mainmenu', 0, 1, 'menutype=adagency\nmenu_style=list\nstartLevel=0\nendLevel=0\nshowAllChildren=0\nwindow_open=\nshow_whitespace=0\ncache=1\ntag_id=\nclass_sfx=\nmoduleclass_sfx=_menu\nmaxdepth=10\nmenu_images=0\nmenu_images_align=0\nmenu_images_link=0\nexpand_menu=0\nactivate_parent=0\nfull_active_id=0\nindent_image=0\nindent_image1=\nindent_image2=\nindent_image3=\nindent_image4=\nindent_image5=\nindent_image6=\nspacer=\nend_spacer=\n\n', 0);";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $db->query();
            $sql = "SELECT id FROM `#__modules` ORDER BY id DESC LIMIT 1";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $module_id_adagency = $db->loadColumn();
            $sql = "INSERT INTO `#__modules_menu` (`moduleid` ,`menuid`) VALUES ('" . $module_id_adagency["0"] . "', '0');";
            $sqlz[] = $sql;
            $db->setQuery($sql);
            $db->query();
        }
        $sql = "UPDATE `#__menu` SET `component_id` = '" . $componentid . "', `parent_id` = '1', `level` = '1', `access` = '1' WHERE `menutype` = 'adagency' ";
        $db->setQuery($sql);
        $db->query();
        $sql = "UPDATE `#__modules` SET `module` = 'mod_menu' WHERE `title` = 'Ad Agency' ";
        $db->setQuery($sql);
        $db->query();
        // *********** END ITEMID PART ********************
        $this->add_plugins();
        $this->add_currencies();
        $this->add_countries();
    }
Esempio n. 8
0
 function store()
 {
     jimport('joomla.filesystem.folder');
     $item = $this->getTable('adagencyConfig');
     $imagepath = str_replace("/administrator", "", JPATH_BASE);
     $imagepath = $imagepath . "/images/stories/";
     $data = JRequest::get('post');
     $newimgfolder = $data['imgfolder'];
     $full_path = JFolder::makeSafe($imagepath . $newimgfolder);
     if (!JFolder::exists($full_path)) {
         JFolder::create($full_path);
         // mkdir ( $imagepath . $newimgfolder );
     }
     if (JPath::canChmod($full_path)) {
         JPath::setPermissions($full_path);
     }
     $data['payment'] = @serialize($data['payment']);
     $show = '';
     $mandatory = '';
     $database = JFactory::getDBO();
     if (isset($data['show'])) {
         foreach ($data['show'] as $key => $value) {
             if ($value == 1) {
                 $show .= $key . ';';
             }
         }
     }
     if (isset($data['mandatory'])) {
         foreach ($data['mandatory'] as $key => $value) {
             if ($value == 1) {
                 $mandatory .= $key . ';';
             }
         }
     }
     $data['params'] = @serialize($data['params']);
     $data['show'] = $show;
     $data['mandatory'] = $mandatory;
     $data['txtafterreg'] = JRequest::getVar("txtafterreg", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyafterreg'] = JRequest::getVar("bodyafterreg", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyafterregaa'] = JRequest::getVar("bodyafterregaa", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyactivation'] = JRequest::getVar("bodyactivation", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyrep'] = JRequest::getVar("bodyrep", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodycmpappv'] = JRequest::getVar("bodycmpappv", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodycmpdis'] = JRequest::getVar("bodycmpdis", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyadappv'] = JRequest::getVar("bodyadappv", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyaddisap'] = JRequest::getVar("bodyaddisap", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodyadvdis'] = JRequest::getVar("bodyadvdis", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodynewad'] = JRequest::getVar("bodynewad", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodynewcmp'] = JRequest::getVar("bodynewcmp", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodycmpex'] = JRequest::getVar("bodycmpex", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodynewuser'] = JRequest::getVar("bodynewuser", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['overviewcontent'] = JRequest::getVar("overviewcontent", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['sbcmpexpadm'] = JRequest::getVar("sbcmpexpadm", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['bodycmpexpadm'] = JRequest::getVar("bodycmpexpadm", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['forcehttps'] = JRequest::getVar("forcehttps", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['sbadchanged'] = JRequest::getVar("sbadchanged", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['boadchanged'] = JRequest::getVar("boadchanged", "", "post", "string", JREQUEST_ALLOWHTML);
     $data['txtafterreg'] = fk_slashes($data['txtafterreg']);
     $data['bodyafterreg'] = fk_slashes($data['bodyafterreg']);
     $data['bodyafterregaa'] = fk_slashes($data['bodyafterregaa']);
     $data['bodyactivation'] = fk_slashes($data['bodyactivation']);
     $data['bodyrep'] = fk_slashes($data['bodyrep']);
     $data['bodycmpappv'] = fk_slashes($data['bodycmpappv']);
     $data['bodycmpdis'] = fk_slashes($data['bodycmpdis']);
     $data['bodyadappv'] = fk_slashes($data['bodyadappv']);
     $data['bodyaddisap'] = fk_slashes($data['bodyaddisap']);
     $data['bodyadvdis'] = fk_slashes($data['bodyadvdis']);
     $data['bodynewad'] = fk_slashes($data['bodynewad']);
     $data['bodynewcmp'] = fk_slashes($data['bodynewcmp']);
     $data['bodycmpex'] = fk_slashes($data['bodycmpex']);
     $data['bodynewuser'] = fk_slashes($data['bodynewuser']);
     $data['overviewcontent'] = fk_slashes($data['overviewcontent']);
     $data['sbcmpexpadm'] = fk_slashes($data['sbcmpexpadm']);
     $data['bodycmpexpadm'] = fk_slashes($data['bodycmpexpadm']);
     $data['txtafterreg'] = $this->addFullUrl($data['txtafterreg']);
     $data['bodyafterreg'] = $this->addFullUrl($data['bodyafterreg']);
     $data['bodyafterregaa'] = $this->addFullUrl($data['bodyafterregaa']);
     $data['bodyactivation'] = $this->addFullUrl($data['bodyactivation']);
     $data['bodyrep'] = $this->addFullUrl($data['bodyrep']);
     $data['bodycmpappv'] = $this->addFullUrl($data['bodycmpappv']);
     $data['bodycmpdis'] = $this->addFullUrl($data['bodycmpdis']);
     $data['bodyadappv'] = $this->addFullUrl($data['bodyadappv']);
     $data['bodyaddisap'] = $this->addFullUrl($data['bodyaddisap']);
     $data['bodyadvdis'] = $this->addFullUrl($data['bodyadvdis']);
     $data['bodynewad'] = $this->addFullUrl($data['bodynewad']);
     $data['bodynewcmp'] = $this->addFullUrl($data['bodynewcmp']);
     $data['bodycmpex'] = $this->addFullUrl($data['bodycmpex']);
     $data['bodynewuser'] = $this->addFullUrl($data['bodynewuser']);
     $data['overviewcontent'] = $this->addFullUrl($data['overviewcontent']);
     $data['sbcmpexpadm'] = $this->addFullUrl($data['sbcmpexpadm']);
     $data['bodycmpexpadm'] = $this->addFullUrl($data['bodycmpexpadm']);
     /* Pictures in Emails */
     $data['txtafterreg'] = $this->fixIMG($data['txtafterreg']);
     $data['bodyafterreg'] = $this->fixIMG($data['bodyafterreg']);
     $data['bodyafterregaa'] = $this->fixIMG($data['bodyafterregaa']);
     $data['bodyactivation'] = $this->fixIMG($data['bodyactivation']);
     $data['bodyrep'] = $this->fixIMG($data['bodyrep']);
     $data['bodycmpappv'] = $this->fixIMG($data['bodycmpappv']);
     $data['bodycmpdis'] = $this->fixIMG($data['bodycmpdis']);
     $data['bodyadappv'] = $this->fixIMG($data['bodyadappv']);
     $data['bodyaddisap'] = $this->fixIMG($data['bodyaddisap']);
     $data['bodyadvdis'] = $this->fixIMG($data['bodyadvdis']);
     $data['bodynewad'] = $this->fixIMG($data['bodynewad']);
     $data['bodynewcmp'] = $this->fixIMG($data['bodynewcmp']);
     $data['bodycmpex'] = $this->fixIMG($data['bodycmpex']);
     $data['bodynewuser'] = $this->fixIMG($data['bodynewuser']);
     $data['overviewcontent'] = $this->fixIMG($data['overviewcontent']);
     $data['sbcmpexpadm'] = $this->fixIMG($data['sbcmpexpadm']);
     $data['bodycmpexpadm'] = $this->fixIMG($data['bodycmpexpadm']);
     if (isset($_POST['jomfields']) && is_array($_POST['jomfields'])) {
         $data['jomfields'] = json_encode($_POST['jomfields']);
     } else {
         $data['jomfields'] = '';
     }
     if (!$item->bind($data)) {
         return JError::raiseError(500, $database->getErrorMsg());
         return false;
     }
     if (!$item->check()) {
         return JError::raiseError(500, $database->getErrorMsg());
         return false;
     }
     if (!$item->store()) {
         return JError::raiseError(500, $database->getErrorMsg());
         return false;
     }
     /*Salvam PLUGIN*/
     $plugin_handler = adagencyAdminModeladagencyConfig::makePluginList();
     if (count($plugin_handler) > 0) {
         foreach ($plugin_handler as $name => $plugin) {
             $name = $plugin->name;
             $value = JRequest::getVar($name . "_account", array(0), 'array');
             $value = implode(" ", $value);
             $default = JRequest::getVar("default", null, 'post');
             $sandbox = JRequest::getVar($name . "_sandbox", 0, 'post');
             $reqhttps = JRequest::getVar($name . "_reqhttps", 0, 'post');
             $default = substr($default, 0, strlen($default) - 4);
             $value = $database->escape($value);
             if ($plugin->type == 'encoding' && file_exists($value)) {
                 $query = "update #__ad_agency_plugins set value='{$value}', sandbox='{$sandbox}' where name='{$name}';";
             } else {
                 if ($plugin->type != 'encoding') {
                     $query = "update #__ad_agency_plugins set value='{$value}', sandbox='{$sandbox}', reqhttps='{$reqhttps}' where name='{$name}';";
                 } else {
                     $query = '';
                 }
             }
             $database->setQuery($query);
             $database->query();
             $query = "update #__ad_agency_plugins set def='' where def='default';";
             $database->setQuery($query);
             $database->query();
             $query = "update #__ad_agency_plugins set def='default' where name='" . stripslashes($default) . "';";
             $database->setQuery($query);
             $database->query();
         }
     }
     if (isset($data['aa'])) {
         foreach ($data['aa'] as $key => $value) {
             $query = "";
             if ($key == "campaign_2") {
                 $query = "ALTER TABLE `#__ad_agency_campaign` CHANGE `renewcmp` `renewcmp` INT( 3 ) NOT NULL default " . $value;
             } else {
                 $query = "ALTER TABLE `#__ad_agency_" . $key . "` CHANGE `approved` `approved` ENUM( 'Y', 'N', 'P' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT '" . $value . "'";
             }
             $database->setQuery($query);
             $database->query();
         }
         $allow_add_keywords = JRequest::getVar("allow_add_keywords", "0");
         $sql = "UPDATE `#__ad_agency_settings` SET `allow_add_keywords` = '" . intval($allow_add_keywords) . "' WHERE `id`=1";
         $database->setQuery($sql);
         $database->query();
     }
     return true;
 }
Esempio n. 9
0
 /**
  * Method to check if the permissions of Phpthumb cache folder
  *
  * @access public
  * @return	boolean	True on success
  */
 function getCacheThumbChmod()
 {
     static $return;
     if ($return === null) {
         jimport('joomla.filesystem.folder');
         jimport('joomla.filesystem.jpath');
         $phpthumbcache = JPath::clean(JPATH_SITE . DS . 'components' . DS . 'com_flexicontent' . DS . 'librairies' . DS . 'phpthumb' . DS . 'cache');
         // CHECK phpThumb cache exists and create the folder
         if (!JFolder::exists($phpthumbcache) && !JFolder::create($phpthumbcache)) {
             JError::raiseWarning(100, 'Error: Unable to create phpThumb folder: ' . $phpthumbcache . ' image thumbnail will not work properly');
             return true;
             // Cancel task !! to allow user to continue
         }
         // CHECK phpThumb cache permissions
         $return = preg_match('/rwxr.xr.x/i', JPath::getPermissions($phpthumbcache)) ? true : false;
         // If permissions not good check if we can change them
         if (!$return && !JPath::canChmod($phpthumbcache)) {
             JError::raiseWarning(100, 'Error: Unable to change phpThumb folder permissions: ' . $phpthumbcache . ' there maybe a wrong owner of the folder. Correct permissions are important for proper thumbnails and for -security-');
             return true;
             // Cancel task !! to allow user to continue
         }
     }
     return $return;
 }
Esempio n. 10
0
    function install($parent)
    {
        $version = $parent->get("manifest")->version;
        $mainframe = JFactory::getApplication();
        $db = JFactory::getDBO();
        $query = "SELECT count(1) FROM #__modules" . " WHERE position IN ( '" . implode("', '", $this->positions) . "' )";
        $db->setQuery($query);
        $count = $db->loadResult();
        if ($count) {
            $this->uninstall($parent);
        }
        jimport('joomla.filesystem.folder');
        $src = 'components' . DS . 'com_arkeditor' . DS . 'modules' . DS;
        $dest = 'modules' . DS;
        foreach ($this->modules as $module) {
            if (!JFolder::copy($src . $module, $dest . $module, JPATH_ADMINISTRATOR, true)) {
                $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', $module . ' module!'));
            }
        }
        /*===========================================================> */
        /*==============================================> LEFT MODULES */
        /*===========================================================> */
        $row = JTable::getInstance('module');
        $row->module = '';
        $row->position = 'ark_icon';
        $row->published = 1;
        $row->showtitle = 1;
        $row->access = 1;
        $row->client_id = 1;
        $row->params = '{}';
        /*$row->id 		= 0;
        		$row->title 	= 'Dashboard';
        		$row->module 	= 'mod_arkquickicon';
        		$row->ordering = $row->getNextOrder( "position='ark_icon'" );
        		if (!$row->store()) {
        			$mainframe->enqueueMessage( JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL','Control Panel icon Module data!') );
        		}*/
        $row->id = 0;
        $row->title = 'Statistics';
        $row->module = 'mod_arkstats';
        $row->params = '{"moduleclass_sfx":"box-arkstats","icon":"bars"}';
        $row->ordering = $row->getNextOrder("position='ark_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', 'Statistical Module data!'));
        }
        $row->id = 0;
        $row->title = 'Spread The Love';
        $row->module = 'mod_arkvote';
        $row->params = '{"moduleclass_sfx":"box-arkvote","icon":"heart-2"}';
        $row->ordering = $row->getNextOrder("position='ark_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', 'Vote Module data!'));
        }
        $row->id = 0;
        $row->title = 'Update Available';
        $row->module = 'mod_arkupdate';
        $row->params = '{"moduleclass_sfx":"box-arkupdate","icon":"loop"}';
        $row->ordering = $row->getNextOrder("position='ark_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', 'Update Module data!'));
        }
        /*===========================================================> */
        /*=============================================> RIGHT MODULES */
        /*===========================================================> */
        $row = JTable::getInstance('module');
        $row->module = '';
        $row->position = 'ark_cpanel';
        $row->published = 1;
        $row->showtitle = 1;
        $row->access = 1;
        $row->client_id = 1;
        $row->params = '{}';
        $row->id = 0;
        $row->title = 'Ark Editor v' . $version;
        $row->module = 'mod_custom';
        $row->params = '{"moduleclass_sfx":"box-arkinfo","icon":"info-circle"}';
        $row->content = '<table class="table table-striped">
			<tr>
				<td rowspan="6"><img src="components/com_arkeditor/icons/ark-editor-logo-lg.png" alt="Logo"></td>
			</tr>
			<tr>
				<td>Version:</td>
				<td>' . $version . '</td>
			</tr>
			<tr>
				<td>Author:</td>
				<td><a href="http://www.arkextensions.com" target="_blank">www.arkextensions.com</a></td>
			</tr>
			<tr>
				<td>Copyright:</td>
				<td>&copy; WebxSolution Ltd, All rights reserved.</td>
			</tr>
			<tr>
				<td>License:</td>
				<td>GPLv2.0</td>
			</tr>
			<tr>
				<td>More info:</td>
				<td><a href="http://arkextensions.com/terms-of-use" target="_blank">http://arkextensions.com/terms-of-use</a></td>
			</tr>
		</table>';
        $row->ordering = $row->getNextOrder("position='ark_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', 'Ark Editor custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'Tip of the Day';
        $row->module = 'mod_arktip';
        $row->params = '{"moduleclass_sfx":"box-arktip","icon":"info-circle"}';
        $row->ordering = $row->getNextOrder("position='ark_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', 'Tip of the day data!'));
        }
        $row->id = 0;
        $row->title = 'GO PRO!';
        $row->module = 'mod_arkpro';
        $row->params = '{"moduleclass_sfx":"box-arkpro","icon":"lightning"}';
        $row->ordering = $row->getNextOrder("position='ark_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL', 'Pro Module data!'));
        }
        /*===========================================================> */
        /*============================================> FOOTER MODULES */
        /*===========================================================> */
        $row = JTable::getInstance('module');
        $row->module = '';
        $row->position = 'ark_footer';
        $row->published = 1;
        $row->showtitle = 1;
        $row->access = 1;
        $row->client_id = 1;
        $row->params = '{}';
        /*$row->id 		= 0;
        		$row->title 	= 'Dashboard';
        		$row->module 	= 'mod_arkquickicon';
        		$row->ordering = $row->getNextOrder( "position='ark_footer'" );
        		if (!$row->store()) {
        			$mainframe->enqueueMessage( JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL','Control Panel icon Module data!') );
        		}*/
        jimport('joomla.filesystem.file');
        //Check System requirements for the editor
        define('ARKEDITOR_BASE', JPATH_CONFIGURATION . DS . 'plugins' . DS . 'editors' . DS . 'arkeditor/ckeditor');
        if (!JFolder::exists(ARKEDITOR_BASE)) {
            $mainframe->enqueueMessage(JText::_('COM_ARKEDITOR_CUSTOM_INSTALL_SYSTEM_DETECTED_EDITOR_NOT_INSTALLED'));
            return;
        }
        $perms = fileperms(JPATH_CONFIGURATION . DS . 'index.php');
        $perms = decoct($perms & 0777);
        $default_fperms = '0644';
        $default_dperms = '0755';
        if ($perms == 777 || $perms == 666) {
            $default_fperms = '0666';
            $default_dperms = '0777';
        }
        $fperms = ARKEDITOR_BASE . DS . 'config.js';
        if (!stristr(PHP_OS, 'WIN') && JPath::canChmod(ARKEDITOR_BASE) && $perms != decoct(fileperms($fperms) & 0777)) {
            $path = ARKEDITOR_BASE . DS . 'plugins';
            if (!JPath::setPermissions($path, $default_fperms, $default_dperms)) {
                $mainframe->enqueueMessage(JText::_('COM_ARKEDITOR_CUSTOM_INSTALL_SYSTEM_DETECTED_INCORRECT_FILE_PERMISSONS_FOR_EDITOR'));
            }
        }
        //for upgrade
        $query = 'SELECT p.name FROM `#__ark_editor_plugins` p WHERE p.iscore = 0';
        $db->setQuery($query);
        $results = $db->loadObjectList();
        if (!empty($results)) {
            for ($i = 0; $i < count($results); $i++) {
                if (JFolder::exists(JPATH_PLUGINS . DS . 'editors' . DS . 'arkeditor' . DS . 'plugins' . DS . $results[$i]->name) && !JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_arkeditor' . DS . 'editor' . DS . 'plugins' . DS . $results[$i]->name)) {
                    $src = JPATH_PLUGINS . DS . 'editors' . DS . 'arkeditor' . DS . 'plugins' . DS . $results[$i]->name;
                    $dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_arkeditor' . DS . 'editor' . DS . 'plugins' . DS . $results[$i]->name;
                    if (!JFolder::copy($src, $dest)) {
                        $mainframe->enqueueMessage(JText::sprintf('COM_ARKEDITOR_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', 'base plugin .' . $results[$i]->name . ' to ARK backup folder!'));
                    }
                }
            }
            //end for loop
        }
        //fix remove component install file from the editor's folder
        $file = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_arkeditor' . DS . 'editor' . DS . 'com_arkeditor.xml';
        if (JFile::exists($file)) {
            JFile::delete($file);
        }
    }
Esempio n. 11
0
         mkdir($mosConfig_absolute_path . '/images/jtips');
     }
 } else {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.path');
     if (!JFolder::exists($mosConfig_absolute_path . '/images/jtips')) {
         JFolder::create($mosConfig_absolute_path . '/images/jtips');
     }
     //create empty img files and make writeable
     JFile::write($mosConfig_absolute_path . '/images/jtips/' . $filename_100, '');
     if (JPath::canChmod($mosConfig_absolute_path . '/images/jtips/' . $filename_100)) {
         JPath::setPermissions($mosConfig_absolute_path . '/images/jtips/' . $filename_100, 666);
     }
     JFile::write($mosConfig_absolute_path . '/images/jtips/' . $filename_25, '');
     if (JPath::canChmod($mosConfig_absolute_path . '/images/jtips/' . $filename_25)) {
         JPath::setPermissions($mosConfig_absolute_path . '/images/jtips/' . $filename_25, 666);
     }
 }
 /**
  * This is the only part that requires actual apache access to the images directory
  * Difficult to resize an image if apache cannot write the image anywhere
  */
 $ti = new ThumbnailImage();
 $ti->src_file = $_FILES['logo']['tmp_name'];
 $ti->dest_type = THUMB_JPEG;
 $ti->dest_file = $mosConfig_absolute_path . '/images/jtips/' . $filename_100;
 $ti->max_width = 100;
 $ti->max_height = 100;
 $ti->Output();
 $ti = null;
Esempio n. 12
0
 function make_user_dir($base_dir)
 {
     if (!is_dir($base_dir)) {
         if (!JFolder::create($base_dir, 0755)) {
             JError::raiseWarning('SOME_ERROR_CODE', 'JFolder::create: ' . JText::_('KISS_GENERAL_ERROR_DIRNOTCREATED'), 'Path: ' . $base_dir);
         } else {
             // Try to adjust the file and folder rights
             if (JPath::canChmod($base_dir)) {
                 JPath::setPermissions($base_dir, 0644, 0755);
             } else {
                 JError::raiseWarning('SOME_ERROR_CODE', 'JFolder::create: ' . JText::_('KISS_GENERAL_ERROR_FOLDERPERMISSIONS'), 'Path: ' . $base_dir);
             }
             // End if JPath::canChmod ...
         }
         // End if(!JFolder::create ...)
     }
     // End if (!is_dir....)
 }
Esempio n. 13
0
 function changeChmod()
 {
     //set core plugin permissons
     // Try to recover from bad chmod settings
     if (!defined('JFCK_BASE')) {
         define('JFCK_BASE', $this->_path_root . 'plugins/editors/fckeditor/editor');
     }
     //file manager plugin
     $dir = JFCK_BASE . '/filemanager';
     $perms = fileperms($this->_path_root . 'index.php');
     $perms = decoct($perms & 0777);
     switch ($perms) {
         case 666:
             $perms = 777;
             break;
         case 644:
             $perms = 755;
     }
     $default_fperms = '0644';
     $default_dperms = '0755';
     if (!stristr(PHP_OS, 'WIN') && file_exists($dir . '/connectors/php/connector.php') && JPath::canChmod($dir . '/connectors/php/connector.php') && $perms != decoct(fileperms($dir) & 0777)) {
         $oldumask = umask(0);
         if ($perms == 755) {
             @chmod(JFCK_BASE, 0755);
             @chmod($dir, 0755);
             JPath::setPermissions($dir);
         } else {
             $default_fperms = '0666';
             $default_dperms = '0777';
             @chmod(JFCK_BASE, 0777);
             @chmod($dir, 0777);
             JPath::setPermissions($dir, '0666', '0777');
         }
         // About plugin
         $dir = JFCK_BASE . '/dialog';
         @chmod($dir, octdec($default_dperms));
         @chmod($dir . '/fck_about.php', octdec($default_fperms));
         //JPath::setPermissions($dir,$default_fperms, $default_dperms);
         //JLink plugin
         $dir = JFCK_BASE . '/plugins';
         @chmod($dir, octdec($default_dperms));
         @chmod($dir . '/jlink', octdec($default_dperms));
         @chmod($dir . '/jlink/suggest.php', octdec($default_fperms));
         @chmod($dir . '/jlink/suggest.class.php', octdec($default_fperms));
         //SpellCheck plugin
         $dir = JFCK_BASE . '/plugins/pspellcheck';
         @chmod($dir, octdec($default_dperms));
         @chmod($dir . '/spellcheck', octdec($default_dperms));
         @chmod($dir . '/spellcheck/spellchecker.php', octdec($default_fperms));
         umask($oldumask);
     }
 }
Esempio n. 14
0
 /**
  * Helper wrapper method for canChmod
  *
  * @param   string  $path  Path to check.
  *
  * @return  boolean  True if path can have mode changed.
  *
  * @see     JPath::canChmod()
  * @since   3.4
  */
 public function canChmod($path)
 {
     return JPath::canChmod($path);
 }
Esempio n. 15
0
 /**
  * Set default folder permissions
  *
  * @param   string  $folder
  * @param   string  $options
  *
  * @return  boolean  True on success
  *
  * @since   3.0
  */
 public function setFolderPermissions($folder, $options)
 {
     // Get the options as a object for easier handling.
     $options = JArrayHelper::toObject($options);
     $ftpFlag = false;
     $ftpRoot = $options->ftpRoot;
     // Determine if the path is "chmodable".
     if (!JPath::canChmod(JPath::clean(JPATH_SITE . '/' . $folder))) {
         $ftpFlag = true;
     }
     // Do NOT use ftp if it is not enabled
     if (empty($options->ftp_enable)) {
         $ftpFlag = false;
     }
     if ($ftpFlag == true) {
         // Connect the FTP client
         $client = JClientFtp::getInstance($options['ftp_host'], $options['ftp_port']);
         $client->login($options['ftp_user'], $options['ftp_pass']);
         // Translate path for the FTP account
         $path = JPath::clean($ftpRoot . "/" . $folder);
         // Chmod using ftp
         if (!$client->chmod($path, '0755')) {
             $ret = false;
         }
         $client->quit();
         $ret = true;
     } else {
         $path = JPath::clean(JPATH_SITE . '/' . $folder);
         if (!@chmod($path, octdec('0755'))) {
             $ret = false;
         } else {
             $ret = true;
         }
     }
     return $ret;
 }
Esempio n. 16
0
 function finishExceptions()
 {
     if ($this->upgrade && !empty($this->no_overwrite) || !$this->upgrade) {
         foreach ($this->no_overwrite as $restore) {
             if (JPath::canChmod($restore['dest'])) {
                 JPath::setPermissions($restore['dest']);
             }
         }
         if ($this->copyFiles($this->no_overwrite)) {
             JFolder::delete($this->backup_dir);
         }
     }
 }
Esempio n. 17
0
    function install($parent)
    {
        $version = '6.4.1';
        $mainframe = JFactory::getApplication();
        $db = JFactory::getDBO();
        $query = "SELECT count(1) FROM #__modules" . " WHERE module = 'mod_jckquickicon'";
        $db->setQuery($query);
        $count = $db->loadResult();
        if ($count) {
            $this->uninstall($parent);
        }
        jimport('joomla.filesystem.folder');
        $src = 'components' . DS . 'com_jckman' . DS . 'modules' . DS . 'mod_jckquickicon';
        $dest = 'modules' . DS . 'mod_jckquickicon';
        if (!JFolder::copy($src, $dest, JPATH_ADMINISTRATOR, true)) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'control panel icon module!'));
        }
        /*===========================================================> */
        /*==============================================> LEFT MODULES */
        /*===========================================================> */
        $row = JTable::getInstance('module');
        $row->position = 'jck_icon';
        $row->published = 1;
        $row->showtitle = 1;
        $row->access = 1;
        $row->client_id = 1;
        $row->params = '';
        $row->id = 0;
        $row->title = 'JCK Manager';
        $row->content = '<img alt="" src="components/com_jckman/icons/jck-manager-logo.png" />';
        $row->ordering = $row->getNextOrder("position='jck_icon'");
        $row->module = 'mod_custom';
        $row->params = '{"prepare_content":0}';
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'Dashboard';
        $row->module = 'mod_jckquickicon';
        $row->params = '';
        $row->ordering = $row->getNextOrder("position='jck_icon'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'Control Panel icon Module data!'));
        }
        $row->id = 0;
        $row->title = 'JCK Manager v' . $version;
        $row->module = 'mod_custom';
        $row->content = '<table class="table table-striped" border="0" cellpadding="0" cellspacing="0" style="margin-bottom:0px;">
			<tr>
				<td>Version:</td>
				<td>' . $version . '</td>
			</tr>
			<tr>
				<td>Author:</td>
				<td><a href="http://www.joomlackeditor.com" target="_blank">www.joomlackeditor.com</a></td>
			</tr>
			<tr>
				<td>Copyright:</td>
				<td>&copy; WebxSolution Ltd, All rights reserved.</td>
			</tr>
			<tr>
				<td>License:</td>
				<td>GPLv2.0</td>
			</tr>
			<tr>
				<td>More info:</td>
				<td><a href="http://joomlackeditor.com/terms-of-use" target="_blank">http://joomlackeditor.com/terms-of-use</a></td>
			</tr>
		</table>';
        $row->ordering = $row->getNextOrder("position='jck_icon'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        /*===========================================================> */
        /*============================================> CPANEL MODULES */
        /*===========================================================> */
        $row = JTable::getInstance('module');
        $row->position = 'jck_cpanel';
        $row->published = 1;
        $row->showtitle = 1;
        $row->access = 1;
        $row->client_id = 1;
        $row->params = '';
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_MANAGER_LABEL';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_MANAGER_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_PLUGIN_LABEL';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_PLUGIN_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_CHECK_LABEL';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_CHECK_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_LAYOUT_MANAGER';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_SYSTEM_LAYOUT_MANAGER_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_BACKUP_LABEL';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_BACKUP_LABEL_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTAL', 'custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_RESTORE_LABEL';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_RESTORE_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'COM_JCKMAN_CPANEL_SLIDER_SYNC_LABEL';
        $row->content = 'COM_JCKMAN_CPANEL_SLIDER_SYNC_HTML';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL', 'JCK PlugMan custom Module data!'));
        }
        jimport('joomla.filesystem.file');
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'pluginoverrides.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'pluginoverrides.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', 'pluginoverrides JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'languageoverrides.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'languageoverrides.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', 'languageoverrides JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'acl.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'acl.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', ' ACL JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'components.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbar' . DS . 'components.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', 'JCK  toolbar plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', 'base plugins file to JCK library!'));
        }
        //$src 	= JPATH_ADMINISTRATOR.DS .'components' .DS. 'com_jckman' .DS. 'editor'.DS.'includes.php';
        //$dest 	= JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'includes.php';
        /*
        if( !JFile::copy( $src, $dest) ){
        	$mainframe->enqueueMessage( JText::_('Unable to move updated includes file to JCK plugin!') );
        }
        */
        unset($row);
        //Check System requirements for the editor
        define('JCK_BASE', JPATH_CONFIGURATION . DS . 'plugins' . DS . 'editors' . DS . 'jckeditor');
        if (!JFolder::exists(JCK_BASE)) {
            $mainframe->enqueueMessage(JText::_('COM_JCKMAN_CUSTOM_INSTALL_SYSTEM_DETECTED_EDITOR_NOT_INSTALLED'));
            return;
        }
        $perms = fileperms(JPATH_CONFIGURATION . DS . 'index.php');
        $perms = decoct($perms & 0777);
        $default_fperms = '0644';
        $default_dperms = '0755';
        if ($perms == 777 || $perms == 666) {
            $default_fperms = '0666';
            $default_dperms = '0777';
        }
        $fperms = JCK_BASE . DS . 'config.js';
        if (!stristr(PHP_OS, 'WIN') && JPath::canChmod(JCK_BASE) && $perms != decoct(fileperms($fperms) & 0777)) {
            $path = JCK_BASE . DS . 'plugins';
            if (!JPath::setPermissions($path, $default_fperms, $default_dperms)) {
                $mainframe->enqueueMessage(JText::_('COM_JCKMAN_CUSTOM_INSTALL_SYSTEM_DETECTED_INCORRECT_FILE_PERMISSONS_FOR_EDITOR'));
            }
        }
        // clear explorer cache to avoid breaking the export feature (filename too long)
        // This code is also run of install/upgrade of the jckexplorer plugin
        $cache = JCK_BASE . '/plugins/jckexplorer/cache';
        if (JFolder::exists($cache)) {
            // Delete cache folders
            foreach (JFolder::folders($cache) as $folder) {
                JFolder::delete($cache . DS . $folder);
            }
            //end foreach
            // Delete cache files
            foreach (JFolder::files($cache) as $file) {
                if ($file != 'index.html') {
                    JFile::delete($cache . DS . $file);
                }
                //end if
            }
            //end foreach
        }
        //end if
        //for upgrade
        $query = 'SELECT p.name FROM `#__jckplugins` p WHERE p.iscore = 0';
        $db->setQuery($query);
        $results = $db->loadObjectList();
        if (!empty($results)) {
            for ($i = 0; $i < count($results); $i++) {
                if (JFolder::exists(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $results[$i]->name) && !JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS . $results[$i]->name)) {
                    $src = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $results[$i]->name;
                    $dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS . $results[$i]->name;
                    if (!JFolder::copy($src, $dest)) {
                        $mainframe->enqueueMessage(JText::sprintf('COM_JCKMAN_CUSTOM_INSTALL_UNABLE_TO_MOVE_SPRINTF', 'base plugin .' . $results[$i]->name . ' to JCK backup folder!'));
                    }
                }
            }
            //end for loop
        }
        //fix remove component install file from the editor's folder
        $file = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'com_jckman.xml';
        if (JFile::exists($file)) {
            JFile::delete($file);
        }
    }
Esempio n. 18
0
    function install($parent)
    {
        $mainframe = JFactory::getApplication();
        $db = JFactory::getDBO();
        $query = "SELECT count(1) FROM #__modules" . " WHERE module = 'mod_jckquickicon'";
        $db->setQuery($query);
        $count = $db->loadResult();
        if ($count) {
            $this->uninstall($parent);
        }
        jimport('joomla.filesystem.folder');
        $src = 'components' . DS . 'com_jckman' . DS . 'modules' . DS . 'mod_jckquickicon';
        $dest = 'modules' . DS . 'mod_jckquickicon';
        if (!JFolder::copy($src, $dest, JPATH_ADMINISTRATOR, true)) {
            $mainframe->enqueueMessage(JText::_('Unable to install control panel icon module!'));
        }
        $row = JTable::getInstance('module');
        $row->title = 'JCK Manager v4.8.7';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/jck-manager-logo.png" style="margin: 3px 2px 0pt 0pt;" />
		</div>
		<div style="padding:5px;"> 
		Installed version: 4.8.7<br/> 
		Author: <a href="http://www.joomlackeditor.com">www.joomlackeditor.com</a><br/>
		Copyright &copy; WebxSolution Ltd, All rights reserved.<br/>
		License: GPLv2.0<br/>
		For licensing information please visit the following web sites:<br/>
		<a href="http://joomlackeditor.com/terms-of-use">http://joomlackeditor.com/terms-of-use</a>
		</div>
		<div style="padding: 5px;">
		The JCK Manager is a way of effortlessly extending the JCK Editor without the need of programming knowledge! And because the Editor is built upon a state-of-the-art plug-and-play architecture you can expand it and shape it in any direction!
			<br />
			<br />
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        $row->position = 'jck_cpanel';
        $row->published = 1;
        $row->showtitle = 1;
        $row->access = 1;
        $row->client_id = 1;
        $row->module = 'mod_custom';
        $row->params = '{"prepare_content":0}';
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'JCK Plugin Manager';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-plugin.png" style="float: left; margin: 3px 2px 0pt 0pt;" />
			
			The Plugin Manager controls what buttons are displayed in the editor&rsquo;s interface. It allows plugins to be published, unpublished, and assigned to specific tool-bars with the ability to setup user permissions.
			<br/> 
			<br/> 
			In addition to these features the Plugin Manager will allow you to drill down and edit each and every plug-in that makes up the JCK Editor. The plugin allows for 3 globel parameters for the dialog popup screens: Height, Title and Width and you will find further customisable parameters just like any standard Joomla extension!
			<br />
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'JCK Plugin Installer';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-installer.png" style="float: left; margin: 3px 2px 0pt 0pt;" />
			
			A JCK plugin consists of an extension that interacts with the editor. These plugins or extensions are used to enable the user to quickly and simply customise or expand the functionality of the editor. This could be done to meet your needs to portfolio images in a stylish light-box gallery or to expand the editor with media or image editing extensions. The possibilities are endless!  What\'s so great about it is that it works similar to Joomla\'s stock installer, so it\'s very easy to install, and you don\'t have to be a developer to get started!
		<br />
		</div>
		<div style="padding: 5px;">
			Please click here to visit the official Plug-in Store: <a href="http://www.joomlackeditor.com/downloads/jck-plugins-store">http://www.joomlackeditor.com/downloads/jck-plugins-store</a>
		<br />
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'System Check';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-systemcheck.png" style="float: left; margin: 3px 2px 0pt 0pt;" />
			
			The JCK Manager has an intelligent API that will attempt to fix problems and reconfigure your website if you upgrade your template. It does this by automatically performing a health checks on your system and notifies you of these problems and will help you address them. 
		<br />
		</div>
		<div style="padding: 5px;">
			This also reinitiates the helpful installation wizard which will walk you step by step through the process of setting up the basic functionally of the editor.
		<br />
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'Layout Manager';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-layout.png" style="float: left; margin: 3px 2px 0pt 0pt;" />
			
			The Layout manager allows control over the editors toolbars, with it you can create your own bespoke toolbars, position plugins, create new toolbars, add and remove! It\'s surprisingly easy do thanks to its simple drag-and-drop interface which will allow you to craft your own bespoke layouts.
		<br />
		</div>
		<div style="padding: 5px;">
			It also allows for different toolbars to be assigned to different components and areas of your website.  This is especially useful if you want to use the \'blog\' toolbar for your blogging component while having a more advanced \'editorial\' toolbar for the rest of your site.
			<br />
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'Backup';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-export.png" style="float: left; margin: 3px 2px 0pt 0pt;" /> 
			
			The backup wizard gives you the ability to create backup copies of your editor&rsquo;s configuration and files.  This includes backing up your JCK plugins and settings, your JCK Manager configuration (including toolbars and user permissions) and lastly your editor&rsquo;s configuration. It does this by creating a clone and exporting it as a tar.gz file ready for you to reinstate via the JCK Managers backup restore feature!
		<br />
		</div>
		<div style="padding: 5px;">
		This feature is very useful, and can be used to export restore points prior to upgrading or used to export your custom configuration to another Joomla compatible system!
		<br />
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'Restore';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-import.png" style="float: left; margin: 3px 2px 0pt 0pt;" /> 
			To restore a backup is very easy! All you need to do is click in the &lsquo;Restore&rsquo;s icon, navigate to the tar.gz backup file and click in the &lsquo;Upload File &amp; install&rsquo;s button. Or if you want to migrate your configuration from one server to another, all you need to do is install the JCK Editor &amp; Manager first, and repeat the above &ndash; job done!
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row->id = 0;
        $row->title = 'Sync';
        $row->content = '<div style="padding: 5px;">
			<img alt="" src="components/com_jckman/icons/icon-48-sync.png" style="float: left; margin: 3px 2px 0pt 0pt;" />
			The JCK Manager keeps a hard copy of your editor&rsquo;s settings and plugins. At any given moment you can use the &lsquo;Sync&rsquo; button to synchronize this data back to the JCK Editor. This is especially useful as it will allow you to uninstall and reinstall the editor during upgrade, before synchronizing your editor&rsquo;s settings back!
		</div>';
        $row->ordering = $row->getNextOrder("position='jck_cpanel'");
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert JCK PlugMan custom Module data!'));
        }
        $row = JTable::getInstance('module');
        $row->title = 'JCK PLugMan Control Panel Icons';
        $row->ordering = $row->getNextOrder("position='jck_icon'");
        $row->position = 'jck_icon';
        $row->published = 1;
        $row->showtitle = 0;
        $row->access = 1;
        $row->client_id = 1;
        $row->module = 'mod_jckquickicon';
        $row->params = '';
        if (!$row->store()) {
            $mainframe->enqueueMessage(JText::_('Unable to insert Control Panel icon Module data!'));
        }
        jimport('joomla.filesystem.file');
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'pluginoverrides.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'pluginoverrides.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move pluginoverrides JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'acl.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'editor' . DS . 'acl.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move ACL JCK plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'components.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins' . DS . 'toolbar' . DS . 'components.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move components JCK  toolbar plugin!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'plugins.php';
        if (!JFile::copy($src, $dest)) {
            $mainframe->enqueueMessage(JText::_('Unable to move base plugins file to JCK library!'));
        }
        $src = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'toolbar' . DS . 'mobile.php';
        $dest = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'jckeditor' . DS . 'includes' . DS . 'ckeditor' . DS . 'toolbar' . DS . 'mobile.php';
        if (!JFile::exists($dest)) {
            if (!JFile::copy($src, $dest)) {
                $mainframe->enqueueMessage(JText::_('Unable to move mobile toolbar file to JCK library!'));
            }
        }
        //$src 	= JPATH_ADMINISTRATOR.DS .'components' .DS. 'com_jckman' .DS. 'editor'.DS.'includes.php';
        //$dest 	= JPATH_PLUGINS.DS.'editors'.DS.'jckeditor'.DS.'includes.php';
        /*
        if( !JFile::copy( $src, $dest) ){
        	$mainframe->enqueueMessage( JText::_('Unable to move updated includes file to JCK plugin!') );
        }
        */
        unset($row);
        //Check System requirements for the editor
        define('JCK_BASE', JPATH_CONFIGURATION . DS . 'plugins' . DS . 'editors' . DS . 'jckeditor');
        if (!JFolder::exists(JCK_BASE)) {
            $mainframe->enqueueMessage(JText::_('System has detected JCK Editor has not been installed!'));
            return;
        }
        $perms = fileperms(JPATH_CONFIGURATION . DS . 'index.php');
        $perms = decoct($perms & 0777);
        $default_fperms = '0644';
        $default_dperms = '0755';
        if ($perms == 777 || $perms == 666) {
            $default_fperms = '0666';
            $default_dperms = '0777';
        }
        $fperms = JCK_BASE . DS . 'config.js';
        if (!stristr(PHP_OS, 'WIN') && JPath::canChmod(JCK_BASE) && $perms != decoct(fileperms($fperms) & 0777)) {
            $path = JCK_BASE . DS . 'plugins';
            if (!JPath::setPermissions($path, $default_fperms, $default_dperms)) {
                $mainframe->enqueueMessage(JText::_('System detected incorrect file permissons for the JCK Editor. Unable to autocorrect so please mannually change.'));
            }
        }
        //for upgrade
        $query = 'SELECT p.name FROM `#__jckplugins` p WHERE p.iscore = 0';
        $db->setQuery($query);
        $results = $db->loadObjectList();
        if (!empty($results)) {
            for ($i = 0; $i < count($results); $i++) {
                if (JFolder::exists(JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $results[$i]->name) && !JFolder::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS . $results[$i]->name)) {
                    $src = JPATH_PLUGINS . DS . 'editors' . DS . 'jckeditor' . DS . 'plugins' . DS . $results[$i]->name;
                    $dest = JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_jckman' . DS . 'editor' . DS . 'plugins' . DS . $results[$i]->name;
                    if (!JFolder::copy($src, $dest)) {
                        $mainframe->enqueueMessage(JText::_('Unable to move base plugin .' . $results[$i]->name . ' to JCK backup folder!'));
                    }
                }
            }
            //end for loop
        }
    }
Esempio n. 19
0
 function create_thumb(&$field, $filename, $size, $origpath = '', $destpath = '', $copy_original = 0, $extra_prefix = '')
 {
     static $destpaths_arr = array();
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.jpath');
     // (DB/Folder) Mode of image field
     $image_source = $field->parameters->get('image_source', 0);
     if ($image_source > 1) {
         global $fc_folder_mode_err;
         if (empty($fc_folder_mode_err[$field->id])) {
             echo __FUNCTION__ . "(): folder-mode: " . $image_source . " not implemented please change image-source mode in image/gallery field with id: " . $field->id;
             $fc_folder_mode_err[$field->id] = 1;
             $image_source = 1;
         }
     }
     // Image file paths
     $dir = $field->parameters->get('dir');
     $origpath = $origpath ? $origpath : JPath::clean(COM_FLEXICONTENT_FILEPATH . DS);
     $destpath = $destpath ? $destpath : JPath::clean(JPATH_SITE . DS . $dir . DS);
     $prefix = $size . '_' . $extra_prefix;
     $filepath = $destpath . $prefix . $filename;
     // Parameters for phpthumb
     $ext = strtolower(JFile::getExt($filename));
     $default_widths = array('l' => 800, 'm' => 400, 's' => 120, 'b' => 40);
     $default_heights = array('l' => 600, 'm' => 300, 's' => 90, 'b' => 30);
     $w = $field->parameters->get('w_' . $size, $default_widths[$size]);
     $h = $field->parameters->get('h_' . $size, $default_heights[$size]);
     $crop = $field->parameters->get('method_' . $size);
     $quality = $field->parameters->get('quality');
     $usewm = $field->parameters->get('use_watermark_' . $size);
     $wmfile = JPath::clean(JPATH_SITE . DS . $field->parameters->get('wm_' . $size));
     $wmop = $field->parameters->get('wm_opacity');
     $wmpos = $field->parameters->get('wm_position');
     // Create destination folder if it does not exist
     if (!JFolder::exists($destpath) && !JFolder::create($destpath)) {
         JError::raiseWarning(100, $field->label . ' : ' . JText::_('Error. Unable to create folders'));
         return false;
     }
     // Make sure folder is writtable by phpthumb
     if (!isset($destpaths_arr[$destpath]) && JPath::canChmod($destpath)) {
         //JPath::setPermissions($destpath, '0644', '0755');  // *** VERY SLOW does chmod on all folder / subfolder files
         chmod($destpath, 0755);
     }
     $destpaths_arr[$destpath] = 1;
     // Avoid trying to set folder permission multiple times
     // EITHER copy original image file as current thumbnail (FLAG 'copy_original' is set)
     if ($copy_original) {
         $result = JFile::copy($origpath . $filename, $filepath);
     } else {
         $result = $this->imagePhpThumb($origpath, $destpath, $prefix, $filename, $ext, $w, $h, $quality, $size, $crop, $usewm, $wmfile, $wmop, $wmpos);
     }
     // Make sure the created thumbnail has correct permissions
     if ($result && JPath::canChmod($filepath)) {
         chmod($filepath, 0644);
     }
     return $result;
 }
Esempio n. 20
0
 private function checkUploadPath($path)
 {
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     // create wirtable upload path
     if (!JFolder::exists(JPATH_ROOT . $path)) {
         JFolder::create(JPATH_ROOT . $path, 0777);
     }
     if (!is_writable(JPATH_ROOT . $path) and JPath::canChmod(JPATH_ROOT . $path)) {
         JPath::setPermissions(JPATH_ROOT . $path, null, '0777');
     }
     // check upload path
     if (!is_writable(JPATH_ROOT . $path)) {
         $app = JFactory::getApplication();
         $app->enqueueMessage(JText::sprintf('MOD_PWEBCONTACT_CONFIG_MSG_UPLOAD_DIR', $path), 'warning');
     } elseif (!JFile::exists(JPATH_ROOT . $path . 'index.html')) {
         JFile::copy(JPATH_ROOT . '/media/mod_pwebcontact/upload/index.html', JPATH_ROOT . $path . 'index.html');
     }
 }
Esempio n. 21
0
 /**
  * Set default folder permissions
  *
  * @param string $path The full file path
  * @param string $buffer The buffer to write
  * @return boolean True on success
  * @since 1.5
  */
 function setDirPerms($dir, &$srv)
 {
     jimport('joomla.filesystem.path');
     /*
      * Initialize variables
      */
     $ftpFlag = false;
     $ftpRoot = $srv['ftpRoot'];
     /*
      * First we need to determine if the path is chmodable
      */
     if (!JPath::canChmod(JPath::clean(JPATH_SITE . DS . $dir))) {
         $ftpFlag = true;
     }
     // Do NOT use ftp if it is not enabled
     if (!$srv['ftpEnable']) {
         $ftpFlag = false;
     }
     if ($ftpFlag == true) {
         // Connect the FTP client
         jimport('joomla.client.ftp');
         $ftp =& JFTP::getInstance($srv['ftpHost'], $srv['ftpPort']);
         $ftp->login($srv['ftpUser'], $srv['ftpPassword']);
         //Translate path for the FTP account
         $path = JPath::clean($ftpRoot . "/" . $dir);
         /*
          * chmod using ftp
          */
         if (!$ftp->chmod($path, '0755')) {
             $ret = false;
         }
         $ftp->quit();
         $ret = true;
     } else {
         $path = JPath::clean(JPATH_SITE . DS . $dir);
         if (!@chmod($path, octdec('0755'))) {
             $ret = false;
         } else {
             $ret = true;
         }
     }
     return $ret;
 }
Esempio n. 22
0
File: helper.php Progetto: 01J/topm
 protected static function createToggleImage($path = null, $file = null)
 {
     $params = self::getParams();
     $font_path = $params->get('media_path') . 'images/fonts/' . $params->get('toggler_font', 'NotoSans-Regular') . '.ttf';
     $font_size = (int) $params->get('toggler_font_size', 12);
     if ($params->get('rtl')) {
         $text_open = self::utf8_strrev($params->get('toggler_name_open'));
         $text_close = self::utf8_strrev($params->get('toggler_name_close'));
     } else {
         $text_open = $params->get('toggler_name_open');
         $text_close = $params->get('toggler_name_close');
     }
     $length = strlen($text_open);
     if ($text_close and strlen($text_close) > $length) {
         $length = strlen($text_close);
     }
     $width = $params->get('toggler_width', 30);
     $height = is_numeric($params->get('toggler_height')) ? $params->get('toggler_height') : $length * $font_size / 1.2;
     $rotate = (int) $params->get('toggler_rotate', 1);
     // Parse font color
     if ($color = $params->get('toggler_color')) {
         $color = self::parseToRgbColor($color);
     }
     if (!is_array($color)) {
         if (in_array($params->get('style_toggler', 'blue'), array('white', 'gray'))) {
             $color = array('r' => 51, 'g' => 51, 'b' => 51);
         } else {
             $color = array('r' => 255, 'g' => 255, 'b' => 255);
         }
         // white
     }
     // create image
     $im = imagecreatetruecolor($text_close ? $width * 2 : $width, $height);
     imagesavealpha($im, true);
     imagealphablending($im, false);
     // set transparent background color
     $bg = imagecolorallocatealpha($im, 255, 0, 255, 127);
     imagefill($im, 0, 0, $bg);
     // set font color
     $font_color = imagecolorallocate($im, $color['r'], $color['g'], $color['b']);
     // display text
     if ($rotate > 0) {
         imagettftext($im, $font_size, -90, $width * 0.25, 0, $font_color, $font_path, $text_open);
         if ($text_close) {
             imagettftext($im, $font_size, -90, $width + $width * 0.25, 0, $font_color, $font_path, $text_close);
         }
     } else {
         imagettftext($im, $font_size, 90, $width * 0.75, $height, $font_color, $font_path, $text_open);
         if ($text_close) {
             imagettftext($im, $font_size, 90, $width + $width * 0.75, $height, $font_color, $font_path, $text_close);
         }
     }
     // set write permissions to cache folder
     jimport('joomla.filesystem.folder');
     if (!JFolder::exists($path)) {
         JFolder::create($path, 0777);
     } elseif (!is_writable($path) and JPath::canChmod($path)) {
         JPath::setPermissions($path, null, '0777');
     }
     // save image
     //TODO consider output image and catch it with ob_get_contents() and then write with JFile
     imagepng($im, $path . $file);
     imagedestroy($im);
 }