Jump to content

flydev

Members
  • Posts

    1,365
  • Joined

  • Last visited

  • Days Won

    49

Everything posted by flydev

  1. Yes, and I misread your post, I didn’t paid attention that the site is served from MAMP through prepos proxy. And as you already spot, they are transformed in your bundle source. Keep in mind that all process calls are Node.js things and aren’t available in the browser. Anyway, on the example of Alchemy, the api key is made for you, what I mean is, the front app make a request to ProcessWire endpoint, then the needed requests are made from ProcessWire to alchemy endpoint using your api key stored on server side, eg. in template or module, db, .env file/process, then Alchemy answer your server, and finally, ProcessWire send back the response to the front app. It seem you got the idea. What is complicated on your side, if I can help? If is just to test and see external services like alchemy from local, just do not scratch your head to much, and use them as they are, included in the bundle. Using env variable on this case make things easier than going into the source code to change them.
  2. @protro nice tool, I think I am going to build something similar but based with vite/rollup. About your issue, as you pointed it, your are serving your website from MAMP server, then the env will not be available on built app when served by MAMP and you will need to use a solution like php dotenv, and I saw you already read the thread about dotenv then I assume you got it working ? It's also worth noting that by using prepros you are bundling your app with webpack and not vite or rollup, keep in mind that when you will head to js libs documentation or when trying to find what's is not working. Under the hood, there is the stack list: Webpack 5.86.0 Babel 7.22.5 Autoprefixer 10.4.14 Node Sass 9.0.0 PostCSS 8.4.24 PostCSS Preset 8.4.2 Dart Sass 1.63.3 Tailwindcss 3.3.2 Terser 5.17.7 Yes. Or to be more precise, what we can call Entry points. It contain the entry point of your app and the vendors. For more information about the splitting process head to webpack doc.
  3. @strandoo without brainstorming a lot, you could setup an hidden pre-filled field. You certainly want to use `processLoginForm()` and optionnaly `loginSuccess()` hooks. Example there on this old thread, feel free to ask for help: Edit: I highly suggest you to buy a license for the Pro version if your project can afford it, the module is safe, but when dealing with secure access, you want something maintained. You will have possibility to ask ryan directly, and it's a way of "sponsoring" Ryan dev, without speaking of the benefit to the community. ? ... comes from the company’s Managing Director (you want to keep a good reputation ?) That was my positive comment of the day ?
  4. To users of TailwindCSS / Windy, I think you will want to use UnoCSS. @MarkE just see your thread about your page builder, to avoid workarounds or hacks, you don't want to use interpolated or concatened strings. <div class="<?= $error ? 'text-red-600' : 'text-green-600' ?>"></div> Do not pay to much attention to this comment, it's just for the science.
  5. It is. You will be able to use vite module with static or dynamic routes. Two-month bug hunt completed at work so hopefully releasing a beta this weekend, I think I will find the time to finish the skyscrapers profiles based on Svelte, Vue and a dashboard sample with the launch of the module to get you up and running quickly. I can't wait to hear what you think of something that, thanks to @ryan since pw-3.0.173, makes things so much easier about routing for a simple SPA with less than ten lines of code. About the Inertia setup, I hope to make sir @FireWire switch from laravel or at least to give a try ?. Stay tuned.
  6. flydev

    Hacked website

    But actuals logs, stack and software version plus taking note of all files timestamp before doing any modif should be the minimum to help here.
  7. Its just a matter of organizing my directory tree structure. when I was using MAMP, WAMP and even now in Caddytron, I was used to put in every root site folder a wwwroot folder that was the root folder of the virtualhost, so I can keep related meta files, log files, backups, or whatever, on the same directory, without having it accessible from internet. It's basically the same setup as your. To illustrate: - htdocs - wwwroot - index.php - wire … or - /var/www/html - website1 - readme.md - wwwroot - website1 - readme.md - wwwroot About the node_modules folder, just keep in mind that is a dev folder not uploaded on production. So it doesn’t matter where you put the folder as no scripts are linked or interfering with your pw files. If you are working for example on a react app, svelte or vue or even a simple js/ta app, your app will be « talking » with your pw setup from Ajax call or static routes. You only want the final built scripts to be shipped on your production (i mean your pw setup). They will be included the same way like any other script files you are used to do.
  8. Hi @protro I didn't read the thread linked, but I will try to give a small insight of how I am used to dev with ProcessWire, and a note of ES6+ modules, with the answer of the import statements error, I will give you a starter module too at the end of this thread. And sorry, I have to be quick, so I am posting screenshot instead of a good formatted post, see the setup image at the end. First, there is nothing wrong about using a package manager like node/npm, but you should do it in order to make you the life easier. It's more true when working with all the crypto mess. A word on your previous message, almost all lib/packages are developed using JS (TypeScript) so it will work with quite every frameworks/libs (React, Svelte, Vue, whatever). Some implementation are specialized for React, not surprising, React is in JS world what Wordpress is in the PHP world (check the stats in the linked thread below, fellow members here seem to not used it, hooray, react syntax is weird and slow). My setup of almost every app (stay tuned as the whole things are coming published for free): About the ES6+ module, when working with them, you need to use JS and for production building the app, OR you can call them in your `<script></script>` by setting up the script as module by writing `<script type="module"></script>`. Keep in mind that writing calls like that in templates, make global objects, like window, not available until the document is ready making things like binding events to DOM a bit tiresome.. And a draft of a module. It should not work as is, but it's just to give you an "image" more than words and could be written in templates. Writing JS like that (module or template) is not the better way to do it, and should be avoided, it makes things complicated when they're actually quite simple, even more when speaking about Metamask. Check the method `writeWeb3ModalScript()`, you can see that libs can be used from a CDN when published (unpkg make automatically available dist files of any packages): <?php namespace ProcessWire; class Web3 extends WireData implements Module, ConfigurableModule { const WEB3MODAL_PROJECT_ID = ''; // read from db or .env file const ALCHEMY_API_KEY = ''; // read from db or .env file public static function getModuleInfo() { return [ 'title' => 'Web3', 'version' => '0.0.1', 'summary' => 'Web3 for ProcessWire', 'autoload' => false, 'icon' => '', 'requires' => [], 'installs' => [], ]; } public function writeWeb3ModalScript($buttonDomID) { $scriptTag = <<<EOT <link rel="stylesheet" href="https://unpkg.com/@rainbow-me/rainbowkit@1.0.7/dist/index.css" /> <script type="module"> import Onboard from 'https://unpkg.com/@web3-onboard/core' import injected from 'https://unpkg.com/@web3-onboard/injected-wallets' window.onload = async function() { const MAINNET_RPC_URL = 'https://mainnet.infura.io/v3/[APIKEY-HERE]' const onboard = Onboard({ wallets: [injected], chains: [ { id: '0x1', token: 'ETH', label: 'Ethereum Mainnet', rpcUrl: MAINNET_RPC_URL } ] }) const wallets = await onboard.connectWallet() console.log(wallets) const connectButton = document.getElementById("$buttonDomID"); // 3. Sign In window.onSignIn = function() { console.log(connectButton); console.log(window, window.onSignIn); } } </script> EOT; return $scriptTag; } // wallet can be an ENS formatted address public function getTokensForWallet($wallet) { $url = "https://eth-mainnet.g.alchemy.com/nft/v3/" . self::ALCHEMY_API_KEY; $url .= "/getNFTsForOwner?owner=" . $wallet; // send get request to alchemy api $http = new WireHttp(); $response = $http->getJSON($url); return $response; } // two fields in the backend /** * Config inputfields * * @param InputfieldWrapper $inputfields */ public function getModuleConfigInputfields($inputfields) { $modules = $this->wire()->modules; /** @var InputfieldFieldset $fs */ $fs = $modules->get('InputfieldFieldset'); $fs->label = $this->_('API Configuration'); $inputfields->add($fs); /** @var InputfieldCheckbox $f */ $f = $modules->InputfieldText; $f_name = 'web3modal_project_id'; $f->name = $f_name; $f->label = $this->_('Web3Modal Project ID'); $f->description = $this->_('Get Key there: https://cloud.walletconnect.com'); $f->columnWidth = 50; $f->value = $this->web3modal_project_id; $fs->add($f); /** @var InputfieldText $f */ $f = $modules->InputfieldText; $f_name = 'alchemy_api_key'; $f->name = $f_name; $f->label = $this->_('Alchemy API Key'); $f->description = $this->_('Get Key there: https://dashboard.alchemy.com'); $f->columnWidth = 50; $f->value = $this->alchemy_api_key; $fs->add($f); } } (The NPM package is still not available publicly, but not fully required) I will come back later with a working example using a CDN and a small example of a built js app working with PW. In the meantime, I'll leave you to ponder.
  9. Did you read the doc if there is something you might missed ? https://processwire.com/docs/front-end/front-end-editing/
  10. Hi, This message is to be taken as informational and being transparency, NOT as a security alert. In short: The module code do not contain vulnerabilities, you are safe to use it. In depth: Years ago, I could spot some offsec users cloning/forking the project on Github. Theses last days, the project got more activities that can be seen on this graph and it look like the module is now included in some open-source offensive security tools. I took a few hours to find and go back to these tools and took the liberty of testing them myself on three online sites, based on Processwire with the module installed. I obtained no negative results, no red flags to deplore. What's more, the code is now monitored to automatically find and correct vulnerabilities in open source code and dependencies with security tools and DeepCode AI. If you ever find something or even if you are not sure about it, feel free to contact me by following the Security Policy. Have a nice day.
  11. Hi @theoretic Without details about how "big" the database is, I do not see any risks to upgrade to InnoDB. You should read the introduction made by @teppo and the post written by @ryan https://weekly.pw/issue/223/ https://processwire.com/blog/posts/using-innodb-with-processwire/ A nice and short explanation by @clsource : https://github.com/joyofpw/how-to-install-processwire#which-engine-is-better-myisam-or-innodb And of course, ingesting the official mysql dev doc (choose the right version according to your setup): https://dev.mysql.com/doc/refman/5.7/en/converting-tables-to-innodb.html You might need to adjust some buffer settings, to get a first insight of it, you could run mysql-tuner, it take seconds to install and run, in order to get an easy to read report (steps below). ### Install wget (mandatory) ``` apt-get update apt-get install -y wget ``` ### Download mysqltuner ``` wget http://mysqltuner.pl/ -O mysqltuner.pl wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/basic_passwords.txt -O basic_passwords.txt wget https://raw.githubusercontent.com/major/MySQLTuner-perl/master/vulnerabilities.csv -O vulnerabilities.csv ``` ### Run MySQLTuner ``` chmod u+x mysqltuner.pl ./mysqltuner.pl --user $MYSQL_USER --pass $MYSQL_PASSWORD ```
  12. I also use AppApi frequently, you can pull it from AppApi if the code is server side, or, with js dotenv(): // .env file SECRET_API_TOKEN=abcd00001234 // your module/template code <script> const MyApiCall = async (url) => { let connect = await fetch(url, { method: 'GET', credentials: 'same-origin', mode: 'same-origin', headers: { 'x-api-key': process.env.SECRET_API_TOKEN, } }) let result = await connect.json() return result } </script> But it seem you are writing js code from php templates instead of using js components and/or a built app, then: <?php // load .env $dotenv = Dotenv\Dotenv::createImmutable(__DIR__ /* where is .env file */); $dotenv->load(); // ?> <script> const MyApiCall = async (url) => { let connect = await fetch(url, { method: 'GET', credentials: 'same-origin', mode: 'same-origin', headers: { 'x-api-key': <?php $_ENV['SECRET_API_TOKEN'] ?>, } }) let result = await connect.json() return result } </script> dotenv. You just do not want to leak it, whatever the method used. Maybe just try to find an article that correspond you better to understand the process.
  13. What Steve said. And if you need it from your js components, there is dotenv. Take care to not leak the token, if you build the app with Vite, only variable with VITE prefix are exposed as import.meta.env.* eg. VITE_BAAAAAAD=abcd1234 (leaked) DEADBEEF=abcd1234 (not leaked / undefined)
  14. Its copied on the bottom because its an example of a feature not finished on another (not really) WIP module. it does what you are talking about. Copy image from another field, or from a screenshot, it doesnt matter, I understood you was talking about « clipboard ». The specific reason is as you are limited on mimetypes when working with the clipboard write api, in the example above it render the blob in a canvas, on différent format, including webp. Voila ?
  15. Something like that ? I remember i had started to implement the feature in the not finished module editorjs. I can put my hand on it if you want, it shouldn't be missing lot of work as the upload between the two inputfields is still working.. Click "copy" button on the first pasge, CTRL/COMMAND+V on the second. Enregistrement #62.mp4 Edit: I must admit that this feature could be handy in the core image things.
  16. Glad to hear it, thanks for the kind of words., do not hesitate to try Duplicator integration in wire-cli. To get back to the topic, understood, then you should be able to get started quickly, With both web3 you will get users/guest wallet connected. To interact with Ethereum and smart-contracts, the easier way is to use one of the cleanest API made by Alchemy through their alchemy-sdk. You will be able with something like ten lines of code to get the tokens (fungible or not) from the contract(s) of your choices and then send ajax request to your scripts/templates to set something in the user session and let user view the hiddens pages and/or medias. Do you use a "vanilla" JS/PHP frontend or are you on React, Svelte or something?
  17. Hi, I "don't get what you have in mind" when you say "managed by" but things are pretty easy. Just associate public wallet address(es) of an user in the system user template by adding a new field to it. You will need a custom module and/or some hooks to interact with ProcessWire's session, brainstorming needed there before going further. The workflow then could be: the user land on the site he process to log in by connecting his wallet address if this address is known then proceed to log in after the user sign the transaction if there are no account associated with this address, create the account with user approbation (signing transaction) The account creation will be only made after the user selected hs wallet, and signed the transaction you sent to it. Then I highly suggest you to use a battle tested solution to interact with wallets as there are multiple way of interacting with them, knowing that all wallet do not use the same method. For example you will find different process between CoinbaseWallet, TrustWallet using WalletConnect and Metamask/Phantom, not to mention the various blockchains implementation, eg. Ripple. So, about the lib to use, just use Web3Modal made by WalletConnect or Web3-Onboard made by Blocknative. Another solution which is good to know it exist, I used it in january when I built a desktop app wallet (this one is not the cheapest you will find and it's more focused for established companies), is WaaS (wallet as a service) by cryptoapis.io and using HD wallets (xPub, yPub, zPub), TSS and distributed key. More complex things. Feel free to ask more infos, as I had planned to write a module for all this mess and it might be a good starting point while interacting with some users starting with Web3 and ProcessWire ? --- Edit: About the connector/solution you posted above, it look legit, but I think we never heard about them here in the forum, it seem to be an indian company. You might want to contact them directly from the official website, note that the ProcessWire connector IS NOT listed there. The SHA fingerprints of the GoDaddy certificate on both urls are the same.
  18. You want to use RecordRTC.js, you will find a lot of demos and code there: https://www.webrtc-experiment.com/RecordRTC/
  19. @dotnetic @MarkE was refering about multi-instance issue, where there are some hints with Ryan intervention, it might help:
  20. Hello, welcome. A template file is required only if you want to navigate to or view a page associated with this template on the frontend side. So in your case, you need to create a file partner_3.php (empty or not) in site/templates. What you mean by « no access to theme files » ?
  21. It look like a namespace issue. To debug it, what I would do in first instance, is to make backup of databases of the fresh installs which is working, and then the others. After that, I would compare dbs with a good tools like BeyondCompare. In second instance, I would write a script to extract all namespace declaration and use directives to see if there is something to spot.
  22. This is a bit hackish and add only obscurity. There is a better way that not everyone are aware of to achieve what OP ask if it's ok to let users log in into the backend, I didn't followed all the topic previously. Keep in mind that you can override parts of the AdminTheme. To give you an example, let's assuming you are on a default setup with AdminThemeUikit, then follow theses steps: create a new directory AdminThemeUikit in site/templates create a file called _restricted-masthead.php and paste the code you will find at the end of this post copy the file _main.php from /wire/modules/AdminTheme/AdminThemeUikit/_main.php into /site/templates/AdminThemeUikit adjust the behavior of the admin theme as you want in _main.php (example below, just replace the full code) Code of _main.php ? Code of _restricted-masthead.php ? Result Enregistrement #61.mp4 - https://streamable.com/jg2l0p More informations there: https://github.com/processwire/processwire/blob/dev/wire/modules/AdminTheme/AdminThemeUikit/README.md Enjoy ✌️
  23. Could you give us a bit more of details of how your structure / pages tree look like ? Also, which "output strategy" did you choose ? Basically, the main page - which by default is called `home` with a template also called `home` - doesn't require something special. You have full control of what and how things are displayed. If for example, your tree look like the following: Page Title [template name] -------------------------- |- Home [home] |--- Blog Parent [blog] |------ Post1 [blogpost] |------ Post2 [blogpost] To show blog posts in the frontend page Home [home] (home.php) you want to write something like: <?php namespace ProcessWire; $blogposts = $pages->find("template=blogpost, limit=10"); // this is a selector, $blogposts will contain the two page objetcs Post1 and Post2 // loop through all blogposts contained in variable $blogposts foreach($blogposts as $post) { echo "<h2>$post->title</h2"; // echo title field $excerpt = substr($post->body, 0, 150); // simple excerpt to illustrate, 150 chars from body field echo "<p>$excerpt</p>"; } Hope you get the idea.
  24. Another link from the official doc for more informations about multisite: https://processwire.com/docs/more/multi-site-support/
×
×
  • Create New...