Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 20,946
» Latest member: blackopsdlc
» Forum threads: 21,999
» Forum posts: 22,966

Full Statistics

Online Users
There are currently 1426 online users.
» 0 Member(s) | 1420 Guest(s)
Applebot, Baidu, Bing, Facebook, Google, Yandex

Latest Threads
[Steam Release] The Unive...
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 3
[DevBlog MS] Creating a m...
Forum: C#, Visual Basic, & .Net Frameworks
Last Post: xSicKxBot

» Replies: 0
» Views: 9
[WoW Retail News] Fixed C...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 11
[PS.Blog] Fading Echo mak...
Forum: Sony Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 11
[Steam Release] Cowbots a...
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 14
[Dev News] September Free...
Forum: Game Development
Last Post: xSicKxBot

» Replies: 0
» Views: 12
Marvel Rivals Venom guide...
Forum: PC Discussion
Last Post: xSicKxBot

» Replies: 0
» Views: 16
[WoW Retail News] Midnigh...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 21
[Steam Release] Kodon
Forum: New Game Releases
Last Post: xSicKxBot

» Replies: 0
» Views: 22
[WoW Retail News] Downloa...
Forum: World of Warcraft
Last Post: xSicKxBot

» Replies: 0
» Views: 18

 
  [Tut] How to Create Zip Files using PHP ZipArchive and Download
Posted by: xSicKxBot - 09-13-2022, 07:21 PM - Forum: PHP Development - No Replies

How to Create Zip Files using PHP ZipArchive and Download

by Vincy. Last modified on September 12th, 2022.

Creating a zip from a folder full of files can be done in PHP using the ZipArchive class. This class instance creates a handle to read or write files to a compressed archive.

This class includes several properties and methods to zip file archives.

In this article, we will see an example of,

  1. How to create a zip archive file.
  2. How to download the compressed zip file.

If you want to know how to compress more than one image in PHP image compression refer to this earlier article.

How to create a zip archive file


This file parses the input directory and compresses its files into a zip file. It proceeds with the following steps to create the zip file of a directory.

  1. Create a PHP ZipArchive class instance.
  2. Open a zip file archive with the instance. It accepts the output zip file name and the mode to open the archive.
  3. Apply a recursive parsing in the input directory.
  4. If the directory includes a file, then it adds to the zip archive using addFile().

It handles the use cases of getting the possibilities of being unable to read or archive the directory. Once the zip is created, it displays a message to the browser.

create-zip-file.php

<?php
// Important: You should have read and write permissions to read
// the folder and write the zip file
$zipArchive = new ZipArchive();
$zipFile = "./example-zip-file.zip";
if ($zipArchive->open($zipFile, ZipArchive::CREATE) !== TRUE) { exit("Unable to open file.");
}
$folder = 'example-folder/';
createZip($zipArchive, $folder);
$zipArchive->close();
echo 'Zip file created.'; function createZip($zipArchive, $folder)
{ if (is_dir($folder)) { if ($f = opendir($folder)) { while (($file = readdir($f)) !== false) { if (is_file($folder . $file)) { if ($file != '' && $file != '.' && $file != '..') { $zipArchive->addFile($folder . $file); } } else { if (is_dir($folder . $file)) { if ($file != '' && $file != '.' && $file != '..') { $zipArchive->addEmptyDir($folder . $file); $folder = $folder . $file . '/'; createZip($zipArchive, $folder); } } } } closedir($f); } else { exit("Unable to open directory " . $folder); } } else { exit($folder . " is not a directory."); }
}
?>

Output


//If succeeded it returns Zip file created. //If failed it returns Unable to open directory example-folder.
[or] "example-folder is not a director.

php create zip

How to download the compressed zip file


In the last step, the zip file is created using the PHP ZipArchive class. That zip file can be downloaded by using the PHP code below.

It follows the below steps to download the zip file created.

  1. Get the absolute path of the zip file.
  2. Set the header parameters like,
    • Content length.
    • Content type.
    • Content encoding, and more.

download-zip-file.php

<?php
$filename = "example-zip-file.zip";
if (file_exists($filename)) { // adjust the below absolute file path according to the folder you have downloaded // the zip file // I have downloaded the zip file to the current folder $absoluteFilePath = __DIR__ . '/' . $filename; header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Cache-Control: private', false); // content-type has to be defined according to the file extension (filetype) header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . basename($filename) . '";'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($absoluteFilePath)); readfile($absoluteFilePath); exit();
}
?>

This file just has the links to trigger the function to create a zip file containing the compressed archive of the directory. Then, the action to download the output zip archive is called.

index.php

<div class='container'> <h2>Create and Download Zip file using PHP</h2> <p> <a href="create-zip-file.php">Create Zip File</a> </p> <p> <a href="download-zip-file.php">Download Zip File</a> </p>
</div>

Some methods of PHP ZipArchive class


We can do more operations by using the methods and properties of the PHP ZipArchive class. This list of methods is provided by this PHP class.

  1. count() – used to get the number of files in the zip archive file.
  2. extractTo() – extracts the archive content.
  3. renameIndex() – rename a particular archive entry by index.
  4. replaceFile() – replace a file in the zip archive with a new file by specifying a new path.

ZipArchive methods used in this example


Some of the methods are used in this example listed below. These are frequently used methods of this class to work with this.

  1. open() – Open a zip archive file by specifying the .zip file name.
  2. addFile() – To add a file from the input directory to the zip archive.
  3. addEmptyDir() – adds an empty directory into the archive to load the subdirectory file of the input directory.
  4. close() – closes the active ZipArchive with the reference of the handle.

Download

↑ Back to Top



https://www.sickgaming.net/blog/2022/09/...-download/

Print this item

  News - Tales Of Symphonia Remastered Coming To Nintendo Switch In 2023
Posted by: xSicKxBot - 09-13-2022, 07:21 PM - Forum: Lounge - No Replies

Tales Of Symphonia Remastered Coming To Nintendo Switch In 2023

Announced during the Nintendo Direct, Tales of Symphonia Remastered will launch on Nintendo Switch in early 2023. Originally released on the Nintendo GameCube, the game follows Llyod and Colette, as they journey to save the world from darkness.

They will meet a number of allies along their journey, like the wondering aristocrat Zelos and Presea, a lumberjack who lost her emotions. Together they will make sure that Colette, the current chosen one, can climb the Tower of Salvation and defeat the evil Desians. Tales of Symphonia Remastered will feature up to four player co-op for its real-time combat, letting you and your friends cast magic and defeat enemies together.

Tales of Symphonia Remastered is set to launch on Nintendo Switch, PS4, and Xbox One in early 2023.

Continue Reading at GameSpot

https://www.gamespot.com/articles/tales-...01-10abi2f

Print this item

  PC - Call of the Wild: The Angler
Posted by: xSicKxBot - 09-13-2022, 07:21 PM - Forum: New Game Releases - No Replies

Call of the Wild: The Angler



From the creators of theHunter: Call of the Wild comes a genre-defying fishing experience! Explore a vast and atmospheric open world in search of the perfect fishing spot. Ride the open waters alone or with friends and embark on your journey to become a master angler.

Publisher: Expansive Worlds

Release Date: Aug 31, 2022




https://www.metacritic.com/game/pc/call-...the-angler

Print this item

  [Tut] How to Find a Partial String in a Python List?
Posted by: xSicKxBot - 09-12-2022, 03:53 PM - Forum: Python - No Replies

How to Find a Partial String in a Python List?

5/5 – (1 vote)

Problem Formulation


? Challenge: Given a Python list of strings and a query string. Find the strings that partially match the query string.

Example 1:

  • Input: ['hello', 'world', 'python'] and 'pyth'
  • Output: ['python']

Example 2:

  • Input: ['aaa', 'aa', 'a'] and 'a'
  • Output: ['aaa', 'aa', 'a']

Example 3:

  • Input: ['aaa', 'aa', 'a'] and 'b'
  • Output: []

Let’s dive into several methods that solve this and similar type of problems. We start with the most straightforward solution.

Method 1: Membership + List Comprehension


The most Pythonic way to find a list of partial matches of a given string query in a string list lst is to use the membership operator in and the list comprehension statement like so: [s for s in lst if query in s].

Here’s a simple example:

def partial(lst, query): return [s for s in lst if query in s] # Example 1:
print(partial(['hello', 'world', 'python'], 'pyth'))
# ['python'] # Example 2:
print(partial(['aaa', 'aa', 'a'], 'a'))
# ['aaa', 'aa', 'a'] # Example 3:
print(partial(['aaa', 'aa', 'a'], 'b'))
# []

In case you need some background information, feel free to check out our two tutorials and the referenced videos.

? Recommended Tutorial: List Comprehension in Python

YouTube Video

? Recommended Tutorial: The Membership Operator in Python

YouTube Video

Method 2: list() and filter()


To find a list of partial query matches given a string list lst, combine the membership operator with the filter() function in which you pass a lambda function that evaluates the membership operation for each element in the list like so: list(filter(lambda x: query in x, lst)).

Here’s an example:

def partial(lst, query): return list(filter(lambda x: query in x, lst)) # Example 1:
print(partial(['hello', 'world', 'python'], 'pyth'))
# ['python'] # Example 2:
print(partial(['aaa', 'aa', 'a'], 'a'))
# ['aaa', 'aa', 'a'] # Example 3:
print(partial(['aaa', 'aa', 'a'], 'b'))
# []

Beautiful Python one-liner, isn’t it? ?

I recommend you check out the following tutorial with video to shed some light on the background information here:

? Recommended Tutorial: Python Filtering

YouTube Video

Generally, I like list comprehension more than the filter() function because the former is more concise (e.g., no need to convert the result to a list) and slightly faster. But both work perfectly fine!

Method 3: Regex Match + List Comprehension


The most flexible way to find a list of partial query matches given a string list lst is provided by Python’s powerful regular expressions functionality. For example, the expression [x for x in lst if re.match(pattern, x)] finds all strings that match a certain query pattern as defined by you.

The following examples showcase this solution:

import re def partial(lst, query): pattern = '.*' + query + '.*' return [x for x in lst if re.match(pattern, x)] # Example 1:
print(partial(['hello', 'world', 'python'], 'pyth'))
# ['python'] # Example 2:
print(partial(['aaa', 'aa', 'a'], 'a'))
# ['aaa', 'aa', 'a'] # Example 3:
print(partial(['aaa', 'aa', 'a'], 'b'))
# []

In this example, we use the dummy pattern .*query.* that simply matches words that contain the query string. However, you could also do more advanced pattern matching—regex to the rescue!

Again, I’d recommend you check out the background info on regular expressions:

? Recommended Tutorial: Python Regex match() — A Simple Illustrated Guide

YouTube Video


Regex Humor


Wait, forgot to escape a space. Wheeeeee[taptaptap]eeeeee. (source)



https://www.sickgaming.net/blog/2022/09/...thon-list/

Print this item

  (Indie Deal) Conspiracy Corner Bundle, Ubisoft & Cities Sales
Posted by: xSicKxBot - 09-12-2022, 03:52 PM - Forum: Deals or Specials - No Replies

Conspiracy Corner Bundle, Ubisoft & Cities Sales

Conspiracy Corner Bundle | 6 Steam Games | 94% OFF
[www.indiegala.com]
Are we living in a simulation...or are we simulating life...via videogames? Investigate, explore, deduce and uncover conspiracies with the following indie games: Who Stole My Beard?, Just Take Your Left, The Corridor: On Behalf Of The Dead, Fhtagn! - Tales of the Creeping Madness, Abetot Family Estate, NMNE.

https://www.youtube.com/watch?v=prGxSKMdnkw
Ubisoft & Cities Skylines Sales
[www.indiegala.com]
[www.indiegala.com]
https://www.youtube.com/watch?v=0uAgCTBWZVw
Stay Inside, Stay Safe and Enjoy Good Games.
Check out IndieGala on Twitter, YouTube & Facebook[www.facebook.com]


https://steamcommunity.com/groups/indieg...7947227349

Print this item

  News - Ubisoft Reveals New Details On Its Assassin's Creed Netflix Series
Posted by: xSicKxBot - 09-12-2022, 03:52 PM - Forum: Lounge - No Replies

Ubisoft Reveals New Details On Its Assassin's Creed Netflix Series

Ubisoft and Netflix are working together on an Assassin's Creed live-action TV series, as was confirmed back in 2020. More details on the project emerged at Ubisoft Forward today, with Marc-Alexis Cote of Ubisoft Quebec confirming the show is "still early in development."

Ubisoft Film and Television is producing the show alongside Netflix and showrunner Jeb Stuart. Stuart wrote the iconic action movies Die Hard and The Fugitive, and more recently wrote Netflix TV show Vikings: Valhalla.

"It's gonna be an epic, genre-bending live-action adaptation of our video game series," Cote said. Along with the show, Ubisoft is also releasing an Assassin's Creed mobile game with Netflix Games.

Continue Reading at GameSpot

https://www.gamespot.com/articles/ubisof...01-10abi2f

Print this item

  PC - Scathe
Posted by: xSicKxBot - 09-12-2022, 03:52 PM - Forum: New Game Releases - No Replies

Scathe



Scathe is an intense, classic FPS with big guns and even bigger demons. You are Scathe, Enforcer of the Legions of Hell, forged from the earth by the Divine Creator himself. And you, like your fallen kin before you, must prove your worth by navigating a deviously crafted maze, entangled with demonic evil at every twist and turn. So, grab your Hell Hammer and get ready to unleash your almighty fury!

Use Scathe's brute strength and extreme speed to purge your way through Hell's most grotesque abominations, as you search for the Hellstones and defeat the all-powerful Guardians that protect them.

It's time to blast your way out of bullet Hell.

Publisher: Kwalee Ltd

Release Date: Aug 31, 2022




https://www.metacritic.com/game/pc/scathe

Print this item

  [Tut] Python TypeError ‘set’ object is not subscriptable
Posted by: xSicKxBot - 09-11-2022, 08:12 AM - Forum: Python - No Replies

Python TypeError ‘set’ object is not subscriptable

5/5 – (1 vote)

Minimal Error Example


Given the following minimal example where you create a set and attempt to access an element of this set using indexing or slicing:

my_set = {1, 2, 3}
my_set[0]

If you run this code snippet, Python raises the TypeError: 'set' object is not subscriptable:

Traceback (most recent call last): File "C:\Users\xcent\Desktop\code.py", line 2, in <module> my_set[0]
TypeError: 'set' object is not subscriptable

Why Does the Error Occur?


The Python TypeError: 'set' object is not subscriptable occurs if you try to access an element of a set using indexing or slicing that imply an ordering of the set.

However, sets are unordered collections of unique elements: they have no ordering of elements. Thus, you cannot use slicing or indexing, operations that are only possible on an ordered type.

? Recommended Tutorial: The Ultimate Guide to Python Sets

How to Fix the Error?


How to fix the TypeError: 'set' object is not subscriptable?

To fix the TypeError: 'set' object is not subscriptable, either convert the unordered set to an ordered list or tuple before accessing it or get rid of the indexing or slicing call altogether.

Here’s an example where you convert the unordered set to an ordered list first. Only then you use indexing or slicing so the error doesn’t occur anymore:

my_set = {1, 2, 3} # Convert set to list:
my_list = list(my_set) # Indexing:
print(my_list[0])
# 1 # Slicing:
print(my_list[:-1])
# [1, 2]

Alternatively, you can also convert the set to a tuple to avoid the TypeError: 'set' object is not subscriptable:

my_tuple = tuple(my_set)

Let’s end this article with a bit of humor, shall we? ?

Programmer Humor


There are only 10 kinds of people in this world: those who know binary and those who don’t.
??‍♂️
~~~

There are 10 types of people in the world. Those who understand trinary, those who don’t, and those who mistake it for binary.
??‍♂️?‍♀️



https://www.sickgaming.net/blog/2022/09/...criptable/

Print this item

  (Indie Deal) Movie Quest Giveaways, Frontier & Ubisoft Sales
Posted by: xSicKxBot - 09-11-2022, 08:12 AM - Forum: Deals or Specials - No Replies

Movie Quest Giveaways, Frontier & Ubisoft Sales

Movie Quest Giveaways
[www.indiegala.com]

https://www.youtube.com/watch?v=icC3BbrxRQI
[www.indiegala.com]
[www.indiegala.com]
https://www.youtube.com/watch?v=jvYSjvibfm4


https://steamcommunity.com/groups/indieg...7417618431

Print this item

  News - Best NBA 2K23 PFs: Top Power Forwards By Rating
Posted by: xSicKxBot - 09-11-2022, 08:12 AM - Forum: Lounge - No Replies

Best NBA 2K23 PFs: Top Power Forwards By Rating

NBA 2K23 is finally here, which means it's time to discuss the league's best power forwards. Barkley or Malone? Duncan or Webber? Dirk or Gasol? This year's list of NBA strong forwards has a lot more talent than you think and with Paolo Banchero being the Rookie Of The Year favorite, we wanted to find out the answers for ourselves. 2K23 ratings are in the wild and if you're curious about who's on the rise, here's everything you need to know about the 10 Best power forwards in NBA 2K23.

For more on NBA 2K23, check out our MyNBA Eras preview and the 2K23 ratings hub.

NBA 2K23: Top 10 Power Forwards

Below is Visual Concepts' in-game list of the best strong fours in NBA 2K23:

Continue Reading at GameSpot

https://www.gamespot.com/articles/best-n...01-10abi2f

Print this item