Jump to content

terungwa

Members
  • Content Count

    90
  • Joined

  • Last visited

Posts posted by terungwa

  1. I have Set Up a Remote Database to Optimize wordpress Site Performance with MySQL on Ubuntu 16.04. I downloaded the wordpress onto my web server. When I Navigate to the public IP address associated with my web server, i get "Error establishing a database connection".

    With wordpressdebug mode set to true, the details of the error is:

     

    Warning: mysqli_real_connect(): (HY000/3159): Connections using insecure
    transport are prohibited
    while --require_secure_transport=ON. in /var/www
    /html/wp-includes/wp-db.php on line 1538

     

    I have tested remote connection using the remote user and I am able to connect. This means my database server is running and my remote user credentials are also correct.

    What may be causing this and how can I resolve this?

     

  2. I have created a phone number as Buddypress Profile field. I need to check that no two or more user accounts share the same phone number. My query below is not enforcing the restriction.

    I need help to resolve this.

    function bp_phone_number_validate() {
    global $bp;
    global $wpdb;
    
    // check if phone number is in use
    $result=$bp->get_var("SELECT COUNT(*) FROM {$bp->profile->wp_bp_xprofile_data} WHERE value = '{$_POST['field_2']}' GROUP BY id;");
    
    if($result > 0){
    $bp->signup->errors['field_2'] = __( 'Phone number is already in use.', 'buddypress' );
    }
    }
    add_action( 'bp_signup_validate', 'bp_phone_number_validate');
    

     

  3. I have used this tutorial here (https://codex.wordpress.org/Integrating_WordPress_with_Your_Website) as a guide to set up non-wordpress pages to access some wordpress resources on non-wordpress pages. Eg I can view wordpress posts on non-wordpress page. I have wordpress installed in a sub-folder(

    ./root - PHP pages

    ./root/wordpres - Wordpress installation}

     

    In addition, I need to be able to detect if a user is logged into wordpress on the non-wordpress page. I am using this code below on non-wordpress pages for that:

    if(is_user_logged_in()){
    $current_user = wp_get_current_user();
    /**
     * @example Safe usage: $current_user = wp_get_current_user();
     * if ( !($current_user instanceof WP_User) )
     *     return;
     */
    echo 'Username: ' . $current_user->user_login . '<br />';
    echo 'User email: ' . $current_user->user_email . '<br />';
    echo 'User first name: ' . $current_user->user_firstname . '<br />';
    echo 'User last name: ' . $current_user->user_lastname . '<br />';
    echo 'User display name: ' . $current_user->display_name . '<br />';
    echo 'User ID: ' . $current_user->ID . '<br />';
    echo get_avatar( $current_user->user_email, 32 ). '<br />';
    echo '<hr />';  
    
    }
    else{
     echo 'Not logged-in';
    }
    

    Even though I am logged into wordpress, when I navigate to the non-wordpress page, I see wordpress posts listed but, the is_user_logged_in() function returns false and prints 'Not logged-in'!!!

     

    Is there a way of achieving this besides the approach I have adopted?

    I need guidance to resolve this.

  4. I am trying to install WAMP on a 64bit Computer with windows version 8.1 installed.

    I have downloaded the WAMP version for a 64bit system. Following installation, This "httpd.exe-System Error pops up "The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem".

     

    Fixing the problem above requires installation of the Visual C++ Redistributable for Visual Studio 2015 update 3. I have also installed other recommended runtime libraries.

     

    I have downloaded this runtime library (Visual C++ Redistributable for Visual Studio 2015 update 3) from microsoft website but the runtime library installation keeps failing (Setup Failed error). I have pasted below details of the log file for review as well.

    [129C:2760][2016-10-03T09:07:12]i001: Burn v3.7.3813.0, Windows v6.3 (Build 9600: Service Pack 0), path: C:\ProgramData\Package Cache\{e46eca4f-393b-40df-9f49-076faf788d83}\VC_redist.x64.exe, cmdline: '/uninstall -burn.unelevated BurnPipe.{40571A66-B687-451B-A73F-AB3C54C08E62} {63634010-28A6-4D8E-84CD-A74B4B69E29C} 10004'
    [129C:2760][2016-10-03T09:07:12]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\BEMAST~1\AppData\Local\Temp\dd_vcredist_amd64_20161003090712.log'
    [129C:2760][2016-10-03T09:07:13]i100: Detect begin, 10 packages
    [129C:2760][2016-10-03T09:07:13]i000: File search: windows_uCRT_DetectKey, did not find path: C:\Windows\system32\api-ms-win-crt-runtime-l1-1-0.dll
    [129C:2760][2016-10-03T09:07:13]i000: File search: windows_uCRT_DetectKeyExists, did not find path: C:\Windows\system32\api-ms-win-crt-runtime-l1-1-0.dll
    [129C:2760][2016-10-03T09:07:13]i000: Setting numeric variable 'windows_uCRT_DetectKeyExists' to value 0
    [129C:2760][2016-10-03T09:07:13]i102: Detected related bundle: {3ee5e5bb-b7cc-4556-8861-a00a82977d6c}, type: Upgrade, scope: PerMachine, version: 14.0.23506.0, operation: None
    [129C:2760][2016-10-03T09:07:13]i102: Detected related bundle: {d992c12e-cab2-426f-bde3-fb8c53950b0d}, type: Upgrade, scope: PerMachine, version: 14.0.24215.1, operation: None
    [129C:2760][2016-10-03T09:07:13]i108: Detected compatible package: vcRuntimeMinimum_x64, provider: Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v14, installed: {50A2BC33-C9CD-3BF1-A8FF-53C10A0B183C}, version: 14.0.24215, chained: {0D3E9E15-DE7A-300B-96F1-B4AF12B96488}
    [129C:2760][2016-10-03T09:07:13]i103: Detected related package: {50A2BC33-C9CD-3BF1-A8FF-53C10A0B183C}, scope: PerMachine, version: 14.0.24215.0, language: 0 operation: Downgrade
    [129C:2760][2016-10-03T09:07:13]i108: Detected compatible package: vcRuntimeAdditional_x64, provider: Microsoft.VS.VC_RuntimeAdditionalVSU_amd64,v14, installed: {EF1EC6A9-17DE-3DA9-B040-686A1E8A8B04}, version: 14.0.24215, chained: {BC958BD2-5DAC-3862-BB1A-C1BE0790438D}
    [129C:2760][2016-10-03T09:07:13]i103: Detected related package: {EF1EC6A9-17DE-3DA9-B040-686A1E8A8B04}, scope: PerMachine, version: 14.0.24215.0, language: 0 operation: Downgrade
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i052: Condition '(windows_uCRT_DetectKeyExists AND windows_uCRT_DetectKey >= v10.0.10137.0)' evaluates to false.
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: vcRuntimeMinimum_x64, state: Obsolete, cached: Complete
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: vcRuntimeAdditional_x64, state: Obsolete, cached: Complete
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: Windows81_x86, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: Windows81_x64, state: Absent, cached: Complete
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: Windows8_x86, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: Windows8_x64, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: Windows7_MSU_x86, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: Windows7_MSU_x64, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: WindowsVista_MSU_x86, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i101: Detected package: WindowsVista_MSU_x64, state: Absent, cached: None
    [129C:2760][2016-10-03T09:07:13]i052: Condition 'VersionNT64 >= v6.0 OR (VersionNT64 = v5.2 AND ServicePackLevel >= 1)' evaluates to true.
    [129C:2760][2016-10-03T09:07:13]i199: Detect complete, result: 0x0
    [129C:2760][2016-10-03T09:07:14]i200: Plan begin, 10 packages, action: Repair
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.3 AND NOT VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: Windows81_x86
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.3 AND VersionNT64' evaluates to true.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: Windows81_x64
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.2 AND NOT VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: Windows8_x86
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.2 AND VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: Windows8_x64
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.1 AND NOT VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: Windows7_MSU_x86
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.1 AND VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: Windows7_MSU_x64
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.0 AND NOT VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: WindowsVista_MSU_x86
    [129C:2760][2016-10-03T09:07:14]i052: Condition 'VersionNT = v6.0 AND VersionNT64' evaluates to false.
    [129C:2760][2016-10-03T09:07:14]w321: Skipping dependency registration on package with no dependency providers: WindowsVista_MSU_x64
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: vcRuntimeMinimum_x64, state: Obsolete, default requested: None, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Register
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: vcRuntimeAdditional_x64, state: Obsolete, default requested: None, ba requested: None, execute: None, rollback: None, cache: No, uncache: No, dependency: Register
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: Windows81_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: Windows81_x64, state: Absent, default requested: Repair, ba requested: Repair, execute: Install, rollback: Uninstall, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: Windows8_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: Windows8_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: Windows7_MSU_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: Windows7_MSU_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: WindowsVista_MSU_x86, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i201: Planned package: WindowsVista_MSU_x64, state: Absent, default requested: Absent, ba requested: Absent, execute: None, rollback: None, cache: No, uncache: No, dependency: None
    [129C:2760][2016-10-03T09:07:14]i207: Planned related bundle: {3ee5e5bb-b7cc-4556-8861-a00a82977d6c}, type: Upgrade, default requested: None, ba requested: None, execute: None, rollback: None, dependency: None
    [129C:2760][2016-10-03T09:07:14]i207: Planned related bundle: {d992c12e-cab2-426f-bde3-fb8c53950b0d}, type: Upgrade, default requested: None, ba requested: None, execute: None, rollback: None, dependency: None
    [129C:2760][2016-10-03T09:07:14]i299: Plan complete, result: 0x0
    [129C:2760][2016-10-03T09:07:14]i300: Apply begin
    [2714:2474][2016-10-03T09:07:15]i360: Creating a system restore point.
    [2714:2474][2016-10-03T09:07:16]i361: Created a system restore point.
    [2714:2474][2016-10-03T09:07:16]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{e46eca4f-393b-40df-9f49-076faf788d83}, resume: Active, restart initiated: No, disable resume: No
    [2714:0330][2016-10-03T09:07:16]i304: Verified existing payload: Windows81_x64 at path: C:\ProgramData\Package Cache\FC6260C33678BB17FB8B88536C476B4015B7C5E9\packages\Patch\x64\Windows8.1-KB2999226-x64.msu.
    [2714:2474][2016-10-03T09:07:16]i325: Registering dependency: {e46eca4f-393b-40df-9f49-076faf788d83} on package provider: Microsoft.VS.VC_RuntimeMinimumVSU_amd64,v14, package: vcRuntimeMinimum_x64
    [2714:2474][2016-10-03T09:07:16]i325: Registering dependency: {e46eca4f-393b-40df-9f49-076faf788d83} on package provider: Microsoft.VS.VC_RuntimeAdditionalVSU_amd64,v14, package: vcRuntimeAdditional_x64
    [2714:2474][2016-10-03T09:07:16]i301: Applying execute package: Windows81_x64, action: Install, path: C:\ProgramData\Package Cache\FC6260C33678BB17FB8B88536C476B4015B7C5E9\packages\Patch\x64\Windows8.1-KB2999226-x64.msu, arguments: '"C:\Windows\SysNative\wusa.exe" "C:\ProgramData\Package Cache\FC6260C33678BB17FB8B88536C476B4015B7C5E9\packages\Patch\x64\Windows8.1-KB2999226-x64.msu" /quiet /norestart'
    [2714:2474][2016-10-03T09:07:20]e000: Error 0x80240017: Failed to execute MSU package.
    [129C:2760][2016-10-03T09:07:20]e000: Error 0x80240017: Failed to configure per-machine MSU package.
    [129C:2760][2016-10-03T09:07:20]i319: Applied execute package: Windows81_x64, result: 0x80240017, restart: None
    [129C:2760][2016-10-03T09:07:20]e000: Error 0x80240017: Failed to execute MSU package.
    [2714:2474][2016-10-03T09:07:20]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{e46eca4f-393b-40df-9f49-076faf788d83}, resume: ARP, restart: None, disable resume: No
    [2714:2474][2016-10-03T09:07:20]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{e46eca4f-393b-40df-9f49-076faf788d83}, resume: ARP, restart initiated: No, disable resume: No
    [129C:2760][2016-10-03T09:07:20]i399: Apply complete, result: 0x80240017, restart: None, ba requested restart:  No
    

    What might I do to fix this problem and successfully install WAMP server?

    . I have attached a screenshot of the error popups for you review.

    post-166929-0-89468900-1475481593_thumb.jpg

    post-166929-0-39741100-1475481598_thumb.jpg

  5. Threads merged and moved to Regex.

     

    terungwa, as Jacques said the regex works in PHP, while you need a pattern that works with Javascript's regular expressions (which is what the "pattern" is). There are big differences between the two.

    (?:\+?234|0)?(?:704|702|803|806|703|706|813|816|810|814|903|802|708|808|812|701|902|809|817|818|909|908|805|705|815|807|811|905)\d{7}
    - \A and \z anchors are not supported - use ^ and $. However the "pattern" is already implicitly anchored so you don't need them.

    - Remove the extra backslashes, which were being used for escaping within PHP strings

     

    Be sure to do the same validation in PHP (with the other regex) because this validation in HTML can by easily bypassed.

     

     

    Threads merged and moved to Regex.

     

    terungwa, as Jacques said the regex works in PHP, while you need a pattern that works with Javascript's regular expressions (which is what the "pattern" is). There are big differences between the two.

    (?:\+?234|0)?(?:704|702|803|806|703|706|813|816|810|814|903|802|708|808|812|701|902|809|817|818|909|908|805|705|815|807|811|905)\d{7}
    - \A and \z anchors are not supported - use ^ and $. However the "pattern" is already implicitly anchored so you don't need them.

    - Remove the extra backslashes, which were being used for escaping within PHP strings

     

    Be sure to do the same validation in PHP (with the other regex) because this validation in HTML can by easily bypassed.

     

    Yea I shall definitely validate server side. The html5 pattern attribute is for user experience improvement on supported browsers

  6. I need to create a pattern attribute that specifies a regular expression for an <input> element's value that accepts mobile phone numbers. Jacques1 provided this PHP regex function which works great. I attempted to use this as a value for the pattern attribute but is is failing to check properly.

     

    Here is the regex code below:

    
    <!DOCTYPE html>
    <html>
    <body>
    
    <form action="demo_form.asp">
      Country code: <input type="text" name="country_code"
     pattern="\\A(?:\\+?234|0)?(?:704|702|803|806|703|706|813|816|810|814|903|802|708|808|812|701|902|809|817|818|909|908|805|705|815|807|811|905)\\d{7}\\z" title="Allowed formats are: 09031111111, 2340801111111, or +2340801111111">
      <input type="submit">
    </form>
    </body>
    </html>
    

     What is the proper format to use as a pattern attribute value. Note a number as this should be valid (2349098766543) but it is failing.

     

    Thanks

  7.  

    The regex syntax is all over the place, and you don't have anchors to prevent matches somewhere in the middle of the input.

    • [+234|234|0] makes no sense. The square brackets denote a list of characters, but you want alternatives: (?:\\+?234|0). Read: Either an optional plus sign followed by 234, or the digit 0.
    • The + character is a meta character in regular expressions and must be escaped.
    • Use the \\A and \\z anchors to match the beginning and end of the input.
    /\\A(?:\\+?234|0)?(?:704|...)\\d{7}\\z/
    

    Thanks Jacques1,

    but Your pattern

    /\\A(?:\\+?234|0)?(?:704|803)\\d{7}\\z/
    

    does not match this subject string (2347048134704); when tested here https://www.regex101.com/

     

    Or am I missing something?

  8. I have a regex expression that validates a set of mobile numbers: The numbers have optional prefixes (+234 or 234 or 0) and I have used the alternation with the pipe character. Immediately following the international code or zero character is a set of service provider specific identifiers that I have also specified the options using the alternation character.

     

    Based on the regex I have, this number should not be valid (12349098766543); but the regex returns it as valid. It appears the there is a match on 909 in the code. But shouldn't the presence of 1 at the beginning of the test string enforce a validation failure? What is wrong with the regex i have here?

    function check_number($number) {
    if(!preg_match('/[+234|234|0]?(704|702|803|806|703|706|813|816|810|814|903|802|708|808|812|701|902|809|817|818|909|908|805|705|815|807|811|905)\d{7}$/', $number)) {
        return 'Invalid Phone Number';
    }else{
        return 'valid Phone Number';}
    

    The execution below should fail, but is is passed as valid.

    $str = '12349098766543';
    echo check_number($str); 
    
  9. I had successfully set up and integrated a third party payment integration system on WHMCS. Inorder to Validate callback authenticity, the gateway provides a method of verifying that a callback originated from them as shown in code below:

    $mertid ='secretmerchantID';
    $amt = '10000';
    $tranxid = 'gtPay130958397220820';
    $hashkey ='secretclientkey';
    
    $hash =  hash('sha512', $mertid . $tranxid . $hashkey);
    
    $url = 'https://ibank.gtbank.com/GTPayService/gettransactionstatus.xml?mertid='.$mertid.'&amount='.$amt.'&tranxid='.$tranxid.'&hash='.$hash;
    
    
    $xmlString = file_get_contents($url);
    if($xmlString === false)
    {
        echo "Response Description: GTPAY Verification service failed to  open. 
    }
    else
    {
        $xml = simplexml_load_string($xmlString );
    
        var_dump($xml);
    } 
    

    I am using the file_get_contents function to read the API response into a string, then simplexml_load_string function to Interprets the string of XML into an object with properties containing the data held within the xml string. On each successful transaction run $xml=simplexml_load_string($jString), returns FALSE.

     

    However when I call this code in a file directly in a browser on WAMP using the same transaction values, then $xml=simplexml_load_string($jString), returns the string of XML into an object as expected. Also when I place the file on a different remote host and call it in browser, it also returns the string of XML into an object.

     

    Strangely, when I place this code in a file within the WHMCS root folder and I attempt to call directly in a browser using the same successful transaction values used above, then $xml=simplexml_load_string($jString), returns FALSE again.

     

    What may be restricting this call to the Third party API call within the WHMCS install?

    Thanks.

  10. I wish to redirect to a custom page following the failure in payment as returned by payment gateway.
    To this end, I am using the ShoppingCartCheckoutCompletePage hook to check this using the variable $vars['ispaid'].
    When payment is successful, $vars['ispaid'] is true and the redirect to the thankyou page works.
     

     
    add_hook('ShoppingCartCheckoutCompletePage', 1, function ($vars)
    {
        # Will be true if the order has been paid
        if($vars['ispaid'] == true)
        {
            #redirect to thank you page
            header('location:'.thankYouPage);
            die;
        }
        else
        {
            header('location:'.transactionFailedPage);
            die;
        }    
    }
    

    However the else statement is not executing when payment obviously fails,
    rather the viewinvoice.php page is loaded and payment status set to 'unpaid'

    Am I missing something?
    How can I redirect to the transaction failed page?
     

     

×
×
  • Create New...

Important Information

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