Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11

Discussione: Errore funzione

  1. #1

    Errore funzione

    Uff è da 2 giorni che sto provando a risolvere questo errore... ma niente da fare... praticamente un amico (tedesco) mi ha dato un file .php che dovrebbe inserire in tutti i blog (basati su wordpress) dei banner.... ma mi da questo errore

    codice:
    Fatal error: Call to undefined function: get_ads() in /var/www/vhosts/ilblog.it/httpdocs/wp-inst/wp-content/mu-plugins/tk_ads.php on line 123
    La riga 123 è

    Codice PHP:
    $ads get_ads(); 
    e fa parte della funzione

    Codice PHP:
        function action_display_ads() {
            
    $ads get_ads();
        } 
    Se volete vi posto tutto il file... anzi lo posto

    Codice PHP:
    class TK_ads {
        var 
    $version "20051017";
        var 
    $db_version "20051017"//may differ from $version !
        
    var $settings;
        
    function 
    get_ads() {
            if (empty(
    $this->ads)) {
            global 
    $wpdb;
            
    $query "SELECT * from `" $wpdb->tk_ads_types "`";
            
    $this->ads $wpdb->getVar($query);
            }
            return 
    $this->ads;    
        }
        
        function 
    TK_ads() {
            global 
    $wpdb;
            
    $this->wpdb_tables();
            
    add_action('admin_menu', array(&$this'admin_menu'));
            
    add_action('admin_footer', array(&$this'admin_footer'));
            
    $this->settings get_settings('tk-ads');
            
            
            if( empty(
    $this->settings)
                || 
    $wpdb->get_var("show tables like '".$wpdb->tk_ads."'" ) != $wpdb->tk_ads
                
    || $wpdb->get_var("show tables like '".$wpdb->tk_ads_types."'" ) != $wpdb->tk_ads_types) {
                
    $this->make_tables();
            }
            else if (
    $this->settings['table_version'] != $this->table_version) {
                
    $this->make_tables();
                
    $this->added_tables true;
            }
        }
        
        
        
        function 
    admin_footer() {
            
    update_option('tk-ads'$this->settings);
        }
        
        
        function 
    admin_menu() {
            
    $pfile basename(dirname(__FILE__)) . '/' basename(__FILE__);
            
    add_submenu_page('edit.php'__('Advertisement'), __('Advertisement'), 0$pfile, array(&$this'plugin_content'));
        }
        
        
        function 
    wpdb_tables() {
            global 
    $wpdb$table_prefix;

            
    $wpdb->tk_ads  "tk_ads";
            
    $wpdb->tk_ads_types  "tk_ads_types";
        }

        
        function 
    make_tables() {
            global 
    $wpdb$table_prefix;
            if(!include_once(
    ABSPATH 'wp-admin/upgrade-functions.php')) {
                die(
    _e('There is was error adding the required tables to the database.  Please refer to the documentation regarding this issue.''tk_ads'));
            }
            
    $query "CREATE TABLE " $wpdb->tk_ads " (
                ad_id int(11) NOT NULL,
                theme_name varchar(255) NOT NULL,
                PRIMARY KEY (ad_id)
                );"
    ;
            
    $wpdb->query$query );
            
    $query "CREATE TABLE " $wpdb->tk_ads_types " (
                ad_id int(11) NOT NULL auto_increment,
                name CHAR(63) NOT NULL,
                content TEXT NOT NULL DEFAULT '',
                PRIMARY KEY  (ad_id)
                );"
    ;
            
    $wpdb->query$query );

            
    $this->settings['table_version'] = $this->table_version;
            
    update_option('tk-ads'$this->settings);
        }

        function 
    plugin_content() {
        
            global 
    $wpdb;
            
    $action 'display';
            if (isset(
    $_GET['action']))
                
    $action $_GET['action'];
            
            
    // to split up the actions we use several methods for them. looks nicer
            
    if (method_exists($this'action_'.$action))
                
    call_user_method('action_'.$action$this);
        }
            
        function 
    action_display() {
            
    $this->action_display_ads();
            
    $this->action_display_themes();
        }
        
        
        function 
    action_display_ads() {
            
    $ads get_ads();
        }
        
        function 
    action_display_themes() {
            
    $themes =  array_values(get_themes());
            
    $ads $this->get_ads();
            
    $background_colors = array('#FFFFFF''#EEEEEE''#DDDDDD');

            
    // assume there's at least one theme...
            
    printf('<div class="wrap">
    <table class="themes">
        <tr>
            <th>'
    .__('Theme').'</th>
            <th>'
    .__('Description').'</th>
            <th>'
    .__('Advertisement').'</th>
        </tr>
    '
    );
            for (
    $i=0$i count($themes); $i++) {
                
    printf('
        <tr style="background-color:%s;">
            <td>%s</td>
            <td>%s</td>
            <td>%s</td>
        </tr>
            '
    $background_colors[$i count($background_colors)],
                
    $themes[$i]['Name'],
                
    $themes[$i]['Description'],
                
    $this->html_select($ads"themes[".$themes[$i]['Name']."]"
                                                     
    $ads[$themes[$i]['Name']])
                );
            }
            
    printf("\n\n</table>\n\n</div>");
        }
        
        
        

        
        function 
    html_select(&$options, &$default) {
            
        }
    }



    $tk_ads = new TK_Ads(); 
    Non so piu dove sbattere la testa... a questo tipo non riesco piu a contattarlo...
    Riuscite ad aiutarmi? Grazie molte
    http://WWW.HOSTINGTALK.IT
    Forum italiano dedicato all'hosting

  2. #2
    Utente di HTML.it L'avatar di raf86
    Registrato dal
    Feb 2001
    Messaggi
    175
    penso che essendo in una classe ci devi accedere tramite un'istanza
    Staiano Raffaele: web agency di Realizzazione siti web, posizionamento siti internet e molto altro

  3. #3
    si infatti quella pagina viene aperta tramite un'altra pagina es

    http://luca.ilblog.it/wp-admin/edit....ins/tk_ads.php

    questo che volevi dire?
    Grazie molte
    http://WWW.HOSTINGTALK.IT
    Forum italiano dedicato all'hosting

  4. #4
    Utente di HTML.it L'avatar di raf86
    Registrato dal
    Feb 2001
    Messaggi
    175
    intendevo dire che essendo una classe, devi creare un oggetto (istanziare) riferito a quella classe. a quel punto puoi accedere alle funzioni contenute in quella classe. se fosse stata una funzione static (non so se in php4 si possa fare) sarebbe stato possibile accedervi direttamente (usando il nome della classe) senza creare l'oggetto
    Staiano Raffaele: web agency di Realizzazione siti web, posizionamento siti internet e molto altro

  5. #5
    capito grazie...
    ora il problema è... come la creo? il file postato non l'ho creato io e non so minimamente come creare un oggetto e il tipo che ha creato il file risulta irraggiungibile ormai da giorni :rollo:
    Come potrei fare?
    http://WWW.HOSTINGTALK.IT
    Forum italiano dedicato all'hosting

  6. #6
    UP
    http://WWW.HOSTINGTALK.IT
    Forum italiano dedicato all'hosting

  7. #7
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    591
    già provato con
    codice:
    function action_display_ads() { 
            $ads = $this->get_ads(); 
        }
    ?

  8. #8
    Ciao e grazie della reply,
    ho provato e dice

    codice:
    Fatal error: Call to undefined function: getvar() in /var/www/vhosts/ilblog.it/httpdocs/wp-inst/wp-content/mu-plugins/tk_ads.php on line 36
    linea 36

    Codice PHP:
    $this->ads $wpdb->getVar($query); 
    che fa parte della funzione

    Codice PHP:
    function get_ads() {
            if (empty(
    $this->ads)) {
            global 
    $wpdb;
            
    $query "SELECT * from `" $wpdb->tk_ads_types "`";
            
    $this->ads $wpdb->getVar($query);
            }
            return 
    $this->ads;    
        } 
    Grazie molte
    http://WWW.HOSTINGTALK.IT
    Forum italiano dedicato all'hosting

  9. #9
    Utente di HTML.it
    Registrato dal
    May 2003
    Messaggi
    591
    sembri essere un passo avanti ( se quel che ti ho suggerito ha un senso) ora devi trovare xchè $wpdb non sembra istanziata ( global ma manca la new x cui non trova il metodo)

  10. #10
    e quindi?...
    e grazie molte
    http://WWW.HOSTINGTALK.IT
    Forum italiano dedicato all'hosting

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.