behnampmdg3

Experience

10,100

0 Best Reply Awards

  • Member Since 4 Years Ago
  • 52 Lessons Completed
  • 2 Favorites

12th July, 2018

behnampmdg3 left a reply on Redirect Iframe's Parent With Window.top.location.href Not Working • 1 week ago

Sorry bobby;

Please check again.

Open network tab in the inspector and see bc.php

behnampmdg3 started a new conversation Redirect Iframe's Parent With Window.top.location.href Not Working • 1 week ago

Hi;

How come redirect iframe parent doesn't work?

window.top.location.href

Direct link: http://pum.wdsmembers.com/bc.html

Fiddle: https://jsfiddle.net/kv51uf7p/

Redirect code is generated in https://timerz.xyz/timer/bc.php

Thanks

30th June, 2018

behnampmdg3 started a new conversation Best Approach To Make Form Widget • 3 weeks ago

Hi;

I want to make a product where my clients can log in, build simple forms (max 5 fields), grab the code for the form and add to their websites. Basically simple form widgets.

In the past, I did it with JS like this

<div id = "countdown_timer" style="" > <script type="text/javascript" src="https://timers.webmoosh.com/timer/bc.php" data-id="1132" data-lt="broadcast"></script></div> 

And this is the JS that loads the iframe


(function(window)
    { 
         
            var currentScript = document.currentScript; 
            var apiUrl = currentScript.src; 

            if (!('jQuery' in window))
                { 
                    loadJQuery(initialize); 
                }
            else 
                { 
                    initialize(); 
                } 
            function loadJQuery(cb)
                { 
                    var script = document.createElement('script'); 
                    script.src = 'https://code.jquery.com/jquery-3.3.1.min.js'; 
                    script.type = 'text/javascript'; 
                    script.addEventListener('load', cb); 
                    document.getElementsByTagName('head')[0].appendChild(script); 
                } 
            function initialize()
                { 
                    //Validate 
                    var $currentScript = $(currentScript); 
                    var params = $.param({ 
                        action: 'load-template' 
                        , launch_owner_email_hashed: $currentScript.data('launch_owner_email_hashed') 
                        , launch_id: $currentScript.data('launch_id') 
                    }); 

                    $.get(apiUrl, params).then(function(html){ 
                        var div = $('<div style="margin:0; padding: 0;">').html(html); 
                        $currentScript.after(div); 
                    });

                    $(document).ready(function() 
                        {
                            console.log(1);
                        }); 
                }


    }
(this));

I wanna take some ideas before starting. What do you recommend as simple, fast and good option?

Thanks

25th June, 2018

behnampmdg3 left a reply on CSS Help. Setting The Right Height For Iframe Inside A Div, And The Parent Div. • 3 weeks ago

We already established that it won't be perfect.

I am asking about the best approach even though not perfect.

behnampmdg3 left a reply on CSS Help. Setting The Right Height For Iframe Inside A Div, And The Parent Div. • 3 weeks ago

Yes I get it. What's the "best" way?

behnampmdg3 started a new conversation CSS Help. Setting The Right Height For Iframe Inside A Div, And The Parent Div. • 3 weeks ago

Hello;

I have a code that dynamically loads iframes in div.

So here on this page, I embedded 4 common scenarios: [URL="https://webmoosh.com/broadcast.html"]https://webmoosh.com/broadcast.html[/URL]

Since the content is different, they could all have different heights.

For some reason, it adds extra height in some situations.

[URL="https://webmoosh.com/broadcast.html"]In the example[/URL], The top fixed one is ok, however, the other 3 have issues.

The timer with blue font and the one with white font have some extra gap under.

And the bottom fixed one has extra height on iPhone.

What are the right ways of doing this do the height of the div containing the iframe, and the iframe itself be correct?

I've done everything by the book.

Thanks

22nd June, 2018

21st June, 2018

behnampmdg3 left a reply on Can You Calculate The Maximum Number Of Requests This System Can Handle? • 1 month ago

End point:

<?php
include 'config.php';

if( isset($_POST['user_id'])            && 
    isset($_POST['launch_id'])          && 
    isset($_POST['secret_key'])         && 
    isset($_POST['prospect_email'])     &&
    ctype_digit($_POST['launch_id'])    &&  
    ctype_digit($_POST['user_id'])      
)
    {
        date_default_timezone_set('UTC');
        $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $stmt = $conn->prepare("
            INSERT INTO LTC 
            (user_id, 
             launch_id, 
             prospect_email, 
             time_added, 
             date_added, 
             source) 
SELECT launch_owners.id, 
       :launch_id, 
       :prospect_email, 
       :time_added, 
       :date_added, 
       :source 
FROM   launch_owners 
       INNER JOIN launch_launches 
               ON launch_launches.user_id = launch_owners.id
       AND launch_launches.id = :launch_id 
WHERE  launch_owners.id = :id 
       AND secret_key = :secret_key");

        $time = date('H:i');
        $date = date('Y-m-d');
        $stmt->bindParam(':id', $_POST['user_id']);
        $stmt->bindParam(':secret_key', $_POST['secret_key']);
        $stmt->bindParam(':launch_id', $_POST['launch_id']);
        $stmt->bindParam(':prospect_email', $_POST['prospect_email']);
        $stmt->bindParam(':time_added', $time);
        $stmt->bindParam(':date_added', $date);
        $stmt->bindParam(':source', $_POST['source']);
        $stmt->execute();
            $conn=NULL; 

    }
    

behnampmdg3 started a new conversation Can You Calculate The Maximum Number Of Requests This System Can Handle? • 1 month ago

Hello;

By looking at this http://bit.ly/2K4Xep0 , how can I calculate the maximum number of requests this system can handle?

20th June, 2018

behnampmdg3 left a reply on How Is This Even Possible With Javascript? • 1 month ago

Know anyone good here u could hook me up? Thanks bro

behnampmdg3 left a reply on How Is This Even Possible With Javascript? • 1 month ago

Cronix u open to some php jquery job?

19th June, 2018

behnampmdg3 left a reply on Where To Post Jobs? • 1 month ago

Hi;

None of the leaders have it lol

behnampmdg3 started a new conversation Where To Post Jobs? • 1 month ago

Hi;

Is this the right place to post jobs?

I've got a bunch of php job I wanna hire someone preferably from here.

Thanks

behnampmdg3 left a reply on How Is This Even Possible With Javascript? • 1 month ago

This happens via page builders.

They might have multiple forms on the page.

Maybe there is no robust way to get this 100% right.

behnampmdg3 left a reply on How Is This Even Possible With Javascript? • 1 month ago

Ok, I understand you so far.

I want to do similar things and my clients do upload any javascript I give them to their page.

All I need at this end is the email field. I need a solid way to capture the emails.

I am gonna try the method above see how far I go. I'll probably post more about it.

behnampmdg3 left a reply on How Is This Even Possible With Javascript? • 1 month ago

And what about submission?

How does it submit the form to different URLs?

Little hint plz

behnampmdg3 started a new conversation How Is This Even Possible With Javascript? • 1 month ago

How can Javascript collect email address from a form "without knowing the form id or any other details about the form"?

They claim you can stick a piece of JS on the page and it collects email from the form.

https://www.youtube.com/watch?v=xkyCSAsCYx4

How is this possible?

behnampmdg3 left a reply on Load Multiple Scripts Inside Javascript • 1 month ago

I have this already but it's ugly as F

(function(window) {
    var currentScript = document.currentScript;
    var apiUrl = currentScript.src;


    if (!('jQuery' in window)) {
        loadJQuery(initialize);

    } else {
        initialize();
    }



    function loadJQuery(cb) {
        var script = document.createElement('script');
        script.src = 'https://code.jquery.com/jquery-3.3.1.min.js';
        script.type = 'text/javascript';
        script.addEventListener('load', cb);
        document.getElementsByTagName('head')[0].appendChild(script);
    }

    function initialize() {



        $.getScript('https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js', function() {
            $(document).ready(function() {
                console.log(123);
                if (!$.cookie("timer_created_at")) {
                    var now = new Date().getTime();
                    $.cookie("timer_created_at", now);

                } else {
                    var age = new Date().getTime() - $.cookie("timer_created_at");
                    console.log(age / 60000);
                }
            });
        });



        var $currentScript = $(currentScript);
        var params = $.param({
            action: 'load-template',
            launch_owner_email_hashed: $currentScript.data('launch_owner_email_hashed'),
            launch_id: $currentScript.data('launch_id')
        });

        console.log('here');




        $.get(apiUrl, params).then(function(html) {
            var div = $('<div>').html(html);
            $currentScript.after(div);
        });
    }
}(this));

behnampmdg3 left a reply on Load Multiple Scripts Inside Javascript • 1 month ago

It's not like that. The page is not html

 <?php 
header('Access-control-allow-origin: *'); 
$action = isset($_GET['action'])?$_GET['action']:null; 
switch ($action){ 
    case 'load-template': 
        load_template(); 
        break; 
    default: 
        DoDefault();  
} 
exit; 
function DoDefault(){ 
    header('Content-type: text/javascript'); 
?> 
(function(window){ 
    var currentScript = document.currentScript; 
    var apiUrl = currentScript.src; 

    if (!('jQuery' in window)){ 
        loadJQuery(initialize); 
    } else { 
        initialize(); 
    } 




    function loadJQuery(cb){ 
        var script = document.createElement('script'); 
        script.src = 'https://code.jquery.com/jquery-3.3.1.min.js'; 
        script.type = 'text/javascript'; 
        script.addEventListener('load', cb); 
        document.getElementsByTagName('head')[0].appendChild(script); 

    } 

    function initialize(){ 
        //Validate 
        var $currentScript = $(currentScript); 
        var params = $.param({ 
            action: 'load-template' 
            , launch_owner_email_hashed: $currentScript.data('launch_owner_email_hashed') 
            , launch_id: $currentScript.data('launch_id') 
        });

        console.log('here'); 
        
        $(document).ready(function() 
          { 
            if(!$.cookie("timer_created_at"))
              {
                var now = new Date().getTime();
                $.cookie("timer_created_at", now);
                
              } 
            else 
              {
                var age = new Date().getTime() - $.cookie("timer_created_at"); 
                console.log(age/60000);
              } 
          }); 


        $.get(apiUrl, params).then(function(html){ 
            var div = $('<div style="margin:0; padding: 0; height:100px">').html(html); 
            $currentScript.after(div); 
        }); 
    } 
}(this)); 
<?php 
} 
function validate() 
    { 
       
    } 

  function load_template() 
      { 
      
      }

behnampmdg3 started a new conversation Load Multiple Scripts Inside Javascript • 1 month ago

Omg, I am going mad.

I am loading Jquery, also want to I wanna also load

https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.js

But I can't.

Help plz.

(function(window){ 
    var currentScript = document.currentScript; 
    var apiUrl = currentScript.src; 

    if (!('jQuery' in window)){ 
        loadJQuery(initialize); 
    } else { 
        initialize(); 
    }

    function loadJQuery(cb){ 
        var script = document.createElement('script'); 
        script.src = 'https://code.jquery.com/jquery-3.3.1.min.js'; 
        script.type = 'text/javascript'; 
        script.addEventListener('load', cb); 
        document.getElementsByTagName('head')[0].appendChild(script); 

    } 

    function initialize(){ 
        //Validate 
        var $currentScript = $(currentScript); 
        var params = $.param({ 
            action: 'load-template' 
            , launch_owner_email_hashed: $currentScript.data('launch_owner_email_hashed') 
            , launch_id: $currentScript.data('launch_id') 
        });
        
        $.get(apiUrl, params).then(function(html){ 
            var div = $('<div>').html(html); 
            $currentScript.after(div); 
        }); 
    } 
}(this)); 

18th June, 2018

behnampmdg3 left a reply on Is There Any Way To Make This Code Perform Faster? • 1 month ago

You probably mean this?

$stmt = $conn->prepare("
            INSERT INTO launch_temp_leads 
            (user_id, 
             launch_id, 
             prospect_email, 
             time_added, 
             date_added, 
             source) 
SELECT launch_owners.id, 
       :launch_id, 
       :prospect_email, 
       :time_added, 
       :date_added, 
       :source 
FROM   launch_owners 
       INNER JOIN launch_launches 
               ON launch_launches.user_id = launch_owners.id 
WHERE  launch_owners.id = :id 
       AND secret_key = :secret_key 
       AND launch_launches.id = :launch_id ");
        $time = date('H:i');
        $date = date('Y-m-d');
        $stmt->bindParam(':id', $_POST['user_id']);
        $stmt->bindParam(':secret_key', $_POST['secret_key']);
        $stmt->bindParam(':launch_id', $_POST['launch_id']);
        //$stmt->bindParam(':user_id', $_POST['user_id']);
        $stmt->bindParam(':prospect_email', $_POST['prospect_email']);
        $stmt->bindParam(':time_added', $time);
        $stmt->bindParam(':date_added', $date);
        $stmt->bindParam(':source', $_POST['source']);
        $stmt->execute();

behnampmdg3 left a reply on Is There Any Way To Make This Code Perform Faster? • 1 month ago

Interesting!

How about the complexity of query vs overhead of one call?

17th June, 2018

behnampmdg3 left a reply on Is There Any Way To Make This Code Perform Faster? • 1 month ago

Thanks.

Nixck I understand what you mean.

The question is how much 'performance' difference we talking here?

This is currently responding 100% to 700 requests per second.

Peace

behnampmdg3 left a reply on Is There Any Way To Make This Code Perform Faster? • 1 month ago

By the way cronix, this code works SO MUCH faster than Laravel or even Codeigniter.

I am starting to accept using a framework for end-point api is not a good idea.

behnampmdg3 left a reply on Is There Any Way To Make This Code Perform Faster? • 1 month ago

if($stmt->rowCount()==1)

to validate the credentials. If it's trash, ignore it.

What kind of index for secret_key and launch_key? Unique?

CREATE TABLE `launch_temp_leads` (
 `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
 `date_added` date NOT NULL,
 `time_added` varchar(255) NOT NULL,
 `launch_id` int(11) NOT NULL,
 `prospect_email` varchar(255) NOT NULL,
 `source` varchar(255) NOT NULL,
 `user_id` int(11) NOT NULL,
 `status` varchar(255) DEFAULT 'pending',
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8
CREATE TABLE `launch_owners` (
 `id` int(11) NOT NULL AUTO_INCREMENT,
 `account_type` varchar(255) NOT NULL,
 `secret_key` varchar(255) NOT NULL,
 `email` varchar(255) NOT NULL,
 `password` varchar(255) NOT NULL,
 `date_added` date NOT NULL,
 `status` varchar(255) NOT NULL,
 `timezone` varchar(255) NOT NULL,
 `temp_password` int(11) DEFAULT NULL,
 `password_update_request` int(11) DEFAULT NULL,
 PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8

behnampmdg3 started a new conversation Is There Any Way To Make This Code Perform Faster? • 1 month ago

Hello;

Is there any way to make this code perform faster? Or is it as optimized as it can be.

<?php
include 'config.php';

if(isset($_POST['user_id']) && ctype_digit($_POST['user_id']) && 
   isset($_POST['launch_id']) && ctype_digit($_POST['launch_id']) && 
    isset($_POST['secret_key']))
    {
        $conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        
        //Check Credentials
        $stmt = $conn->prepare("SELECT secret_key, launch_timezone FROM launch_owners INNER JOIN launch_launches ON launch_launches.user_id = launch_owners.id WHERE launch_owners.id = :id AND secret_key = :secret_key AND launch_launches.id = :launch_id");
        $stmt->bindParam(':id', $_POST['user_id']);
        $stmt->bindParam(':secret_key', $_POST['secret_key']);
        $stmt->bindParam(':launch_id', $_POST['launch_id']);
        $stmt->execute();
        if($stmt->rowCount()==1)
            {
                $result = $stmt->fetchAll();
                date_default_timezone_set($result[0]['launch_timezone']);
                //Insert record
                    $stmt = $conn->prepare("INSERT INTO launch_temp_leads (user_id, launch_id, prospect_email, time_added, date_added, source) VALUES (:user_id, :launch_id)");
                    $stmt->bindParam(':user_id', $_POST['user_id']);
                    $stmt->bindParam(':launch_id', $_POST['secret_key']);
                    $stmt->bindParam(':prospect_email', $_POST['prospect_email']);
                    $stmt->bindParam(':time_added', date('i:H'));
                    $stmt->bindParam(':date_added', date('Y-m-d'));
                    $stmt->execute();
                //Insert record    
            }
        $conn=NULL; 
    }
else 
    {
        echo "Not sufficient post data";
    }   

Thanks

behnampmdg3 left a reply on A Design Question. What If The Customer Don't Upgrade? How Can I Limit The Service? • 1 month ago

Need to get creative with this. Thanks

16th June, 2018

behnampmdg3 started a new conversation Can I Write This Query Better? • 1 month ago

Hello;

Tips to optimize based on Explain => https://snag.gy/5HCPtd.jpg

SELECT launch_owners.status, 
       launch_owners.secret_key, 
       COUNT(*) AS TOTAL_LEADS 
FROM   launch_prospects 
       INNER JOIN launch_owners 
               ON launch_prospects.owner_id = launch_owners.id 
                  AND launch_owners.id = 1 
       INNER JOIN launch_launches 
               ON launch_launches.user_id = launch_owners.id 
                  AND launch_launches.id = 112 

behnampmdg3 left a reply on A Design Question. What If The Customer Don't Upgrade? How Can I Limit The Service? • 1 month ago

Dude, setting cronjobs will take so much pressure off my api endpoint too!

I dont need to set up workers either.

I add everything to db, then later check it with cron job and classify/delete the garbage etc.

behnampmdg3 left a reply on A Design Question. What If The Customer Don't Upgrade? How Can I Limit The Service? • 1 month ago

Maybe I can set cronjobs in whm

behnampmdg3 left a reply on A Design Question. What If The Customer Don't Upgrade? How Can I Limit The Service? • 1 month ago

Yes, this is a biz logic question.

And again yes, when the endpoint receives leads, I have to perform a count and check this.

I am trying to avoid using workers at the same time keep the endpoint as light as possible.

API endpoint seems to be a good punching bag for extra queries etc.

behnampmdg3 left a reply on A Design Question. What If The Customer Don't Upgrade? How Can I Limit The Service? • 1 month ago

I hear you. For simple products that works.

This one is B2B.

Can't phuck with "their" customers. They use these widgets on their sales pages.

I still notify them with emails and alerts on the website. Need to also disable the widgets they add to their sites.

Maybe disable the widgets after X days be a good idea. That brings me to "when did they go over the limit" and give them 2 weeks time before unplugging.

See where this is going?

15th June, 2018

behnampmdg3 started a new conversation A Design Question. What If The Customer Don't Upgrade? How Can I Limit The Service? • 1 month ago

Hi;

It's a monthly payment system. The client can buy 3 account types:

1 - Basic, 2 - Pro, 3 - Consultant

Basic allows them to have 10000 emails in their account. Pro allows them to have 100000 emails in their account. Consultant allows them to have 200000 emails in their account.

They can add prospects emails to their account using my API endpoint.

Scenario:

If they buy a Basic account and at some point the number of the emails in their account increase over the limit:

1 - How can I give them X days to upgrade and what if they don't upgrade? 2 - How can I calculate the number of days they've been over the limit (without making things complicated and shet in the code)

I want to give them maybe X days notice. After that 2 things could happen:

1 - They upgrade 2 - They don't upgrade

What if they stay on the same account type? I can't cancel their account because they still paying.

Tanx

behnampmdg3 left a reply on Is This A Good Approach To Create Countdown Timer Like This? • 1 month ago

Yes, I don't have that option, unfortunately.

I am going with cookies.

Thanks bro

behnampmdg3 left a reply on Is This A Good Approach To Create Countdown Timer Like This? • 1 month ago

The only reliable solution is getting them to sign up and pass the email in the url. Nothing beats the database.

behnampmdg3 left a reply on Is This A Good Approach To Create Countdown Timer Like This? • 1 month ago

"i will open private browser, so cookie not work for me"

What does Cronix have to say to that?

behnampmdg3 left a reply on Is This A Good Approach To Create Countdown Timer Like This? • 1 month ago

Ok,

I have to do calculations with JS rather than PHP now.

For this one, I'll drop the IP and DB idea altogether and focus 100% on the cookie.

WIll probably post about it soon.

Thanks

behnampmdg3 left a reply on Is This A Good Approach To Create Countdown Timer Like This? • 1 month ago

Yo;

Is cookie reliable option?

behnampmdg3 started a new conversation Is This A Good Approach To Create Countdown Timer Like This? • 1 month ago

Hi;

How would you tackle this issue:

Requirements:

When a visitor hits the page, load a countdown timer that shows X days, hours and minutes before expiring. When the visitor returns, the timer should be set from the time visitor first visited the page.

My solution:

Give a piece of Javascript code to the client to embed in the page. Each time that code gets loaded, I create a record with IP address of the visitor in the database.

When that page gets reloaded, I query the database, if the IP exists, instead of creating the record, I load the countdown timer associated with that id, calculate the time since created, and load the countdown accordingly.

Ideas?

14th June, 2018

behnampmdg3 left a reply on Css Question. Iframe Height. • 1 month ago

Anyone?

13th June, 2018

behnampmdg3 started a new conversation Css Question. Iframe Height. • 1 month ago

Hi;

The question is about the timer sticking to the bottom of this page https://webmoosh.com/demo

How can I set the iframe height so it still works well cross-browser and this annoying few pixel gap goes away? http://prntscr.com/jup0yq

Thanks

behnampmdg3 left a reply on Can Phpinfo Reveal This? • 1 month ago

ResultsGot an update email from the server they just applied the settings to the second server.

By the way, Liquid server company, they are the best I've seen!

12th June, 2018

behnampmdg3 left a reply on With A Page Under Heavy Traffic, Would It Be A Better Design To Dump Everything In 1 Controller? • 1 month ago

Let's establish this first: "structure the code well and ignore library/helper load time." Deal?

behnampmdg3 left a reply on With A Page Under Heavy Traffic, Would It Be A Better Design To Dump Everything In 1 Controller? • 1 month ago

So, structure the code well and ignore library/helper load time.

Correct?

behnampmdg3 started a new conversation With A Page Under Heavy Traffic, Would It Be A Better Design To Dump Everything In 1 Controller? • 1 month ago

Hi;

With a page under heavy traffic, would it be a better design to dump everything in 1 controller? Will it be better in terms of "saving time not having to load libraries"?

Or, create simple libraries for each specific task and don't worry about the time load since these are tiny libraries?

behnampmdg3 started a new conversation DateTimeZone::listIdentifiers With GMT, CET And Eastern • 1 month ago

Hi;

Is there a version of DateTimeZone::listIdentifiers that contain all timezones such as GMT, CET and Eastern?

I get this but it's missing some main ones. Not sure why they keep changing this!

echo '<select name = "launch_timezone" class="form-control">';
$time_zone_selected =  (!isset($launch['launch_timezone'])) ? 'UTC' : html_escape($launch['launch_timezone']);
$timezones = DateTimeZone::listIdentifiers(DateTimeZone::ALL);
foreach($timezones as $tz=>$val)
  {
   echo '<option value="'.$val.'"'; 
   if($time_zone_selected==$val)
      {
         echo 'selected = "selected"';
      }
    echo '>'.$val.'</option>';
  }
  echo '</select>';?>

behnampmdg3 left a reply on Can Phpinfo Reveal This? • 1 month ago

Hey Click.

These are connected to the same database.

Edit Your Profile
Update

Want to change your profile photo? We pull from gravatar.com.