prefix."contactdir"; if($wpdb->get_var("SHOW TABLE LIKES '".$tb."'") != $tb) { $sql = "CREATE TABLE IF NOT EXISTS `".$tb."` (". "`id` int(11) NOT NULL AUTO_INCREMENT,". "`name` varchar(255) NOT NULL,". "`email` varchar(255) NOT NULL,". "`url` varchar(255) NOT NULL,". "`phone` varchar(255) NOT NULL,". "`address` text NOT NULL,". "`cat_id` text NOT NULL,". "`time_created` int(11) NOT NULL,". "`status` int(1) NOT NULL,". "PRIMARY KEY (`id`)". ") ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"; $wpdb->query($sql); } if($wpdb->get_var("SHOW TABLE LIKES '".$tb."_cat'") != $tb."_cat") { $sql2 = "CREATE TABLE IF NOT EXISTS `".$tb."_cat` (". "`id` int(4) NOT NULL AUTO_INCREMENT,". "`name` varchar(255) NOT NULL,". "`status` int(1) NOT NULL,". "PRIMARY KEY (`id`)". ") ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;"; $q = $wpdb->query($sql2); if($q) { $sql3 = "INSERT INTO `".$tb."_cat` (". "`id` ,`name` ,`status`) VALUES (". "NULL , 'General', '1');"; $wpdb->query($sql3); } } $version = "3.0.1"; if(!add_option("contactdir_version",$version)) { update_option("contactdir_version",$version); } $opt_ct[defstatus] = 1; $opt_ct[showpp] = 30; $opt_ct[template] = "%name%
\nEmail: %mail%
\nHemsida: %url%
\nTelefon: %phone%
\nAdress: %address%\n
"; $opt_ct[css] = ".contactdir_addform {\n\n}\n.contactdir_addform input {\n\n}\n.contactdir_error {\n\tbackground-color:#FCC;\n\tpadding:5px;\n\tmargin-bottom:5px;\n\tdisplay:block;\n}\n.contactdir_info {\n\tbackground-color:#FF9;\n\tpadding:5px;\n\tmargin-bottom:5px;\n\tdisplay:block;\n}"; if(!add_option("contactdir_options",$opt_ct)) { update_option("contactdir_options",$opt_ct); } } /* Misc Functions */ function contactdir_url($page) { echo get_bloginfo('wpurl').'/wp-admin/admin.php?page=wp-contacts-directory/'.$page.'.php'; } /* Add Navigation On Dashboard Menu */ function contactdir_navigation() { if(function_exists('add_object_page')) { add_object_page( "WP Contacts Directory", "Contacts Dir.", 10, __FILE__, "contactdir_manager", get_option('home')."/wp-content/plugins/wp-contacts-directory/contact-directory.png" ); } else { add_menu_page( "WP Contacts Directory", "Contact Directory", 10, __FILE__, "contactdir_manager", get_option('home')."/wp-content/plugins/wp-contacts-directory/contact-directory.png" ); } add_submenu_page(__FILE__, 'WP Contacts Directory Categories' , 'Manage Categories', 10,'contactdir-category', 'contactdir_category' ); add_submenu_page(__FILE__, 'WP Contacts Directory Management' , 'Manage Contact', 10,'contactdir-manage', 'contactdir_manage' ); add_submenu_page(__FILE__, 'WP Contacts Directory Options' , 'Options', 10,'contactdir-options', 'contactdir_options' ); } function contactdir_head(){ global $opt_ct; echo ""; } function contactdir_cat_list($selected = "", $show_hidden = FALSE) { global $wpdb; $tb = $wpdb->prefix."contactdir_cat"; if(!$show_hidden) $hd = " WHERE `status` = 1"; $query = $wpdb->get_results("SELECT * FROM `$tb`$hd",ARRAY_A); if(is_array($query)) { foreach($query as $data) { $tcat = unserialize($selected); if(is_array($tcat)) { if(in_array($data[id],$tcat)) $sel = ' checked="checked"'; } ?> prefix."contactdir_cat"; $query = $wpdb->get_row("SELECT * FROM `$tb` WHERE `id` = $id"); return $query; } function contactdir_update() { global $opt_ct,$wpdb,$contactdir_version; $tb = $wpdb->prefix."contactdir"; $sql_update = "ALTER TABLE `$tb` CHANGE `cat_id` `cat_id` TEXT NOT NULL"; $query = $wpdb->query($sql_update); if($query) { $query2 = $wpdb->get_results("SELECT * FROM `$tb`",ARRAY_A); if(is_array($query2)): foreach($query2 as $array) { $tid = $array[id]; $cid = $array[cat_id]; $scid = serialize(array($cid)); if(is_numeric($cid)) $wpdb->query("UPDATE `$tb` SET `cat_id` = '$scid' WHERE `id` = $tid LIMIT 1"); } endif; $opt_ct[template] = "%name%
\nEmail: %mail%
\nHemsida: %url%
\nTelefon: %phone%
\nAdress:
%address%
\n
"; update_option("contactdir_options",$opt_ct); update_option("contactdir_version",$contactdir_version); echo "

Update is success...

"; } else { echo "

Error occured, update is failed. Please try again, or consult with me...

"; } } function contactdir_manage() { global $wpdb,$opt_ct; $tb = $wpdb->prefix."contactdir"; extract($_POST); echo '
'; echo '

'; if($_GET[update]) { contactdir_update(); } $version = get_option("contactdir_version"); $ver = str_replace(".","",$version); if(substr($ver,0,2) < 23) { echo "

You currently using old version. Please Click Here to update.

"; } echo "

WP Contact Directory Management

"; if($_POST[Submit]) { if($contactdir_cat_id) $contactdir_cat_id = serialize($contactdir_cat_id); if($contactdir_medit) { $sql = "UPDATE `$tb` SET `name` = '".$contactdir_mname."',". "`email` = '".$contactdir_mmail."',". "`url` = '".$contactdir_murl."',". "`phone` = '".$contactdir_mphone."',". "`address` = '".$contactdir_maddress."',". "`cat_id` = '".$contactdir_cat_id."',". "`status` = '".$contactdir_mstatus."' WHERE `id` = '".$contactdir_medit."' LIMIT 1 ;"; $q = $wpdb->query($sql); if($q) echo "

Contact is updated, go to Contact List...

"; } else { $result = $wpdb->query("INSERT INTO `$tb` (`id`, `name`, `email`, `url`, `phone`, `address`, `cat_id`, `time_created`, `status`) VALUES (NULL, '$contactdir_mname', '$contactdir_mmail', '$contactdir_murl', '$contactdir_mphone', '$contactdir_maddress', '$contactdir_cat_id', '".time()."', '$contactdir_mstatus');"); if($result) echo "

New Contact is saved, go to Contact List.

"; } } if($_GET[edit]) { $array = $wpdb->get_row("SELECT * FROM `$tb` WHERE `id` = '".$_GET[edit]."'",ARRAY_A); } else { $array[status] = 1; } ?> query("INSERT INTO `$tb` (`id`, `name`, `email`, `url`, `phone`, `address`, `cat_id`, `time_created`, `status`) VALUES (NULL, '".$array[0]."', '".$array[1]."', '".$array[2]."', '".$array[3]."', '".$array[4]."', '".$cat_id."', '".time()."', '".$_POST[contactdir_status]."');"); } if($result) echo "

CSV was successfully imported.

"; endif; } ?>
Category Name

" type="submit">


CSV Importer

Default Category

(Office 2007 use ';' as separator, and Ofiice 2003 use ',' as separator)

CSV Table Sample

name email url phone address
Name 1 email@email1.com http://website.com 0123434 Indo
Name 2 email@email2.com http://website2.com 01234342 Jogja
'; } function contactdir_addform_shortcode() { global $wpdb,$c_url; $tb = $wpdb->prefix."contactdir"; extract($_POST); $opt_ct = get_option("contactdir_options"); if($contactdir_submit): if(empty($contactdir_name) or empty($contactdir_email)) { $error .= "Fyll i namn och e-mail!
"; } if(!is_email($contactdir_email)) { $error .= "Ogiltig e-mail!
"; } $is_ex = $wpdb->get_row("SELECT `id` FROM `$tb` WHERE `email` = '$contactdir_email'",ARRAY_A); if(is_array($is_ex)) { $error .= "E-mailen finns redan i telefonboken
"; } if(empty($error)) { if($contactdir_cat_id) $contactdir_cat_id = serialize($contactdir_cat_id); $result = $wpdb->query("INSERT INTO `$tb` (`id`, `name`, `email`, `url`, `phone`, `address`, `cat_id`, `time_created`, `status`) VALUES (NULL, '$contactdir_name', '$contactdir_email', '$contactdir_url', '$contactdir_phone', '$contactdir_address', '$contactdir_cat_id', '".time()."', '".$opt_ct[defstatus]."');"); if($opt_ct[defstatus] != 1) $apm = " and pending for approval."; if($result) echo "
Din kontakt har lagts till$apm, Tack.
"; } endif; ?>
$error
"; ?>
* är obligatoriska
prefix."contactdir"; switch($query) { case "alpha": $qdb = " WHERE `name` LIKE '".$_GET[depan]."%' AND `status` = 1"; break; case "cat": $qdb = " WHERE `cat_id` = '".$_GET[id]."' AND `status` = 1"; break; case "caricerdas": $s = $_GET[contact_dir_s]; $qdb = " WHERE (`name` LIKE '%$s%' OR `email` LIKE '%$s%' OR `url` LIKE '%$s%' OR `phone` LIKE '%$s%' OR `address` LIKE '%$s%') AND `status` = 1"; break; default: $qdb = " WHERE `status` = 1"; break; } ?>

Sök alfabetiskt: $deret | "; }else { $list .= "$deret | "; } } echo $list."All"; ?>

get_results("SELECT `id` FROM `".$tb."`$qdb", ARRAY_A); if(is_array($query_db) and is_array($contactdir_cat_id)) { foreach($query_db as $query) { if($query[cat_id]) { $cat_id = unserialize($query[cat_id]); $tmparray = array(); foreach($contactdir_cat_id as $cid) { if(in_array($cid,$cat_id)) { $tmparray[] = $query; } } } } $query_db = $tmparray; } $total = count($query_db); $page_links = paginate_links( array( 'base' => add_query_arg( 'apage', '%#%' ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($total / $show_pp), 'current' => $page )); if ( $page_links ) : ?>
' . __( 'Displaying %s–%s from total %s contacts - ' ) . '%s', number_format_i18n( $start + 1 ), number_format_i18n( min( $page * $show_pp, $total ) ), number_format_i18n( $total ), $page_links ); echo $page_links_text; ?>
get_results("SELECT * FROM `".$tb."`$qdb ORDER BY `name` LIMIT $start, $num", ARRAY_A); if(is_array($query_db) and is_array($contactdir_cat_id)) { foreach($query_db as $query) { if($query[cat_id]) { $cat_id = unserialize($query[cat_id]); $tmparray = array(); foreach($contactdir_cat_id as $cid) { if(in_array($cid,$cat_id)) { $tmparray[] = $query; } } } } $query_db = $tmparray; } if(is_array($query_db)): echo "
"; foreach($query_db as $array): ?>
prefix."contactdir"; echo '
'; echo '

'; echo "

WP Contact Directory

"; $version = get_option("contactdir_version"); $ver = str_replace(".","",$version); if(substr($ver,0,2) < 23) { echo "

You currently using old version. Please Click Here to update.

"; } if(function_exists("file_get_contents")) { $output = file_get_contents("http://ahlul.web.id/tools/plugads/wpcontact.php"); if($output) echo $output; } if($delete) { $_POST[selected_contacts][0] = $delete; $_POST[action] = "delete"; } if(is_array($_POST[selected_contacts])) { switch($_POST[action]) { case "aktif": foreach($_POST[selected_contacts] as $array): $q = $wpdb->query("UPDATE `$tb` SET `status` = 1 WHERE `id` = ".$array); endforeach; if($q) echo "

Selected Contacts is set to active...

"; break; case "nonaktif": foreach($_POST[selected_contacts] as $array): $q = $wpdb->query("UPDATE `$tb` SET `status` = 0 WHERE `id` = ".$array); endforeach; if($q) echo "

Selected Contacts is set to pending...

"; break; case "delete": foreach($_POST[selected_contacts] as $array): $q = $wpdb->query("DELETE FROM `$tb` WHERE `id` = ".$array); endforeach; if($q) echo "

Selected Contacts is deleted...

"; break; } } ?>
get_var($wpdb->prepare("SELECT COUNT(id) FROM `$tb` WHERE `status` = '1'")); $row_naktif = $wpdb->get_var($wpdb->prepare("SELECT COUNT(id) FROM `$tb` WHERE `status` <> '1'")); ?>
1"; break; case "cat": $qdb = " WHERE `cat_id` = '".$_GET[id]."'"; break; case "caricerdas": $s = $_GET[s]; $qdb = " WHERE (`name` LIKE '%$s%' OR `email` LIKE '%$s%' OR `url` LIKE '%$s%' OR `phone` LIKE '%$s%' OR `address` LIKE '%$s%')"; break; } $opt_ct = get_option("contactdir_options"); $show_pp = $opt_ct[showpp]; if(!$show_pp) $show_pp = 10; if ( isset( $_GET['apage'] ) ) $page = abs( (int) $_GET['apage'] ); else $page = 1; $start = $offset = ( $page - 1 ) * $show_pp; $num = $show_pp; $query_db = $wpdb->get_results("SELECT `id` FROM `".$tb."`$qdb", ARRAY_A); $total = count($query_db); $page_links = paginate_links( array( 'base' => add_query_arg( 'apage', '%#%' ), 'format' => '', 'prev_text' => __('«'), 'next_text' => __('»'), 'total' => ceil($total / $show_pp), 'current' => $page )); if ( $page_links ) : ?>
' . __( 'Displaying %s–%s from total %s contacts' ) . '%s', number_format_i18n( $start + 1 ), number_format_i18n( min( $page * $show_pp, $total ) ), number_format_i18n( $total ), $page_links ); echo $page_links_text; ?>
get_results("SELECT * FROM `".$tb."`$qdb ORDER BY `id` DESC LIMIT $start, $num", ARRAY_A); if(is_array($query_db)): foreach($query_db as $array): ?>
Name E-mail Website Phone Category Status
Name E-mail Website Phone Category Status

'.$array[email].'':""; ?> '.$array[url].'':""; ?> name; ?>,
'; } function contactdir_options() { extract($_POST); echo '
'; echo '

'; echo "

WP Contact Directory Options

"; if($_POST[Submit]) { $opt_ct[defstatus] = $contactdir_defstatus; $opt_ct[showpp] = $contactdir_showpp; $opt_ct[css] = $contactdir_css; $opt_ct[template] = $contactdir_template; if(!is_numeric($contactdir_showpp)): echo "

Number per page must be numeric...

"; else: if(!add_option("contactdir_options",$opt_ct)) { update_option("contactdir_options",$opt_ct); echo "

New Configurations is saved...

"; } endif; } $opt_ct = get_option("contactdir_options"); $opt_ct_defstatus = $opt_ct[defstatus]; $opt_ct_showpp = $opt_ct[showpp]; $opt_ct_css = $opt_ct[css]; $opt_ct_template = $opt_ct[template]; ?>
Default Action for New Entry
Avialable tags: %name%, %mail%, %url%, %phone%, %category%, %address%

'; } function ahlul_credit() { ?>

 

Support

If you have problem or you wanna to make a website or tools please send email to me, ceo.ahlul@yahoo.com

Donate for me

If you find this plugin is usefull and want make donation for me you can send it to my paypal (ahlul_amc@yahoo.co.id) ;)

Thanks before for donation.

prefix."contactdir_cat"; if($submit and $contactdir_cat_name) { if($contactdir_cat_edit) { $q = $wpdb->query("UPDATE `$tb` SET `name` = '$contactdir_cat_name', `status` = '$contactdir_cat_status' WHERE `id` = '$contactdir_cat_edit'"); if($q) echo "

Category is updated...

"; } else { $row = $wpdb->get_row("SELECT `id` FROM `$tb` WHERE `name` = '$contactdir_cat_name'"); if($row) { echo "

Sorry, category '$contactdir_cat_name' already exists on database...

"; } else { $q = $wpdb->query("INSERT INTO `$tb` (`id`,`name`,`status`) VALUES (NULL,'$contactdir_cat_name',1)"); if($q): echo "

New Categories is saved...

"; else: echo "

Error occured, category not save...

"; endif; } } } if($_GET[delete]) { $q = $wpdb->query("DELETE FROM `$tb` WHERE `id` = '".$_GET[delete]."'"); if($q): echo "

Category is deleted...

"; else: echo "

Error occured, category not deleted...

"; endif; } if(is_array($cat_delete) and $action = "delete") { foreach($cat_delete as $array) { $wpdb->query("DELETE FROM `$tb` WHERE `id` = '".$array."'"); } echo "

All Selected Categories is deleted...

"; } ?>

WP Contact Directory Categories



get_results("SELECT * FROM `$tb`$k ORDER BY `id` DESC", ARRAY_A); if(is_array($row)): foreach($row as $array) { ?>
Name Status
Name Status
Edit | Delete

Edit Category"; } else { echo "

Add Category

"; } ?>
"; $row = $wpdb->get_row("SELECT * FROM `$tb` WHERE `id` = '".$_GET[edit]."'",ARRAY_A); } else { $row[status] = 1; } ?>
'; echo " Cancel Editing"; } else { echo '

'; } ?>

'; } function csv2array($file,$include_table_header = TRUE,$sep = ";") { $row = 1; if (($handle = fopen($file, "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, $sep)) !== FALSE) { $num = count($data); $array[] = $data; } fclose($handle); if($include_table_header) $array = array_slice($array, 1); } return array("data"=>$array,"numfields"=>$num); } ?>