amuck-landowner

I've got an array and I want to break it up into two files

shovenose

New Member
Verified Provider
I've got a PHP array where I'm registering a few globals. Unfortunately I have to break it up into two files. One with user editable configs and one with non-user-editable configs.

It worked perfectly when it was one file but when I chop it in half and use require_once('configuration2.php'); it breaks with error(s). The user-editable config file is called configuration.php and the one I don't want people diting is configuration2.php.

The reason I do want those options as part of a configuration file is that in the future I may want to edit some data.

What am I doing wrong?
 
Last edited by a moderator:

LiamCyrus

Member
Verified Provider
Um, that's gonna be a tough one. How much of the code do you need to see?
Well for starters, what is the error you're being prompted with when you try to split the array across two files?

Can you provide a snippet of the array/how you declare it? Check for conflicting variable names?
 
Last edited by a moderator:

GIANT_CRAB

New Member
>registering a few globals

That's your problem.

Usually, people use PHP define function instead of registering globals.
 
Last edited by a moderator:
  • Like
Reactions: scv

Aldryic C'boas

The Pony
So, you're working on a project you're unwilling to share code of... very recently, you asked for opinions on billing software.  It's a fairly easy connection to see what you're working on - but to be brutally honest, the best thing you could do at this point is don't.

This isn't trying to rip your effort, or make fun of you;  for your own good, take a step back and look at the situation objectively.  You're a novice with php, a language which already has fundamental flaws that have to be taken into consideration when dealing with security.  It's a reasonable guess that you're wanting to build a billing panel, or at least an operational replacement for WHMCS (perhaps even to monitize).  But you HAVE to know your limits.

Look at your recent KVM issue - you opened, closed, and reopened a brand all within 48 hours, due to inexperience, frustration, and lack of conviction.  You're not ready to undertake projects on your own - especially given you only have a passing knowledge of the language in question.  And that's not even touching on just how complex a billing system can get.  That's why we're seeing so many quickly-abandoned panel projects;  people think it's easy to just throw some code down, and very soon get frustrated with how much actual work is involved and give up.  Or in the case of DimeCadium or a certain 'developer' we used to work with, just taking someone's money and running without having any intent of producing.

Seriously, save yourself headache and embarrassment now - don't try to do anything more complex than a single-user blog-type website by yourself.  You have neither the experience nor the coding skill for something that large.  Get involved with some simple open-source projects - really get a good grasp of the languages and tie-ins (such as the finer points of PROPER mySQL - you can't just play with mysql_query() and think you know how DBs really work).  Spend a couple of years building a solid understanding of the tools you'll need.  After all - you're going to be asking your clients to trust your work to keep their information secure.

Last, but probably most important - before you do ANY type of attempt at a panel, learn how existing ones work first.  Don't just skim documentation - actually spend some time writing modules for systems like WHMCS.  Teach yourself to do the simple point-and-click actions using the more complex API, or even writing short scripts to do the work.  Yes, this is 'excessive work', but it helps you learn just how complex the panel really is, and just how important all the various pieces are to each other.

A food-for-though example:  in your WHMCS database, there are over 90 tables.  Two of them are tblproductconfigoptionssub and tblhostingconfigoptions, for example.  Do you know what those two tables do?  Do you know how they interact with multiple other tables?  I will be the first to tell you that WHMCS is very, very poorly written.  But the bottom line is - they've build a functional billing panel, and you haven't.  Learn from them.  Use an existing setup to familiarize yourself with what you will need to do.

But again, first and foremost.  Learn the basics.  Temper your impatience, and try to realize now that every little mistake you make is going to seriously affect your credibility down the line.  Not because you made a mistake, everyone does that.  But because you dove headfirst into something you're not ready for - a VERY scary idea once people realize they're trusting you with their data.
 

Damian

New Member
Verified Provider
What Aldryic said. I know there's a strong sentiment of OH GOD ANOTHER WHMCS VULN ITS KILLING MY GRANDMOTHER NEED TO GET ANOTHER PANEL OMGOMGOMGOMGOMG but there's a lot of moving parts within WHMCS. It's going to take a LOT of effort to replicate even a small amount of what WHMCS has done. I have a pretty good idea of the error that you're encountering, but if you yourself don't know how to overcome it, then I'd kinda rather not enable you to continue.

I don't mean to discourage or demean here, and i'm sure the project has been started with the best intentions, but instead of going off on your own and coming up with a potentially poor product, why don't you join up with Blesta or someone else who's writing a panel? Help someone else make their wheel roll better instead of inventing a new wheel.

Additionally, please take a look at the giant red warning at the top of http://php.net/manual/en/security.globals.php
 
Last edited by a moderator:

wlanboy

Content Contributer
There are no dump questions only dump replies.
Everyone should be able to ask stuff here.

Array filter is nice to split arrays depending on some logic:


<?php
function odd($var)
{
return($var & 1);
}
$array1 = array("a"=>1, "b"=>2, "c"=>3, "d"=>4, "e"=>5);

echo "Odd :\n";
print_r(array_filter($array1, "odd"));
?>
Output:
Odd :
Array
(
[a] => 1
[c] => 3
[e] => 5
)

Next thing is that one file should create the array and the other one should only add elements:


<?php
$stack = array("a" => 1);

array_push($stack, "b" => 2);
print_r($stack);
?>

And please do not use globals.
 

shovenose

New Member
Verified Provider
I am not coding the actual code of a billing system (well, I just about finished the client side interface on it but did none of the back end code which is being done by other people)...

What I am doing right now is a live chat software. I will work on my code, if I still have the problem I will post it here clearly with enough info and errors. I'm also working on a point of sale system but I've hired people to do most of the hard work on that then I can simply learn from how they did it.

I'm not an idiot nor am I a scammer. If I didn't feel comfortable using the product myself I would not sell it. I understand how much work a billing system is and that is why ShoveHostingCompleteBillingSolution is not for sale lol and a. won't be called that and b. is going to be a work in progress with a long, long way to go. And all of the neccessary security audits are going to be performed before the first beta is even released.

UnmanagedServers.NET is now available to buy VPS's from. I know that it was a fail the first time, but how many times did it take me to get ShoveHost right? I've learned a lot and I've got happy customers to prove it. And the same goes for UnmanagedServers.NET - I saw what I did wrong the first time and now the node is solid, fast, and usable.
 
Last edited by a moderator:

GIANT_CRAB

New Member
Shovenose, you can't always be dependent on others all the time for answers.

You'll need to do research yourself.

If you really want to learn PHP, visit PHP.net's documentation.

Almost every function are well documented.

People here are just a bit tired of the nonsense they have to put up with.

If you want PHP help, you can PM me but you'll have to try to Google for the answer first.

Nobody called you an idiot or a scammer.

The fact that you can type in this forum is the evidence that your IQ is higher than an idiot.

The fact that you're not banned (or unbanned) from this forum is the evidence that you're not a scammer.

I'm pretty sure you're a verified provider because you're not an idiot or a scammer.

You'll need to get used to getting judged and criticised for everything by society.

Its how the society works, either deal with it or be anti-social.

I can't really care less about your billing system and how you're going to have security audits.

Its just that everyone is jumping into the bandwagon of making billing systems, etc.

One last thing to tip you on, Paypal's API is fucking terrible.

Its so terrible that its fucking bad. Its completely illogical, unintuitive and not pragmatic in any ways.

Also, correction to my previous post, I don't think you can actually define arrays.
 
Last edited by a moderator:

BlueVM

New Member
Verified Provider
I'm writing a billing panel as well and I'll tell you flat out right now it's a lot of work.

As an example I've been writing Feathur (our VPS Control Panel) for nearly 5 months... It's over 50,000 lines long and it's BARELY in alpha stage. Your average/good programmer is going to pump out 150 lines of usable code an hour.

I usually meet that average, which means that I've spent a month and a half of my life programming Feathur. (Based on working 8 hours a day), not to mention time spent documenting, answering questions, converting customers, etc... I don't think a billing panel would be any less complex (heck it's probably more complex). So take this as a word of caution: Build something much smaller before you dive into a billing panel.
 

Francisco

Company Lube
Verified Provider
How in the world is your panel 50k+ lines?

Shiiiit Stallion 2 is only ~33k with all the frontend javascript, views, etc.

But yes, a billing panel can be complex. On the other hand, if you're only using it for yourself and have no interest in taking it to market, you could be clever and just use paypal 'buy now' button subscriptions w/ an IPN.

We're working on billing2 right now and we've already had to redesign the database 3 times because we get to some functionality that we didn't plan out properly yet. Thankfully, we aren't taking this to market so there's lots of things that we can just leave as simple SQL tables or configuration files.

I think the most complex part of the whole system is going to be the IPN's. It shouldn't be since it's just POST data, but paypal is a very odd platform.

Francisco
 
Last edited by a moderator:

BlueVM

New Member
Verified Provider
@Francisco - I'd say my number is a guesstimate, not the actual count. It's probably closer to 30k, but I was trying to make a point...
 

LiamCyrus

Member
Verified Provider
As somebody who is also writing a billing panel, I haven't had too many issues with IPNs. Stripe's API is easy as hell to implement, and Google Checkout is only slightly more troublesome. Admittedly PayPal's is a nightmare, but I'm confident that Bitpay and Amazon will be easier to add.

The biggest thing that I've had trouble on so far is working with invoices. My invoice cronjob is a clusterfuck. It's too much for my little brain to handle. Is an invoice due within three days? Email the client. Is the invoice for hosting, or something else? Has it been paid for? If not, do you need to suspend the account? Has the account already been suspended? How will you deal with suspending SSL certificates and domains? If it has been paid for, when are you generating a new one? Is the invoice monthly or yearly? Are you billing for all items, or just recurring ones? Has the account already been terminated? Is the invoice overdue? Are you adding a late fee? Has the client requested to cancel the invoice/terminate the service?

Oh well.
 
Last edited by a moderator:

joepie91

New Member
As somebody who is also writing a billing panel, I haven't had too many issues with IPNs. Stripe's API is easy as hell to implement, and Google Checkout is only slightly more troublesome. Admittedly PayPal's is a nightmare, but I'm confident that Bitpay and Amazon will be easier to add.


The biggest thing that I've had trouble on so far is working with invoices. My invoice cronjob is a clusterfuck. It's too much for my little brain to handle. Is an invoice due within three days? Email the client. Is the invoice for hosting, or something else? Has it been paid for? If not, do you need to suspend the account? Has the account already been suspended? How will you deal with suspending SSL certificates and domains? If it has been paid for, when are you generating a new one? Is the invoice monthly or yearly? Are you billing for all items, or just recurring ones? Has the account already been terminated? Is the invoice overdue? Are you adding a late fee? Has the client requested to cancel the invoice/terminate the service?


Oh well.
Warning ahead: Bit-Pay (and CoinBase) do not have callback verification. You'll need to set a 'secret key' to verify that they are legitimate callbacks.

I can't say I'm happy with the current state of the various Bitcoin payment gateways, security-wise...
 

jarland

The ocean is digital
So, you're working on a project you're unwilling to share code of... very recently, you asked for opinions on billing software.  It's a fairly easy connection to see what you're working on - but to be brutally honest, the best thing you could do at this point is don't.
Keep in mind that the best way to learn for many people is to find a practical application that interests you and figure out how to make it work. After you've figured out how to spin the wheels, you might have a more solid foundation to say "Alright, I know how to get the result, now what should I have done better."

Just a thought. I know that I learn better by building crappy things than I do studying until I know how to do it flawlessly before touching a line of code. Motivation, for me, is found in seeing results. When I know I can get results, motivation is plentiful to fix and learn.
 
Top
amuck-landowner