Example #1
0
 public function mysql_save_from_post($post)
 {
     foreach ($post as $pk => $pv) {
         foreach (get_object_vars($this) as $ok => $ov) {
             if ($pk == $ok) {
                 $this->{$ok} = $pv;
             }
         }
     }
     $lid = $this->mysql_save();
     $this->id = $lid;
     if (isset($post['buttons'])) {
         foreach ($this->get_ItemButtons() as $button) {
             if (!in_array($button->name, $post['buttons'])) {
                 $button->mysql_delete();
             }
         }
         for ($i = 0; $i < count($post['buttons']); $i++) {
             $name = $post['buttons'][$i];
             $function = $post['functions'][$i];
             if ($name == "") {
                 continue;
             }
             $button = $this->get_Button($name);
             if ($button == null) {
                 $button = new ItemButton();
                 $button->id = 0;
             }
             $button->function = $function;
             $button->Item_id = $lid;
             $button->name = $name;
             $button->mysql_save();
         }
     }
     $default_btn = ItemButton::from_property(array("name" => $post["default_btn_name"], "Item_id" => $post["oid"]), false);
     if ($default_btn != null) {
         $this->default_Button_id = $default_btn->id;
     } else {
         $this->default_Button_id = 0;
     }
     $this->hash = $this->calculate_hash();
     $this->mysql_save();
     return $lid;
 }
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
if (!isset($ini)) {
    require_once '../model/Ini.php';
    $ini = new Ini();
}
if (isset($_POST['hash'])) {
    $item = Item::from_hash($_POST['hash']);
} else {
    $item = null;
}
$sid = User::initialize_session();
$variables = array();
foreach ($_POST as $k => $v) {
    ItemButton::insert_rout_variable($sid, mysql_real_escape_string($k), mysql_real_escape_string($v));
    $variables[$k] = $v;
}
ItemButton::insert_rout_variable($sid, 'template_id', mysql_real_escape_string($item->id));
$variables["template_id"] = $item->id;
ItemButton::insert_rout_variable($sid, 'SessionID', $sid);
$variables['SessionID'] = $sid;
ItemButton::insert_rout_variable($sid, 'IP', $_SERVER['REMOTE_ADDR']);
$variables['IP'] = $_SERVER['REMOTE_ADDR'];
ItemButton::insert_rout_variable($sid, 'browser', $_SERVER["HTTP_USER_AGENT"]);
$variables['browser'] = $_SERVER["HTTP_USER_AGENT"];
echo json_encode($variables);