Jump to content

Laikmosh

Members
  • Posts

    37
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Laikmosh

  1. Im currently using this setup to manage this exact case you mention, my folder structure is looking like this for all my environments: site ├── config.php └── config-dev.php My config.php has the usual stuff and a constant definition to detect my current environment like this: <?php # All the usual processwire configurations # Have my database setup with env vars: $config->dbHost = $_ENV['dbHost']; $config->dbName = $_ENV['dbName']; $config->dbUser = $_ENV['dbUser']; $config->dbPass = $_ENV['dbPass']; if ($_ENV['dbHostReader']) { $config->dbReader = [ 'host' => $_ENV['dbHostReader'] ]; } $config->dbPort = '3306'; /*------------------------------------*\ Detect environment \*------------------------------------*/ switch ($_SERVER['HTTP_HOST']) { case 'www.site.com': define('ENV', 'PRODUCTION'); break; case 'staging.site.com': define('ENV', 'STAGING'); break; default: define('ENV', 'LOCAL'); break; } Since config-dev.php is present on all my environments, it will prevent config.php from running, so I manually call it and then override the settings I need like this: # I call the normal config.php so that the usual stuff is loaded as always require_once 'config.php'; # In case env vars failed if (!$config->dbHost) die('Missing env vars'); if ('LOCAL' === ENV) { $config->moduleInstall('download', true); // tracy config for dev development $config->tracy = [ 'outputMode' => 'development', 'guestForceDevelopmentLocal' => true, 'forceIsLocal' => true, // use this only on local dev!!!! ]; /** * Disable all HTTPS requirements? */ $config->noHTTPS = true; } if ('STAGING' === ENV) { # Staging settings... } This way I can use the exact same codebase on all my environments, hope this helps
  2. Well for me it has to be more automated because I have to share my environment with a team, so I just created this code and put it in the config-dev.php file $dest = "./site/assets/wire"; // Get canonicalized absolute pathname $path = realpath($dest); // If it exist, check if it's a directory if (!$path and !is_dir($path)) { $src = "/var/www/html/wire"; shell_exec("cp -r $src $dest"); } But just yesterday I uploaded a docker compose configuration that has all this configured by default, maybe it works for you: Processwire docker image
  3. ProcessWire Docker Image Dockerized Processwire installation and development enviroment Local enviroment with MariaDB container included Mount local filesystem Processwire versions VSCode Itelliphense configuration xDebug preconfigured Opcache + JIT ready (xDebug must be disabled) Installation & usage Development enviroment installation Build using local script $ git clone https://github.com/laikmosh/docker-processwire.git $ cd docker-processwire $ docker-compose up Install as usual, no extra configuration is needed. There is a config-dev.php file in the ./site/ folder, this file will load by default when running locally, but is in the .dockerignore, so it wont be included at image building time. Custom php.ini settings can be set at: /Processwire/scripts/php/php.ini *Image must be rebuilt for changes on php.ini to take effect Development enviroment usage By default the ProcessWire installer will load the `.env` configuration. Configure .env file for project and DB settings, default database credentials are: Database: {COMPOSE_PROJECT_NAME} User: admin Password: password Server: database Port: 3306 Editable files and templates will be installed to the ./site/ folder. Processwire documentation ProcessWire ProcessWire Repo ProcessWire Documentation
  4. I just stumbled into this thread with the same problem you describe here, the solution for me was having a copy of the core folder inside my project, I put it inside the assets folder since I already have it configured to not show up in searchs or anything, as long as viscose has access to the files, it can parse the suggestions
  5. Well in this case an alternative would be to create a role called "Self", and include in your logic that any role that can be seen by the "Self" role, is shown to any user with the same role, maybe not as elegant as having the role itself named on the lista, but it could get the job done, as Ivan's link mentions, it is not possible to have a page that references itself, but this could be a workaround
  6. im not getting why are you trying to reference a page on itself, any data that you might get in the reference already exists in the page itself, this is like calling yourself on the phone, could you explain what are you trying to achieve with this?
  7. Im back to be in need of this horizontal scaling, still no clue on what im missing, anyone here has ever tried using read replicas with processwire?
  8. If you are using MAMP make sure you have disabled any cache module from the PHP Language settings on MAMP, sometimes that messes with what you are doing Also how are you setting up the cache expire time?
  9. Hello, im trying to configure a read replica as documented in https://processwire.com/blog/posts/pw-3.0.175/ I have already configured my aws aurora database to have read replicas Im using elasticbeanstalk so i configured the writer and reader endpoints as env vars: and finally added this configuration to my config.php /** * Installer: Database Configuration * */ $config->dbHost = $_SERVER['host']; $config->dbName = $_SERVER['db']; $config->dbUser = $_SERVER['user']; $config->dbPass = $_SERVER['pass']; $config->dbPort = 3306; $config->dbEngine = 'InnoDB'; if ($_SERVER['hostReader']) { $config->dbReader = [ 'host' => $_SERVER['hostReader'], ]; }; but now im getting this error anytime i try to load the site: Error: Exception: SQLSTATE[HY000]: General error: 1836 Running in read-only mode (in wire/core/WireDatabasePDO.php line 889) Any ideas what i could be doing wrong?
  10. Hello! its me again, so in the end it didint work, after some days the error is back, any attemp at creating new files turns into an error until i go into ssh and change the permissions for all files again, any attemp includes when users try to view an image that has not the thumbnail size created yet, processwire attemps to creat the thumbnail and there comes the error, so the error is almost anywhre in the page where there are images loaded, the error im getting is this one: Unable to create temp dir: /opt/bitnami/apache2/htdocs/site/assets/cache/WireTempDir/.PFM0.52373300T1574384522RyRV5wmiGO8N23/L1-L2-L3-L4/ en /opt/bitnami/apache2/htdocs/wire/core/WireTempDir.php linea 173 if anyone knows anything about this please help!
  11. ok, i thik found the solution just in case anybody else has this problem, the first time i made the backup recovery using the install.php file from the duplicator backup, at the time i didnt know about the commands to change the user credentials i described in the original post, so the only way i was able to get permissions was using a ssh tunnel and accesed to the file using localhost:8888/install.php, this way every file was attributed to bitnami, but then when frontend users tried to save images their user daemon was not allowed to edit files or folders made by bitnami So the solution is to use the ssh commands to change the permissions and authors BEFORE using the installer.php, this might also be true when trying to use the root installer of processwire, i dont know but if anyone else runs into this problem this might help, thanks to everyone who didn't replied, please leave me a middle finger if you read this
  12. had the same problem, tried with jquery ui and all kind of calendar libraries around, but in the end the best solution for me was 3 select boxes with day, month and year inline, just used JS to adjust the available days depending on the month and year(in some years february has 29 days), and also to convert that tu a unix timecode and feed it to a hidden inputfield for uploading(be sure to consider timezone in your code), so that ws the best solution for me, what exactly do you expect from a calendar input?
  13. Ive been using signaturepad.js for this, its a js library that allows you to put an input field where users can sign (works really well on mobile), it outputs a png/jpg file that then you can upload to any image field you want (what i do for this on the front end is to upload the signature to a temp folder via ajax and then retreive the url and put it in a text field and then input that url to a $p->image->add($url); on server side, this works for a frontend implementation, i dont know if you require to do this using a processwire form
  14. Hello, i recently migrated my project from a shared hosting to an amazon lightsail instance, it was fairly easy thanks to the duplicator module, but since i moved to the new server ive been having problems with the tight permissions of AWS, since the begining any time processwire was trying to write files in storage it was throwing a "permission denied" error, looking around i found a soultion to change the permissions via ssh with this: sudo chmod -R g+w /opt/bitnami/apache2/htdocs sudo chown -R bitnami:daemon /opt/bitnami/apache2/htdocs (bitnami is the default username that comes with the LAMP installation that comes with lightsail) in the begining this worked fine but then i noticed from time to time the error was coming back at random times (it seems to me everytime processwire creates a new folder in the temp folder, it is created by default with the ownership like bitnami:bitnami instead of bitnami:daemon, but i havent been able to prove this) So now im thinking of running the ssh command every minute to stop this, but i dont think this will be very reliable and would like to know if there is any other way to change the permissions permanently so that any new folder created has the right permissions, or maybe im getting everything wrong and i should do something else, never really worked with ssh or file permissions before so i might be really off on this, hope someone here has had experience with this before, thank!
  15. Is there any way to do the modules>refresh via API?
  16. i just noticed that when i try to delete all caches at once using this code $cache->delete("*"); all the modules installed get uninstalled, is there any reason for this behaviour?
  17. wow, didnt know these things existed, thank you very much! one weird thing is that when i used it i got an error stating that "pages() is undefined", this function is supposed to work from 3.0.39+ and i have 3.0.98, ill chacke what might be the problem but for now i just made a function at the begining like this: function pages() { return wire('pages'); }; its a temporary solution while i find out the real problem but thanks for pointing me in the right direction!
  18. I've been using wire("pages") instead of $pages because sometimes the code is inside functions and the $pages var is not defined unless its included in the args, and i've foundin a post by Ryan that globals $var doesnt work at all in processwire, so for consistency i've been using wire('pages') anytime i need to find or get a page, but now im wondering if there might be any difference in performance from using one or the other Or maybe im just screwing everything up and there is another way to get global vars to work inside a function in processwire?
  19. and how can i set the formatted value of an image file created via API (auto, single, multi, string)?
  20. i went to look into that code and made this modification so i can see whats the problem in the log: if($this->config->sessionChallenge) { if(empty($_COOKIE[$sessionName . "_challenge"]) ) { $valid = false; $reason = "Error: Invalid challenge value, empty cookie"; // $reason = "Error: Invalid challenge value"; } if(($this->get('_user', 'challenge') != $_COOKIE[$sessionName . "_challenge"])) { $valid = false; $user_challenge = $this->get('_user', 'challenge'); $cookie_challenge = $_COOKIE[$sessionName."_challenge"]; $reason = "Error: Invalid challenge value, no match: sessionName=".$sessionName.', cookie='.$cookie_challenge.'user='.$user_challenge; // $reason = "Error: Invalid challenge value"; } } and this was the result: User 'elbedroom' - Error: Invalid challenge value, no match: sessionName=wire, cookie=user=U.kakjfc.txoyfTz0jWmFM7KipM8lHIo (IP: 0.0.0.0) It seems strange because if the cookie was empty the the log would be for the first option and it would say: "Error: Invalid challenge value, empty cookie", but instead it confirms that the cookie is not empty but then it shows an empty result. When i look for the cookies i see the "wire_challenge" cookie is there, everytime i reload thepage the value changes, and when i logout the cookie disappears, im thinking there is some code deleting the cookie everytime i do a frontend login before it validates the challenge, or something like that...
  21. Ok, that’s the perfect option to temporarily stop all the users from yelling at me and sendind death threats over email, but you think there is anything in my code that could be causing this error? What should I look for?
  22. Well I just erased all the cookies but anyway it’s not a local problem, the problem is persistent with all users and on any computer or browser
  23. Tried that but didint work, same thing happens even if i change browser, and the same error is happening when any of the users try to login from their computers
  24. Hello, im having a strange behavior at a frontend login, yesterday it was working perfectly, this morning it stopped working without me changing a line of code, so here is the problem, maybe somebody here has seen this before: this is my login code, it checks the inputs via ajax and returns either "logueado" or "falla_login" $username = slugify($datos['login_username']); $username = $sanitizer->username($username); $pass = $datos['login_password']; if(isset($username) && isset($pass)) { $u = $session->login($username, $pass); if($u) { $respuesta->status = "logueado"; } else { $respuesta->status = "falla_login"; } }; Now this part of the code appears to be working fine, its returning "logueado" when I input the right credentials and "falla_login" when im not. So, after this the answer is evaluated by ajax and if the login was successful("logueado") it reloads the page, This is is the code for the page, its suposed to show you a diferent page depending on your role and the login page if you are not logged in: require("./include/head.php"); if (($user->isLoggedin())) { //si el usuario inició sesión require("./include/header.php"); if ($role=="administrador"||$role=="ceo"||$role=="superuser") { //si es administrador o superuser require("./administracion/administracion-index.php"); //llamar página de administrador } if ($role=="instructor") { //si es instructor require("./instructor/instructor-index.php"); //llamar página de instructor } if ($role=="alumno") { //si es alumno require("./alumno/alumno-index.php"); //llamar página de alumno } } else { $role = "unLogged"; //si el usuario no esta logueado require("./login.php"); // mostrar pantalla de login }; The problem is that when I login with the right credentials the page is reloaded and its suposed to check for my role (the code for setting the $role variable is inside the functions.php file) and then show me the right page, but its returning me to the login page, the weirdest thing is when i check the sessions log i find this: log1: Successful login for 'elbedroom' log2: User 'elbedroom' - Error: Invalid challenge value (IP: 0.0.0.0) So apparently there is somethingchecking for an ip or something and its unlogging me right after logging in, i havent found anyhting on the forums about this "Invalid challenge value" so i hope somebody can help, right now i can only login if i go the the backend, login and return to the front end, this way everything works fine, but from the frontend login nothing is working
×
×
  • Create New...