LC Script in PHP File

jbv at souslelogo.com jbv at souslelogo.com
Sun Nov 23 03:23:23 EST 2014


Hi
You can also use the curl function if your LC script is located on a server :

  $data = 'http://myDomain/lc/myLCscript.lc?a=' . $myVar;

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $output = curl_exec($ch);
  curl_close($ch);

I use this method very often in my php scripts and find it very easy to
maintain.

Best
jbv


> Hi,
>
> I am in the process of putting a web app together using the UserFrosting
> system as a starting point.
> I am slowly getting the hang of the framework and am now wishing to start
> using LC Server to do some backend crunching to render the pages. (Im not
> picking up PHP as fast as I hoped!)
>
> The UserFrosting system bases all of its page contents in PHP Files by
> design.
>
> For example the index file is index.php
>
> My question is, am I able to call LC functions from within a PHP file?
>
> For example, in the below page (which is a PHP file)
> Red content...
>
> <?php
> /*
>
> UserFrosting Version: 0.2.1 (beta)
> By Alex Weissman
> Copyright (c) 2014
>
> Based on the UserCake user management system, v2.0.2.
> Copyright (c) 2009-2012
>
> UserFrosting, like UserCake, is 100% free and open-source.
>
> Permission is hereby granted, free of charge, to any person obtaining a
> copy
> of this software and associated documentation files (the 'Software'), to
> deal
> in the Software without restriction, including without limitation the
> rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
> THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
>
> */
>
> require_once("../models/config.php");
>
> if (!securePage(__FILE__)){
>   // Forward to index page
>   addAlert("danger", "Whoops, looks like you don't have permission to view
> that page.");
>   header("Location: 404.php");
>   exit();
> }
>
> setReferralPage(getAbsoluteDocumentPath(__FILE__));
>
> ?>
>
> <!DOCTYPE html>
> <html lang="en">
>   <?php
>       echo renderAccountPageHeader(array("#SITE_ROOT#" => SITE_ROOT,
> "#SITE_TITLE#" => SITE_TITLE, "#PAGE_TITLE#" => "Whiteboard"));
>   ?>
>
>   <body>
>
>     <div id="wrapper">
>
>       <!-- Sidebar -->
>        <?php
>           echo renderMenu("whiteboard");
>         ?>
>       <div id="page-wrapper">
>         <div class="row">
>           <div class="col-lg-12">
>             <h1>Whiteboard <small>Idea's register</small></h1>
>             <ol class="breadcrumb">
>               <li class="active"><i class="fa fa-home"></i>
> Whiteboard</li>
>             </ol>
>             <div class="alert alert-success alert-dismissable">
>               <button type="button" class="close"  data-dismiss="alert"
> aria-hidden="true">×</button>
>               A place for use to explore idea's between the group. Kind of
> like a contained forum for our idea's.
>             </div>
>           </div>
>         </div><!-- /.row -->
>     <div class="row">
>           <div id='display-alerts' class="col-lg-12">
>           </div>
>         </div>
>
> <!-- Button trigger modal -->
> <button type="button" class="btn btn-primary btn-lg" data-toggle="modal"
> data-target="#myModal">
>   List Idea
> </button>
>
> <!-- Modal -->
> <div class="modal fade" id="myModal" tabindex="-1" role="dialog"
> aria-labelledby="myModalLabel" aria-hidden="true">
>   <div class="modal-dialog">
>     <div class="modal-content">
>       <div class="modal-header">
>         <button type="button" class="close" data-dismiss="modal"><span
> aria-hidden="true">×</span><span
> class="sr-only">Close</span></button>
>         <h4 class="modal-title" id="myModalLabel">Modal title</h4>
>       </div>
>       <div class="modal-body">
> <?lc
> put "<H1>hello world</H1>"
> ?>
>       </div>
>       <div class="modal-footer">
>         <button type="button" class="btn btn-default"
> data-dismiss="modal">Close</button>
>         <button type="button" class="btn btn-primary">Save idea</button>
>       </div>
>     </div>
>   </div>
> </div>
>
>       </div><!-- /#page-wrapper -->
>
>     </div><!-- /#wrapper -->
>
>
> </html>
> COPYRIGHT / DISCLAIMER: This message and/or including attached files may
> contain confidential proprietary or privileged information. If you are not
> the intended recipient, you are strictly prohibited from using,
> reproducing, disclosing or distributing the information contained in this
> email without authorisation from WesTrac. If you have received this
> message in error please contact WesTrac on +61 8 9377 9444. We do not
> accept liability in connection with computer virus, data corruption,
> delay, interruption, unauthorised access or unauthorised amendment. We
> reserve the right to monitor all e-mail communications.
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>





More information about the use-livecode mailing list