Jump to content

Search the Community

Showing results for tags 'PHP'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • HTML/XHTML
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • XSLT/XSL-FO
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Languages

  1. I have been chasing this issue now for a week. I am new to PHP but have been programming in ASP.NET /VB for over 10 years. I have taken the time to document my issue with PHP connecting to a Localhost database and will try to provide a brief explanation of where I am at. First some environment information. OS - Windows 10 - 64bit. DB - Both SQL Server Manager and MySQL Community. Both running on my development machine. PHP - Version 7.2.12 Development Server running Localhost. From my PHP.INI file here are the extensions I am running. extension=mysqli extension=odbc extension=pdo_mysql Under the ;Paths and Directories I made the following changes. Uncommented include_path = ".;c:\php\includes" Uncommented and edited extension_dir = "c:\PHP\EXT" Note: I also had a number of PHP drivers for MSSQL but have abandoned that attempt and moved to MyPHP // MY TEST CODE \\ <?php $link = mysql__construct("localhost", "mikea", "!QAZ2wsx"); mysql_select_db("database", $link); $result = mysql__construct("SELECT * FROM actor", $link); $num_rows = mysql_num_rows($result); echo "$num_rows Rows\n"; ?> // HERE IS THE ERROR \\ Note I got the same error when trying to use PHP and MSSQL. And the same error with a number of different coding attempts. Fatal error: Uncaught Error: Call to undefined function mysql__construct() in C:\PHP\www\site.php:3 Stack trace: #0 {main} thrown in C:\PHP\www\site.php on line 3 From the error syntax, it appears that the PHP is attempting to call a function out of the driver and it is not being found. This could indicate that there is a compatibility issue the driver is not being called. I have conducted a great deal of research and there is a lot about this problem but most are a few years old. I have downloaded and installed the most current versions of PHP and the MySQL drivers. I want to progress with PHP but need to be able to make connections to mySQL or MSSQL database. I would prefer now to use MySQL as it is more popular on hosting sites.
  2. Hi everyone, I want to make clear again. I am trying to get data from "name" by PHP in HTML, but problem is "name" is used up by Javascript, but I need "name" for PHP's $_POST to get data from input from html, but can I use this "name" by JavaScript and PHP in same time? I need to get data from that word to post in database, but I think I'm stuck now...Anyone can tell me what is alternative keyword to get data from "name" in HTML? If you don't understand what I said, I will display and show you Thanks, Gary
  3. Hello people, Im stuck for a long time, I have an what older login system on my site but it had mysql but now i wanted to upgrade it to mysqli. I've came litlle by litlle bit of searcing this far but it still got error's. I really want it to work again beacause i use it on all my sites. Code: <?php // Een beveiliging om te voorkomen dat men in je header.php probeert te openen. if(basename($_SERVER['PHP_SELF']) == "header.php") { header("Location: index.php"); } // Configuratie laden include_once('config.php'); // We maken eerst een classe aan class login { // Variabelen private $loginsessie = false; public $fouten = ""; private $gebruikers_info = array(); public $database_velden = array(); private $recheck = 0; // Deze functie wordt aangeroepen bij het laden van de classe public function __construct() { // maak verbinding met de database, als het niet lukt breek het af $con = mysqli_connect(mysql_host, mysql_user, mysql_password, mysql_database) or die(mysqli_error($con)); // mysqli_select_db(mysql_database, $verbinding) or die (mysqli_error($con)); // Controlleren op een login sessie $this->check_session(); // De loguit actie koppelen aan de end_session functie if(isset($_GET['actie']) && $_GET['actie'] == 'uitloggen' && $this->loginsessie === true) { $this->end_session(); } } // Init functie public function init() { // Controlleren op een POST request, wanneer er nog geen loginsessie is if($_SERVER['REQUEST_METHOD'] == 'POST') { /* was eerst if($_SERVER['REQUEST_METHOD'] == 'POST' && $this->loginsessie===false) {*/ if(isset($_POST['actie'])) { switch($_POST['actie']) { case 'login': $this->controleer_gegevens(); break; case 'registreer_gebruiker': $this->registreer_gebruiker(); break; } } } } // Functie om het ip adres op te vragen public function get_ip() { if (isSet($_SERVER)) { if (isSet($_SERVER["HTTP_X_FORWARDED_FOR"])) { $realip = $_SERVER["HTTP_X_FORWARDED_FOR"]; } elseif (isSet($_SERVER["HTTP_CLIENT_IP"])) { $realip = $_SERVER["HTTP_CLIENT_IP"]; } else { $realip = $_SERVER["REMOTE_ADDR"]; } } else { if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) { $realip = getenv( 'HTTP_X_FORWARDED_FOR' ); } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) { $realip = getenv( 'HTTP_CLIENT_IP' ); } else { $realip = getenv( 'REMOTE_ADDR' ); } } return $realip; } private function registreer_gebruiker() { if(isset($_POST['actie']) && $_POST['actie'] == 'registreer_gebruiker') { $velden = array(); if(!is_array($this->database_velden) || !count($this->database_velden)) { die("FOUT: Geen velden opgegeven."); } // Alle velden uit de array doorlopen foreach($this->database_velden as $veld) { $veld = split(':', $veld); // Veldnaam $veld_naam = $veld[0]; $velden[$veld_naam] = $_POST[$veld_naam]; // Veld instellingen $veld_instellingen = split('\|', $veld[1]); foreach($veld_instellingen as $instelling) { if($instelling == 'verplicht' && empty($velden[$veld_naam])) { // Controlleer of het veld is ingevuld $this->fouten .= "- Het veld '". $veld_naam ."' is verplicht<br />"; } elseif($instelling == 'md5') { // Codeer naar md5 $velden[$veld_naam] = md5($velden[$veld_naam]); } elseif(substr($instelling, 0, 3) == 'min') { // Controlleer minimum stringlengte if(strlen($velden[$veld_naam]) < (int) substr($instelling, 4)) { $this->fouten .= "- Het veld '". $veld_naam ."' is te kort.<br />"; } } elseif(substr($instelling, 0, 3) == 'max') { // Controleer maximum stringlengte if(strlen($velden[$veld_naam]) > (int) substr($instelling, 4)) { $this->fouten .= "- Het veld '". $veld_naam ."' is te lang.<br />"; } } elseif(substr($instelling, 0, 2) == "==") { if($velden[$veld_naam] != $_POST[substr($instelling, 2)]) { $this->fouten .= '- De velden '. $veld_naam .' en '. substr($instelling, 2) .' komen niet overeen.<br />'; } } elseif($instelling == "avatar") { $velden[$veld_naam] = ('http://habmoon.org/status/habbie?habbie='.$_POST["gebruikersnaam"].'&direction=4&head_direction=3&action=wlk&gesture=sml&size=b'); } elseif($instelling == 'uniek') { $q = mysqli_query($this->con,"SELECT ". $veld_naam ." FROM gebruikers WHERE ". $veld_naam ." = '". mysqli_real_escape_string($this->con, $velden[$veld_naam]) ."' "); if(!$q) { $this->fouten .= '- Er is een MySQL fout opgetreden <br />'; } else { if(mysqli_num_rows($q)) { $this->fouten .= 'De inhoud van veld '. $veld_naam .' bestaat al<br />'; } } } elseif($instelling == 'email') { // Controleer email if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $velden[$veld_naam])) { $this->fouten .= "- Het email is incorrect.<br />"; } } } } if(!$this->fouten) { // SQL genereren $SQL = "INSERT INTO gebruikers "; $SQL_TMP = ""; foreach($velden as $key=>$value) { $SQL_TMP .= ", ". $key ." = '". mysqli_real_escape_string($this->con, $value) ."' "; } // Eerste komma weghalen $SQL .= "SET ".preg_replace("#^,{0,1}#", '', $SQL_TMP); if($SQL_TMP && mysqli_query($this->con,$SQL)) { header("Location: ../index.php"); } else { $this->fouten = "Er is een MySQL fout opgetreden."; /* om te debuggen gebruik: die(mysqli_error($con)); */ } } } } // Functie om gegevens te controleren private function controleer_gegevens() { // Kijken of we het juiste formulier gebruiken if(isset($_POST['actie']) && $_POST['actie'] == 'login') { // Gegevens van formulier opvragen en escapen tegen mysql injectie $gebruiker = mysqli_real_escape_string($this->con, $_POST['gebruikersnaam']); $wachtwoord = mysqli_real_escape_string($this->con, $_POST['wachtwoord']); // Kijken of we MD5 moeten gebruiken (zie configuratie bestand) if(login_password_md5===true) { $wachtwoord = md5($wachtwoord); } // Kijken of de gegevens correct zijn $query = mysqli_query($this->con,"SELECT * FROM gebruikers WHERE gebruikersnaam = '". $gebruiker ."' AND wachtwoord = '". $wachtwoord ."'"); if(mysqli_num_rows($query)) { // Array gebruikersinfo maken $this->gebruikersinfo = array(); $this->gebruikersinfo['info'] = mysqli_fetch_array($query); // Start sessie return $this->start_session(); } else { // Kijken wat er mis ging: if(mysqli_error($this->con)) { $this->fouten = "Er is een mysql fout opgetreden."; } else { $this->fouten = "Gebruiksnaam en/of wachtwoord is incorrect."; } } } } // Functie om de sessie te controlleren private function check_session() { // Controleren op cookie if($this->recheck>=3) { $this->fouten = "Er is een ongeldige cookie sleutel gevonden die niet kon worden verwijderd."; return false; } if(isset($_COOKIE['sid']) && !empty($_COOKIE['sid'])) { // Er is een niet-lege cookie $sid = mysqli_real_escape_string($this->con, $_COOKIE['sid']); // Controleren of sleutel en ip aanwezig zijn in database $query = mysqli_query($this->con,"SELECT * FROM logins WHERE sid = '". $sid ."' AND ip = '". $this->get_ip() ."'") or die("Er is een fout opgetreden."); if(mysqli_num_rows($query)) { $f = mysqli_fetch_array($query); // Gegevens uit database ophalen $query = mysqli_query($this->con,"SELECT * FROM gebruikers WHERE id = '". $f['uid'] ."' "); if(mysqli_num_rows($query)) { $this->loginsessie = true; $this->gebruikersinfo = array(); $this->gebruikersinfo['info'] = mysqli_fetch_array($query); } } } else { // Er is een ongeldige sleutel gevonden, laten we die eens verwijderen $secondes = login_session_time * 3600; setcookie("sid", "", time()-$secondes, "/"); $this->recheck = $this->recheck + 1; } } // De functie om de login sessie te starten private function start_session() { // Unieke sleutel maken $this->gebruikersinfo['sleutel'] = md5(rand(0,99999999999).date("dmyhis")); // Informatie invoegen in database $info = $this->gebruikersinfo['info']; $SQL = "INSERT INTO logins "; $SQL .= "SET uid = '". mysqli_real_escape_string($this->con, $info['id']) ."' "; $SQL .= ", sid = '". mysqli_real_escape_string($this->con, $this->gebruikersinfo['sleutel']) ."' "; $SQL .= ", ip = '". mysqli_real_escape_string($this->con, $this->get_ip()) ."' "; $SQL .= ", datum = NOW() "; mysqli_query($this->con,$SQL) or die("Error: kon niet inloggen."); // Secondes maken van uren, zie configuratie bestand $secondes = login_session_time * 3600; setcookie("sid", $this->gebruikersinfo['sleutel'], time()+$secondes, "/"); // Verversing header("Location: ".$_SERVER['REQUEST_URI']); } private function end_session() { // index.php?actie=uitloggen // Verwijder sessie mysqli_query($this->con,"DELETE FROM logins WHERE sid = '". $_COOKIE['sid'] ."' AND ip = '". $this->get_ip() ."'") or die("Er is een fout opgetreden."); // verwijder cookie $secondes = login_session_time * 3600; setcookie("sid", "", time()-$secondes, "/"); // Redirect $url = str_replace("actie=uitloggen", "", $_SERVER['REQUEST_URI']); // haal de actie weg header("Location: ".$url); } // Functie om gegevens op te vragen public function get_login_info($wat=false) { // Is er iets aanwezig? if(!$this->loginsessie || !count($this->gebruikersinfo)) { return false; } else { if($wat==='alles') { return $this->gebruikersinfo['info']; } elseif(isset($this->gebruikersinfo['info'][$wat])) { return $this->gebruikersinfo['info'][$wat]; } else { return true; } } } } // Class starten $login = new login(); $login->database_velden = array( /* Velden waarvan de value in de database komt. Plaats die in de database en formulier. Syntax: veldnaam:instellingen Instellingen scheiden met '|'. Instellingen: 'verplicht': [string] Verplicht veld. 'min=int': [int] Minimum aantal karakters dat is vereist. 'max=int': [int] Maximum aantal karakters dat is vereist. '==veldnaam': [string] waarde van dit veld moet overeenkomen met 'veldnaam'. 'md5': [string] Codeer met md5. MOET als laatste. */ 'gebruikersnaam:verplicht|uniek|min=3|max=15|', 'rank:max=15|', 'email:max=100|email|', 'avatar:max=100|avatar|', 'wachtwoord:verplicht|min=3|max=16|==wachtwoord2|md5|' /* was eerst 'wachtwoord:verplicht|min=3|max=16|==wachtwoord2'*/ ); $login->init(); ?> Error: Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 157 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 157 Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 158 Warning: mysqli_real_escape_string() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 158 Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 166 Warning: mysqli_query() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 166 Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\xampp\htdocs\Admin\header.php on line 167 Notice: Undefined property: login::$con in C:\xampp\htdocs\Admin\header.php on line 176 Warning: mysqli_error() expects parameter 1 to be mysqli, null given in C:\xampp\htdocs\Admin\header.php on line 176
  4. BACKGROUND: While implementing Peppe Occhi's CRON Scheduler I have come across several lines of code that I am not entirely familiar. In particular I am concerned with the following: $scheduler->php('script.php')->hourly(); found under the heading Schedules execution time. It appears to be of this format $some_instance->some_methodA(arguments)->method_B(arguments); QUESTION: Is the above expression equivalent to the following: $some_instance->some_methodA(arguments); $some_instance->method_B(arguments); In other words, the following is correct: $scheduler->php( 'path_to_folder/script.php', 'path_to_php_version/ea-php72', ['-c' => 'ignore','--merge' => null,], 'file_name' ); $scheduler->hourly(); Please advise. Roddy
  5. Hi everyone, is it possible to collect data such as checkbox and radio inside iframe when push button outside of iframe? or require to method of post inside iframe?
  6. Hi everyone, I'm trying to create the look like "paginate data page", but it is not. I set up the file to insert in website by iframe, but I need to find a way to make clicked data like click the checkbox, then click on next, go to next file in iframe, then come back, stay checked in checkbox. Do you understand what I mean? I'm not fluent in English, my prime is American Sign Language.
  7. BACKGROUND: I am creating a custom class for use with PHPMailer that will hopefully eliminate redundancy in its application and even facilitate my use of the class. One of my questions deals with inheritance and the other has to do with scope. My current use of PHPMailer is quite simple. It consists of a folder containing four files: three of these are PHP class definitions and one of them is an autoloader. PHPMailer is called in the following manner: require_once '../../../PHPMailerAutoload.php'; $mail = new PHPMailer; Once the instance $mail has been created I have access to a large number of public functions that I have thought to consolidate into a single class of my own making called PHPGlobalMailer. My construction of this class appears awkward, and I would like to solicit your feedback in an attempt to remove its clumsiness. class PHPGlobalMailer { private $mail; private static $char_set = 'UTF-8'; private static $smtp_debug = 0; // SMTP::DEBUG_OFF (0): Disable debugging (default). // SMTP::DEBUG_CLIENT (1): Output messages sent by the client. // SMTP::DEBUG_SERVER (2): as 1, plus responses received from the server. // SMTP::DEBUG_CONNECTION (3): as 2, plus more information about the initial connection (used to diagnose STARTTLS failures. // SMTP::DEBUG_LOWLEVEL (4): as 3 (Verbose). private static $debug_output = 'html'; // 'echo': Plain text output (default). // 'html': Browser output. // 'error_log': Output to php.ini configured error.log. // function($str, $level) {echo "Debug Level: " . $level; "Error Message: " . $str;} private static $hostserver = '...'; private static $server_port = ...; private static $smpt_auth = 'true'; private static $mail_account_name = '...'; private static $mail_account_password = '...'; private static $from_mail_address = '...'; private static $from_mail_name = '...'; private static $reply_to_address = '...'; private static $reply_to_name = '...'; public $email = ''; public $name = ''; public $subject = ''; public $html_message = ''; public $alt_message = ''; public function __construct($email, $name, $subject, $html_message, $alt_message) { if ($this->mail new PHPMailer) { $this->mail->CharSet=self::$char_set; $this->mail->isSMPT(); $this->mail->SMTPDebug = self::$smpt_debug; $this->mail->Debugoutput = self::$debug_output; $this->mail->Host = self::$hostserver; $this->mail->Port = self::$server_port; $this->mail->SMPTAuth = self::$smpt_auth; $this->mail->Username = self::$mail_account_name; $this->mail->Password = self::$mail_account_password; $this->mail->setFrom(self::$from_mail_address, self::$from_mail_name); $this->mail->addReplyTo(self::$reply_to_address, self::$reply_to_name); $this->mail->addAddress($this->email, $this->name); $this->mail->Subject = $this->subject; $this->mail->msgHTML($html_message); $this->mail->altBody = $alt_message; } else { echo "Error: Failure to create new PHPMailer instance."; } } public function get_character_set() { return self::$char_set; } public function set_character_set($char_set) { self::$char_set = $char_set; } public function get_smtp_debug() { return self::$smtp_debug; } public function set_password($smtp_debug) { self::$smtp_debug = $smtp_debug; } public function get_debug_format() { return self::$debug_output; } public function set_debug_format($debug_output) { self::$debug_output = $debug_output; } public function get_debug_format() { return self::$debug_output; } public function set_debug_format($debug_output) { self::$debug_output = $debug_output; } public function get_mail_instance() { return $this->mail; } } The AWKWARDNESS 1) In order to make it work I must include PHPMailerAutoload.php file. Is there someway that I could avoid this, say through inheritance? 2) Notice that I am creating an instance of PHPMailer inside my class and then using the instance's public functions to modify it. Is this proper? If not, what would be a more appropriate way of constructing my class. 3) I am concerned that adjustments to an instance of PHPGlobalMailer will affect other instances created in a similar manner. For example, were I to change the value of $smpt_debug for a particular instance of PHPGlobalMailer would it not effect the value of that same parameter for other instances of PHPGlobalMailer? In effect, I would like full control of each instance, but still maintain constancy with regard to the $account_name and $account_password and other values across all instances. Could you please comment on each of three points. Roddy
  8. Hi everyone, I am running into an issue when I am sending out emails using the mail() function. What I am trying to do is on one page, there is a text area that enters information into a form and sends it to another php to process. Here is the form: <form method='POST' action='../home/contact-send-email.inc.php'> <div class='input_form'> <input type='hidden' name='cid' value='".$rowcon['cid']."'><br> <input type='hidden' name='from' value='".$_SESSION['email']."'><br> <input type='hidden' name='email' value='".$rowcon['email']."'><br> <input type='text' name='subject' placeholder='Subject'><br> <textarea style='width: 103.5%; height: 500px; resize: none;' type='text' name='message' placeholder='Message'></textarea><br> <button type='submit'>Send Mail</button> </div> </form> Now with the text area, I want it to allow line breaks. The issue I am running into now is that when I send email out, I am getting the text but were I put the line breaks, there is a \r\n in text. Here is the mail process php: <?php include '../inc/dbh.php'; $from = mysqli_real_escape_string($conn, $_POST['from']); $msg = mysqli_real_escape_string($conn, $_POST['message']); $to = mysqli_real_escape_string($conn, $_POST['email']); $subject = mysqli_real_escape_string($conn, $_POST['subject']); $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type:text/html; charset=UTF-8\r\n"; $headers .= "From: ".$from."\r\n"; $headers .= "X-Mailer: PHP 5.x\r\n"; $txt = nl2br($msg); mail($to, $subject, $txt, $headers); ?> So quick over view: When I send an email out using this code and there are line breaks in there, where the line breaks are happening, in the email there is \r\n instead of the line break.
  9. BACKGROUND: Recently I had occasion to make a search on my own website using the Newsletter search engine. What I discovered was the most bizarre of behaviors. I could perform one search in Japanese and then no more. In other languages such as French, German, and English I could perform as many searches as I liked -- even repeating the same words more than once -- and I always I was able to produce the expected result. Mind you, this bizarre one-find-stop--all-further-finds behavior in the Japanese language was not the case when I first installed my search engines. Now, I have checked my PHP error.log file and found nothing related to this problem. I have also checked that the parameter value of the AJAX call is being properly passed; here too there is no unusual behavior. This bizarre behavior was not always the case. It appears to have begun taking place all of its own. Any ideas? Roddy
  10. BACKGROUND: While I continue to struggle with my wget problem, I would like to reaffirm a discussion that we had already two or three months ago about the use of hash marks in an HTTP Request query string. Please consider the following HTTP Request copied from a Matomo API request generated by Matomo. I only initiated the request, I did not create it. https://www.nudge.online/_utilities/php/matomo/index.php ?module=CoreHome &action=index &idSite=1 &period=day &date=yesterday #?idSite=1 &period=day &date=yesterday &category=General_Actions &subcategory=Actions_SubmenuSitesearch Is it not likely that the above request is one request riding piggy-back on another that upon arrival get split and are made into two separate requests? If my interpretation is indeed accurate, then why make the initial request at all, as it appears to add no new information. Why not just write and send the following: https://www.nudge.online/_utilities/php/matomo/index.php ?module=CoreHome &action=index &idSite=1 &period=day &date=yesterday &category=General_Actions &subcategory=Actions_SubmenuSitesearch Any ideas? Roddy ps: I know it seems silly to have to post these questions at W3Schools, but this reflects the desert of support that Matomo offers while making its software free to the general public. Although it is surely true that beggars should not be choosers, how can one possibly expect to promote one's software without providing even the most minimal support needed to make it work!
  11. BACKGROUND: Having upgraded my server I now have full command of the UNIX terminal. Although a good thing, my first attempt to make use of it has failed. The following code was used to access the Matomo application which resides on the same Lunarpages VPS server as the PHP routine that calls it -- albeit from a different domain name. The CODE: <?php ini_set('log_errors', 1); ini_set('error_log', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'error.log'); ini_set('html_errors', 0); ini_set('display_errors', 0); error_reporting(E_ALL); exec('wget --http-user=[...] --http-password=[...] -P /tmp/ -p -k https://.../index.php?module=Widgetize&action=iframe&containerId=GoalsOverview&widget=1&moduleToWidgetize=CoreHome&actionToWidgetize=renderWidgetContainer&idSite=1&period=day&date=yesterday&disableLink=1&widget=1&token_auth=[...]'); ?> When I examine the Response panel in the Network Menu of Firefox, nothing appears. This said PHP does not complain and the Headers panel returns an HTTP Request code of 200. When I run the same wget command in terminal I am able to generate an HTML file, but the contents tells me that the Matomo API responsible for generating the desired widget is not accessible. The error message reads, Any suggestions? Roddy
  12. I want to create a customized birthday greeting for my members once they log in. Requirements: If they log in +/- 7 days from their birthday, show custom greeting in a pop up box only once. - so if they log in every day they only see the greeting once... Show the greeting on their birthday (again or new custom message) if they log in ON their birthday. If they don't log in on their birthday or the +/- 7 days, show a Sorry we missed you, birthday greeting the next time they log in. I can handle the logic part of this, i.e. BDate +/- 7, etc. I just don't know how to keep track of the log ins. I tried searching on the web but I kept getting results specific to development platforms, like WordPress or Wix. I want to write my own code. I assume it should be handled with a counter? on the log in. Or do I create a new line in the membership table for this log in? Can someone point me to some documentation or an example? I don't mind researching it.
  13. Greetings to all the users and administrators of w3scools invisionzone forum. I would love to get some constructive criticism on this web development tutorial site namely webtrickshome. It's been around for slightly more than a year but I redesigned it recently. Any feedback regarding the design and contents would be highly appreciated. Thankyou
  14. Hello everyone, I am running into an issue now to where I am trying to get information from a database but it is only happening when there is an apostrophe in the text. Meaning things, getting the data from the database, there is a word with an apostrophe in it. I get all the information from the start up to the point where the apostrophe is at. For example: The cat can't jump over water. What I will get is this: The can can Then I don't get the rest of my data. Here is the code I am dealing with. Any help would be great. $id = $_POST['id']; $title = $_POST['title']; $writer = $_POST['writer']; $description = $_POST['description']; $date_created = $_POST['date_created']; $message = $_POST['message']; echo "By: ".$writer; echo "Title: ".$title; echo "Description: ".$description; echo "Message: ".nl2br($message);
  15. Hi everyone, I am still learning changing PHP by mysqli to PDO. I'm not get used with PDO because it is little complex to understand, but maybe few weeks I will understand how PDO works. Now, I am trying to make redirect with type account in website and database. I am trying to identify type of three - administrator, license, and scorer page. I set up the test to make it work, seem it went dead end, it won't go to admin or license or scorer page. What did I do wrong? maybe something is missing. here my code: <?php /** * Created by PhpStorm. * User: Gary.Taylor * Date: 7/5/2018 * Time: 10:10 PM */ session_start(); require('access.php'); if(isset($_POST['submitted'])) { $username = $_POST['username']; $password = $_POST['password']; if($username && $password) { $login = $GaryDB->prepare("select username, password, Administrator from account Where username = '.$username.' and password = '.$password.' and Administrator = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:admin.php'); } } elseif ($username && $password) { $login = $GaryDB->prepare("select username, password, License from account Where username = '.$username.' and password = '.$password.' and License = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:license.php'); } } elseif ($username && $password) { $login = $GaryDB->prepare("select username, password, Scorer from account Where username = '.$username.' and password = '.$password.' and Scorer = X"); $login->execute(); $count = $login->fetch(); if($count == 1) { $_SESSION['username'] = $username; header('location:scorer.php'); } } else{ header('location:denied.html'); } }
  16. OBJECTIVE: Suppress my site's splash panel for repeat visitors using a mechanism similar to the one that I use to suppress the panel for visitors whose viewports are too small to handle it properly. BACKGROUND: As I have instructed Matomo not to recognize me when I access the application I have no way of testing whether my code is working. According to a friend who has experimented with his own computer it does not. Although I am able to retrieve the cookie set by Matomo, I am now uncertain about how to handle it. NOTE: The cookie that Matomo appears to set is not set until the page has The COOKIE Sent by Matomo Array ( [_pk_id_1_28d8] => b1dccabc0123a611.1529214805.24.1530731060.1530731060. [_pk_ses_1_28d8] => * ) The PHP that Recovers the COOKIE and Assigns It to a Javascript Variable if (isset($_COOKIE['_pk_id_1_28d8'])) { $cookie_set = 1; } The JAVASCRIPT on the Same Page as the PHP var cookie_set = <?php echo $cookie_set;?>; The JAVASCRIPT on a Loaded Script Page that Controls the Splash Panel if ((!refer_type && !navtype && (viewportWidth > 360)) || !cookie_set) { [the code that sets the splash panel] } QUESTION: Can you see anything in the above logic or design that could be showing the splash panel when it is not desired? Roddy
  17. REQUEST: Please compare the following PHP code with the intended result, and if possible, say why only the last urls[ ] parameter is being read. BACKGROUND: The following code is part of a successfully received and partially processed HTTP POST Bulk Request to the Matomo application. Both of the called methods -- namely, Events.getCategory and Events.getAction -- have been tested separately and are perfectly functional. Further, the Matomo application reports no dysfunction, and there are no warning, notices or other indicated sources of foul coding in the PHP log file. $result = ''; $query_str = ''; $i = 0; $token_auth = '...'; function set_url_request($method, $params) { $request = "method=$method"; foreach ($params as $param) { $request .= "&" . $param; } return rawurlencode($request); } $url = "https:/.../index.php"; $url .= "?module=API"; $url .= "&method=API.getBulkRequest"; $url .= "&format=json"; $url .= "&token_auth=$token_auth"; foreach ($_POST['methodName'] as $method) { $method = filter_var($method, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH); if ($method == '_getCategory') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","format=json"); $query_str = set_url_request($method, $params); $url .= "&urls[$i++]=" . $query_str; } if ($method == '_getAction') { $method = "Events." . substr($method, 1); $params = array("idSite=1","period=year","date=today","format=json"); $query_str = set_url_request($method, $params); $url .= "&urls[$i++]=" . $query_str; } } The above is suppose to yield code formatted in a manner similar to the following HTTP request. Obviously, I have modified it in important ways, Important, however, is that the &urls[0] request appears to be ignored. https://demo.piwik.org/index.php ?module=API &method=API.getBulkRequest &format=json &urls[0]= method%3dVisitsSummary.get %26idSite%3d3 %26date%3d2012-03-06 %26period%3dday &urls[1]= method%3dVisitorInterest.getNumberOfVisitsPerVisitDuration %26idSite%3d3 %26date%3d2012-03-06 %26period%3dday Roddy
  18. Hey guys, EDIT: I have been looking on the web to find a way to automatically download a pdf when a page opens, without user having to click a link. However, no solution found (at least which i can get to work...) Help is much appreciated!! Thanks guys!
  19. Hello, I am currently in the middle of creating a web comic aggregation website. So far, I have written a PHP-based RSS reader that grabs the image source links and publication dates for various web comics from their RSS feeds, and uses this to update a MySQL database. This RSS reader/database updater is configured to run once every several hours and update the database with any new comics it finds. It seems to be working fine, and now I am starting to work on the front end of the website, which needs to grab this information from the ever-growing database, and display it in a user-friendly and interactive format. I wrote the database updater in a fairly procedural way, because it didn't strike me as something that lent itself very much to object-oriented development. However, the front end of the website does strike me as something that I can save myself a lot of time on by coming up with a decent object oriented design first. Unfortunately, I don't have a lot of experience in this, so I thought I would look online for suggestions. So far, I have decided specifically what I would like the front end to do, and have come up with 2 possible approaches to designing it, but am unsure about both. Here's what I would like it to do: (To clarify, when I say the phrase "comic strip," I'm referring to a whole strip like XKCD, Dilbert, the far side, etc., and when I say the phrase "comic," it refers to an individual comic within a comic strip, i.e. the Dilbert comic for 8/30/2016). I would like my webpage, by default, to display a vertically stacked list of the latest comic images from each comic strip in the database. For customization, I want a comic strip control panel, which allows users to decide which comic strips are enabled/disabled, and in what order they are displayed. I would like each comic image to appear between text denoting the name/author of the strip and an individual set of buttons that allows the user to go forward and backward through the archived comics, and also to adjust the size/scaling of the image. Finally, I would like a similar but generalized set of buttons that allows the user to control all the comic strips in the same fashion, but at once. Based on my basic understanding of object oriented programming, and the design approach suggested in this stack overflow answer: http://stackoverflow.com/questions/1100819/how-do-you-design-object-oriented-projects, I came up with one possible design: Two classes: 1) a comic strip class that contains attributes like the comic strip's name, ID number (from my database), enabled/disabled status, and current comic to display (an object of the next class), in addition to functions to get and set each of these variables, 2) a comic class that contains attributes like the image source link, publication date, and scaling percentage, in addition to functions to get and set each of these variables Then the main webpage would contain a comic strip control panel and general comic control panel as described in the desired functionality. In addition, it would contain an array of individual comic control panels, and an array of div tags (or a similar tag), which would be displayed vertically stacked and alternating along with the comic strip names in plain text. Finally, there would be functions for updating comic and comic strip object information from the database, and functions for updating the div tag content for comic display based on the comic object information. All the functions would be called using JavaScript/Ajax from the appropriate buttons. However, I was unsure about this design, so I asked a friend, who suggested that I use a model-view-controller design pattern, which I guess is popular in web development because its potential for separating all the various languages. After reading about this online, I have come up with a possible alternative design: Model: PHP, an array of comic strips, including name and ID number, active/inactive status, and current comic image URL/publishing date View: PHP generated HTML/CSS, as described before, a comic strip control panel for enabling/disabling and ordering, a vertically stacked list of comic strip names, constituent comic images, and individual control buttons, and a general set of buttons for controlling all enabled comics at once Controller: PHP/MySQL, a function to update order and active/inactive comic strip status, a function to update a given comic strip's current comic information, and a function to update all comic strips' current comic information at once As I understand it, the controller functions would be called upon user input into the view (clicking the buttons), which would then update the information stored in the model, and then somehow that would trigger a refresh of the view based on the new model information. I am worried I may have missed something in each of these designs (especially the first one), and unsure about the potential merits of one versus another. I was also wondering if it might be possible to combine the two somehow. Does anyone have any suggestions? Help would be much appreciated
  20. Hello, Please help, how to implement the Depth First Search algorithm into PHP MyQsli. I have a table: - problem - because - solution The DFS diagram I attached. thank you
  21. Hi everyone, I will like to know how to have table under master table. Is it relationship? or how you do that? Thanks, Gary
  22. NATURE: This is part of a steadfast effort to hack through the thicket of PHP classes and namespaces of which the Matomo application consists. It is not an endeavor for the weak or timid, as the thicket is formidable and the documentation obscure. BACKGROUND: In order to submit a proper report request to the Matomo application the values of certain variables must be known. Although there are generators within the application that have been created to achieve this task, they are not easily accessible, as the thicket is, well, thick. Please find below both the file and code that produces the error message provided. The FILE: <?php /** * Piwik - free/libre analytics platform * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * * @package Piwik */ use Piwik\ErrorHandler; use Piwik\ExceptionHandler; use Piwik\FrontController; if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { ErrorHandler::registerErrorHandler(); ExceptionHandler::setUp(); } FrontController::setUpSafeMode(); if (!defined('PIWIK_ENABLE_DISPATCH')) { define('PIWIK_ENABLE_DISPATCH', true); } if (PIWIK_ENABLE_DISPATCH) { $environment = new \Piwik\Application\Environment(null); $environment->init(); $controller = FrontController::getInstance(); try { $controller->init(); $response = $controller->dispatch(); if (!is_null($response)) { echo $response; } } catch (Exception $ex) { ExceptionHandler::dieWithHtmlErrorPage($ex); } } The CODE: require_once ('../../../../nudge.online/_utilities/php/matomo/core/dispatch.php'); The ERROR MESSAGE: LINE 16 ErrorHandler::registerErrorHandler(); Now, including the file ErrorHandler.php does not help. Neither does a call to the static function registerErrorHandler() appear to make a difference. Piwik\ErrorHandler::registerErrorHandler(); For the response is always the same Any ideas? Roddy
  23. BACKGROUND: I would like to embed a Matomo widget into a page, but I dare not embed it directly. For, to do so would require that I expose the authorization token that enables knowledgeable visitors of Matomo -- and coding in general -- the ability to view everything about my website that I am able to view. As I, myself, do not yet know what to do with everything that Matomo makes available (it appears endless), I certainly do not want to put it all into the hands of others willy-nilly. It is simply bad business. OBJECTIVE: Read the data into a PHP file, and load the result into the src attribute of an iframe. Below is sample code taken directly from the Matomo website. (The absence of the authorization token assumes that the superuser has given access to all users the right to view whatever they like. I do not wish to grant this privilege). SIMPLE URL https://www.nudge.online/_utilities/php/matomo/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=Live&actionToWidgetize=getSimpleLastVisitCount&idSite=1&period=day&date=yesterday&disableLink=1&widget=1 EMBEDDING CODE <div id="widgetIframe"><iframe width="100%" height="350" src="https://www.nudge.online/_utilities/php/matomo/index.php?module=Widgetize&action=iframe&widget=1&moduleToWidgetize=Live&actionToWidgetize=getSimpleLastVisitCount&idSite=1&period=day&date=yesterday&disableLink=1&widget=1" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div> Obviously, there is no difference in the URLs. QUESTION: If an image can be created by a PHP file and then read into the src attribute of an image tag, surely it must then also be possible to read the HTML content of a PHP file into the src attribute of an iFrame. What is the necessary header argument required? I have tried both " header('Content-Type: text/html'); and header('Content-Type: text/plain'); Neither works! Or, am I just guessing. And, what I am trying to do simply does not work. Roddy
  24. I would like to share with you a message that I posted on the Matomo forum for which I am not expecting a satisfactory reply. I suspect that Matomo will be unwilling to entertain the idea for fear of opening a Pandora's box of insecurity for casual users and thereby endangering its reputation as a secure web utility. Matomo's fear need not be my own, however, with the proper guidance. BACKGROUND: After several weeks of enormous frustration I was finally able to access the Matomo web application directly with PHP. I was able to achieve this somewhat (for me) monumental task by renaming the .htaccess file (see below) in the /matomo/config folder and thus canceling its prohibitive effect. Obviously, this file was placed in the /matomo/config folder as a matter of security -- security, mind you, that I do not wish to compromise. This said, an unending series of HTTP requests uses up an enormous number of resources, and I wish to share the data that I collect about my users with my users via my own custom-built PHP files for which I require direct communication with the Matomo application. (I have no desire to play the governmental game of protect-and-deceive -- read GDPR or NSA). So, I explored the internet and found alternative contents <https://www.slicewise.net/php/piwik-absichern/> to the current .htaccess file in use by Matomo as of 3.5.1. REQUEST: Would anyone like to comment on the merging of these two files (see below) into a workable arrangement that would give me the superuser direct access to the Matomo web-application via PHP, but deny access to everyone else except through those channels already set in place by Matomo for anonymous users and opt-in/out visitors. PROPOSED FILE <Files "*"> AuthUserFile /path/to/piwik.htpasswd AuthName Piwik-Password AuthType Basic <RequireAny> Require valid-user Require ip 127.0.0.1 <your-server-ip> #needed for some scripts </RequireAny> </Files> <Files ~ "^piwik\.(js|php)|robots\.txt|idxsec\.php|favicon\.ico$"> Require all granted </Files> CURRENT FILE <Files "*"> <IfModule mod_version.c> <IfVersion < 2.4> Order Deny,Allow Deny from All </IfVersion> <IfVersion >= 2.4> Require all denied </IfVersion> </IfModule> <IfModule !mod_version.c> <IfModule !mod_authz_core.c> Order Deny,Allow Deny from All </IfModule> <IfModule mod_authz_core.c> Require all denied </IfModule> </IfModule> </Files> My goal is to give my visitors an important glimpse into the reality of data collection and analysis. I now know that I am able to do this my eliminating the .htaccess file. Elimination of the file is, however, not my goal. Roddy
  25. BACKGROUND: I have now tried a number of ways to make two cURL calls within the same Javascript (jQuery) routine. For each new way, I have discovered what I believe to be a reasonable explanation for my failure. For my most recent attempt, however, a good explanation is not forthcoming. To be sure, single AJAX calls with a single cURL call for each yield the desired results. Simply I cannot seem to combine these results simultaneously on the same page. The scenario given below, for example, returns the desired outcome for the second cURL call, but not the first. JAVASCRIPT: $.ajax({ url: '.../VisitsSummary.php', method: 'GET', data: {methodName : '_get', methodName : '_getSumVisitsLengthPretty'}, dataType: 'JSON', statusCode: { 404: function() { alert( "Page not found" ); }}, success: function(visitsSummary_data) { console.log(visitsSummary_data); var tv = visitsSummary_data.nb_visits; var uv = visitsSummary_data.nb_uniq_visitors; var visits_per_unique_visitor = Math.round(tv/uv * 10)/10; $('#so_total_visits').html(visitsSummary_data.nb_visits); $('#so_unique_visitors').html(visitsSummary_data.nb_uniq_visitors); $('#visits_per_visitor').html(visits_per_unique_visitor); $('#so_average_time_spent').html(visitsSummary_data.avg_time_on_site); } }); PHP: if (isset($_GET['methodName'])) { $method_name = $_GET['methodName']; if ($_GET['methodName'] == '_get') { $url = 'https://.../index.php?module=API&action=index&method=VisitsSummary.get&idSite=1&period=year&date=today&format=json&token_auth=&token_auth=...'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, false); curl_exec($curl_request); if(curl_errno($curl_request)) { echo 'Curl error: ' . curl_error($curl_request); } curl_close($curl_request); } if ($_GET['methodName'] == '_getSumVisitsLengthPretty') { $url = 'https://.../index.php?module=API&action=index&method=VisitsSummary.getSumVisitsLengthPretty&idSite=1&period=year&date=today&format=json&token_auth=&token_auth=...'; $curl_request = curl_init(); curl_setopt($curl_request, CURLOPT_URL, $url); curl_setopt($curl_request, CURLOPT_RETURNTRANSFER, false); curl_exec($curl_request); if(curl_errno($curl_request)) { echo 'Curl error: ' . curl_error($curl_request); } curl_close($curl_request); } } QUESTION: Can you find anything wrong with the above strategy? If so, what would you recommend to replace it? Roddy
×
×
  • Create New...