--- counter/counter.module 2010-09-17 02:48:29.000000000 +0800
+++ counter.module_6.2.11_added_counter_base_node_type 2010-11-28 15:47:02.420000001 +0800
@@ -111,6 +111,10 @@
$counter_published_node = variable_get('counter_published_node',1);
$counter_unpublished_node = variable_get('counter_unpublished_node',1);
+ //hack:added group_node/banji/fenhui
+ $counter_group_node_banji = variable_get('counter_group_node_banji',1);
+ $counter_group_node_fenhui = variable_get('counter_group_node_fenhui',1);
+
$counter_show_server_ip = variable_get('counter_show_server_ip',1);
$counter_show_ip = variable_get('counter_show_ip',1);
$counter_show_counter_since = variable_get('counter_show_counter_since',1);
@@ -204,22 +208,25 @@
$results = db_query($sql, $new_site_counter);
//Read counter_data
- //published_node, registered_user, site_counter, unique_visitor, unpublished_node, unregistered_user
+ //hack group-nodebanji/fenhui
+ //published_node, registered_user, site_counter, unique_visitor, unpublished_node, unregistered_user,node types
$sql = " SELECT * FROM {counter_data} ORDER BY counter_name";
$results = db_query($sql);
$i=0;
+
while ($data = db_fetch_object($results)) {
$i++;
$counter_name[$i] = $data->counter_name;
- $counter_value[$i] = $data->counter_value;
+ $counter_value[$i] = $data->counter_value;
+ $field_name_id[$counter_name[$i]]=$counter_value[$i];
}
//Write output
$output = '';
$output .= '
';
if ($counter_show_site_counter) {
- $output .= '- '.t('Site Counter: '). number_format($counter_initial_counter+$counter_value[4]).'
';
+ $output .= '- '.t('Site Counter: '). number_format($counter_initial_counter+ $counter_value[12]).'
';
}
if ($counter_show_unique_visitor) {
@@ -233,7 +240,7 @@
$sql = " UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='unique_visitor' ";
$results = db_query($sql, $counter_unique);
} else {
- $counter_unique = $counter_value[5];
+ $counter_unique = $field_name_id['unique_visitor'];
}
$output .= '- '.t('Unique Visitor: '). number_format($counter_initial_unique_visitor+$counter_unique).'
';
}
@@ -248,7 +255,7 @@
$sql = " UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='registered_user' ";
$results = db_query($sql, $total);
} else {
- $total = $counter_value[3];
+ $total = $field_name_id['registered_user'];
}
$output .= '- '.t('Registered Users: '). number_format($total).'
';
}
@@ -263,7 +270,7 @@
$sql ="UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='unregistered_user' ";
$results = db_query($sql, $total);
} else {
- $total = $counter_value[7];
+ $total = $field_name_id['unregistered_user'];
}
$output .= '- '.t('Unregistered Users: '). number_format($total).'
';
}
@@ -278,7 +285,7 @@
$sql = " UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='blocked_user' ";
$results = db_query($sql, $total);
} else {
- $total = $counter_value[1];
+ $total = $field_name_id['blocked_user'];
}
$output .= '- '.t('Blocked Users: '). number_format($total).'
';
}
@@ -293,7 +300,7 @@
$sql = " UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='published_node' ";
$results = db_query($sql, $total);
} else {
- $total = $counter_value[2];
+ $total = $field_name_id['published_node'];
}
$output .= '- '.t('Published Nodes: '). number_format($total).'
';
}
@@ -308,11 +315,30 @@
$sql = "UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='unpublished_node' ";
$results = db_query($sql, $total);
} else {
- $total = $counter_value[6];
+ $total = $field_name_id['unpublished_node'];
}
$output .= '- '.t('Unpublished Nodes: '). number_format($total).'
';
}
-
+ $node_types=node_get_types('names');
+ $select_type=variable_get('counter_node_types', array(''));
+ foreach($node_types as $typestr=>$typename){
+ if(in_array($typestr, $select_type, TRUE)){
+ if ($data_update) {
+ $sql = " SELECT count(*) as total FROM {node} WHERE type='".$typestr."'";
+ $results = db_query($sql);
+ $data = db_fetch_object($results);
+ $total = $data->total;
+
+ $sql = " UPDATE {counter_data} SET counter_value='%s' WHERE counter_name='".$typestr."' ";
+ $results = db_query($sql, $total);
+ } else {
+ $field_name ="node_type_".$typestr;
+ $total = $field_name_id[$field_name];
+ }
+ $output .= '- '.$typename." : ". number_format($total).'
';
+ }
+ }
+
if ($counter_show_server_ip) {
$output .= '- '.t("Server IP: ").$counter_svr_ip.'
';
}
@@ -344,18 +370,18 @@
}
}
-
+/**
if ($counter_statistic_today || $counter_statistic_week
|| $counter_statistic_month || $counter_statistic_year) {
$output .= '- '.t("Visitors: ").'
';
}
-
+**/
if ($counter_statistic_today) {
$sql="SELECT count(*) AS total FROM {counter} WHERE SUBSTRING(counter_date,1,10)= '%s'";
$results = db_query($sql, date('Y-m-d'));
$data = db_fetch_object($results);
$statistic = $data->total;
- $output .= t("Today: ").$statistic."
";
+ $output .= "- ".t("Today: ").$statistic."
";
}
if ($counter_statistic_week) {
$date1 = date('Y-m-d', time()-7*24*60*60);
@@ -366,21 +392,21 @@
$results = db_query($sql);
$data = db_fetch_object($results);
$statistic = $data->total;
- $output .= t("This week: ").$statistic."
";
+ $output .= "- " .t("This week: ").$statistic."
";
}
if ($counter_statistic_month) {
$sql="SELECT count(*) AS total FROM {counter} WHERE SUBSTRING(counter_date,1,7)= '%s'";
$results = db_query($sql, date('Y-m'));
$data = db_fetch_object($results);
$statistic = $data->total;
- $output .= t("This month: ").$statistic."
";
+ $output .= "- " . t("This month: ").$statistic."
";
}
if ($counter_statistic_year) {
$sql="SELECT count(*) AS total FROM {counter} WHERE SUBSTRING(counter_date,1,4)= '%s'";
$results = db_query($sql, date('Y'));
$data = db_fetch_object($results);
$statistic = $data->total;
- $output .= t("This year: ").$statistic;
+ $output .= "- " .t("This year: ").$statistic ."
";
}
$output .= '
';
@@ -393,4 +419,4 @@
}
}
-?>
\ No newline at end of file
+?>