Author: gsiv1mgyj72u

  • gistash

    Gistash

    Gistash

    Upload your local changes or stashed files to GitHub Gist.

    Downloads Version License Minimum Node.js version PRs welcome! Follow @mittalyashu77

    🧐 About

    Gistash is a CLI tool that lets you save your local changes or stashed file to GitHub gist.

    The whole concept of git-stash to stash the changes in a dirty working directory away.

    There is no option to share your stashed file with other conbtributors.

    💡 Features

    • 🗂 Upload multiple files at once
    • ⏱ Reports each step
    • 🔒 Safely storing your GitHub token on your local machine
    • 👀 Public or private gist
    • 📋 Copy url to clipboard or open in browser
    • ⛏ Maintained

    🔰 Installation

    npm

    $ npm i -g gistash
    

    yarn

    $ yarn global add gistash
    

    🚶🏻‍♂️ Usage

    $ gistash --help
    
    Upload your local changes or stashed files to GitHub Gist.
    
    Usage
    	$ gistash <single|multiple file>
    
    Options
    	-p, --public     Set GitHub gist as public (default: false)
    	-c, --copy       Copy GitHub gist url to clipboard (default: false)
    	-o, --open       Open GitHub gist url in browser
    	-m, --message    GitHub gist description
    	-v, --version    gistash CLI version
    	-h, --help       Showing all available commands
    

    Example

    $ gistash ./hello-world.js --open --public
    
    • Upload hello-world.js file
    • Set gist to public using --public
    • Open in browser with --open

    🙏🏻 Credits

    Visit original content creator repository https://github.com/mittalyashu/gistash
  • lisk-bike

    Lisk Bike

    Demo

    You can try the mobile app on your device by following this link : https://expo.io/@jesusthehun/lisk-bike.
    Download the Expo Client app and scan the QR code.

    BEFORE YOU USE THE DEMO be aware that it will reveal your real location and store it into the demo blockchain.
    If you are in a private location, you might want to use a local blockchain instead.

    Bike Location Behavior

    The bike location is updated when you move with your phone.
    Since bike are not visible on the map if they are already rented, you won’t see the bike’s position updated until you return the bike.

    Development

    Blockchain using Docker

    For the first run we have to create the database before we start the node app.

    cd blockchain
    docker-compose build
    docker-compose up -d psql
    docker exec -ti lisk-psql psql -h localhost -U lisk -d postgres -c "CREATE DATABASE lisk_dev OWNER lisk"
    docker-compose up -d nodejs

    Next times you can use docker-compose start and docker-compose stop

    Create some data

    We will create two accounts, one for the company, one for rent.
    The accounts will be store in json file in the script directory.

    cd tests && node create-accounts.test.js 

    We will now create bikes using the company account.
    The default bike location is in Paris, you can of course edit the script to change their default location.

    node create-bikes.test.js ARG

    Mobile app

    The app has been created with Expo.
    The blockchain needs to be running.

    cd client && npm i
    npm start

    Scan the QR code with the Expo Client app and you are good to go !

    Technical details

    Rent & Return

    To ensure consistency and reversability, both rent & return transaction must specify the previous transaction of each.
    For example, to rent a bike you must specify the lastRentTransactionId and to return the bike you must specify the lastReturnTransactionId.

    Read scripts for more details, they are pretty straight forward.

    Visit original content creator repository
    https://github.com/JesusTheHun/lisk-bike

  • PHP-FSMySQL

    PHP-FSMySQL

    This repository contains the source code of FSMySQL for PHP7+ programming language. The main objective of this mysql connection system with small footprint is to be the fastest and most secure. Repository is currently live and maintained.

    Guide

    USAGE:

    • First Step -> Define the “MySQL” variable and set it to true. Example: define('MySQL', TRUE);
    • Second Step -> Require the connection.php file. Example: require_once('connection.php');
    • Third Step -> Create an instance or object of the DBConnect class. Example: $DBX = new DBConnect();
    • Fourth Step -> Query with built in function. Example: $DBX->dbquery('SQL Query', array('s', mixed $VALUE));
    • Fifth Step -> Destroy or unset the instance or object of the class. Example: unset($DBX);

    NOTE:

    • The function mysqli_report() have five modes. PHP Function MySQLi Report Manual
    • The query command array can take multiple mixed values with the increasing number of “s” as “sss” form.
    • The try catch exception handler can provide full exception detail by providing the “$e” variable on the exit() function.

    Features

    1. Fastest connections due to php raw code implementation.
    2. Most secure sql query courtesy of parameter and string escaping method.
    3. Small footprint of just one file of 1.5KB.
    4. PHP class for easy implementation to other methods.
    5. Defined but synchronous garbage collection.

    Bugs

    1. [CRITICAL] Read sql statements not working due to the usage of result get array tag. [Issue #4]

    Contribute

    FSMySQL is licensed under the GNU General Public v3 License. Anybody is welcome to create issues and pull requests for different bugs and features. We highly acknowledge open source power.

    Visit original content creator repository
    https://github.com/FSMySQL/PHP-FSMySQL

  • SafeGuard

    Some words from the Developer

    Hii it is just my first project in java lang . Well it is also my first app and after 3 month of working , here is its beta version 1.0Beta. it may be full of error , coz we know Error is the best teacher for a programer .

    ok let’s see a brief introduction on it.

    Introduction

    What is SafeGuard ?

    In single sentence

    SafeGuard is a totally offline assistant app that can detect some SOS Signal and can do some predefined work to deal with that situation.

    Well i made this app specialy for protect female. We all know that girls/women are really not safe at this time.There are many cruel criminals outside home.Thus this app is in under Development it may arise many bugs and errors. You can report that by the in app Report button or you may contact me on this (error368280@gmail.com) email and report problem so that we can make the app better for decrease a little amount of the rate of crime.

    Actually i forgot to say “why this app is necessary?”. Actually people can call 112 at the emergency situation but there are many examples of the situation where the victim doesn’t have the time to open his/her phone and call the emergency number. They are busy by either running from the criminal or by dealing with that painful situations. Didn’t they can survive if atleast his/her family or friends (whom they trust) was informed that there might be something wrong with their close one ? In my opinion yes it must be. See , in this situation they must atleast call to the person who may be in problem and confirm is everything all right!! Actually here how my app works 😅

    Before we know how to use it or how it works , lets know some features that my app have.

    features

    1. Shake detection
    2. Voice command

    How it works ?

    My app has a continuously Listening function so In a SOS situation the user can give some predefined voice commands or shake the device that give signal to the app that “User is in problem , we must help her”. By doing this a overlay pop-up will be display to confirm is it accidentally or not. If the user doesn’t give any response to it in 30 seconds, it will trigger its SOS mode.
    In future i will also add some other way to detect the signal and also improve this app as better i can. Below i have put some important note to use my app.

    IMPORTANT

    1. I told that this app is under development and has a continuously listening funtion and also offline , it gonna process all the data in your device . So it can use cpu and battery too much.So when you feel safe and generaly when you at home or any other safe place stop the service from app. App>Home>Stop Button
    2. Start the service only when you feel unsafe . It may not gonna hang your phone but it may take much battery. But you can keep the service ON always if you want . But highly recommend to Start the servie before leave home (generaly at night).
    3. Sometime it may detect false things so when your device vibrate , it show a confirmation window . Remember to check it.

    NOTE

    Since due to privacy , Android restrict Background mic access .So the continuous listen function may misbehave or sometimes it may stop listening . In this case other trigger signal will work so I recommend you to use the shake function and other functiions (i will add soon). If you are using MIUI/Xiaomi phone , there is high chance that it will restict my voice trigger method. Sorry for that. But i am trying to fix this as soon as possible.
    There is a high chance for monthly update . Thus i didn’t add any update alert method so pls check this site for update the app. Soon i will upload it in Google play store (if i got the permission).Later you can update from there.

    Atlast my last word is-

    STAY SAFE , STAY HAPPY , LIVE LIFE WITH JOY AND ENJOY YOUR FREEDOM. IT’S UR RIGHTS
    ~ERROR

    Visit original content creator repository
    https://github.com/E-r-r-o-r-6-6-6/SafeGuard

  • dialogflow-sample-voice-application

    Vonage API – Google Dialogflow integration sample application

    This sample application allows you to call a phone number to interact with a Google Dialogflow agent using Vonage Voice API, including getting real time transcripts and sentiment analysis.

    This application uses a Dialogflow reference connection code (more details below) for the actual 2-way audio interaction with the Dialogflow agent.

    About this sample application

    This sample application makes use of Vonage Voice API to answer incoming voice calls and set up a WebSocket connection to stream audio to and from the Dialogflow reference connection for each call.

    The Dialogflow reference connection code will:

    • Send audio to the Dialogflow agent from caller’s speech,
    • Stream audio responses from the Dialogflow agent to the caller via the WebSocket,
    • Post back in real time transcripts and caller’s speech sentiment scores via webhooks call back to this Voice API sample application.

    Once this application will be running, you call in to the phone number linked to your application (as explained below) to interact via voice with your Dialogflow agent.

    Set up the Dialogflow reference connection code – Host server public hostname and port

    First set up a Dialogflow reference connection code from the dialogflow-reference-connection.

    Default local (not public!) reference connection code port is: 5000.

    If you plan to test using Local deployment with ngrok (Internet tunneling service) for both the Dialogflow reference connection code and this sample application, you may set up multiple ngrok tunnels.

    For the next steps, you will need:

    • The Dialogflow reference connection code server’s public hostname and if necessary public port.

    e.g. xxxxxxxx.ngrok.io, xxxxxxxx.herokuapp.com, myserver.mycompany.com:32000 (as DF_CONNECTING_SERVER, no port, https:// nor http:// are necessary with ngrok or heroku as public hostname)

    Set up your Vonage Voice API application credentials and phone number

    Log in to your or sign up for a Vonage APIs account.

    Go to Your applications, access an existing application or + Create a new application.

    Under Capabilities section (click on [Edit] if you do not see this section):

    Enable Voice

    • Under Answer URL, leave HTTP GET, and enter https://<host>:<port>/answer (replace <host> and <port> with the public host name and if necessary public port of the server where this sample application is running)
    • Under Event URL, select HTTP POST, and enter https://<host>:<port>/event (replace <host> and <port> with the public host name and if necessary public port of the server where this sample application is running)
      Note: If you are using ngrok for this sample application, the answer URL and event URL look like:
      https://yyyyyyyy.ngrok.io/answer
      https://yyyyyyyy.ngrok.io/event
    • Click on [Generate public and private key] if you did not yet create or want new ones, save the private.key file in this application folder.
      IMPORTANT: Do not forget to click on [Save changes] at the bottom of the screen if you have created a new key set.
    • Link a phone number to this application if none has been linked to the application.

    Please take note of your application ID and the linked phone number (as they are needed in the very next section.)

    For the next steps, you will need:

    • Your Vonage API key (as API_KEY)
    • Your Vonage API secret, not signature secret, (as API_SECRET)
    • Your application ID (as APP_ID),
    • The phone number linked to your application (as SERVICE_NUMBER), your phone will call that number,
    • The Dialogflow reference connection code server public hostname and port (as DF_CONNECTING_SERVER)

    Overview on how this sample Voice API application works

    • On an incoming call to the phone number linked to your application, GET /answer route plays a TTS greeting to the caller (“action”: “talk”), then start a WebSocket connection to the Dialogflow agent reference connection (“action”: “connect”),
    • Once the WebSocket is established (GET /ws_event with status “answered”), it plays a TTS greeting to this Dialogflow agent, as the Dialogflow agent expects the user to speak first, we need to start the conversation as one would do in a phone call, with the answerer greeting the caller. The result is that the caller will immediately hear the Dialogflow agent initial greeting (e.g. “How may I help you?”) without having to say anything yet.
      You can customize that inital TTS played to Dialogflow to correspond to your Dialogflow agent programming and use case.
    • Transcripts and sentiment scores will be received by this application in real time,
    • When the caller hangs up, both phone call leg and WebSocket leg will be automatically terminated.

    Running Dialogflow sample Voice API application

    You may select one of the following 2 types of deployments.

    Local deployment

    To run your own instance of this sample application locally, you’ll need an up-to-date version of Node.js (we tested with version 14.3.0).

    Download this sample application code to a local folder, then go to that folder.

    Copy the .env.example file over to a new file called .env:

    cp .env.example .env

    Edit .env file, and set the five parameter values:
    API_KEY=
    API_SECRET=
    APP_ID=
    SERVICE_NUMBER=
    DF_CONNECTING_SERVER=

    Install dependencies once:

    npm install

    Launch the applicatiom:

    node df-application

    Command Line Heroku deployment

    You must first have deployed your application locally, as explained in previous section, and verified it is working.

    Install git.

    Install Heroku command line and login to your Heroku account.

    If you do not yet have a local git repository, create one:

    git init
    git add .
    git commit -am "initial"

    Start by creating this application on Heroku from the command line using the Heroku CLI:

    heroku create myappname

    Note: In above command, replace “myappname” with a unique name on the whole Heroku platform.

    On your Heroku dashboard where your application page is shown, click on Settings button,
    add the following Config Vars and set them with their respective values:
    API_KEY
    API_SECRET
    APP_ID
    SERVICE_NUMBER
    DF_CONNECTING_SERVER

    add also the parameter PRIVATE_KEY_FILE with the value ./private.key

    Now, deploy the application:

    git push heroku master

    On your Heroku dashboard where your application page is shown, click on Open App button, that hostname is the one to be used under your corresponding Vonage Voice API application Capabilities (click on your application, then [Edit]).

    For example, the respective links would be like:
    https://myappname.herokuapp.com/answer
    https://myappname.herokuapp.com/event

    See more details in above section Set up your Vonage Voice API application credentials and phone number.

    From any phone, dial the Vonage number (the one in the .env file). This will connect to the DialogFlow agent (as specified in the .env file), and you will be able to have voice interaction with it.

    Visit original content creator repository
    https://github.com/nexmo-community/dialogflow-sample-voice-application

  • junit-cli-report-viewer

    JUnit CLI report viewer

    npm version Build Status Coverage Status

    JUnit CLI report viewer is a commandline tool to generate CLI reports from JUnit XML format file. It generates a pretty report from provided XML file as shown below.

    output demo

    Installation

    Run following command

    npm install -g junit-cli-report-viewer

    junit-cli-report-viewer command will now be available in your shell.

    Usage

    Pass the path to JUnit XML format file as commandline argument to junit-cli-report-viewer command. For eg:

    junit-cli-report-viewer /Users/amal/reports/junit.xml

    Options

    • --logs flag is to support outputting the stdout and stderr logs for each test case.

    Development

    Questions, problems or suggestions? Please post them on the issue tracker.

    You can contribute changes by forking the project and submitting a pull request. Feel free to contribute 😍

    UNDER MIT LICENSE

    The MIT License (MIT)

    Copyright (c) 2018 Amal Francis

    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.

    Visit original content creator repository https://github.com/amalfra/junit-cli-report-viewer
  • wait-for

    Visit original content creator repository
    https://github.com/eficode/wait-for

  • Kungfu-App

    GitHub commit activity GitHub contributors GitHub forks GitHub last commit GitHub code size in bytes

     Content: 💬😀👍


    Folder: Content:
    affenschwanz “Affenschwanz-Prinzip” mit ISSET / FILTER_VAR and SANITIZING
    API (i) Searchbar mit TMDB (The Movie DB Datenbank) with API for direct database request
    bootstrap_formulare Formular with Bootstrap
    datum_Zeit Date Time
    einfaches_cms Easy CMS without Database
    einfaches_cms_db Not-so-easy CMS with Database
    einstieg OOP (i) Classes / Superclasses / Method (class with function) / Extends / Constructors / functions / modificators
    fit_fuer_MySQL MySQL exercise
    formular_validierung Email / Regex Password / String length (filled fields)
    formular-elemente How to write a form properly (labels, buttons, POST)
    joins Innerjoin / Leftjoin / Joins for Tables / Primary- Foreign Key + Index / namespaces
    login Procedural Login with password HASH and password VERIFY
    OOP_uebungen (i) Dateiupload (Image) / Formular Validation without DB but with ERRORMESSAGES / Image Gallery
    pagination_Seiteninhalt (i) Showing content splitted on various pages (1 of 7 etc)
    PDO (i) Connect to database / Query a database / Using CRUD-Operations / Apply the MVC Model / Login with PDO / Login and registration with PDO
    sessions Mistakes / redirect / write / destroy
    weiterfuehrend_OOP (i) Continuing with Frameworks
    zusMaterial Additional Material

     Licensing: ✅


    • Basic structure, basic comments and design belongs to Rene Esposito, Instructor of https://www.sae.edu/

    • Adjustments are made by me, Sven Kamm, for a better personal understanding and comfortable usage in the future


     Before to start: ✅


    Useful steps:

    1. Make sure you installed XAMPP or MAMP to work with a localhost on an apache-server
    2. Copy this in your htdocs folder to work with your PHP-files
    3. Have you heared about MVC (Model View Controller)? here you go: https://www.youtube.com/watch?v=3OKOe7CraGY

    Why OOP?

    • OOP uses seperate files with concerning tasks – Its better for group work and organized processes
    • Do more in less time: Develop together, changes of code can be made collectively
    • You can re-use the code (less code to compile)
    • Easier to build larger websites
    • Basic PHP (Procedural PHP) still has to be learned for the basic understanding

    Why MVC?

    • it’s a design pattern who takes care of database processes and CRUD-Operations

    • When you chose the way to write PHP-Code with OOP, you automatically start working to use MVC

    • Although connecting to MySQL-Database the procedural way is improved with i = MYSQLI, but for every other file you have to duplicate the code. MVC makes it much easer (1 to 3 are three different “people” or classes):

      0) We want to share our secrets and content: DB
      1) Model = Is the "CEO", which knows everything about the database stuff, connecting to database for example)
      2) View = "Sells stuff for custommers" and works as a communicator in between (gets data from the model and tries to sell it to the controller)
      3) Controller = "Custommer who wants to buy stuff" (where the users do their input and catch infos from the model)
      

     OOP with MVC: “Kurz und knackig” – “Short and Crisp” 🍪


    [GER]

    • Alles wird in Objekte beschrieben
    • Jedes Objekt hat Eigenschaften
    • In den Eigentschaften speichern wir Daten in Form von Funktionalitäten (Methoden)
    • Prozesse zeigen wir mit Methoden auf. Ein Haus z.B mit verkaufen() / abreissen() etc. || Methoden werden immer so dargestellt: Beispiel()

    [ENG]

    • Everything is described in OBJECTS
    • Each OBJECT has PROPERTIES
    • In properties we store data in the form of functionalities (METHODS)
    • We show processes with METHODS. A house, for example, with sell() / demolish() etc. || Methods are always represented like this: Example()

      !IMPORTANT: USEFUL TIPS: 🔥


    I) Use DOTS (.) to interrupt a string:

    $dsn = 'Blabla hello world' . $interruption . 'string goes on';

    II) Use BACKSLASH ( \ ) before inverted commas ( ” ) to interrupt the closing of a string ( \ ” ):

    $code .= "<p><a href=\"movie.php?id=".$out['id']."\">Zum Film</a></p>";
    /*
    1) <a href="" src="" nuten auch Anführungszeichen! Setze ein \ davor um den String nicht abzubrechen!
    2) Wird ein String interrupted I) mit ". .", so setzen wir KEIN \ davor!
    */

    III) Pro tip: Use ( ‘ ) and ( ” ) to avoid taking care of Tip II) with ( \ ):

    $code .= '<p><a href="https://github.com/Svendolin/movie.php?id=".$out['id']."">Zum Film</a></p>';

    IV) < label > and < input > – Who is who?

    <div>
       <label for="vorname">Vorname</label> // for="" des Labels zugehörig zur id="" des Inputs
       <input type="text" id="vorname" name="vorname" value="<?=$vornameValue?>"><br> // name="" wichtig für Affenschwanz Duchgang / value="" PHP Inhalte aus Datenbank anzeigen
    </div>

     OOP and PDO: Important TERMS in this WEBAPP_KUNGFU: 📈


    Term (word): Explenation:
    “INSTANZIERUNG” -> $instanz => “Bauplan” (Wichtig: Nach -> NICHT Dollarzeichen verwenden, da Variable dadurch instanziert wird)
    “AUSGABE” $ausgabe = Ausgabenvariable “Fernseher”, um “Bauplan” durch Ausrufen der Instanz-> anzuzeigen
    “new” Instance a class from .class File to Main-File to create a new object (A)
    PROCEDURAL PHP Regular PHP with tons of code with NO SEPERATE FILES AND CONCERNING TASKS vs:
    OOP PHP with MVC Object Oriented Programming which uses a design pattern called Model View Controller
    MVC – Model View Controller In OOP, we divide the code into certain areas / files: 1)=> A model file (connecting to database) 2)=> A view file (to show what the user has done) and 3)=> A control area (where users do their input), and link them together.
    PDO PHP Data Object, which helps to connect to database in OOP {{{ PDO > CRUD_beispiel / loginWithPDO }}} (Top)= PDO > MySQLi > MySQL =(flop)
    QUERIES Databaserequests. Be sure to use prepared statements to guarantee the maximum amount of safety! To run a query: prepare() > bindParam() > execute()
    ARRAY Data structure that stores one or more similar type of values in a single name
    CLASS (I) A OOP-package of Methods and Properties
    METHOD (II) + (visability) A OOP-function …() in a class {} (I) – Each method has an unique relation to the class you nested it inside of it {}
    PROPERTY (III) + Visability: “Eigenschaft in OOP”: A variable “$” in a class {} to capture a value in this variable + you HAVE TO define the visability as public, protected or private…
    “public” Visability-Accessmodifier: “The counter is open for all” TIP: At first, set everything to Public to make sure your project works.
    “protected” Visability-Accessmodifier: “The counter is closed to the public, department among themselves can continue to operate”. With “protected”, the superclass can “lock the door”, the subclasses “act as emergency keys”
    “private” Visability-Accessmodifier: With “private”, access can neither be guaranteed via main and class files, nor via class inheritance.
    $this $this-Keyword is used to call Methods (II) and Properties (III) in a class (I) “Bauch der Instanzierung”
    OBJECT (A) with “new” in main-processing-document Instance (“Instanzierung”) of a class with an allocated memory (“Sammlung von Variablen”) in the MAIN FILE (index file) => We can define it as a “BLUEPRINT”
    MEMBERS The “called” Methods (II) and Properties (III) in an object (A)
    CONSTRUCTOR function __construct() => Konstruktor-Methode-Infrastrukur (“Grundversorgung einer Methode”(II)) am Anfang einer Klasse (Destructor = Am Ende einer Klasse)
    INHERITANCE with: “Vererbung” with Superclasses (HEREDITARY = VERERBEND) and Subclasses (INHERITED = ERBEND)
    SUPERCLASS > SUBCLASS Subclasses are CHILDS, subordinated and inherited of their PARENTS, known as Superclasses
    EXTENDS Keyword: “subclass of” => class HUND extends HAUSTIER = Therefore: “Hund ist eine Subklasse von Haustier”

    1.1 METHODE (OHNE PROPERTIES) – EINE AUSGABE: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    
    // 0) METHODE definieren: Funktion "rechne()" in einer Klasse "QuadratZahl1"
    // Ausgelagert in .class-Ordner require("class/QuadratZahl1.class.php");
    class QuadratZahl1 {
    
    	// +(Methode)+
    	function rechne($anna) {
    		$resultat = $anna * $anna;
    		return $resultat; // return, kein echo notwendig
    	}
    }
    
    /* ---- MAIN FILE (PROCESSING FILE) ---- */
    
    // 0) Auf das ausgelagerte File zugreifen
    require("class/QuadratZahl1.class.php");
    
    // 1) Object-Instanzierung (Instanz erhält mit "new"-Anweisung die Spezielkraft, Klasse wird mit seinem Namen instanziert)
    $instanz = new QuadratZahl1();
    
    // 1.1) OPT: var_dump() zeigt den Inhalt dieser Klasse auf
    var_dump($instanz);
    
    // 2) Aufrufen in der Instanzvariable mit Parameter (hier 5) und als Ausgabevariable definieren für das spätere Echo
    $ausgabe = $instanz -> rechne(5);
    
    /* ---- MAIN FILE HTML ---- */
    
    // 3) Als echo im HTML ausgeben
    echo $ausgabe; // 25

    1.2 METHODE (OHNE PROPERTIES) – MEHRERE OBJEKT-AUSGABEN: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class QuadratZahl1 {
    
    	// +(Methode)+
    	function rechne($anna) {
    		$resultat = $anna * $anna;
    		return $resultat; // return, kein echo notwendig
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/QuadratZahl1.class.php");
    
    // + (Object 1) +
    $instanz1 = new QuadratZahl1();
    $ausgabe1 = $instanz1 -> rechne(5);
    
    // + (Object 2) +
    $instanz2 = new QuadratZahl1();
    $ausgabe2 = $instanz2 -> rechne(8);
    
    // + (Object 3) +
    $instanz3 = new QuadratZahl1();
    $ausgabe3 = $instanz3 -> rechne(15);
    
    /* MAIN FILE HTML */
    echo "Erste Ausgabe: ".$ausgabe1."<br>";
    echo "Zweite Ausgabe: ".$ausgabe2."<br>";
    echo "Dritte Ausgabe: ".$ausgabe3;

    1.3 METHODE – MIT PROPERTY (EIGENSCHAFT) und VALUE + public + $this + MEHREREN AUSGABEN: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class QuadratZahl2 {
    	
      // public-EIGENSCHAFT "PROPERTY" ist wie eine "VOREINSTELLUNG" in Variable $AntwortSatz. d.h:
      // Wir geben im Bauch des Antwortsatzes automatisch diesen String mit:
    
    	// +(Property mit Value)+ (Dieser String wird der DEFAULT-WERT sein von dieser property) 
    	public $AntwortSatz = "Das Resultat ist: "; 
    	
    	// +(Methode)+
    	function rechne($anna) {
    		/* $this (Zugreifen, was innerhalb der Klasse definiert wurde)
    		- Mit $this wird auf die Eigenschaft zugegriffen, die in allen Methoden sichtbar sind 
    			("Im Bauch der Methode suchen")
    		- Mit $this macht man einen Verweis auf das eigene Objekt aus der VOREINSTELLUNG
    		- Beachte, dass das $-Zeichen vor "AntwortSatz" fehlt!!!
    		*/
    		$resultat = $this->AntwortSatz.$anna * $anna;
    		
    		return $resultat;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/QuadratZahl2class.php");
    
    $instanz = new QuadratZahl2();
    $ausgabe1 = $instanz -> rechne(5); // "rechne()" kümmert sich um "25", public gibt den String mit
    $ausgabe2 = $instanz -> AntwortSatz; // Hier geben wir nur den String mit
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe1; // Das Resultat ist 25
    echo $ausgabe2; // Das Resultat ist

    1.4 METHODE – MIT PROPERTY (EIGENSCHAFT) OHNE VALUE (ft. D.Krossing) —

    /* ---- Beispiel ---- */
    /* ---- .CLASS FILE AUSGELAGERT ---- */
    
    // +(Class)+
    class Person {
    	// +(Properties ohne default Wert)+
    	public $name;
    	public $eyeColor;
    	public $age;
    	
    	// +(Methods)+
    	public function setName($name) {
    		$this->name = $name;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/...");
    // +(Object)+
    
    $instanz = new Person();
    $ausgabe = $instanz -> setName("Sven"); 
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe; // Sven

    2.1 KONSTRUKTOR-METHODE: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class Konstruktiv {
    
    	// +(Property)+ (Schlüsselwort Ausgabe)
    	public $ausgabe;
    
    	// +(Konstruktormethode)+ (Hier wird die GRUNDVERSORGUNG angegeben = WAS DAS OBJEKT ZUM ÜBERLEBEN BRAUCHT)
    	function __construct() { // Immer mit 2x _ schreiben 
    		$string = "Ich wurde geboren am ";
    		$string .= date("d.m.y")." um ";
    		$string .= date("H:i:s");
    		// Hier wird mit echo gearbeitet, dies jedoch nur aus didaktischen Gründen (KEIN RETURN)!!!
    		echo $string; // KEIN return sondern direkt das echo, wenn man __construct() verwendet
    	}
    
    }
    
    /* ---- MAIN FILE ---- */
    require("class/Konstruktiv.class.php");
    
    $instanz = new Konstruktiv();
    
    /* ---- MAIN FILE HTML ---- */
    // "ausgabe" NICHT $ausgabe nach -> da instanziert
    echo $instanz -> ausgabe; // Ich wurde geboren am (Timestamp Datum) um (Timestamp Zeit)

    2.2 KONSTRUKTOR-METHODE MIT BRIEFKASTENVARIABLEN, WELCHE PARAMETER EMPFÄNGT: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class KonstruktivPara {
    	
    	// Die Konstruktormethode empfängt Parameter (Briefkastenvariablen reinschreiben)
    
    	// +(Constructor-Method)+
    	function __construct($param1,$param2) {
    		$str = "Guten Tag ";
    		// Hier wird mit echo gearbeitet, dies jedoch nur aus didaktischen Gründen!!!
    		echo $str.$param1." ".$param2;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/KonstruktivPara.class.php");
    // Die Konstruktormethode wird mit Parameter in Form von x2 Strings"" aufgerufen
    // Instanzierung mit new und Klassenname() (In $instanz ist der ganze Bauplan):
    $instanz = new KonstruktivPara("Peter","Muster");

    2.3 KONSTRUKTOR-METHODE MIT MEHREREN AUSGABEN: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class Kreisberechnung {
    
    	// +(Properties)+
    	public $flaeche = "";
    	public $umfang = "";
    	
    	// +(Konstruktormethode)+
    	function __construct($radius) {
    		// Aufrufen der Hilfs-Methoden
    		$this -> flaeche = $this -> calculateArea($radius);
    		$this -> umfang = $this -> calculateCircumference($radius) ;
    	}
    	
    	// Hilfs-Methode für das Berechnen der Kreisfläche
    	public function calculateArea($r) {
    		$fl = $r * $r * pi();
    		$flGerundet = round($fl, 2);
    		$flAntwort = "Die Kreisflaeche betraegt: ".$flGerundet;
    		return $flAntwort;
    	}
    	
    	// Hilfs-Methode für das Berechnen des Kreisumfangs
    	public function calculateCircumference($r) {
    		$um = 2 * $r * pi();
    		$umGerundet = round($um, 2);
    		$umAntwort = "Der Kreisumfang betraegt: ".$umGerundet;
    		return $umAntwort;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/Kreisberechnung.class.php");
    $instanz = new Kreisberechnung(5);
    // Lesen der Eigenschaften
    $ausgabe1 = $instanz -> flaeche;
    $ausgabe2 = $instanz -> umfang;
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe1;
    echo "<br>";
    echo $ausgabe2;

    3.1 VERERBUNG (INHERITANCE) SUPER- SUBKLASSENBEZIEHUNG: — (Click HERE to view in folder)

    /* ---- ERSTES .CLASS FILE AUSGELAGERT (SUPERKLASSE) ---- */
    //  * Superklasse *
    class Haustier {
    	// Es hat drin: + Porperties (Eigenschaften) für ALLE Haustiere
    	public $geschlecht;
    	public $name;
    	public $art;
    		
    	// Es hat drin: + Methode für ALLE Haustiere
    	function WasBinIch() {
    		$string = "Über mich: Ich bin ein/e ";
    		$string .= $this->art.", "; // $this = Referenz auf Objekt public $art
    		$string .= "ich heisse ".$this->name;
    		$string .= " und ich bin ".$this->geschlecht;
    		return $string;
    	}
    }
    
    /* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */
    // Hier braucht's das Schlüsselwort "extends"
    // Somit ist diese Klasse HUND offiziell eine Subklasse von HAUSTIER
    class Hund extends Haustier {
    		
    	// Diese METHODE gibt's NUR HIER, in der Subklasse
    	function bellen() {
    		$meineWoerter = "Wuff, Wuff";
    		return $meineWoerter;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/Haustier.class.php");
    require("class/Hund.class.php");
    
    // Instanziiert wird hier NUR DIE SUBKLASSE! - "new Hund()" reicht
    // Trotzdem stehen darauf die Mitglieder der Superklasse im Objekt zur Verfügung.
    $instanz = new Hund();
    
    // Eigenschaften schreiben, man beachte:
    // diese gehören zur Instanz der Subklasse, obwohl sie in der Superklasse definiert wurden!!!
    // Über die Instanz ansprechen:
    $instanz -> geschlecht = "männlich";
    $instanz -> name = "Waldi";
    $instanz -> art = "Hund";
    
    // 1) Methode der SUPERKLASSE aufrufen, man beachte:
    // diese gehört zur Instanz der Subklasse, obwohl sie in der Superklasse definiert wurde!!!
    $ausgabe1 = $instanz -> WasBinIch();
    
    // 2) Methode der SUBKLASSE aufrufen:
    $ausgabe2 = $instanz -> bellen();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe1;
    echo "<br>";
    echo $ausgabe2;

    3.2 VERERBUNG SICHTBARKEIT mit ACCESS MODIFIER PROTECTED an Methoden (WIRD AKZEPTIERT): — (Click HERE to view _4 in folder)

    • ((Kurz => “Eltern schützen, Kind frei laufen lassen”))
    /* ---- ERSTES .CLASS FILE AUSGELAGERT (PROTECTED-SUPERKLASSE) ---- */
    //  * Superklasse *
    class SchatzkisteProtected {
    
    	protected function zeigeCodeFuerSchatz() { 
    		$source = "<img src=\"bilder/treasurechest.png\">";
    		return $source;
    	}
    }
    
    /* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */
    //  * Subklasse *
    /* Hier definieren wir die Subklasse welche nicht geschützt ist ABER mit internem ZUGRIFF auf Superklasse */
    class SchatzkisteKind extends SchatzkisteProtected {
    
    	public function KindMethode() {
    		// Aufruf einer Methode in der Superklasse, die mit protected definiert ist
    		$raus = $this -> ZeigeCodeFuerSchatz();
    		return $raus;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/SchatzkisteProtected.class.php");
    require("class/SchatzkisteKind.class.php");
    $instanz = new SchatzkisteKind();
    /* Zugriff auf eine öffentliche Methode der SUBKLASSE,
       die (intern) auf eine Methode der Superklasse zugreift,
       welche ihrerseits mit protected definiert ist:
    	 Sprich: Superklasse verschliesst die Tür, die Subklasse ist unser Notschlüssel! */
    $ausgabe = $instanz -> KindMethode();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe;

    3.3 VERERBUNG SICHTBARKEIT mit ACCESS MODIFIER PRIVATE an Methoden (WIRD ABGEBLOCKT): — (Click HERE to view _5 in folder)

    /* ---- ERSTES .CLASS FILE AUSGELAGERT (SUPERKLASSE) ---- */
    //  * Superklasse *
    class SchatzkistePrivate {
    
    	/* Opt:
    	- Ändere private zu protected, um die Subklasse zu schützen und den Error hier zu löschen! Somit kann die Subklasse 	           ihren part übernehmen
    	- Ändere private zu public, so wird die Superklasse direkt ausgeführt und die Subklasse wäre eigentlich hinfällig
    	*/
    	private function zeigeCodeFuerSchatz() { 
    		$source = "<img src=\"bilder/treasurechest.png\">";
    		return $source;
    	}
    }
    
    /* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */
    //  * Subklasse *
    // Hier braucht's ebenfalls das Schlüsselwort "extends"
    /class SchatzkisteKind2 extends SchatzkistePrivate {
    
    	public function KindMethode() {
    		// Aufruf einer Methode in der Superklasse SchatzkistePrivate, die mit private definiert ist
    		// Dies schlägt fehl
    		$raus = $this -> ZeigeCodeFuerSchatz();
    		return $raus;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/SchatzkistePrivate.class.php"); // Auslagerung der Superklasse (set to private)
    require("class/SchatzkisteKind2.class.php"); // Auslagerung der Subklasse (set to public)
    $instanz = new SchatzkisteKind2();
    // 1) Zugriff auf eine öffentliche Methode der Subklasse SchatzkisteKind2...
    // 2) ...die (intern) auf eine Methode der Superklasse SchatzkistePrivate zugreift...
    // 3) ...welche ihrerseits mit private definiert ist.
    // 4) Das schlägt fehl! Der Notschlüssel
    $ausgabe = $instanz -> KindMethode();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe;

    3.4 Wie kann man den ACCESS MODIFIER private korrekt anwenden? — (Click HERE to view _6 in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class SchatzkistePrivatePlus {
    	// Properties kann man mit Sichtbarkeit schalten, METHODEN enbenfalls!
    	// Somit setzen wir die ertse Methode auf PRIVATE...
    	private function zeigeCodeFuerSchatz() {
    		$source = "<img src=\"bilder/treasurechest.png\">";
    		return $source;
    	}
    	// ...und die zweite Methode auf PUBLIC:
    	// Innerhalb der KLASSE kann auf die obige Methode zugegriffen werden, auch wenn diese mit private definiert ist:
    	public function zweiteMethode() {
    		$sourceVonOben = $this -> zeigeCodeFuerSchatz();
    		return $sourceVonOben;
    	
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/SchatzkistePrivatePlus.class.php");
    $instanz = new SchatzkistePrivatePlus();
    // Zugriff auf eine öffentliche Methode,
    // die (intern) auf eine andere Methode der gleichen Klasse zugreift,
    // welche ihrerseits mit private definiert ist
    $ausgabe = $instanz -> zweiteMethode();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe;

     PDO: Execute Queries = prepare – bind – execute 💡


    1.1. Arbeiten mit CRUD Statements via PDO (Verbindung zur Datenbank) — (Click HERE to view folder)

    /* Localhost siehe: http://localhost/OOP/webapp_kungfu/PDO/CRUD_beispiel/create.php (Create ist hier der "index.php") */
    
    // Welche Funktionen haben die Files?
    
    * SimpleCRUD.class.php = Verwaltungsfile von Klassen und Methoden [prepare() > bindParam() > execute()] + PDO Datenbankzugriff
    * credentials.php = Datenbankangaben
    * create.php = Index.php File mit Inputfelder [CRUD = Create]
    * read.php = Lesefile [CRUD = Read]
    * read_erweitert.php = Tabelle mit [CRUD = Read, Update, Delete]
    * update.php = Update mit ID, wenn User fon read_erweitert.php auf UDPATE klickt [CRUD = Update]

    1.2. Beispiel eines simplen Logins (sign in) OHNE Registrierung (no sign up) — (Click HERE to view folder)

    /* Localhost siehe: http://localhost/OOP/webapp_kungfu/PDO/loginWithPDO/login_form.php (login_form ist hier der "index.php") */
    
    // Welche Funktionen haben die Files?
    
    * SimpleCRUD.class.php = Verwaltungsfile von Klassen und Methoden [prepare() > bindParam() > execute()] + PDO Datenbankzugriff
    * credentials.php = Datenbankangaben
    * login_form.php = Index.php File quasi, Login-Formular mit Inputfelder 
    * login_tabelle.sql = Datenbankformular, wo 2 Nutzer bereits erstellt sind, siehe: test_user.txt
    * success.php = Privater Bereich, falls Login erfolgreich
    
    // Falls man PASSWÖRTER HASHEN möchte...
    
    1) Im Browser anzeigen lassen:
    echo password_hash("YourPasswordHere", PASSWORD_DEFAULT); 
    
    2) Rauskommentieren und Username sowie Passwort aufschreiben
    3) Passender Hash zum Passwort wird zur SQL-Liste hinzugefügt

    Visit original content creator repository https://github.com/Svendolin/Kungfu-App
  • Kungfu-App

    GitHub commit activity GitHub contributors GitHub forks GitHub last commit GitHub code size in bytes

     Content: 💬😀👍


    Folder: Content:
    affenschwanz “Affenschwanz-Prinzip” mit ISSET / FILTER_VAR and SANITIZING
    API (i) Searchbar mit TMDB (The Movie DB Datenbank) with API for direct database request
    bootstrap_formulare Formular with Bootstrap
    datum_Zeit Date Time
    einfaches_cms Easy CMS without Database
    einfaches_cms_db Not-so-easy CMS with Database
    einstieg OOP (i) Classes / Superclasses / Method (class with function) / Extends / Constructors / functions / modificators
    fit_fuer_MySQL MySQL exercise
    formular_validierung Email / Regex Password / String length (filled fields)
    formular-elemente How to write a form properly (labels, buttons, POST)
    joins Innerjoin / Leftjoin / Joins for Tables / Primary- Foreign Key + Index / namespaces
    login Procedural Login with password HASH and password VERIFY
    OOP_uebungen (i) Dateiupload (Image) / Formular Validation without DB but with ERRORMESSAGES / Image Gallery
    pagination_Seiteninhalt (i) Showing content splitted on various pages (1 of 7 etc)
    PDO (i) Connect to database / Query a database / Using CRUD-Operations / Apply the MVC Model / Login with PDO / Login and registration with PDO
    sessions Mistakes / redirect / write / destroy
    weiterfuehrend_OOP (i) Continuing with Frameworks
    zusMaterial Additional Material

     Licensing: ✅


    • Basic structure, basic comments and design belongs to Rene Esposito, Instructor of https://www.sae.edu/

    • Adjustments are made by me, Sven Kamm, for a better personal understanding and comfortable usage in the future


     Before to start: ✅


    Useful steps:

    1. Make sure you installed XAMPP or MAMP to work with a localhost on an apache-server
    2. Copy this in your htdocs folder to work with your PHP-files
    3. Have you heared about MVC (Model View Controller)? here you go: https://www.youtube.com/watch?v=3OKOe7CraGY

    Why OOP?

    • OOP uses seperate files with concerning tasks – Its better for group work and organized processes
    • Do more in less time: Develop together, changes of code can be made collectively
    • You can re-use the code (less code to compile)
    • Easier to build larger websites
    • Basic PHP (Procedural PHP) still has to be learned for the basic understanding

    Why MVC?

    • it’s a design pattern who takes care of database processes and CRUD-Operations

    • When you chose the way to write PHP-Code with OOP, you automatically start working to use MVC

    • Although connecting to MySQL-Database the procedural way is improved with i = MYSQLI, but for every other file you have to duplicate the code. MVC makes it much easer (1 to 3 are three different “people” or classes):

      0) We want to share our secrets and content: DB
      1) Model = Is the "CEO", which knows everything about the database stuff, connecting to database for example)
      2) View = "Sells stuff for custommers" and works as a communicator in between (gets data from the model and tries to sell it to the controller)
      3) Controller = "Custommer who wants to buy stuff" (where the users do their input and catch infos from the model)
      

     OOP with MVC: “Kurz und knackig” – “Short and Crisp” 🍪


    [GER]

    • Alles wird in Objekte beschrieben
    • Jedes Objekt hat Eigenschaften
    • In den Eigentschaften speichern wir Daten in Form von Funktionalitäten (Methoden)
    • Prozesse zeigen wir mit Methoden auf. Ein Haus z.B mit verkaufen() / abreissen() etc. || Methoden werden immer so dargestellt: Beispiel()

    [ENG]

    • Everything is described in OBJECTS
    • Each OBJECT has PROPERTIES
    • In properties we store data in the form of functionalities (METHODS)
    • We show processes with METHODS. A house, for example, with sell() / demolish() etc. || Methods are always represented like this: Example()

      !IMPORTANT: USEFUL TIPS: 🔥


    I) Use DOTS (.) to interrupt a string:

    $dsn = 'Blabla hello world' . $interruption . 'string goes on';

    II) Use BACKSLASH ( \ ) before inverted commas ( ” ) to interrupt the closing of a string ( \ ” ):

    $code .= "<p><a href=\"movie.php?id=".$out['id']."\">Zum Film</a></p>";
    /*
    1) <a href="" src="" nuten auch Anführungszeichen! Setze ein \ davor um den String nicht abzubrechen!
    2) Wird ein String interrupted I) mit ". .", so setzen wir KEIN \ davor!
    */

    III) Pro tip: Use ( ‘ ) and ( ” ) to avoid taking care of Tip II) with ( \ ):

    $code .= '<p><a href="https://github.com/Svendolin/movie.php?id=".$out['id']."">Zum Film</a></p>';

    IV) < label > and < input > – Who is who?

    <div>
       <label for="vorname">Vorname</label> // for="" des Labels zugehörig zur id="" des Inputs
       <input type="text" id="vorname" name="vorname" value="<?=$vornameValue?>"><br> // name="" wichtig für Affenschwanz Duchgang / value="" PHP Inhalte aus Datenbank anzeigen
    </div>

     OOP and PDO: Important TERMS in this WEBAPP_KUNGFU: 📈


    Term (word): Explenation:
    “INSTANZIERUNG” -> $instanz => “Bauplan” (Wichtig: Nach -> NICHT Dollarzeichen verwenden, da Variable dadurch instanziert wird)
    “AUSGABE” $ausgabe = Ausgabenvariable “Fernseher”, um “Bauplan” durch Ausrufen der Instanz-> anzuzeigen
    “new” Instance a class from .class File to Main-File to create a new object (A)
    PROCEDURAL PHP Regular PHP with tons of code with NO SEPERATE FILES AND CONCERNING TASKS vs:
    OOP PHP with MVC Object Oriented Programming which uses a design pattern called Model View Controller
    MVC – Model View Controller In OOP, we divide the code into certain areas / files: 1)=> A model file (connecting to database) 2)=> A view file (to show what the user has done) and 3)=> A control area (where users do their input), and link them together.
    PDO PHP Data Object, which helps to connect to database in OOP {{{ PDO > CRUD_beispiel / loginWithPDO }}} (Top)= PDO > MySQLi > MySQL =(flop)
    QUERIES Databaserequests. Be sure to use prepared statements to guarantee the maximum amount of safety! To run a query: prepare() > bindParam() > execute()
    ARRAY Data structure that stores one or more similar type of values in a single name
    CLASS (I) A OOP-package of Methods and Properties
    METHOD (II) + (visability) A OOP-function …() in a class {} (I) – Each method has an unique relation to the class you nested it inside of it {}
    PROPERTY (III) + Visability: “Eigenschaft in OOP”: A variable “$” in a class {} to capture a value in this variable + you HAVE TO define the visability as public, protected or private…
    “public” Visability-Accessmodifier: “The counter is open for all” TIP: At first, set everything to Public to make sure your project works.
    “protected” Visability-Accessmodifier: “The counter is closed to the public, department among themselves can continue to operate”. With “protected”, the superclass can “lock the door”, the subclasses “act as emergency keys”
    “private” Visability-Accessmodifier: With “private”, access can neither be guaranteed via main and class files, nor via class inheritance.
    $this $this-Keyword is used to call Methods (II) and Properties (III) in a class (I) “Bauch der Instanzierung”
    OBJECT (A) with “new” in main-processing-document Instance (“Instanzierung”) of a class with an allocated memory (“Sammlung von Variablen”) in the MAIN FILE (index file) => We can define it as a “BLUEPRINT”
    MEMBERS The “called” Methods (II) and Properties (III) in an object (A)
    CONSTRUCTOR function __construct() => Konstruktor-Methode-Infrastrukur (“Grundversorgung einer Methode”(II)) am Anfang einer Klasse (Destructor = Am Ende einer Klasse)
    INHERITANCE with: “Vererbung” with Superclasses (HEREDITARY = VERERBEND) and Subclasses (INHERITED = ERBEND)
    SUPERCLASS > SUBCLASS Subclasses are CHILDS, subordinated and inherited of their PARENTS, known as Superclasses
    EXTENDS Keyword: “subclass of” => class HUND extends HAUSTIER = Therefore: “Hund ist eine Subklasse von Haustier”

    1.1 METHODE (OHNE PROPERTIES) – EINE AUSGABE: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    
    // 0) METHODE definieren: Funktion "rechne()" in einer Klasse "QuadratZahl1"
    // Ausgelagert in .class-Ordner require("class/QuadratZahl1.class.php");
    class QuadratZahl1 {
    
    	// +(Methode)+
    	function rechne($anna) {
    		$resultat = $anna * $anna;
    		return $resultat; // return, kein echo notwendig
    	}
    }
    
    /* ---- MAIN FILE (PROCESSING FILE) ---- */
    
    // 0) Auf das ausgelagerte File zugreifen
    require("class/QuadratZahl1.class.php");
    
    // 1) Object-Instanzierung (Instanz erhält mit "new"-Anweisung die Spezielkraft, Klasse wird mit seinem Namen instanziert)
    $instanz = new QuadratZahl1();
    
    // 1.1) OPT: var_dump() zeigt den Inhalt dieser Klasse auf
    var_dump($instanz);
    
    // 2) Aufrufen in der Instanzvariable mit Parameter (hier 5) und als Ausgabevariable definieren für das spätere Echo
    $ausgabe = $instanz -> rechne(5);
    
    /* ---- MAIN FILE HTML ---- */
    
    // 3) Als echo im HTML ausgeben
    echo $ausgabe; // 25

    1.2 METHODE (OHNE PROPERTIES) – MEHRERE OBJEKT-AUSGABEN: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class QuadratZahl1 {
    
    	// +(Methode)+
    	function rechne($anna) {
    		$resultat = $anna * $anna;
    		return $resultat; // return, kein echo notwendig
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/QuadratZahl1.class.php");
    
    // + (Object 1) +
    $instanz1 = new QuadratZahl1();
    $ausgabe1 = $instanz1 -> rechne(5);
    
    // + (Object 2) +
    $instanz2 = new QuadratZahl1();
    $ausgabe2 = $instanz2 -> rechne(8);
    
    // + (Object 3) +
    $instanz3 = new QuadratZahl1();
    $ausgabe3 = $instanz3 -> rechne(15);
    
    /* MAIN FILE HTML */
    echo "Erste Ausgabe: ".$ausgabe1."<br>";
    echo "Zweite Ausgabe: ".$ausgabe2."<br>";
    echo "Dritte Ausgabe: ".$ausgabe3;

    1.3 METHODE – MIT PROPERTY (EIGENSCHAFT) und VALUE + public + $this + MEHREREN AUSGABEN: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class QuadratZahl2 {
    	
      // public-EIGENSCHAFT "PROPERTY" ist wie eine "VOREINSTELLUNG" in Variable $AntwortSatz. d.h:
      // Wir geben im Bauch des Antwortsatzes automatisch diesen String mit:
    
    	// +(Property mit Value)+ (Dieser String wird der DEFAULT-WERT sein von dieser property) 
    	public $AntwortSatz = "Das Resultat ist: "; 
    	
    	// +(Methode)+
    	function rechne($anna) {
    		/* $this (Zugreifen, was innerhalb der Klasse definiert wurde)
    		- Mit $this wird auf die Eigenschaft zugegriffen, die in allen Methoden sichtbar sind 
    			("Im Bauch der Methode suchen")
    		- Mit $this macht man einen Verweis auf das eigene Objekt aus der VOREINSTELLUNG
    		- Beachte, dass das $-Zeichen vor "AntwortSatz" fehlt!!!
    		*/
    		$resultat = $this->AntwortSatz.$anna * $anna;
    		
    		return $resultat;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/QuadratZahl2class.php");
    
    $instanz = new QuadratZahl2();
    $ausgabe1 = $instanz -> rechne(5); // "rechne()" kümmert sich um "25", public gibt den String mit
    $ausgabe2 = $instanz -> AntwortSatz; // Hier geben wir nur den String mit
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe1; // Das Resultat ist 25
    echo $ausgabe2; // Das Resultat ist

    1.4 METHODE – MIT PROPERTY (EIGENSCHAFT) OHNE VALUE (ft. D.Krossing) —

    /* ---- Beispiel ---- */
    /* ---- .CLASS FILE AUSGELAGERT ---- */
    
    // +(Class)+
    class Person {
    	// +(Properties ohne default Wert)+
    	public $name;
    	public $eyeColor;
    	public $age;
    	
    	// +(Methods)+
    	public function setName($name) {
    		$this->name = $name;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/...");
    // +(Object)+
    
    $instanz = new Person();
    $ausgabe = $instanz -> setName("Sven"); 
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe; // Sven

    2.1 KONSTRUKTOR-METHODE: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class Konstruktiv {
    
    	// +(Property)+ (Schlüsselwort Ausgabe)
    	public $ausgabe;
    
    	// +(Konstruktormethode)+ (Hier wird die GRUNDVERSORGUNG angegeben = WAS DAS OBJEKT ZUM ÜBERLEBEN BRAUCHT)
    	function __construct() { // Immer mit 2x _ schreiben 
    		$string = "Ich wurde geboren am ";
    		$string .= date("d.m.y")." um ";
    		$string .= date("H:i:s");
    		// Hier wird mit echo gearbeitet, dies jedoch nur aus didaktischen Gründen (KEIN RETURN)!!!
    		echo $string; // KEIN return sondern direkt das echo, wenn man __construct() verwendet
    	}
    
    }
    
    /* ---- MAIN FILE ---- */
    require("class/Konstruktiv.class.php");
    
    $instanz = new Konstruktiv();
    
    /* ---- MAIN FILE HTML ---- */
    // "ausgabe" NICHT $ausgabe nach -> da instanziert
    echo $instanz -> ausgabe; // Ich wurde geboren am (Timestamp Datum) um (Timestamp Zeit)

    2.2 KONSTRUKTOR-METHODE MIT BRIEFKASTENVARIABLEN, WELCHE PARAMETER EMPFÄNGT: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class KonstruktivPara {
    	
    	// Die Konstruktormethode empfängt Parameter (Briefkastenvariablen reinschreiben)
    
    	// +(Constructor-Method)+
    	function __construct($param1,$param2) {
    		$str = "Guten Tag ";
    		// Hier wird mit echo gearbeitet, dies jedoch nur aus didaktischen Gründen!!!
    		echo $str.$param1." ".$param2;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/KonstruktivPara.class.php");
    // Die Konstruktormethode wird mit Parameter in Form von x2 Strings"" aufgerufen
    // Instanzierung mit new und Klassenname() (In $instanz ist der ganze Bauplan):
    $instanz = new KonstruktivPara("Peter","Muster");

    2.3 KONSTRUKTOR-METHODE MIT MEHREREN AUSGABEN: — (Click HERE to view in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class Kreisberechnung {
    
    	// +(Properties)+
    	public $flaeche = "";
    	public $umfang = "";
    	
    	// +(Konstruktormethode)+
    	function __construct($radius) {
    		// Aufrufen der Hilfs-Methoden
    		$this -> flaeche = $this -> calculateArea($radius);
    		$this -> umfang = $this -> calculateCircumference($radius) ;
    	}
    	
    	// Hilfs-Methode für das Berechnen der Kreisfläche
    	public function calculateArea($r) {
    		$fl = $r * $r * pi();
    		$flGerundet = round($fl, 2);
    		$flAntwort = "Die Kreisflaeche betraegt: ".$flGerundet;
    		return $flAntwort;
    	}
    	
    	// Hilfs-Methode für das Berechnen des Kreisumfangs
    	public function calculateCircumference($r) {
    		$um = 2 * $r * pi();
    		$umGerundet = round($um, 2);
    		$umAntwort = "Der Kreisumfang betraegt: ".$umGerundet;
    		return $umAntwort;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/Kreisberechnung.class.php");
    $instanz = new Kreisberechnung(5);
    // Lesen der Eigenschaften
    $ausgabe1 = $instanz -> flaeche;
    $ausgabe2 = $instanz -> umfang;
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe1;
    echo "<br>";
    echo $ausgabe2;

    3.1 VERERBUNG (INHERITANCE) SUPER- SUBKLASSENBEZIEHUNG: — (Click HERE to view in folder)

    /* ---- ERSTES .CLASS FILE AUSGELAGERT (SUPERKLASSE) ---- */
    //  * Superklasse *
    class Haustier {
    	// Es hat drin: + Porperties (Eigenschaften) für ALLE Haustiere
    	public $geschlecht;
    	public $name;
    	public $art;
    		
    	// Es hat drin: + Methode für ALLE Haustiere
    	function WasBinIch() {
    		$string = "Über mich: Ich bin ein/e ";
    		$string .= $this->art.", "; // $this = Referenz auf Objekt public $art
    		$string .= "ich heisse ".$this->name;
    		$string .= " und ich bin ".$this->geschlecht;
    		return $string;
    	}
    }
    
    /* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */
    // Hier braucht's das Schlüsselwort "extends"
    // Somit ist diese Klasse HUND offiziell eine Subklasse von HAUSTIER
    class Hund extends Haustier {
    		
    	// Diese METHODE gibt's NUR HIER, in der Subklasse
    	function bellen() {
    		$meineWoerter = "Wuff, Wuff";
    		return $meineWoerter;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    require("class/Haustier.class.php");
    require("class/Hund.class.php");
    
    // Instanziiert wird hier NUR DIE SUBKLASSE! - "new Hund()" reicht
    // Trotzdem stehen darauf die Mitglieder der Superklasse im Objekt zur Verfügung.
    $instanz = new Hund();
    
    // Eigenschaften schreiben, man beachte:
    // diese gehören zur Instanz der Subklasse, obwohl sie in der Superklasse definiert wurden!!!
    // Über die Instanz ansprechen:
    $instanz -> geschlecht = "männlich";
    $instanz -> name = "Waldi";
    $instanz -> art = "Hund";
    
    // 1) Methode der SUPERKLASSE aufrufen, man beachte:
    // diese gehört zur Instanz der Subklasse, obwohl sie in der Superklasse definiert wurde!!!
    $ausgabe1 = $instanz -> WasBinIch();
    
    // 2) Methode der SUBKLASSE aufrufen:
    $ausgabe2 = $instanz -> bellen();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe1;
    echo "<br>";
    echo $ausgabe2;

    3.2 VERERBUNG SICHTBARKEIT mit ACCESS MODIFIER PROTECTED an Methoden (WIRD AKZEPTIERT): — (Click HERE to view _4 in folder)

    • ((Kurz => “Eltern schützen, Kind frei laufen lassen”))
    /* ---- ERSTES .CLASS FILE AUSGELAGERT (PROTECTED-SUPERKLASSE) ---- */
    //  * Superklasse *
    class SchatzkisteProtected {
    
    	protected function zeigeCodeFuerSchatz() { 
    		$source = "<img src=\"bilder/treasurechest.png\">";
    		return $source;
    	}
    }
    
    /* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */
    //  * Subklasse *
    /* Hier definieren wir die Subklasse welche nicht geschützt ist ABER mit internem ZUGRIFF auf Superklasse */
    class SchatzkisteKind extends SchatzkisteProtected {
    
    	public function KindMethode() {
    		// Aufruf einer Methode in der Superklasse, die mit protected definiert ist
    		$raus = $this -> ZeigeCodeFuerSchatz();
    		return $raus;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/SchatzkisteProtected.class.php");
    require("class/SchatzkisteKind.class.php");
    $instanz = new SchatzkisteKind();
    /* Zugriff auf eine öffentliche Methode der SUBKLASSE,
       die (intern) auf eine Methode der Superklasse zugreift,
       welche ihrerseits mit protected definiert ist:
    	 Sprich: Superklasse verschliesst die Tür, die Subklasse ist unser Notschlüssel! */
    $ausgabe = $instanz -> KindMethode();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe;

    3.3 VERERBUNG SICHTBARKEIT mit ACCESS MODIFIER PRIVATE an Methoden (WIRD ABGEBLOCKT): — (Click HERE to view _5 in folder)

    /* ---- ERSTES .CLASS FILE AUSGELAGERT (SUPERKLASSE) ---- */
    //  * Superklasse *
    class SchatzkistePrivate {
    
    	/* Opt:
    	- Ändere private zu protected, um die Subklasse zu schützen und den Error hier zu löschen! Somit kann die Subklasse 	           ihren part übernehmen
    	- Ändere private zu public, so wird die Superklasse direkt ausgeführt und die Subklasse wäre eigentlich hinfällig
    	*/
    	private function zeigeCodeFuerSchatz() { 
    		$source = "<img src=\"bilder/treasurechest.png\">";
    		return $source;
    	}
    }
    
    /* ---- ZWEITES .CLASS FILE AUSGELAGERT (SUBKLASSE) ---- */
    //  * Subklasse *
    // Hier braucht's ebenfalls das Schlüsselwort "extends"
    /class SchatzkisteKind2 extends SchatzkistePrivate {
    
    	public function KindMethode() {
    		// Aufruf einer Methode in der Superklasse SchatzkistePrivate, die mit private definiert ist
    		// Dies schlägt fehl
    		$raus = $this -> ZeigeCodeFuerSchatz();
    		return $raus;
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/SchatzkistePrivate.class.php"); // Auslagerung der Superklasse (set to private)
    require("class/SchatzkisteKind2.class.php"); // Auslagerung der Subklasse (set to public)
    $instanz = new SchatzkisteKind2();
    // 1) Zugriff auf eine öffentliche Methode der Subklasse SchatzkisteKind2...
    // 2) ...die (intern) auf eine Methode der Superklasse SchatzkistePrivate zugreift...
    // 3) ...welche ihrerseits mit private definiert ist.
    // 4) Das schlägt fehl! Der Notschlüssel
    $ausgabe = $instanz -> KindMethode();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe;

    3.4 Wie kann man den ACCESS MODIFIER private korrekt anwenden? — (Click HERE to view _6 in folder)

    /* ---- .CLASS FILE AUSGELAGERT ---- */
    class SchatzkistePrivatePlus {
    	// Properties kann man mit Sichtbarkeit schalten, METHODEN enbenfalls!
    	// Somit setzen wir die ertse Methode auf PRIVATE...
    	private function zeigeCodeFuerSchatz() {
    		$source = "<img src=\"bilder/treasurechest.png\">";
    		return $source;
    	}
    	// ...und die zweite Methode auf PUBLIC:
    	// Innerhalb der KLASSE kann auf die obige Methode zugegriffen werden, auch wenn diese mit private definiert ist:
    	public function zweiteMethode() {
    		$sourceVonOben = $this -> zeigeCodeFuerSchatz();
    		return $sourceVonOben;
    	
    	}
    }
    
    /* ---- MAIN FILE ---- */
    
    require("class/SchatzkistePrivatePlus.class.php");
    $instanz = new SchatzkistePrivatePlus();
    // Zugriff auf eine öffentliche Methode,
    // die (intern) auf eine andere Methode der gleichen Klasse zugreift,
    // welche ihrerseits mit private definiert ist
    $ausgabe = $instanz -> zweiteMethode();
    
    /* ---- MAIN FILE HTML ---- */
    echo $ausgabe;

     PDO: Execute Queries = prepare – bind – execute 💡


    1.1. Arbeiten mit CRUD Statements via PDO (Verbindung zur Datenbank) — (Click HERE to view folder)

    /* Localhost siehe: http://localhost/OOP/webapp_kungfu/PDO/CRUD_beispiel/create.php (Create ist hier der "index.php") */
    
    // Welche Funktionen haben die Files?
    
    * SimpleCRUD.class.php = Verwaltungsfile von Klassen und Methoden [prepare() > bindParam() > execute()] + PDO Datenbankzugriff
    * credentials.php = Datenbankangaben
    * create.php = Index.php File mit Inputfelder [CRUD = Create]
    * read.php = Lesefile [CRUD = Read]
    * read_erweitert.php = Tabelle mit [CRUD = Read, Update, Delete]
    * update.php = Update mit ID, wenn User fon read_erweitert.php auf UDPATE klickt [CRUD = Update]

    1.2. Beispiel eines simplen Logins (sign in) OHNE Registrierung (no sign up) — (Click HERE to view folder)

    /* Localhost siehe: http://localhost/OOP/webapp_kungfu/PDO/loginWithPDO/login_form.php (login_form ist hier der "index.php") */
    
    // Welche Funktionen haben die Files?
    
    * SimpleCRUD.class.php = Verwaltungsfile von Klassen und Methoden [prepare() > bindParam() > execute()] + PDO Datenbankzugriff
    * credentials.php = Datenbankangaben
    * login_form.php = Index.php File quasi, Login-Formular mit Inputfelder 
    * login_tabelle.sql = Datenbankformular, wo 2 Nutzer bereits erstellt sind, siehe: test_user.txt
    * success.php = Privater Bereich, falls Login erfolgreich
    
    // Falls man PASSWÖRTER HASHEN möchte...
    
    1) Im Browser anzeigen lassen:
    echo password_hash("YourPasswordHere", PASSWORD_DEFAULT); 
    
    2) Rauskommentieren und Username sowie Passwort aufschreiben
    3) Passender Hash zum Passwort wird zur SQL-Liste hinzugefügt

    Visit original content creator repository https://github.com/Svendolin/Kungfu-App
  • meditation

    meditation

    version downloads license

    A deep and refined theme for the Ghost blog engine.

    preview

    You can see a demo in my own blog.

    Features

    • Responsive
    • QRCode share
    • Social share buttons
    • Focus on reading experience (base on typo.css)
    • Source code highlight (base on highlight.js)

    Installation

    1. Download the latest version from release page;
    2. Unzip into path/to/your/ghost/content/themes folder;
    3. Activate mediation in the Ghost General settings.

    Configuration

    You can configure share buttons and copyright information with $meditationTool by the Ghost code injection feature:

    Write configuration code in Ghost Admin > Settings -> Code Injection -> Blog Footer:

    <script>
      $meditationTool.setShareButtons(['FACEBOOK', 'TWITTER'])
                     .setCopyright('<p>Author: PeachScript</p>');
    </script>

    $meditationTool

    methods

    setShareButtons

    Configure share buttons in the post page. Support the following enumeration values:

    Name Meaning
    DOUBAN Add the Douban share button
    WEIBO Add the Weibo share button
    RENREN Add the Renren share button
    QZONE Add the QQ Zone share button
    GPLUS Add the Google Plus share button
    FACEBOOK Add the Facebook share button
    TWITTER Add the Twitter share button
    QRCODE Add the QRCode button to share by mobile phone

    Usage:

    // Passing an array to set share buttons
    $meditationTool.setShareButtons(['GPLUS', 'FACEBOOK']);
    
    // You also can passing a two-dimensional array to render multi-line share buttons
    $meditationTool.setShareButtons([
      ['FACEBOOK'],
      ['GPLUS', 'TWITTER'],
      ['DOUBAN', 'WEIBO', 'RENREN']
    ]);

    setCopyright

    Configure copyright information in the post page. Support HTML tags.

    Notice: For security you only can call the method once in synchronized manner.

    Usage:

    $meditationTool.setCopyright('<p>Any code you want to insert to the copyright label</p>');

    Development setup

    # install dependencies
    npm install
    
    # start webpack-dev-server
    npm run dev

    Thanks to

    1. typo.css
    2. highlight.js
    3. normalize.css
    4. qrcodejs
    5. webpack
    6. uno-zen

    License

    MIT License

    Copyright (c) 2017 PeachScript

    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.

    Visit original content creator repository https://github.com/PeachScript/meditation