$value) { $text .= ""; } } return $text; } function array_to_checkboxes($array, $checked_arr, $as_array = '') { if ($as_array != ''){ foreach($array as $key => $value){ $text .= ""; } } else{} return $text; } function bits_to_array($number){ If ($number == 0) { return array(0 => false); } else { $i = 0; $power = 0; $setbits = array(); while($i <= $number){ $i = 1 << $power; $setbits[$power] = checkbit($number, $power); $power++; } return $setbits; } } function array_to_bits($array){ $bits = 0; if (isset($array) && is_array($array)) { foreach($array as $key => $value) { if ($value) { $bits += 1 << $key; } } } return $bits; } function checkbit($number, $bit) { $mask = 1 << $bit; return (boolean) ($number & $mask); } function get_LJ_login_data() { global $unt_livepress_options, $unt_lp_clientid, $user_login, $journals; //get_currentuserinfo(); foreach (array_keys($journals) as $name){ //if (strpos($journals[$name]['allowlist'], $user_login) === False) //{ //unset($journals[$name]); //} } require_once(ABSPATH . '/wp-includes/class-IXR.php'); foreach(array_keys($journals) as $name) { $msg_array = array(); $msg_array['username'] = utf8_encode($name); $msg_array['auth_method'] = utf8_encode('clear'); $msg_array['hpassword'] = utf8_encode($journals[$name]['password']); $msg_array['clientversion'] = utf8_encode($unt_lp_clientid); $msg_array['getpickws'] = utf8_encode('1'); $msg_array['getpickwurls'] = utf8_encode('1'); $client = new IXR_client("www.livejournal.com", "/interface/xmlrpc", 80); $client->debug = false; if (!$client->query('LJ.XMLRPC.login', $msg_array)) { return false; } $journals[$name]['data'] = $client->getResponse(); } } function user_pics($lj_meta){ global $unt_livepress_options, $journals; $userpics_text = $unt_livepress_options['userpics']['text']; $text .= $userpics_text; $text .= ''; foreach ($journals as $key => $value){ $username = $key; $lj_pics = $value['data']['pickws']; $lj_pics = array_combine(array_values($lj_pics), $lj_pics); $text .= ' ' . "\n"; } return $text; } function friend_groups($lj_meta){ global $unt_livepress_options, $journals; $text .= ' ' . "\n"; $text .= '
'; foreach ($journals as $key => $value){ $username = $key; $lj_friendboxes = $value['data']['friendgroups']; $temp_array = array(); foreach($lj_friendboxes as $value) { $temp_array[$value['id']] = $value['name']; } $lj_friendboxes = $temp_array; $text .= ''; } return $text; } function user_journals($lj_meta) { global $unt_livepress_options, $journals; $text .= ''; foreach ($journals as $key => $value){ $username = $key; $lj_userjournals = $value['data']['usejournals']; $lj_userjournals = array_combine(array_values($lj_userjournals), $lj_userjournals); $text .= ' ' . "\n"; } return $text; } function get_LJ_meta($post_ID) { global $wpdb, $tablepostmeta; $meta_array = array(); if (is_numeric($post_ID)) { $metadata = has_meta($post_ID); if (isset($metadata)) { foreach($metadata as $meta) { $meta_array[$meta['meta_key']] = array('id' => $meta['meta_id'], 'value' => $meta['meta_value']); } } } return $meta_array; } function place_LJ_Extras_GUI () { print ' '; } function save_LJ_meta($lj_meta, $name, $value, $post_ID) { global $wpdb, $tablepostmeta; $metavalue = $wpdb->escape( stripslashes( trim($value) ) ); if (array_key_exists($name, $lj_meta)) { update_meta($lj_meta[$name]['id'], $name, $metavalue); } else { $metakey = $name; $result = $wpdb->query(" INSERT INTO $tablepostmeta (post_id,meta_key,meta_value) VALUES ('$post_ID','$metakey','$metavalue') "); } } function save_LJ_Extras ($post_ID) { global $wpdb, $tablepostmeta, $unt_livepress_options; $lj_meta = get_LJ_meta($post_ID); if (!$_POST['deletemeta'] && !$_POST['updatemeta']) { if ($_POST['ljusername'] != '') { save_LJ_meta($lj_meta, 'unt_lj_username', $_POST['ljusername'], $post_ID); } if($unt_livepress_options['general']['usemusic']) { if ($_POST['ljmusic'] != '') { save_LJ_meta($lj_meta, 'unt_lj_music', $_POST['ljmusic'], $post_ID); } } if($unt_livepress_options['general']['usemoods']) { if ($_POST['ljmoodid'] != '') { save_LJ_meta($lj_meta, 'unt_lj_moodid', $_POST['ljmoodid'], $post_ID); } if ($_POST['ljmood'] != '') { save_LJ_meta($lj_meta, 'unt_lj_mood', $_POST['ljmood'], $post_ID); } } if ($_POST['ljsynch']) { save_LJ_meta($lj_meta, 'unt_lj_synch', 'checked', $post_ID); } if ($_POST['ljexcerptonly']) { save_LJ_meta($lj_meta, 'unt_lj_excerptonly', 'checked', $post_ID); } if ($_POST['ljnocomment']) { save_LJ_meta($lj_meta, 'unt_lj_nocomment', 'checked', $post_ID); } if ($_POST['ljuserjournals'] != '') { save_LJ_meta($lj_meta, 'unt_lj_journal', $_POST['ljuserjournals'], $post_ID); } if ($_POST['ljlinkback'] != '') { save_LJ_meta($lj_meta, 'unt_lj_linkback', 'checked', $post_ID); } if ($_POST['ljlinkbacktext'] != '') { save_LJ_meta($lj_meta, 'unt_lj_linkbacktext', $_POST['ljlinkbacktext'], $post_ID); } if ($_POST['ljentry'] != '') { save_LJ_meta($lj_meta, 'unt_lj_entry', $_POST['ljentry'], $post_ID); } if ($_POST['ljuserpics'] != '') { save_LJ_meta($lj_meta, 'unt_lj_userpic', $_POST['ljuserpics'], $post_ID); } if ($_POST['ljfriendgroups'] != '') { save_LJ_meta($lj_meta, 'unt_lj_securitylevel', $_POST['ljfriendgroups'], $post_ID); } if (isset($_POST['ljfriendboxes'])) { save_LJ_meta($lj_meta, 'unt_lj_allowmask', array_to_bits($_POST['ljfriendboxes']), $post_ID); } } return $post_ID; } function mood_list($meta) { //get values from LJ mood config file global $unt_livepress_options, $ljmoods; $mood_text = $unt_livepress_options['moods']['text']; $lj_meta = $meta; $text = $mood_text; $text .= ' Alt Text ' . "\n"; return $text; } function build_LJ_Extras_GUI() { global $unt_livepress_options, $journals; $unt_lp_music_text = $unt_livepress_options['music']['text']; $synch_by_default = $unt_livepress_options['synch']['bydefault']; $excerpt_by_default = $unt_livepress_options['synch']['excerptonly']; $linkback_by_default = $unt_livepress_options['synch']['insertlinkback']; $userpics_text = $unt_livepress_options['userpics']['text']; $unt_lp_settings = $unt_livepress_options; $lj_meta = get_LJ_meta($_GET['post']); echo ''; } function journal_Switcher() { echo ''; } function init_LJ_Extras_GUI() { global $unt_livepress_options, $journals; if (isset($journals)) { $firstJournal = array_keys($journals); $firstUserName = $firstJournal[0]; echo ''; } } if (strpos($_SERVER['PHP_SELF'],'wp-admin/post.php') || strpos($_SERVER['PHP_SELF'],'wp-admin/bookmarklet.php')) { get_LJ_login_data(); //add_action('admin_head', 'LJ_Extras_Style'); add_action('admin_head', 'journal_Switcher'); //add_action('admin_footer', 'build_LJ_Extras_GUI'); //add_action('admin_footer', 'place_LJ_Extras_GUI'); add_action('admin_footer', 'init_LJ_Extras_GUI'); add_action('edit_post', 'save_LJ_Extras'); add_action('publish_post', 'save_LJ_Extras', 5); add_action('simple_edit_form', 'build_LJ_Extras_GUI'); add_action('edit_form_advanced', 'build_LJ_Extras_GUI'); } ?>