+ Cevap Yaz
Toplam 28 sayfadan 16. sayfa İlkİlk ... 6 12 13 14 15 16 17 18 19 20 26 ... En SonEn Son
280 sonuçtan 151 ile 160 arası gösteriliyor

Konu: Kütüphane

  1. #151
    anilkan Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    01/2007
    Yer
    İzmirliyiz dedik ya ...
    Mesaj
    64
    Ceviz Üyesi

    Varsayılan

    3 Katmanlı Mimari ve PHP (di sanırım) yazısındaki class.page.php den esinlenerek kendi kullanımım için oluşturduğum page classım. Eksiklerini tamamiyle test etme imkanım olmadı. Bu haliyle localde düzgün çalışıyor.

    PHP Kodu:
    <?
    class Page
    {
        var 
    $WhitePage = array('about','resim','blog');
        var 
    $page;
        
        
        function 
    Page()
        {
            
            
            if(empty(
    $_REQUEST['module'])){$this->page   "about";
            }else{
            
                if(
    in_array($_REQUEST['module'], $this->WhitePage)){$this->page   $_REQUEST['module'];
                }else{
                
    $this->page  "about";            
                }
                
            
            }
            
    $this->page     =  $this->ClearPage($this->page);
            
    $this->ClearGlobals;
            
    $this->pagedir  =  $this->IncludePage();
        }
        
        
        function 
    IncludePage()
        {
            switch(
    $this->page)
            {
                case 
    "about" :
                    
    $IPage $this->AddPage("about");
                break;
                case 
    "resim" :
                    
    $IPage $this->AddPage("resim");
                break;
                case 
    "blog" :
                    
    $IPage $this->AddPage("blog");
                break;
                default :
                    
    $IPage $this->AddPage("about");
            }
            
            if(!
    $IPage){
                
    $IPage $this->AddPage("about");
            }
            
            return 
    $IPage;
        }
        
        
        function 
    AddPage($veri)
        {
            
    $APage "page/" $veri ".php";
            return 
    $APage;
        }
        
        
        function 
    ClearPage($page)
        {
            
    $page         = (!isset($page)) ? "about" $page;
            
    $page         str_replace(array(":""/""..""."";""\\""http""ftp"), ""$page);    
            
            return 
    $page;    
        }
        
        
        function 
    ClearGlobals()
        {
            if (!
    get_magic_quotes_gpc()) 
            {
                @
    $_REQUEST  $this->Escape($_REQUEST);
                @
    $_POST     $this->Escape($_POST);
                @
    $_GET      $this->Escape($_GET);
                @
    $_COOKIE   $this->Escape($_COOKIE);
                @
    $_SESSION  $this->Escape($_SESSION);
                @
    $_SERVER   $this->Escape($_SERVER);
            }

        }
        
        
    }
    ?>
    Kullanımı :
    index.php
    PHP Kodu:
    $page    = new Page();
    @include (
    "$page->pagedir"); 
    Enson 17/09/2007 17:32 tarihinde anilkan tarafından düzenlenmiştir. Sebep: imla hatası

  2. #152

    Üyelik Tarihi
    09/2007
    Mesaj
    410
    Ceviz Üyesi

    Varsayılan

    ezSQL CLASS;

    PHP Kodu:
    ez_sql_mysql.php
    <?php

        
    /**********************************************************************
        *  Author: Justin Vincent (justin@visunet.ie)
        *  Web...: http://php.justinvincent.com
        *  Name..: ezSQL_mysql
        *  Desc..: mySQL component (part of ezSQL databse abstraction library)
        *
        */

        /**********************************************************************
        *  ezSQL error strings - mySQL
        */

        
    $ezsql_mysql_str = array
        (
            
    => 'Require $dbuser and $dbpassword to connect to a database server',
            
    => 'Error establishing mySQL database connection. Correct user/password? Correct hostname? Database server running?',
            
    => 'Require $dbname to select a database',
            
    => 'mySQL database connection is not active',
            
    => 'Unexpected error while trying to select database'
        
    );

        
    /**********************************************************************
        *  ezSQL Database specific class - mySQL
        */

        
    if ( ! function_exists ('mysql_connect') ) die('<b>Fatal Error:</b> ezSQL_mysql requires mySQL Lib to be compiled and or linked in to the PHP engine');
        if ( ! 
    class_exists ('ezSQLcore') ) die('<b>Fatal Error:</b> ezSQL_mysql requires ezSQLcore (ez_sql_core.php) to be included/loaded before it can be used');

        class 
    ezSQL_mysql extends ezSQLcore
        
    {

            var 
    $dbuser false;
            var 
    $dbpassword false;
            var 
    $dbname false;
            var 
    $dbhost false;

            
    /**********************************************************************
            *  Constructor - allow the user to perform a qucik connect at the
            *  same time as initialising the ezSQL_mysql class
            */

            
    function ezSQL_mysql($dbuser=''$dbpassword=''$dbname=''$dbhost='localhost')
            {
                
    $this->dbuser $dbuser;
                
    $this->dbpassword $dbpassword;
                
    $this->dbname $dbname;
                
    $this->dbhost $dbhost;
            }

            
    /**********************************************************************
            *  Short hand way to connect to mySQL database server
            *  and select a mySQL database at the same time
            */

            
    function quick_connect($dbuser=''$dbpassword=''$dbname=''$dbhost='localhost')
            {
                
    $return_val false;
                if ( ! 
    $this->connect($dbuser$dbpassword$dbhost,true) ) ;
                else if ( ! 
    $this->select($dbname) ) ;
                else 
    $return_val true;
                return 
    $return_val;
            }

            
    /**********************************************************************
            *  Try to connect to mySQL database server
            */

            
    function connect($dbuser=''$dbpassword=''$dbhost='localhost')
            {
                global 
    $ezsql_mysql_str$return_val false;

                
    // Must have a user and a password
                
    if ( ! $dbuser )
                {
                    
    $this->register_error($ezsql_mysql_str[1].' in '.__FILE__.' on line '.__LINE__);
                    
    $this->show_errors trigger_error($ezsql_mysql_str[1],E_USER_WARNING) : null;
                }
                
    // Try to establish the server database handle
                
    else if ( ! $this->dbh = @mysql_connect($dbhost,$dbuser,$dbpassword,true) )
                {
                    
    $this->register_error($ezsql_mysql_str[2].' in '.__FILE__.' on line '.__LINE__);
                    
    $this->show_errors trigger_error($ezsql_mysql_str[2],E_USER_WARNING) : null;
                }
                else
                {
                    
    $this->dbuser $dbuser;
                    
    $this->dbpassword $dbpassword;
                    
    $this->dbhost $dbhost;
                    
    $return_val true;
                }

                return 
    $return_val;
            }

            
    /**********************************************************************
            *  Try to select a mySQL database
            */

            
    function select($dbname='')
            {
                global 
    $ezsql_mysql_str$return_val false;

                
    // Must have a database name
                
    if ( ! $dbname )
                {
                    
    $this->register_error($ezsql_mysql_str[3].' in '.__FILE__.' on line '.__LINE__);
                    
    $this->show_errors trigger_error($ezsql_mysql_str[3],E_USER_WARNING) : null;
                }

                
    // Must have an active database connection
                
    else if ( ! $this->dbh )
                {
                    
    $this->register_error($ezsql_mysql_str[4].' in '.__FILE__.' on line '.__LINE__);
                    
    $this->show_errors trigger_error($ezsql_mysql_str[4],E_USER_WARNING) : null;
                }

                
    // Try to connect to the database
                
    else if ( !@mysql_select_db($dbname,$this->dbh) )
                {
                    
    // Try to get error supplied by mysql if not use our own
                    
    if ( !$str = @mysql_error($this->dbh))
                          
    $str $ezsql_mysql_str[5];

                    
    $this->register_error($str.' in '.__FILE__.' on line '.__LINE__);
                    
    $this->show_errors trigger_error($str,E_USER_WARNING) : null;
                }
                else
                {
                    
    $this->dbname $dbname;
                    
    $return_val true;
                }

                return 
    $return_val;
            }

            
    /**********************************************************************
            *  Format a mySQL string correctly for safe mySQL insert
            *  (no mater if magic quotes are on or not)
            */

            
    function escape($str)
            {
                return 
    mysql_escape_string(stripslashes($str));
            }

            
    /**********************************************************************
            *  Return mySQL specific system date syntax
            *  i.e. Oracle: SYSDATE Mysql: NOW()
            */

            
    function sysdate()
            {
                return 
    'NOW()';
            }

            
    /**********************************************************************
            *  Perform mySQL query and try to detirmin result value
            */

            
    function query($query)
            {

                
    // Initialise return
                
    $return_val 0;

                
    // Flush cached values..
                
    $this->flush();

                
    // For reg expressions
                
    $query trim($query);

                
    // Log how the function was called
                
    $this->func_call "\$db->query(\"$query\")";

                
    // Keep track of the last query for debug..
                
    $this->last_query $query;

                
    // Count how many queries there have been
                
    $this->num_queries++;

                
    // Use core file cache function
                
    if ( $cache $this->get_cache($query) )
                {
                    return 
    $cache;
                }

                
    // If there is no existing database connection then try to connect
                
    if ( ! isset($this->dbh) || ! $this->dbh )
                {
                    
    $this->connect($this->dbuser$this->dbpassword$this->dbhost);
                    
    $this->select($this->dbname);
                }

                
    // Perform the query via std mysql_query function..
                
    $this->result = @mysql_query($query,$this->dbh);

                
    // If there is an error then take note of it..
                
    if ( $str = @mysql_error($this->dbh) )
                {
                    
    $is_insert true;
                    
    $this->register_error($str);
                    
    $this->show_errors trigger_error($str,E_USER_WARNING) : null;
                    return 
    false;
                }

                
    // Query was an insert, delete, update, replace
                
    $is_insert false;
                if ( 
    preg_match("/^(insert|delete|update|replace)\s+/i",$query) )
                {
                    
    $this->rows_affected = @mysql_affected_rows();

                    
    // Take note of the insert_id
                    
    if ( preg_match("/^(insert|replace)\s+/i",$query) )
                    {
                        
    $this->insert_id = @mysql_insert_id($this->dbh);
                    }

                    
    // Return number fo rows affected
                    
    $return_val $this->rows_affected;
                }
                
    // Query was a select
                
    else
                {

                    
    // Take note of column info
                    
    $i=0;
                    while (
    $i < @mysql_num_fields($this->result))
                    {
                        
    $this->col_info[$i] = @mysql_fetch_field($this->result);
                        
    $i++;
                    }

                    
    // Store Query Results
                    
    $num_rows=0;
                    while ( 
    $row = @mysql_fetch_object($this->result) )
                    {
                        
    // Store relults as an objects within main array
                        
    $this->last_result[$num_rows] = $row;
                        
    $num_rows++;
                    }

                    @
    mysql_free_result($this->result);

                    
    // Log number of rows the query returned
                    
    $this->num_rows $num_rows;

                    
    // Return number of rows selected
                    
    $return_val $this->num_rows;
                }

                
    // disk caching of queries
                
    $this->store_cache($query,$is_insert);

                
    // If debug ALL queries
                
    $this->trace || $this->debug_all $this->debug() : null ;

                return 
    $return_val;

            }

        }

    ?>
    PHP Kodu:
    #disk_cache_example.php
    <?php

        
    // Standard ezSQL Libs
        
    include_once "../shared/ez_sql_core.php";
        include_once 
    "ez_sql_mysql.php";

        
    // Initialise singleton
        
    $db = new ezSQL_mysql('db_user''db_pass''db_name');

        
    // Cache expiry
        
    $db->cache_timeout 24// Note: this is hours

        // Specify a cache dir. Path is taken from calling script
        
    $db->cache_dir 'ezsql_cache';

        
    // (1. You must create this dir. first!)
        // (2. Might need to do chmod 775)

        // Global override setting to turn disc caching off
        // (but not on)
        
    $db->use_disk_cache true;

        
    // By wrapping up queries you can ensure that the default
        // is NOT to cache unless specified
        
    $db->cache_queries true;

            
    // At last.. a query!
            
    $db->get_results("SHOW TABLES");
            
    $db->debug();

            
    // Select * from use
            
    $db->get_results("SELECT * FROM User");
            
    $db->debug();

        
    // This ensures only the above querys are cached
        
    $db->cache_queries false;

        
    // This query is NOT cached
        
    $db->get_results("SELECT * FROM User LIMIT 0,1");
        
    $db->debug();

    /*

        Of course, if you want to cache EVERYTHING just do..

        $db = new ezSQL_mysql('db_user', 'db_pass', 'db_name');
        $db->use_disk_cache = true;
        $db->cache_queries = true;
        $db->cache_timeout = 24;

    */

    ?>
    PHP Kodu:
    #demo.php
    <?php

        
    /**********************************************************************
        *  ezSQL initialisation for mySQL
        */

        // Include ezSQL core
        
    include_once "../shared/ez_sql_core.php";

        
    // Include ezSQL database specific component
        
    include_once "ez_sql_mysql.php";

        
    // Initialise database object and establish a connection
        // at the same time - db_user / db_password / db_name / db_host
        
    $db = new ezSQL_mysql('db_user','db_password','db_name','db_host');

        
    /**********************************************************************
        *  ezSQL demo for mySQL database
        */

        // Demo of getting a single variable from the db
        // (and using abstracted function sysdate)
        
    $current_time $db->get_var("SELECT " $db->sysdate());
        print 
    "ezSQL demo for mySQL database run @ $current_time";

        
    // Print out last query and results..
        
    $db->debug();

        
    // Get list of tables from current database..
        
    $my_tables $db->get_results("SHOW TABLES",ARRAY_N);

        
    // Print out last query and results..
        
    $db->debug();

        
    // Loop through each row of results..
        
    foreach ( $my_tables as $table )
        {
            
    // Get results of DESC table..
            
    $db->get_results("DESC $table[0]");

            
    // Print out last query and results..
            
    $db->debug();
        }

    ?>

  3. #153
    m.erin Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    04/2005
    Yer
    GOCA GONYA
    Mesaj
    416
    İnterneti Kurtaran Adam

    Varsayılan Basit veri sayfalama sınıfı

    Benim işimi fazlasıyla görüyor, çoğu arkadaşınkini de görecektir geliştirilebilir.
    Boş bir vaktimde VBulletin' de veya Wordpress' de olduğu gibi (1 2 3 ... 20) linkler olacak şekilde geliştirmeyi planlıyorum. Aslında bir fonksiyon ile de halledilebilir ama sınıf yapısını yeni yeni öğrenmeye başlıyorum, kendimi geliştirmek adına yazdım. Umarım faydalı olur.

    kgPager.class.php
    PHP Kodu:
    <?PHP
    /*
    #--> kgPager v0.1 basit veri sayfalama sınıfı <--#
    Yazar    : Muharrem ERİN
    E-Posta    : info@muharremerin.com
    Web        : www.muharremerin.com / www.mhrrmrn.com / www.kisiselgunce.com
    Tarih    : 01 Kasım 2007 / Perşembe
    */
    class kgPager {
        var 
    $total;
        var 
    $total_page;
        var 
    $this_page;
        var 
    $start;
        var 
    $limit;
        var 
    $pager_link;
        var 
    $pager_content;
        function 
    pager($query$limit$pg$url$previous_next) {
            
    $this -> total mysql_num_rows(mysql_query($query));
            
    $sql mysql_query($query);
            if (!
    is_numeric($pg)) { $pg 1; }
            if (
    $pg == 1) { $start 0; }else{ $start = ($pg 1) * $limit; }
            
    $total_page ceil(($this -> total) / $limit);
            if (
    $pg != 1) { $previous_page $pg 1; }
            if (
    $pg $total_page) { $next_page $pg 1; }
            if (
    $previous_next == true and $pg and $previous_page 0) { $pager_link .= '<a href="'.$url.$previous_page.'">&lt;&lt;</a> '; }
            for (
    $i 1$i <= $total_page$i++) {
                if (
    $pg == $i) { $pager_link .= '<span class="this_page">['.$i.'] </span>'; }else{ $pager_link .= '<a href="'.$url.$i.'">'.$i.'</a> '; }
            }
            if (
    $previous_next == true and $total_page and $next_page 0) { $pager_link .= '<a href="'.$url.$next_page.'">&gt;&gt;</a> '; }
            
    $this -> total_page $total_page;
            
    $this -> start $start;
            
    $this -> limit $limit;
            
    $this -> this_page $pg;
            
    $this -> pager_link $pager_link;
            
    $sql mysql_query(" ".$query." LIMIT ".$this -> start.", ".$this -> limit."");
            if (
    $pg == 1) { $i 1; }else{ $i = ($pg $limit) - $limit 1; }
            while (
    $read mysql_fetch_assoc($sql)) {
                
    $pager_content .= 'SIRA: '.$i.' - ID:'$read['id'].' - Title: '.stripslashes($read['title']).'<br />';
            
    $i++;
            }
            
    $this -> pager_content $pager_content;
        }
    }
    ?>
    Kullanımı (index.php)
    PHP Kodu:
    <?PHP
    header
    ('Content-Type: text/html; charset=utf-8');
    require_once(
    'kgPager.class.php');
    $conn mysql_pconnect('localhost''root''');
    $select mysql_select_db('content_db');
    mysql_query("SET NAMES 'utf8'");

    $query 'SELECT id, title FROM contents'// sql

    $url 'index.php?pg='// sayfa linki
    $limit 5// Her sayfada kaç veri gösterilecek
    $previous_next true// true : ileri ve geri linkleri olsun / false : olmasın

    $pager_obj = new kgPager();
    $pager_obj -> pager($query$limit$_GET['pg'], $url$previous_next);
    echo 
    '<p>'.$pager_obj -> pager_content.'</p>';
    if (
    $pager_obj -> total_page 0) { echo '<p>Sayfalar: '.$pager_obj -> pager_link.'</p>'; }
    echo 
    '<p>Toplamda <strong>'.$pager_obj -> total.'</strong> adet veri <strong>'.$pager_obj -> total_page.'</strong> sayfada gösteriliyor. Şu anda <strong>'.floor($pager_obj -> this_page).'</strong>. sayfadasınız.</p>';
    ?>
    Örnek SQL :
    Kod:
    CREATE TABLE `contents` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `title` varchar(255) NOT NULL,
      `content` longtext NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=0 ;
    

  4. #154

    Üyelik Tarihi
    01/2007
    Mesaj
    354
    Üyeliği İptal Edildi

    Varsayılan

    türkçe karakterine çözüm için geliştirdiğim bir fonksiyon, kend, kütüphanemden birtane yayınlayayım dedim
    siz & # arasındaki boşluğu silersiniz, vb otomatik türkçeye çeviriyor çünkü bu sistemi vb'de kullanıyor.


    PHP Kodu:
     function non_ascii(&$veri$decode false)
    {
        
    $search   = array("!""\"""$""%""'""("")"","":"";""<""="">""[""\\""]""^""`""´""{""|""}""~""?""\n"" ","ş""Ş""ğ""Ğ""ü""Ü""ö""Ö""ç""Ç""ı""İ""¨""æ""ß""€");
        
    $replace  = array("& #33;""& #34;""& #36;""& #37;""& #39;""& #40;""&  #41;""& #44;""& #58;""& #59;""& #60;""& #61;""& #62;""& #91;""& #92;""&  #93;""& #94;""& #96;""& #180;""& #123;""& #124;""& #125;""& #126;""& #63;""& #13;& #10;""& #32;""& #351;""& #350;""& #287;""& #286;""& #252;""& #220;""& #246;""& #214;""& #231;""& #199;""& #305;""& #304;""& #168;""& #230;""& #223;""& #8364;");
        if(
    $decode)
        
    $veri       =& str_replace($replace$search,    $veri);
        else
        
    $veri       =& str_replace($search$replace$veri);
        return 
    $veri;

    kullanımı

    encode için
    Kod:
    $veri = "türkçe karakterler kullanın işte";
    $veri = non_ascii($veri);
    
    decode için
    Kod:
    $veri = "türkçe karakterler kullanın işte";
    $veri = non_ascii($veri, true);
    
    utf8'de vs. oto decode oluyor zaten ama ne olur ne olmaz diye. artık veritabanın bozulmasına son.

  5. #155
    Felix Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    02/2006
    Yer
    Bursa
    Mesaj
    197
    Ceviz Üyesi

    Varsayılan

    Faktöriyel fonksiyonu:
    Kod:
    function faktoriyel($a) {
    if ($a == 1 or $a==0) {
    return 1;
    } else {
    $i= 2;
    $temp=1;
    while($i < $a) {
    $temp= $temp*$i;
    $i++;
    }
    return $temp*$a;
    }
    }//faktoriyel fonksiyonu sonu
    
    Matematik ödevim için az önce kodladım.
    Proletarier aller Länder, vereinigt euch!

  6. #156
    sineld Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    09/2005
    Yer
    Php.Net
    Mesaj
    1,265
    aynanın "Amca" dediği

    Tamam

    Alıntı Lisans, mesajından alıntı: Mesajı Gör
    türkçe karakterine çözüm için geliştirdiğim bir fonksiyon, kend, kütüphanemden birtane yayınlayayım dedim
    siz & # arasındaki boşluğu silersiniz, vb otomatik türkçeye çeviriyor çünkü bu sistemi vb'de kullanıyor.


    PHP Kodu:
     function non_ascii(&$veri$decode false)
    {
        
    $search   = array("!""\"""$""%""'""("")"","":"";""<""="">""[""\\""]""^""`""´""{""|""}""~""?""\n"" ","ş""Ş""ğ""Ğ""ü""Ü""ö""Ö""ç""Ç""ı""İ""¨""æ""ß""€");
        
    $replace  = array("& #33;""& #34;""& #36;""& #37;""& #39;""& #40;""&  #41;""& #44;""& #58;""& #59;""& #60;""& #61;""& #62;""& #91;""& #92;""&  #93;""& #94;""& #96;""& #180;""& #123;""& #124;""& #125;""& #126;""& #63;""& #13;& #10;""& #32;""& #351;""& #350;""& #287;""& #286;""& #252;""& #220;""& #246;""& #214;""& #231;""& #199;""& #305;""& #304;""& #168;""& #230;""& #223;""& #8364;");
        if(
    $decode)
        
    $veri       =& str_replace($replace$search,    $veri);
        else
        
    $veri       =& str_replace($search$replace$veri);
        return 
    $veri;

    kullanımı

    encode için
    Kod:
    $veri = "türkçe karakterler kullanın işte";
    $veri = non_ascii($veri);
    
    decode için
    Kod:
    $veri = "türkçe karakterler kullanın işte";
    $veri = non_ascii($veri, true);
    
    utf8'de vs. oto decode oluyor zaten ama ne olur ne olmaz diye. artık veritabanın bozulmasına son.
    çok emek vermişsin, ellerine sağlık..
    sineld amcanın imzası:

    PHP Kodu:
    <?php 
    $amca
    'http://www.sinaneldem.com'
    header('Location: '.$amca); 
    ?>
    amcanın evi

  7. #157
    roviss Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    08/2003
    Yer
    Elazığ
    Mesaj
    161
    Ceviz Üyesi

    Varsayılan ...

    Flash okul sitemiz için CMS hazırlamaya karar verdiğimden ve PHP/MYSQL konusunda yumurta son noktaya dayandığından Web'de daha kalitelisini bulamadığım bu paylaşım platformunun başta forum yöneticileri olmak üzere tüm mensuplarına teşekkür ederim. Saygılarımla... (PS: Başlığa aykırı bir teşekkür olabilir, idare edin lütfen )
    imzam yok, parmak bassam olur mu ?

  8. #158
    m.erin Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    04/2005
    Yer
    GOCA GONYA
    Mesaj
    416
    İnterneti Kurtaran Adam

    Artist Sayfalama Sınıfı (forumdaki ve wp'dekine benzer)

    Merhabalar.

    http://forum.ceviz.net/showpost.php?...&postcount=153 (Kütüphane)

    Yukarıdaki linkte yazdığım sınıf kendimi NYP'da geliştirmek adına yaptığım bir alıştırmaydı. Yukarıdaki sınıfın biraz daha profesyonel hali diyebilirim. Biraz daha kompleks ve kullanışlı. Çoğu arkadaşın işine yarayacağına eminim

    Güle güle kullanın.

    kgPager.class.php
    PHP Kodu:
    <?PHP
    /*
    ########################################################################################################################
    #
    #   KG Pager v1.0
    #   Class Name  : KG Pager Class
    #   Version     : 2.0
    #   Requirement : PHP4 >
    #   Build Date  : December 17, 2007 - Monday
    #   Developer   : Muharrem ERİN (TÜRKİYE) - info@muharremerin.com - muharremerin.com - mhrrmrnr.com - kisiselgunce.com
    #   Licence     : GNU General Public License (c) 2007
    #
    ########################################################################################################################

    Sample mysql table code
    -----------------------
    CREATE TABLE `MyTable` (
      `id` int(10) unsigned NOT NULL auto_increment,
      `title` varchar(255) NOT NULL,
      `content` longtext NOT NULL,
      PRIMARY KEY  (`id`)
    ) ENGINE=MyISAM AUTO_INCREMENT=0 ;

    */

    // pager class
    class kgPager {
        var 
    $total_records NULL;
        var 
    $start NULL;
        var 
    $scroll_page NULL;
        var 
    $per_page NULL;
        var 
    $total_pages NULL;
        var 
    $current_page NULL;
        var 
    $page_links NULL;

        
    // total pages and essential variables
        
    function total_pages ($pager_url$total_records$scroll_page$per_page$current_page) {
            
    $this -> url $pager_url;
            
    $this -> total_records $total_records;
            
    $this -> scroll_page $scroll_page;
            
    $this -> per_page $per_page;
            if (!
    is_numeric($current_page)) {
                
    $this -> current_page 1;
            }else{
                
    $this -> current_page $current_page;
            }
            
    $this -> total_pages intval($this -> total_records $this -> per_page);
        }

        
    // page links
        
    function page_links ($inactive_page_tag) {
            if (
    $this -> total_pages <= $this -> scroll_page) {
                
    $loop_start 1;
                
    $loop_finish $this -> total_pages;
            }else{
                if(
    $this -> current_page intval($this -> scroll_page 2) + 1) {
                    
    $loop_start 1;
                    
    $loop_finish $this -> scroll_page;
                }else{
                    
    $loop_start $this -> current_page intval($this -> scroll_page 2);
                    
    $loop_finish $this -> current_page intval($this -> scroll_page 2);
                    if (
    $loop_finish $this -> total_pages$loop_finish $this -> total_pages;
                }
            }
            for (
    $i $loop_start$i <= $loop_finish$i++) {
                if (
    $i == $this -> current_page) {
                    
    $this -> page_links .= '<span '.$inactive_page_tag.'>'.$i.'</span>';
                }else{
                    
    $this -> page_links .= '<span><a href="'.$this -> url.$i.'">'.$i.'</a></span>';
                }
            }
        }

        
    // previous page
        
    function previous_page ($previous_page_text) {
            if (
    $this -> current_page 1) {
                
    $this -> previous_page '<span><a href="'.$this -> url.($this -> current_page 1).'">'.$previous_page_text.'</a></span>';
            }
        }

        
    // next page
        
    function next_page ($next_page_text) {
            if (
    $this -> current_page $this -> total_pages) {
                
    $this -> next_page '<span><a href="'.$this -> url.($this -> current_page 1).'">'.$next_page_text.'</a></span>';
            }
        }

        
    // first page
        
    function first_page ($first_page_text) {
            if (
    $this -> current_page 1) {
                
    $this -> first_page '<span><a href="'.$this -> url.'1">'.$first_page_text.'</a></span>'// :)
            
    }
        }

        
    // last page
        
    function last_page ($last_page_text) {
            if (
    $this -> current_page $this -> total_pages) {
                
    $this -> last_page '<span><a href="'.$this -> url.$this -> total_pages.'">'.$last_page_text.'</a></span>';
            }
        }

        
    // pages functions set
        
    function pager_set ($pager_url$total_records$scroll_page$per_page$current_page$inactive_page_tag$previous_page_text$next_page_text$first_page_text$last_page_text) {
            
    $this -> total_pages($pager_url$total_records$scroll_page$per_page$current_page);
            
    $this -> page_links($inactive_page_tag);
            
    $this -> previous_page($previous_page_text);
            
    $this -> next_page($next_page_text);
            
    $this -> first_page($first_page_text);
            
    $this -> last_page($last_page_text);
        }
    }
    ?>
    test.php
    PHP Kodu:
    <?PHP
    header
    ('Content-Type: text/html; charset=utf-8');
    require_once(
    'kgPager.class.php');
    $conn mysql_pconnect('localhost''root''');
    $select mysql_select_db('MyDB');
    mysql_query("SET NAMES 'utf8'");
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>KG Pager Class v2.0 - Test</title>
    <style type="text/css">
        body { font:0.8em/1.8em tahoma, helvetica, sans serif; color#333; }
        #pager_links a { text-decoration:none; color:#ff3300; background:#fff; border:1px solid #e0e0e0; padding:1px 4px 1px 4px; margin:2px; }
        #pager_links a:hover { text-decoration:none; color:#3399ff; background:#f2f2f2; border:1px solid #3399ff; padding:1px 4px 1px 4px; margin:2px; }
        #current_page { border:1px solid #333; padding:1px 4px 1px 4px; margin:2px; color:#333; }
    </style>
    </head>
    <body>

    <?PHP
    $query 
    "SELECT id, title FROM MyTable"// sql
    $sql mysql_query($query);
    $total_records mysql_num_rows($sql); // toplam veri sayısı
    $scroll_page 5// kaydırılacak sayfa sayısı
    $per_page 4// her sayafa gösterilecek sayfa sayısı
    $current_page $_GET['page']; // bulunulan sayfa
    $pager_url 'test.php?page='// sayfalamanın yapıldığı adres
    $inactive_page_tag 'id="current_page"'// aktif olmayan sayfa linki için biçim
    $previous_page_text '&lt; Önceki Sayfa'// önceki sayfa metni (resim de olabilir <img src="... gibi)
    $next_page_text 'Sonraki Sayfa &gt;'// sonraki sayfa metni (resim de olabilir <img src="... gibi)
    $first_page_text '&lt;&lt; İlk Sayfa'// ilk sayfa metni (resim de olabilir <img src="... gibi)
    $last_page_text 'Son Sayfa &gt;&gt;'// son sayfa metni (resim de olabilir <img src="... gibi)

    $kgPagerOBJ = & new kgPager();
    $kgPagerOBJ -> pager_set($pager_url$total_records$scroll_page$per_page$current_page$inactive_page_tag$previous_page_text$next_page_text$first_page_text$last_page_text);

    echo 
    '<p><strong>Toplam Sayfa :</strong>';
    echo 
    $kgPagerOBJ -> total_pages;
    echo 
    '</p>';
    $sql mysql_query($query." ORDER BY id ASC LIMIT ".$kgPagerOBJ -> start.", ".$kgPagerOBJ -> per_page."");
    while (
    $read mysql_fetch_assoc($sql)) {
        echo 
    '<ul>';
        echo 
    '<li>'.$read['id'].' - '.$read['title'].'</li>';
        echo 
    '</ul>';
    }
    echo 
    '<p id="pager_links">';
    echo 
    $kgPagerOBJ -> first_page;
    echo 
    $kgPagerOBJ -> previous_page;
    echo 
    $kgPagerOBJ -> page_links;
    echo 
    $kgPagerOBJ -> next_page;
    echo 
    $kgPagerOBJ -> last_page;
    echo 
    '</p>';
    ?>
    </body>
    </html>
    Kısacası aşağıdaki resimde olduğu gibi bir veri sayfalama yapar

    Görüşmek üzere.
    Eklenmiş Grafikler

  9. #159

    Üyelik Tarihi
    01/2006
    Mesaj
    155
    Ceviz Üyesi

    Varsayılan

    Herkese çok teşekkürler arkadaşlar. İşime yarayanları copy-paste yaparak aldım.

  10. #160
    m.erin Adlı Üyenin Profil Grafiği
    Üyelik Tarihi
    04/2005
    Yer
    GOCA GONYA
    Mesaj
    416
    İnterneti Kurtaran Adam

    Varsayılan kgUploader v1.0 Çoklu Dosya Yükleme Sınıfı

    Merhabalar. Bugün yazdığım bir sınıfı sizinle paylaşmak istedim. Sınıf sunucuda belirtilen dizine rahatça bir veya birden çok dosyanın yüklenmesini sağlıyor.

    kgUploader.class.php
    PHP Kodu:
    <?PHP
    #############################################################################################################
    #
    #   KG Uploader v1.0
    #   Class Name  : KG Uploader Class
    #   Version     : 1.0
    #   Requirement : PHP4 >
    #   Build Date  : January 13, 2007 - Wednesday
    #   Developer   : Muharrem ERİN - info@muharremerin.com - muharremerin.com - mhrrmrnr.com - kisiselgunce.com
    #   Licence     : GNU General Public License (c) 2007
    #
    #############################################################################################################

    // uploader class
    class kg_uploader {

        var 
    $files = array();
        var 
    $error NULL;
        var 
    $file_names = array();
        var 
    $directory NULL;
        var 
    $uploaded false;
        var 
    $uploaded_files = array();
        var 
    $file_new_name NULL;
        var 
    $results NULL;

        
    // dizin kontrolleri
        
    function directory($directory) {
            
    // dizin var mi?
            
    if (!is_dir($directory)) {
                
    $this -> error .= '<li><strong>'.$directory.'</strong> isminde bir dizin bulunamadı!</li>';
            }
            
    // dizinin yazma izni var mi?
            
    if (is_dir($path) && !is_writable($directory)) {
                
    $this -> error .= '<li><strong>'.$directory.'</strong> isimli dizine yazma izni bulunmamaktadır!</li>';
            }
            
    $this -> directory $directory;
        }

        
    // dosya bilgileri
        
    function files($files) {
            if (
    $files) {
                for (
    $i 0$i count($files); $i++) {
                    if (
    $files['name'][$i]) {
                        
    $this -> files['tmp_name'][] = $files['tmp_name'][$i];
                        
    $this -> files['name'][] = $files['name'][$i];
                        
    $this -> files['type'][] = $files['type'][$i];
                        
    $this -> files['size'][] = $files['size'][$i];
                    }
                }
            }
        }

        
    // kötü karakterleri değiştir.
        
    function bad_character_rewrite($text){
                
    $first = array("\\""/"":"";""~""|""("")""\"""#""*""$""@""%""[""]""{""}""<"">""`""'"","" ""ğ""Ğ""ü""Ü""ş""Ş""ı""İ""ö""Ö""ç""Ç");
                
    $last = array("_""_""_""_""_""_""""_""_""_""_""_""_""_""_""_""_""_""_""_""_""""_""_""g""G""u""U""s""S""i""I""o""O""c""C");
                
    $text_rewrite str_replace($first$last$text);
                return 
    $text_rewrite;
        }

        
    // dosya uzantısı bul
        
    function file_extension($file_name) {
            
    $file_extension strtolower(substr(strrchr($file_name'.'), 1));
            return 
    $file_extension;
        }

        
    // ayni isimdeki dosya kontrolu
        
    function file_name_control($file_name) {
            
    $file_name $this -> bad_character_rewrite($file_name);
            if (!
    file_exists($this -> directory.'/'.$file_name)) {
                return 
    $file_name;
            }else{
                return 
    rand(000000001,999999999).'_'.rand(000000001,999999999).'_'.$file_name;
            }
        }

        
    // dosya(lari) yukle
        
    function upload($mime_types) {
            if(!
    $this -> error) {
                for (
    $i 0$i count($this -> files['tmp_name']); $i++) {
                    if (
    in_array($this -> files['type'][$i], $mime_types)) {
                        
    $this -> file_new_name $this -> file_name_control($this -> files['name'][$i]);
                        
    move_uploaded_file($this -> files['tmp_name'][$i], $this -> directory.'/'.$this -> file_new_name);
                        
    $this -> uploaded_files[] = $this -> file_new_name;
                        
    $this -> results .= '<li><strong>'.$this -> files['name'][$i].'</strong> isimli dosya, <strong>'.$this -> file_new_name.'</strong> ismiyle yüklendi<br />(~'.round($this -> files['size'][$i] / 10242).' kb). Dosya Tipi : '.$this -> file_extension($this -> files['name'][$i]).'</li>';
                    }else{
                        echo 
    $this -> files['type'][$i];
                        
    $this -> results .= '<li>'.$this -> files['name'][$i].' isimli dosya, uyumsuz dosya tipi nedeniyle yüklenmedi!</li>';
                    }
                }
                
    $this -> uploaded true;
            }
        }

        
    // upload result reports
        
    function result_report() {
            if(isset(
    $this -> error)) {
                echo 
    '<ul>';
                echo 
    $this -> error;
                echo 
    '</ul>';
            }
            if (
    $this -> uploaded == true) {
                echo 
    '<ul>';
                echo 
    $this -> results;
                echo 
    '</ul>';
            }
        }

        function 
    uploader_set($files$directory$mime_types) {
            
    $this -> directory($directory);
            
    $this -> files($files);
            
    $this -> upload($mime_types);
        }
    }
    ?>
    test.php
    PHP Kodu:
    <?PHP
    header
    ("Content-Type: text/html; charset=utf-8");
    require_once(
    'kgUploader.class.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <title>KG Uploader v1.0</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
        body {
            margin:20px; background:#f2f2f2; font:0.8em/1.8em arial, helvetica, sans serif; color:#333;
        }
        form {
            margin:0;
        }
        #reports {
            margin:auto; width:300px; padding:3px;  background:#fff; border:1px solid #e0e0e0;
        }
        #reports ul {
            list-style-type:square;
        }
        #reports ul li {
            border-bottom:1px dotted #e0e0e0;
        }
        #form {
            margin:auto; width:300px; padding:3px; margin-top:3px; background:#fff; border:1px solid #e0e0e0;
        }
    </style>
    </head>
    <body>

    <?PHP
    if($_FILES) {
    ?>
    <div id="reports">
    <?PHP
        $mime_types 
    = array('image/pjpeg''image/jpeg''image/gif''image/png''image/x-png''application/x-tar''application/zip''application/msword''application/vnd.ms-excel''application/vnd.ms-powerpoint''application/mspowerpoint''application/x-shockwave-flash''text/plain''text/richtext''application/pdf'); // izin verilecek olan dosya tipleri
        
    $kgUploaderOBJ = & new kg_uploader();
        
    $kgUploaderOBJ -> uploader_set($_FILES['dosyalar'], './repo'$mime_types); // 1. parametre FILES dizisi, 2. parametre dizin, 3. parametre ise izin verilen dosya tipleri
        
    $kgUploaderOBJ -> result_report(); // yukleme ayrintilarini gosterir
        /* //Eğer dosya isimleri bir tabloya kaydedilmek istenirse asagidaki gibi listeletilebilir.
        for ($i = 0; $i < count($kgUploaderOBJ -> uploaded_files); $i++) {
            echo $kgUploaderOBJ -> uploaded_files[$i];
        }
        */
    ?>
    </div>
    <?PHP
    }
    ?>

    <div id="form">
        <form method="post" action="test.php" enctype="multipart/form-data">
            <p><input type="file" name="dosyalar[]" id="dosya1" /></p>
            <p><input type="file" name="dosyalar[]" id="dosya2" /></p>
            <p><input type="file" name="dosyalar[]" id="dosya3" /></p>
            <p><input type="file" name="dosyalar[]" id="dosya4" /></p>
            <p><input type="file" name="dosyalar[]" id="dosya5" /></p>
            <p><input type="submit" name="upload" value="Yükle" id="upload" /></p>
        </form>
    </div>

    </body>
    </html>
    Umamrım işinize yarar. Güle güle kullanın

+ Cevap Yaz

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Benzer Konular

  1. Kütüphane otomasyon
    By sigma in forum Uygulama Yazılımları / Hazır Betikler
    Cevap: 2
    En Son Mesaj: 23/06/2010, 18:54
  2. Kütüphane
    By turker in forum Flash / Director / Swift 3D ...
    Cevap: 7
    En Son Mesaj: 17/01/2009, 04:26
  3. Asp Kütüphane scripti
    By erus in forum ASP
    Cevap: 4
    En Son Mesaj: 16/12/2006, 17:56
  4. Kütüphane Programı Lazım
    By halikara in forum Visual Basic
    Cevap: 3
    En Son Mesaj: 19/03/2004, 02:10

Tags for this Thread

Bookmarks

Mesaj Yazma Hakları

  • Yeni mesajgöndermezsiniz
  • Cevap yazamazsınız
  • Dosya ekleyemezsiniz
  • Mesajınızı düzenleyemezsiniz