Repository: giandonatoinverso/PHP-Dynamic-Qr-code Branch: master Commit: 268a6a3f65c1 Files: 126 Total size: 6.8 MB Directory structure: gitextract_zy8zlmoi/ ├── .dockerignore ├── .gitignore ├── Dockerfile ├── LICENSE ├── README.md ├── docker-compose.yml ├── documentation/ │ ├── assets/ │ │ ├── custom.js │ │ ├── run_prettify.css │ │ ├── run_prettify.js │ │ └── style.css │ └── index.html └── src/ ├── authenticate.php ├── bulk_action.php ├── config/ │ ├── config.php │ └── environment.php ├── dist/ │ ├── css/ │ │ ├── adminlte.css │ │ ├── alt/ │ │ │ ├── adminlte.components.css │ │ │ ├── adminlte.core.css │ │ │ ├── adminlte.extra-components.css │ │ │ ├── adminlte.pages.css │ │ │ └── adminlte.plugins.css │ │ └── custom.css │ └── js/ │ ├── adminlte.js │ └── custom.js ├── dynamic_qrcode.php ├── dynamic_qrcodes.php ├── forms/ │ ├── filters.php │ ├── form_dynamic_add.php │ ├── form_dynamic_edit.php │ ├── form_static_add.php │ ├── form_static_edit.php │ ├── form_users.php │ ├── logo.php │ ├── qrcode_options.php │ ├── static/ │ │ ├── 2fa.php │ │ ├── bitcoin.php │ │ ├── bookmark.php │ │ ├── country-code.html │ │ ├── email.php │ │ ├── event.php │ │ ├── location.php │ │ ├── paypal.php │ │ ├── phone.php │ │ ├── skype.php │ │ ├── sms.php │ │ ├── text.php │ │ ├── timezones.html │ │ ├── vcard.php │ │ ├── whatsapp.php │ │ └── wifi.php │ ├── table_dynamic.php │ ├── table_static.php │ └── table_users.php ├── helpers/ │ └── helpers.php ├── includes/ │ ├── auth_validate.php │ ├── flash_messages.php │ ├── footer.php │ ├── head.php │ ├── navbar.php │ ├── search_order.php │ └── sidebar.php ├── index.php ├── lib/ │ ├── DynamicQrcode/ │ │ └── DynamicQrcode.php │ ├── ICS/ │ │ └── ICS.php │ ├── MysqliDb/ │ │ └── MysqliDb.php │ ├── Qrcode/ │ │ ├── Qrcode-intchil.php │ │ └── Qrcode.php │ ├── StaticQrcode/ │ │ └── StaticQrcode.php │ ├── Users/ │ │ └── Users.php │ └── vCard/ │ └── vCard.php ├── login.php ├── logout.php ├── plugins/ │ ├── bootstrap/ │ │ └── js/ │ │ ├── bootstrap.bundle.js │ │ └── bootstrap.js │ ├── bootstrap-colorpicker/ │ │ ├── css/ │ │ │ └── bootstrap-colorpicker.css │ │ └── js/ │ │ └── bootstrap-colorpicker.js │ ├── chart.js/ │ │ ├── Chart.bundle.js │ │ ├── Chart.css │ │ └── Chart.js │ ├── daterangepicker/ │ │ ├── bower.json │ │ ├── daterangepicker.css │ │ ├── daterangepicker.js │ │ ├── example/ │ │ │ ├── amd/ │ │ │ │ ├── index.html │ │ │ │ ├── main.js │ │ │ │ └── require.js │ │ │ └── browserify/ │ │ │ ├── README.md │ │ │ ├── bundle.js │ │ │ ├── index.html │ │ │ └── main.js │ │ ├── package.js │ │ ├── website/ │ │ │ ├── index.html │ │ │ ├── website.css │ │ │ └── website.js │ │ ├── website.css │ │ └── website.js │ ├── fontawesome-free/ │ │ └── css/ │ │ ├── all.css │ │ ├── brands.css │ │ ├── fontawesome.css │ │ ├── regular.css │ │ ├── solid.css │ │ ├── svg-with-js.css │ │ └── v4-shims.css │ ├── jquery/ │ │ ├── core.js │ │ ├── jquery.js │ │ └── jquery.slim.js │ ├── jquery-ui/ │ │ ├── AUTHORS.txt │ │ ├── LICENSE.txt │ │ ├── external/ │ │ │ └── jquery/ │ │ │ └── jquery.js │ │ ├── jquery-ui.css │ │ ├── jquery-ui.js │ │ ├── jquery-ui.structure.css │ │ └── jquery-ui.theme.css │ ├── jquery-validation/ │ │ ├── additional-methods.js │ │ └── jquery.validate.js │ ├── moment/ │ │ ├── locales.js │ │ └── moment-with-locales.js │ └── overlayScrollbars/ │ ├── css/ │ │ └── OverlayScrollbars.css │ └── js/ │ ├── OverlayScrollbars.js │ └── jquery.overlayScrollbars.js ├── read.php ├── saved_qrcode/ │ └── zip/ │ └── .gitkeep ├── static_qrcode.php ├── static_qrcodes.php ├── upgrade/ │ └── upgrade.php ├── user.php └── users.php ================================================ FILE CONTENTS ================================================ ================================================ FILE: .dockerignore ================================================ # Exclude specific directories src/install/ src/upgrade/ ================================================ FILE: .gitignore ================================================ .settings .project .idea .DS_Store ================================================ FILE: Dockerfile ================================================ FROM php:8.3 RUN if [ "$(grep '^VERSION_ID=' /etc/os-release | cut -d '=' -f 2 | tr -d '"')" -eq "9" ]; then \ sed -i -e 's/deb.debian.org/archive.debian.org/g' \ -e 's/security.debian.org/archive.debian.org/g' \ -e '/stretch-updates/d' /etc/apt/sources.list; \ fi # Download script to install PHP extensions and dependencies ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ RUN chmod +x /usr/local/bin/install-php-extensions RUN DEBIAN_FRONTEND=noninteractive apt-get update -q \ && DEBIAN_FRONTEND=noninteractive apt-get install -qq -y \ curl \ dnsutils \ git \ iputils-ping \ less \ libzip-dev \ libjpeg62-turbo-dev \ libpng-dev \ libfreetype6-dev \ nano \ net-tools \ procps \ tar \ tini \ zip unzip \ # iconv, mbstring and pdo_sqlite are omitted as they are already installed && PHP_EXTENSIONS=" \ amqp \ bcmath \ bz2 \ calendar \ event \ exif \ gd \ gettext \ intl \ ldap \ memcached \ mysqli \ opcache \ pdo_mysql \ pdo_pgsql \ pgsql \ redis \ soap \ sockets \ xsl \ zip \ " \ && case "$PHP_VERSION" in \ 5.6.*) PHP_EXTENSIONS="$PHP_EXTENSIONS mcrypt mysql";; \ 7.0.*|7.1.*) PHP_EXTENSIONS="$PHP_EXTENSIONS mcrypt";; \ esac \ # Install Imagick from master on PHP >= 8.3, because imagick 3.7.0 broke on latest PHP releases and Imagick maintainers don't care to tag a newer release && if [ $(php -r 'echo PHP_VERSION_ID;') -lt 80300 ]; then \ PHP_EXTENSIONS="$PHP_EXTENSIONS imagick"; \ else PHP_EXTENSIONS="$PHP_EXTENSIONS https://api.github.com/repos/Imagick/imagick/tarball/28f27044e435a2b203e32675e942eb8de620ee58"; \ fi \ && install-php-extensions $PHP_EXTENSIONS \ && if command -v a2enmod; then a2enmod rewrite; fi # Install Composer. ENV PATH=$PATH:/root/composer/vendor/bin \ COMPOSER_ALLOW_SUPERUSER=1 \ COMPOSER_HOME=/root/composer RUN cd /opt \ # Download installer and check for its integrity. && curl -sSL https://getcomposer.org/installer > composer-setup.php \ && curl -sSL https://composer.github.io/installer.sha384sum > composer-setup.sha384sum \ && sha384sum --check composer-setup.sha384sum \ # Install Composer 2. && php composer-setup.php --install-dir=/usr/local/bin --filename=composer --2 \ # Remove installer files. && rm /opt/composer-setup.php /opt/composer-setup.sha384sum RUN docker-php-source extract RUN docker-php-ext-install pdo_mysql zip exif pcntl gd RUN docker-php-ext-install mysqli && docker-php-ext-enable mysqli RUN docker-php-ext-install gettext && docker-php-ext-enable gettext RUN docker-php-ext-install sockets && docker-php-ext-enable sockets RUN mkdir -p /opt && chmod 777 /opt WORKDIR /opt RUN git clone https://github.com/chillerlan/php-qrcode.git \ && chmod -R 777 ./php-qrcode RUN cp ./php-qrcode/composer.json /var/www/html/composer.json RUN mkdir -p /var/www/html/test && chmod 777 /var/www/html/test RUN cp ./php-qrcode/examples/image.php /var/www/html/test/image.php RUN cp -R ./php-qrcode/src /var/www/html/ WORKDIR /var/www/html RUN composer update COPY ./src ./ RUN chmod 755 *; EXPOSE 80 CMD ["php", "-S", "0.0.0.0:80"] ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2020 Giandonato Inverso Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================

' . var_export($data, true) . ''; exit(); } } ?> ================================================ FILE: src/lib/Qrcode/Qrcode.php ================================================ table = "static_qrcodes"; $this->redirect_url = "static_qrcodes.php"; } else if($type === "dynamic") { $this->table = "dynamic_qrcodes"; $this->redirect_url = "dynamic_qrcodes.php"; } else { $this->redirect_url = "index.php"; $this->failure("Type not allowed"); } } /** * */ public function __destruct() { } public function getQrcode($id) { $db = getDbInstance(); $db->where('id', $id); $result = $db->getOne($this->table); if($result !== NULL) return $result; else $this->failure("Qrcode not found"); } /** * Set option for qr code like: * Error Correction Level, size (default = 100), foreground, background * return array of values */ private function setOptions($input_data) { $errorCorrectionLevel = 'L'; if (isset($input_data['level']) && in_array($input_data['level'], array('L','M','Q','H'))) $errorCorrectionLevel = $input_data['level']; $size = 100; if (isset($input_data['size'])) $size = min(max((int)$input_data['size'], 100), 1000); //character # deleted $foreground = substr($input_data['foreground'], 1); $background = substr($input_data['background'], 1); //$logo = $_POST['optionlogo']; return array( "errorCorrectionLevel" => $errorCorrectionLevel, "size" => $size, "foreground" => $foreground, "background" => $background, //"optionlogo" => $logo, ); } /** * Add qr code * Check out http://goqr.me/api/ for more information * We save the file obtained with the chosen name and in the selected folder * We save into db the url of qrcode image */ public function addQrcode($input_data, $data_to_db, $data_to_qrcode) { $options = $this->setOptions($input_data); if(!file_exists(SAVED_QRCODE_DIRECTORY.$data_to_db['filename'].'.'.$data_to_db['format'])){ $url = 'https://api.qrserver.com/v1/create-qr-code/?data='. $data_to_qrcode. '&&size='.$options['size'].'x'.$options['size']. '&ecc='.$options['errorCorrectionLevel']. '&margin=0&color='.$options['foreground']. '&bgcolor='.$options['background']. '&qzone=2'. '&format='.$data_to_db['format']; $content = file_get_contents($url); $filename = SAVED_QRCODE_DIRECTORY.$data_to_db['filename'].'.'.$data_to_db['format']; try{ file_put_contents($filename, $content); } catch(Exception $e){ $this->failure($e->getMessage()); } // If you want you can customi
' . var_export($data, true) . ''; exit(); } } ?> ================================================ FILE: src/lib/StaticQrcode/StaticQrcode.php ================================================ qrcode_instance = new Qrcode("static"); } /** * */ public function __destruct() { } /** * Set friendly columns\' names to order tables\' entries */ public function setOrderingValues() { $ordering = [ 'id' => 'ID', 'id_owner' => 'Owner', 'filename' => 'File Name', 'type' => 'Type', 'content' => 'Content', 'qrcode' => 'Qr Code', 'created_at' => 'Created at', 'updated_at' => 'Updated at' ]; return $ordering; } /** * create a qr code of type "text" * @string text -> required */ public function textQrcode($text) { if($text != NULL){ $this->sData = $text; $this->sContent = 'Text: '.$text; $this->addQrcode("text"); } else $this->requiredFieldsError(); } /** * create a qr code of type "email" * @string email -> required * @string subject * @string message -> required */ public function emailQrcode($email, $subject, $message) { if($email != NULL && $message != NULL){ $this->sData = 'MATMSG:TO:'.$email.';SUB:'.$subject.';BODY:'.$message.';'; $this->sContent = 'Email: '.$email.'
' . var_export($data, true) . ''; exit(); } } ?> ================================================ FILE: src/lib/Users/Users.php ================================================ 'ID', 'username' => 'Username', 'type' => 'Type' ]; return $ordering; } public function getAllUsers() { $db = getDbInstance(); return $db->get(DATABASE_PREFIX.'users'); } public function getUser($id) { $db = getDbInstance(); $db->where('id', $id); $result = $db->getOne('users'); if($result !== NULL) return $result; else $this->failure("User not found"); } /** * Add user */ public function addUser($input_data) { $db = getDbInstance(); $data_to_db["username"] = $input_data["username"]; $data_to_db['password'] = password_hash($input_data['password'], PASSWORD_DEFAULT); $data_to_db["type"] = $input_data["type"]; $db->where('username', $data_to_db['username']); $db->get('users'); if ($db->count >= 1) $this->failure('Username already exists'); $last_id = $db->insert('users', $data_to_db); if ($last_id) $this->success('User added successfully'); } /** * Edit user * */ public function editUser($input_data) { $db = getDbInstance(); $db->where('username', $input_data['username']); $db->where('id', $input_data["id"], '!='); $row = $db->getOne('users'); if (!empty($row['username'])) { $query_string = http_build_query(array( 'id' => $input_data["id"], 'edit' => "true", )); $this->failure('Username already exists', 'Location: user.php?'.$query_string); } $data_to_db["username"] = $input_data["username"]; $data_to_db['password'] = password_hash($input_data['password'], PASSWORD_DEFAULT); $data_to_db["type"] = $input_data["type"]; $db->where('id', $input_data["id"]); $stat = $db->update('users', $data_to_db); if ($stat) $this->success('User updated successfully!'); else $this->failure('Failed to update User: ' . $db->getLastError()); } /** * Delete user * */ public function deleteUser($id) { if($_SESSION['type']!='super'){ header('HTTP/1.1 401 Unauthorized', true, 401); exit("401 Unauthorized"); } $db = getDbInstance(); $db->where('id', $id); $stat = $db->delete('users'); if ($stat) $this->info('User deleted successfully!'); else $this->failure('Unable to delete user'); } /** * Flash message Failure process */ public function failure($message, $location = 'Location: users.php') { $_SESSION['failure'] = $message; header($location); exit(); } /** * Flash message Success process */ public function success($message) { $_SESSION['success'] = $message; header('Location: users.php'); exit(); } /** * Flash message Info process */ public function info($message) { $_SESSION['info'] = $message; header('Location: users.php'); exit(); } } ?> ================================================ FILE: src/lib/vCard/vCard.php ================================================ * @copyright (c) 2012-2018, Pierre-Henry Soria. All Rights Reserved. * @license GNU General Public License
Sign in to start your session