function save($data = array())
 {
     $result = array();
     $fields = $this->db->list_fields($this->table_name);
     unset($fields['google_site_id']);
     if (!empty($data)) {
         $this->db->flush_cache();
         $this->set_fields($fields, $data, $this->table_name);
         if (isset($data['google_site_id']) && !empty($data['google_site_id'])) {
             $old_record = $this->get_records(array('google_site_id' => $data['google_site_id']));
             $this->db->where('google_site_id', $data['google_site_id']);
             $this->db->update('google_sites');
             $new_record = $this->get_records(array('google_site_id' => $data['google_site_id']));
             $this->model_audit->save('U', 'google_sites', $data['google_site_id'], $old_record, $new_record);
             $google_site_status = 'update';
         } else {
             $this->db->insert('google_sites');
             $data['google_site_id'] = $this->db->insert_id();
             $new_record = $this->get_records(array('google_site_id' => $data['google_site_id']));
             $this->model_audit->save('I', 'google_sites', $data['google_site_id'], array(), $new_record);
             $google_site_status = 'insert';
         }
         $google_site = $this->get_records(array('google_site_id' => $data['google_site_id']));
         $result = $google_site[0];
         // If this is a new record, then specify that the first data collection goes the required interval
         if ($google_site_status == 'insert') {
             $start_date = strtotime(get_app_var('NEW_SITE_STAT_INTERVAL'), mktime());
         } else {
             $start_date = strtotime(get_app_var('EXISTING_SITE_STAT_INTERVAL'), mktime());
         }
         $result['start_date'] = mktime(0, 0, 0, date('n', $start_date), date('j', $start_date), date('Y', $start_date));
     }
     return $result;
 }
Example #2
0
 function get_google_data($url = '', $refresh_token = '', &$access_token = '', $parameters = array())
 {
     $result = array();
     if (!empty($url)) {
         if (!empty($refresh_token) && empty($access_token)) {
             $CI =& get_instance();
             $CI->load->library('google_auth');
             $CI->google_auth->auth_url = 'https://accounts.google.com/o/oauth2/token';
             $post_data = array();
             if (is_live()) {
                 $post_data['client_id'] = get_app_var('GOOGLE_CLIENT_ID');
                 $post_data['client_secret'] = get_app_var('GOOGLE_CLIENT_KEY');
             } else {
                 $post_data['client_id'] = get_app_var('GOOGLE_DEV_CLIENT_ID');
                 $post_data['client_secret'] = get_app_var('GOOGLE_DEV_CLIENT_KEY');
             }
             $post_data['refresh_token'] = $refresh_token;
             $post_data['grant_type'] = 'refresh_token';
             $response = $CI->google_auth->get_access_token($post_data);
             if (isset($response['access_token'])) {
                 $access_token = $response['access_token'];
             }
         }
         if (!empty($access_token)) {
             $url .= '?access_token=' . $access_token;
             if (!empty($parameters)) {
                 $url .= '&' . implode('&', $parameters);
             }
             $result = @file_get_contents($url);
             if ($result == false) {
                 log_message('error', 'Failed to read URL: ' . $url);
             } else {
                 $result = json_decode($result, true);
                 if (isset($result['items'])) {
                     $result = $result['items'];
                 }
             }
         }
     }
     return $result;
 }
Example #3
0
 function update_whois($client_id = 0, $second_level_domain = '')
 {
     $result = '';
     if (!empty($client_id) && !empty($second_level_domain)) {
         $CI =& get_instance();
         $CI->load->model('model_site_whois');
         if (is_domain($second_level_domain) && (empty($stat_date) || (mktime() - $stat_date) / (24 * 60 * 60) > get_app_var('DEFAULT_WHOIS_UPDATE_DAYS'))) {
             $whois_api = get_app_var('WHOIS_API');
             $whois_username = get_app_var('WHOIS_USERNAME');
             $whois_password = get_app_var('WHOIS_PASSWORD');
             $tries = 0;
             $contents = '';
             while ($tries < 3 && !$contents) {
                 $contents = @file_get_contents($whois_api . '?domainName=' . $second_level_domain . '&username='******'&password='******'&outputFormat=JSON');
                 if ($contents) {
                     $whois = json_decode($contents, true);
                     if (isset($whois['WhoisRecord']) && !empty($whois['WhoisRecord'])) {
                         // Pick up all sites for this client with this second level domain
                         $sites = $this->get_records(array('client_id' => $client_id, 'second_level_domain' => $second_level_domain));
                         if (!empty($sites)) {
                             foreach ($sites as $site) {
                                 $site_whois = array();
                                 $site_whois['site_id'] = $site['site_id'];
                                 $site_whois['client_id'] = $client_id;
                                 $site_whois['stat_date'] = mktime();
                                 $CI->model_site_whois->delete($site_whois);
                                 if (isset($whois['WhoisRecord']['registrarName'])) {
                                     $site_whois['registrar'] = trim($whois['WhoisRecord']['registrarName']);
                                 }
                                 if (isset($whois['WhoisRecord']['registryData']['expiresDate'])) {
                                     if (!empty($whois['WhoisRecord']['registryData']['expiresDate'])) {
                                         $site_whois['expiry_date'] = date('d/m/Y', strtotime($whois['WhoisRecord']['registryData']['expiresDate']));
                                     }
                                 }
                                 if (isset($whois['WhoisRecord']['registrant']['name'])) {
                                     $site_whois['registrant_name'] = $whois['WhoisRecord']['registrant']['name'];
                                 } elseif (isset($whois['WhoisRecord']['registryData']['registrant']['name'])) {
                                     $site_whois['registrant_name'] = $whois['WhoisRecord']['registryData']['registrant']['name'];
                                 }
                                 if (isset($whois['WhoisRecord']['registrant']['email'])) {
                                     $site_whois['registrant_email'] = $whois['WhoisRecord']['registrant']['email'];
                                 } elseif (isset($whois['WhoisRecord']['registryData']['registrant']['email'])) {
                                     $site_whois['registrant_email'] = $whois['WhoisRecord']['registryData']['registrant']['email'];
                                 }
                                 if (isset($whois['WhoisRecord']['registryData']['nameServers']['hostNames'])) {
                                     $site_whois['name_servers'] = implode(', ', $whois['WhoisRecord']['registryData']['nameServers']['hostNames']);
                                 }
                                 if (isset($whois['WhoisRecord']['domainNameExt'])) {
                                     $site_whois['tld'] = $whois['WhoisRecord']['domainNameExt'];
                                 }
                                 $CI->model_site_whois->save($site_whois);
                             }
                         }
                     } elseif (isset($whois['ErrorMessage'])) {
                         $result = $whois['ErrorMessage']['msg'];
                         break;
                     }
                 }
                 $tries++;
             }
         }
     }
     return $result;
 }
Example #4
0
 function _get_tab_columns($client_tab_id = 0)
 {
     $this->_secure(5);
     $grid_method = get_grid_method_from_page();
     $result = array();
     $user = $this->session->all_userdata();
     $filter_display = get_user_preference('filter_display');
     if ($grid_method == 'jqgrid' || $grid_method == 'slick') {
         $names = array();
         $field_width = 95;
         $date_width = 80;
         if ($filter_display == '0') {
             $field_width = 150;
         }
     } else {
         $field_width = '95px';
         $date_width = '95px';
         if ($filter_display == '0') {
             $field_width = '112px';
             $date_width = '112px';
         }
     }
     $this->load->model('model_client_tabs');
     $client_tabs = $this->model_client_tabs->get_records(array('client_id' => $user['client_id'], 'security_level' => $user['user_security_level']));
     $site_title_name = get_app_var('SITE_TITLE_NAME');
     if (!empty($client_tabs)) {
         if ($grid_method == 'jqgrid') {
             $result[] = array('name' => 'actions', 'index' => 'actions', 'datatype' => 'T', 'width' => 35, 'sortable' => false, 'frozen' => true, 'resizable' => false, 'align' => 'center', 'sorttype' => 'text', 'title' => false);
             $result[] = array('name' => 'site_title', 'index' => 'site_title', 'datatype' => 'T', 'sorttype' => 'text', 'hidden' => false, 'classes' => 'site_title tooltip', 'width' => 250, 'frozen' => true, 'title' => false);
             $names[] = '';
             $names[] = $site_title_name;
         } elseif ($grid_method == 'slick') {
             $result[] = array('id' => 'actions', 'name' => '', 'toolTip' => 'Actions', 'headerCssClass' => 'tooltip', 'field' => 'actions', 'width' => 45, 'searchable' => false, 'sortable' => false, 'orderable' => false, 'attributeType' => 'T', 'attributeID' => 0);
             $result[] = array('id' => 'site_title', 'name' => $site_title_name, 'toolTip' => 'Site title derived on Masterdash', 'headerCssClass' => 'tooltip', 'field' => 'site_title', 'width' => 250, 'searchable' => true, 'sortable' => true, 'sorttype' => 'text', 'orderable' => false, 'attributeType' => 'T', 'attributeID' => 0);
         } else {
             $result[] = array('sName' => 'site_title', 'sTitle' => '<span>' . $site_title_name . '</span>', 'sClass' => 'site_title', 'sType' => 'string', 'bVisible' => true);
         }
         foreach ($client_tabs as $client_tab) {
             $visible = false;
             if ($client_tab['client_tab_id'] == $client_tab_id || $client_tab_id == 'all') {
                 $visible = true;
             }
             $tab_attributes = $client_tab['tab_attributes'];
             if (!empty($tab_attributes)) {
                 foreach ($tab_attributes as $tab_attribute) {
                     $type = $grid_method == 'jqgrid' || $grid_method == 'slick' ? 'text' : 'string';
                     if ($tab_attribute['attribute_value_type'] == 'D') {
                         $type = 'date';
                     } elseif ($tab_attribute['attribute_value_type'] == 'M') {
                         $type = 'time';
                     } elseif ($tab_attribute['attribute_value_type'] == 'PC' || $tab_attribute['attribute_value_type'] == 'PT') {
                         $type = $grid_method == 'jqgrid' || $grid_method == 'slick' ? 'text' : 'html';
                     } elseif ($tab_attribute['attribute_value_type'] == 'F') {
                         $type = $grid_method == 'jqgrid' || $grid_method == 'slick' ? 'float' : 'text';
                     } elseif ($tab_attribute['attribute_value_type'] == 'I') {
                         $type = $grid_method == 'jqgrid' || $grid_method == 'slick' ? 'integer' : 'text';
                     }
                     if ($grid_method == 'jqgrid') {
                         $class = $tab_attribute['attribute_array_index'] . ' ' . $type . ($type == 'float' || $type == 'integer' ? ' tooltip_right' : ' tooltip');
                         $result[] = array('name' => $tab_attribute['attribute_array_index'], 'index' => $tab_attribute['attribute_array_index'], 'datatype' => $tab_attribute['attribute_value_type'], 'classes' => $class, 'sorttype' => $type, 'width' => $type == 'date' ? $date_width : $field_width, 'align' => $type == 'date' || $type == 'time' ? 'center' : ($type == 'float' || $type == 'integer' ? 'right' : 'left'), 'hidden' => $visible ? false : true);
                         $names[] = $tab_attribute['attribute_name'];
                     } elseif ($grid_method == 'slick') {
                         if ($visible) {
                             $class = $tab_attribute['attribute_array_index'] . ' ' . $type;
                             $result[] = array('id' => $tab_attribute['attribute_array_index'], 'name' => $tab_attribute['attribute_name'], 'toolTip' => $tab_attribute['attribute_description'], 'field' => $tab_attribute['attribute_array_index'], 'width' => $type == 'date' ? $date_width : $field_width, 'headerCssClass' => 'tooltip', 'cssClass' => $class, 'searchable' => true, 'sortable' => true, 'sorttype' => $type, 'orderable' => $client_tab_id == 'all' || $user['user_security_level'] < 50 ? false : true, 'attributeType' => $tab_attribute['attribute_value_type'], 'attributeID' => $tab_attribute['attribute_id']);
                         }
                     } else {
                         $class = $tab_attribute['attribute_array_index'] . ' ' . $type;
                         $result[] = array('sName' => $tab_attribute['attribute_array_index'], 'sTitle' => '<span>' . teaser($tab_attribute['attribute_name'], 30) . '</span>', 'sClass' => $class, 'sType' => $type, 'sWidth' => $field_width, 'bVisible' => $visible);
                     }
                 }
             }
         }
     }
     if ($grid_method == 'jqgrid') {
         $result = array('names' => $names, 'columns' => $result);
     } elseif ($grid_method == 'slick') {
         $result = array('columns' => $result);
     }
     return $result;
 }
Example #5
0
 function dashboard_config()
 {
     $this->_secure();
     $user = $this->session->all_userdata();
     $this->load->model('model_attribute_groups');
     $this->load->model('model_client_tabs');
     $this->load->model('model_client_attributes');
     $client_tabs = $this->model_client_tabs->get_records(array('client_id' => $user['client_id']));
     if (empty($client_tabs)) {
         for ($i = 0; $i < get_app_var('TAB_COUNT'); $i++) {
             $client_tab_data = array();
             $client_tab_data['client_id'] = $user['client_id'];
             $client_tab_data['tab_number'] = $i + 1;
             $client_tab_data['tab_name'] = 'Tab ' . ($i + 1);
             $this->model_client_tabs->save($client_tab_data);
         }
         $client_tabs = $this->model_client_tabs->get_records(array('client_id' => $user['client_id']));
     }
     $tab_attribute_ids = array();
     if (!empty($client_tabs)) {
         for ($i = 0; $i < sizeof($client_tabs); $i++) {
             if (!empty($client_tabs[$i]['tab_attributes'])) {
                 for ($j = 0; $j < sizeof($client_tabs[$i]['tab_attributes']); $j++) {
                     $tab_attribute = $client_tabs[$i]['tab_attributes'][$j];
                     $tab_attribute_ids[] = $tab_attribute['attribute_id'];
                     $client_attributes = $this->model_client_attributes->get_records(array('client_id' => $user['client_id'], 'attribute_id' => $tab_attribute['attribute_id']));
                     if (isset($client_attributes[0]['attribute_values']) && !empty($client_attributes[0]['attribute_values'])) {
                         $client_tabs[$i]['tab_attributes'][$j]['attribute_values'] = $client_attributes[0]['attribute_values'];
                     }
                 }
             }
         }
     }
     $attribute_groups = $this->model_attribute_groups->get_records();
     if (!empty($attribute_groups)) {
         for ($i = 0; $i < sizeof($attribute_groups); $i++) {
             $all_attributes = $this->model_client_attributes->get_records(array('client_id' => $user['client_id'], 'attribute_group_id' => $attribute_groups[$i]['attribute_group_id']));
             $attribute_groups[$i]['attributes'] = $all_attributes;
         }
     }
     $data = array();
     $data['client_tabs'] = $client_tabs;
     $data['attribute_groups'] = $attribute_groups;
     $data['javascripts'] = array('/javascript/admin_dashboard_control');
     $data['action_view'] = 'users/admin/dashboard_config';
     $this->load->view('layouts/default/default', $data);
 }
Example #6
0
 function update_site_content($site_id = 0)
 {
     $this->_secure();
     $this->load->model('model_sites');
     $filters = array();
     $filters['select'] = array('sites.site_id', 'sites.site_title', 'site_content.stat_date');
     if (!empty($site_id)) {
         $filters['site_id'] = $site_id;
     }
     $sites = $this->model_sites->get_records($filters, false, false);
     if (!empty($sites)) {
         $update_interval = get_app_var('CONTENT_UPDATE_INTERVAL');
         foreach ($sites as $site) {
             if (!empty($site_id) || empty($site['stat_date']) || $site['stat_date'] <= strtotime($update_interval, mktime())) {
                 $this->model_sites->update_site_content($site['site_id']);
             }
         }
     }
     if (isset($_GET['url']) && !empty($_GET['url'])) {
         if (!empty($errors)) {
             $this->session->set_flashdata('flash_error', $errors);
         } else {
             $this->session->set_flashdata('flash_message', 'The Site information has been updated.');
         }
         redirect($_GET['url']);
     } else {
         if (!empty($errors)) {
             echo $errors;
         }
         exit;
     }
 }
Example #7
0
<?php

$grid_method = get_grid_method_from_page();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title>[[page_title]]</title>
	<meta http-equiv="Content-Type" content="text/html; charset=<?php 
echo get_app_var('DEFAULT_CHARSET');
?>
">
	<link rel="shortcut icon" href="http://<?php 
echo $_SERVER['SERVER_NAME'];
?>
/favicon.ico" type="image/x-icon">
	<!-- css -->
	<link rel="stylesheet" href="/css/all.css" type="text/css" media="screen"/>
	<?php 
$user = $this->session->all_userdata();
if (!empty($user)) {
    $client = call_model_function('model_clients', 'model_clients', 'get_records', array('client_id' => $user['client_id']));
    $theme = call_model_function('model_themes', 'model_themes', 'get_records', array('theme_id' => $client[0]['client_theme_id']));
}
if (empty($theme)) {
    $theme = call_model_function('model_themes', 'model_themes', 'get_records', array('theme_default_flag' => '1'));
}
$theme_path = $theme[0]['theme_path'];
$theme_sub_path = $theme[0]['theme_sub_path'];
$theme_jquery_path = $theme[0]['theme_jquery_path'];
?>
Example #8
0
					</div>
				</div>
				<div class="form_field">
					<div class="form_title">
						<a class="btn theme big admin_action" href="javascript:update_site_whois();">Update WhoIs</a>
					</div>
					<div class="form_input_wide action_description">
						Update site whois information - normally runs nightly and picks up sites that haven't been updated in the last
						<?php 
echo str_replace('-', '', get_app_var('WHOIS_UPDATE_INTERVAL'));
?>
						(<span class="warning">WARNING</span>: this task can take some time to complete)
					</div>
				</div>
				<div class="form_field">
					<div class="form_title">
						<a class="btn theme big admin_action" href="javascript:update_site_content();">Update Content</a>
					</div>
					<div class="form_input_wide action_description">
						Update site content information - normally runs nightly and picks up sites that haven't been updated in the last
						<?php 
echo str_replace('-', '', get_app_var('CONTENT_UPDATE_INTERVAL'));
?>
						(<span class="warning">WARNING</span>: this task can take some time to complete)
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
Example #9
0
 function reset_password($user_email = '')
 {
     $result = false;
     if (!empty($user_email)) {
         $user = $this->get_records(array('user_email' => $user_email));
         if (!empty($user)) {
             $user_password = $this->_generate_random_password();
             $this->save(array('user_id' => $user[0]['user_id'], 'user_password' => $user_password));
             $email_to = $user_email;
             $email_from = get_app_var('FROM_EMAIL');
             $email_subject = get_app_var('PASSWORD_RESET_SUBJECT');
             $email_content_raw = get_app_var('PASSWORD_RESET_CONTENT');
             $email_content = replace_tokens($email_content_raw, array('login_page' => 'http://' . $_SERVER['SERVER_NAME'] . '/', 'site_name' => get_app_var('SITE_NAME'), 'user_email' => $email_to, 'user_password' => $user_password));
             email_send($email_from, $email_to, $email_subject, $email_content, true);
         }
     }
     return $result;
 }
Example #10
0
    function get_page_meta_values()
    {
        global $app_global;
        $result = array('meta_title' => '', 'meta_keywords' => '', 'meta_description' => '', 'h1_tag' => '');
        // 1. Fill the values with site wide default values
        $result['meta_title'] = get_app_var('DEFAULT_META_TITLE');
        $result['meta_description'] = get_app_var('DEFAULT_META_DESCRIPTION');
        $result['meta_keywords'] = get_app_var('DEFAULT_META_KEYWORDS');
        $result['h1_tag'] = get_app_var('DEFAULT_H1_TAG');
        $CI =& get_instance();
        $CI->load->model('model_pages');
        $page_id = $CI->model_pages->get_current_page_id();
        // 2. Simply use the menu data
        if ($page_id) {
            $page = $CI->model_pages->get_records(array('page_id' => $page_id));
            if (!empty($page[0]['menu_name'])) {
                $result['meta_title'] = $result['meta_title'] . ' - ' . $page[0]['menu_name'];
                $result['meta_description'] = $page[0]['menu_name'];
                $result['meta_keywords'] = $page[0]['menu_name'];
                $result['h1_tag'] = $page[0]['menu_name'];
            } else {
                $result['meta_title'] = $result['meta_title'] . ' - ' . $page[0]['page_name'];
                $result['meta_description'] = $page[0]['page_name'];
                $result['meta_keywords'] = $page[0]['page_name'];
                $result['h1_tag'] = $page[0]['page_name'];
            }
        }
        // 3. Specific meta info for individual page
        if ($page_id) {
            $query = $this->db->query('select	*
										 from	page_meta
										 where	page_id=?', array($page_id));
            if ($query->num_rows() > 0) {
                $meta_result = $query->result_array();
                if (isset($meta_result[0])) {
                    $result['meta_title'] = $meta_result[0]['meta_title'];
                    $result['meta_description'] = $meta_result[0]['meta_description'];
                    $result['meta_keywords'] = $meta_result[0]['meta_keywords'];
                    $result['h1_tag'] = $meta_result[0]['h1_tag'];
                }
            }
        }
        // 4. Override - this has the highest precedence
        $override = $this->override_meta_data();
        if (!empty($override)) {
            if (isset($override['meta_title'])) {
                $result['meta_title'] = $override['meta_title'];
            }
            if (isset($override['add_meta_title'])) {
                $result['meta_title'] = $override['add_meta_title'] . $result['meta_title'];
            }
            if (isset($override['meta_description'])) {
                $result['meta_description'] = $override['meta_description'];
            }
            if (isset($override['meta_keywords'])) {
                $result['meta_keywords'] = $override['meta_keywords'];
            }
            if (isset($override['h1_tag'])) {
                $result['h1_tag'] = $override['h1_tag'];
            }
        }
        return $result;
    }
Example #11
0
<?php

if (validation_errors()) {
    echo '	<script type="text/javascript">
					$(function() {
						$.jGrowl(\'' . get_app_var('FORM_SUBMISSION_ERROR') . '\',
							{
								position:   \'top-center\',
								theme:		\'error\'
							}
						);
					});
				</script>';
}
}
if (isset($csss) && !empty($csss)) {
    foreach ($csss as $css) {
        echo '<link rel="stylesheet" href="' . $css . '" type="text/css" media="screen"/>' . "\n";
    }
}
?>
	<link rel="stylesheet" href="/css/style" type="text/css" media="screen"/>
	<link rel="stylesheet" href="/uploadify/uploadify.css" type="text/css" media="screen"/>
	<!-- js -->
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js" type="text/javascript"></script>
	<script src="/js/all.js" type="text/javascript"></script>
	<script src="/javascript/general" type="text/javascript"></script>
	<?php 
if (get_app_var('USE_JQGRID')) {
    echo '<script src="/js/grid.locale-en.js" type="text/javascript"></script>' . "\n";
    echo '  <script src="/js/jquery.jqGrid.min.js" type="text/javascript"></script>' . "\n";
} else {
    echo '<script src="/js/jquery.dataTables.min.js" type="text/javascript"></script>' . "\n";
    echo '  <script src="/js/FixedColumns.min.js" type="text/javascript"></script>' . "\n";
}
if (isset($javascripts) && !empty($javascripts)) {
    foreach ($javascripts as $javascript) {
        echo '  <script src="' . $javascript . '" type="text/javascript"></script>' . "\n";
    }
}
$this->load->view('layouts/default/google_analytics');
?>
	<script src="/uploadify/swfobject.js" type="text/javascript"></script>
	<script src="/uploadify/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>