The best code editors for WordPress developers

Hello! Since you are reading this article, it means that you are a WordPress developer, just like me, and strive to make your work with WordPress as productive as possible.

What do we have to do when creating sites on WordPress? We do not just edit PHP files. We should be a programmer and WEB-designer, have the skills to work with HTML, CSS and JavaScript, as it is necessary for a successful WEB-programming.

And a modern IDE or text editor that wants to win the favor of users should provide support for all the necessary languages and technologies.

As a rule, to manage several projects you need a full PHP development environment, such as PhpStorm or CodeLobster. But I also use text editors too, for example if I need to quickly correct a template or modify the code of my function.

Creators of code editors are constantly working on adding new and expanding existing capabilities of their products to support CMS WordPress. Because the community of programmers understand the importance of implementing WordPress support in their software.

I had to spend a lot of time to pick up several IDEs and text editors with advanced features and convenient functionality for WordPress developers.

I suggest you to discover these wonderful programs.

SublimeText

Sublime Text is a fast text editor with a fashionable user interface. It perfectly supports HTML, CSS and JavaScript syntax without additional plug-ins.

To expand the functionality and add tools for WordPress developers, you need to install special packages.

Run the program and go to the main menu “Tools” -> “Install Package Control …”. Package Control is a package that allows you to manage other plug-ins.

After that, you can download, install and remove plug-ins. To start the Package Control, go to the main menu “Preferences” -> “Package Control”.

In order for the program to load the list of available modules, it is necessary to select from the list or enter from the keyboard the command “Install Package”.

Let’s enter “WordPress” in the search bar to filter out the plug-ins specific to this CMS.

From the list, you can immediately select the first “WordPress” package and install it by double-clicking it. This package adds a set of snippets and the ability to auto-complete the functions of WordPress.

Sublime Text

The next plugin we select from the list is called “Search WordPress Codex”. Using it, you can search the official WordPress online help directly from the editor.

For example, right-click on the function and select “WordPress Codex” -> “Search Selection” from the context menu to view online help on it.

Sublime Text

Also there are several popular extensions that you should pay attention to, for example:

  • WordPress snippets – provides a collection of snippets for WordPress programmers.
  • WordPress New Project Config – helps you to create and configure a new project for WordPress CMS.
  • Genesis – facilitates the work of the creators of themes for WordPress, which use the child themes of Genesis.

Atom

Atom is another text editor with a lot of advanced functions and beautiful design. It positions itself as an IDE and successfully competes with other similar programs, such as Sublim Text and Rapid PHP.

Atom is based on themes and packages, so it has a wide range of functions and is flexibly configured. It has its own package manager, which we will use to install WordPress support.

Launch Atom and go to the main menu “File” -> “Settings”. In the opened settings tab, click on “Install”.

Now, to find new packages, enter the keyword “wordpress” in the search field and press “Enter”. You can also click on the “Packages” button.

In the list that appears, let’s choose one of the popular packages, for example – Autocomplete WordPress Hooks. This extension will help the developer by providing the completion of WordPress Actions and Filters.

Find this package in the list and click the “Install” button. After a minute we will see that the package is installed.

Now check the functionality of the just added module. Start type the name of the function and press Ctrl + Space.

Atom Now check the functionality of the just added module. Start type the name of the function and press Ctrl + Space.
Atom

After that, we can also use the hints on the parameters of the function.

Atom

The algorithm for working with other packages is the same. Just read the description, and if the functionality is suitable, install it.

For example, you can install the following add-ons:

  • WordPress API – this add-on greatly speeds up the development process, offering useful WordPress snippets.
  • WordPress Dictionary for Atom – adds snippets for all WordPress functions, including Actions and Filters.

Rapid PHP

Rapid PHP is also a good editor with support of PHP, HTML, CSS and JavaScript. It successfully combines the functionality of the real IDE with high speed.

It is not resource-demanding, has a built-in PHP debugger, supports HTML5, CSS3 and several frameworks, including WordPress.

For higher performance, ability to work with frameworks is disabled by default. To enable WordPress support, go to the main menu “Options” -> “Frameworks”.

In the list that appears, you can select one or more libraries that you want to work with. In this case, choose WordPress and click “OK”.

In the next step, let’s create the project, for that we go to the main menu and select “Project” -> “New Project”.

Now enter the project name and path to the project files. In this example, specify the folder with WordPress installed.

When the project is created, you can view its contents in the right pane of the program using the file browser.

Rapid PHP provides the programmer with ability to use the autocompletion feature when pressing the Ctrl + Space keys.

Rapid PHP
Rapid PHP

You can also trigger an instant prompt on WordPress functions by pressing Shift + Ctrl + Space.

Rapid PHP
Rapid PHP

If in the process of work you need to use the online help for any PHP function, just place the cursor on its name and press the F1 key. The page with online help will be displayed in the browser installed on the system.

CodeLobster

CodeLobster is a functional IDE that provides a complete set of tools for the web developer.

It has an editor of PHP, HTML, CSS and JavaScript with suggestions and autocompletion.

CodeLobster allows you to work with databases directly from the IDE, edit PHP files on the local computer and on a remote server using FTP.

Among other things, you can use PHP debugger, contextual and dynamic help.

There is a convenient function of installing WordPress directly from the program. In addition to that the CMS is installed and configured instantly, much faster than via the WEB-interface.

For example, to create a project, go to the main menu “Project” -> “Create Project …”.

Then in the dialog box, you can specify the type of the project, which will be created using the framework or one of the popular CMS.

Select “Create Empty WordPress Site”, enter the name and specify the location of the directory for installation. Then the New WordPress Site Wizard will run.

It will take only a few steps to configure the connection to the database and at the last step specify the parameters of our blog.

After clicking the “Finish” button, the fresh WordPress distribution will be installed and a new project will be created, you can immediately start working.

If we move the mouse pointer to any function name, we get information about it in a tooltip.

CodeLobster

For full information about this function from the official WordPress documentation, it is enough to select it and press the F1 key.

To use autocompletion, just start typing the name of the function and press Ctrl + Space.

CodeLobster

CodeLobster includes the WordPress plugin in its professional version. That allows the developer to quickly start working with this CMS, since no additional installation is required.

PhpStorm

PhpStorm is a PHP IDE with many convenient features for the web developer. This programming environment is built on the IntelliJ IDEA platform and inherited all the capabilities of the parent platform.

For WordPress programmers, the distribution of the IDE comes with a special plug-in for integration with WordPress.

To start working, you need to register WordPress in the program. Start PhpStorm and go to the main menu “File” -> “Settings …”.

In the settings we will find the section “Languages & Frameworks” and select the “PHP” item. Then in the “Include Path” tab we press the plus button and specify the path to the installed CMS.

The directory with the installation will be indexed, this will allow us to use the WordPress source code when navigating through functions and showing dynamic help.

In addition, you can set the WordPress coding style, which for sure has already became familiar to WordPress developers.

In the program settings window, go to “Editor” -> “Code Style” -> “PHP”. Click on the link “Set from …” and select “Predefined Style” -> “WordPress” from the drop-down list.

Click “OK” to save the settings.

Now consider the process of creation of a new project. In the main menu, select “File” -> “New Project …”.

In the opened dialog, go to the “WordPress Plugin” section and specify the directory for the project and the second one – there the WordPress is installed.

Choose the location of the project in the folder with WordPress. Then click “Create” – so we create a project based on the existing source files.

You should wait a few seconds while PhpStorm scans the files. After that the project is opened and we can continue to study the functions of the program.

To use auto-completion, start entering the name of the function and press Ctrl + Space.

PhpStorm

It is enough just to set the cursor to the function name and press Ctrl + Q to get dynamic help on this function.

PhpStorm

IDE also supports WordPress Actions and Filters. When you press Ctrl + Space, you can quickly get a dynamic hint about the existing parameters.

This review can be completed for now. As you can see, all of the programs in this article have their advantages.

Which one to choose? A simple and lightweight text editor, such as Rapid PHP, or a complex IDE, such as PhpStorm?

I chose CodeLobster, that combines the speed of work, functionality and ease of setting up WordPress projects. I’m happy to add it to my set of web development tools.

It’s very interesting to know what your favorite editor is? Do you create sites on WordPress, or use another CMS? I suggest sharing your experience with other readers. I really look forward to your comments.

 

Alternative way monitoring Zabbix via PHP API

Purpose create this project

Display: alarms, warnings from Zabbix on PHP page. In this case I had to show some information about my services on independent web page.

Set enviroment for Zabbix PHP API

What you need to start:

  1. Zabbix API 2+ – doc: https://www.zabbix.com/documentation/, download: https://www.zabbix.com/download
  2. Apache 2.4+
  3. PHP 7+
  4. Bootstap 3+
  5. I have defined some alarms in Zabbix and I want to observe it in “application”. Just use https://github.com/confirm/PhpZabbixApi and https://www.zabbix.com/documentation/2.2/manual/api
  6. Fronted i use Bootstrap http://getbootstrap.com/javascript/#buttons and some additional lib’s https://datatables.net/extensions/index it is good effective way to make it simple an easy.
  7. Git (Btubucket, Github)

Work set

Zabbix PHP API

PhpZabbixApi is an open-source PHP class library to communicate with the Zabbix™ JSON-RPC API. Because PhpZabbixApi is generated directly from the origin Zabbix™ 2.0 PHP front-end source code / files, each real Zabbix™ JSON-RPC API method is implemented (hard-coded) directly as an own PHP method. This means PhpZabbixApi is IDE-friendly, because you’ve a PHP method for each API method, and there are no PHP magic functions or alike.

Bootstrap

Bootstrap is the most popular HTML, CSS, and JS framework for developing responsive, mobile first projects on the web.

Source code on Bitbucket

<?php
/**
 * ZabbixAPI_class.php Copyright 2017 by Karol Preiskorn
 *
 * @version 18.03.2017 21:35:17 Karol Preiskorn Init
 * @version 19.03.2017 16:37:59 KPreiskorn ZabbixAPI_class.php Export to BB
 *
 */
require_once 'PhpZabbixApi-2.4.5/build/ZabbixApi.class.php';
include 'header.php';

use ZabbixApi\ZabbixApi;

/**
 *
 * @todo add LDAP via uptime
 *
 * @var string $uri
 *
 */

$uri = "http://zabixx";
$username = "user";
$password = "pass";

// set passwords and uri
include "passwords.php";

/**
 * poor print_r function
 *
 * @param unknown $val
 *
 */
function print_r2($val)
{
    echo '<pre>';
    print_r($val);
    echo '</pre>';
}

/**
 * Better print_r function
 */
function obsafe_print_r($var, $return = false, $html = true, $level = 0)
{
    $spaces = "";
    $space = $html ? " " : " ";
    $newline = $html ? "<br />" : "\n";
    for ($i = 1; $i <= 6; $i ++) {
        $spaces .= $space;
    }
    $tabs = $spaces;
    for ($i = 1; $i <= $level; $i ++) {
        $tabs .= $spaces;
    }
    if (is_array($var)) {
        $title = "Array";
    } elseif (is_object($var)) {
        $title = get_class($var) . " Object";
    }
    $output = "<b>" . $title . "</b>" . $newline . $newline;
    foreach ($var as $key => $value) {
        if (is_array($value) || is_object($value)) {
            $level ++;
            $value = obsafe_print_r($value, true, $html, $level);
            $level --;
        }
        $output .= $tabs . "[" . $key . "] => [" . $value . "]" . $newline;
    }
    if ($return)
        return $output;
    else
        echo "<pre>" . $output . "</pre>";
}

/**
 *
 * Generate bootstrap table with headers and coun of elements
 *
 * @param string $title
 * @param unknown $count
 * @param unknown $id
 */
function print_table_header($title, $count, $headers, $id)
{
    print('<div class="panel panel-default">' . "\n");
    print('<div class="panel-heading">' . $title . ' <a href="#"> <span class="badge">' . $count . '</span></a></div>' . "\n");
    print("<table id='" . $id . "' class='table table-striped table-bordered'>" . "\n");

    print("<thead><tr>" . "\n");
    foreach ($headers as $header) {
        print("<th>" . $header . "</th>" . "\n");
    }
    print("</tr>\n</thead>\n<tbody>" . "\n");
}

try {
    // connect to Zabbix API
    $api = new ZabbixApi($uri, $username, $password);

    // get all graphs
    $alerts = $api->alertGet();
    // print_r2 ( $graphs [0] );

    arsort($alerts);

    $headers = array(
        "Alert Id",
        "Event Id",
        "Date time",
        "Sent to",
        "Subject",
        "Message"
    );

    print_table_header('Alerts', count($alerts), $headers, 'alarms');

    // print all alerts
    foreach ($alerts as $alert) {
        if ($alert->sendto != "karol.preiskorn@t-mobile.pl") {
            if (strpos($alert->subject, "PROBLEM:") !== false) {
                $alerttype = "class='warning'";
            } else {
                $alerttype = "class='normal'";
            }
            if (preg_match("/Original event ID: ([0-9]{4,12})/", $alert->message, $regs)) {
                $eventid_org = "[link: <a href='#" . $regs[1] . "'>" . $regs[1] . "</a>]";
            } else {
                $eventid_org = "Not found Original event ID";
            }
            printf("<tr id='%s' %s><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>" . "\n", $alert->eventid, $alerttype, $alert->alertid, $alert->eventid, date("Y-m-d h:i", $alert->clock), $alert->sendto, $alert->subject, $alert->message . " " . $eventid_org);
        }
    }
    print("</tbody>\n</table>\n</div>\n");

    // get all graphs
    $graphs = $api->graphGet();
    $header_graph = array(
        "Graph Id",
        "Description"
    );
    print_table_header('Graph', count($graphs), $header_graph, 'graph');

    // print all graph IDs
    foreach ($graphs as $graph) {
        printf("<tr><td>%8d</td><td>%s</td></tr>\n", $graph->graphid, $graph->name);
    }
    print("</tbody>\n</table>\n</div>\n");

    print('<div class="panel-footer">

        <p>© T-Mobile Polska Company | OSS development powered by Karol Preiskorn | internal use</p>

      </div>');
    print("</div></body></html>"); // end of container

    // print "<h1>Alerts... agian in raw</h2>";
                                       // obsafe_print_r ( $alerts, FALSE, TRUE );
} catch (Exception $e) {
    // Exception in ZabbixApi catched
    echo $e->getMessage();
}
?>
<?php
/**
 *
 * HTML 5
 *
 */
?>
<!DOCTYPE html>
<html>
<head>
<title>Zabbix</title>

<link rel="stylesheet" type="text/css"
	href="https://cdn.datatables.net/v/bs-3.3.7/jq-2.2.4/dt-1.10.13/af-2.1.3/b-1.2.4/b-colvis-1.2.4/fh-3.1.2/kt-2.2.0/r-2.1.1/rr-1.2.0/sc-1.4.2/se-1.2.0/datatables.min.css" />
<script type="text/javascript"
	src="https://cdn.datatables.net/v/bs-3.3.7/jq-2.2.4/dt-1.10.13/af-2.1.3/b-1.2.4/b-colvis-1.2.4/fh-3.1.2/kt-2.2.0/r-2.1.1/rr-1.2.0/sc-1.4.2/se-1.2.0/datatables.min.js"></script>

<script>
$(document).ready(function() {
    $('#alarms').DataTable( {
        deferRender:    true,
        scrollY:        400,
        scrollCollapse: false,
        scroller:       false
    } );
} );


$(document).ready(function() {
	$('#graph').DataTable({
        deferRender:    true,
        scrollY:        400,
        scrollCollapse: false,
        scroller:       false
    } );
} );
</script>

</head>

<body>
	<div class="container">
		<div class="jumbotron">
			<h1>Zabbix Alarm monitoring</h1>
			<p>Aplikacja monitoruje alarmy z Zabbix.</p>

			<a class="btn btn-primary btn-lg"
				href="http://wrex/zabbix/zabbix.php?action=dashboard.view"
				role="button">Zabbix Dashboard</a> <a class="btn btn-lg"
				href="#alarms" role="button">Alarms</a> <a class="btn btn-lg"
				href="#graph" role="button">Graph</a> <a class="btn btn-lg"
				href="simple-json.php" role="button">Simple JSON</a>


			<button class="btn btn-primary" type="button" data-toggle="collapse"
				data-target="#collapseExample" aria-expanded="false"
				aria-controls="collapseExample">About</button>


			<div class="collapse" id="collapseExample">
				<div class="well">Aplikacja monitoruje alarmy z OSS Zabbix na
					serwerze wrex. Dost�p do API poprzez klas� PHP -> ZabbixApi. Opis
					API
					https://www.zabbix.com/documentation/2.2/manual/api/reference/history/get
				</div>
			</div>

		</div>
<?php

/**
 * Zabbix monitoring in PHP
 *
 * @author Karol Preiskorn
 *
 * @version 2017-04-16 KP init
 * @version 17.03.2017 14:47:16 Karol Preiskorn dodanie informacji na temat Alert�w
 * @version 17.03.2017 18:07:38 Karol Preiskorn - dodanie synchronizacji
 * @version 9 gru 2017 12:47:16 KPreiskorn simple-json.php add composer and manage password
 *
 *
 *
 * phpinfo ();
 *
 */
$uri = "http://zabixx";
$username = "user";
$password = "pass";

// set passwords and uri
include "passwords.php";
/**
 *
 * @param unknown $in
 * @param number $indent
 * @param string $from_array
 * @return string
 */
function json_readable_encode($in, $indent = 0, $from_array = true) {
	$_myself = __FUNCTION__;
	$_escape = function ($str) {
		return preg_replace ( "!([\b\t\n\r\f\"\\'])!", "\\\\\\1", $str );
	};

	$out = '';

	foreach ( $in as $key => $value ) {
		$out .= str_repeat ( "\t", $indent + 1 );
		$out .= "\"" . $_escape ( ( string ) $key ) . "\": ";

		if (is_object ( $value ) || is_array ( $value )) {
			$out .= "\n";
			$out .= $_myself ( $value, $indent + 1 );
		} elseif (is_bool ( $value )) {
			$out .= $value ? 'true' : 'false';
		} elseif (is_null ( $value )) {
			$out .= 'null';
		} elseif (is_string ( $value )) {
			$out .= "\"" . $_escape ( $value ) . "\"";
		} else {
			$out .= $value;
		}

		$out .= ",\n";
	}

	if (! empty ( $out )) {
		$out = substr ( $out, 0, - 2 );
	}

	$out = str_repeat ( "\t", $indent ) . "{\n" . $out;
	$out .= "\n" . str_repeat ( "\t", $indent ) . "}";

	return $out;
}

/**
 *
 * @param unknown $array
 */
function expand_arr($array) {
	foreach ( $array as $key => $value ) {
		if (is_array ( $value )) {
			echo "<i>" . $key . "</i>:<br>";
			expand_arr ( $value );
			echo "<br>\n";
		} else {
			echo "<i>" . $key . "</i>: " . $value . "<br>\n";
		}
	}
}
/**
 *
 * @param unknown $uri
 * @param unknown $data
 * @return mixed
 */
function json_request($uri, $data) {
	$json_data = json_encode ( $data );
	$c = curl_init ();
	curl_setopt ( $c, CURLOPT_URL, $uri );
	curl_setopt ( $c, CURLOPT_CUSTOMREQUEST, "POST" );
	curl_setopt ( $c, CURLOPT_RETURNTRANSFER, true );
	curl_setopt ( $c, CURLOPT_POST, $json_data );
	curl_setopt ( $c, CURLOPT_POSTFIELDS, $json_data );
	curl_setopt ( $c, CURLOPT_HTTPHEADER, array (
			'Content-Type: application/json',
			'Content-Length: ' . strlen ( $json_data )
	) );
	curl_setopt ( $c, CURLOPT_SSL_VERIFYPEER, false );
	$result = curl_exec ( $c );

	echo "<b>JSON Request:</b><br>\n";
	echo $json_data . "<br><br>\n";

	echo "<b>JSON Answer:</b><br>\n";
	echo $result . "<br><br>\n";

	/*
	 * echo "<b>CURL Debug Info:</b><br>\n";
	 * $debug = curl_getinfo ( $c );
	 * echo expand_arr ( $debug ) . "<br><hr>\n";
	 */

	return json_decode ( $result, true );
}
/**
 *
 * @param unknown $uri
 * @param unknown $username
 * @param unknown $password
 * @return unknown
 */
function zabbix_auth($uri, $username, $password) {
	$data = array (
			'jsonrpc' => "2.0",
			'method' => "user.login",
			'params' => array (
					'user' => $username,
					'password' => $password
			),
			'id' => "1"
	);
	$response = json_request ( $uri, $data );
	return $response ['result'];
}

/**
 *
 * @param unknown $uri
 * @param unknown $authtoken
 * @return unknown
 */
function zabbix_get_hostgroups($uri, $authtoken) {
	$data = array (
			'jsonrpc' => "2.0",
			'method' => "hostgroup.get",
			'params' => array (
					'output' => "extend",
					'sortfield' => "name"
			),
			'id' => "2",
			'auth' => $authtoken
	);
	$response = json_request ( $uri, $data );
	return $response ['result'];
}
/**
 *
 * @param unknown $uri
 * @param unknown $authtoken
 */
function zabbix_get_alert($uri, $authtoken) {
	$data = array (
			"jsonrpc" => "2.0",
			"method" => "alert.get",
			"params" => array (
					"output" => "extend",
					"actionids" => "3"
			),
			"auth" => $authtoken,
			"id" => 1
	);
	$response = json_request ( $uri, $data );
	return $response ['result'];
}

/**
 *
 * @var Ambiguous $authtoken
 */
print "<h1>Auth</h1>";
$authtoken = zabbix_auth ( $uri, $username, $password );

print "<h1>HostGrups</h1>";
expand_arr ( zabbix_get_hostgroups ( $uri, $authtoken ) );
print "<h2>json_readable_encode</h2>";
json_readable_encode ( zabbix_get_hostgroups ( $uri, $authtoken ) );
print "<h1>Alerts</h1>";
expand_arr ( zabbix_get_alert ( $uri, $authtoken ) );
?>

Sublime Text (3) for PHP Developers

Sublime Text (3) for php Developers Posted on June 26, 2015 | By Matt Stauffer A lot of folks in the php community have been checking out PHPStorm lately, including myself and most of the developers I work with. We love the code intelligence we get from PHPStorm, but still miss the speed, quick boot-up, and convenience of Sublime Text. Before I blindly assume PHPStorm is the only way to go, I wanted to see: Can I bring the things a PHP-focused IDE provides PHP developers back to Sublime Text and ge

Source: Sublime Text (3) for PHP Developers – Matt Stauffer on Laravel, PHP, Frontend development

Narzędzia to projektowania baz danych

GNU-GPL

Multiple versions/licenses (each has a “free” and a “not-free” version)

  • DBVisualizer
  • Toad http://www.toadsoft.com/

Not-free

  • Microsoft Visio – (If you already have it, it does work quite well)
  • DataStudio – 30 day trial http://www.aquafold.com
  • DBWrench – 30 day trial http://www.dbwrench.com/

ER diagram tool

  • http://druid.sf.net/
  • http://schemaspy.sourceforge.net/
  • http://uml.sourceforge.net/index.php

Przykład zadania egazminacyjnego z programowania PHP

Zadanie

  1. Stwórz dwuwymiarową tablicę numeryczną (z użyciem PHP). Napisz funkcję, za pomocą której wyświetlisz tablicę w HTML. Wyświetl tablicę.
  2. Napisz funkcję obliczającą i wyświetlającą sumę wszystkich elementów tej tablicy. Zastosuj ją.
  3. Napisz funkcję znajdującą wartości max i min w tablicy. Napisy funkcję zamieniającą po przekątnej z prawej do lewej wszystkie wartości na max, a z lewej do prawej – na min. Wyświetl wynik.
  4. Zamień losową komórkę tablicy na napis i wyznacz jego długość (za pomocą wyszukiwania napisu). Wyświetl tablicę za pomocą funkcji.
  5. Stwórz formularz odbierający wprowadzone dane podczas rejestracji (login, hasło, powtórzenie hasła, mail, imię, nazwisko, dane ankietowe, lista typu select)

Projekt PHP

  • Stwórz tablicę (z użyciem html). Napisz funkcję, za pomocą której wyświetlisz tablicę. Wyświetl tablicę.
  • Napisz funkcję obliczającą i wyświetlającą sumę wszystkich elementów tej tablicy. Zastosuj ją.
  • Napisz funkcję znajdującą wartości max i min w tablicy.
  • Napisz funkcję zamieniającą po przekątnej z prawej do lewej wszystkie wartości na max, a z lewej do prawej – na min. Wyświetl wynik.
  • Zamień losową komórkę tablicy na napis i wyznacz jego długość (za pomocą wyszukiwania napisu). Wyświetl tablicę za pomocą funkcji.
  1. Stwórz formularz odbierający wprowadzone dane podczas rejestracji
  2. login
  3. hasło
  4. powtórzenie hasła,
  5. mail,
  6. imię,
  7. nazwisko,
  8. dane ankietowe,
  9. lista typu select.

Source from GitHub

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Projekt PHP</title>
    </head>
    <body>
        <h1>Projekt PHP</h1>
        <ol>
            <li>Stwórz tablicę (z użyciem html). Napisz funkcję, za pomocą której wyświetlisz tablicę. Wy-świetl tablicę.</li>
            <li>Napisz funkcję obliczającą i wyświetlającą sumę wszystkich elementów tej tablicy. Zastosuj ją.</li>
            <li>Napisz funkcję znajdującą wartości max i min w tablicy. Napisy funkcję zamieniającą po przekątnej z prawej do lewej wszystkie wartości na max, a z lewej do prawej – na min. Wyświetl wynik.</li>
            <li>Zamień losową komórkę tablicy na napis i wyznacz jego długość (za pomocą wyszukiwania napisu). Wyświetl tablicę za pomocą funkcji.</li>
            <li>Stwórz formularz odbierający wprowadzone dane podczas rejestracji (login, hasło, powtórze-nie hasła, mail, imię, nazwisko, dane ankietowe, lista typu select).</li>
        </ol>
        <?php
        error_reporting(E_ALL);

        function print_pre($p_string) {
            print "<pre>" . print_r($p_string, true) . "</pre>";
        }

        function tablica_wyswietlanie($la_array, $p_nazwa) {
            print "<h3>" . $p_nazwa . "</h3>";
            print "<table>";
            foreach ($la_array as $key_x => $value_x) {
                echo '<tr>';
                foreach ($value_x as $key_y => $value_y) {
                    echo '<td>' . $la_array[$key_x][$key_y] . '</td>';
                }
                echo '</tr>';
            }
            print '</table>';
        }

        function tablica_min_max($la_array, $p_operacja) {
            $max = 0;
            $max_x = 0;
            $max_y = 0;

            $min = 5;
            $min_x = 0;
            $min_y = 0;

            foreach ($la_array as $key_x => $value_x) {
                foreach ($value_x as $key_y => $value_y) {

                    if ($la_array[$key_x][$key_y] >= $max) {
                        $max = $la_array[$key_x][$key_y];
                        $max_x = $key_x;
                        $max_y = $key_y;
                    }

                    if ($la_array[$key_x][$key_y] < $min) {
                        $min = $la_array[$key_x][$key_y];
                        $min_x = $key_x;
                        $min_y = $key_y;
                    }
                }
            }
            if ($p_operacja == 'max') {
                print "<p>max [" . $max_x . ',' . $max_y . "] = " . $max . "</p>";
                return $max;
            } else {
                print "<p>min [" . $min_x . ',' . $min_y . "] = " . $min . "</p>";
                return $min;
            }
        }

        function tablica_suma($la_array) {
            $sum = 0;

            foreach ($la_array as $key_x => $value_x) {
                foreach ($value_x as $key_y => $value_y) {

                    $sum = $sum + $la_array[$key_x][$key_y];
                }
            }
            print "<p>Suma elementów tablicy = " . $sum . "</p>";
        }

        function tablica_przekatna_prawa($la_array, $p_min, $p_max) {
            foreach ($la_array as $key_x => $value_x) {
                foreach ($value_x as $key_y => $value_y) {
                    if ($key_x <= $key_y)
                        $la_array [$key_x][$key_y] = $p_min;
                    if ($key_x > $key_y)
                        $la_array [$key_x][$key_y] = $p_max;
                   
                }
            }
            return $la_array;
        }

        $model = Array(
            array(1, 5, 6),
            array(2, 3, 1),
            array(4, 4, 8),
            array(8, 9, 3));

        print "Ilość pól w tablicy = " . count($model) . "<br>";


        print "<h2>Zadanie 1</h2>";
        tablica_wyswietlanie($model, 'Tablica model');

        print "<h2>Zadanie 2</h2>";
        tablica_suma($model);

        print "<h2>Zadanie 3a</h2>";
        $t_min = tablica_min_max($model, 'min');
        $t_max = tablica_min_max($model, 'max');

        print "<h2>Zadanie 3b</h2>";
        $t_prawa = tablica_przekatna_prawa($model, $t_min, $t_max);
        tablica_wyswietlanie($t_prawa, 'Wypełnienie prawe');
       
        print "<h2>Zadanie 4</h2>";
       
        $l_x = rand(0, 2);
        $l_y = rand(0, 3);
       
        $model[$l_x][$l_y] = 'Jakiś napis...';
       
        tablica_wyswietlanie($model, 'Losowy napis');

        print "<p>Długość napisu model [$l_x][$l_y] = " . strlen($model[$l_x][$l_y])."</p>";
       
        ?>
    </body>
</html>

Hackowanie CMS-ów

Wreszcie się doczekałem ktoś włamał się na stronę którą przygotowałem dziś dzień czyszczenia z wirusów smile emoticon i zabezpieczania CMS-a. W tym krótkim wątku podsumuję w jaki sposób zabezpieczyć się przed włamaniem do CMS (Drupal i WordPress).

Site został najpierw spamowany. Przez nie wykasowany moduł edytora ckeditor. Podejrzany kod:

Po zdekodowaniu wygląda to tak:

Zainfekowanych zostało około 30 plików.

Sublime Text 2 tips for Python and web developers

Update 2014-03: Please see updated blog post for Sublime Text 3. Sublime Text 2 is a very powerful text editor which has gained popularity recently – for good reasons. It is commercial (59 USD). Plenty of power comes from the fact that Sublime has a plug-in framework built in Python. Even though the core app remains closed there exist a vibrant plug-in ecosystem around the editor. Note: You can try Sublime for free. It simply

Źródło: Sublime Text 2 tips for Python and web developers

How to write SAP ABAP web service and consume it in PHP

Last time i spend lot of time to develop SAP ES webservices connected to PHP. Why PHP? Because PHP was fastest method for me. Without starting do it in Java/Tomcat. But now i thing Tomcat will be better… I want o share some information about my work with SAP webservices.

At the beginning most time I spent on configure SAP basis problems with web-services. Roles setting ect.

Basic information about SAP and PHP configuration

  1. SAP ABAP – development
    1. Destination typu „G” InAcT (SM59)  (otwarty na konkretny skrypt PHP)
    2. Embedded pakiet ZIPS\ZWEBSERVICES
    3. Function RFC (external) ZWEBSERV_INACT
    4. Logs ‘BAL_LOG_MSG_ADD’ + view data by IW33 (Tr. SLG1)
    5. Enterprise Serwis: Z_WEBSERV_PM3
  2. SAP AS
    1. Define webserwis SAP WSLD
  3. How it works in SAP?
    1. Simple JOB  fill public table named: ZWEBSRV_PM in procedure Z_JOB_FILL_ZWEBSRV_PM (call with variant
  4. Security
    1. Communication by HTTPS (simple but effective in corp. environment)
  5. InAcT – server Windows x64 2012 R1 (planned migrate do Linux)
    1. Server Apache 2.4/PHP 5.3 (+biblioteka SOAP)
    2. Skrypt PHP index.php
    3. Windows job scheduler call PHP http://SOAP/index.php

Basic information about run and start web services in SAP

  •  SAP Note 1300943
  • Transport web-services SAP Note (need password) no. 1300943

PHP implementation

  • Apache 2.4/PHP 5.6 (now 7)
  • Enable SOAP, XML in php.ini config file
  • Przykład kodu wywołania SOAP AS SAP z poziomu PHP

SAP implementation

  1. Włączenie webswerwisów na ERP
  2. Konfiguracja oraz Noty
  3. Zdefiniowanie modułu funkcyjnego
    1. Typu RFC
    2. Gdzie parametry przekazywane są przez wartość – Pass Values
  4. Zdefiniowanie webserwisu
    1. Utworzenie Enterprise Service
    2. Service Provider
    3. Existing ABAP Objects
  5. Function Module
  6. W wyniku powstaje webserwis i definicja webserwisu plik WSLD.
  7. Należy zdefiniować PROXY w SOAMANAGER.
    1. Provider Security
    2. Configuration of Web Service Binding
    3. SSL
    4. Secure Coversation
    5. Authentitaction Setings
    6. User/ID Password
    7. WSDL Generation
    8. WSDL Format – Standard
    9. Binding SOAP Version –  SOAP 1.1
    10. Przy takich ustawieniach generowany jest WSLD .

 Architecture webserwices SAP and PHP What next?

  1. Zdefiniowanie i wykorzystanie JMS http://en.wikipedia.org/wiki/Java_Message_Service
  2. UUDI http://en.wikipedia.org/wiki/Universally_unique_identifier
  3. Poprawa bezpieczeństwa przez szyfrowanie komunikatów (HTTPS/SSL).
  4. Przejście na klienta JAVA.

Links

  1. https://www.codeproject.com/tips/671437/creating-web-service-using-php-within-minutes/
  2. http://sapuniversity.eu/creation-and-consuming-of-a-webservice-in-sap-abap-without-the-obsolete-transaction-lpconfig/
  3. PHP, SAP and SSL http://wiki.scn.sap.com/wiki/download/attachments/250646828/PHP+-+How+to+Guide.pdf?original_fqdn=wiki.sdn.sap.com&version=2&modificationDate=1318254213504

 

 

Pomiar wydajności bazy danych

Przy wyborze hostingu warto sprawdzić jak prezentuje się wydajność zakupionych serwerów może w tym pomóc skrypt http://www.linux.pl

Po przeróbkach skryptu zainstalowałem go na serwerze http://ultimasolution.pl/projects/bechmark_phpmysql/?iterations=50000&amp;amp;tabletype=MYISAM

i oto co wyszło:

Testing a(n) MYISAM table using 50000 rows.

Successfully created database speedtestdb
Sucessfully created table speedtesttable

This MySQL instance does NOT support MYISAM tables
Table Type Verified: ..

Done. 50000 inserts in 1.98958 seconds or

25131 inserts per second.

Done. 50000 row reads in 6.0E-5 seconds or

833333333 row reads per second.

Done. 50000 updates in 6.0E-5 seconds or

833333333 updates per second.

Inne pomysły na zgadanie wydajności:

 

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑