Trending February 2024 # How To Create A Web Archive With Archivebox # Suggested March 2024 # Top 10 Popular

You are reading the article How To Create A Web Archive With Archivebox updated in February 2024 on the website Kientrucdochoi.com. We hope that the information we have shared is helpful to you. If you find the content interesting and meaningful, please share it with your friends and continue to follow and support us for the latest updates. Suggested March 2024 How To Create A Web Archive With Archivebox

Archivebox is an easy-to-use archival program that allows you to create an accurate snapshot of any website. This can be helpful for archivists and users that want to preserve information online. Not only that, Archivebox is also incredibly simple and easy to use. For example, you can run the program both as a command line tool and as a web app that you can access anywhere.

Why Should You Archive Websites?

Over the years, the World Wide Web enabled individuals across the globe to easily share and communicate information with each other. One issue with the Web, however, is that websites do not hold up over time.

Most websites only stay active for around two to five years. After that, they either go offline completely or are replaced by a different website altogether. For example, there are little to no websites from the 1990s that are still online today.

Alternatively, you can also use the WayBack machine to archive websites – no installation required.

Archivebox’s Requirement

Before you can install Archivebox, you need to make sure that you have the following resources:

A machine that you can access from outside your home network. This can either be a machine at home that you can port-forward or a rented remote VPS.

Your machine needs to have an adequate amount of storage space. In most cases, a 1TB disk should be able to store between 100,000 to 1,000,000 individual webpages.

Your machine’s filesystem needs to either be EXT4 or ZFS for Archivebox to work properly.

Note: this tutorial focuses on installing and configuring Archivebox on a local Ubuntu 22.04 LTS machine.

Installing Archivebox

First, install the program’s dependencies. Open a terminal and type the following command:

sudo

apt

install

python3 nodejs python3-pip nginx npm npm

install

--no-audit

--no-fund

'@postlight/mercury-parser'

Install Archivebox through Python PIP:

pip3

install

archivebox

PATH

=

$PATH

:

/

home

/

$USER

/

.local

/

bin

Next, create a folder where Archivebox will save all of its data. In my case, I am creating my directory in my “/home/archivebox” directory:

mkdir

/

home

/

$USER

/

abox-data

&&

cd

/

home

/

$USER

/

abox-data

Lastly, you can finalize your Archivebox instance by running the following command to download and configure all the Python patches that the program needs to run in your machine.

archivebox init

--setup

You will be asked for the details of the first user.

Check whether you have installed Archivebox properly by running:

archivebox

--version

Preparing the Web GUI

While Archivebox is perfectly usable as a command line utility, it is also possible to access the program through a web interface. This is useful if you want to either share Archivebox with other users or access the program outside your server.

To host a web GUI, you need to create an Nginx reverse proxy to redirect any incoming web traffic to the Archivebox daemon.

Create a new Nginx configuration file:

sudo

nano

/

etc

/

nginx

/

sites-available

/

archivebox

Copy and paste the following code, changing server_name to your own domain name:

server

{

listen

80

;

listen

[

::

]

:80

;

root

/home/archivebox/abox-data

;

location

/

{

}

}

Enable the Archivebox configuration:

sudo

ln

-s

/

etc

/

nginx

/

sites-available

/

archivebox

/

etc

/

nginx

/

sites-enabled

/

Restart Nginx and start the Archivebox daemon:

sudo

systemctl restart nginx archivebox server 0.0.0.0:

8000

Archiving Your First Website

Open your web browser and access the Archivebox instance through your domain name. In my case, I am going to “yetanotherarchiveboxxyz.”

Enter your user credentials to log in to the utility.

Archive your first website by pressing the “Add” button on the page’s upper sidebar.

Next, you can choose a variety of options to archive your website. For example, you can provide a set of tags for your links to sort them properly.

Further, you can tell Archivebox to save the contents of any immediate link in the page that you want to archive. This is useful in cases where you want to preserve the context of a website.

Archiving a Website Using the Command Line

To archive a webpage from the command line, run the following commands:

cd

/

home

/

$USER

/

abox-data

You can also customize how Archivebox obtains the pages that it saves. For example, it is possible to save only a screenshot of every web page that you archive.

This is helpful for users who want to save disk space while storing websites. To disable the other formats, you need to run the following commands:

archivebox config

--set

SAVE_WGET

=False archivebox config

--set

SAVE_WARC

=False archivebox config

--set

SAVE_PDF

=False archivebox config

--set

SAVE_SINGLEFILE

=False archivebox config

--set

SAVE_READABILITY

=False archivebox config

--set

SAVE_MERCURY

=False Adding a New User in Archivebox

Once inside the Admin Panel, go to the “Authentication and Authorization” category and select “Users.”

This will list all the active users in the system. Select the “Add User +” button in the page’s upper-right corner.

Similar to adding users to a Linux group, the user creation process in Archivebox can be complicated. Despite that, a new user only requires three things to function properly: username, password and a set of user permissions.

To create a new user, first provide a password.

After that, select the user permissions for that particular user. In most cases, you only need to toggle the following options for a regular user:

Lastly, select the “SAVE” button on the page’s lower right corner to apply your changes.

Frequently Asked Questions How can I solve a "Failed to install Python packages" error?

This happens due to a bug in Archivebox that prevents it from finding the binaries it is looking for. Despite that, this error only affects a minor part of the program and will not damage the integrity of your archive.

One way to mitigate this issue is by making sure that your installation is always up to date. Do that by running pip3 install --upgrade archivebox.

Image credit: Unsplash. All alterations and screenshots by Ramces Red.

Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

You're reading How To Create A Web Archive With Archivebox

How To Create A Bbs In Linux With Enigmabbs

Bulletin Board Systems (BBS) used to be the quintessential information hubs of the 90s. These were geographically local machines that users could connect to as a way to access information, obtain files and even communicate with other BBS users. Over the years, however, the know-how that you needed to even connect to one made it challenging for a regular user to participate in a BBS, making it lose its luster and appeal in favor of the more global Web.

Despite that, it is still possible to create your own BBS server using Linux. There are numerous projects, such as EnigmaBBS, that use modern languages and technologies to recreate the BBS experience of the 90s.

What Is a BBS and EnigmaBBS?

At its core, a BBS is a suite of programs that allow multiple users to access a computer over a remote network. These computers, in turn, often contain programs that a system operator made to highlight a feature of their BBS. For example, most BBS machines in the 1990s provided games that are unique to their server.

EnigmaBBS is a modern adaptation of the traditional BBS software. It aims to recreate the original ’90s BBS experience with modern coding standards and technologies. EnigmaBBS also contains a number of features, such as WebSockets and SSH, which allow you to easily host and use a BBS.

Unlike traditional BBS, EnigmaBBS provides a platform for easy communication with other similar services through FidoNET. This approach enables you to seamlessly interact with other servers without the need to explicitly connect to each other.

Lastly, EnigmaBBS fully supports third-party Door Games through DoorParty, Exodus and CombatNet, so loading games through it is as simple as providing the dropfile for that particular game. It is possible to turn EnigmaBBS to a dedicated BBS gaming server for your friends and family.

Installing EnigmaBBS

Create a separate user account for the BBS server to make sure that it will not have any access to your personal files. To get started, run the following commands:

sudo

useradd

-s

/

bin

/

bash

-d

/

home

/

enigma

-m

-G

sudo

enigma

sudo

passwd

enigma

Run su enigma to switch to the new user account.

Download the EnigmaBBS installation script: an all-in-one script that fetches, compiles and installs all the necessary tools to create a copy of the BBS. Run the following commands:

sudo

apt

install

curl

git

make

gcc

g++

python p7zip lhasa arj lrzsz python-is-python3

chmod

+x .

/

install.sh .

/

install.sh

EnigmaBBS will begin by downloading all the packages that it needs to compile NodeJS. From there, it will download all the necessary packages to install the BBS software.

Generating Your EnigmaBBS Configuration

Next, open a new terminal window to make sure that the machine will detect all of the programs that you just installed.

Since we’re using Ubuntu, we pressed the “New Tab” button in the current terminal window.

Go to EnigmaBBS’s root directory. This is the folder that contains all the files and details for your BBS server. Run the following command to access it:

cd

/

home

/

$USER

/

enigma-bbs Creating a New Configuration File

Once inside, you can now create your BBS server’s configuration file with this command:

.

/

oputil.js config new

EnigmaBBS will ask where you want to place your configuration file. For the most part, you only need to press Enter here to ensure that you can find all of the configuration files in their default directories.

You’ll be asked to name your new EnigmaBBS instance. We named ours “Hello, world!”

Provide a name for your first message conference, similar to a category in a forum website. We pressed Enter twice to use the default “Local” name.

The script will ask you to name your first message area. Similar to a message conference, this is a way to further categorize the messages in your BBS. Once again, we pressed Enter twice to use the default values.

Set the amount of logs that the program should keep while running. By default, EnigmaBBS recommends that you only keep diagnostic information in the server. Despite this, you can choose to either increase or decrease the amount of logging in your server, which can be especially useful if you are diagnosing a problem. We’ve picked the default “Info” level for our server.

Connecting and Using Your New BBS

With your basic configuration done, you can start your EnigmaBBS server. Unlike other webservers, running a BBS instance is incredibly easy.

Run the following command:

.

/

main.js

This will boot up EnigmaBBS and expose it to your local network. To connect to it, however, you’ll need to either use a telnet client or SSH. We used the former.

Similar to starting up EnigmaBBS, connecting to it through telnet is quite straightforward, as Ubuntu ships with a BBS-compatible telnet client out of the box. Connecting to your local instance only requires that you run a single command:

telnet localhost

8888

Once you are connected, EnigmaBBS will print a splash screen along with three options: “Login,” “Apply” and “Logout.”

Creating the Sysop User

By default, EnigmaBBS reserves the first user account in the server as the Sysop user.

To create your administrator account, select “Apply” in the splash screen.

Provide a username and other information about yourself. We used “ramcesr” as our username.

One important thing to note is that you do not need to provide any real information in most of the fields in this page. For example, you can provide an email that does not exist, and EnigmaBBS will still create the account. This can be helpful in situations where do not want to leave any contact information in the BBS.

Sending and Reading Your First Message

EnigmaBBS will immediately redirect you to your account’s main menu, where you can interact with various features of your BBS instance.

Press M, then P to tell EnigmaBBS that you want to create a new message post.

Press Enter on the next screen to write the subject of your message. We wrote “Hello world!”

Press Enter again to write the body of your message.

Press Esc, then “Save” to submit your message to the BBS.

Viewing messages in EnigmaBBS is also relatively simple. Press M, then L in the Main Menu to list all the new messages in the current message conference.

Communicating with a Different BBS

As mentioned above, EnigmaBBS also allows you to seamlessly communicate with other BBS servers. It can be especially useful if you want to introduce additional activity in your BBS instance.

Turn off your EnigmaBBS instance by either pressing Ctrl + C or closing its terminal window.

Edit your server’s configuration file. You can find this HJSON file under the “config” folder of the EnigmaBBS root directory.

nano

/

home

/

$USER

/

enigma-bbs

/

config

/

config.hjson

Find the “chatServers” option. This controls the Multi-Relay Chat function of EnigmaBBS. Look for this option by pressing / and typing “chatServers.”

Change the “enabled” value from “false” to “true.”

Save this file and restart EnigmaBBS.

Access the Multi-Relay Chat by typing MRC and pressing Enter in the Main Menu.

A new windows will load where EnigmaBBS will connect you to a chatroom with other BBS servers.

Creating a Web Content Server

Aside from sending messages, EnigmaBBS is also a highly flexible piece of software that can be extended to do whatever you want. For example, it is possible to create a content server that will display all the messages and files in the BBS.

Open your server’s “config.hjson” file.

Look for the “contentServer” function, a block that contains all the necessary settings that you need to set to create a Web-based content portal. We pressed / in Vim and typed “contentServer” to jump to that particular section.

Provide a domain name for the web server that you are creating. We wrote “localhost” since we only intend to run this server in the local network.

Save the “config.hjson” file and restart your BBS server to apply the new settings.

Once done, you can then visit the BBS web portal by typing

localhost:8080

in your web browser.

Frequently Asked Questions The EnigmaBBS installation script is not working

This is most likely because you are using a different shell in your system. By default, the EnigmaBBS install script uses Bash to compile the necessary programs. The script relies on Bash-specific functions to perform the installation properly. One way to solve this issue is to run the Bash shell from your current terminal by running: /bin/bash. Doing this will change the prompt in the screen indicating that you are now using Bash. From there, you can run the installation script again.

EnigmaBBS is reporting a MODULE_NOT_FOUND error

This happens when there is a difference between the library versions that EnigmaBBS expects and what it can find in your computer.

To fix this, you need to do three things: First, you need to run rm -rf /home/$USER/enigma-bbs/node-modules to remove all the objects that EnigmaBBS just compiled.

Then add the official NodeJS repository to your package manager in Ubuntu by running the command:

Once done, install the appropriate version of NodeJS as well as rebuild all the objects for EnigmaBBS by running this single command:

sudo apt install nodejs && nvm install v14.19.3 && npm install && npm rebuild.

Is it possible to change the default port of EnigmaBBS?

Yes. The BBS server uses port 8888 for telnet connections because most Linux distributions disable the default telnet port and do not allow any traffic through it. Despite that, you can still change the port that EnigmaBBS uses by changing a few settings in the “config.hjson” file.

Look for the port: variable under “loginServers,” then change it to any number that does not conflict with any running service in your system.

Image credit: Unsplash All screenshots by Ramces Red

Ramces Red

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.

By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time.

How To Hack A Web Server

Customers usually turn to the internet to get information and buy products and services. Towards that end, most organizations have websites. Most websites store valuable information such as credit card numbers, email address and passwords, etc. This has made them targets to attackers. Defaced websites can also be used to communicate religious or political ideologies etc.

In this tutorial, we will introduce you toweb servers hacking techniques and how you can protect servers from such attacks.

How to Hack a Web Server

In this practical scenario, we are going to look at the anatomy of a web server attack. We will assume we are targeting chúng tôi We are not actually going to hack into it as this is illegal. We will only use the domain for educational purposes.

Step 1) What we will need

Bing search engine

SQL Injection Tools

Stept 2) Information gathering

We will need to get the IP address of our target and find other websites that share the same IP address.

We will use an online tool to find the target’s IP address and other websites sharing the IP address

Enter chúng tôi as the target

You will get the following results

Based on the above results, the IP address of the target is 69.195.124.112

We also found out that there are 403 domains on the same web server.

Our next step is to scan the other websites for SQL injection vulnerabilities. Note: if we can find a SQL vulnerable on the target, then we would directly exploit it without considering other websites.

Enter the URL chúng tôi into your web browser. This will only work with Bing so don’t use other search engines such as google or yahoo

Enter the following search query

ip:69.195.124.112 .php?id=

HERE,

“ip:69.195.124.112” limits the search to all the websites hosted on the web server with IP address 69.195.124.112

“.php?id=” search for URL GET variables used a parameters for SQL statements.

You will get the following results

As you can see from the above results, all the websites using GET variables as parameters for SQL injection have been listed.

The next logic step would be to scan the listed websites for SQL Injection vulnerabilities. You can do this using manual SQL injection or use tools listed in this article on SQL Injection.

Step 3) Uploading the PHP Shell

Open the URL where you uploaded the chúng tôi file.

You will get the following window

Once you have access to the files, you can get login credentials to the database and do whatever you want such as defacement, downloading data such as emails, etc.

Web server vulnerabilities

Default settings– These settings such as default user id and passwords can be easily guessed by the attackers. Default settings might also allow performing certain tasks such as running commands on the server which can be exploited.

Misconfiguration of operating systems and networks – certain configuration such as allowing users to execute commands on the server can be dangerous if the user does not have a good password.

Bugs in the operating system and web servers– discovered bugs in the operating system or web server software can also be exploited to gain unauthorized access to the system.

In additional to the above-mentioned web server vulnerabilities, the following can also led to unauthorized access

Lack of security policy and procedures– lack of a security policy and procedures such as updating antivirus software, patching the operating system and web server software can create security loop holes for attackers.

Types of Web Servers

The following is a list of the common web servers

Apache– This is the commonly used web server on the internet. It is cross platform but is it’s usually installed on Linux. Most PHP websites are hosted on Apache servers.

Internet Information Services (IIS)– It is developed by Microsoft. It runs on Windows and is the second most used web server on the internet. Most asp and aspx websites are hosted on IIS servers.

Apache Tomcat – Most Java server pages (JSP) websites are hosted on this type of web server.

Other web servers – These include Novell’s Web Server and IBM’s Lotus Domino servers.

Types of Attacks against Web Servers

Directory traversal attacks– This type of attacks exploits bugs in the web server to gain unauthorized access to files and folders that are not in the public domain. Once the attacker has gained access, they can download sensitive information, execute commands on the server or install malicious software.

Denial of Service Attacks– With this type of attack, the web server may crash or become unavailable to the legitimate users.

Domain Name System Hijacking – With this type of attacker, the DNS setting are changed to point to the attacker’s web server. All traffic that was supposed to be sent to the web server is redirected to the wrong one.

Sniffing– Unencrypted data sent over the network may be intercepted and used to gain unauthorized access to the web server.

Phishing– With this type of attack, the attack impersonates the websites and directs traffic to the fake website. Unsuspecting users may be tricked into submitting sensitive data such as login details, credit card numbers, etc.

Pharming– With this type of attack, the attacker compromises the Domain Name System (DNS) servers or on the user computer so that traffic is directed to a malicious site.

Defacement– With this type of attack, the attacker replaces the organization’s website with a different page that contains the hacker’s name, images and may include background music and messages.

Effects of successful attacks

An organization’s reputation can be ruined if the attacker edits the website content and includes malicious information or links to a porn website

The web server can be used to install malicious software on users who visit the compromised website. The malicious software downloaded onto the visitor’s computer can be a virus, Trojan or Botnet Software, etc.

Compromised user data may be used for fraudulent activities which may lead to business loss or lawsuits from the users who entrusted their details with the organization

Web server attack tools

Some of the common web server attack tools include;

Metasploit– this is an open source tool for developing, testing and using exploit code. It can be used to discover vulnerabilities in web servers and write exploits that can be used to compromise the server.

MPack– this is a web exploitation tool. It was written in PHP and is backed by MySQL as the database engine. Once a web server has been compromised using MPack, all traffic to it is redirected to malicious download websites.

Zeus– this tool can be used to turn a compromised computer into a bot or zombie. A bot is a compromised computer which is used to perform internet-based attacks. A botnet is a collection of compromised computers. The botnet can then be used in a denial of service attack or sending spam mails.

Neosplit – this tool can be used to install programs, delete programs, replicating it, etc.

How to avoid attacks on Web server

An organization can adopt the following policy to protect itself against web server attacks.

Patch management– this involves installing patches to help secure the server. A patch is an update that fixes a bug in the software. The patches can be applied to the operating system and the web server system.

Secure installation and configuration of the operating system

Secure installation and configuration of the web server software

Vulnerability scanning system– these include tools such as Snort, NMap, Scanner Access Now Easy (SANE)

Firewalls can be used to stop simple DoS attacks by blocking all traffic coming the identify source IP addresses of the attacker.

Antivirus software can be used to remove malicious software on the server

Disabling Remote Administration

Default accounts and unused accounts must be removed from the system

Default ports & settings (like FTP at port 21) should be changed to custom port & settings (FTP port at 5069)

Summary

Web server stored valuable information and are accessible to the public domain. This makes them targets for attackers.

The commonly used web servers include Apache and Internet Information Service IIS

Popular web server hacking tools include Neosploit, MPack, and ZeuS.

A good security policy can reduce the chances of been attacked

How To Create A Daemonset?

Definition of Kubernetes Daemonset

Web development, programming languages, Software testing & others

What is Kubernetes Daemonset?

A Daemonset is a dynamic object in kubernetes which is managed by a controller. The user can set the desired state that represents the specific pods which need to exist on every node. The compromise in the control loop can compare the current practical state with the desired state. If the practical node, doesn’t fit the matching pod, then the controller of the Daemonset creates a new one automatically. This automated process has all recently created nodes and existing nodes. The pods developed by the controller of Daemonset are neglected by the Kubernetes scheduler and present as the same node itself.

What are the Use Case for Daemonset?

The use case for Daemonset are as follows,

As the use case is complex, the user can deploy many possible Daemonsets for a typical kind by a variety of flags, CPU requests, and memory units for different types of hardware.

Daemonset can enhance the performance of the cluster by pod deployment to execute maintenance activities and support services for every node. The background processes like monitoring apps in Kubernetes and other services must be present along with clusters to offer timely and relevant services.

It is mostly adapted for long-running services like collection of logs, monitoring of node resources, storage in clusters, and pods related to infrastructure. It is standard for Daemonset to run on a single daemon throughout all the nodes in the cluster. The multiple Daemonset can manage one type of Daemonset by applying different labels. This label can identify rules in deployment based on the behavior of individual nodes. Daemonsets is deployed on the background tasks which the user can execute on all the possible nodes but it doesn’t need any intervention. The user can have Daemonset for every type of daemon to execute on all nodes. The user can also execute multiple Daemonset for every single daemon type. But can use various configurations for diverse hardware models and resource requirements.

How to Create a Daemonset?

To create a Daemonset the following steps are involved.

The Daemonset is developed in a YAML file with few parts.

It requires apiVersion

It requires the type or kind of the behavior for Daemonset

It needs the metadata for the Daemonset

It needs spec_template for pod definition which the user needs to execute on all nodes.

It needs spec_selector to manage the pods for Daemonset and this kind must be label specific in a template of pods. The selector name defined in the template is applied in the selector. But this name cannot be changed once the Daemonset is created without leaving the pods created prior in the Daemonset.

The spec_template-spec-node selector is used to execute only the nodes subset which suits the selector

Spec-template-spec-affinity is used to execute on nodes subset which has affinity match.

Once the configuration is completed, Daemonset is created in the cluster.

Methods to communicate with pods Kubernetes Daemonset

The user can transfer data from other pods to a pod of Daemonset executed on the node. The user can transmit data metrics to pod monitoring in two ways,

The pod spec in Daemonset has specifiy host port to uncover it on the node. Then it can interact directly with the IP of node which is executed on it.

Using the same pod selector, the service is created as a Daemonset and then it is used to reach the Daemonset. The limitation of this service is that a Daemonset of a pod is random to receive the request. This implies that the request may pass over the network instead of hanging on a similar pod as the requested pod.

In NodeIP with Known port, the Daemonset pods use the hostport, and so the pods are connected through node IPs. The client understands the use nodeIP list and is also aware of the port conventions.

DNS develop headless service and explore Daemonset using endpoint to retrieve reports from DNS

In-Service, it creates the service with a similar pod selector and uses it to reach the daemon of the random node.

Conclusion

Hence, the feature of Daemonset is used to check that few or all the pods are executed and scheduled on every available node. It executes the copy of the desired pod throughout all the nodes. So when a new node is joined to the cluster of Kubernetes, the new pod is added to the recently attached node.

Recommended Articles

This is a guide to Kubernetes Daemonset. Here we discuss Definition, What is Kubernetes Daemonset? How to create a Daemonset?. You may also have a look at the following articles to learn more –

How To Create A Button Programmatically?

In this article, you will learn about how to create a button prograticamtilly in the Swift language. There are different ways to create a button object programmatically in iOS. Let’s explore some of them with an example.

We will see the following ways to create a button −

Step 1 − In this step, we will create a button object and customize it later when required.

Step 2 − In this step, we will create a button object using a lazy keyword.

Step 3 − In this step, we will create a button object and set the frame later.

Create a button and customize it later

Here is an example of how you can create a button programmatically in iOS using Swift −

Example import UIKit class TestController: UIViewController { private let loginButton = UIButton() override func viewDidLoad() { super.viewDidLoad() initialSetup() } private func initialSetup() { view.backgroundColor = .white navigationItem.title = "UIButton" loginButton.setTitle("Login", for: .normal) loginButton.setTitleColor(.white, for: .normal) loginButton.layer.cornerRadius = 10 loginButton.layer.masksToBounds = true loginButton.backgroundColor = .darkGray loginButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold) loginButton.addTarget(self, action: #selector(handleLoginButtonTapped), for: .touchUpInside) view.addSubview(loginButton) loginButton.translatesAutoresizingMaskIntoConstraints = false loginButton.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true loginButton.heightAnchor.constraint(equalToConstant: 50).isActive = true loginButton.widthAnchor.constraint(equalToConstant: 280).isActive = true } @objc private func handleLoginButtonTapped() { print("login button tapped...") } } Output

In the above step, a button object named loginButton is created in the controller. The button’s title is set to “Login” and the title color is set to white. The button is also given a target-action pair so that when the button is tapped, the function “handleLoginButtonTapped” will be called. Finally, the button is added as a subview to the current view.

You will see that initially, we created a button object. After that, we will customize the button in the viewDidLoad() method. And finally, add it to the super view with some required constraints.

Create a button using the lazy keyword

Here is an example of how you can create a button programmatically in iOS using the lazy keyword in UIKit −

Example import UIKit class TestController: UIViewController { private lazy var loginButton: UIButton = { let button = UIButton() button.setTitle("Login", for: .normal) button.setTitleColor(.white, for: .normal) button.layer.cornerRadius = 10 button.layer.masksToBounds = true button.backgroundColor = .darkGray button.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold) button.addTarget(self, action: #selector(handleLoginButtonTapped), for: .touchUpInside) button.translatesAutoresizingMaskIntoConstraints = false return button }() override func viewDidLoad() { super.viewDidLoad() initialSetup() } private func initialSetup() { view.backgroundColor = .white navigationItem.title = "UIButton" view.addSubview(loginButton) loginButton.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true loginButton.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true loginButton.heightAnchor.constraint(equalToConstant: 50).isActive = true loginButton.widthAnchor.constraint(equalToConstant: 280).isActive = true } @objc private func handleLoginButtonTapped() { print("login button tapped...") } } Output

In the above step, a button object named loginButton is created in the controller using the lazy keyword. The button’s title is set to “Login” and the title color is set to white. The button is also given a target-action pair so that when the button is tapped, the function “handleLoginButtonTapped” will be called. Finally, the button is added as a subview to the current view.

Note that with lazy keyword you don’t need to add the button as subview in the declaration of button, you can do it later whenever you need it.

Create a button using a frame

Here is an example of how you can create a button programmatically in iOS using Swift −

Example import UIKit class TestController: UIViewController { private let loginButton = UIButton(type: .system) override func viewDidLoad() { super.viewDidLoad() initialSetup() } private func initialSetup() { view.backgroundColor = .white navigationItem.title = "UIButton" loginButton.frame = CGRect(x: 20, y: 150, width: 280, height: 50) loginButton.setTitle("Login", for: .normal) loginButton.setTitleColor(.white, for: .normal) loginButton.layer.cornerRadius = 10 loginButton.layer.masksToBounds = true loginButton.backgroundColor = .darkGray loginButton.titleLabel?.font = UIFont.systemFont(ofSize: 18, weight: .semibold) loginButton.addTarget(self, action: #selector(handleLoginButtonTapped), for: .touchUpInside) view.addSubview(loginButton) } @objc private func handleLoginButtonTapped() { print("login button tapped...") } } Output

You can change x, y, width and height according to your needs and also you can change the button title and action according to your requirement.

Conclusion

You can programmatically create buttons in a variety of ways. You can create a button object and customize it later whenever you need it in code. In addition, the lazy keyword can be used to create a button object. The UIButton class provides the flexibility to set the frame later in the code. You can see how to set the frame of a button in the above example.

Using a lazy keyword is the most recommended way. You can create a button object and add any customization in a single block. Also, you can add the target in the same block.

How To Disable The Facebook Stories Archive.

Although they haven’t exactly taken off or become super popular since coming to Facebook, ‘Stories’ are here to stay, whether you like it or not. In fact! They’ve just been upgraded and now allow you to save them to a special archive, for personal viewing.

How to Make Exceptions For Files and Folders on Windows 10.

Stories aren’t exactly anything new, having originally been invented by Snapchat, back in October 2013. Since then, however, just about every social media platform has adopted the feature, with Instagram, Facebook, Facebook Messenger, and even WhatsApp all having some variant of Stories available. Although Snapchat and Instagram are still the most widely used, Facebook is desperately trying to persuade users to start using Stories on their flagship platform.

As part of their persuasion efforts, Facebook’s latest feature now gives users the ability to archive Stories. This is basically a safe place Stories save to after they have expired from their 24hr public viewing phase. Any Stories that have been saved to your archive become private and can only be viewed by you and aren’t publically available. If you are an active Stories user, there’s a good chance you’ll like the option to keep your short clips as memories.

After you have updated to the latest version of Facebook, Stories will automatically have the archive feature enabled so you will need to disable it manually if you don’t wish any of your content to save after 24 hours. If you are are having trouble doing so, continue reading below for a full list of instructions on disabling Facebook’s Story Archive.

Related: How to Snooze Keywords on Facebook. (Block content and potential spoilers)

How Do You Disable Your Story Archive on Facebook? (Stop Facebook Saving Stories)

To begin, you’ll need to make sure you have the latest version of Facebook installed on your device, which you probably already have considering you have archiving available. Next, open Facebook and bring your gaze to the Stories section at the top of the screen. In this small section, you will see a small new heading called Your Archive, tap this once to open your archive.

If this is your first time here, you will see a quick guide showing you how to disable the feature. If you don’t see the guide, tap the settings icon in the top right-hand corner and flip the toggle to Off. If you don’t have any Stories currently listed, you will be able to flip the toggle from the middle of the screen without having to enter into the small settings cog.

As soon as you make the change Facebook will stop saving any Stories to your archive. If you already have some Stories in your archive, they won’t automatically be removed if you disable archiving. Facebook will simply stop adding new content to the archive until you enable it once again, so feel free to enable and disable Facebook Story Archiving at your choosing. If you wish to remove old Stories from the archive simply tap, hold, and select the remove option.

How to Block, Hide, and Filter Facebook Newsfeed Content.

Update the detailed information about How To Create A Web Archive With Archivebox on the Kientrucdochoi.com website. We hope the article's content will meet your needs, and we will regularly update the information to provide you with the fastest and most accurate information. Have a great day!