'something', ), $atts ) ); $sql = "select * from $tbl_shareandgetit_buttons where button_name=\"".trim($name)."\""; $row = $wpdb->get_results($wpdb->prepare($sql)); if($wpdb->num_rows == 0) { return ''; } if(strpos($row[0]->file_path,"SHAAGE_FILE:") == 1) { $row[0]->file_path = str_replace(":SHAAGE_FILE:",'',$row[0]->file_path); } $lang = get_bloginfo( "language", "raw" ); // dans la variable data j'ajoute en array l'itm btnpage que je recupère grâce à REQUEST_URI $data=array("fanpageurl"=>$row[0]->fan_page_url,"post"=>$row[0]->post, "file"=>$row[0]->file_path, "blogger"=>$row[0]->twitter_name, "domain"=>$_SERVER['HTTP_HOST'],"btnPage"=>$_SERVER['REQUEST_URI'] ,"btnname"=>$row[0]->button_name,"language"=>$lang); $encoded=urlencode(base64_encode(utf8_encode(serialize($data)))); $url = "http://shareandgetit.com/process/process.php?data=$encoded"; $content.='
Share&Get it ! Get twitter followersTwitter Backgrounds
'; return $content; } function shaagi_btnslist($page,$link) { global $wpdb,$tbl_shareandgetit_buttons; $count_per_page = 10; if( !isset($page) || empty($page) || $page <= 0) $page = 1; $lim1 = ($page-1)*$count_per_page; $lim2 = $count_per_page; $result = $wpdb->get_row(" SELECT count( * ) as count_all FROM ".$tbl_shareandgetit_buttons); $count_all = $result->count_all; $last_page = ceil($count_all/$count_per_page); $rows = $wpdb->get_results(" SELECT * FROM ".$tbl_shareandgetit_buttons." Limit $lim1,$lim2;"); $previous_page = $page - 1; if($previous_page < 1) $previous_page = 1; $next_page = $page + 1; if($next_page > $last_page) $next_page = $last_page; // loop $i = $page - 3; if( $i < 1) $i = 1; $loop_count = 1; if($i >1) { $previous_page = $i-1; } else { $previous_page = 1; } echo '
'; $count = $wpdb->num_rows; $op=explode("?",$_SERVER["HTTP_REFERER"]); foreach ($rows as $row) { if(strpos($row->file_path,":SHAAGE_FILE:") == 0) { $row->file_path = basename(str_replace(":SHAAGE_FILE:",'',$row->file_path)); } echo ' '; } $loop_count = 1; $i = $page -2; if($i < 1) $i = 1; echo '
'.__("Button name",SHAAGI_TRASNLATE).' '.__("Shortcode",SHAAGI_TRASNLATE).' '.__("File",SHAAGI_TRASNLATE).' '.__("Edit",SHAAGI_TRASNLATE).' '.__("Delete",SHAAGI_TRASNLATE).'
'.$row->button_name.' '.$row->shortcode.' '.$row->file_path.' '.__("Edit",SHAAGI_TRASNLATE).' '.__("Delete",SHAAGI_TRASNLATE).'
'; } function shaagi_delete_buttons() { if ( isset($_POST['bids'])) { $url = $_POST['url']; $page = $_POST['page']; $bids = trim($_POST['bids'],","); global $wpdb,$tbl_shareandgetit_buttons; $sql = "delete from ".$tbl_shareandgetit_buttons." where id in (".$bids.")"; if($wpdb->query($sql)) { // show button list again shaagi_btnslist($page,$url); } } die(); } function shaagi_buttons_list_callback($p='',$l='') { if(isset($_POST['page'])) $page = $_POST['page']; else $page = $p; if(isset($_POST['link'])) $link = $_POST['link']; else $link = $l; shaagi_btnslist($page,$link); die(); } function shaagi_action_callback() { global $wpdb,$tbl_shareandgetit_buttons; // this is how you get access to the database $tweet = $_POST['t']; $btn = trim($_POST['bname']); $tname= $_POST['tname']; $fan_page= $_POST['fanpage']; $file=$_POST['f']; $location=$_POST['l']; $mode=$_POST['mode']; $bid=$_POST['bid']; if ($location == "local") { $file = ":SHAAGE_FILE:".SHAAGI_UPLOAD_URL."/".basename($file); } $shortcode = '[shaagi-button name="'.$btn.'"]'; if($mode=="add") { $sql_insert = "insert into ".$tbl_shareandgetit_buttons." values('','$fan_page','$tname','$btn','$tweet','$file','$shortcode')"; $out=$wpdb->query($sql_insert); } else if($mode=="edit") { if(strlen($_POST['f'])>0) $update_string=",file_path='$file'"; $sql_update = "update ".$tbl_shareandgetit_buttons." set fan_page_url='$fan_page', twitter_name='$tname',post='$tweet' ".$update_string." where id=$bid;"; $out=$wpdb->query($sql_update); } if(is_bool($out) && $out == false) { echo "
".__("Failed to $mode button, change button name and try again",SHAAGI_TRASNLATE)."!
"; } else if (!$out) { echo "
".__("Failed to $mode button, change some button attributes and try again",SHAAGI_TRASNLATE)."!
"; } else { echo "

".__("Your button is ready",SHAAGI_TRASNLATE)." !
".__("copy / paste this code in your posts, pages and widgets",SHAAGI_TRASNLATE)." !

".$shortcode.'
'; } die(); } ?> Luca Ricatti - Chitarra, fingerpicking e sopravvivenza