Plugin Directory

Changeset 1854499


Ignore:
Timestamp:
04/07/2018 12:13:27 PM (8 years ago)
Author:
macmonir
Message:

changed table name wp_to db prefix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nomination-and-voting/trunk/voting.php

    r1348359 r1854499  
    33Plugin Name: nomination and voting
    44Plugin URI: #
    5 Description: nomination and voting 
     5Description: nomination and voting
    66Author: macmonir
    77Version: 1.1
     
    1212function wpnv_install(){
    1313    global $wpdb;
    14    
     14
    1515       $table_name1 = $wpdb->prefix . "nv_nomination";
    1616       $table_name2 = $wpdb->prefix . "nv_nominee";
     
    1818       $table_name4 = $wpdb->prefix . "nv_vote";
    1919
    20          
     20
    2121       $sql1 = "CREATE TABLE IF NOT EXISTS ".$table_name1." (
    2222  `id` int(11) NOT NULL AUTO_INCREMENT,
     
    2626  PRIMARY KEY (`id`)
    2727) ENGINE=MyISAM  DEFAULT CHARSET=latin1";
    28    
     28
    2929    $sql2 = "CREATE TABLE IF NOT EXISTS ".$table_name2." (
    3030  `id` int(11) NOT NULL AUTO_INCREMENT,
    3131  `nominee_name` varchar(255) NOT NULL,
    3232  PRIMARY KEY (`id`)
    33 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1"; 
     33) ENGINE=MyISAM  DEFAULT CHARSET=latin1";
    3434
    3535$sql3 = "CREATE TABLE IF NOT EXISTS ".$table_name3." (
     
    3838  `name` varchar(255) DEFAULT NULL,
    3939  PRIMARY KEY (`id`)
    40 ) ENGINE=MyISAM  DEFAULT CHARSET=latin1"; 
     40) ENGINE=MyISAM  DEFAULT CHARSET=latin1";
    4141
    4242$sql4 = "CREATE TABLE IF NOT EXISTS ".$table_name4." (
     
    4646  `category` int(11) NOT NULL,
    4747  PRIMARY KEY (`id`)
    48 ) ENGINE=MyISAM DEFAULT CHARSET=latin1"; 
    49    
     48) ENGINE=MyISAM DEFAULT CHARSET=latin1";
     49
    5050       require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
    5151       dbDelta($sql1);
     
    5656}
    5757
    58 function wpnv_custom_init() 
     58function wpnv_custom_init()
    5959{
    6060  $labels = array(
     
    6969    'search_items' => __('Search Voting Poll'),
    7070    'not_found' =>  __('No Voting Poll found'),
    71     'not_found_in_trash' => __('No Voting Poll found in Trash'), 
     71    'not_found_in_trash' => __('No Voting Poll found in Trash'),
    7272    'parent_item_colon' => '',
    7373    'menu_name' => 'Vote'
     
    7878    'public' => true,
    7979    'publicly_queryable' => true,
    80     'show_ui' => true, 
    81     'show_in_menu' => true, 
     80    'show_ui' => true,
     81    'show_in_menu' => true,
    8282    'query_var' => true,
    8383    'rewrite' => true,
    8484    'capability_type' => 'post',
    85     'has_archive' => true, 
     85    'has_archive' => true,
    8686    'hierarchical' => false,
    8787    'menu_position' => null,
    8888    'supports' => array('title','editor')
    89   ); 
     89  );
    9090  register_post_type('vote',$args);
    91  
    92  
     91
     92
    9393  // Add new taxonomy, make it hierarchical (like categories)
    9494  $labels = array(
     
    9999    'parent_item' => __( 'Parent VotingCategory' ),
    100100    'parent_item_colon' => __( 'Parent VotingCategory:' ),
    101     'edit_item' => __( 'Edit VotingCategory' ), 
     101    'edit_item' => __( 'Edit VotingCategory' ),
    102102    'update_item' => __( 'Update VotingCategory' ),
    103103    'add_new_item' => __( 'Add New VotingCategory' ),
    104104    'new_item_name' => __( 'New VotingCategory Name' ),
    105105    'menu_name' => __( 'VotingCategory' ),
    106   );   
     106  );
    107107
    108108  register_taxonomy('VotingCategory',array('vote'), array(
     
    118118function nomination_menu(){
    119119     //add_menu_page( "Voting", "Voting and Nomination", "administrator", "vote_nomination", "wp_nv_settings" );
    120      add_submenu_page('edit.php?post_type=vote', 'Voting and Nomination Settings', 'Settings', 'administrator', 'vote_nomination_settings', 'wp_nv_settings');   
    121      add_submenu_page('edit.php?post_type=vote', 'All Nominees', 'All Nominees', 'administrator', 'all_nominee', 'wp_nv_nominee_list');   
    122      add_submenu_page('edit.php?post_type=vote', 'All Voters', 'All Voters', 'administrator', 'all_voter', 'wp_nv_voter_list'); 
    123      
    124      
    125        
     120     add_submenu_page('edit.php?post_type=vote', 'Voting and Nomination Settings', 'Settings', 'administrator', 'vote_nomination_settings', 'wp_nv_settings');
     121     add_submenu_page('edit.php?post_type=vote', 'All Nominees', 'All Nominees', 'administrator', 'all_nominee', 'wp_nv_nominee_list');
     122     add_submenu_page('edit.php?post_type=vote', 'All Voters', 'All Voters', 'administrator', 'all_voter', 'wp_nv_voter_list');
     123
     124
     125
    126126}
    127127
     
    148148function wp_nv_nominee_list(){
    149149    global $wpdb;
    150     $where=""; 
    151     $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_nominee ". $where); 
    152     include("tpls/nominee_list.php"); 
     150    $where="";
     151    $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_nominee ". $where);
     152    include("tpls/nominee_list.php");
    153153}
    154154function wp_nv_voter_list(){
    155155
    156156    global $wpdb;
    157     $where=""; 
    158     $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_visitor wvs inner join ".$wpdb->prefix."nv_vote wv on wvs.id=wv.visitorid inner join ".$wpdb->prefix."nv_nominee wn on wn.id=wv.voterid ". $where); 
    159     include("tpls/voter_list.php"); 
     157    $where="";
     158    $data=$wpdb->get_results("select * from ".$wpdb->prefix."nv_visitor wvs inner join ".$wpdb->prefix."nv_vote wv on wvs.id=wv.visitorid inner join ".$wpdb->prefix."nv_nominee wn on wn.id=wv.voterid ". $where);
     159    include("tpls/voter_list.php");
    160160}
    161161
    162162function wp_nv_settings(){
    163        
    164       include("tpls/settings.php"); 
     163
     164      include("tpls/settings.php");
    165165}
    166166
     
    176176
    177177function wp_nomination_frontend(){
    178    
     178
    179179    //$concat= get_option("permalink_structure")?"?":"&";
    180180    $mode=get_option('_wp_nv_mode');
     
    204204        if($nid==0){
    205205            //insert into nominee
    206         $wpdb->insert( 
    207             'wp_nv_nominee',
     206        $wpdb->insert(
     207            $wpdb->prefix.'nv_nominee',
    208208            array( 'nominee_name' => $_POST['nominee']), array('%s'));
    209209            $nid=$wpdb->insert_id;
    210210        }
    211        
    212        
     211
     212
    213213        //insert into nomination
    214         $wpdb->insert( 
    215             $wpdb->prefix.'nv_nomination', 
    216             array( 
    217                 'visitorid' => $id, 
     214        $wpdb->insert(
     215            $wpdb->prefix.'nv_nomination',
     216            array(
     217                'visitorid' => $id,
    218218                'nomineeid' => $nid ,
    219                 'category' => $_POST['cat'] 
    220                
    221             ), 
    222             array( 
     219                'category' => $_POST['cat']
     220
     221            ),
     222            array(
    223223                '%d',
    224                 '%d', 
    225                 '%d' 
    226             ) 
     224                '%d',
     225                '%d'
     226            )
    227227        );
    228228        die("submitted");
     
    253253    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return;
    254254    if ( !current_user_can( 'edit_post', $post_id ) ) return;
    255    
     255
    256256    update_post_meta($post_id,'vote_category',$_POST['cat']);
    257257    update_post_meta($post_id,'voter_nomineeid',$_POST['voter_nomineeid']);
     
    271271                $nominees  =array();
    272272                $nominees_name =array();
    273                 $cat = get_post_meta($value->ID, 'vote_category',true); 
     273                $cat = get_post_meta($value->ID, 'vote_category',true);
    274274                $nominees= get_post_meta($value->ID, 'voter_nomineeid',true);
    275275                $nominees_name= get_post_meta($value->ID, 'voter_nomineename',true);
    276                
    277                  
     276
     277
    278278                if($cat){
    279                    
     279
    280280                     $catname=$data = $wpdb->get_results("select name from ".$wpdb->prefix."terms  where term_id='".$cat."' ");
    281281                      $vcat[$cat]=$catname[0]->name;
    282282                      $pid[$cat]=$value->ID;
    283283                }
    284                
     284
    285285                //if($nominees)
    286                
     286
    287287        }
    288288        include_once("tpls/asking_voting.php");
     
    290290        return;
    291291    }
    292    
     292
    293293}
    294294
     
    300300        $html="";
    301301        global $wpdb;
    302        
     302
    303303        /*print_r($nominees);
    304304        print_r($nominees_name);die();*/
    305305        $data = $wpdb->get_results("select *,wn.id as id from ".$wpdb->prefix."nv_nominee wn inner join ".$wpdb->prefix."nv_nomination wnm on wn.id=wnm.nomineeid where category='".$_POST['catid']."' group by nomineeid");
    306        
     306
    307307        if(count($data))
    308308        foreach($data as $val){
     
    327327        }
    328328        //$wpdb->last_query;
    329        
    330        
     329
     330
    331331        //echo $id;
    332332        $dataf = $wpdb->get_results("select id from ".$wpdb->prefix."nv_vote where visitorid='".$id."' and category='".$_POST['cat']."' and (social='facebook' or social='twitter')");
     
    338338            }
    339339        }
    340        
     340
    341341        //echo $count;
    342342        //insert into nomination
     
    346346                    if($_COOKIE['email']){
    347347                        $social=$_COOKIE['email'];
    348                         $wpdb->insert( 
    349                             'wp_nv_vote',
    350                             array( 
    351                                 'visitorid' => $id, 
     348                        $wpdb->insert(
     349                            $wpdb->prefix.'nv_vote',
     350                            array(
     351                                'visitorid' => $id,
    352352                                'voterid' => $_POST['nominee'],
    353                                 'category' => $_POST['cat'], 
    354                                 'social' => "facebook" 
    355                                
    356                             ), 
    357                             array( 
     353                                'category' => $_POST['cat'],
     354                                'social' => "facebook"
     355
     356                            ),
     357                            array(
    358358                                '%d',
    359                                 '%d',
    360359                                '%d',
    361                                 '%s'
    362                             )
     360                                '%d',
     361                                '%s'
     362                            )
    363363                        );
    364364                    }
     
    367367                    if($_COOKIE['twitter_anywhere_identity']){
    368368                    $social=$_COOKIE['twitter_name'];
    369                     $wpdb->insert( 
    370                         'wp_nv_vote',
    371                         array( 
    372                             'visitorid' => $id, 
     369                    $wpdb->insert(
     370                        $wpdb->prefix.'nv_vote',
     371                        array(
     372                            'visitorid' => $id,
    373373                            'voterid' => $_POST['nominee'] ,
    374                             'category' => $_POST['cat'], 
    375                             'social' => "twitter" 
    376                            
    377                         ), 
    378                         array( 
    379                             '%d',
    380                             '%d', 
    381                             '%d',
    382                             '%s' 
    383                         ) 
     374                            'category' => $_POST['cat'],
     375                            'social' => "twitter"
     376
     377                        ),
     378                        array(
     379                            '%d',
     380                            '%d',
     381                            '%d',
     382                            '%s'
     383                        )
    384384                    );
    385385                }
     
    390390                if($sc=="facebook"){
    391391                    if($_POST['tw']){
    392                        if($_COOKIE['twitter_anywhere_identity']){ 
    393                            $wpdb->insert( 
    394                                 'wp_nv_vote',
    395                                 array( 
    396                                     'visitorid' => $id, 
     392                       if($_COOKIE['twitter_anywhere_identity']){
     393                           $wpdb->insert(
     394                                $wpdb->prefix.'nv_vote',
     395                                array(
     396                                    'visitorid' => $id,
    397397                                    'voterid' => $_POST['nominee'] ,
    398                                     'category' => $_POST['cat'], 
    399                                     'social' => "twitter" 
    400                                    
    401                                 ), 
    402                                 array( 
     398                                    'category' => $_POST['cat'],
     399                                    'social' => "twitter"
     400
     401                                ),
     402                                array(
    403403                                    '%d',
    404                                     '%d',
    405404                                    '%d',
    406                                     '%s'
    407                                 )
     405                                    '%d',
     406                                    '%s'
     407                                )
    408408                            );
    409409                       }
     
    413413                    if($_POST['fb']){
    414414                        if($_COOKIE['email']){
    415                     $wpdb->insert( 
    416                         'wp_nv_vote',
    417                         array( 
    418                             'visitorid' => $id, 
     415                    $wpdb->insert(
     416                        $wpdb->prefix.'nv_vote',
     417                        array(
     418                            'visitorid' => $id,
    419419                            'voterid' => $_POST['nominee'],
    420                             'category' => $_POST['cat'], 
    421                             'social' => "facebook" 
    422                            
    423                         ), 
    424                         array( 
    425                             '%d',
    426                             '%d', 
    427                             '%d',
    428                             '%s' 
    429                         ) 
     420                            'category' => $_POST['cat'],
     421                            'social' => "facebook"
     422
     423                        ),
     424                        array(
     425                            '%d',
     426                            '%d',
     427                            '%d',
     428                            '%s'
     429                        )
    430430                    );
    431431                    }
     
    445445session_start();
    446446include_once('twitteroauth/twitteroauth.php');
    447 //require_once('config.php');   
    448    
     447//require_once('config.php');
     448
    449449    //postToTwitter(CONSUMER_KEY, CONSUMER_SECRET, oauth_token, oauth_token_secret); petalert application
    450450    postToTwitter("47CcqrU8EyPgbcZD9pmfZg","VYhl4pCsHrokZ4fiGctUnDErXL9JK6wFaOrMTn4s","125561843-zdGAagUe0bEka178R1jVYXXhC6FLbeLPYM8jZlTf","l5SUvacxP6nXqvec1AA27Gg9bu9wTdLW9PDojKUMes");
     
    454454function postToTwitter($CONSUMER_KEY, $CONSUMER_SECRET, $oauth_token, $oauth_token_secret){
    455455    $msg=get_option('_wp_nv_fb_twiter_text1');
    456    
     456
    457457    $msg=str_replace("{nominee}",$_POST['name'],$msg);
    458458    $connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $oauth_token, $oauth_token_secret);
     
    460460    //var_dump($content->response);
    461461    //print_r($content);
    462     $connection->post('statuses/update', array('status' => $msg));     
    463     } 
    464 
    465 
    466 
    467  
     462    $connection->post('statuses/update', array('status' => $msg));
     463    }
     464
     465
     466
     467
    468468wp_enqueue_script("jquery");
    469 wp_enqueue_script('jquery-form'); 
     469wp_enqueue_script('jquery-form');
    470470wp_enqueue_script('jquery-cookie',plugins_url("/nomination-and-voting/js/jquery.cookie.js"));
    471471if(is_admin()){
     
    477477    //metabox
    478478    //add_action( 'add_meta_boxes', 'wpnv_add_custom_box' );
    479    
    480 }
    481 add_action("wp_head","wp_nomination_frontend"); 
     479
     480}
     481add_action("wp_head","wp_nomination_frontend");
    482482add_action("init","wp_nomination_submit");
    483483add_action("init","nominee_for_cat");
Note: See TracChangeset for help on using the changeset viewer.