The document provides instructions for creating a PHP extension module that wraps the libares asynchronous DNS resolving library. It begins by explaining why such an extension is useful and covers generating an extension skeleton, configuring the build system to find libares, the key C API functions to expose, and the basic anatomy of a PHP extension.
The document discusses various PHP wrappers that can be used to read and write data in non-standard ways and bypass security restrictions. It describes how wrappers like php://filter, zip://, and data:// can be used to read and write local files, modify file contents, bypass authentication, and perform XXE attacks. It also notes that filters in the php://filter wrapper can be used to selectively remove parts of file contents during I/O operations.
COSCUP2012: How to write a bash script like the python?Lloyd Huang
This document discusses how to write bash scripts similar to Python scripts by using functions, modules, and documentation strings (docstrings). It explains that bash functions allow for logic, reuse, and unit testing like Python. It demonstrates how to define bash functions, import them as modules, and add docstrings. While bash can mimic some Python features, it has limitations compared to Python for things like namespaces and cannot work with all shells like busybox ash.
PHP 5.5 is the latest version of PHP that includes new features like a password hashing API, generators syntax, and a finally keyword for exceptions. It also includes performance improvements and integration with the OPcache for opcode caching. Some changes in PHP 5.5 include deprecating the mysql extension and preg_replace /e modifier.
The document discusses configuring the Apache web server. It covers topics like:
- The Apache configuration file httpd.conf and options within it like DocumentRoot
- Using .htaccess files to override httpd.conf settings for specific directories
- Configuring password authentication for directories using htpasswd
- Setting up virtual hosts to serve different websites from the same server using different IP addresses
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...Puppet
The document discusses various ways to manage files and lines within files using Puppet, including using the file, concat, augeas, file_line, inifile, datacat, and template resources and functions. It provides examples of managing entire files, specific lines, using static content or templates, and leveraging other modules to manage files and configurations.
An overview of the main questions/design issues when starting to work with databases in Perl
- choosing a database
- matching DB datatypes to Perl datatypes
- DBI architecture (handles, drivers, etc.)
- steps of DBI interaction : prepare/execute/fetch
- ORM principles and difficulties, ORMs on CPAN
- a few examples with DBIx::DataModel
- performance issues
First given at YAPC::EU::2009 in Lisbon. Updated version given at FPW2011 in Paris and YAPC::EU::2011 in Riga
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
Puppet 4 introduces several new features and changes including improved performance, scalability, measurability and flexibility. It features a new Puppet Server based on Clojure and Trapperkeeper, packaging changes, improved environment handling, r10k for managing environments from git, new language features like lambdas and EPP templates, improved data binding and overriding, stronger typing support, and various deprecations around node inheritance, hyphens in names, and other changes. Upgrading requires testing modules against the new version and addressing any compatibility issues.
The document discusses how to install, configure, and uninstall the Apache web server on Linux systems. It provides instructions for installing Apache using packages or compiling from source, editing configuration files to set up the server, and different methods for uninstalling Apache including using package managers or manually deleting files. The document also covers Apache configuration directives for the Prefork and Worker MPM modules and gives an overview of Apache filters and how to use them to manipulate HTTP request and response data.
The document discusses various PHP wrappers that can be used to read and write data in non-standard ways and bypass security restrictions. It describes how wrappers like php://filter, zip://, and data:// can be used to read and write local files, modify file contents, bypass authentication, and perform XXE attacks. It also notes that filters in the php://filter wrapper can be used to selectively remove parts of file contents during I/O operations.
COSCUP2012: How to write a bash script like the python?Lloyd Huang
This document discusses how to write bash scripts similar to Python scripts by using functions, modules, and documentation strings (docstrings). It explains that bash functions allow for logic, reuse, and unit testing like Python. It demonstrates how to define bash functions, import them as modules, and add docstrings. While bash can mimic some Python features, it has limitations compared to Python for things like namespaces and cannot work with all shells like busybox ash.
PHP 5.5 is the latest version of PHP that includes new features like a password hashing API, generators syntax, and a finally keyword for exceptions. It also includes performance improvements and integration with the OPcache for opcode caching. Some changes in PHP 5.5 include deprecating the mysql extension and preg_replace /e modifier.
The document discusses configuring the Apache web server. It covers topics like:
- The Apache configuration file httpd.conf and options within it like DocumentRoot
- Using .htaccess files to override httpd.conf settings for specific directories
- Configuring password authentication for directories using htpasswd
- Setting up virtual hosts to serve different websites from the same server using different IP addresses
Puppet Camp Phoenix 2015: Managing Files via Puppet: Let Me Count The Ways (B...Puppet
The document discusses various ways to manage files and lines within files using Puppet, including using the file, concat, augeas, file_line, inifile, datacat, and template resources and functions. It provides examples of managing entire files, specific lines, using static content or templates, and leveraging other modules to manage files and configurations.
An overview of the main questions/design issues when starting to work with databases in Perl
- choosing a database
- matching DB datatypes to Perl datatypes
- DBI architecture (handles, drivers, etc.)
- steps of DBI interaction : prepare/execute/fetch
- ORM principles and difficulties, ORMs on CPAN
- a few examples with DBIx::DataModel
- performance issues
First given at YAPC::EU::2009 in Lisbon. Updated version given at FPW2011 in Paris and YAPC::EU::2011 in Riga
Puppet Camp Paris 2015: Power of Puppet 4 (Beginner) Puppet
Puppet 4 introduces several new features and changes including improved performance, scalability, measurability and flexibility. It features a new Puppet Server based on Clojure and Trapperkeeper, packaging changes, improved environment handling, r10k for managing environments from git, new language features like lambdas and EPP templates, improved data binding and overriding, stronger typing support, and various deprecations around node inheritance, hyphens in names, and other changes. Upgrading requires testing modules against the new version and addressing any compatibility issues.
The document discusses how to install, configure, and uninstall the Apache web server on Linux systems. It provides instructions for installing Apache using packages or compiling from source, editing configuration files to set up the server, and different methods for uninstalling Apache including using package managers or manually deleting files. The document also covers Apache configuration directives for the Prefork and Worker MPM modules and gives an overview of Apache filters and how to use them to manipulate HTTP request and response data.
This document summarizes some new features in PHP 5.4:
- Array syntax can now be written more concisely using square brackets instead of array functions.
- PHP 5.4 includes a built-in web server for development purposes, allowing PHP scripts to be run without Apache.
- Traits allow sharing of methods across classes to reduce code duplication, similar to mixins in Ruby.
- Closures now support accessing properties of the enclosing class scope via $this.
This document provides PHP tips and tricks summarized in 3 sentences:
It discusses various PHP functions for working with arrays, URLs, variables, objects, output buffering, caching, error handling, and debugging - including array_rand(), parse_url(), compact(), extract(), variable variables, output buffering, auto_prepend caching, and get_debug_backtrace(). The document is presented by Damien Séguy and provides code examples to demonstrate various PHP language features and best practices.
The document provides an introduction to basic UNIX commands written by Razor on January 15, 2000 for new UNIX users. It includes commands for working with files and permissions, such as cp and mv to copy and move files, cd to change directories, pwd to show the current directory, mkdir to create directories, and rm to delete files and directories. The first part focuses on commands for copying, moving, changing directories, viewing the current directory, creating directories, and deleting files and directories.
The document discusses Perl programming and is divided into 5 modules: 1) Introduction to Perl, 2) Regular Expressions, 3) File Handling, 4) Connecting to Databases, and 5) Introduction to Perl Programming. It provides an overview of Perl variables, data types, operators, and basic programming structures. It also covers installing Perl, Perl modules, and interacting with files and databases.
This document provides an introduction to PHP, including:
- PHP is an open source scripting language suited for web development that can be embedded into HTML. Code is placed between <?php ?> tags.
- PHP files are processed by the web server, which returns plain HTML with no PHP code visible. Variables can store and pass different types of data between PHP sections.
- Functions allow common or repetitive tasks to be reused. Popular PHP functions and a large library are available online.
- Form data can be captured with PHP variables like $_POST then inserted into a MySQL database using SQL queries. The data is later retrieved and output dynamically.
- Data validation is important for security. Functions like htmlentities() and mysql
This document summarizes new features in PL/Perl for PostgreSQL 9.0. It introduces new built-in functions for quoting, encoding bytea, and checking if a value looks like a number. It describes improved support for arrays, trusted modules, and executing arbitrary Perl code using DO. The document also covers internal changes like removing the Safe module, new configuration options, and integration with the NYTProf profiler.
BASH Guide Summary
The document summarizes key information about BASH (Bourne Again SHell):
1. BASH is a command interpreter or shell that provides a command line interface for Linux, Unix, and macOS systems. It acts as an interface between the user and the operating system.
2. BASH can be used interactively or in scripts. When used interactively, it displays a prompt and accepts commands one at a time. Scripts contain a sequence of commands that are executed automatically.
3. BASH handles parameters, variables, command substitution, redirection, piping, wildcards, and supports basic programming constructs like conditionals, loops, and functions. It also provides
The Perforce Web Content Management System development team, lacking a pre-existing solution in PHP, designed and implemented their own object model and record layer to ease the interaction of the system with the Perforce Server. This session will focus on how users can access files in Perforce via a simple CRUD API, the subsystems exposed, and their usage.
This document provides an overview and introduction to basic Linux commands and directories for CAD beginners. It discusses the root and home directories, common commands like ls, cd, pwd, and man. It also covers file permissions and the .bashrc file, text editors like vi, the grep command, secure sharing with ssh and scp, compression with zip and tar, installing software from repositories or from source code, and Python package management with pip.
Perl6 introduces a variety of tools for functional programming and writing readable code. Among them parameter declarations and lazy lists. This talk looks at how to get Perl6, where to find examples on RakudoCode, and how to use Perl6 functional tools for converting an algorithm from imperative to functional code, including parallel dispatch with the ">>" operator.
PHP 7 – What changed internally? (PHP Barcelona 2015)Nikita Popov
The document discusses optimizations made in PHP 7 to improve performance. Some key points:
- PHP 7 optimized how values and objects are stored in memory by removing unnecessary overhead like reference counting. This reduces memory usage and indirection.
- Arrays were optimized to reduce the number of allocations, size, and lookup indirections compared to PHP 5.
- Objects saw reduced allocations, size and indirection for property values in PHP 7.
- Other optimizations included using 64-bit integers, improving immutable array performance, and enhancing the virtual machine to better manage function call stacks.
This document provides an overview of some new features and enhancements in Ruby 2.0, including refinements, Module#prepend, keyword arguments, lazy enumerables, %i and %I symbol literals, default UTF-8 encoding, Struct#to_h, respond_to? limitations for protected methods, and require optimizations.
A set of rules and best practices to write bash shell scripts. Following these rules, you will have less programming errors and spend less time debugging.
It also shows and explains a lot of features from bash you didn't event know existed :
Pattern removal: ${var##*/}
StrReplace: ${var//search/replace}
Options: set -o pipefail -o nounset -o noclobber
And many more...
This document provides an overview of Linux Bash shell scripting. It covers topics such as writing basic scripts, variables, conditionals, loops, functions, arguments, and input/output redirection. Examples are given for many common scripting tasks like arithmetic operations, string manipulation, file operations, and comparing values. The document is intended to teach the basics of scripting in the Linux Bash shell.
Training on php by cyber security infotech (csi). Cs-infotech is one of the best cyber security and website development company in India. we also provide Network security, software development, Cyber security corporate training and SEO and SMO services.
Our services are Employee Monitoring System,Employee Monitoring Software,Website Audit,Network Security,Network Audit and Information Security.
PHP is a server-side scripting language commonly used with the LAMP stack. It allows developers to easily create dynamic web pages. The document discusses PHP basics like variables, arrays, functions, and interacting with URLs, APIs, databases and more. It provides examples to demonstrate how to display data, parse XML/JSON, load content from web APIs, and talk to MySQL databases using PHP. Node.js is introduced as a JavaScript runtime that allows writing server-side code with JavaScript in an event-driven, non-blocking way.
Johannes Schlüter's PHPNW08 slides:
The current PHP version, PHP 5.3 introduced a multitude of new language features, most notably namespaces and late static binding, new extensions such as phar, as well as numerous other improvements. Even so, this power-packed release boasts better performance than older PHP releases. This talk will give you a good overview about PHP 5.3 and show some less known features in detail.
The document provides tips for optimizing PHP code, including using string functions instead of regular expressions where possible, passing references to reduce memory usage, using persistent database connections, and checking mysql_unbuffered_query() for faster queries. It also discusses HTTP requests and responses, cookie expiry, references in PHP, returning references from functions, and the debug_backtrace() function. The document concludes with tips for improving security such as checking for uninitialized variables, validating user input, and restricting access to included files.
PHP is a widely-used open source scripting language suited for web development. It allows embedding code into HTML pages to make them dynamic. PHP code is executed on the server and generates HTML that is sent to the client. Key features include using variables, conditional statements, loops, functions, and interacting with databases or external sources. The document provides an introduction to basic PHP syntax and constructs like variables, arrays, operators, control structures, and functions.
This document summarizes some new features in PHP 5.4:
- Array syntax can now be written more concisely using square brackets instead of array functions.
- PHP 5.4 includes a built-in web server for development purposes, allowing PHP scripts to be run without Apache.
- Traits allow sharing of methods across classes to reduce code duplication, similar to mixins in Ruby.
- Closures now support accessing properties of the enclosing class scope via $this.
This document provides PHP tips and tricks summarized in 3 sentences:
It discusses various PHP functions for working with arrays, URLs, variables, objects, output buffering, caching, error handling, and debugging - including array_rand(), parse_url(), compact(), extract(), variable variables, output buffering, auto_prepend caching, and get_debug_backtrace(). The document is presented by Damien Séguy and provides code examples to demonstrate various PHP language features and best practices.
The document provides an introduction to basic UNIX commands written by Razor on January 15, 2000 for new UNIX users. It includes commands for working with files and permissions, such as cp and mv to copy and move files, cd to change directories, pwd to show the current directory, mkdir to create directories, and rm to delete files and directories. The first part focuses on commands for copying, moving, changing directories, viewing the current directory, creating directories, and deleting files and directories.
The document discusses Perl programming and is divided into 5 modules: 1) Introduction to Perl, 2) Regular Expressions, 3) File Handling, 4) Connecting to Databases, and 5) Introduction to Perl Programming. It provides an overview of Perl variables, data types, operators, and basic programming structures. It also covers installing Perl, Perl modules, and interacting with files and databases.
This document provides an introduction to PHP, including:
- PHP is an open source scripting language suited for web development that can be embedded into HTML. Code is placed between <?php ?> tags.
- PHP files are processed by the web server, which returns plain HTML with no PHP code visible. Variables can store and pass different types of data between PHP sections.
- Functions allow common or repetitive tasks to be reused. Popular PHP functions and a large library are available online.
- Form data can be captured with PHP variables like $_POST then inserted into a MySQL database using SQL queries. The data is later retrieved and output dynamically.
- Data validation is important for security. Functions like htmlentities() and mysql
This document summarizes new features in PL/Perl for PostgreSQL 9.0. It introduces new built-in functions for quoting, encoding bytea, and checking if a value looks like a number. It describes improved support for arrays, trusted modules, and executing arbitrary Perl code using DO. The document also covers internal changes like removing the Safe module, new configuration options, and integration with the NYTProf profiler.
BASH Guide Summary
The document summarizes key information about BASH (Bourne Again SHell):
1. BASH is a command interpreter or shell that provides a command line interface for Linux, Unix, and macOS systems. It acts as an interface between the user and the operating system.
2. BASH can be used interactively or in scripts. When used interactively, it displays a prompt and accepts commands one at a time. Scripts contain a sequence of commands that are executed automatically.
3. BASH handles parameters, variables, command substitution, redirection, piping, wildcards, and supports basic programming constructs like conditionals, loops, and functions. It also provides
The Perforce Web Content Management System development team, lacking a pre-existing solution in PHP, designed and implemented their own object model and record layer to ease the interaction of the system with the Perforce Server. This session will focus on how users can access files in Perforce via a simple CRUD API, the subsystems exposed, and their usage.
This document provides an overview and introduction to basic Linux commands and directories for CAD beginners. It discusses the root and home directories, common commands like ls, cd, pwd, and man. It also covers file permissions and the .bashrc file, text editors like vi, the grep command, secure sharing with ssh and scp, compression with zip and tar, installing software from repositories or from source code, and Python package management with pip.
Perl6 introduces a variety of tools for functional programming and writing readable code. Among them parameter declarations and lazy lists. This talk looks at how to get Perl6, where to find examples on RakudoCode, and how to use Perl6 functional tools for converting an algorithm from imperative to functional code, including parallel dispatch with the ">>" operator.
PHP 7 – What changed internally? (PHP Barcelona 2015)Nikita Popov
The document discusses optimizations made in PHP 7 to improve performance. Some key points:
- PHP 7 optimized how values and objects are stored in memory by removing unnecessary overhead like reference counting. This reduces memory usage and indirection.
- Arrays were optimized to reduce the number of allocations, size, and lookup indirections compared to PHP 5.
- Objects saw reduced allocations, size and indirection for property values in PHP 7.
- Other optimizations included using 64-bit integers, improving immutable array performance, and enhancing the virtual machine to better manage function call stacks.
This document provides an overview of some new features and enhancements in Ruby 2.0, including refinements, Module#prepend, keyword arguments, lazy enumerables, %i and %I symbol literals, default UTF-8 encoding, Struct#to_h, respond_to? limitations for protected methods, and require optimizations.
A set of rules and best practices to write bash shell scripts. Following these rules, you will have less programming errors and spend less time debugging.
It also shows and explains a lot of features from bash you didn't event know existed :
Pattern removal: ${var##*/}
StrReplace: ${var//search/replace}
Options: set -o pipefail -o nounset -o noclobber
And many more...
This document provides an overview of Linux Bash shell scripting. It covers topics such as writing basic scripts, variables, conditionals, loops, functions, arguments, and input/output redirection. Examples are given for many common scripting tasks like arithmetic operations, string manipulation, file operations, and comparing values. The document is intended to teach the basics of scripting in the Linux Bash shell.
Training on php by cyber security infotech (csi). Cs-infotech is one of the best cyber security and website development company in India. we also provide Network security, software development, Cyber security corporate training and SEO and SMO services.
Our services are Employee Monitoring System,Employee Monitoring Software,Website Audit,Network Security,Network Audit and Information Security.
PHP is a server-side scripting language commonly used with the LAMP stack. It allows developers to easily create dynamic web pages. The document discusses PHP basics like variables, arrays, functions, and interacting with URLs, APIs, databases and more. It provides examples to demonstrate how to display data, parse XML/JSON, load content from web APIs, and talk to MySQL databases using PHP. Node.js is introduced as a JavaScript runtime that allows writing server-side code with JavaScript in an event-driven, non-blocking way.
Johannes Schlüter's PHPNW08 slides:
The current PHP version, PHP 5.3 introduced a multitude of new language features, most notably namespaces and late static binding, new extensions such as phar, as well as numerous other improvements. Even so, this power-packed release boasts better performance than older PHP releases. This talk will give you a good overview about PHP 5.3 and show some less known features in detail.
The document provides tips for optimizing PHP code, including using string functions instead of regular expressions where possible, passing references to reduce memory usage, using persistent database connections, and checking mysql_unbuffered_query() for faster queries. It also discusses HTTP requests and responses, cookie expiry, references in PHP, returning references from functions, and the debug_backtrace() function. The document concludes with tips for improving security such as checking for uninitialized variables, validating user input, and restricting access to included files.
PHP is a widely-used open source scripting language suited for web development. It allows embedding code into HTML pages to make them dynamic. PHP code is executed on the server and generates HTML that is sent to the client. Key features include using variables, conditional statements, loops, functions, and interacting with databases or external sources. The document provides an introduction to basic PHP syntax and constructs like variables, arrays, operators, control structures, and functions.
The document provides an overview and introduction to PHP including:
- PHP is a server-side scripting language used for web development. It was created by Rasmus Lerdorf in 1995.
- It discusses PHP basics like syntax, variables, strings, arrays, functions, and how to interact with forms and retrieve data from web pages.
- It also covers using PHP to communicate with backend databases and services to fetch and parse XML/JSON data.
PHP is a server-side scripting language commonly used for web development. The document provides an introduction to PHP including a brief history, how PHP scripts are parsed, variables, arrays, operators, control structures, and including external files. It discusses PHP's architecture and how scripts are executed on the server before being sent to the browser.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. Key points:
- PHP scripts are executed on the server and output HTML, JavaScript, or other code to browsers.
- PHP supports variables, arrays, functions, classes, and control structures like if/else statements.
- External data like from text files or databases can be easily incorporated into dynamic web pages using PHP.
- PHP files have a .php extension and PHP code is delimited by <?php ?> tags within HTML files or standalone PHP files.
The document discusses Node.js and compares it to other technologies like CakePHP. It provides an overview of Node.js including its event-driven and asynchronous model, key features like the V8 engine and packages/modules, and frameworks like Express. It then demonstrates building a sample messaging application with a JSON API using both CakePHP and Node.js.
The document introduces PHP as a server-side scripting language that is easy to learn and commonly used with the LAMP stack. It provides examples of basic PHP syntax for variables, arrays, functions, and interacting with URLs and external data sources. The goal is to teach enough PHP to handle simple requests and parse/generate XML and JSON through practical code examples.
PHP is a server-side scripting language commonly used for web development. It allows developers to add dynamic content to websites. PHP code is embedded within HTML and executed on the server before the page is sent to the browser. The document provides an introduction and overview of PHP, covering its history, syntax based on Perl and C, how PHP scripts are parsed and executed, variables, arrays, operators, control structures like if/else and loops, functions to include external files, and how PHP can be used to retrieve and display external data.
The document provides an overview of the Lumen micro-framework by Laravel. It discusses Lumen's system requirements, how to install Lumen using Composer or the Lumen installer, configuring pretty URLs, the directory structure, HTTP routing, middleware, controllers, and views. Additional features covered include caching, databases, encryption, errors and logging, events, queues, testing, and more full-stack features like authentication and mail.
This document provides an introduction to PHP, covering its history, core concepts like variables, arrays, operators, control structures, and how to include external files. PHP is a server-side scripting language commonly used for web development. It was created in 1994 and has evolved through several versions. Key points covered include PHP's loose typing, how variables work and are assigned, the various operators available, using arrays to store multiple values, and control structures like if/else statements and loops to control program flow. The document also discusses including other files to reuse code and read external data files.
This document provides an introduction and overview of PHP. It begins with a brief history of PHP, noting it was created in 1994 and is now one of the premier open source projects. It discusses PHP's server-side scripting capabilities and mentions variables, arrays, operators, functions and control structures as topics that will be covered. The document provides background on PHP and how it is well-suited for dynamic web content. It also discusses PHP parsing and architecture.
This document provides instructions for installing Hadoop on a single node Ubuntu 14.04 system by setting up Java, SSH, creating Hadoop users and groups, downloading and configuring Hadoop, and formatting the HDFS filesystem. Key steps include installing Java and SSH, configuring SSH certificates for passwordless access, modifying configuration files like core-site.xml and hdfs-site.xml to specify directories, and starting Hadoop processes using start-all.sh.
This document discusses performance considerations with PHP 7. It describes how PHP 7 has a new compiler that optimizes code more at compile time compared to PHP 5. PHP 7 also has optimizations for variables, references, hashtables, strings, and encapsed strings that improve performance. These changes make PHP code run faster and be more efficient with memory and CPU cache usage compared to PHP 5.
PHP Basics is a presentation that introduces PHP. It discusses that PHP is a server-side scripting language used for building dynamic websites. It can be embedded into HTML. When a PHP file is requested, the server processes the PHP code and returns the output to the browser as HTML. The presentation covers PHP syntax, variables, data types, operators, functions, and conditional statements. It provides examples to illustrate basic PHP concepts and functionality.
This document provides an overview of Puppet, an open source configuration management tool. It discusses key Puppet concepts like infrastructure as code, reproducible setups, and aligned environments. It also describes Puppet's architecture including the Puppet master, agent nodes, catalogs, resources, and the lifecycle of a Puppet run. The Puppet language is declarative and node-based. Resources are defined and organized into classes. Relationships between resources can be specified.
This document provides an introduction to PHP for beginners. It covers the basics of PHP syntax, variables, arrays, functions, interacting with URLs, loading content from external websites, displaying XML and JSON data, and connecting to a MySQL database. Code samples and links for further reference are included to demonstrate common PHP tasks.
This document provides a help and tutorial for TopStyle Pro version 3.11. It covers getting started with TopStyle, editing style sheets and HTML/XHTML, working with colors, previews, validation, site management, reports, mappings, customization, and third-party integration. It also includes appendices on CSS basics and tips, TopStyle tips and tricks, style sheet resources, keyboard shortcuts, and regular expressions.
TopStyle Help & <b>Tutorial</b>tutorialsruby
This document provides a table of contents for the TopStyle Pro Help & Tutorial, which teaches how to use the TopStyle software for editing style sheets and HTML/XHTML documents. It lists over 50 sections that provide explanations and instructions for features like creating and opening files, editing styles, working with colors, previews, validation, site management, reports and customizing the software. The document was created by Giampaolo Bellavite from the online help provided with TopStyle version 3.11.
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting <b>...</b>tutorialsruby
This document provides the course outline for IMD 210 Fundamentals of Scripting Languages at The Art Institute of Atlanta during the Spring 2005 quarter. The course focuses on integrating programming concepts with interface design using scripting languages like JavaScript and CSS. It will cover topics like DOM, CSS layout, JavaScript variables, conditionals, and events. Students will complete 4 assignments including redesigning existing websites, and there will be weekly quizzes, a midterm, and final exam. The course is worth 4 credits and meets once a week for class and lab.
This document provides the course outline for IMD 210 Fundamentals of Scripting Languages at The Art Institute of Atlanta during the Spring 2005 quarter. The course focuses on integrating programming concepts with interface design using scripting languages like JavaScript and CSS. It will cover topics like DOM, CSS layout, JavaScript variables, conditionals, and events. Students will complete 4 assignments including redesigning existing websites, and there will be weekly quizzes, a midterm, and final exam. The course is worth 4 credits and meets once a week for class and lab.
The group aims to bridge gaps between peer-to-peer database architectures and scaling multimedia information retrieval. They develop a probabilistic multimedia database system with abstraction layers for applications and researchers. They also research challenges of peer-to-peer networks for distributed data management. Both lines are supported by the MonetDB platform to exploit custom hardware and adaptive query optimization. The goal is a modular solution linking theoretical optimal solutions to application demands under resource limitations.
Standardization and Knowledge Transfer – INS0tutorialsruby
The group aims to bridge gaps between peer-to-peer database architectures and scaling multimedia information retrieval. They develop a probabilistic multimedia database system with abstraction layers and a flexible model. They also research challenges of peer-to-peer networks for distributed data management. Both lines are supported by the MonetDB platform to exploit custom hardware and adaptive query optimization. The goal is a modular solution linking theoretical optimal solutions to application demands under resource limitations.
This document provides an introduction to converting HTML documents to XHTML, including the basic syntax changes needed like making all tags lowercase and closing all tags. It provides examples of correct XHTML markup for different tags. It also explains the new DOCTYPE declaration and shows a sample well-formed XHTML document incorporating all the discussed changes. Resources for learning more about XHTML are listed at the end.
This document provides an introduction to converting HTML documents to XHTML, including the basic syntax changes needed like making all tags lowercase and closing all tags. It provides examples of correct XHTML markup for different tags. It also explains the new DOCTYPE declaration and shows a sample well-formed XHTML document incorporating all the discussed changes. Resources for learning more about XHTML are listed at the end.
XHTML is a markup language that provides structure and semantics to web pages. It is based on XML and is more strict than HTML. XHTML pages must have a document type definition, html and head tags, and a body where the visible content goes. Common XHTML tags include paragraphs, lists, links, images, and divisions to logically separate content. While XHTML provides structure, CSS is used to style pages and control visual presentation by defining rules for tags. CSS rules are defined in external style sheets to keep presentation separate from structure and content.
XHTML is a markup language that provides structure and semantics to web pages. It is based on XML and is more strict than HTML. XHTML pages must have a document type definition, html and head tags, and a body where the visible content goes. Common XHTML tags include paragraphs, lists, links, images, and divisions to logically separate content. While XHTML provides structure, CSS is used to style pages and control visual presentation through rules that target specific XHTML elements.
This document discusses how to create and use external cascading style sheets (CSS) in Dreamweaver. It provides steps to:
1. Open the CSS Styles tab in Dreamweaver and create a new external CSS stylesheet using a sample text style.
2. Save the stylesheet and link it to a new HTML page to style elements like headings, text sizes, and boxes.
3. Edit existing styles by selecting a tag in the CSS Styles panel and modifying properties directly, or by clicking the tag and using the pencil icon to edit in a window. This allows customizing styles globally across all linked pages.
This document provides an overview of how to create and use cascading style sheets (CSS) in Dreamweaver. It describes the different types of style sheets, including external and internal style sheets. It outlines the steps to create an external style sheet in Dreamweaver using the CSS Styles panel and provides instructions for linking the external style sheet to an HTML page. The document demonstrates how to experiment with predefined styles and how to edit, add, and delete styles in the CSS stylesheet.
This document appears to be a weekly update from an intro to computer science course. It includes summaries of classmates' demographics, comfort levels, and prior experience. It also discusses time spent on problem sets and recommends upcoming courses in CS51 and CS61. Finally, it recommends reading on TCP/IP, HTTP, XHTML, CSS, PHP, SQL and using the bulletin board for questions.
This document appears to be a weekly update from an intro to computer science course. It includes summaries of classmates' demographics, comfort levels, and prior experience. It also discusses time spent on problem sets and recommends upcoming courses in CS51 and CS61. Finally, it recommends reading on topics like TCP/IP, HTTP, XHTML, CSS, PHP, SQL and using bulletin boards, and includes images related to these topics.
The document discusses how to use Cascading Style Sheets (CSS) with Corvid Servlet Runtime templates to control formatting and layout. CSS allows separating design from content, making templates simpler and easier to maintain. It also enables adapting appearance for different devices. The document provides examples of using CSS classes to style template elements and explains how to set up a demo system using the included CSS and templates.
The document discusses how to use Cascading Style Sheets (CSS) with Corvid Servlet Runtime templates to control formatting and layout. CSS allows separating design from content, making templates simpler and easier to maintain. It also enables customization of appearance for different devices. The document provides examples of how to apply CSS classes and rules to Corvid template elements to control fonts, colors, positioning and more.
The document provides an introduction to CSS and how it works with HTML to control the presentation and styling of web page content. It explains basic CSS concepts like selectors, properties and values, and how CSS rules are used to target specific HTML elements and style them. Examples are given of common CSS properties and selectors and how they can be used to style elements and format the layout of web pages.
The document introduces CSS and how it works with HTML to separate content from presentation, allowing the styling of web pages through rules that target HTML elements. It explains CSS syntax and various selectors like type, class, ID, and descendant selectors. Examples are provided of how CSS can be used to style properties like color, font, padding, and layout of elements on a page.
Cascading Style Sheets (CSS) allow users to define how HTML elements are presented on a page. CSS enables changing the appearance and layout of an entire website by editing just one CSS file. CSS uses selectors to apply styles to HTML elements via properties and values. Styles can be defined internally in HTML or externally in CSS files. CSS can control text formatting, colors, spacing, positioning and more to achieve visual consistency across web pages.
Cascading Style Sheets (CSS) allow users to define how HTML elements are presented on a page. CSS enables changing the appearance and layout of an entire website by editing just one CSS file. CSS uses selectors to apply styles to HTML elements via properties and values. Styles can be defined internally in HTML or externally in CSS files. CSS can control text formatting, colors, spacing, positioning and more to achieve visual consistency across web pages.
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIVladimir Iglovikov, Ph.D.
Presented by Vladimir Iglovikov:
- https://www.linkedin.com/in/iglovikov/
- https://x.com/viglovikov
- https://www.instagram.com/ternaus/
This presentation delves into the journey of Albumentations.ai, a highly successful open-source library for data augmentation.
Created out of a necessity for superior performance in Kaggle competitions, Albumentations has grown to become a widely used tool among data scientists and machine learning practitioners.
This case study covers various aspects, including:
People: The contributors and community that have supported Albumentations.
Metrics: The success indicators such as downloads, daily active users, GitHub stars, and financial contributions.
Challenges: The hurdles in monetizing open-source projects and measuring user engagement.
Development Practices: Best practices for creating, maintaining, and scaling open-source libraries, including code hygiene, CI/CD, and fast iteration.
Community Building: Strategies for making adoption easy, iterating quickly, and fostering a vibrant, engaged community.
Marketing: Both online and offline marketing tactics, focusing on real, impactful interactions and collaborations.
Mental Health: Maintaining balance and not feeling pressured by user demands.
Key insights include the importance of automation, making the adoption process seamless, and leveraging offline interactions for marketing. The presentation also emphasizes the need for continuous small improvements and building a friendly, inclusive community that contributes to the project's growth.
Vladimir Iglovikov brings his extensive experience as a Kaggle Grandmaster, ex-Staff ML Engineer at Lyft, sharing valuable lessons and practical advice for anyone looking to enhance the adoption of their open-source projects.
Explore more about Albumentations and join the community at:
GitHub: https://github.com/albumentations-team/albumentations
Website: https://albumentations.ai/
LinkedIn: https://www.linkedin.com/company/100504475
Twitter: https://x.com/albumentations
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
How to Get CNIC Information System with Paksim Ga.pptxdanishmna97
Pakdata Cf is a groundbreaking system designed to streamline and facilitate access to CNIC information. This innovative platform leverages advanced technology to provide users with efficient and secure access to their CNIC details.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Cosa hanno in comune un mattoncino Lego e la backdoor XZ?Speck&Tech
ABSTRACT: A prima vista, un mattoncino Lego e la backdoor XZ potrebbero avere in comune il fatto di essere entrambi blocchi di costruzione, o dipendenze di progetti creativi e software. La realtà è che un mattoncino Lego e il caso della backdoor XZ hanno molto di più di tutto ciò in comune.
Partecipate alla presentazione per immergervi in una storia di interoperabilità, standard e formati aperti, per poi discutere del ruolo importante che i contributori hanno in una comunità open source sostenibile.
BIO: Sostenitrice del software libero e dei formati standard e aperti. È stata un membro attivo dei progetti Fedora e openSUSE e ha co-fondato l'Associazione LibreItalia dove è stata coinvolta in diversi eventi, migrazioni e formazione relativi a LibreOffice. In precedenza ha lavorato a migrazioni e corsi di formazione su LibreOffice per diverse amministrazioni pubbliche e privati. Da gennaio 2020 lavora in SUSE come Software Release Engineer per Uyuni e SUSE Manager e quando non segue la sua passione per i computer e per Geeko coltiva la sua curiosità per l'astronomia (da cui deriva il suo nickname deneb_alpha).
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
UiPath Test Automation using UiPath Test Suite series, part 6DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 6. In this session, we will cover Test Automation with generative AI and Open AI.
UiPath Test Automation with generative AI and Open AI webinar offers an in-depth exploration of leveraging cutting-edge technologies for test automation within the UiPath platform. Attendees will delve into the integration of generative AI, a test automation solution, with Open AI advanced natural language processing capabilities.
Throughout the session, participants will discover how this synergy empowers testers to automate repetitive tasks, enhance testing accuracy, and expedite the software testing life cycle. Topics covered include the seamless integration process, practical use cases, and the benefits of harnessing AI-driven automation for UiPath testing initiatives. By attending this webinar, testers, and automation professionals can gain valuable insights into harnessing the power of AI to optimize their test automation workflows within the UiPath ecosystem, ultimately driving efficiency and quality in software development processes.
What will you get from this session?
1. Insights into integrating generative AI.
2. Understanding how this integration enhances test automation within the UiPath platform
3. Practical demonstrations
4. Exploration of real-world use cases illustrating the benefits of AI-driven test automation for UiPath
Topics covered:
What is generative AI
Test Automation with generative AI and Open AI.
UiPath integration with generative AI
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfMalak Abu Hammad
Discover how MongoDB Atlas and vector search technology can revolutionize your application's search capabilities. This comprehensive presentation covers:
* What is Vector Search?
* Importance and benefits of vector search
* Practical use cases across various industries
* Step-by-step implementation guide
* Live demos with code snippets
* Enhancing LLM capabilities with vector search
* Best practices and optimization strategies
Perfect for developers, AI enthusiasts, and tech leaders. Learn how to leverage MongoDB Atlas to deliver highly relevant, context-aware search results, transforming your data retrieval process. Stay ahead in tech innovation and maximize the potential of your applications.
#MongoDB #VectorSearch #AI #SemanticSearch #TechInnovation #DataScience #LLM #MachineLearning #SearchTechnology
Maruthi Prithivirajan, Head of ASEAN & IN Solution Architecture, Neo4j
Get an inside look at the latest Neo4j innovations that enable relationship-driven intelligence at scale. Learn more about the newest cloud integrations and product enhancements that make Neo4j an essential choice for developers building apps with interconnected data and generative AI.
1. Extending PHP
Wez Furlong
wez@thebrainroom.com
PHP{Con West, Santa Clara, October 2003
2. Extending PHP
Sooner or later, you will find that PHP doesn't do everything that you need
it to do.
• No bindings for a particular library
• Might want to integrate PHP more tightly into your existing
systems (or vice versa)
• Maybe PHP script is too slow for performance critical parts of
your application
Rather than abandon (the otherwise perfect!) PHP and search for an
alternative language, it could easily be worthwhile to extend PHP to make
it do what you want.
3. What we will cover
• Generating an extension skeleton (ext_skel)
• config.m4 and the PHP build system
• Extension Anatomy 101
• PHP_FUNCTION
• Resources
• Parameter passing
We have 3 hours of interactive tutorial time; feel free to ask questions at
any point. Shout if I don't seem to have noticed you!
To give us focus, I've picked on an asynchronous DNS resolving library
and we'll create a PHP extension for it today, right now.
4. libares
Starting with PHP 4.3.0, it is now possible to write some pretty smart
multiplexing networking applications stream_select(). The only problem is
that the standard DNS functions gethostbyname() block the whole script
until the domain name resolves.
Wouldn't it be nice to have an alternative method of resolving DNS that
won't cause your existing sockets to time out?
We'll be using libares (written by Greg Hudson) as the basis of a PHP
extension that provides such an alternative method. libares is released
under an MIT license.
5. ares C API
Before we can write the extension, we have to have some knowledge of
the code that we want to expose to our PHP scripts.
Focusing on replacing gethostbyname(), ares provides the following
interesting functions:
interesting ares API
typedef void (*ares_host_callback)(void *arg, int status,
struct hostent *hostent);
int ares_init(ares_channel *channelptr);
void ares_destroy(ares_channel channel);
void ares_gethostbyname(ares_channel channel, const char *name,
int family, ares_host_callback callback, void *arg);
int ares_fds(ares_channel channel, fd_set *read_fds, fd_set *write_fds);
void ares_process(ares_channel channel, fd_set *read_fds,
fd_set *write_fds);
Typical usage for these functions (taken from the ahost example code in
ares distribution) looks something like this:
example of ares API in action
#include <ares.h>
/* gets called when the name has been resolved */
static void callback(void *arg, int status, struct hostent *host)
{
char *mem, **p;
struct in_addr addr;
if (status != ARES_SUCCESS) {
fprintf(stderr, "%s: %sn", (char*)arg,
ares_strerror(status, &mem));
ares_free_errmem(mem);
}
for (p = host->h_addr_list; *p; p++) {
memcpy(&addr, *p, sizeof(addr));
printf("%s: %sn", host->h_name, inet_ntoa(addr));
}
}
int main(int argc, char **argv)
{
ares_channel channel;
char *errmem;
int status, nfds;
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
/* create/initialize a channel for DNS communications */
6. status = ares_init(&channel);
if (status != ARES_SUCCESS) {
fprintf(stderr, "ares_init: %sn",
ares_strerror(status, &errmem));
ares_free_errmem(errmem);
return 1;
}
/* for each command line arg */
for (argv++; *argv; argv++) {
/* look up the domain name */
ares_gethostbyname(channel, *argv, AF_INET, callback, *argv);
}
/* wait for the queries to complete */
while (1) {
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
select(nfds, &read_fds, &write_fds, NULL, tvp);
/* calls the callback as appropriate */
ares_process(channel, &read_fds, &write_fds);
}
/* all done */
ares_destroy(channel);
return 0;
}
7. extension functions
Based on the C api, a nice convenient PHP alternative might look like this:
PHP version of ares resolving
<?php
function gothost($hostname, $status, $hostent)
{
if ($status != ARES_SUCCESS) {
echo "Failed to resolve $hostname: "
. ares_strerror($status) . "n";
return;
}
foreach ($hostent['addr_list'] as $ip) {
echo "$hostent[name] -> $ipn";
}
}
/* for each argument, resolve it */
function lookup_hosts()
{
$args = func_get_args();
$resolver = ares_init();
foreach ($args as $arg) {
ares_gethostbyname($resolver, $arg, 'gothost', $arg);
}
// wait up to 2 seconds for hosts to be resolved
while (ares_process_with_timeout($resolver, 2) > 0) {
// timed out (2 seconds are up)
// could do other stuff here while waiting
echo ".";
}
ares_destroy($resolver);
}
?>
We have arrived at a list of 5 functions that we need to implement in our
PHP extension:
• ares_init()
• ares_gethostbyname()
• ares_process_with_timeout()
• ares_destroy()
• ares_strerror()
Of these, ares_process_with_timeout() is special, as it wraps up a
number of bits and pieces that are difficult to bring into user space. Later,
we will look at plugging ares into stream_select(), but lets get this basic
step out of the way first.
8. ext_skel
Make sure you have these things ready:
• Latest PHP 4 source release
• ares headers and library
• Working build environment(!)
First thing to do is to generate an extension skeleton which will contain all
the stuff that PHP needs to be able to see your code.
generating a skeleton
% cd php4.3.x/ext
% ./ext_skel --extname=ares
ext_skel will produce output like this:
ext_skel output
Creating directory ares
Creating basic files: config.m4 .cvsignore ares.c php_ares.h CREDITS EXPERIMENTAL
tests/001.phpt ares.php [done].
To use your new extension, you will have to execute the following steps:
1. $ cd ..
2. $ vi ext/ares/config.m4
3. $ ./buildconf
4. $ ./configure --[with|enable]-ares
5. $ make
6. $ ./php -f ext/ares/ares.php
7. $ vi ext/ares/ares.c
8. $ make
Repeat steps 3-6 until you are satisfied with ext/ares/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.
As it suggests, looking in the config.m4 file is the first thing we need to do -
we want configure to be able to find libares, so it is an essential step.
9. config.m4: the PHP build system
PHP has an excellent flexible build system. Each extension defines a
config.m4 containing shell script (and m4 macros) to help locate libraries
and headers that are required.
ext_skel has conveniently generated a template for us to use; all we need
to do is uncomment the parts that apply to our extension.
ares config.m4
dnl $Id$
dnl config.m4 for extension ares
PHP_ARG_WITH(ares, for ares support,
[ --with-ares Include ares support])
if test "$PHP_ARES" != "no"; then
# --with-ares -> check with-path
SEARCH_PATH="/usr/local /usr"
SEARCH_FOR="/include/ares.h"
if test -r $PHP_ARES/; then # path given as parameter
ARES_DIR=$PHP_ARES
else # search default path list
AC_MSG_CHECKING([for ares files in default path])
for i in $SEARCH_PATH ; do
if test -r $i/$SEARCH_FOR; then
ARES_DIR=$i
AC_MSG_RESULT(found in $i)
fi
done
fi
if test -z "$ARES_DIR"; then
AC_MSG_RESULT([not found])
AC_MSG_ERROR([Please reinstall the ares distribution])
fi
# --with-ares -> add include path
PHP_ADD_INCLUDE($ARES_DIR/include)
# --with-ares -> check for lib and symbol presence
LIBNAME=ares
LIBSYMBOL=ares_init
PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
[
PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $ARES_DIR/lib, ARES_SHARED_LIBADD)
AC_DEFINE(HAVE_ARESLIB,1,[ ])
],[
AC_MSG_ERROR([wrong ares lib version or lib not found])
],[
-L$ARES_DIR/lib -lm
])
PHP_SUBST(ARES_SHARED_LIBADD)
PHP_NEW_EXTENSION(ares, ares.c, $ext_shared)
fi
10. Extension Anatomy 101
php_ares.h as generated by ext_skel
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
$Id: header,v 1.10.8.1 2003/07/14 15:59:18 sniper Exp $
*/
#ifndef PHP_ARES_H
#define PHP_ARES_H
extern zend_module_entry ares_module_entry;
#define phpext_ares_ptr &ares_module_entry
#ifdef PHP_WIN32
#define PHP_ARES_API __declspec(dllexport)
#else
#define PHP_ARES_API
#endif
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_MINIT_FUNCTION(ares);
PHP_MSHUTDOWN_FUNCTION(ares);
PHP_RINIT_FUNCTION(ares);
PHP_RSHUTDOWN_FUNCTION(ares);
PHP_MINFO_FUNCTION(ares);
PHP_FUNCTION(confirm_ares_compiled); /* For testing, remove later. */
/*
Declare any global variables you may need between the BEGIN
and END macros here:
ZEND_BEGIN_MODULE_GLOBALS(ares)
long global_value;
char *global_string;
ZEND_END_MODULE_GLOBALS(ares)
*/
/* In every utility function you add that needs to use variables
in php_ares_globals, call TSRM_FETCH(); after declaring other
variables used by that function, or better yet, pass in TSRMLS_CC
after the last function argument and declare your utility function
with TSRMLS_DC after the last declared argument. Always refer to
the globals in your function as ARES_G(variable). You are
encouraged to rename these macros something shorter, see
examples in any other php module directory.
*/
11. #ifdef ZTS
#define ARES_G(v) TSRMG(ares_globals_id, zend_ares_globals *, v)
#else
#define ARES_G(v) (ares_globals.v)
#endif
#endif /* PHP_ARES_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* indent-tabs-mode: t
* End:
*/
ares.c as generated by ext_skel
/*
+----------------------------------------------------------------------+
| PHP Version 4 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2003 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 2.02 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.php.net/license/2_02.txt. |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: |
+----------------------------------------------------------------------+
$Id: header,v 1.10.8.1 2003/07/14 15:59:18 sniper Exp $
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_ares.h"
/* If you declare any globals in php_ares.h uncomment this:
ZEND_DECLARE_MODULE_GLOBALS(ares)
*/
/* True global resources - no need for thread safety here */
static int le_ares;
/* {{{ ares_functions[]
*
* Every user visible function must have an entry in ares_functions[].
*/
function_entry ares_functions[] = {
PHP_FE(confirm_ares_compiled, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in ares_functions[] */
};
/* }}} */
/* {{{ ares_module_entry
*/
zend_module_entry ares_module_entry = {
#if ZEND_MODULE_API_NO >= 20010901
STANDARD_MODULE_HEADER,
#endif
"ares",
12. ares_functions,
PHP_MINIT(ares),
PHP_MSHUTDOWN(ares),
PHP_RINIT(ares), /* Replace with NULL if there's nothing to do at request
start */
PHP_RSHUTDOWN(ares), /* Replace with NULL if there's nothing to do at request end
*/
PHP_MINFO(ares),
#if ZEND_MODULE_API_NO >= 20010901
"0.1", /* Replace with version number for your extension */
#endif
STANDARD_MODULE_PROPERTIES
};
/* }}} */
#ifdef COMPILE_DL_ARES
ZEND_GET_MODULE(ares)
#endif
/* {{{ PHP_INI
*/
/* Remove comments and fill if you need to have entries in php.ini
PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("ares.global_value", "42", PHP_INI_ALL, OnUpdateInt,
global_value, zend_ares_globals, ares_globals)
STD_PHP_INI_ENTRY("ares.global_string", "foobar", PHP_INI_ALL, OnUpdateString,
global_string, zend_ares_globals, ares_globals)
PHP_INI_END()
*/
/* }}} */
/* {{{ php_ares_init_globals
*/
/* Uncomment this function if you have INI entries
static void php_ares_init_globals(zend_ares_globals *ares_globals)
{
ares_globals->global_value = 0;
ares_globals->global_string = NULL;
}
*/
/* }}} */
/* {{{ PHP_MINIT_FUNCTION
*/
PHP_MINIT_FUNCTION(ares)
{
/* If you have INI entries, uncomment these lines
ZEND_INIT_MODULE_GLOBALS(ares, php_ares_init_globals, NULL);
REGISTER_INI_ENTRIES();
*/
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MSHUTDOWN_FUNCTION(ares)
{
/* uncomment this line if you have INI entries
UNREGISTER_INI_ENTRIES();
*/
return SUCCESS;
}
/* }}} */
/* Remove if there's nothing to do at request start */
/* {{{ PHP_RINIT_FUNCTION
*/
PHP_RINIT_FUNCTION(ares)
{
return SUCCESS;
}
/* }}} */
/* Remove if there's nothing to do at request end */
13. /* {{{ PHP_RSHUTDOWN_FUNCTION
*/
PHP_RSHUTDOWN_FUNCTION(ares)
{
return SUCCESS;
}
/* }}} */
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(ares)
{
php_info_print_table_start();
php_info_print_table_header(2, "ares support", "enabled");
php_info_print_table_end();
/* Remove comments if you have entries in php.ini
DISPLAY_INI_ENTRIES();
*/
}
/* }}} */
/* Remove the following function when you have succesfully modified config.m4
so that your module can be compiled into PHP, it exists only for testing
purposes. */
/* Every user-visible function in PHP should document itself in the source */
/* {{{ proto string confirm_ares_compiled(string arg)
Return a string to confirm that the module is compiled in */
PHP_FUNCTION(confirm_ares_compiled)
{
char *arg = NULL;
int arg_len, len;
char string[256];
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) ==
FAILURE) {
return;
}
len = sprintf(string, "Congratulations! You have successfully modified
ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "ares", arg);
RETURN_STRINGL(string, len, 1);
}
/* }}} */
/* The previous line is meant for vim and emacs, so it can correctly fold and
unfold functions in source code. See the corresponding marks just before
function definition, where the functions purpose is also documented. Please
follow this convention for the convenience of others editing your code.
*/
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/
14. ares_init - resources
The first function that we are going to implement is ares_init(). In the C
library, ares_init initializes a structure and then all other functions operate
on a pointer to that structure. Since we don't have structures and pointers
in PHP, we need to declare a resource type.
Resources are implemented in PHP using a global (per request) linked list
of resource identifiers. Each individual resource has associated with it:
• A resource "type" id
• A pointer value
In order to return a resource to the script, we will need to register a
resource type when our extension is loaded. We need to do this so that the
Zend Engine knows how to release the resource when the script
terminates - we register the resource with a destructor function.
registering a resource
/* True global resources - no need for thread safety here */
static int le_ares_channel;
static void ares_channel_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
/* TODO: rsrc->ptr need to be released correctly */
}
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MINIT_FUNCTION(ares)
{
le_ares_channel = zend_register_list_destructors_ex(ares_channel_dtor,
NULL, "ares channel", module_number);
return SUCCESS;
}
*/
Now we need to write the PHP function itself.
implementing ares_init()
/* {{{ proto resource ares_init()
Creates a DNS resolving communications channel */
PHP_FUNCTION(ares_init)
{
ares_channel channel;
int status;
status = ares_init(&channel);
if (status != ARES_SUCCESS) {
15. char *errmem;
ares_strerror(status, &errmem);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "failed to init ares channel: %s",
errmem);
ares_free_errmem(errmem);
RETURN_NULL();
}
ZEND_REGISTER_RESOURCE(return_value, channel, le_ares_channel);
}
/* }}} */
• ares_channel is typedef'd as a pointer type
• If the channel couldn't be created, a regular php E_WARNING is
raised, and NULL is returned.
For the sake of completeness, lets implement ares_destroy() now too. It
demonstrates how to accept a resource type as a parameter.
ares_destroy()
/* {{{ proto void ares_destroy(resource $channel)
Destroys a DNS resolving channel */
PHP_FUNCTION(ares_destroy)
{
zval *r;
ares_channel channel;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"r", &r)) {
return;
}
ZEND_FETCH_RESOURCE(channel, ares_channel, &r, -1, "ares channel",
le_ares_channel);
zend_list_delete(Z_LVAL_P(r));
}
/* }}} */
• ZEND_FETCH_RESOURCE will automatically emit an error and return
from the function if the $channel parameter is not a valid channel
resource (eg: stream or image)
Almost done - now that we know how we are creating the channel, we
should fill in that dtor so it really does some work.
registering a resource
static void ares_channel_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
{
ares_channel channel = (ares_channel)rsrc->ptr;
ares_destroy(channel);
}
16. ares_gethostbyname()
Now we can write the real core of the extension - the resolver. We
decided that the API for the function would work like this:
function prototype for ares_gethostbyname
<?php
ares_gethostbyname($channel, $hostname, $callback, $callbackarg);
?>
So we need to write a PHP_FUNCTION that accepts a resource, a string,
and two generic zval values as parameters.
ares_gethostbyname() in C
/* {{{ proto void ares_gethostbyname(resource $channel, string $hostname, mixed
$callback, mixed $arg)
Initiate resolution of $hostname; will call $callback with $arg when complete */
PHP_FUNCTION(ares_gethostbyname)
{
zval *zchannel, *zcallback, *zarg;
char *hostname;
long hostname_len;
ares_channel channel;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rszz",
&zchannel, &hostname, &hostname_len, &zcallback, &zarg)) {
return;
}
ZEND_FETCH_RESOURCE(channel, ares_channel, &zchannel, -1, "ares channel",
le_ares_channel);
/* more code to go here ... */
}
/* }}} */
Now, we've hit a little bit of a hurdle - we need to call back into the engine
when the resolution completes. There is a little bit of magic required, since
we can't call a PHP_FUNCTION directly from C (well, we can, but we can't
call it directly from this callback). We need to define a structure to hold the
function name (or object + method name) of the callback, as well as the
argument. We'll pass those to ares and have a little stub C function to act
as the real callback:
structure and callback for gethostbyname
struct php_ares_callback_struct {
zval *callback;
zval *arg;
};
static void php_ares_hostcallback(void *arg, int status, struct hostent *host)
17. {
struct php_ares_callback_struct *cb = (struct php_ares_callback_struct *)arg;
/* TODO: map hostent to php and call the callback */
}
Let's jump back to the gethostbyname function and fill in the callback
structure:
ares_gethostbyname() continued
/* {{{ proto void ares_gethostbyname(resource $channel, string $hostname, mixed
$callback, mixed $arg)
Initiate resolution of $hostname; will call $callback with $arg when complete */
PHP_FUNCTION(ares_gethostbyname)
{
zval *zchannel, *zcallback, *zarg;
char *hostname, *callback_name;
long hostname_len;
ares_channel channel;
struct php_ares_callback_struct *cb;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rszz",
&zchannel, &hostname, &hostname_len, &zcallback, &zarg)) {
return;
}
ZEND_FETCH_RESOURCE(channel, ares_channel, &zchannel, -1, "ares channel",
le_ares_channel);
/* verify that the callback will work */
if (!zend_is_callable(zcallback, 0, &callback_name)) {
php_error_docref1(NULL TSRMLS_CC, callback_name, E_WARNING,
"3rd argument is not a valid callback");
efree(callback_name);
return;
}
/* copy the values into the structure */
cb = (struct php_ares_callback_struct*)emalloc(sizeof(*cb));
MAKE_STD_ZVAL(cb->callback);
*cb->callback = *zcallback;
zval_copy_ctor(*cb->callback);
MAKE_STD_ZVAL(cb->arg);
*cb->arg = *zarg;
zval_copy_ctor(*cb->arg);
ares_get_hostbyname(channel, hostname, AF_INET,
php_ares_hostcallback, cb);
}
/* }}} */
We can come back to the callback now - we have another little problem -
we can't pass a struct hostent directly to a script, so we need to copy the
data from it into a zval that can be passed. Looking back at our API
sample, we chose to use an array with keys named similarly to the C
structure:
the sample PHP version of the callback
<?php
function gothost($hostname, $status, $hostent)
{
18. if ($status != ARES_SUCCESS) {
echo "Failed to resolve $hostname: "
. ares_strerror($status) . "n";
return;
}
foreach ($hostent['addr_list'] as $ip) {
echo "$hostent[name] -> $ipn";
}
}
?>
So the task is now to create an array and set it up as follows:
layout of the hostent parameter
<?php
$hostent = array();
$hostent['name'] = $hostname;
$hostent['addr_list'] = array();
$hostent['addr_list'][] = $ip1;
?>
The C translation of that code looks like this:
building a hostent array in C
static void php_ares_hostcallback(void *arg, int status, struct hostent *host)
{
struct php_ares_callback_struct *cb = (struct php_ares_callback_struct *)arg;
struct in_addr addr;
char **p;
zval *hearray, *addr_list;
MAKE_STD_ZVAL(hearray);
array_init(hearray);
add_assoc_string(hearray, "name", host->h_name, 1);
MAKE_STD_ZVAL(addr_list);
array_init(addr_list);
for (p = host->h_addr_list; *p; p++) {
memcpy(&addr, *p, sizeof(addr));
add_next_index_string(addr_list, inet_ntoa(addr), 1);
}
add_assoc_zval(hearray, "addr_list", addr_list);
}
Now we get to the most important part - calling the callback.
using call_user_function to call the callback
static void php_ares_hostcallback(void *arg, int status, struct hostent *host)
{
zval retval;
zval *arguments[3];
struct php_ares_callback_struct *cb = (struct php_ares_callback_struct *)arg;
/* insert code for mapping the hostent to an array (from above) here */
arguments[0] = cb->arg;
MAKE_STD_ZVAL(arguments[1]);
ZVAL_LONG(arguments[1], status);
19. arguments[1] = hearray;
if (call_user_function(EG(function_table), NULL,
cb->callback, &retval, 3, arguments TSRMLS_CC) == SUCCESS) {
/* release any returned zval - it's not important to us */
zval_dtor(&retval);
}
FREE_ZVAL(arguments[1]);
/* and clean up the structure */
zval_dtor(cb->callback);
zval_dtor(cb->arg);
zval_dtor(hearray);
efree(cb);
}
20. ares_process_with_timeout
This function provides the easy way to check on the status of the DNS
resolution, and call the callbacks if it has completed. For convenience we
can specify a timeout so we can "sleep" on it while waiting.
Lets take a look at the fragment of code from the ahost example again:
fragment from ahost
int main(int argc, char **argv)
{
ares_channel channel;
int status, nfds;
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
/* ... */
/* wait for the queries to complete */
while (1) {
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
nfds = ares_fds(channel, &read_fds, &write_fds);
if (nfds == 0)
break;
tvp = ares_timeout(channel, NULL, &tv);
select(nfds, &read_fds, &write_fds, NULL, tvp);
/* calls the callback as appropriate */
ares_process(channel, &read_fds, &write_fds);
}
/* ... */
}
We'll do things a little differently - we will be specifying our own timeout.
implementing the function
/* {{{ proto long ares_process_with_timeout(resource $channel, long $secs)
check for completion of DNS resolution and call callbacks. Returns number of
outstanding requests. */
PHP_FUNCTION(ares_process_with_timeout)
{
zval *zchannel;
ares_channel channel;
long timeout_secs;
struct timeval tv;
int status, nfds;
fd_set read_fds, write_fds;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl",
&zchannel, &timeout_secs)) {
return;
}
ZEND_FETCH_RESOURCE(channel, ares_channel, &zchannel, -1, "ares channel",
le_ares_channel);
FD_ZERO(&read_fds);
22. Nice things for error handling
If the DNS resolution fails for some reason, we might want to notify the
user of the error message, or we might want to act upon the error code
and take some alternative course of action. To do these things we need to
have a function to retrieve the error message text, and it would also be
nice to have some symbolic constants to descirbe the error codes.
implementing ares_strerror
/* {{{ proto string ares_strerror(long $statuscode)
returns a string description for an error code */
PHP_FUNCTION(ares_strerror)
{
long statuscode;
char *errmem = NULL;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l",
&statuscode)) {
return;
}
ares_strerror(status, &errmem);
RETVAL_STRING(return_value, errmem, 1);
ares_free_errmem(errmem);
}
/* }}} */
The other nice thing to have is symbolic constants. We can do the
equivalent of define() when our extension is loaded. We do this in our
module init (MINIT) function, just after the point where we register our
resource type.
error codes defined by libares
#define ARES_SUCCESS 0
/* Server error codes (ARES_ENODATA indicates no relevant answer) */
#define ARES_ENODATA 1
#define ARES_EFORMERR 2
#define ARES_ESERVFAIL 3
#define ARES_ENOTFOUND 4
#define ARES_ENOTIMP 5
#define ARES_EREFUSED 6
/* Locally generated error codes */
#define ARES_EBADQUERY 7
#define ARES_EBADNAME 8
#define ARES_EBADFAMILY 9
#define ARES_EBADRESP 10
#define ARES_ECONNREFUSED 11
#define ARES_ETIMEOUT 12
#define ARES_EOF 13
#define ARES_EFILE 14
#define ARES_ENOMEM 15
#define ARES_EDESTRUCTION 16
23. To map these into user space:
registering a resource
/* {{{ PHP_MSHUTDOWN_FUNCTION
*/
PHP_MINIT_FUNCTION(ares)
{
le_ares_channel = zend_register_list_destructors_ex(ares_channel_dtor,
NULL, "ares channel", module_number);
REGISTER_LONG_CONSTANT("ARES_SUCCESS", ARES_SUCCESS, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ARES_ENODATA", ARES_ENODATA, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("ARES_EFORMERR", ARES_EFORMERR, CONST_CS|CONST_PERSISTENT);
/* ... */
return SUCCESS;
}
*/
24. Summary
We can now make asynchronous DNS resolution requests, and even run
them concurrently. Along the way we have learned about the major parts
of writing a PHP extension:
• config.m4
• general structure
• PHP_FUNCTION
• zend_parse_parameters
• making callbacks
• registering resources
• registering constants
• returning values to the script
how to use with stream_select()
<?php
$s1 = fsockopen($host1, $port);
$s2 = fsockopen($host2, $port);
$chan = ares_init();
ares_gethostbyname($chan, 'sample.com', 'sample.com');
/* wait for things to come back */
while (true) {
/* don't wait for anything - return immediately */
ares_process_with_timeout($chan, 0);
/* wait 5 seconds for data on the sockets */
$r = array($s1, $s2);
$n = stream_select($r, $w = null, $e = null, 5);
if ($n) {
/* do something with it */
}
}
?>