Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/09/2016 in all areas

  1. Absolutely true. Rest of this sentence was great too, but just wanted to point out that I fully agree with this: if someone prefers platform Y over PW in a specific case, that's their call to make. They may or may not have good reasoning behind that decision, but that doesn't change the fact that it's still theirs to make. Someone I used to work with once explained to me that "WP is awesome because I don't have to know anything about web development to add new features to my site". For most users, even those who describe themselves as "developers", that's really the gist of it: being able to add features in a cost-effective way and without having to understand what's really going on behind the scenes. While this approach no doubt has it's benefits, sometimes the result is this: "Grade D, 10.29 seconds load time, 3.5 MB page size, and 206 (!!) requests." Or worse, a hacked site because one or more of those plugins you installed were badly written and you didn't have the time, money or knowledge needed to spot those issues, or perhaps you neglected to monitor the site and install all those updates in time. I'm not saying that WP can't be used to develop sites "the proper way", or that you actually have to keep installing stuff until your site breaks, but it's good to realise that what is often considered the biggest benefit of the system (ability to add features with no so-called programming knowledge) is also one of the easiest ways to completely wreck it. Each and every feature you add to the site increases the amount of technical debt, that's just how it works.
    5 points
  2. MarkupGoogleRecaptcha Google reCAPTCHA for ProcessWire. This module simply adds reCAPTCHA V2 or Invisible reCAPTCHA to your form. How To Install Download the zip file at Github or from the modules repository Drop the module files in /site/modules/MarkupGoogleRecaptcha In your admin, click Modules > Refresh Click "install" for "MarkupGoogleRecaptcha" Official install/uninstall doc: http://modules.processwire.com/install-uninstall/ API You must create an API key prior to use this module. Goto https://www.google.com/recaptcha/admin to create your own. Next, add the API keys information to the module's settings. Usage Call the module : $captcha = $modules->get("MarkupGoogleRecaptcha"); Call $captcha->getScript(); somewhere to get the javascript used by reCAPTCHA Render reCAPTCHA in a standard HTML <form></form> by calling $captcha->render() or Render reCAPTCHA in an InputfieldForm by passing as argument your form to the render function: $captcha->render($form) Call verifyResponse() to get the result. It return TRUE if the challenge was successful. Example Using ProcessWire's form API : $out = ''; $captcha = $modules->get("MarkupGoogleRecaptcha"); // if submitted, check response if ($captcha->verifyResponse() === true) { $out .= "Hi " . $input->post["name"].", thanks for submitting the form!"; } else { $form = $modules->get("InputfieldForm"); $form->action = $page->url; $form->method = "post"; $form->attr("id+name", "form"); $field = $this->modules->get('InputfieldText'); $field->name = "name"; $field->placeholder = "name"; $form->add($field); // CAPTCHA - our form as argument, the function will add an InputfieldMarkup to our form $captcha->render($form); // add a submit button $submit = $this->modules->get("InputfieldSubmit"); $submit->name = "submit"; $submit->value = 'Submit'; $form->add($submit); $out .= $form->render(); // include javascript $out .= $captcha->getScript(); } echo $out; Example using plain HTML Form : $captcha = $modules->get("MarkupGoogleRecaptcha"); // if submitted check response if ($captcha->verifyResponse() === true) { $out .= "Hi " . $input->post["name"] . ", thanks for submitting the form!"; } else { $out .= "<form method='post' action='{$page->url}'>\n" . "\t<input type='text' name='name'>\n" . $captcha->render() // render reCaptcha . "\t<input type='submit'>\n" . "</form>\n"; $out .= $captcha->getScript(); } echo $out;
    4 points
  3. Thats what I was talking (thinking) about when agreed to @tpr and @szabesz : the use of the UA-Switcher. Honestly I think, when already using (installed) TracyDebugger, there is no need to have an additional UA-Switcher elsewhere. But I'm using ALIF everytime. In my local (not yet released) version, ALIF even has a toggle button to switch on/off the TracyDebugger And I use it in production sites for frontend edit- and logout- buttons for editors. That was the initial reason why I have written it.
    4 points
  4. @cmscritic Mike, great to hear from you. I'd be very interested to know a little more about the holes in the PW offerings that compelled you to look at WP; there obviously are some, or you wouldn't have made the call to switch. I've never personally used WP, but I know people that like the theme-ability (is that a word?) and the large number of extensions that are available for it. It's also very popular with a large section of online entrepreneurs. I don't think we should get too emotional about folks' decisions to switch, as there are obviously a wide choice of tools around, but I would like to understand what is missing from the PW eco-system - and where possible, without detracting from Ryan's design decisions for PW - plug the gaps through well designed modules and site profiles. Thanks for all you've done in promoting PW and hope we can get you back to using it soon.
    4 points
  5. That's correct! This is one more example on how things grow in our community: we work together to make it as good as we can. Someone come up with a good solution for a partial thing. This a) directly help others, it b) inspires other users to new / other solutions, and this, in the end, makes working with our beloved PW a little more better again. And, in this case, (ALIF and Tracy): from now on, everytime when I will use Tracy, I will have the feeling that a little part of my work is into it.
    4 points
  6. Hi Barido, Welcome to the ProcessWire forums. I think there will be a number of solutions you can choose from. A few that occur to me are below. 1. Without using any modules and just working with the default Pages tree, you could use either the Published/Unpublished state or the Hidden/Unhidden state of the job page to switch a job from Active to Inactive (or vice versa). These states can be set directly from the Pages tree without needing to open the page for editing, as shown in the screenshot below. If inactive jobs need to be shown on the website front-end then the Hidden/Unhidden state would be the one to go with. In your templates you can test for the hidden state using the $page->isHidden() method. 2. You could use the Batch Child Editor module to toggle the Published/Unpublished or Hidden/Unhidden state. 3. You could purchase the Lister Pro module. This module has a number of cool features, one of which is the inline editing of page fields directly in the page list. So if you wanted to use a checkbox field in the job page to store the active/inactive state you could toggle this field via Lister Pro.
    4 points
  7. The latest version adds a new User Switcher panel that lets you instantly switch to any user (or logout) and then easily switch back to your superuser account. It is fairly similar in functionality to the user switcher in @horst's excellent ALIF module, but has the advantage of making the Tracy debug bar available when switched to any user and even when logged out, which can be very useful for debugging. Obviously there are some security concerns when setting up functionality that can log into other accounts without needing a password. There are several things this panel does to make this safe(r), but the key thing to remember is that setting Tracy to Production mode keeps you safe! It is completely disabled unless Tracy is specifically set to Development mode. Detect mode won't work and even the "Superuser Force Development Mode" option won't enable it so you can be sure your live sites are safe unless you specifically enable Development Mode for a debugging session. You need to be a superuser to have access to the panel until a session is started, so even when Development mode is enabled, other users still won't be able to use it. It only works for the duration of user switcher session (max 60 minutes) and only a superuser can start a session. Starting the session makes use of PW's CSRF protection. The switcher session has a unique ID and expiry time which is stored in the database and must match the ID in the user's session. Once the session has expired, it is no longer possible to switch users. You can manually end the session, or if you forget it will expire automatically based on the session length you set. As usual, icon colors are meaningful telling you what type of user is currently logged in: Green: superuser Orange: non-superuser Red: guest / logged out Please let me know how you go with this new panel - hopefully it will be a significant timesaver when checking/debugging your site from other user roles. Also, if you think of any improvements that could make this more secure, or useful, please let me know. I would definitely appreciate an extra set of eyes (or two) to take a look! This new version also has the following changes: It removes the need for the separate helper process module for executing the Console Panel code - it will be uninstalled during the upgrade. I have removed the "Debug Statements" tool in the config settings - I think this is superfluous now that you can easily add debug statements to template files dynamically using the Template Editor Panel. If anyone really wants this back, let me know. There is also significant cleanup of other sections of code, so please let me know if you notice any issues from these changes. Have a great weekend!
    4 points
  8. A quick update folks. A member of the forums has reached out and offered their services so perhaps you'll see our return to ProcessWire after all. We shall see.
    4 points
  9. To be completely fair, it is a part of the core and it doesn't require a module The easiest way to handle this is to create a page to contain images (or multiple pages, separated into categories, or whatever) and then, when embedding an image, choose to use an image from one of these pages instead of the current one. That's just about it. The modules that handle something like this are largely just layers of abstraction built to hide the underlying concept from the end user. Sure, if your needs are massive then you might require a more complex solution to solve them, but something as simple as reusable images are very easy to set up using nothing but the tools that ProcessWire already ships with
    3 points
  10. @horst, Yes! My clients love that ALIF shows up on the front-end. It makes it easier for them and me to get to the back-end. It's very visual and simple to explain to anyone. I've been very happy ever since you made the ALIF module available. Excellent work on having the Tracy toggle! You and @adrian are to be greatly commended for doing some remarkable work on all of your modules. Thanks.
    3 points
  11. I respectfully disagree, unless you are only talking about depreciating the user switching part of ALIF. I use ALIF all of the time when logged in as an administrator. I only turn-on Tracy Debugger whenever I need to debug something. I have great use for both tools and would not like to see either one of them depreciated. My opinion.
    3 points
  12. Launched phase 1 of a new site. Still working out a bunch of details, poco a poco. http://vacuumwholesalers.com Modules include MarkupSimpleNav Form Builder Lister Pro Pro Fields
    3 points
  13. I thought I'd chime in and answer some questions first and foremost as I saw people chatting about this here. We initially moved because we wanted to add some functionality that would have cost too much to develop. My biggest issue myself is that I am not a developer (i'm a tinkerer) and I wanted more advanced product pages, etc. Yes, they could for sure have been built in processwire but I felt that for someone like myself who is not a code guy, I was too limited by the product as I simply don't have the time to learn enough PHP to code and hiring a developer to do work i could theoretically do myself with wordpress seemed like a waste of money. So those were the initial motivations for moving. Now that we've moved, however, the whole "grass is greener" effect has faded and I have some regrets, however, the extra functionality has allowed us to make more sales and bring on new customers that we didn't have before. So it's a catch 22 for me. I'll expand more on this further down. I don't think this is a fair statement, frankly. The initial point of our website was to view things from an end users point of view, not that of a seasoned developer. Our reviews don't go into how easy it is to code with something but rather how easy it is to use, how functional, etc. These are the things most of our readers want to know as we tend to get a lot of traffic from those who are looking for software but don't have a development background. Yes, this grade sucks. Part of the issue for me is again, I'm not a developer so we clearly need to work on things. This is good to know, please do tell me what specifically you feel is missing so we can fix it. ProcessWire is an awesome product and Ryan did a ton for us. Ideally, I would have loved to have simply paid him to make everything we have now work on PW. If that was a possibility and the cost wasn't too high, I would have gone that route. Sadly, it just isn't feasible sometimes and I often look for alternative ways to compensate those who work for us. Before our move to WP, the intent was to search out vendors who were willing to take on the task of building our site on their platform in exchange for an agreed upon advertising term. In other words, they build our site on their platform (which is a bonus as then their product gets noticed more, as was the case for processwire) and in exchange, we offer advertising for an agreed upon term as the form of payment. With the case of PW, however, this didn't work and we needed to pay for the development costs up front which, while worth it since Ryan is so awesome.. tend to get costly when every tweak needs a developer. If I'm able to find someone with a development house who wants on the advertising in exchange for work method, I may be able to pull off a move back to PW but until then, I may have to search out other alternatives. Fortunately, there are plenty of companies that are interested in doing this but I'm picky so moving is a decision that I need to consider deeply. Normally I wouldn't share these kinds of details to this extent but I feel I owe this community, which we've been part of for a long time, an explanation. So here's the pitch: If there's anyone out there who wants to take on the task of making what we need a reality and getting long term advertising for their business in exchange, drop me a line. Until then, the search for an alternative may continue as WP simply seems to be causing too many issues and bloat (I should have seen this coming granted but hey, nobody's perfect and a critic isn't always right). Thanks for reading Mike
    3 points
  14. This week we've got a pretty major upgrade to our page finding selectors that we think you will find useful in a lot of cases! Now you can accomplish much more with less, and this really brings our selectors to the next level. https://processwire.com/blog/posts/pw-3.0.25/
    2 points
  15. I am not so sure about that and it certainly wasn't my intention. ALIF has additional features that make it a worthwhile tool, like: screen dimensions session destroy OPCacheStatus viewer Also for those not using Tracy because they prefer a different PHP debugger, the user switcher in ALIF will still be indispensable.
    2 points
  16. You just made ALIF deprecated but I think @horst can live with that
    2 points
  17. This is another great addition to the toolset of your No1 developer helper plugin! Thanx so much! "...hopefully it will be a significant timesaver when checking/debugging your site from other user roles." Sure, it will be! The only reason I sometimes used the ALIF module was the user switcher feature. Now we have a more feature rich solution, without needing to install another module.
    2 points
  18. @cmscritic Hey Mike, The fact that you can drop in and share with us so much about your reasons for the move says a lot about you. I like that; I respect that. As others have said, we've also gained a lot as a community from your collaboration with Ryan: Hanna Code, the awesome CMS Critic development write-up, and who knows how many people have found ProcessWire because of your site . So, thanks for the ride... Best wishes for the future.
    2 points
  19. Hello folks I made this simple tutorial of explaining my methodology when creating a PW system. https://medium.com/@clsource/understanding-processwire-templates-fields-and-pages-201aecd0a1a4#.osipvjevk
    1 point
  20. Assuming you're usine Apache, it's better to use Options +Indexes, without the + you may reset other apache directives that are currently in effect. Take a look about 2/3 of the way down this page: https://httpd.apache.org/docs/2.4/mod/core.html#options
    1 point
  21. i've just created a pull request that makes it possible to modify less variables. it also adds a check if the js/css file exists and throws a note either in console if tracy is installed or in the processwire log. that's how you can modify your less variables: <?php $config->styles->append('less/theme.less'); $lessVars = array( 'tm-primary-bg' => '#568AEA', 'background-image' => 'url("' . $page->backgroundimage->url . '")', ); ?> <link rel="stylesheet" href="<?php echo AIOM::CSS($config->styles->unique(), $lessVars); ?>"> https://github.com/FlipZoomMedia/ProcessWire-AIOM-All-In-One-Minify/pull/57
    1 point
  22. These are two different things: subcriber system and newsletter sending. I suggest to first read / post in the NewsletterSubscriptionModules forum support thread to get this working. In regard to newsletter sending, I suggest to use a service and / or use a module like: http://modules.processwire.com/modules/wire-mail-mandrill/ http://modules.processwire.com/modules/wire-mail-mailgun/ http://modules.processwire.com/modules/altivebirit
    1 point
  23. Thanks for the offer. The individual in question may be offering full development of what we need in exchange for advertising / promotional services. I'll let you know if we need additional help and truly appreciate the offer. Thank you, I think we should be ok at the moment but I'll advise if we need additional help. Gotta love this community! I'm in need of more coffee before I go full on with my reply but one of the big ones was the lack of a media library to reuse media content (I'm aware now that there are some solutions to this so we'll see how this plays out if the new site gets developed back on PW). Obviously, this is frustrating because we're stuck re-uploading images as opposed to reusing old ones. I know there are some solutions out there but IMHO it should be part of the core solution as opposed to something requiring a plugin.
    1 point
  24. Hello teppo, I have re-installed this module on a 3.25 dev version today and it works. I dont get any error messages
    1 point
  25. Hello, I would also like to donate my services to help get you back on track. I've seen my fair share of WordPress sites hacked. We don't want that to CMSCritic. Front-end developer, so I do a lot of front-end facing functionality and UI/UX. If someone would like to create a private bitbucket team for this, maybe it can be open to the community.
    1 point
  26. @Robin S 's solutions are perfect. My personal favourite would be the first one: just working with the basic page tree and hidden / unhidden or published / unpublished states. If you want go with another pagefield solution (checkbox), but want to have a good visual sign rendered in the page tree, there are some code examples in the forums here how to use a hook for that. Other than in the linked example, with recent PW versions, you don't need a module for that. You just can add a code snippet for that hook into your sites init.php. If you need any further help, just ask.
    1 point
  27. Haven't tried myself but you could see if this is something you could use: http://processwire.com/blog/posts/processwire-3.0.21-and-2.8.21/#multi-language-toggle
    1 point
  28. In before better answer, there is a good tip from @horst about how to set a default language from the start. The thread is interesting too.
    1 point
  29. Then it seems your server doesn't allow Directory listings +Indexes. Nothing to do with PW.
    1 point
  30. Hi @bernhard - glad to hear that Tracy is first on your list I am happy to make that ignore list configurable, but I would also like to know what errors you were getting due to those invalid characters. Maybe that also needs some attention? I am also wondering if perhaps it should be the other way around - maybe it should only process the root of site/templates plus the root level of the scripts and styles subfolders. In other words it would not scan any other site/templates subfolders and also no subfolders with scripts and styles. I would of course make this configurable also as I expect some people change "styles" to "css and "scripts" to "js". I don't want to end up with too many config options, but sometime soon I need to make it easy to export Tracy settings from one install and import into other installs.
    1 point
  31. hi adrian, new website, first module installed: tracy it's really a great tool, thanks again! today i had the problem of several errors when using the todo-panel, because there where some invalid characters in some of my template sources. it is a folder of my designer using uikit and some other resources... i fixed it by adding the template folder on this line: https://github.com/adrianbj/TracyDebugger/blob/master/TodoPanel.inc#L148 i think it would be a good option to have a textarea to EXCLUDE (or maybe also include?) some folders from being processed. i have lots of todos/hacks/bugs in my template that are not my concern - so this option would be great in two ways: prevent errors like the one i had today and prevent showing todos that do not belong to my work.
    1 point
  32. If this is true i am very much impressed with the community (my brothers/sisters), please @cmscritic let us know how we can chime in too.
    1 point
  33. Thanks for your honest reply Mike.
    1 point
  34. Thanks Mike for that honest and transparent answer to the discussion. Being low on budget will always force projects to make trade-offs even if one would like to not make them. And as you've experienced it: Not everything that looks shiny in the first place will ultimately be as simple, which is also a valuable insight for anyone here needing to tell that to customers.
    1 point
  35. Hi Mike thanks most times i come to cms critic so i can know what cms exists for different platform e.g CMS for .NET or CMS for Python you guys had that feature and it was awesome but now it's missing and it makes it harder for me to explore other CMS out there. If you can bring it back i'd be extremely happy, because it was very easy and convenient with your site.
    1 point
  36. Thanks! Actually it's not the module's CSS but the base (Reno) theme. My module only overwrites values, though I tried to fix this but with only partial success (on load the initial CSS styling was still visible). Now I corrected this text color issue (no version change).
    1 point
  37. Wow! Works like a charme!! The only thing I would change is the color of the bold text in the tooltipps. I dont know why but, you use #777 as color. I think the contrast between the background and the color of the bold text is not really good. Here is your CSS part: .description strong, .notes strong { color: #777; font-weight: 700; } I would use #fff for bold text too so it would be better readable. Congratulations to this awesome module!
    1 point
  38. v027 is up with the Tooltips submodule. The CSS got a bit complicated but hopefully everything will be fine forever so I don't have to dive into it again You can switch whether to use it for field descriptions and/or notes, and whether to use the "overlay" style.
    1 point
  39. Update: Version 010 Changelog Following up on the last commit, made message to show if no base image found configurable.
    1 point
  40. New Template Editor panel just added! This is an alternative to the Template Path panel (which I still think is a great option) if you need to edit a live site, which of course you never do The difference with this compared to Nico's Template File Editor (http://modules.processwire.com/modules/template-editor/) is that it allows you to test changes without affecting other users currently viewing the site. Note that there are three buttons: Test: This will reload the page using the code in the editor - no changes are made to the template file or the code served to all other users of the site. Push Live: This will save the editor code to the template file, making this a live and permanent change. Reset: This will reload the page (and the code in the editor) with the code from the saved template file. Possible use scenarios Use this panel similarly to your dev console for tweaking CSS/HTML - it still requires a page reload, but there are likely less clicks than your normal workflow. Use it to tweak a live site if you're away from your computer and need a quick way to fix something, but want the ability to test first without breaking something temporarily due to a simple syntax error mistake or more serious code mistake. Use it to add debug statements: fl(), bd(), d() etc to your template code without ever touching the actual template files. This is a first version of this panel - I am looking for feedback and feature/behavior suggestions. At the moment this only lets you edit the template file for the currently viewed page. I am considering adding a dropdown where you can load other files (included files, JS, CSS files etc), but want to see what you guys think.
    1 point
  41. @adrian, Git branch integration next?
    1 point
  42. Looking for a little advice. I have just added ACE Editor to the Console panel (not committed yet): Questions: Do you think we need an option to revert to a standard textarea or is having ACE loaded the only option ok? This works without having either of the PW ACE modules installed so I am just packaging the ACE core, the PHP highlighter, and one theme (tomorrow_night). Is everyone ok with this, or would you prefer to have the ability to change themes? If I do this, then I will probably require InputfieldAceExtended to be installed to prevent a huge download included with this module. Any thoughts on whether adding a snippets manager to this panel would be useful? It would allow you to name and save code snippets which can be loaded dynamically from a select field. Any thoughts or suggestions? Thanks!
    1 point
  43. Update: thanks to LostKobrakai's prompting, I've looked at delayed operation and implemented a mix of immediate and delayed updates. This is a major change, so the code is still in alpha and available in the dev branch at github (there are also some screenshots to be found in the readme). I've incorporated an admin page where pending updates can be seen and triggered, but the whole thing is still lacking permissions checks (both for visibility of the admin page and for listing viewable/editable pages), which may require some big changes to the code (perhaps even split hooks and update functionality into separate modules). Of course, if that happens, I'll make sure updating works. Every page clone now stores a todo entry in the database. When cloning a page, URL updates are triggered after the last page has been cloned and at most 50 pages are updated (configurable in module settings). The rest of the updates have to be triggered manually in the admin page (for now). So if anybody wants to give it a try, I'd love to get some feedback.
    1 point
  44. That's interesting. Usually I have a local copy of each site. For sync (and deploy) I use capistrano. For example: cap production db:server_to_local. - db:server_to_local Import server database locally --- executes --- - db:dump_server_db dump server database - db:download_server_dump download server database dump - db:dump_local_db backup local database - db:import_server_db import server database locally - db:download_assets you will be asked, whether to fetch assets from server This way I can also sync between servers easily (production to staging for example).
    1 point
  45. $image = $page->images->get("name=picture.jpg");
    1 point
  46. The goal is that there would be no difference from our perspective. But the reality is they are two totally different things behind-the-scenes, so there are sometimes minor differences. In time, hopefully there won't even be minor differences. But either way, it's good to know the difference just because database-querying selectors are more expensive to execute in terms of resources. Any function that accepts a selector and returns pages from the $pages or $page API variable is a database-querying selector. Whereas in-memory selectors are primarily used by PageArrays, as they represent a group of pages already loaded in memory and selectors are used to filter through them. $results = $pages->find("selector"); // database-querying $results = $results->find("selector"); // in-memory $children = $page->children; // database-querying $children = $page->children("selector"); // database-querying $children = $children->filter("selector"); // in-memory $children = $page->children->find("selector"); // database AND in-memory (just use children w/selector instead)
    1 point
  47. I'm embarrassed to admit that I send them myself, using a script I wrote more than a decade ago. It's always worked fine, so I've just stuck with it. But I agree with the guys that say it's better to use a service. Someday I will take that advice myself too. But if you want to use what I'm using, here you go… First you'll need a text file with your subscribers in it. 1 email address per line. It can be only a few, or it can be thousands. subscribers.txt bob@email.com jim@bigcompany.com mike@little-org.com Now you'll need the email content. You'll want 1 HTML file and 1 text file. Both should have the same content: template.html <html> <head> <title>test email</title> </head> <body> <h1>Test</h1> <p>This is a test email</p> </body> </html> template.txt TEST This is a test email email.php Place this PHP file in the same directory as the above files. Edit the DEFINEs at the top as necessary. I apologize in advance for this rather awful email solution, but hey it works, and that's why I haven't bothered to rewrite it in 10 years. To run, place the files on a web server and then load in your browser. It should start emailing immediately, once every 3 seconds. If you are sending thousands, then it might take several hours. But because it sends slow, it never seems to caught up in any filters. <?php /** * GhettoMailer v1.0 * * © 1994 by Ryan Cramer * */ define("NAME_FROM", '"Your Name Here"'); define("EMAIL_FROM", "you@domain.com"); define("REPLY_TO", "you@domain.com"); define("ERRORS_TO", "you@domain.com"); define("SUBJECT", "ProcessWire News & Updates - April/May 2013"); define("SECONDS", 3); // seconds delay between each email sent define("TEXT_ONLY", false); // set to true if not sending HTML email define("TEST_MODE", false); // set to true if just testing a send define("TEST_MODE_EMAIL", "you@domain.com"); // email to send to when testing define("SUBSCRIBERS_FILE", "subscribers.txt"); // file containing subscribers, 1 email per line define("TEMPLATE", "template"); // file containing email to send: template.html and template.txt define("X_MAILER", "GhettoMailer 1.0"); /**************************************************************************************/ ini_set("auto_detect_line_endings", true); function mailTextHtml($to, $subject, $message_text, $message_html, $headers) { // exactly like regular mail function except sends both text and html versions $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers = trim($headers); // in case there is a trailing newline $headers .= "\nX-Mailer: " . X_MAILER . "\n" . "MIME-Version: 1.0\n" . "Content-Type: multipart/alternative;\n boundary=\"$mime_boundary\""; $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . "$message_text\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . "$message_html\n\n" . "--{$mime_boundary}--\n"; $success = @mail($to, $subject, $message, $headers, "-f" . ERRORS_TO); return $success; } /**************************************************************************************/ $start = 0; if(!empty($_GET['start'])) $start = (int) $_GET['start']; $subscribers = file(SUBSCRIBERS_FILE); if(isset($subscribers[$start])) { $line = trim($subscribers[$start]); $total = count($subscribers)-1; $email = trim($line); $subject = SUBJECT; if(isset($_GET['pause'])) { $meta = ''; $content = "[$start/$total] Paused. <a href=\"email.php?start=$start\">Resume</a><br />"; } else { $meta = '<META HTTP-EQUIV=Refresh CONTENT="' . SECONDS . '; URL=./email.php?start=' . ($start+1) . '">'; $content = "[$start/$total] Emailing <u>$email</u><br />" . '<a href="email.php?pause=1&start=' . ($start+1) . '">Pause</a><br />'; if(TEST_MODE) $email = TEST_MODE_EMAIL; $headers = "From: " . NAME_FROM . " <" . EMAIL_FROM . ">\n" . "Reply-To: " . REPLY_TO . "\n" . "Errors-To: " . ERRORS_TO; $content .= "Subject: <b>$subject</b><br />"; $bodyText = file_get_contents(TEMPLATE . ".txt"); if(TEXT_ONLY) { mail($email, $subject, $bodyText, $headers, "-f" . ERRORS_TO); } else { $bodyHtml = file_get_contents(TEMPLATE . '.html'); mailTextHtml($email, $subject, $bodyText, $bodyHtml, $headers); } $handle = fopen("email.log", "a"); if($handle) { fwrite($handle, "[$start/$total]: $email\n"); fclose($handle); } } } else { $meta = ''; $content = "Subscriber emailing finished. $start emails sent."; } ?> <html> <head> <?=$meta; ?> </head> <body> <?=$content; ?> </body> email.php
    1 point
  48. Nik is right about this. You probably want to change your selector to something like this: $field = $user->language->isDefault() ? "body" : "body.data" . $user->language; $matches = $pages->find("$field*=$q"); That will force it to not consider the default language in the matches at all. However, most of the time you should just do this, which already takes languages into account: $matches = $pages->find("body*=$q"); So whether the user searches for "Beer" or "Cerveza" they will still get to the right page. If you exclude the default language, then that fallback never happens.
    1 point
×
×
  • Create New...