PHP - How To Include Uri Content After Route Traffic To Controller.php ?
Hi;
I have succesfully managed to route all the traffic to the file controller.php using this command line of .htaccess :
RewriteEngine On RewriteRule (.*) /var/www/html/site/controller.php [L,QSA]Now how to tell the controller.php to process the url that was passed. For example i have tried that: controller.php : <?php include( $_SERVER["REQUEST_URI"] ); ?>but the controller.php didn't do anything i keep getting a blank page when i browse any webpage such as site/index.php so how to tell controller.php to echo the content of the request ? because the user shouldn't notice any change as if there is no controller.php. Thank you. Similar TutorialsHi: I have this code that - when added to a page - works fine: Code: [Select] <div class=\"<?php echo (time() <= strtotime('4/17/2011 2:00:00 AM')) ? 'myUpcoming' : 'myPassed'; ?>\"> <span class=\"myGameDate\">April 16:</span> <span class="myGameDateRed">Home</span> vs Baltimore </div> It's a schedule that will display one CSS style before the date, and another CSS style after the date. Works fine on the homepage. I am trying to add it to an include navigation file, so I can add it to all the pages like this: myNav.php Code: [Select] function spSchedule() { $spSchedule = " <div class=\". echo time() ." <= strtotime("4/17/2011 2:00:00 AM") ? \"myUpcoming\" : \"myPassed\"; .\"> <span class=\"myGameDate\">April 16:</span> <span class=\"myGameDateRed\">Home</span> vs Baltimore </div> "; return $spSchedule; } myPage.php: Code: [Select] <?php include('include/myNav.php'); ?> ... <?php echo spSchedule(); ?> What it is doing is writing "myUpcoming" to the page, and that's it. What am I missing on this, please? I'm trying to create a INSERT query statement that makes use of the content of 'include' files. When I call up the include it simply echos it to the screen but I can't seem to capture the text string and actually make it function as part of the query. I've tried setting the include as a variable but again it only outputs to the screen. Help please! Here's a portion of the code... if (($_POST['sched_templates']) == "sched_TestingOnly.htm") { $query = include 'sched_TestingOnlyQuery1.htm'; } if (@mysql_query ($query)) { mysql_close(); // End adding Registration to the database header ('Location: redirectfile.htm'); exit(); } else { print "<p><b>Sorry, your entry could not be entered. } I need to develop a web based bulk SMS application to integrated into my existing website which is written in PHP.
That means I shall use my authentication script to lock it down.
The application should be able to pull phone numbers from MYSQL database, and from a specified list.
If you can do this or need more information, reach out to me.
Thanks.
hi i need some help . i see some person use bot traffic or proxey taffic software or script like jiggling and hitleap . they give a url of any sites then this software proxey view this websites.. i want asked can it possible stop these bot traffic its any procedure in php or javascript to stop this traffic..
I would like to be able to detect, for instance, people who are using the TOR browser when they attempt to log in to one of my sites. my traffic report globals can already tell me if they are coming from a TOR node, but I would like to reject a login if an onion system or an anonymity browser is being used. I have only ran into one other site that has the capability of doing this, in terms of talking about forums only, and that is MrExcel: https://www.mrexcel.com/board/ if you try to register an account there with TOR, the page renders and says “we have detected you are trying to use automated queries to register an account”. there are of course, ways to get around that, if you click buttons in a timely manner, so they are not that good. but regardless, the pre-packaged software they bought does the job fairly well. can anyone offer any help in this regard? I know for a fact that most of the big banks in the USA have this covered, so I know that technology exists to block traffic coming from these sources, but I don’t know if it’s available to the little guy like me. Hi, Is it possible to make some kind of network/web traffic sniffer than can give you stats on how much p2p, mail etc etc traffic is going out your router? If so, does anyone know of any tutorials on the subject? I am using JWT for an API authentication and like them. Previously, I would query both some GUID and the user's ID (which wasn't their PK but a unique key per GUID), but now I just include both the account and user's DB PK in the token. Also, including something regarding the user's permissions, however, I still haven't bought into this approach as I don't know how to deal with changing permissions and still having some JWT with different permissions floating around. I suppose I could save the JWT's timestamp in the DB, but that seems to eliminate the benefit of token expirations... Sorry, back to the question at hand. I now have a need to provide emails with a reduced subset of endpoints to either view some resource or update some status. I don't want to make the user first go to some website and then include the JWT in the header, but instead just a single click action. Problem is now I have their JWT which is effectively their password in some email which isn't ideal, and their is no way to ensure that the specific user was the individual that viewed the resource or performed some action. Then I thought maybe I would make some common low access JWT and use the exact same GET routes as I would do so normally and create some new GET routes to emulate main application POST/PUT/PATCH routes. Before going down that path, I would like to investigate other solutions. Often single use tokens are used to reset passwords and other actions which should only performed once and this is not my need but maybe close. I am thinking of creating a token that includes the actual resource path with URL parameters along with the HTTP method. Since everything is in the token, I wouldn't need a typical REST path to identify the resource but would have a single endpoint to retrieve them. I searched for related information and didn't find anything which makes me concerned I am going down a rabbit hole. Any thoughts on how to implement this? Thanks Hello, I am hoping to get some advice on how to make my code work. What I would like to do is display a "you are already subscribed" message if the user experiences error 1062 (duplicate entry) and die, or if it's a different error that occurs I would just like it to display the raw error message and die. I've tried it this and way and that but I'm stumped (obviously I'm also pretty new to this). Here is my code: Quote <?php $con = mysql_connect("localhost"); if (!$con) { die ('Could not connect: ' . mysql_error()); } mysql_select_db("subscribe", $con); $sql="INSERT INTO subscribe_init (id, notes) values ('$_POST[id]','$_POST[notes]')"; if (!mysql_errno() == 1062) echo 'You are already subscribed.'; elseif (!mysql_query($sql,$con)) die ('Error: ' . mysql_errno() . mysql_error()); else echo "Thank you for signing up!"; mysql_close($con) ?> Any advice is greatly appreciated. Thank you! How to draw the path of individual planes that avoid the intersection of their paths for safety and optimization of routes?!
Note:
Same number of planes. ( = M )
Same number of coordinates for airports ( junctions ). ( = N )
Add new points to avoid Intersection of paths of the planes!
flights 12 1.JPG 16.44KB
0 downloads
flights 12.JPG 16.08KB
0 downloads
Edited by Vamsi19, 17 September 2014 - 10:57 PM. hi everyone I have this site i want to make changes to the contact form. Right now it sends the info to a database and posts in the admin area. I have this file controller.php that has a section with a funtion function Cuenta_Contactos that i think passes the info. Is there a way to add an email address there so it sends the message to that email account? Thanks ive attached the file . Hi y'all. First off, posting this here to hopefully avoid the noise that's happening in the Applications sub-forums, so mods please feel free to move if it's too inappropriate here. Anyway, I'm currently doing a skills assessment for a potential new job in Laravel - if I wasn't using Laravel I would've been done hours ago, but one of the requirements is Laravel. Honestly, for the most part I dig it - it's pretty simple, despite it's reliance on magic. Anyway, I've written a couple API routes and when I visit them in the browser everything works exactly as expected and desired. However, when I run the pre-built test file, I get a Symfony\Component\HttpKernel\Exception\NotFoundHttpException for /var/www/html/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php. The route as defined in api.php: use App\Http\Controllers\User; /** * I tried using a Resource Collection here - there's obviously something about those * that I'm missing, because it actively refused to do anything worthwhile. I'd pass in * UserModel::with('timelogs')->get() like I use in \App\Http\Controllers\User::getTotalSeconds(), * and it didn't care. Just printed out absolute garbage, no matter what I fed to it. */ Route::get('/user-timelogs', function(Request $request) { $u = new User; return $u->getTotalSeconds(); }); And the controller code: namespace App\Http\Controllers; use Illuminate\Http\Request; use App\User as UserModel; class User extends Controller public function getTotalSeconds() { $users = UserModel::with('timelogs')->get(); $ret = []; foreach($users as $user){ array_push($ret, [ 'user_id' => $user->id, 'seconds_logged' => $this->calculateTime($user->timelogs) ]); }; return json_encode($ret); } private function calculateTime($logs) { $totalTime = 0; foreach($logs as $log){ $totalTime += $log->seconds_logged; } return $totalTime; } } The model file for good measu namespace App; use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'email', 'password', 'id', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'password', 'remember_token', ]; /** * The attributes that should be cast to native types. * * @var array */ protected $casts = [ 'email_verified_at' => 'datetime', ]; public function timelogs() { return $this->hasMany('App\Timelog'); } } Again, when I visit localhost/api/user-timelogs, the user IDs and correct total of seconds is right there. It's just in the test file that it's an issue. Anybody have any ideas? Edited September 21, 2019 by maxxdwas totally not done typing... I'm very new to MVC and I'm trying to figure out how to transition my code and I'm not sure where to place things. It easy to want to just put everything in the view, but I know that doesn't make sense. Can you please guide me on how I should transition the rest of my code for my header? I'm currently using codeigniter. Current View Code: [Select] <?php $page = substr(end(explode(DIRECTORY_SEPARATOR, $_SERVER['PHP_SELF'])), 0, -4); $title = (array_key_exists($page, $page_names) !== false) ? $page_names[$page]: ''; if (array_key_exists($page, $page_names) !== false) { $title .= " | Jason Biondo"; } $banner_imgs = array('contact.jpg', 'about.jpg', 'tools.jpg', 'portfolio.jpg', 'articles.jpg'); $nav_names = array('Contact', 'About', 'Tools', 'Portfolio', 'Articles'); $gutter_values = array('307', '230', '161', '84', '0'); $alt_page = 'Articles'; foreach($nav_names as $k => $name) { if($page === strtolower($name)) { $g_value = $gutter_values[$k]; } } if(!isset($g_value)) { $g_value = 0; } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" dir="ltr"> <head> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="content-script-type" content="text/javascript" /> <meta http-equiv="content-style-type" content="text/css" /> <meta http-equiv="content-language" content="en" /> <meta name="description" content="Jason is a serial entrepreneur that builds web applications using advanced programming technologies and unique interface design." /> <meta name="keywords" content="jason , entrepreneur, investors, venture capitalist, angel investor, vc, ventures, private equity, startups, startup community, startup investments, investment network, raise capital, where to find capital, fund raising, venture financing, contact investors, angel fund, angel group, investment strategy, business plan" /> <title><?=$title?></title> <link rel="shortcut icon" type="image/x-icon" href="/assets/img/favicon.ico" /> <link rel="stylesheet" type="text/css" media="screen" href="/css/style.css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script src="./js/jquery.validate.min.js"></script> <script src="./js/jquery.corner.js"></script> <script src="./js/init.js"></script> <?php if (file_exists("./assets/js/pages/${page}.js")) { echo "<script type=\"text/javascript\" src=\"./js/pages/${page}.js\"></script>"; } ?> </head> <body> <div class="header"> <div class="header_container"> <a href="/"> <img class="logo" src="/assets/img/logo.png" alt="Jason" title="Jason" /> </a> <div class="navigation f_right"> <div class="gutter"> <span id="nav_highlight" class="nav_highlight" style="left: <?php echo $g_value; ?>px;"></span> </div> <ul> <?php foreach($nav_names as $k => $name) { if(is_odd($k)) { ?> <li class="pike"></li> <?php } ?> <li> <a id="<?php echo strtolower($name); ?>" <?php echo (($page === strtolower($name)) || ($alt_page === $name)) ? 'class="selected"' : ''; ?> href="/<?php echo ($name === $alt_page) ? '' : strtolower($name); ?>"><?php echo $name; ?></a> </li> <?php if(is_odd($k)) { ?> <li class="pike"></li> <?php } } ?> </ul> </div> </div> </div> <div class="stripe"></div> <div id="content_container" class="content_container"> <div id="banner" class="banner"> <?php foreach($nav_names as $k => $name) { if(($page === strtolower($name)) || ($alt_page === $name)) { ?> <img src="/assets/img/banners/<?php echo $banner_imgs[$k]; ?>" /> <h1><?php echo $name; ?></h1> <?php break; } if($alt_page === $name) { ?> <img src="/assets/img/banners/<?php echo $banner_imgs[$k]; ?>" /> <h1><?php echo $name; ?></h1> <?php } } ?> </div> <div class="banner_stripe"></div> <div class="content"> Current Controller Code: [Select] <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Writing extends CI_Controller { public function index() { $this->load->library('common'); $data['page_names'] = $this->common->page_names(); $data['is_odd'] = $this->common->is_odd(); $this->load->view('includes/header', $data); $this->load->view('writing_view'); $this->load->view('includes/footer'); $this->output->enable_profiler(TRUE); } } This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=306553.0 I'm using this struture to run my application, everything works fine, but i don't like how the controllers are called. If i load the model in construct it will work great again, but i think that is unnecessary. You can see two pieces of code about controller "Post.php", the last one, works great. If i try this: (Posts.php) namespace app\controllers; use app\libraries\Controller; use app\models\User; class Posts extends Controller { public function index():void { //Get posts $user = new User(); $posts = $user->posts(); $data = [ 'posts' => $posts ]; $this->view('posts/index', $data); } } I will get an error: QuoteFatal error: Uncaught Error: Class 'app\models\User' not found in C:\xampp\htdocs\shake\app\controllers\Posts.php Structu Quote
- app bootstrap.php //include all files from libraries require_once __DIR__ . "/../vendor/autoload.php"; index.php use app\libraries\Core; require_once '../app/bootstrap.php'; //Init Core Library $init = new Core(); core.php public function __construct(){ $url = $this->getUrl(); //Look in controllers for first value if(file_exists(dirname(__FILE__, 2) . '/controllers/' . ucwords($url[0]) . '.php')){ //if exists, set as controller $this->currentController = ucwords($url[0]); //Unset 0 index unset($url[0]); } //Require the controller require_once dirname(__FILE__, 2) . '/controllers/' . $this->currentController . '.php'; //instantiate controller class $class = 'app\\controllers\\' . $this->currentController; $this->currentController = new $class; //check for second part of url if(isset($url[1])){ //Check to see if method exists in controller if(method_exists($this->currentController, $url[1])){ $this->currentMethod = $url[1]; //Unset 1 index unset($url[1]); } } //Get params $this->params = $url ? array_values($url) : []; //Call a callback with array of params call_user_func_array([$this->currentController, $this->currentMethod], $this->params); } Posts.php class Posts extends Controller { public function __construct() { $this->userModel = $this->model('User'); $this->postModel = $this->model('Post'); } public function index():void { //Get posts $posts = $this->userModel->posts(); $data = [ 'posts' => $posts ]; $this->view('posts/index', $data); } } Controller.php abstract class Controller { /** * Load model * @param $model * @return mixed */ public function model($model) { //Require model file require_once '../app/models/' . $model . ".php"; //instantiate model $class = 'app\models\\' . $model; return new $class(); }
How can I make my PHP script non accessible to users? I am wanting to cron the script and don't want anybody to spam the script as it would cause performance issues if it was constantly spammed by a user. Can I put the PHP file anywhere that only the server can run it?
Thanks any info would be awesome.
Hi Guys I need a PHP function to which I pass two postcodes and it works out the road distance, I dont mind using google or any other API I have managed to fing JS ways and php functions using crow route but I really really need a traffic distance in PHP Please advice, Help Thank you Ok, first let me tell you what I want to do. Google sends me traffic from many keywords, but I want to track what keyword does best for me as sales and so. The Analytics is good but I can't send the data to outside sites. So I figured this out : from the $_SERVER['HTTP_REFERER'] I can get the "q" value from the _GET and pass it on to track it... now I'm kind of stuck and I know it's easy but can't seem to find the function. This is what I have so far: /* Code to try and store the keyword that was used to find and land on my site. */ $exurl = 'http://www.google.ca/url?sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ'; //set a demo refferer url that would usually be $exurl = $_SERVER['HTTP_REFERER'] $refurl = parse_url($exurl, PHP_URL_QUERY); // remove all before and including the "?" echo $refurl; // echo "sa=t&source=web&cd=1&ved=0CBYQFjAA&rct=j&q=mykeyword&ei=pJ2STMy8MsP-8AaqvuznBQ" Ok, so I managed to get the important part out of the google URL, now how do I split this into an array that I can then use. For instance somefunction($refurl, $newarray); and then I could say | echo $newarray['q']; | and it would echo "mykeyword" Of course If there is a space in the keywords I should use the urldecode() function to avoid the % char... Let me know if you know of any way to get this done. Moving an application from one server and domain to another. Have updated all references that I can find to the old url and db. Mirrored all permissions, etc. Am getting the following notice: Notice (8): Undefined index: CakeCookie [APP/config/bootstrap.php, line 47] $user_preferred_city = ''; // Checking whether user has already visited our site $user_preferred_city = $_COOKIE['CakeCookie']['signup_city_name']; $boot = true $shellPaths = null $localePaths = null $vendorPaths = null $pluginPaths = null $helperPaths = null $viewPaths = null $componentPaths = null $controllerPaths = null $behaviorPaths = null $modelPaths = null $user_preferred_city = "" $user_preferred_city = ''; // Checking whether user has already visited our site $user_preferred_city = $_COOKIE['CakeCookie']['signup_city_name']; include - APP/config/bootstrap.php, line 47 Configu :__loadBootstrap() - CORE/cake/libs/configure.php, line 660 Configu :getInstance() - CORE/cake/libs/configure.php, line 137 include - CORE/cake/bootstrap.php, line 43 [main] - APP/webroot/index.php, line 81 What should I look for to resolve this? Am new to PHP and more of a dba than anything, so I a really appreciate any help you can offer. Thanks! This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=318251.0 Hi I will try and explain this as best I can, as I am not sure if the "include" is causing the problem. What I am trying to achieve is count the total number of vehicles in the "vehicles" db table and pass it to views (I have recently moved over to MVC so still learning so please be kind and keep it simple for me please) I have a folder in views called "vehicletracker" , within this folder I have 2 files "index.php" and "widget.php".........The "widget.php" file is an "include" within "index php". The problem I am having is passing data from the controller to the view, I keep getting an "Undefined index: total" error and wonder if someone can help and show me where I am going wrong. This is my Model
<?php class Widget { private $db; public function __construct(){ $this->db = new Database; } public function countVehicles(){ $this->db->query("SELECT * FROM vehicles"); return $this->db->rowCount(); } } This is my controller
<?php class Widgets extends Controller{ public function __construct(){ $this->widgetModel = $this->model('Widget'); public function widget (){ $data['total'] = $this->widgetModel->countVehicles(); $this->view('vehicletracker/widget', $data); } } And my view
<h2 class="text-white"><?php echo $data['total']; ?></h2>
Thanks in advance for any help you can give |