Jump to content

gizmola

Administrators
  • Posts

    5,590
  • Joined

  • Last visited

  • Days Won

    112

gizmola last won the day on November 26

gizmola had the most liked content!

4 Followers

About gizmola

Contact Methods

  • Website URL
    http://www.gizmola.com/

Profile Information

  • Gender
    Male
  • Location
    Los Angeles, CA USA

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

gizmola's Achievements

Prolific Member

Prolific Member (5/5)

290

Reputation

32

Community Answers

  1. I'm sure there are many such libraries but this one has been used by many people: https://github.com/ddeboer/imap This one comes up as the most used in packagist: https://github.com/barbushin/php-imap
  2. This looks like homework .... I understand the idea, and it smells like a recursive exercise, which teachers love, and yet are rarely employed due to the huge overhead involved in building a functional stack. 2 things here: You have code that "looks" ok. Obviously you are having some problems with it, but you have no examples or debugging of what doesn't work Do you expect us to set up an environment and run your code and debug it for you? See #1. So in general, yes, I would say that yes, if this is an assignment, this is an exercise that should involve recursion. This code looks very suspect for a few reasons including that repeat is not shown to be initialized anywhere, and it should be local to the running function on the stack: $repeat = $repeat * $data[$i]['number']; Just off a quick browse of your code, you are trying to combine the reading of the array with the processing of a repeat/close_repeat. You want a recursive function that only handles the repeat/close cycle. So what you need in terms of variables is: index of global array temporary array built, which is return when function completes and is returned to be added to the finalized array. Inside your recursive function you can encounter 1 of 3 things: An entry which you add to your temporary array A repeat, where you calls the function recursively having advanced the start/end index an end_repeat where you duplicate the temp index the #repeat times and return it you increment the index internally, so you need to pass this by reference One trap you probably have is trying to control the other process with a for loop. What you actually want is a repeat--until pattern where you will process starting with index=0 until the index = count(array) -1. PHP does not have repeat/until but it does have do..while, so that is what your control should be based on. Hopefully this leads you to a solution, otherwise, again we need specific code, with your debugging and specific problems you are having with select sections of the code.
  3. I provided you a solution that should work. Just keep in mind that rules are processed in order. You need this "catchall" to come at the end/after all the other more specific rules or those other rules will never be reached. So you want: www rewrite rule specific pseudo directory rules like your news/ the catchall to *.php Just looking at where you are going with this, having a routing class and using a front controller pattern where you route everything through index.php which acts as a router, is essentially the direction you are taking your site from the look of it. You can make everything simpler and cleaner by either porting to symfony or laravel (which have many benefits in terms of access to all the other features of those frameworks) or just integrate some routing class into what you have. This looks like a possible solution for you: https://phprouter.com/ With that said there are myriad others, but that one appears to be functional, simple and minimal.
  4. The courses I mentioned in the other reply cover design and include layouts with flexbox and grid. https://scrimba.com/learn/flexbox https://scrimba.com/learn/cssgrid You want to keep in mind that your goal is to end up proficient with making "responsive layouts" so you should be at some point absorbing some of the ideas involved in how to have a design that adapts to device viewport. Of course you need to get down the basics first and then I think you can add in the elements that really make things responsive. Responsiveness involves a judgement call on your part... what things should shrink or be hidden at smaller sizes. When it's a mobile phone user, do you stack a menu or replace it entirely with a hamburger button? You figure these things out based on your preference. I mentioned Kevin Powell recently. Go through the free Scrimba course they have with him instructing. If you particularly like his style, then you might want to look at his paid courses. Some are free and some are paid either directly or through a Scrimba membership. In my opinion the Scrimba membership gets you the most bang for your buck, but he has a course on flexbox you can enroll in directly: See links to his various course at https://www.kevinpowell.co/courses/ Powell has this "free" course: https://courses.kevinpowell.co/conquering-responsive-layouts It is being done as a 21 day challenge, with new material being released day by day. The course is just being released now, and only has the first few days of content, but it could be a really good place for you to start. I personally like the idea of Scrimba for people learning as it gets you right to where you want to be within the courseware environment. It also has a very active Discord community you should join if you go the Scrimb route. You can also take the scrimba files and download them, fork your solutions etc, and they host all that for you. But of course for your own projects you need a local environment and code editor, and he is likely presenting that material in a local environment using Visual Studio Code and the "Live Server" extension. One nice thing about Visual Studio Code is that you can add the PHP Intelephense plugin and use it for your PHP development as well. Most pro PHP developers are using the PHPStorm commercial editor, but VSCode is the choice of javascript developers at this point, so if you're doing a lot of both, then VSCode + Intelephense is a good alternative. Powell's free responsive course has an early lesson on the environment and that might be helpful to you to see what he's using for his course.
  5. Ease of use vs security is a never ending battle. Try to opt for the simplest solution that also works. You can either act as custodian (allows for you to aid a user when they forget/misplace something) provide no custody, thus insuring a compromise of your system doesn't compromise user assets You can't do both. Not knowing enough about this system, I would question the nature of the vouchers themselves. Does your system know the value and when something is redeemed? You might have a customer service feature that would allow someone to make a new voucher to replace a lost one? That mght be an alternative, but would require your system to have the necessary information and controls available to you to determine the status of a voucher, and be able to revoke/replace it.
  6. Just a note: please don't use imgur links. That site is a mess, and the forum allows you to attach and insert images into your posts. I editted your question to do that. It's better for everyone to have the content referenced here. As I answered this in the bootstrap thread you made, I'm not going to repeat my comments but they are relevant. These days, layouts are a lot easier to do using flexbox and/or grid. I would also suggest using an html/css/js sandbox for your prototyping/etc. Here's an article with quite a list of different ones. I did already mention scrimba to you, so you can certainly use that as well. https://www.sitepoint.com/code-playgrounds/
  7. I'm not 100% sure what you trying to do. I tried to extrapolate that you are looking for "/something" and wanting to rewrite that to "/page.php?slug=something". Options +FollowSymLinks -MultiViews RewriteEngine On ErrorDocument 404 /404.php RewriteCond %{HTTP_HOST} ^domain.com$ RewriteRule ^(.*)$ https://www.domain.com/$1 [R=301,L] RewriteCond %{HTTP_HOST} !php$ RewriteRule "^([A-Za-z]+)" "page.php?slug=$1" [L,QSA] Since you didn't provide examples of what other rules this "broke", this is my best guess. An important addition is that this rule won't run for existing *.php scripts.
  8. The PHP process may not be able to write to the /var/log directory. Assuming it's the apache user that php is running as in this case. Connect to the container and check out the perms for /var/log.
  9. The first question I would have for you, is do you have a solid "non-expert" understanding of html5 and css? That is what I would highly recommend to get down 1st. This is a good free course to go through, that is all done interactively in the Scrimba environment: https://scrimba.com/learn/introhtmlcss It's taught by Kevin Powell who is one of the better known css teachers I know of, and has an extensive set of video tutorials on youtube. Before you go further down any path, I would recommend you watch this video, which really helps you get an idea of what these different techs provide you from a design/UI standpoint: If you watch enough of this you'll get to the point where he compares some options (vanilla css, vs tailwind vs Material UI (MUI) vs Bootstrap, and declares: "Yeah Don't use Bootstrap. It's 2022 and you know better!" Nonetheless, this is a professional design guy who has worked for various well known companies and is very experienced, so I won't be an absolutist about this, but you should at least go into whatever phase of learning you are entering knowing more about this. I personally use Bootstrap every week for a client I work for, and I would certainly love to be able to move on from it now, but I'm stuck with a giant code base that is tightly integrated with it. At least do your research. Absolutely you should be using the latest version if you do use it. I have found that it is actually pretty easy to use in most cases, however this guy has a complete course on it, and most of his videos are really good: One thing to keep in mind is that Bootstrap does have places where to really take advantage of some of the widgets, you also need to have a working understanding of javascript, in order to integrate it with what you are doing. That is going to be true of many other css frameworks and approaches. It also needs to be said, that whether or not you should be using Bootstrap is a significant question, as there are other css frameworks that have become extremely popular, most notably Tailwind CSS. There are a number of other popular css frameworks, many of which are better suited to customizing the look and feel of things, or have a philosophy that is a bit more modern than what bootstrap has (given that Bootstrap is pretty old at this point, even though it has been updated). Here's an intro to tailwind and a complete course by a guy who has a lot of courses on Udemy, and was actually paid to make a professional level course on Tailwind that is again free on youtube. It is project based, but only one project in this case. If you like Tailwind as an approach then you probably want to look at TailwindUI and/or DaisyUI which build upon Tailwind and are closer to what you would get with much of Bootstrap.
  10. There are functions and an entire database class you didn't include that is mysterious. Here's a simplified functional spec Initialize your variables, get initial statistics Get the largest timestamp value in the database. At the end you can use this to update any rows that need to be cancelled because there was no importer entry This assumes that every row has some sort of timestamp row. It appears that way, but you didn't provide the format. Import the file Check that there are entries. You don't want to cancel the entire userbase because the import was flawed Get pre-import statistics for active/cancelled One group by query for this will give you both numbers. SELECT COUNT(*) as count_of, memberStatus FROM Members GROUP BY memberStatus No need to pre-sort import data foreach through the import data SELECT id, status from Member where id = import id If row is found Based on ID, update status, timestamp If it's an actual datetime/timestamp you can do this with column = NOW() This guarantees that a found ID column gets its timestamp updated regardless of the status Based on status add to appropriate bucket rejoined was still status 1 if row not found Add new member Update to new member count When complete, SELECT COUNT(*) FROM Members WHERE "timestamp/updated" column is <= original timestamp you queried during initialization. These are the rows you now need to cancel, so store in your summary array as needed UPDATE Members SET status = 2 WHERE WHERE "timestamp/updated" column is <= original timestamp you queried during initialization At this point you should be able to make your final reporting. Count the arrays for new/ongoing/rejoined. Use the cancelled count# you got from the summary. You probably want to get an initial count of all existing rows via SELECT COUNT(*) but if all rows have a status of 1 or 2, then you can just use the counts from the GROUP BY query summed together.
  11. I'm not sure what you want from us, given an outline of your requirements and a basic list of steps. You know what you want to do, and the code doesn't work right or count right, so that means you have bugs. We can't debug your code without seeing it. Here are a few thoughts based on list of steps: This is a terrible idea. There is no reason to update rows of the entire table to inactive, only at some later point to set them back to active. Don't change rows you don't need to change. This is really unclear. What is the format of the "import" array? Are there ID's? I don't see how you could classify anyone as a "Left user". If they were not found, then they should be added as a new user. Thus all users are either found (existing) or not found (new). It seems like there are a number of baked in assumptions here that aren't clear, starting with where this import file comes from. What constitutes "active" state in this system? What exactly is the format of the import file?
  12. And everything I wrote previously still applies. let json_array = {} json_array.excludes = [] // Use array method json_array.excludes.push("a") json_array.excludes.push("b") //array syntax json_array["excludes"].push("c") console.log(json_array) I Updated the codepen as well with this example code.
  13. Personally, I would recommend uninstalling xamp and using docker. There are a lot of projects out there that offer a docker-compose that orchestrates a lamp environment for you. Devilbox is a massively complete project that offers a myriad of different configurations (not just lamp), but there are many others, not to mention lots of tutorials showing how you can create your own. I even made a project myself to support some of the work I do. I have seen a good deal of discussion of people who primarily make Laravel apps using Laravel Sail, but it can be used for any php project afaik. With that said, if you absolutely must have something similar to what xampp provides, people seem to like Laragon.
  14. the push method is for an array. Adding to objects can be done in a few ways: Using array syntax: obj['property'] Using "." notation: obj.property obj = { 'foo': ['apple', 'banana'], 'getFoo': function() { return this.foo } } console.log(obj.getFoo()) obj['bar'] = ['red', 'green'] obj.foobar = function() { return this.foo.concat(this.bar) } console.log(obj.bar) console.log(obj.foobar()) Example code in this codepen.
  15. In the documentation about external fonts, it specifically provides an example using google fonts. Try adding this to your initialization of dompdf: $tmp = sys_get_temp_dir(); $dompdf = new Dompdf([ 'logOutputFile' => '', // authorize DomPdf to download fonts and other Internet assets 'isRemoteEnabled' => true, 'isFontSubsettingEnabled' => true, 'defaultMediaType' => 'all', // all directories must exist and not end with / 'fontDir' => $tmp, 'fontCache' => $tmp, 'tempDir' => $tmp, 'chroot' => $tmp, ]); $dompdf->setPaper("A4", "portrait"); $dompdf->loadHtml($_template, "UTF-8"); $dompdf->render(); $dompdf->stream(time() . ".pdf", array("Attachment" => false));
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.