Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 3 4 [5] 6 7 ... 10
 41 
 on: June 25, 2014, 03:33:17 PM 
Started by pitabuddha - Last post by pitabuddha
Here is the code that I have. My php skill's are pretty limited. I can usually hack some stuff together but this one has me stuck.

function contact() {
    if (!isset($_POST['contactform'])) {
   $_SESSION[_SITE.'time'] = $time = time();
   echo
   '<div class="commentsbox"><h2>'.l('contact').'</h2>
   <p><em>'.l('required').'</em></p>
   <form method="post" action="'._SITE.'" id="post" accept-charset="UTF-8">
   <p><label for="name"><span class="required">*</span> ',l('name'),'</label>:<br />
   <input type="text" name="name" id="name" maxlength="100" class="text" value="" /></p>
   <p><label for="email"><span class="required">*</span> ',l('email'),'</label>:<br />
   <input type="text" name="email" id="email" maxlength="320" class="text" value="" /></p>
   <p><label for="weblink">',l('url'),'</label>:<br />
   <input type="text" name="weblink" id="weblink"  maxlength="160" class="text" value="" /></p>
   
         <select name="budget">
         <option value="">*Budget</option>
              <option value="Less than $1,000">Less than $1,000</option>
              <option value="$1,000 - $3,000">$1,000 - $3,000</option>
              <option value="$3,000 - $6,000">$3,000 - $6,000</option>
              <option value="$6,000 - $10,000">$6,000 - $10,000</option>
              <option value="Just saying hello!">Just saying hello!</option>
         </select>

   
   <p><label for="message"><span class="required">*</span> ',l('message'),'</label>:<br />
   <textarea name="message" rows="5" cols="5" id="message"></textarea></p>
   ',mathCaptcha(),'
   <p><input type="hidden" name="ip" id="ip" value="',$_SERVER['REMOTE_ADDR'],'" />
   <input type="hidden" name="time" id="time" value="',time(),'" />
   <input type="submit" name="contactform" id="contactform" class="button" value="',l('submit'),'" /></p>
   </form>
   </div>';

   } elseif( isset( $_SESSION[_SITE.'time'] ) ) {
      $count = $magic = 0;
      if( get_magic_quotes_gpc() ){ $magic = 1; }
      foreach($_POST as $k => $v){
      if($count === 8 ) die;
      if( $magic ) $$k = stripslashes($v);
      else $$k = $v;
      ++$count;
      }
      $to = s('website_email');
      $subject = s('contact_subject');

      $name = (isset($name[0]) && ! isset($name[300]) ) ? trim($name) : null;
      $name = ! preg_match('/[\\n\\r]/', $name) ? $name : die;

      $mail = (isset($email[6]) && ! isset($email[320]) ) ? trim($email) : null;
      $mail = ! preg_match('/[\\n\\r]/', $mail) ? $mail : die;

      $url = (isset($weblink[4]) && ! isset($weblink[160]) ) ? trim($weblink) : null;
      $url = ( strpos($url, '?') === false && ! preg_match('/[\\n\\r]/', $url)) ? $url : null;
      
      $budget = isset($_POST["budget"]) ? $_POST["budget"] : null;
            
      
      $message = (isset($message[10]) && ! isset($message[6000]) ) ? strip_tags($message) : null;
      $time = ( isset($_SESSION[_SITE.'time']) && $_SESSION[_SITE.'time'] === (int)$time && (time() - $time) > 10) ? $time : null ;
      if ( isset($ip) && $ip === $_SERVER['REMOTE_ADDR'] && $time
      && $name && $mail && $message && checkMathCaptcha()) {
         unset($_SESSION[_SITE.'time']);
         echo notification(0,l('contact_sent'),'home');
         $send_array = array(
            'to'=>$to,
            'name'=>$name,
            'email'=>$mail,
            'budget'=>$budget,
            'message'=>$message,
            'ip'=>$ip,
            'url'=>$url,
            'subject'=>$subject);
         send_email($send_array);
      } else {
         echo notification(1,l('contact_not_sent'),'contact');
      }
   }
}

 42 
 on: June 24, 2014, 10:37:58 PM 
Started by nukpana - Last post by nukpana
Wow, it's really been some time between postings.  I am still slowly working on this idea, streamlining and updating code. Some changes are as follows:
 - using PHP 5.5 for the password function - http://www.php.net/manual/en/function.password-hash.php and https://php.net//manual/en/function.password-verify.php
 - using Composer for it's autoloader instead of copying the PSR exmaple code
 - started using git for a move to github later on
 - removed unneded code & classes ie Addon class, Options::init(), etc.
  - etc., etc.

Let's take a peek at some code.

Before I noted about the Extension/Plugin code. Again, this has streamlined even further and accomplished almost all of the todo list from before:
Quote
TO DO:
 - What is to be added for Extensions->process, is a true switch for activate w/install, activate w/o install, deactivate w/o uninstall & uninstall.  Still trying to think that one out, but for now...  This class maybe getting heavier IMO and I will need to refactor it some...

 - Next is the PSR-0 autoloader.  For a plugin, this means the each plugin file structure looks like this:
app/ext/
app/ext/Test
app/ext/Test/plugin.ini
app/ext/Test/Plugin/Test.php (example for install/uninstall routine)
app/ext/Test/Plugin/Callback.php (example for hook callback)

I would like to remove that extra folder for the namespace (Plugin\Class === Plugin/Class.php).
- Activation, install, deactivation, reactivation, uninstall are now implemented.  The class may be merged into the core Plugin code, but for now, it's an Admin class.  What is needed is a warning to be sent when a plugin is not loaded due to dependency issues.
Code: [Select]
<?php

    
namespace Core\Admin;

    use 
Core\Plugin;

    final class 
PluginProcess
    
{
        private
            
$_plugin;

        function 
process($str) {
            list(
$action$plugin) = explode('_'$str);

            
$this->_plugin = new \Core\Plugin($plugin);

            
$class '';
            
$state $this->_plugin->getState();

            
# For an active state, the plugin has already been loaded
            
if ( $state ) {
                
$class $this->_plugin->getNamespace() . $plugin;
                if ( 
class_exists($class) ) {
                    
$class = new $class;
                }
            }

            switch (
$action) {
                case (
'activate'):
                case (
'reactivate'):
                    if ( 
$this->_plugin->meetsDependencies() ) {

                        switch (
true) {
                            case (   
$action == 'activate'
                                  
&& $state  == ''
                            
):
                                
$this->_plugin->set();

                                
$class $this->_plugin->getNamespace() . $plugin;
                                if ( 
class_exists($class) && method_exists($class'install') ) {
                                    
$class = new $class;
                                    
$class->install();
                                }
                            break;
                            case (   
$action == 'reactivate'
                                  
&& $state  == 'deactive'
                            
):
                                if ( 
method_exists($class'reactivate') ) {
                                    
$class->reactivate();
                                }
                            break;
                        }

                        
$this->_plugin->setState('active');
                    } else {
                        
// Set a warning that dependencies are not met
                        
$this->_plugin->delete();
                    }
                break;
                case (
'deactivate'):
                    if ( 
$state =='active' && method_exists($class'deactivate') ) {
                        
$class->deactivate();
                    }

                    
$this->_plugin->setState('deactive');
                break;
                case (
'uninstall'):
                    if( 
method_exists($class'uninstall') ) {
                        
$class->uninstall();
                    }

                    
$this->_plugin->delete();
                break;
            }
        }
    }


The code for a plugin can look like this:
Code: [Select]
<?php

    
namespace Plugin;

    class 
Test {
        function 
__construct() {
            echo 
__CLASS__ ' is loaded!!<br>';
        }

        function 
install() {
            echo 
'Installing '.__CLASS__.' Plugin!!!';
        }

        function 
reactivate() {
            echo 
'Reactivating the '.__CLASS__.' Plugin!!!';
        }

        function 
deactivate() {
            echo 
'Deactivating the '.__CLASS__.' Plugin!!!';
        }

        function 
uninstall() {
            echo 
'Uninstalling '.__CLASS__.' Plugin!!!';
        }
    }

Then, our main code in the index file looks like this - you can see Composer's autoloader in action as well
Code: [Select]
    function listAllPlugins() {
        $list = [];
        $dir = opendir(EXT_PATH);
        if ( $dir ) {
            while( false !== ($ext = readdir($dir)) ) {
                $plugin = new Core\Plugin($ext);
                $file = $plugin->requiredFiles();

                if (   $file != '.'
                    && $file != '..'
                    && file_exists($file['ini'])
                ) {
                    $list[$ext] = $plugin->data($file['ini']);

                    if ( $plugin->isActive() ) {
                        $list[$ext]['active'] = true;
                    }
                }
            }
        }
        return $list;
    }

    $list = listAllPlugins();
    foreach ($list as $plugin =>$v) {
        $Plugin = new Core\Plugin($plugin);
        $loader = require 'vendor/autoload.php';
        $loader->addPsr4($Plugin->getNamespace(), EXT_PATH . '/' . $plugin);

        if ($Plugin->isActive()) {
            if( !$Plugin->meetsDependencies() ) {
                $Plugin->delete();
            }

            $Plugin->load();
        }
    }
Then the admin function could look like this:
Code: [Select]
    function AdminPluginList()
    {
        $array = [];

        $list = listAllPlugins();

        foreach ( $list as $k => $v ) {
            $info = [];
            $Plugin = new Core\Plugin($k);

            $active = isset($v['active']) ? true : false;

            $state = $Plugin->getState();

            $activate = 'activate';
            if ($state == 'active') {
                $activate = 'deactivate';
            } elseif ($state == 'deactive') {
                $activate = 'reactivate';
            }

            if ( isset($v['plugin.information'] )) {
                $info = $v['plugin.information'];
            }
            $array[] = [
                'active' => $active,
                'alt'    => ucfirst($activate),
                'link'   => URIBASE . 'admin/plugin/process/' . $activate .'_'. $k,
                'uninstall_link' => URIBASE . 'admin/plugin/process/uninstall_' . $k,
                'title'  => $k,
                'info'   => $info,
                'state'  => $state
            ];
        }

        return $array;
    }

 - If you haven't noticed, the PSR 0 code has been updated to use PSR 4, so we dont need an extra folder due to the namespace
 - Additionally, the plugins now maintain a state - active or deactive or none (not active or installed). Good for a safe mode like scenario (disable all plugins)

Right now, there is still more streamlining of the actual framework and needing to separate the framework from the test app/cms....

EDIT - updated code

 43 
 on: June 24, 2014, 10:32:18 PM 
Started by pitabuddha - Last post by nukpana
Usually you would post the code you have so someone can proof and advise what is the issue.

A drop down is a simple html <select name="?"> and <option value="?">.  On submit of the form, you have the $_POST variable that you named.

 44 
 on: June 24, 2014, 03:11:19 PM 
Started by pitabuddha - Last post by pitabuddha
I'm trying to add a drop down select option with hard coded values to the contact form but can't seem to make it work. Any help would be appreciated.

 45 
 on: June 24, 2014, 02:32:03 AM 
Started by Fred K - Last post by Fred K
Hi Tropy,
Sorry for the inconvenience - I redid the site a while back when I was working on my sNews fork. You can find the dark version here: http://frdk.com/old/themes/freebies/inverted17.zip (ZIP archive, ~4.9 Kb). I'll change the DL link in the OP as well.
Cheers.

 46 
 on: June 23, 2014, 07:43:02 PM 
Started by Tropy - Last post by Keyrocks
I never heard of this before, sorry.

 47 
 on: June 22, 2014, 10:14:18 PM 
Started by Tropy - Last post by Tropy
Hy guys tryed the memu version and locally testeed on xampp windows

cant logout even have to selfe destroy the cooki!!!

has any one same or solved!?

 48 
 on: June 22, 2014, 01:20:17 AM 
Started by Fred K - Last post by Tropy
No download under this adress may be you ar working on your site????!

 49 
 on: June 22, 2014, 12:58:30 AM 
Started by Tropy - Last post by Tropy
same as you and the post describe! may work on an actually tut for memu next times!
 
have only one prob when i edit the text and klick on the button say: Bold nothing happens to see

but if i hit the tool hint ctrl+B then i can see! all buttons didnt have functions!

may be a failure by me did you have a Hint?

Quote
may be a failure by me did you have a Hint? YEEEES

Played to mutch with the tinymce js files inserted the original ones now works!!

 50 
 on: June 20, 2014, 04:51:05 PM 
Started by Tropy - Last post by Keyrocks
Thanks a lot That helps! but found it in my mind and in some files! ;-)

 ;D  ;D  ;D
Please post an update here to let everyone know how it worked out.

Pages: 1 ... 3 4 [5] 6 7 ... 10