コード例 #1
0
 public function __call($method, $parameters)
 {
     if (!defined('static::factory')) {
         throw new UndefinedConstException('[const factory] is required to use the [Call Factory Method Ability]!');
     }
     $originMethodName = $method;
     $method = strtolower($method);
     $calledClass = get_called_class();
     if (!isset(static::factory['methods'][$method])) {
         Support::classMethod($calledClass, $originMethodName);
     }
     $class = static::factory['methods'][$method];
     $factory = static::factory['class'] ?? NULL;
     if ($factory !== NULL) {
         return $factory::class($class)->{$method}(...$parameters);
     } else {
         $classEx = explode('::', $class);
         $class = $classEx[0] ?? NULL;
         $method = $classEx[1] ?? NULL;
         $isThis = NULL;
         if (stristr($method, ':this')) {
             $method = str_replace(':this', NULL, $method);
             $isThis = 'this';
         }
         $namespace = str_ireplace(divide($calledClass, '\\', -1), NULL, $calledClass);
         $return = uselib($namespace . $class)->{$method}(...$parameters);
         if ($isThis === 'this') {
             return $this;
         }
         return $return;
     }
 }
コード例 #2
0
ファイル: StaticAccess.php プロジェクト: bytemtek/znframework
 protected static function useClassName($method, $parameters)
 {
     $class = uselib(STATIC_ACCESS . static::getClassName());
     switch (count($parameters)) {
         // Parametre yoksa
         case 0:
             return $class->{$method}();
             // 1 parametre için
         // 1 parametre için
         case 1:
             return $class->{$method}($parameters[0]);
             // 2 parametre için
         // 2 parametre için
         case 2:
             return $class->{$method}($parameters[0], $parameters[1]);
             // 3 parametre için
         // 3 parametre için
         case 3:
             return $class->{$method}($parameters[0], $parameters[1], $parameters[2]);
             // 4 parametre için
         // 4 parametre için
         case 4:
             return $class->{$method}($parameters[0], $parameters[1], $parameters[2], $parameters[3]);
             // 5 parametre için
         // 5 parametre için
         case 5:
             return $class->{$method}($parameters[0], $parameters[1], $parameters[2], $parameters[3], $parameters[4]);
             // Daha fazla parametre için
         // Daha fazla parametre için
         default:
             return call_user_func_array(array($class, $method), $parameters);
     }
 }
コード例 #3
0
ファイル: Model.php プロジェクト: bytemtek/znframework
 public function __get($class)
 {
     // ---------------------------------------------------------------------
     // Nesnenin tanımlanmamış ise tanımlanmasını sağla.
     // ---------------------------------------------------------------------
     if (!isset($this->{$class})) {
         // Sınıf Tanımlaması Yapılıyor.
         return $this->{$class} = uselib($class);
     }
     // ---------------------------------------------------------------------
 }
コード例 #4
0
ファイル: Library.php プロジェクト: znframework/znframework
function library(string $class, string $function, $parameters = [])
{
    $var = uselib($class);
    if (!is_array($parameters)) {
        $parameters = [$parameters];
    }
    if (is_callable([$var, $function])) {
        return call_user_func_array([$var, $function], $parameters);
    } else {
        return false;
    }
}
コード例 #5
0
ファイル: Factory.php プロジェクト: znframework/znframework
 public static function class(string $class)
 {
     $namespace = NULL;
     if (defined('static::namespace')) {
         $namespace = suffix(static::namespace, '\\');
     } else {
         $calledClass = get_called_class();
         $namespace = str_ireplace(divide($calledClass, '\\', -1), NULL, $calledClass);
     }
     $class = $namespace . $class;
     return uselib($class);
 }
コード例 #6
0
ファイル: Driver.php プロジェクト: znframework/znframework
 public function __construct(string $driver = NULL)
 {
     parent::__construct();
     if (!defined('static::driver')) {
         throw new UndefinedConstException('[const driver] is required to use the [Driver Ability]!');
     }
     nullCoalesce($driver, $this->config['driver'] ?? NULL);
     $this->selectedDriverName = $driver;
     Support::driver(static::driver['options'], $driver);
     if (!isset(static::driver['namespace'])) {
         $this->driver = uselib($driver);
     } else {
         $this->driver = uselib(suffix(static::driver['namespace'], '\\') . $driver . 'Driver');
     }
     if (isset(static::driver['construct'])) {
         $construct = static::driver['construct'];
         $this->{$construct}();
     }
 }
コード例 #7
0
ファイル: Classes.php プロジェクト: bytemtek/znframework
 public function propertyExists($className = '', $property = '', $prefix = STATIC_ACCESS)
 {
     if (!is_string($className) || !is_string($property)) {
         return Error::set('Error', 'stringParameter', '1.($className) & 2.(property)');
     }
     return property_exists(uselib($prefix . $className), $property);
 }
コード例 #8
0
 protected function _drvlib($suffix = 'Driver')
 {
     Support::driver($this->drivers, $this->driver);
     return uselib('ZN\\Database\\Drivers\\' . $this->driver . $suffix);
 }
コード例 #9
0
ファイル: Model.php プロジェクト: znframework/znframework
 public function __get($class)
 {
     if (!isset($this->{$class})) {
         return $this->{$class} = uselib($class);
     }
 }
コード例 #10
0
ファイル: Upload.php プロジェクト: erdidoqan/znframework
 public function sqlFile($sqlFile = '')
 {
     if (!is_string($sqlFile) || empty($sqlFile)) {
         return Error::set(lang('Error', 'stringParameter', 'sqlFile'));
     }
     $fileContents = File::contents(suffix($sqlFile, ".sql"));
     $fileContents = preg_replace("/SET (.*?);/", "", $fileContents);
     $fileContents = preg_replace("/\\/\\*(.*?)\\*\\//", "", $fileContents);
     $fileContents = preg_replace("/--(.*?)\n/", "", $fileContents);
     $fileContents = preg_replace("/\\/\\*!40101/", "", $fileContents);
     $queries = explode(";\n", $fileContents);
     $db = uselib('DB');
     foreach ($queries as $query) {
         if ($query !== '') {
             $db->execQuery(trim($query));
         }
     }
 }
コード例 #11
0
function library($class = NULL, $function = NULL, $parameters = array())
{
    if (empty($class) || empty($function)) {
        return false;
    }
    $var = uselib($class);
    if (!is_array($parameters)) {
        $parameters = array($parameters);
    }
    if (is_callable(array($var, $function))) {
        return call_user_func_array(array($var, $function), $parameters);
    } else {
        return false;
    }
}
コード例 #12
0
 public function transition(bool $tag = false) : Sheet\Helpers\Transition
 {
     return uselib($this->_namespace('Transition'), [$tag]);
 }
コード例 #13
0
ファイル: User.php プロジェクト: bytemtek/znframework
 public function forgotPassword($email = '', $returnLinkPath = '')
 {
     if (isset($this->parameters['email'])) {
         $email = $this->parameters['email'];
     }
     if (isset($this->parameters['returnLink'])) {
         $returnLinkPath = $this->parameters['returnLink'];
     }
     $this->parameters = array();
     if (!is_string($email)) {
         return Error::set('Error', 'stringParameter', '1.(email)');
     }
     if (!is_string($returnLinkPath)) {
         $returnLinkPath = '';
     }
     // ------------------------------------------------------------------------------
     // CONFIG/USER.PHP AYARLARI
     // Config/User.php dosyasında belirtilmiş ayarlar alınıyor.
     // ------------------------------------------------------------------------------
     $userConfig = $this->config;
     $usernameColumn = $userConfig['usernameColumn'];
     $passwordColumn = $userConfig['passwordColumn'];
     $emailColumn = $userConfig['emailColumn'];
     $tableName = $userConfig['tableName'];
     $senderInfo = $userConfig['emailSenderInfo'];
     // ------------------------------------------------------------------------------
     $db = uselib('DB');
     if (!empty($emailColumn)) {
         $db->where($emailColumn . ' =', $email);
     } else {
         $db->where($usernameColumn . ' =', $email);
     }
     $row = $db->get($tableName)->row();
     $result = "";
     if (isset($row->{$usernameColumn})) {
         if (!isUrl($returnLinkPath)) {
             $returnLinkPath = siteUrl($returnLinkPath);
         }
         $newPassword = Encode::create(10);
         $encodePassword = Encode::super($newPassword);
         $templateData = array('usernameColumn' => $row->{$usernameColumn}, 'newPassword' => $newPassword, 'returnLinkPath' => $returnLinkPath);
         $message = Import::template('UserEmail/ForgotPassword', $templateData, true);
         $sendEmail = uselib('Email');
         $sendEmail->sender($senderInfo['mail'], $senderInfo['name']);
         $sendEmail->receiver($email, $email);
         $sendEmail->subject(lang('User', 'newYourPassword'));
         $sendEmail->content($message);
         if ($sendEmail->send()) {
             if (!empty($emailColumn)) {
                 $db->where($emailColumn . ' =', $email);
             } else {
                 $db->where($usernameColumn . ' =', $email);
             }
             if ($db->update($tableName, array($passwordColumn => $encodePassword))) {
                 $this->success = lang('User', 'forgotPasswordSuccess');
                 return true;
             }
             return Error::set('Database', 'updateError');
         } else {
             return Error::set('User', 'emailError');
         }
     } else {
         return Error::set('User', 'forgotPasswordError');
     }
 }
コード例 #14
0
ファイル: Internal.php プロジェクト: znframework/znframework
function internalStartingContoller(string $startController = '', array $param = [])
{
    $controllerEx = explode(':', $startController);
    $controllerPath = !empty($controllerEx[0]) ? $controllerEx[0] : '';
    $controllerFunc = !empty($controllerEx[1]) ? $controllerEx[1] : 'main';
    $controllerFile = CONTROLLERS_DIR . suffix($controllerPath, '.php');
    $controllerClass = divide($controllerPath, '/', -1);
    if (is_file($controllerFile)) {
        require_once $controllerFile;
        if (!is_callable([$controllerClass, $controllerFunc])) {
            report('Error', lang('Error', 'callUserFuncArrayError', $controllerFunc), 'SystemCallUserFuncArrayError');
            die(Errors::message('Error', 'callUserFuncArrayError', $controllerFunc));
        }
        return uselib($controllerClass)->{$controllerFunc}(...$param);
    } else {
        report('Error', lang('Error', 'notIsFileError', $controllerFile), 'SystemNotIsFileError');
        die(Errors::message('Error', 'notIsFileError', $controllerFile));
    }
}
コード例 #15
0
ファイル: Jquery.php プロジェクト: bytemtek/znframework
 public function event($tag = false, $jq = false, $jqui = false)
 {
     return uselib('JQEvent', array($tag, $jq, $jqui));
 }
コード例 #16
0
 public function propertyExists(string $className, string $property) : bool
 {
     return property_exists(uselib($this->_class($className)), $property);
 }
コード例 #17
0
ファイル: ZIP.php プロジェクト: znframework/znframework
 public function undo($data)
 {
     return uselib('GZDriver')->undo($data);
 }
コード例 #18
0
ファイル: ZN.php プロジェクト: znframework/znframework
 public static function __callSTatic($class, $parameters)
 {
     return uselib($class, $parameters);
 }
コード例 #19
0
ファイル: Search.php プロジェクト: bytemtek/znframework
 public function get($conditions = array(), $word = '', $type = 'auto')
 {
     // Parametreler kontrol ediliyor. -----------------------------------------
     if (!is_array($conditions)) {
         return Error::set('Error', 'arrayParameter', 'conditions');
     }
     if (!is_scalar($word)) {
         return Error::set('Error', 'valueParameter', 'word');
     }
     if (!empty($this->type)) {
         $type = $this->type;
     }
     if (!empty($this->word)) {
         $word = $this->word;
     }
     if (!is_string($type)) {
         $type = "inside";
     }
     // ------------------------------------------------------------------------
     $word = addslashes($word);
     $str = "";
     // Aramanın neye göre yapılacağı belirtiliyor. ----------------------------
     $operator = ' LIKE ';
     $str = $word;
     if ($type === "auto") {
         if (is_numeric($word)) {
             $operator = ' = ';
         } else {
             $str = DB::like($word, 'inside');
         }
     }
     // İçerisinde Geçen
     if ($type === "inside") {
         $str = DB::like($word, 'inside');
     }
     // İle Başlayan
     if ($type === "starting") {
         $str = DB::like($word, 'starting');
     }
     // İle Biten
     if ($type === "ending") {
         $str = DB::like($word, 'ending');
     }
     if ($type === 'equal') {
         $operator = ' = ';
     }
     // ------------------------------------------------------------------------
     $db = uselib('DB');
     foreach ($conditions as $key => $values) {
         // Tekrarlayan verileri engelle.
         $db->distinct();
         foreach ($values as $keys) {
             $db->where($keys . $operator, $str, 'OR');
             // Filter dizisi boş değilse
             // Filtrelere göre verileri çek
             if (!empty($this->filter)) {
                 foreach ($this->filter as $val) {
                     $exval = explode("|", $val);
                     // Ve bağlaçlı filter kullanılmışsa
                     if ($exval[2] === "and") {
                         $db->where("{$exval['0']} ", $exval[1], 'AND');
                     }
                     // Veya bağlaçlı or_filter kullanılmışsa
                     if ($exval[2] === "or") {
                         $db->where("{$exval['0']} ", $exval[1], 'OR');
                     }
                 }
             }
         }
         // Sonuçları getir.
         $db->get($key);
         // Sonuçları result dizisine yazdır.
         $this->result[$key] = $db->result();
     }
     $result = $this->result;
     $db->close();
     // Değişkenleri sıfırla
     $this->result = NULL;
     $this->type = NULL;
     $this->word = NULL;
     $this->filter = array();
     // Sonuçları object veri türünde döndür.
     return (object) $result;
 }
コード例 #20
0
 public function event(bool $tag = false, bool $jq = false, bool $jqui = false) : Jquery\Helpers\Event
 {
     return uselib($this->_namespace('Event'), [$tag, $jq, $jqui]);
 }
コード例 #21
0
ファイル: Sheet.php プロジェクト: bytemtek/znframework
 public function transition($tag = false)
 {
     return uselib('CSSTransition', array($tag));
 }
コード例 #22
0
 public function start()
 {
     $this->result = NULL;
     $index = 0;
     foreach ($this->methods as $method => $parameters) {
         $method = explode(':', $method)[0];
         Benchmark::start($method);
         $returnValue = uselib($this->class)->{$method}(...$parameters);
         Benchmark::end($method);
         $this->_output($this->class, $method, gettype($returnValue), $returnValue);
         $index++;
     }
     $this->_outputBottom($index);
     $this->_startDefaultVariables();
 }
コード例 #23
0
 protected static function useClassName($method, $parameters)
 {
     return uselib(INTERNAL_ACCESS . static::getClassName())->{$method}(...$parameters);
 }
コード例 #24
0
ファイル: Migration.php プロジェクト: bytemtek/znframework
 public function version($version = 0)
 {
     if (empty($this->tbl)) {
         return false;
     }
     $name = $this->classFix . $this->_tableName();
     if ($version <= 0) {
         return uselib($name);
     }
     $name .= $this->_version($version);
     return uselib($name);
 }
コード例 #25
0
ファイル: User.php プロジェクト: Allopa/ZN-Framework-Starter
 public function logout($redirectUrl = '', $time = 0)
 {
     if (!is_string($redirectUrl)) {
         $redirectUrl = '';
     }
     if (!is_numeric($time)) {
         $time = 0;
     }
     $config = $this->config;
     $username = $config['usernameColumn'];
     $tableName = $config['tableName'];
     if (isset($this->data($tableName)->{$username})) {
         if (!isset($_SESSION)) {
             session_start();
         }
         if ($config['activeColumn']) {
             $db = uselib('DB');
             $db->where($config['usernameColumn'] . ' =', $this->data($tableName)->{$username})->update($config['tableName'], array($config['activeColumn'] => 0));
         }
         Cookie::delete(md5($config['usernameColumn']));
         Cookie::delete(md5($config['passwordColumn']));
         if (isset($_SESSION[md5($config['usernameColumn'])])) {
             unset($_SESSION[md5($config['usernameColumn'])]);
         }
         redirect($redirectUrl, $time);
     }
 }
コード例 #26
0
ファイル: Kernel.php プロジェクト: znframework/znframework
// SAYFA KONTROLÜ YAPILIYOR...
//--------------------------------------------------------------------------------------------------
//  Sayfa bilgisine erişilmişse sayfa dahil edilir.
//--------------------------------------------------------------------------------------------------
if (is_file($isFile)) {
    require_once $isFile;
    if (!class_exists($page, false)) {
        $page = $namespace . $page;
    }
    if (class_exists($page, false)) {
        if (strtolower($function) === 'index' && !is_callable([$page, $function])) {
            $function = 'main';
        }
        if (is_callable([$page, $function])) {
            try {
                uselib($page)->{$function}(...$parameters);
            } catch (\Throwable $e) {
                if (PROJECT_MODE !== 'publication') {
                    \Exceptions::table($e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTrace());
                }
            }
        } else {
            if ($routeShow404 = Config::get('Services', 'route')['show404']) {
                redirect($routeShow404);
            } else {
                report('Error', lang('Error', 'callUserFuncArrayError', $function), 'SystemCallUserFuncArrayError');
                die(Errors::message('Error', 'callUserFuncArrayError', $function));
            }
        }
    }
} else {