示例#1
0
 public function do(string $old = NULL, string $new = NULL, string $newAgain = NULL, array $data = []) : bool
 {
     if (Factory::class('Login')->is()) {
         $old = Properties::$parameters['oldPassword'] ?? $old;
         $new = Properties::$parameters['newPassword'] ?? $new;
         $newAgain = Properties::$parameters['passwordAgain'] ?? $newAgain;
         $data = Properties::$parameters['column'] ?? $data;
         Properties::$parameters = [];
         if (empty($newAgain)) {
             $newAgain = $new;
         }
         $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns'];
         $getJoining = INDIVIDUALSTRUCTURES_USER_CONFIG['joining'];
         $joinTables = $getJoining['tables'];
         $jc = $getJoining['column'];
         $pc = $getColumns['password'];
         $uc = $getColumns['username'];
         $tn = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table'];
         $encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode'];
         $oldPassword = !empty($encodeType) ? Encode::type($old, $encodeType) : $old;
         $newPassword = !empty($encodeType) ? Encode::type($new, $encodeType) : $new;
         $newPasswordAgain = !empty($encodeType) ? Encode::type($newAgain, $encodeType) : $newAgain;
         if (!empty($joinTables)) {
             $joinData = $data;
             $data = $data[$tn] ?? [$tn];
         }
         $getUserData = Factory::class('Data')->get($tn);
         $username = $getUserData->{$uc};
         $password = $getUserData->{$pc};
         if ($oldPassword != $password) {
             return !($this->error = lang('IndividualStructures', 'user:oldPasswordError'));
         } elseif ($newPassword != $newPasswordAgain) {
             return !($this->error = lang('IndividualStructures', 'user:passwordNotMatchError'));
         } else {
             $data[$pc] = $newPassword;
             $data[$uc] = $username;
             if (!empty($joinTables)) {
                 $joinCol = DB::where($uc, $username)->get($tn)->row()->{$jc};
                 foreach ($joinTables as $table => $joinColumn) {
                     if (isset($joinData[$table])) {
                         DB::where($joinColumn, $joinCol)->update($table, $joinData[$table]);
                     }
                 }
             } else {
                 if (!DB::where($uc, $username)->update($tn, $data)) {
                     return !($this->error = lang('IndividualStructures', 'user:registerUnknownError'));
                 }
             }
             return $this->success = lang('IndividualStructures', 'user:updateProcessSuccess');
         }
     } else {
         return false;
     }
 }
示例#2
0
 public function replace(string $file, $data, $replace) : string
 {
     $file = File::rpath($file);
     if (!is_file($file)) {
         throw new FileNotFoundException($file);
     }
     $fileContentClass = Factory::class('Content');
     $contents = $fileContentClass->read($file);
     $replaceContents = str_ireplace($data, $replace, $contents);
     if ($contents !== $replaceContents) {
         $fileContentClass->write($file, $replaceContents);
     }
     return $replaceContents;
 }
示例#3
0
 public function do(string $redirectUrl = NULL, int $time = 0)
 {
     $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns'];
     $tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table'];
     $username = $getColumns['username'];
     $password = $getColumns['password'];
     $active = $getColumns['active'];
     $getUserData = Factory::class('Data')->get($tableName)->{$username} ?? NULL;
     if ($getUserData !== NULL) {
         if (!empty($active)) {
             DB::where($username, $getUserData)->update($tableName, [$active => 0]);
         }
         Cookie::delete($username);
         Cookie::delete($password);
         Session::delete($username);
         redirect($redirectUrl, $time);
     }
 }
示例#4
0
 public function fileInfo(string $dir, string $extension = NULL) : array
 {
     $dir = File::rpath($dir);
     if (is_dir($dir)) {
         $files = Factory::class('FileList')->files($dir, $extension);
         $dir = suffix($dir);
         $filesInfo = [];
         foreach ($files as $file) {
             $filesInfo[$file]['basename'] = pathInfos($dir . $file, 'basename');
             $filesInfo[$file]['size'] = filesize($dir . $file);
             $filesInfo[$file]['date'] = filemtime($dir . $file);
             $filesInfo[$file]['readable'] = is_readable($dir . $file);
             $filesInfo[$file]['writable'] = is_writable($dir . $file);
             $filesInfo[$file]['executable'] = is_executable($dir . $file);
             $filesInfo[$file]['permission'] = fileperms($dir . $file);
         }
         return $filesInfo;
     } elseif (is_file($dir)) {
         return (array) File::info($dir);
     } else {
         throw new FolderNotFoundException($dir);
     }
 }
示例#5
0
 public function copy(string $source, string $target) : bool
 {
     $source = File::rpath($source);
     $target = File::rpath($target);
     $fileListClass = Factory::class('FileList');
     if (!file_exists($source)) {
         throw new FolderNotFoundException($source);
     }
     if (is_dir($source)) {
         if (!$fileListClass->files($source)) {
             return copy($source, $target);
         } else {
             if (!is_dir($target) && !file_exists($target)) {
                 $this->create($target);
             }
             if (is_array($fileListClass->files($source))) {
                 foreach ($fileListClass->files($source) as $val) {
                     $sourceDir = $source . "/" . $val;
                     $targetDir = $target . "/" . $val;
                     if (is_file($sourceDir)) {
                         copy($sourceDir, $targetDir);
                     }
                     $this->copy($sourceDir, $targetDir);
                 }
             }
             return true;
         }
     } else {
         return copy($source, $target);
     }
 }
示例#6
0
 public function do(array $data = NULL, $autoLogin = false, string $activationReturnLink = NULL) : bool
 {
     $data = Properties::$parameters['column'] ?? $data;
     $autoLogin = Properties::$parameters['autoLogin'] ?? $autoLogin;
     $activationReturnLink = Properties::$parameters['returnLink'] ?? $activationReturnLink;
     Properties::$parameters = [];
     // ------------------------------------------------------------------------------
     // Settings
     // ------------------------------------------------------------------------------
     $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns'];
     $getJoining = INDIVIDUALSTRUCTURES_USER_CONFIG['joining'];
     $tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table'];
     $joinTables = $getJoining['tables'];
     $joinColumn = $getJoining['column'];
     $usernameColumn = $getColumns['username'];
     $passwordColumn = $getColumns['password'];
     $emailColumn = $getColumns['email'];
     $activeColumn = $getColumns['active'];
     $activationColumn = $getColumns['activation'];
     // ------------------------------------------------------------------------------
     if (!empty($joinTables)) {
         $joinData = $data;
         $data = isset($data[$tableName]) ? $data[$tableName] : [$tableName];
     }
     if (!isset($data[$usernameColumn]) || !isset($data[$passwordColumn])) {
         return !($this->error = lang('IndividualStructures', 'user:registerUsernameError'));
     }
     $loginUsername = $data[$usernameColumn];
     $loginPassword = $data[$passwordColumn];
     $encodeType = INDIVIDUALSTRUCTURES_USER_CONFIG['encode'];
     $encodePassword = !empty($encodeType) ? Encode::type($loginPassword, $encodeType) : $loginPassword;
     $usernameControl = DB::where($usernameColumn, $loginUsername)->get($tableName)->totalRows();
     // Daha önce böyle bir kullanıcı
     // yoksa kullanıcı kaydetme işlemini başlat.
     if (empty($usernameControl)) {
         $data[$passwordColumn] = $encodePassword;
         if (!DB::insert($tableName, $data)) {
             return !($this->error = lang('IndividualStructures', 'user:registerUnknownError'));
         }
         if (!empty($joinTables)) {
             $joinCol = DB::where($usernameColumn, $loginUsername)->get($tableName)->row()->{$joinColumn};
             foreach ($joinTables as $table => $joinColumn) {
                 $joinData[$table][$joinTables[$table]] = $joinCol;
                 DB::insert($table, $joinData[$table]);
             }
         }
         $this->success = lang('IndividualStructures', 'user:registerSuccess');
         if (!empty($activationColumn)) {
             if (!isEmail($loginUsername)) {
                 $email = $data[$emailColumn];
             } else {
                 $email = NULL;
             }
             $this->_activation($loginUsername, $encodePassword, $activationReturnLink, $email);
         } else {
             if ($autoLogin === true) {
                 Factory::class('Login')->do($loginUsername, $loginPassword);
             } elseif (is_string($autoLogin)) {
                 redirect($autoLogin);
             }
         }
         return true;
     } else {
         return !($this->error = lang('IndividualStructures', 'user:registerError'));
     }
 }
示例#7
0
 public function create($app = NULL) : string
 {
     $searchWord = '';
     if (Method::post()) {
         $keyword = Method::post('ML_UPDATE_KEYWORD_HIDDEN');
         $languages = explode(',', Method::post('ML_LANGUAGES'));
         $words = Method::post('ML_UPDATE_WORDS');
         // SEARCH
         if (Method::post('ML_SEARCH_SUBMIT')) {
             $searchWord = Method::post('ML_SEARCH');
         }
         // ADD LANGUAGE
         if (Method::post('ML_ADD_ALL_LANGUAGE_SUBMIT')) {
             Factory::class('Insert')->do(Method::post('ML_ADD_LANGUAGE'), 'example', 'Example');
         }
         // ALL DELETE
         if (Method::post('ML_ALL_DELETE_SUBMIT')) {
             $allDelete = Method::post('ML_ALL_DELETE_HIDDEN');
             Factory::class('Delete')->all($allDelete);
         }
         // ADD
         if (Method::post('ML_ADD_KEYWORD_SUBMIT')) {
             $addWords = Method::post('ML_ADD_WORDS');
             $addKeyword = Method::post('ML_ADD_KEYWORD');
             if (is_numeric($addKeyword)) {
                 $addKeyword = 'Wrong Keyword! Only String.';
             }
             if (!empty($languages)) {
                 foreach ($languages as $key => $lang) {
                     Factory::class('Insert')->do($lang, $addKeyword, $addWords[$key]);
                 }
             }
         }
         // UPDATE
         if (Method::post('ML_UPDATE_KEYWORD_SUBMIT')) {
             if (!empty($languages)) {
                 foreach ($languages as $key => $lang) {
                     Factory::class('Update')->do($lang, $keyword, $words[$key]);
                 }
             }
         }
         // DELETE
         if (Method::post('ML_DELETE_SUBMIT')) {
             if (!empty($languages)) {
                 foreach ($languages as $key => $lang) {
                     Factory::class('Delete')->do($lang, $keyword);
                 }
             }
         }
     }
     $config = ENCODINGSUPPORT_ML_CONFIG['table'];
     $attributes = $config['attributes'];
     $pagcon = $config['pagination'];
     $placeHolders = $config['placeHolders'];
     $buttonNames = $config['buttonNames'];
     $title = $config['labels']['title'];
     $confirmMessage = $config['labels']['confirm'];
     $process = $config['labels']['process'];
     $keywords = $config['labels']['keywords'];
     $confirmBox = ' onsubmit="return confirm(\'' . $confirmMessage . '\');"';
     $data = Factory::class('Select')->all($app);
     $languageCount = count($data);
     $table = $this->_styleElement();
     $table .= '<table id="ML_TABLE"' . Html::attributes($attributes['table']) . '>';
     $table .= '<thead>';
     $table .= '<tr><th colspan="' . ($languageCount + 4) . '">' . $title . '</th></tr>';
     $table .= '<tr><th>S/L</th>';
     $table .= '<td colspan="' . ($languageCount + 3) . '">';
     $table .= '<form name="ML_SEARCH_ADD_LANGUAGE_FORM" method="post">';
     $table .= Form::attr($attributes['textbox'])->placeholder($placeHolders['search'])->text('ML_SEARCH');
     $table .= Form::attr($attributes['add'])->submit('ML_SEARCH_SUBMIT', $buttonNames['search']);
     $table .= Form::attr($attributes['textbox'])->placeholder($placeHolders['addLanguage'])->text('ML_ADD_LANGUAGE');
     $table .= Form::attr($attributes['add'])->submit('ML_ADD_ALL_LANGUAGE_SUBMIT', $buttonNames['add']) . '</td>';
     $table .= '</form>';
     $table .= '</tr>';
     $table .= '<tr><th>#</th><td><strong>' . $keywords . '</strong></td>';
     $words = [];
     $formObjects = '';
     $languages = implode(',', array_keys($data));
     $mlLanguages = Form::hidden('ML_LANGUAGES', $languages);
     foreach ($data as $lang => $values) {
         $upperLang = strtoupper($lang);
         $table .= '<form name="ML_TOP_FORM_' . $upperLang . '" method="post"' . $confirmBox . '>';
         $table .= '<td><strong>' . $upperLang . Form::hidden('ML_ALL_DELETE_HIDDEN', $lang) . Form::attr($attributes['delete'])->submit('ML_ALL_DELETE_SUBMIT', $buttonNames['delete']) . '</strong></td>';
         $table .= '</form>';
         foreach ($values as $key => $val) {
             $words[$key][] = $val;
         }
         $formObjects .= '<td>' . Form::attr($attributes['textbox'])->placeholder($upperLang)->text('ML_ADD_WORDS[]') . '</td>';
     }
     $table .= '<td><strong>' . $process . '</strong></td>';
     $table .= '</tr>';
     $table .= '</thead>';
     $table .= '<tbody>';
     $table .= '<tr>';
     $table .= '<form name="ML_TOP_FORM" method="post">';
     $table .= '<th>N</th>';
     $table .= '<td>' . $mlLanguages . Form::attr($attributes['textbox'])->placeholder($placeHolders['keyword'])->text('ML_ADD_KEYWORD') . '</td>';
     $table .= $formObjects;
     $table .= '<td>' . Form::attr($attributes['add'])->submit('ML_ADD_KEYWORD_SUBMIT', $buttonNames['add']) . ' ' . Form::attr($attributes['clear'])->reset('ML_ADD_KEYWORD_RESET', $buttonNames['clear']) . '</td>';
     $table .= '</form>';
     $table .= '</tr>';
     $limit = $this->limit;
     $start = (int) URI::segment(-1);
     $totalRows = count($words);
     $index = 1;
     if (!empty($searchWord)) {
         $newWords = [];
         foreach ($words as $key => $val) {
             if (stristr($key, $searchWord)) {
                 $newWords[$key] = $val;
             } else {
                 $newValues = [];
                 foreach ($val as $v) {
                     if (stristr($v, $searchWord)) {
                         $newValues[] = $v;
                     }
                 }
                 if (!empty($newValues)) {
                     $newWords[$key] = $newValues;
                 }
             }
         }
         $words = $newWords;
     }
     if (empty($searchWord)) {
         $words = array_slice($words, $start, $limit);
     }
     foreach ($words as $key => $val) {
         $table .= '<tr>';
         $table .= '<form name="ML_' . strtoupper($key) . '_FORM" method="post"' . $confirmBox . '>';
         $table .= '<th>' . $index++ . '</th>';
         $table .= '<td>' . Form::hidden('ML_UPDATE_KEYWORD_HIDDEN', $key) . $key . '</td>';
         for ($i = 0; $i < $languageCount; $i++) {
             $table .= '<td>' . Form::attr($attributes['textbox'])->text('ML_UPDATE_WORDS[]', !empty($val[$i]) ? $val[$i] : '') . '</td>';
         }
         $table .= '<td>' . $mlLanguages . Form::attr($attributes['update'])->submit('ML_UPDATE_KEYWORD_SUBMIT', $buttonNames['update']);
         $table .= ' ';
         $table .= Form::attr($attributes['delete'])->submit('ML_DELETE_SUBMIT', $buttonNames['delete']) . '</td>';
         $table .= '</form>';
         $table .= '</tr>';
     }
     if (empty($this->url)) {
         $paginationUrl = CURRENT_CFURI;
     } else {
         $paginationUrl = $this->url;
     }
     if (empty($searchWord)) {
         $pagination = Pagination::style($pagcon['style'])->css($pagcon['class'])->start($start)->totalRows($totalRows)->limit($limit)->url($paginationUrl)->create();
     } else {
         $pagination = NULL;
     }
     if (!empty($pagination) && !empty($totalRows)) {
         $table .= '<tr><th>P</th><td colspan="' . ($languageCount + 3) . '">' . $pagination . '</td></tr>';
     }
     $table .= '</tbody>';
     $table .= '</table>';
     return $table;
 }
示例#8
0
 public function do(string $app = NULL, $key, string $data = NULL) : bool
 {
     return Factory::class('Insert')->do($app, $key, $data);
 }
示例#9
0
 public function is() : bool
 {
     $getColumns = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['columns'];
     $tableName = INDIVIDUALSTRUCTURES_USER_CONFIG['matching']['table'];
     $username = $getColumns['username'];
     $password = $getColumns['password'];
     $cUsername = Cookie::select($username);
     $cPassword = Cookie::select($password);
     $result = NULL;
     if (!empty($cUsername) && !empty($cPassword)) {
         $result = DB::where($username, $cUsername, 'and')->where($password, $cPassword)->get($tableName)->totalRows();
     }
     if (isset(Factory::class('Data')->get($tableName)->{$username})) {
         $isLogin = true;
     } elseif (!empty($result)) {
         Session::insert($username, $cUsername);
         Session::insert($password, $cPassword);
         $isLogin = true;
     } else {
         $isLogin = false;
     }
     return $isLogin;
 }