Beispiel #1
0
    ?>
">
        </a>

        <?php 
    if (isAdmin()) {
        ?>
            <form class="form form-horizontal well" action="<?php 
        echo $config['url'];
        ?>
/update" method="post">
                 <div class="form-group">
                    <label for="image" class="col-sm-2 control-label">Bildes URL</label>
                    <div class="col-sm-10">
                        <input type="text" id="image" class="form-control" name="image" value="<?php 
        echo protocolRelativeUrl($perle->image, true);
        ?>
" placeholder="Bildes URL">
                    </div>
                </div>
                
               <div class="form-group">
                    <label for="description" class="col-sm-2 control-label">Apraksts</label>
                    <div class="col-sm-10">
                        <textarea type="text" id="description" class="form-control" name="description" placeholder="Bez apraksta"><?php 
        echo $perle->description;
        ?>
</textarea>
                    </div>
                </div>
Beispiel #2
0
                $ext = explode('.', $f['name']);
                $ext = end($ext);
                $dir = getcwd() . '/assets/images/';
                $filePath = $dir . strtotime($date) . '.' . $ext;
                umask(0);
                move_uploaded_file($image, $filePath);
                // Just to keep stuff consistent, I'm replacing image with the relative url to the image.
                $image = $config['url'] . '/assets/images/' . basename($filePath);
            } else {
                $_SESSION['message'] = 'Attela augšupielādes kļūda. Attelam jābūt mazakam par ' . $maxsize . 'mb.';
            }
            /**
             * Save the image in the database
             */
            $perle = ORM::forTable('perles_posts')->create();
            $perle->image = protocolRelativeUrl($image);
            $perle->description = htmlspecialchars($description);
            $perle->active = $setToActive && isAdmin() ? 1 : 0;
            $perle->ip = $_SERVER['REMOTE_ADDR'];
            $perle->setExpr('created', 'NOW()');
            $perle->save();
            $_SESSION['message'] = $setToActive && isAdmin() ? 'Attēls pievienots.' : 'Attēls pievienots apskatīšanai.';
        } else {
            $_SESSION['message'] = 'Tas nav attēls.';
        }
    }
    redirect($config['url'] . '/' . $view);
}
$config['title-affix'] = "Iesūti savu bildi";
require 'layout/header.php';
?>